babe.h 4.71 KB
Newer Older
1 2 3 4 5 6
#ifndef BABE_H
#define BABE_H

#include <QObject>
#include <QVariantList>
#include "utils/bae.h"
7
#include "db/collectionDB.h"
8 9 10

#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
class Notify;
11 12
#elif defined (Q_OS_ANDROID)
class NotificationClient;
13 14
#endif

15 16
class CollectionDB;
class Pulpo;
17
class BabeSettings;
18
class ConThread;
19 20
using namespace BAE;

21
class Babe : public CollectionDB
22 23 24 25
{
    Q_OBJECT
public:
    explicit Babe(QObject *parent = nullptr);
26
    ~Babe();
27

28 29 30 31 32 33 34 35
    enum class HINT : uint
    {
        BIG_ALBUM = 200,
        MEDIUM_ALBUM = 120,
        SMALL_ALBUM = 80
    };
    Q_ENUM(HINT)

36
    //    Q_INVOKABLE void runPy();
37

38 39 40
    /* DATABASE INTERFACES */

    Q_INVOKABLE QVariantList get(const QString &queryTxt);
41
    Q_INVOKABLE QVariantList getList(const QStringList &urls);
42

43 44 45
    Q_INVOKABLE void set(const QString &table, const QVariantList &wheres);

    Q_INVOKABLE void trackPlaylist(const QStringList &urls, const QString &playlist);
46
    Q_INVOKABLE void trackLyrics(const QString &url);
47 48 49 50 51 52 53 54
    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);

55

56 57 58
    /* SETTINGS */

    Q_INVOKABLE void scanDir(const QString &url);
59
    Q_INVOKABLE void brainz(const bool &on);
60
    Q_INVOKABLE bool brainzState();
61
    Q_INVOKABLE void refreshCollection();
62
    Q_INVOKABLE void getYoutubeTrack(const QString &message);
63 64 65

    /* STATIC METHODS */

66 67 68
    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);

69 70 71 72 73 74
    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();

75
    Q_INVOKABLE static bool fileExists(const QString &url);
76
    Q_INVOKABLE static void showFolder(const QString &url);
77

78
    /*COLORS*/
79 80
    Q_INVOKABLE static QString baseColor();
    Q_INVOKABLE static QString darkColor();
81 82
    Q_INVOKABLE static QString backgroundColor();
    Q_INVOKABLE static QString foregroundColor();
83
    Q_INVOKABLE static QString textColor();
84 85
    Q_INVOKABLE static QString highlightColor();
    Q_INVOKABLE static QString highlightTextColor();
86
    Q_INVOKABLE static QString midColor();
87 88
    Q_INVOKABLE static QString midLightColor();
    Q_INVOKABLE static QString shadowColor();
89 90
    Q_INVOKABLE static QString altColor();
    Q_INVOKABLE static QString babeColor();
91
    Q_INVOKABLE static QString babeAltColor();
92

93 94

    /*UTILS*/
95
    Q_INVOKABLE static bool isMobile();
96 97
    Q_INVOKABLE static int screenGeometry(QString side);
    Q_INVOKABLE static int cursorPos(QString axis);
98

99 100
    Q_INVOKABLE static QString moodColor(const int &pos);

101
    Q_INVOKABLE static QString homeDir();
102 103
    Q_INVOKABLE static QString musicDir();
    Q_INVOKABLE static QString sdDir();
104 105 106

    Q_INVOKABLE static QVariantList getDirs(const QString &pathUrl);
    Q_INVOKABLE static QVariantMap getParentDir(const QString &path);
107

108 109
    Q_INVOKABLE static QStringList defaultSources();

110
    static void registerTypes();
111

112
    /*USEFUL*/
113
    Q_INVOKABLE QString loadCover(const QString &url);
114
    Q_INVOKABLE QVariantList searchFor(const QStringList &queries);
115

116 117 118 119 120 121
    /*KDE*/
    Q_INVOKABLE static QVariantList getDevices();
    Q_INVOKABLE static bool sendToDevice(const QString &name, const QString &id, const QString &url);

    Q_INVOKABLE void notify(const QString &title, const QString &body);
    Q_INVOKABLE void notifySong(const QString &url);
122 123 124 125

    /*ANDROID*/
    Q_INVOKABLE static void sendText(const QString &text);
    Q_INVOKABLE static void sendTrack(const QString &url);
126
    Q_INVOKABLE static void openFile(const QString &url);
127 128 129
    Q_INVOKABLE static void androidStatusBarColor(const QString &color);


130
public slots:
131 132
    void debug(const QString &msg);

133
private:
134 135 136
    BabeSettings *settings;
    ConThread *thread;

137
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
Camilo Higuita's avatar
Camilo Higuita committed
138
    Notify *nof;
139 140
#elif defined (Q_OS_ANDROID)
    NotificationClient *nof;
141
#endif
142 143

    QString fetchCoverArt(DB &song);
144
    static QVariantList transformData(const DB_LIST &dbList);
145

146
    void fetchTrackLyrics(DB &song);
147 148

signals:
149
    void refreshTables(int size);
150 151 152
    void refreshTracks();
    void refreshAlbums();
    void refreshArtists();
153
    void trackLyricsReady(QString lyrics, QString url);
Camilo Higuita's avatar
Camilo Higuita committed
154 155
    void skipTrack();
    void babeIt();
156
    void message(QString msg);
157 158
};

159

160
#endif // BABE_H