Commit 4fa77346 authored by Camilo Higuita's avatar Camilo Higuita

initial work with kirigami

parent 61503097
QT += quick
QT += quick multimedia sql
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
......@@ -12,7 +12,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp
SOURCES += main.cpp \
db/collectionDB.cpp
RESOURCES += qml.qrc
......@@ -28,3 +29,7 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES +=
HEADERS += \
db/collectionDB.h \
utils/bae.h
This diff is collapsed.
#ifndef COLLECTIONDB_H
#define COLLECTIONDB_H
#include <QString>
#include <QStringList>
#include <QList>
#include <QSqlDatabase>
#include <QDebug>
#include <QSqlQuery>
#include <QSqlError>
#include <QSqlRecord>
#include <QSqlDriver>
#include <QFileInfo>
#include <QDir>
#include <QVariantMap>
#include "../utils/bae.h"
enum sourceTypes
{
LOCAL, ONLINE, DEVICE
};
class CollectionDB : public QObject
{
Q_OBJECT
public:
explicit CollectionDB(QObject *parent = nullptr);
~CollectionDB() override;
bool execQuery(QSqlQuery &query) const;
bool execQuery(const QString &queryTxt);
/*basic public actions*/
void prepareCollectionDB() const;
bool check_existance(const QString &tableName, const QString &searchId, const QString &search);
/* usefull actions */
void insertArtwork(const BAE::DB &track);
void addTrack(const BAE::DB &track);
bool updateTrack(const BAE::DB &track);
bool rateTrack(const QString &path, const int &value);
bool babeTrack(const QString &path, const bool &value);
bool moodTrack(const QString &path, const QString &value);
bool artTrack(const QString &path, const QString &value);
bool lyricsTrack(const BAE::DB &track, const QString &value);
bool playedTrack(const QString &url, const int &increment = 1);
bool wikiTrack(const BAE::DB &track, const QString &value);
bool tagsTrack(const BAE::DB &track, const QString &value, const QString &context);
bool albumTrack(const BAE::DB &track, const QString &value);
bool trackTrack(const BAE::DB &track, const QString &value);
bool wikiArtist(const BAE::DB &track, const QString &value);
bool tagsArtist(const BAE::DB &track, const QString &value, const QString &context = "");
bool wikiAlbum(const BAE::DB &track, QString value);
bool tagsAlbum(const BAE::DB &track, const QString &value, const QString &context = "");
bool addPlaylist(const QString &title);
bool trackPlaylist(const QString &url, const QString &playlist);
BAE::DB_LIST getDBData(const QStringList &urls);
BAE::DB_LIST getDBData(const QString &queryTxt);
BAE::DB_LIST getAlbumTracks(const QString &album, const QString &artist, const BAE::KEY &orderBy = BAE::KEY::TRACK, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getArtistTracks(const QString &artist, const BAE::KEY &orderBy = BAE::KEY::ALBUM, const BAE::W &order = BAE::W::ASC);
BAE::DB_LIST getBabedTracks(const BAE::KEY &orderBy = BAE::KEY::PLAYED, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getSearchedTracks(const BAE::KEY &where, const QString &search);
BAE::DB_LIST getPlaylistTracks(const QString &playlist, const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getMostPlayedTracks(const int &greaterThan = 1,const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::PLAYED, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getFavTracks(const int &stars = 1,const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::STARS, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getRecentTracks(const int &limit = 50, const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
BAE::DB_LIST getOnlineTracks(const BAE::KEY &orderBy = BAE::KEY::ADD_DATE, const BAE::W &order = BAE::W::DESC);
QString getTrackLyrics(const QString &url);
QString getTrackArt(const QString &path);
QStringList getTrackTags(const QString &path);
int getTrackStars(const QString &path);
int getTrackBabe(const QString &path);
QString getArtistArt(const QString &artist);
QString getArtistWiki(const QString &artist);
// QStringList getArtistTags(const QString &artist);
QString getAlbumArt(const QString &album, const QString &artist);
QString getAlbumWiki(const QString &album, const QString &artist);
// QStringList getAlbumTags(const QString &album, const QString &artist);
QStringList getArtistAlbums(const QString &artist);
QStringList getPlaylists();
bool removePlaylistTrack(const QString &url, const QString &playlist);
bool removePlaylist(const QString &playlist);
bool removeArtist(const QString &artist);
bool cleanArtists();
bool removeAlbum(const QString &album, const QString &artist);
bool cleanAlbums();
bool removeSource(const QString &path);
bool removeTrack(const QString &path);
QSqlQuery getQuery(const QString &queryTxt);
/*useful tools*/
sourceTypes sourceType(const QString &url);
void openDB(const QString &name);
private:
QString name;
QSqlDatabase m_db;
/*basic actions*/
bool insert(const QString &tableName, const QVariantMap &insertData);
bool update(const QString &tableName, const BAE::DB &updateData, const QVariantMap &where);
bool update(const QString &table, const QString &column, const QVariant &newValue, const QVariant &op, const QString &id);
bool remove();
public slots:
void closeConnection();
/*useful*/
signals:
void trackInserted();
void artworkInserted(const BAE::DB &albumMap);
void DBactionFinished();
void albumsCleaned(const int &amount);
void artistsCleaned(const int &amount);
};
#endif // COLLECTION_H
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QFontDatabase>
#include "db/collectionDB.h"
int main(int argc, char *argv[])
{
......@@ -9,6 +10,9 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
QFontDatabase::addApplicationFont(":/utils/materialdesignicons-webfont.ttf");
qmlRegisterType<CollectionDB>("org.babe.qml", 1, 0, "CON");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
......
......@@ -2,113 +2,227 @@ import QtQuick 2.9
import QtQuick.Controls 2.2
import QtLocation 5.9
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import org.kde.kirigami 2.0 as Kirigami
import "utils/Icons.js" as MdiFont
import "utils"
import "view_models"
import "widgets"
ApplicationWindow
Kirigami.ApplicationWindow
{
id: root
visible: true
width: 400
height: 500
title: qsTr("Babe")
property int defaultColumnWidth: Kirigami.Units.gridUnit * 13
property int columnWidth: defaultColumnWidth
property int currentView : 0
pageStack.defaultColumnWidth: columnWidth
pageStack.initialPage: [playlist, views]
header: BabeBar
{
id: mainToolbar
visible: true
currentIndex: swipeView.currentIndex
currentIndex: currentView
onTracksViewClicked: swipeView.currentIndex = 1
onAlbumsViewClicked: swipeView.currentIndex = 2
onArtistsViewClicked: swipeView.currentIndex = 3
onPlaylistsViewClicked: swipeView.currentIndex = 4
onInfoViewClicked: swipeView.currentIndex = 0
onTracksViewClicked: currentView = 0
onAlbumsViewClicked: currentView = 1
onArtistsViewClicked: currentView = 2
onPlaylistsViewClicked: currentView = 3
onInfoViewClicked: currentView = 4
onPlaylistClicked: currentIndex = -1
}
Column
Component
{
id: mainView
anchors.fill: parent
id: playlist
SwipeView
Page
{
id: swipeView
width:parent.width
height: parent.height - searchInput.height
currentIndex: 1
id: playlistPage
width: parent.width
height: parent.height
Pane
ColumnLayout
{
width: swipeView.width
height: swipeView.height
width: parent.width
height: parent.height
Column
Rectangle
{
spacing: 40
id: coverPlay
width: parent.width
height: parent.width < columnWidth ? parent.width : columnWidth
Label
FastBlur
{
width: parent.width
wrapMode: Label.Wrap
horizontalAlignment: Qt.AlignHCenter
text: "info view"
anchors.fill: coverPlay
source: artwork
radius: 100
}
Image
{
id: artwork
width: parent.width < columnWidth ? parent.width : columnWidth
height:parent.height
anchors.centerIn: parent
source: "qrc:/assets/test.jpg"
}
}
}
TracksView
{
ProgressBar
{
id: progressBar
width: parent.width
Layout.fillWidth: true
anchors.top: coverPlay.bottom
height: 16
value: 0.5
}
}
Rectangle
{
id: playbackControls
anchors.top: progressBar.bottom
Layout.fillWidth: true
width: parent.width
height: 48
z: 1
AlbumsView
{
RowLayout
{
width: parent.width
height: parent.height
anchors.fill: parent
Row
{
anchors.centerIn: parent
ToolButton
{
id: previousBtn
Icon{text: MdiFont.Icon.skipPrevious}
}
ToolButton
{
id: playBtn
Icon{text: MdiFont.Icon.play}
}
ToolButton
{
id: pauseBtn
Icon{text: MdiFont.Icon.pause}
}
ToolButton
{
id: nextBtn
Icon{text: MdiFont.Icon.skipNext}
}
}
}
}
}
ArtistsView
{
Rectangle
{
width: parent.width
height: parent.height-coverPlay.height - playbackControls.height
anchors.top: playbackControls.bottom
BabeTable
{
id: mainPlaylist
width: parent.width
height: parent.height
}
}
}
}
}
Component
{
id: views
Rectangle
Page
{
width: parent.width
height: 32
color: "white"
TextInput
width: parent.width /2
height: parent.height
clip: true
Column
{
id: searchInput
anchors.fill: parent
anchors.centerIn: parent
width: parent.width
height: parent.height
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
SwipeView
{
id: swipeView
width: parent.width
height: parent.height - searchBox.height
property string placeholderText: "Search..."
currentIndex: currentView
Label
{
anchors.fill: parent
text: searchInput.placeholderText
visible: !searchInput.focus || !searchInput.text
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.bold: true
TracksView
{
}
AlbumsView
{
}
ArtistsView
{
}
onCurrentIndexChanged:
{
currentView = currentIndex
}
}
}
}
Rectangle
{
id: searchBox
width: parent.width
height: 32
color: "white"
TextInput
{
id: searchInput
anchors.fill: parent
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
property string placeholderText: "Search..."
Label
{
anchors.fill: parent
text: searchInput.placeholderText
visible: !(searchInput.focus || searchInput.text)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.bold: true
}
}
}
}
}
}
}
......@@ -17,5 +17,7 @@
<file>view_models/TableDelegate.qml</file>
<file>assets/cover.png</file>
<file>data_models/db_model.qml</file>
<file>widgets/MainPlaylist.qml</file>
<file>assets/test.jpg</file>
</qresource>
</RCC>
......@@ -7,4 +7,6 @@ Text
font.family: "Material Design Icons"
font.pixelSize: 24
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
This diff is collapsed.
......@@ -6,7 +6,7 @@ import QtQuick.Layouts 1.3
Item
{
signal albumClicked(int index)
property int albumSize : 120
property int albumSize : 150
property int borderRadius : 4
property string fillColor: "#31363b"
......@@ -23,7 +23,6 @@ Item
ColumnLayout
{
Row
{
Layout.fillWidth: true
......@@ -34,7 +33,6 @@ Item
width: albumSize
height: albumSize
fillMode: Image.PreserveAspectFit
source: icon
......@@ -50,6 +48,7 @@ Item
anchors.centerIn: parent
width: img.adapt ? img.width : Math.min(img.width, img.height)
height: img.adapt ? img.height : width
radius: borderRadius
// radius: Math.min(width, height)
}
}
......@@ -60,7 +59,6 @@ Item
Row
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: 5
......@@ -68,7 +66,8 @@ Item
Label
{
width: parent.width
text: album
text: album || artist
visible: true
elide: Text.ElideRight
font.pointSize: 10
font.bold: true
......@@ -90,12 +89,12 @@ Item
{
width: parent.width
text: artist
visible: album && artist ? true : false
elide: Text.ElideRight
font.pointSize: 9
color: "white"
}
}
}
......
import QtQuick.Controls 2.2
import QtQuick 2.9
Rectangle
Pane
{
property int albumSize : 120
property int albumSize : 150
property int albumSpacing: 20
property int gridMargin: 50
property int borderRadius : 4
signal albumCoverClicked(string album, string artist)
......@@ -20,7 +19,7 @@ Rectangle
ListElement { album: "Channel Orange"; artist: "Frank Ocean"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Coloring Book"; artist: "Chance the Rapper"; icon: "qrc:/assets/cover.png" }
ListElement { album: "The Lonely Hour"; artist: "Sam Smith"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Messaging"; artist: "Sam Smith"; icon: "qrc:/assets/cover.png" }
ListElement { artist: "Sam Smith"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Lil Empire"; artist: "Petite Meller"; icon: "qrc:/assets/cover.png" }
ListElement { album: "Lost Generation"; artist: "Unkown";icon: "qrc:/assets/cover.png" }
}
......@@ -28,16 +27,18 @@ Rectangle
GridView
{
id: grid
anchors.fill: parent
anchors.centerIn: parent
anchors.leftMargin: gridMargin
// anchors.leftMargin: gridMargin
width: Math.min(model.count, Math.floor(parent.width/cellWidth))*cellWidth
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
cellWidth: albumSize+albumSpacing
cellHeight: parseInt(albumSize+(albumSize*0.6))
focus: true
model: appModel
highlight: Rectangle
{
id: highlight
......@@ -56,7 +57,7 @@ Rectangle
size = size > albumSize+albumSpacing ? size : albumSize+albumSpacing
grid.cellWidth = size
// grid.cellHeight = size
// grid.cellHeight = size
console.log(parseInt(size,10))
}
......@@ -66,6 +67,7 @@ Rectangle
id: delegate
albumSize: albumSize
borderRadius: borderRadius
Connections
{
target: delegate
......
......@@ -141,6 +141,12 @@ ListView
title: "Gravity"
artist: "Jhon Mayer"
}
ListElement
{
trackNumber: "4"
title: "America"
artist: "Petite Miller"
}
}
model: listModel
......
......@@ -34,8 +34,6 @@ ItemDelegate
font.pointSize: 9
}
}
......
......@@ -10,7 +10,7 @@ BabeGrid
{
id:albumsView
visible: true
albumSize: 120
albumSize: 150
borderRadius: 20
Drawer
......
......@@ -10,10 +10,9 @@ BabeGrid
{
id:artistsView
visible: true
albumSize: 120
albumSize: 150
borderRadius: 20
Drawer
{
id: drawer
......
......@@ -39,7 +39,7 @@ ToolBar
Icon
{
text: MdiFont.Icon.playCircle
color: currentIndex === 0? accentColor : textColor
color: currentIndex === -1? accentColor : textColor
}
ToolTip { text: "Playlist" }
......@@ -58,7 +58,7 @@ ToolBar
{
id: tracksIcon
text: MdiFont.Icon.musicNote
color: currentIndex === 1? accentColor : textColor
color: currentIndex === 0? accentColor : textColor
}
onClicked: tracksViewClicked()
......@@ -77,7 +77,7 @@ ToolBar
{
id: albumsIcon
text: MdiFont.Icon.album
color: currentIndex === 2? accentColor : textColor
color: currentIndex === 1? accentColor : textColor
}
onClicked: albumsViewClicked()
......@@ -97,7 +97,7 @@ ToolBar
{
id: artistsIcon
text: MdiFont.Icon.face
color: currentIndex === 3? accentColor : textColor
color: currentIndex === 2? accentColor : textColor
}
onClicked: artistsViewClicked()
......@@ -116,7 +116,7 @@ ToolBar
{
id: playlistsIcon
text: MdiFont.Icon.libraryMusic
color: currentIndex === 4? accentColor : textColor
color: currentIndex === 3? accentColor : textColor
}
onClicked: playlistsViewClicked()
......
import QtQuick.Controls 2.2
import QtQuick 2.9
import QtGraphicalEffects 1.0
Column
{
property string coverArt: "qrc:/assets/cover.png"
id: layout
width:parent.width
height:parent.height
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment