1 /**************************************************************************************** 2 * Copyright (c) 2002 Mark Kretschmann <kretschmann@kde.org> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef AMAROK_APP_H 18 #define AMAROK_APP_H 19 20 #include "amarok_export.h" 21 22 #include <KJob> 23 24 #include <QApplication> 25 #include <QPointer> 26 27 namespace Amarok { 28 class TrayIcon; 29 } 30 31 namespace ScriptConsoleNS{ 32 class ScriptConsole; 33 } 34 35 namespace KIO { 36 class Job; 37 } 38 39 class MediaDeviceManager; 40 class MainWindow; 41 class QCommandLineParser; 42 class QUrl; 43 44 class AMAROK_EXPORT App : public QApplication 45 { 46 Q_OBJECT 47 48 public: 49 App(int &argc, char **argv); 50 ~App() override; 51 instance()52 static App *instance() { return static_cast<App*>( qApp ); } 53 54 void continueInit(); trayIcon()55 Amarok::TrayIcon* trayIcon() const { return m_tray; } 56 void handleCliArgs(const QString &cwd); 57 void initCliArgs(QCommandLineParser *parsers); 58 59 virtual int newInstance(); 60 mainWindow()61 inline QPointer<MainWindow> mainWindow() const { return m_mainWindow; } 62 63 Q_SIGNALS: 64 void prepareToQuit(); 65 void settingsChanged(); 66 67 public Q_SLOTS: 68 void activateRequested(const QStringList & arguments, const QString & cwd); 69 void applySettings(); 70 void applySettingsFirstTime(); 71 void slotConfigAmarok( const QString& page = QString() ); 72 void slotConfigAmarokWithEmptyPage(); 73 void slotConfigShortcuts(); 74 KIO::Job *trashFiles( const QList<QUrl> &files ); 75 void quit(); 76 77 protected: 78 bool event( QEvent *event ) override; 79 80 private Q_SLOTS: 81 void slotTrashResult( KJob *job ); 82 83 private: 84 void handleFirstRun(); 85 86 // ATTRIBUTES 87 QPointer<MainWindow> m_mainWindow; 88 Amarok::TrayIcon *m_tray; 89 MediaDeviceManager *m_mediaDeviceManager; 90 QPointer<ScriptConsoleNS::ScriptConsole> m_scriptConsole; 91 QCommandLineParser *m_args; 92 QString m_cwd; 93 QStringList s_delayedAmarokUrls; 94 }; 95 96 #define pApp App::instance() 97 98 99 #endif // AMAROK_APP_H 100