File indexing completed on 2024-05-05 09:01:58
0001 /* 0002 SPDX-FileCopyrightText: 2017 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr> 0003 0004 SPDX-License-Identifier: LGPL-3.0-or-later 0005 */ 0006 0007 #ifndef ELISAAPPLICATION_H 0008 #define ELISAAPPLICATION_H 0009 0010 #include "elisaLib_export.h" 0011 0012 #include "config-upnp-qt.h" 0013 0014 #include "elisautils.h" 0015 #include "datatypes.h" 0016 0017 #include <QObject> 0018 #include <QString> 0019 0020 #include <memory> 0021 0022 class QIcon; 0023 class QAction; 0024 class MusicListenersManager; 0025 class MediaPlayList; 0026 class MediaPlayListProxyModel; 0027 class AudioWrapper; 0028 class ManageAudioPlayer; 0029 class ManageMediaPlayerControl; 0030 class ManageHeaderBar; 0031 class QQmlEngine; 0032 class ElisaApplicationPrivate; 0033 class QSessionManager; 0034 class KColorSchemeManager; 0035 class QAbstractItemModel; 0036 0037 class ELISALIB_EXPORT ElisaApplication : public QObject 0038 { 0039 0040 Q_OBJECT 0041 0042 Q_PROPERTY(ElisaUtils::PlayListEntryType embeddedView 0043 READ embeddedView 0044 NOTIFY embeddedViewChanged) 0045 0046 Q_PROPERTY(MusicListenersManager *musicManager 0047 READ musicManager 0048 NOTIFY musicManagerChanged) 0049 0050 Q_PROPERTY(MediaPlayList *mediaPlayList 0051 READ mediaPlayList 0052 NOTIFY mediaPlayListChanged) 0053 0054 0055 Q_PROPERTY(MediaPlayListProxyModel *mediaPlayListProxyModel 0056 READ mediaPlayListProxyModel 0057 NOTIFY mediaPlayListProxyModelChanged) 0058 0059 0060 Q_PROPERTY(AudioWrapper *audioPlayer 0061 READ audioPlayer 0062 NOTIFY audioPlayerChanged) 0063 0064 Q_PROPERTY(ManageAudioPlayer *audioControl 0065 READ audioControl 0066 NOTIFY audioControlChanged) 0067 0068 Q_PROPERTY(ManageMediaPlayerControl *playerControl 0069 READ playerControl 0070 NOTIFY playerControlChanged) 0071 0072 Q_PROPERTY(ManageHeaderBar *manageHeaderBar 0073 READ manageHeaderBar 0074 NOTIFY manageHeaderBarChanged) 0075 0076 Q_PROPERTY(bool showNowPlayingBackground 0077 READ showNowPlayingBackground 0078 NOTIFY showNowPlayingBackgroundChanged) 0079 0080 Q_PROPERTY(bool showProgressOnTaskBar 0081 READ showProgressOnTaskBar 0082 NOTIFY showProgressOnTaskBarChanged) 0083 0084 Q_PROPERTY(bool showSystemTrayIcon 0085 READ showSystemTrayIcon 0086 NOTIFY showSystemTrayIconChanged) 0087 0088 Q_PROPERTY(bool useFavoriteStyleRatings 0089 READ useFavoriteStyleRatings 0090 NOTIFY useFavoriteStyleRatingsChanged) 0091 0092 Q_PROPERTY(QAbstractItemModel* colorSchemesModel 0093 READ colorSchemesModel 0094 CONSTANT) 0095 0096 Q_PROPERTY(int initialViewIndex 0097 READ initialViewIndex 0098 NOTIFY initialViewIndexChanged) 0099 0100 Q_PROPERTY(QString initialFilesViewPath 0101 READ initialFilesViewPath 0102 NOTIFY initialFilesViewPathChanged) 0103 0104 public: 0105 explicit ElisaApplication(QObject *parent = nullptr); 0106 0107 ~ElisaApplication() override; 0108 0109 Q_INVOKABLE QAction* action(const QString& name); 0110 Q_INVOKABLE const QString actionShortcut(QAction *action) const; 0111 0112 Q_INVOKABLE QString iconName(const QIcon& icon); 0113 0114 Q_INVOKABLE void installKeyEventFilter(QObject *object); 0115 0116 Q_INVOKABLE void showInFolder(QUrl filePath); 0117 0118 bool eventFilter(QObject *object, QEvent *event) override; 0119 0120 [[nodiscard]] MusicListenersManager *musicManager() const; 0121 0122 [[nodiscard]] MediaPlayList *mediaPlayList() const; 0123 0124 [[nodiscard]] MediaPlayListProxyModel *mediaPlayListProxyModel() const; 0125 0126 [[nodiscard]] AudioWrapper *audioPlayer() const; 0127 0128 [[nodiscard]] ManageAudioPlayer *audioControl() const; 0129 0130 [[nodiscard]] ManageMediaPlayerControl *playerControl() const; 0131 0132 [[nodiscard]] ManageHeaderBar *manageHeaderBar() const; 0133 0134 [[nodiscard]] bool showNowPlayingBackground() const; 0135 0136 [[nodiscard]] bool showProgressOnTaskBar() const; 0137 0138 [[nodiscard]] bool showSystemTrayIcon() const; 0139 0140 [[nodiscard]] bool useFavoriteStyleRatings() const; 0141 0142 [[nodiscard]] ElisaUtils::PlayListEntryType embeddedView() const; 0143 0144 int initialViewIndex() const; 0145 0146 [[nodiscard]] QString initialFilesViewPath() const; 0147 0148 Q_SIGNALS: 0149 0150 void musicManagerChanged(); 0151 0152 void mediaPlayListChanged(); 0153 0154 void mediaPlayListProxyModelChanged(); 0155 0156 void audioPlayerChanged(); 0157 0158 void audioControlChanged(); 0159 0160 void playerControlChanged(); 0161 0162 void manageHeaderBarChanged(); 0163 0164 void enqueue(const DataTypes::EntryDataList &newEntries, 0165 ElisaUtils::PlayListEnqueueMode enqueueMode, 0166 ElisaUtils::PlayListEnqueueTriggerPlay triggerPlay); 0167 0168 void initializationDone(); 0169 0170 void showNowPlayingBackgroundChanged(); 0171 0172 void showProgressOnTaskBarChanged(); 0173 0174 void showSystemTrayIconChanged(); 0175 0176 void useFavoriteStyleRatingsChanged(); 0177 0178 void commitDataRequest(QSessionManager &manager); 0179 0180 void embeddedViewChanged(); 0181 0182 void initialViewIndexChanged(); 0183 0184 void initialFilesViewPathChanged(); 0185 0186 public Q_SLOTS: 0187 0188 void appHelpActivated(); 0189 0190 void aboutApplication(); 0191 0192 void reportBug(); 0193 0194 void configureShortcuts(); 0195 0196 void configureElisa(); 0197 0198 bool openFiles(const QList<QUrl> &files); 0199 bool openFiles(const QList<QUrl> &files, const QString &workingDirectory); 0200 0201 void activateActionRequested(const QString &actionName, const QVariant ¶meter); 0202 0203 void activateRequested(const QStringList &arguments, const QString &workingDirectory); 0204 0205 void openRequested(const QList<QUrl> &uris); 0206 0207 void initialize(); 0208 0209 void activateColorScheme(const QString &name); 0210 0211 public: 0212 0213 void setQmlEngine(QQmlEngine *engine); 0214 0215 KColorSchemeManager *getSchemes(); 0216 0217 private Q_SLOTS: 0218 0219 void goBack(); 0220 0221 void find(); 0222 0223 void togglePartyMode(); 0224 0225 void togglePlaylist(); 0226 0227 void seek(); 0228 0229 void scrub(); 0230 0231 void playPause(); 0232 0233 void configChanged(); 0234 0235 void nextTrack(); 0236 0237 void previousTrack(); 0238 0239 private: 0240 0241 void initializeModels(); 0242 0243 void initializePlayer(); 0244 0245 void setupActions(const QString &actionName); 0246 0247 [[nodiscard]] DataTypes::EntryDataList checkFileListAndMakeAbsolute(const DataTypes::EntryDataList &filesList, 0248 const QString &workingDirectory) const; 0249 0250 QAbstractItemModel *colorSchemesModel(); 0251 0252 std::unique_ptr<ElisaApplicationPrivate> d; 0253 0254 }; 0255 0256 #endif // ELISAAPPLICATION_H