| 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 <config-amarok.h> |
| 21 |
|
| 22 |
#include "aboutdialog/OcsData.h" |
| 23 |
#include "amarok_export.h" |
| 24 |
#include "MainWindow.h" |
| 25 |
|
| 26 |
#include <KAboutData> |
| 27 |
#include <KSplashScreen> |
| 28 |
#include <KUniqueApplication> //baseclass |
| 29 |
#include <KUrl> |
| 30 |
|
| 31 |
#include <QHash> |
| 32 |
#include <QPointer> |
| 33 |
#include <QString> |
| 34 |
|
| 35 |
namespace Amarok { |
| 36 |
class TrayIcon; |
| 37 |
} |
| 38 |
|
| 39 |
class OcsData; |
| 40 |
|
| 41 |
namespace KIO { class Job; } |
| 42 |
|
| 43 |
class KJob; |
| 44 |
class MediaDeviceManager; |
| 45 |
|
| 46 |
class AMAROK_EXPORT App : public KUniqueApplication |
| 47 |
{ |
| 48 |
Q_OBJECT |
| 49 |
|
| 50 |
public: |
| 51 |
App(); |
| 52 |
~App(); |
| 53 |
|
| 54 |
static App *instance() { return static_cast<App*>( kapp ); } |
| 55 |
|
| 56 |
void setUniqueInstance( bool isUnique ) { m_isUniqueInstance = isUnique; } |
| 57 |
bool isNonUniqueInstance() const { return m_isUniqueInstance; } |
| 58 |
|
| 59 |
Amarok::TrayIcon* trayIcon() const { return m_tray; } |
| 60 |
static void handleCliArgs(); |
| 61 |
static void initCliArgs( int argc, char *argv[] ); |
| 62 |
static void initCliArgs(); |
| 63 |
|
| 64 |
static int mainThreadId; |
| 65 |
|
| 66 |
virtual int newInstance(); |
| 67 |
|
| 68 |
inline MainWindow *mainWindow() const { return m_mainWindow; } |
| 69 |
|
| 70 |
/** |
| 71 |
* Determines location of the "amarokcollectionscanner" tool. |
| 72 |
* |
| 73 |
* @return path of the collection scanner binary. |
| 74 |
*/ |
| 75 |
static QString collectionScannerLocation(); |
| 76 |
|
| 77 |
// FRIENDS |
| 78 |
friend class MainWindow; //requires access to applySettings() |
| 79 |
|
| 80 |
signals: |
| 81 |
void prepareToQuit(); |
| 82 |
void settingsChanged(); |
| 83 |
|
| 84 |
private slots: |
| 85 |
void continueInit(); |
| 86 |
void resizeMainWindow(); |
| 87 |
|
| 88 |
public slots: |
| 89 |
void applySettings( bool firstTime = false ); |
| 90 |
#ifdef DEBUG |
| 91 |
static void runUnitTests( const QStringList options, bool _stdout ); |
| 92 |
#endif // DEBUG |
| 93 |
void slotConfigAmarok( const QString& page = QString() ); |
| 94 |
void slotConfigShortcuts(); |
| 95 |
KIO::Job *trashFiles( const KUrl::List &files ); |
| 96 |
void quit(); |
| 97 |
|
| 98 |
protected: |
| 99 |
virtual bool event( QEvent *event ); |
| 100 |
|
| 101 |
private slots: |
| 102 |
void slotTrashResult( KJob *job ); |
| 103 |
|
| 104 |
/** |
| 105 |
* Checks version of the "amarokcollectionscanner" tool. |
| 106 |
* If the version does not match, it shows an error dialog. |
| 107 |
*/ |
| 108 |
void checkCollectionScannerVersion(); |
| 109 |
|
| 110 |
private: |
| 111 |
// ATTRIBUTES |
| 112 |
bool m_isUniqueInstance; |
| 113 |
QPointer<MainWindow> m_mainWindow; |
| 114 |
Amarok::TrayIcon *m_tray; |
| 115 |
MediaDeviceManager *m_mediaDeviceManager; |
| 116 |
|
| 117 |
static QStringList s_delayedAmarokUrls; |
| 118 |
}; |
| 119 |
|
| 120 |
#define pApp static_cast<App*>(kapp) |
| 121 |
|
| 122 |
|
| 123 |
#endif // AMAROK_APP_H |