File indexing completed on 2024-04-21 04:47:49

0001 /****************************************************************************************
0002  * Copyright (c) 2002 Mark Kretschmann <kretschmann@kde.org>                            *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef AMAROK_APP_H
0018 #define AMAROK_APP_H
0019 
0020 #include "amarok_export.h"
0021 
0022 #include <KJob>
0023 
0024 #include <QApplication>
0025 #include <QPointer>
0026 
0027 namespace Amarok {
0028     class TrayIcon;
0029 }
0030 
0031 namespace ScriptConsoleNS{
0032     class ScriptConsole;
0033 }
0034 
0035 namespace KIO {
0036     class Job;
0037 }
0038 
0039 class MediaDeviceManager;
0040 class MainWindow;
0041 class QCommandLineParser;
0042 class QUrl;
0043 
0044 class AMAROK_EXPORT App : public QApplication
0045 {
0046     Q_OBJECT
0047 
0048     public:
0049         App(int &argc, char **argv);
0050         ~App() override;
0051 
0052         static App *instance() { return static_cast<App*>( qApp ); }
0053 
0054         void continueInit();
0055         Amarok::TrayIcon* trayIcon() const { return m_tray; }
0056         void handleCliArgs(const QString &cwd);
0057         void initCliArgs(QCommandLineParser *parsers);
0058 
0059         virtual int newInstance();
0060 
0061         inline QPointer<MainWindow> mainWindow() const { return m_mainWindow; }
0062 
0063     Q_SIGNALS:
0064         void prepareToQuit();
0065         void settingsChanged();
0066 
0067     public Q_SLOTS:
0068         void activateRequested(const QStringList &  arguments, const QString & cwd);
0069         void applySettings();
0070         void applySettingsFirstTime();
0071         void slotConfigAmarok( const QString& page = QString() );
0072         void slotConfigAmarokWithEmptyPage();
0073         void slotConfigShortcuts();
0074         KIO::Job *trashFiles( const QList<QUrl> &files );
0075         void quit();
0076 
0077     protected:
0078         bool event( QEvent *event ) override;
0079 
0080     private Q_SLOTS:
0081         void slotTrashResult( KJob *job );
0082 
0083     private:
0084         void handleFirstRun();
0085 
0086         // ATTRIBUTES
0087         QPointer<MainWindow>        m_mainWindow;
0088         Amarok::TrayIcon            *m_tray;
0089         MediaDeviceManager          *m_mediaDeviceManager;
0090         QPointer<ScriptConsoleNS::ScriptConsole> m_scriptConsole;
0091         QCommandLineParser          *m_args;
0092         QString                     m_cwd;
0093         QStringList                 s_delayedAmarokUrls;
0094 };
0095 
0096 #define pApp App::instance()
0097 
0098 
0099 #endif  // AMAROK_APP_H