Commit b19b1681 authored by Camilo Higuita's avatar Camilo Higuita

fix knotification actions

parent a433434e
......@@ -6,7 +6,7 @@ QT += websockets
QT += network
QT += xml
unix:!android:
unix:linux:!android:
{
include(kde/kde.pri)
}
......
......@@ -7,11 +7,11 @@
#include "db/collectionDB.h"
#include "settings/settings.h"
#include "pulpo/pulpo.h"
#include <QApplication>
#include <QDesktopWidget>
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include "kde/notify.h"
Notify *Babe::nof = new Notify;
#endif
using namespace BAE;
......@@ -27,13 +27,26 @@ Babe::Babe(QObject *parent) : QObject(parent)
emit this->refreshTables(tables);
});
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
this->nof = new Notify(this);
connect(this->nof,&Notify::babeSong,[this](const BAE::DB &track)
{
qDebug()<<"BABETRACKKKK";
Q_UNUSED(track);
emit this->babeIt();
});
connect(this->nof,&Notify::skipSong,[this]()
{
emit this->skipTrack();
});
#endif
}
Babe::~Babe()
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
delete Babe::nof;
#endif
}
QVariantList Babe::get(const QString &queryTxt)
......@@ -177,6 +190,18 @@ void Babe::notify(const QString &title, const QString &body)
}
void Babe::notifySong(const QString &url)
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
auto query = QString("select t.*, al.artwork from tracks t inner join albums al on al.album = t.album and al.artist = t.artist where url = \"%1\"").arg(url);
auto track = this->con->getDBData(query);
Babe::nof->notifySong(track.first());
#else
Q_UNUSED(title);
Q_UNUSED(body);
#endif
}
void Babe::scanDir(const QString &url)
{
emit this->set->collectionPathChanged({url});
......@@ -272,6 +297,29 @@ bool Babe::isMobile()
return BAE::isMobile();
}
int Babe::screenGeometry(QString &side)
{
side = side.toLower();
auto geo = QApplication::desktop()->screenGeometry();
if(side == "width")
return geo.width();
else if(side == "height")
return geo.height();
else return 0;
}
int Babe::cursorPos(QString &axis)
{
axis = axis.toLower();
auto pos = QCursor::pos();
if(axis == "x")
return pos.x();
else if(axis == "y")
return pos.y();
else return 0;
}
QString Babe::loadCover(const QString &url)
{
auto map = this->con->getDBData(QStringList() << url);
......
......@@ -39,7 +39,8 @@ public:
Q_INVOKABLE bool rateTrack(const QString &path, const int &value);
Q_INVOKABLE int trackRate(const QString &path);
Q_INVOKABLE static void notify(const QString &title, const QString &body);
Q_INVOKABLE void notify(const QString &title, const QString &body);
Q_INVOKABLE void notifySong(const QString &url);
/* SETTINGS */
Q_INVOKABLE void scanDir(const QString &url);
......@@ -61,6 +62,8 @@ public:
Q_INVOKABLE static QString babeColor();
Q_INVOKABLE static bool isMobile();
Q_INVOKABLE static int screenGeometry(QString &side);
Q_INVOKABLE static int cursorPos(QString &axis);
/*USEFUL*/
......@@ -71,7 +74,7 @@ private:
CollectionDB *con;
settings *set;
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
static Notify *nof;
Notify *nof;
#endif
QString fetchCoverArt(DB &song);
......@@ -82,7 +85,8 @@ private:
signals:
void refreshTables(QVariantMap tables);
void trackLyricsReady(QString lyrics, QString url);
void skipTrack();
void babeIt();
public slots:
};
......
linux:unix:!android {
message(Building for Linux)
QT += dbus
QT += KConfigCore
QT += KNotifications
QT += KI18n
unix:linux:!android:
{
QT += dbus
QT += KConfigCore
QT += KNotifications
QT += KI18n
HEADERS += \ kde/notify.h \
kde/mpris2.h
HEADERS += \ kde/notify.h \
kde/mpris2.h
SOURCES += kde/notify.cpp \
kde/mpris2.cpp
} else:android {
message(Building for Android)
SOURCES += kde/notify.cpp \
kde/mpris2.cpp
} else {
message("Unknown configuration")
}
android:
{
QT -= dbus
QT -= KConfigCore
QT -= KNotifications
QT -= KI18n
HEADERS -= \ kde/notify.h \
kde/mpris2.h
SOURCES -= kde/notify.cpp \
kde/mpris2.cpp
}
......@@ -35,7 +35,7 @@ void Notify::notify(const QString &title, const QString &body)
notification->sendEvent();
}
void Notify::notifySong(const BAE::DB &trackMap, const QPixmap &pix)
void Notify::notifySong(const BAE::DB &trackMap)
{
this->track = trackMap;
// notification->setComponentName(QStringLiteral("Babe"));
......@@ -44,7 +44,9 @@ void Notify::notifySong(const BAE::DB &trackMap, const QPixmap &pix)
notification->setTitle(QStringLiteral("%1").arg(track[BAE::KEY::TITLE]));
notification->setText(QStringLiteral("%1\n%2").arg(track[BAE::KEY::ARTIST],track[BAE::KEY::ALBUM]));
if(!pix.isNull()) notification->setPixmap(pix);
QPixmap pixmap;
pixmap.load(trackMap[BAE::KEY::ARTWORK]);
if(!pixmap.isNull()) notification->setPixmap(pixmap);
QStringList actions;
if(track[BAE::KEY::BABE].toInt()==1) actions<<i18n("Un-Babe it \xe2\x99\xa1");
......
......@@ -21,7 +21,7 @@ class Notify : public QObject
public:
explicit Notify(QObject *parent = nullptr);
~Notify();
void notifySong(const BAE::DB &, const QPixmap &pix);
void notifySong(const BAE::DB &);
void notify(const QString &title, const QString &body);
private:
......
......@@ -29,11 +29,12 @@ ApplicationWindow
property int currentView : 0
property int iconSize
property alias mainPlaylist : mainPlaylist
// minimumWidth: columnWidth
// pageStack.defaultColumnWidth: columnWidth
// pageStack.initialPage: [playlistPage, views]
onWidthChanged: if(bae.isMobile())
{
if(root.width>root.height)
......@@ -63,6 +64,7 @@ ApplicationWindow
target: player
onPos: mainPlaylist.progressBar.value = pos
onFinished: Player.nextTrack()
}
Connections
......@@ -84,6 +86,9 @@ ApplicationWindow
if(url === root.mainPlaylist.currentTrack.url)
root.mainPlaylist.infoView.lyrics = lyrics
}
onSkipTrack: Player.nextTrack()
onBabeIt: Player.babeTrack()
}
header: BabeBar
......@@ -153,7 +158,7 @@ ApplicationWindow
}
Rectangle
background: Rectangle
{
anchors.fill: parent
color: bae.altColor()
......
......@@ -3,7 +3,7 @@
; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
[Controls]
Style=Material
Style=Universal
[Universal]
Theme=Light
......
......@@ -7,3 +7,5 @@ function rootHeight()
{
return root.height;
}
......@@ -9,6 +9,9 @@ function playTrack(track)
root.title = root.mainPlaylist.currentTrack.title + " - " +root.mainPlaylist.currentTrack.artist
root.mainPlaylist.currentArtwork = root.mainPlaylist.currentTrack.artwork || bae.loadCover(root.mainPlaylist.currentTrack.url)
if(!root.active)
bae.notifySong(root.mainPlaylist.currentTrack.url)
root.mainPlaylist.playIcon.text = Icon.pause
if(bae.trackBabe(root.mainPlaylist.currentTrack.url))
......@@ -176,13 +179,13 @@ function babeTrack()
root.mainPlaylist.babeBtnIcon.text = Icon.heartOutline
root.mainPlaylist.babeBtnIcon.color = root.mainPlaylist.babeBtnIcon.defaultColor
}else
}else
{
bae.babeTrack(root.mainPlaylist.currentTrack.url, true)
root.mainPlaylist.babeBtnIcon.text = Icon.heartOutline
root.mainPlaylist.babeBtnIcon.color = bae.babeColor()
bae.notify("Track Babe'd",root.mainPlaylist.currentTrack.title +" by "+ root.mainPlaylist.currentTrack.artist )
}
}
......@@ -29,7 +29,7 @@ BabeGrid
edge: Qt.BottomEdge
interactive: false
Rectangle
background: Rectangle
{
anchors.fill: parent
z: -999
......
......@@ -28,6 +28,13 @@ BabeGrid
edge: Qt.BottomEdge
interactive: false
background: Rectangle
{
anchors.fill: parent
z: -999
color: bae.altColor()
}
Column
{
anchors.fill: parent
......
......@@ -127,6 +127,34 @@ Item
color: bae.midColor()
z: -999
}
background: Rectangle
{
x: progressBar.leftPadding
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitWidth: 200
implicitHeight: 2
width: progressBar.availableWidth
height: implicitHeight
color: bae.foregroundColor()
Rectangle
{
width: progressBar.visualPosition * parent.width
height: parent.height
color: bae.babeColor()
}
}
handle: Rectangle
{
x: progressBar.leftPadding + progressBar.visualPosition * (progressBar.availableWidth - width)
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitWidth: 16
implicitHeight: 16
radius: 13
color: bae.babeColor()
}
}
Rectangle
......
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