Commit d9d4bb6b authored by Camilo Higuita's avatar Camilo Higuita

initial move to mauikit, use a single model for mainplaylist releated...

initial move to mauikit, use a single model for mainplaylist releated delegates and babetable swipe fixes
parent ed2e334c
<?xml version="1.0"?>
<manifest package="org.kde.vvave" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
android:name="com.example.android.tools.NotificationClient"
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="vvave" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="vvave" android:screenOrientation="unspecified" android:launchMode="singleTop">
android:name=&quot;com.example.android.tools.NotificationClient&quot;
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
......
......@@ -20,7 +20,6 @@
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include <QWidget>
#include "kde/notify.h"
#include "kde/kdeconnect.h"
#endif
#if defined(Q_OS_ANDROID)
......@@ -291,11 +290,11 @@ void Babe::linkDecoder(QString json)
}
case LINK::CODE::COLLECT :
{
auto devices = getDevices();
qDebug()<<"DEVICES:"<< devices;
if(!devices.isEmpty())
sendToDevice(devices.first().toMap().value("name").toString(),
devices.first().toMap().value("id").toString(), msg);
// auto devices = getDevices();
// qDebug()<<"DEVICES:"<< devices;
// if(!devices.isEmpty())
// sendToDevice(devices.first().toMap().value("name").toString(),
// devices.first().toMap().value("id").toString(), msg);
break;
}
......@@ -733,24 +732,6 @@ QVariantList Babe::searchFor(const QStringList &queries)
return mapList;
}
QVariantList Babe::getDevices()
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
return KdeConnect::getDevices();
#else
return {};
#endif
}
bool Babe::sendToDevice(const QString &name, const QString &id, const QString &url)
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
return KdeConnect::sendToDevice(name, id, url) ? true : false;
#else
return {};
#endif
}
void Babe::debug(const QString &msg)
{
emit this->message(msg);
......
......@@ -24,127 +24,124 @@ using namespace BAE;
class Babe : public CollectionDB
{
Q_OBJECT
Q_OBJECT
public:
explicit Babe(QObject *parent = nullptr);
~Babe();
public:
explicit Babe(QObject *parent = nullptr);
~Babe();
BabeSettings *settings;
Linking link;
Player player;
BabeSettings *settings;
Linking link;
Player player;
// Q_INVOKABLE void runPy();
// Q_INVOKABLE void runPy();
/* DATABASE INTERFACES */
/* DATABASE INTERFACES */
Q_INVOKABLE QVariantList get(const QString &queryTxt);
Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE QVariantList get(const QString &queryTxt);
Q_INVOKABLE QVariantList getList(const QStringList &urls);
Q_INVOKABLE void set(const QString &table, const QVariantList &wheres);
Q_INVOKABLE void set(const QString &table, const QVariantList &wheres);
Q_INVOKABLE void trackPlaylist(const QStringList &urls, const QString &playlist);
Q_INVOKABLE void trackLyrics(const QString &url);
Q_INVOKABLE bool trackBabe(const QString &path);
Q_INVOKABLE QString artistArt(const QString &artist);
Q_INVOKABLE QString albumArt(const QString &album, const QString &artist);
Q_INVOKABLE QString artistWiki(const QString &artist);
Q_INVOKABLE QString albumWiki(const QString &album, const QString &artist);
Q_INVOKABLE void trackPlaylist(const QStringList &urls, const QString &playlist);
Q_INVOKABLE void trackLyrics(const QString &url);
Q_INVOKABLE bool trackBabe(const QString &path);
Q_INVOKABLE QString artistArt(const QString &artist);
Q_INVOKABLE QString albumArt(const QString &album, const QString &artist);
Q_INVOKABLE QString artistWiki(const QString &artist);
Q_INVOKABLE QString albumWiki(const QString &album, const QString &artist);
Q_INVOKABLE bool babeTrack(const QString &path, const bool &value);
Q_INVOKABLE bool babeTrack(const QString &path, const bool &value);
/* SETTINGS */
/* SETTINGS */
Q_INVOKABLE void scanDir(const QString &url);
Q_INVOKABLE void brainz(const bool &on);
Q_INVOKABLE bool brainzState();
Q_INVOKABLE void refreshCollection();
Q_INVOKABLE void getYoutubeTrack(const QString &message);
Q_INVOKABLE void scanDir(const QString &url);
Q_INVOKABLE void brainz(const bool &on);
Q_INVOKABLE bool brainzState();
Q_INVOKABLE void refreshCollection();
Q_INVOKABLE void getYoutubeTrack(const QString &message);
/* STATIC METHODS */
/* STATIC METHODS */
Q_INVOKABLE static void saveSetting(const QString &key, const QVariant &value, const QString &group);
Q_INVOKABLE static QVariant loadSetting(const QString &key, const QString &group, const QVariant &defaultValue);
Q_INVOKABLE static void saveSetting(const QString &key, const QVariant &value, const QString &group);
Q_INVOKABLE static QVariant loadSetting(const QString &key, const QString &group, const QVariant &defaultValue);
Q_INVOKABLE static void savePlaylist(const QStringList &list);
Q_INVOKABLE static QStringList lastPlaylist();
Q_INVOKABLE static void savePlaylist(const QStringList &list);
Q_INVOKABLE static QStringList lastPlaylist();
Q_INVOKABLE static void savePlaylistPos(const int &pos);
Q_INVOKABLE static int lastPlaylistPos();
Q_INVOKABLE static void savePlaylistPos(const int &pos);
Q_INVOKABLE static int lastPlaylistPos();
Q_INVOKABLE static bool fileExists(const QString &url);
Q_INVOKABLE static void showFolder(const QString &url);
Q_INVOKABLE static bool fileExists(const QString &url);
Q_INVOKABLE static void showFolder(const QString &url);
/*COLORS*/
Q_INVOKABLE static QString babeColor();
/*COLORS*/
Q_INVOKABLE static QString babeColor();
/*UTILS*/
Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static bool isAndroid();
/*UTILS*/
Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static bool isAndroid();
Q_INVOKABLE static QString moodColor(const int &pos);
Q_INVOKABLE static QString moodColor(const int &pos);
Q_INVOKABLE static QString homeDir();
Q_INVOKABLE static QString musicDir();
Q_INVOKABLE static QString sdDir();
Q_INVOKABLE static QString homeDir();
Q_INVOKABLE static QString musicDir();
Q_INVOKABLE static QString sdDir();
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
Q_INVOKABLE static QStringList defaultSources();
Q_INVOKABLE static QStringList defaultSources();
static void registerTypes();
static void registerTypes();
/*USEFUL*/
Q_INVOKABLE QString loadCover(const QString &url);
Q_INVOKABLE QVariantList searchFor(const QStringList &queries);
/*USEFUL*/
Q_INVOKABLE QString loadCover(const QString &url);
Q_INVOKABLE QVariantList searchFor(const QStringList &queries);
/*KDE*/
Q_INVOKABLE static QVariantList getDevices();
Q_INVOKABLE static bool sendToDevice(const QString &name, const QString &id, const QString &url);
/*KDE*/
Q_INVOKABLE void notify(const QString &title, const QString &body);
Q_INVOKABLE void notifySong(const QString &url);
Q_INVOKABLE void notify(const QString &title, const QString &body);
Q_INVOKABLE void notifySong(const QString &url);
/*ANDROID*/
Q_INVOKABLE static void sendText(const QString &text);
Q_INVOKABLE static void sendTrack(const QString &url);
Q_INVOKABLE static void openFile(const QString &url);
Q_INVOKABLE void fileChooser();
Q_INVOKABLE static void androidStatusBarColor(const QString &color, const bool &contrast);
/*ANDROID*/
Q_INVOKABLE static void sendText(const QString &text);
Q_INVOKABLE static void sendTrack(const QString &url);
Q_INVOKABLE static void openFile(const QString &url);
Q_INVOKABLE void fileChooser();
Q_INVOKABLE static void androidStatusBarColor(const QString &color, const bool &contrast);
public slots:
void debug(const QString &msg);
public slots:
void debug(const QString &msg);
private:
private:
ConThread *thread;
ConThread *thread;
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
Notify *nof;
Notify *nof;
#elif defined (Q_OS_ANDROID)
NotificationClient *nof;
Android *android;
NotificationClient *nof;
Android *android;
#endif
QString fetchCoverArt(DB &song);
static QVariantList transformData(const DB_LIST &dbList);
void fetchTrackLyrics(DB &song);
void linkDecoder(QString json);
signals:
void refreshTables(int size);
void refreshTracks();
void refreshAlbums();
void refreshArtists();
void trackLyricsReady(QString lyrics, QString url);
void skipTrack();
void babeIt();
void message(QString msg);
QString fetchCoverArt(DB &song);
static QVariantList transformData(const DB_LIST &dbList);
void fetchTrackLyrics(DB &song);
void linkDecoder(QString json);
signals:
void refreshTables(int size);
void refreshTracks();
void refreshAlbums();
void refreshArtists();
void trackLyricsReady(QString lyrics, QString url);
void skipTrack();
void babeIt();
void message(QString msg);
};
......
......@@ -7,12 +7,10 @@ QT += webengine
HEADERS += \
$$PWD/notify.h \
$$PWD/mpris2.h \
$$PWD/kdeconnect.h
SOURCES += \
$$PWD/notify.cpp \
$$PWD/mpris2.cpp \
$$PWD/kdeconnect.cpp
LIBS += -ltag
......
......@@ -10,7 +10,6 @@
#include <QStyleHints>
#include <QCommandLineParser>
#include "services/local/linking.h"
#ifdef STATIC_KIRIGAMI
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
......@@ -28,6 +27,8 @@
#include "utils/bae.h"
#include "services/web/youtube.h"
#include "services/web/Spotify/spotify.h"
#include "services/local/linking.h"
#include "mauikit/src/mauikit.h"
#ifdef Q_OS_ANDROID
Q_DECL_EXPORT
......@@ -100,6 +101,7 @@ int main(int argc, char *argv[])
"LINK", // name in QML (does not have to match C++ name)
"Error: only enums" // error in case someone tries to create a MyNamespace object
);
#ifdef STATIC_KIRIGAMI
KirigamiPlugin::getInstance().registerTypes();
#endif
......@@ -115,6 +117,10 @@ int main(int argc, char *argv[])
QtWebEngine::initialize();
#endif
#ifdef MAUI_APP
MauiKit::getInstance().registerTypes();
#endif
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
......
......@@ -22,14 +22,17 @@ import "services/local"
import "services/web"
import "services/web/Spotify"
import "view_models/BabeGrid"
import "db/Queries.js" as Q
import "utils/Player.js" as Player
import "utils/Help.js" as H
import org.kde.kirigami 2.2 as Kirigami
import org.kde.maui 1.0 as Maui
import Link.Codes 1.0
Kirigami.ApplicationWindow
Maui.ApplicationWindow
{
id: root
......@@ -47,7 +50,7 @@ Kirigami.ApplicationWindow
property alias playIcon: playIcon
property alias babeBtnIcon: babeBtnIcon
property alias progressBar: progressBar
property alias animFooter: animFooter
// property alias animFooter: animFooter
property alias mainPlaylist: mainPlaylist
......@@ -84,16 +87,8 @@ Kirigami.ApplicationWindow
readonly property real opacityLevel: 0.8
readonly property int wideSize: Screen.width * 0.5
readonly property int rowHeight: (defaultFontSize * 2) + space.large
readonly property int rowHeightAlt: (defaultFontSize*2) + space.big
iconSize: bae.loadSetting("ICON_SIZE", "BABE", iconSizes.medium)
readonly property int headerHeight: rowHeight
property int toolBarIconSize: bae.loadSetting("ICON_SIZE", "BABE",
iconSizes.medium)
property int toolBarHeight: Kirigami.Units.iconSizes.medium + (Kirigami.Settings.isMobile ? Kirigami.Units.smallSpacing : Kirigami.Units.largeSpacing)
property int miniArtSize: iconSizes.large
property int columnWidth: Kirigami.Units.gridUnit * 17
......@@ -124,14 +119,11 @@ Kirigami.ApplicationWindow
property string syncPlaylist: ""
property bool sync: false
property string infoMsg: ""
property bool infoLabels: bae.loadSetting("PLAYBACKINFO", "BABE",
false) == "true" ? true : false
property bool infoLabels: bae.loadSetting("PLAYBACKINFO", "BABE", false) == "true" ? true : false
property bool isLinked: false
property bool isServing: false
/* ANDROID THEMING*/
Material.theme: Material.Light
......@@ -145,69 +137,6 @@ Kirigami.ApplicationWindow
/******************** UI UNITS ********************/
/*************************************************/
property int iconSize : iconSizes.medium
readonly property real factor : Kirigami.Units.gridUnit * (isMobile ? 0.2 : 0.2)
readonly property int contentMargins: space.medium
readonly property int defaultFontSize: Kirigami.Theme.defaultFont.pointSize
readonly property var fontSizes: ({
tiny: defaultFontSize * 0.7,
small: (isMobile ? defaultFontSize * 0.7 :
defaultFontSize * 0.8),
medium: (isMobile ? defaultFontSize * 0.8 :
defaultFontSize * 0.9),
default: (isMobile ? defaultFontSize * 0.9 :
defaultFontSize),
big: (isMobile ? defaultFontSize :
defaultFontSize * 1.1),
large: (isMobile ? defaultFontSize * 1.1 :
defaultFontSize * 1.2)
})
readonly property var space : ({
tiny: Kirigami.Units.smallSpacing,
small: Kirigami.Units.smallSpacing*2,
medium: Kirigami.Units.largeSpacing,
big: Kirigami.Units.largeSpacing*2,
large: Kirigami.Units.largeSpacing*3,
huge: Kirigami.Units.largeSpacing*4,
enormus: Kirigami.Units.largeSpacing*5
})
readonly property var iconSizes : ({
tiny : Kirigami.Units.iconSizes.small*0.5,
small : (isMobile ? Kirigami.Units.iconSizes.small*0.5:
Kirigami.Units.iconSizes.small),
medium : (isMobile ? (isAndroid ? 22 : Kirigami.Units.iconSizes.small) :
Kirigami.Units.iconSizes.smallMedium),
big: (isMobile ? Kirigami.Units.iconSizes.smallMedium :
Kirigami.Units.iconSizes.medium),
large: (isMobile ? Kirigami.Units.iconSizes.medium :
Kirigami.Units.iconSizes.large),
huge: (isMobile ? Kirigami.Units.iconSizes.large :
Kirigami.Units.iconSizes.huge),
enormous: (isMobile ? Kirigami.Units.iconSizes.huge :
Kirigami.Units.iconSizes.enormous)
})
/***************************************************/
/**************************************************/
/*************************************************/
readonly property real screenWidth : Screen.width
readonly property real screenHeight : Screen.height
......@@ -216,14 +145,6 @@ Kirigami.ApplicationWindow
/***************************************************/
/******************** UI COLORS *******************/
/*************************************************/
property string backgroundColor: Kirigami.Theme.backgroundColor
property string textColor: Kirigami.Theme.textColor
property string highlightColor: Kirigami.Theme.highlightColor
property string highlightedTextColor: Kirigami.Theme.highlightedTextColor
property string buttonBackgroundColor: Kirigami.Theme.buttonBackgroundColor
property string viewBackgroundColor: Kirigami.Theme.viewBackgroundColor
property string altColor: Kirigami.Theme.complementaryBackgroundColor
property string babeColor: bae.babeColor()
readonly property string darkBackgroundColor: "#303030"
......@@ -253,8 +174,7 @@ Kirigami.ApplicationWindow
{
color: isAndroid ? darkColor : "transparent"
opacity: 0.5
height: root.height - playbackControls.height - toolbar.height
y: toolbar.height
height: root.height - footBar.height - headBar.height
}
overlay.modeless: Rectangle
......@@ -309,72 +229,186 @@ Kirigami.ApplicationWindow
}
}
FloatingDisk
/* UI */
property bool accent : pageStack.wideMode || (!pageStack.wideMode && pageStack.currentIndex === 1)
headBar.middleContent : Row
{
id: floatingDisk
spacing: space.medium
Maui.ToolButton
{
iconName: "view-media-track"
iconColor: accent && currentView === viewsIndex.tracks ? babeColor : textColor
display: pageStack.wideMode ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly
onClicked:
{
pageStack.currentIndex = 1
currentView = viewsIndex.tracks
}
text: qsTr("Tracks")
}
Maui.ToolButton
{
text: qsTr("Albums")
iconName: /*"album"*/ "view-media-album-cover"
iconColor: accent && currentView === viewsIndex.albums ? babeColor : textColor
display: pageStack.wideMode ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly
onClicked:
{
pageStack.currentIndex = 1
albumsView.currentIndex = 0
currentView = viewsIndex.albums
}
}
Maui.ToolButton
{
text: qsTr("Artists")
iconName: "view-media-artist"
iconColor: accent && currentView === viewsIndex.artists ? babeColor : textColor
display: pageStack.wideMode ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly
onClicked:
{
pageStack.currentIndex = 1
artistsView.currentIndex = 0
currentView = viewsIndex.artists
}
}
Maui.ToolButton
{
text: qsTr("Playlists")
iconName: "view-media-playlist"
iconColor: accent && currentView === viewsIndex.playlists ? babeColor : textColor
display: pageStack.wideMode ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly
onClicked:
{
pageStack.currentIndex = 1
currentView = viewsIndex.playlists
}
}
}
/* UI */
header: BabeBar
onSearchButtonClicked:
{
id: toolbar
width: root.width
height: toolBarHeight
pageStack.currentIndex = 1
currentView = viewsIndex.search
searchView.searchInput.forceActiveFocus()
}
visible: !focusMode
currentIndex: currentView
onSettingsViewClicked: settingsDrawer.visible ? settingsDrawer.close() :
settingsDrawer.open()
footBar.z : 0
pageStack.z: 0
footBar.middleContent: Row
{
spacing: space.medium
onTracksViewClicked:
Maui.ToolButton
{
pageStack.currentIndex = 1
currentView = viewsIndex.tracks
id: babeBtnIcon
iconName: "love"
iconColor: currentBabe ? babeColor : darkTextColor
onClicked: if (!mainlistEmpty)
{
var value = mainPlaylist.contextMenu.babeIt(
currentTrackIndex)
currentBabe = value
}
}
onAlbumsViewClicked:
Maui.ToolButton
{
pageStack.currentIndex = 1
albumsView.currentIndex = 0
currentView = viewsIndex.albums
iconName: "media-skip-backward"
iconColor: darkTextColor
onClicked: Player.previousTrack()
onPressAndHold: Player.playAt(prevTrackIndex)
}
onArtistsViewClicked:
Maui.ToolButton
{
pageStack.currentIndex = 1
artistsView.currentIndex = 0
currentView = viewsIndex.artists
id: playIcon
iconColor: darkTextColor
iconName: isPlaying ? "media-playback-pause" : "media-playback-start"
onClicked:
{
if (isPlaying)
Player.pauseTrack()
else
Player.resumeTrack()
}
}
onPlaylistsViewClicked:
Maui.ToolButton
{
pageStack.currentIndex = 1
currentView = viewsIndex.playlists
id: nextBtn
iconColor: darkTextColor
iconName: "media-skip-forward"
onClicked: Player.nextTrack()
onPressAndHold: Player.playAt(Player.shuffle())
}
onSearchViewClicked:
Maui.PieButton
{
pageStack.currentIndex = 1
currentView = viewsIndex.search
searchView.searchInput.forceActiveFocus()
id: shuffleBtn
iconColor: darkTextColor
iconName: isShuffle ? "media-playlist-shuffle" : "media-playlist-repeat"
delegateSize: iconSizes.large + space.big
// onClicked: isShuffle = !isShuffle
model: mainPlaylist.list.model
delegate: BabeAlbum
{
id: delegate
itemWidth: iconSizes.large + space.big
itemHeight: itemWidth
albumSize: iconSizes.large
showIndicator: false
showLabels: false
albumRadius: itemWidth
Connections
{
target: delegate
onClicked:
{
shuffleBtn.close()
Player.playAt(index)
}
}
}
}
}
footer: ToolBar
{
id: playbackControls
position: ToolBar.Footer
height: toolBarHeight + space.medium
width: root.width
visible: true
focus: true
leftPadding: 0
rightPadding: 0
footBar.background: Rectangle
{
id: footerBg
color: darkViewBackgroundColor
opacity: focusMode ? 0.2 : opacityLevel
SequentialAnimation
{
id: animFooter
PropertyAnimation
{
target: footerBg
property: "color"
easing.type: Easing.InOutQuad
from: "black"
to: darkViewBackgroundColor
duration: 500
}
}
FastBlur
{
......@@ -388,29 +422,6 @@ Kirigami.ApplicationWindow
z: -999
}
Rectangle
{
id: footerBg
anchors.fill: parent
color: darkViewBackgroundColor
opacity: focusMode ? 0.2 : opacityLevel
z: -999
SequentialAnimation
{
id: animFooter
PropertyAnimation
{
target: footerBg
property: "color"
easing.type: Easing.InOutQuad
from: "black"
to: darkViewBackgroundColor
duration: 500
}
}
}
Slider
{
id: progressBar
......@@ -425,7 +436,6 @@ Kirigami.ApplicationWindow
value: 0
spacing: 0
focus: true
onMoved: player.seek(player.duration() / 1000 * value)
background: Rectangle
......@@ -457,171 +467,307 @@ Kirigami.ApplicationWindow
color: babeColor
}
}
}
FloatingDisk
{