elisaapplication.h 4.79 KB
Newer Older
1
/*
Matthieu Gallien's avatar
Matthieu Gallien committed
2
3
4
   SPDX-FileCopyrightText: 2017 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>

   SPDX-License-Identifier: LGPL-3.0-or-later
5
6
7
8
9
 */

#ifndef ELISAAPPLICATION_H
#define ELISAAPPLICATION_H

10
11
#include "elisaLib_export.h"

12
13
#include "config-upnp-qt.h"

14
#include "elisautils.h"
15
#include "datatypes.h"
16

17
18
19
#include <QObject>
#include <QString>

20
21
#include <memory>

22
23
class QIcon;
class QAction;
24
25
class MusicListenersManager;
class MediaPlayList;
26
class MediaPlayListProxyModel;
Alexander Stippich's avatar
Alexander Stippich committed
27
class AudioWrapper;
Alexander Stippich's avatar
Alexander Stippich committed
28
class ManageAudioPlayer;
29
30
class ManageMediaPlayerControl;
class ManageHeaderBar;
31
class QQmlEngine;
32
class ElisaApplicationPrivate;
33
class QSessionManager;
34

35
class ELISALIB_EXPORT ElisaApplication : public QObject
36
{
37

38
    Q_OBJECT
39

40
    Q_PROPERTY(DataTypes::EntryDataList arguments
41
42
43
44
               READ arguments
               WRITE setArguments
               NOTIFY argumentsChanged)

45
46
47
48
    Q_PROPERTY(ElisaUtils::PlayListEntryType embeddedView
               READ embeddedView
               NOTIFY embeddedViewChanged)

49
50
51
52
53
54
55
56
    Q_PROPERTY(MusicListenersManager *musicManager
               READ musicManager
               NOTIFY musicManagerChanged)

    Q_PROPERTY(MediaPlayList *mediaPlayList
               READ mediaPlayList
               NOTIFY mediaPlayListChanged)

57
58
59
60
61
62

    Q_PROPERTY(MediaPlayListProxyModel *mediaPlayListProxyModel
               READ mediaPlayListProxyModel
               NOTIFY mediaPlayListProxyModelChanged)


Alexander Stippich's avatar
Alexander Stippich committed
63
64
65
66
    Q_PROPERTY(AudioWrapper *audioPlayer
               READ audioPlayer
               NOTIFY audioPlayerChanged)

Alexander Stippich's avatar
Alexander Stippich committed
67
68
69
70
    Q_PROPERTY(ManageAudioPlayer *audioControl
               READ audioControl
               NOTIFY audioControlChanged)

71
72
73
74
75
76
77
78
    Q_PROPERTY(ManageMediaPlayerControl *playerControl
               READ playerControl
               NOTIFY playerControlChanged)

    Q_PROPERTY(ManageHeaderBar *manageHeaderBar
               READ manageHeaderBar
               NOTIFY manageHeaderBarChanged)

79
80
81
82
    Q_PROPERTY(bool showProgressOnTaskBar
               READ showProgressOnTaskBar
               NOTIFY showProgressOnTaskBarChanged)

83
84
85
86
    Q_PROPERTY(bool showSystemTrayIcon
               READ showSystemTrayIcon
               NOTIFY showSystemTrayIconChanged)

87
public:
88
    explicit ElisaApplication(QObject *parent = nullptr);
89

90
91
    ~ElisaApplication() override;

92
93
94
95
    Q_INVOKABLE QAction* action(const QString& name);

    Q_INVOKABLE QString iconName(const QIcon& icon);

96
97
98
99
    Q_INVOKABLE void installKeyEventFilter(QObject *object);

    bool eventFilter(QObject *object, QEvent *event) override;

100
    const DataTypes::EntryDataList &arguments() const;
101

102
103
104
105
    MusicListenersManager *musicManager() const;

    MediaPlayList *mediaPlayList() const;

106
107
    MediaPlayListProxyModel *mediaPlayListProxyModel() const;

Alexander Stippich's avatar
Alexander Stippich committed
108
109
    AudioWrapper *audioPlayer() const;

Alexander Stippich's avatar
Alexander Stippich committed
110
111
    ManageAudioPlayer *audioControl() const;

112
113
114
115
    ManageMediaPlayerControl *playerControl() const;

    ManageHeaderBar *manageHeaderBar() const;

116
117
    bool showProgressOnTaskBar() const;

118
119
    bool showSystemTrayIcon() const;

120
121
    ElisaUtils::PlayListEntryType embeddedView() const;

122
123
Q_SIGNALS:

124
125
    void argumentsChanged();

126
127
128
129
    void musicManagerChanged();

    void mediaPlayListChanged();

130
131
    void mediaPlayListProxyModelChanged();

Alexander Stippich's avatar
Alexander Stippich committed
132
133
    void audioPlayerChanged();

Alexander Stippich's avatar
Alexander Stippich committed
134
135
    void audioControlChanged();

136
137
138
139
    void playerControlChanged();

    void manageHeaderBarChanged();

140
    void enqueue(const DataTypes::EntryDataList &newEntries,
141
142
                 ElisaUtils::PlayListEnqueueMode enqueueMode,
                 ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay);
143

144
145
    void initializationDone();

146
147
    void showProgressOnTaskBarChanged();

148
149
    void showSystemTrayIconChanged();

150
151
    void commitDataRequest(QSessionManager &manager);

152
153
    void embeddedViewChanged();

154
155
156
157
158
159
160
161
162
163
public Q_SLOTS:

    void appHelpActivated();

    void aboutApplication();

    void reportBug();

    void configureShortcuts();

164
165
    void configureElisa();

166
    void setArguments(const DataTypes::EntryDataList &newArguments);
167
168
169
170
171
172
173

    void activateActionRequested(const QString &actionName, const QVariant &parameter);

    void activateRequested(const QStringList &arguments, const QString &workingDirectory);

    void openRequested(const QList< QUrl > &uris);

174
    void initialize();
175

176
177
public:

178
    void setQmlEngine(QQmlEngine *engine);
179

180
181
182
183
private Q_SLOTS:

    void goBack();

184
185
    void find();

Diego Gangl's avatar
Diego Gangl committed
186
187
    void togglePlaylist();

188
189
190
191
    void seek();

    void scrub();

192
193
    void playPause();

194
195
    void configChanged();

196
197
198
199
    void nextTrack();

    void previousTrack();

200
201
private:

202
203
204
205
    void initializeModels();

    void initializePlayer();

206
207
    void setupActions(const QString &actionName);

208
    DataTypes::EntryDataList checkFileListAndMakeAbsolute(const DataTypes::EntryDataList &filesList,
209
                                                              const QString &workingDirectory) const;
210

211
    std::unique_ptr<ElisaApplicationPrivate> d;
212

213
214
215
};

#endif // ELISAAPPLICATION_H