~ubuntu-branches/ubuntu/maverick/amarok/maverick-backports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/****************************************************************************************
 * Copyright (c) 2002 Mark Kretschmann <kretschmann@kde.org>                            *
 *                                                                                      *
 * This program is free software; you can redistribute it and/or modify it under        *
 * the terms of the GNU General Public License as published by the Free Software        *
 * Foundation; either version 2 of the License, or (at your option) any later           *
 * version.                                                                             *
 *                                                                                      *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
 *                                                                                      *
 * You should have received a copy of the GNU General Public License along with         *
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
 ****************************************************************************************/

#ifndef AMAROK_APP_H
#define AMAROK_APP_H

#include <config-amarok.h>

#include "aboutdialog/OcsData.h"
#include "amarok_export.h"
#include "MainWindow.h"

#include <KAboutData>
#include <KSplashScreen>
#include <KUniqueApplication>   //baseclass
#include <KUrl>

#include <QHash>
#include <QPointer>
#include <QString>

namespace Amarok {
    class TrayIcon;
}

class OcsData;

namespace KIO { class Job; }

class KJob;
class MediaDeviceManager;

class AMAROK_EXPORT App : public KUniqueApplication
{
    Q_OBJECT

    public:
        App();
       ~App();

        static App *instance() { return static_cast<App*>( kapp ); }

        void setUniqueInstance( bool isUnique ) { m_isUniqueInstance = isUnique; }
        bool isNonUniqueInstance() const { return m_isUniqueInstance; }

        Amarok::TrayIcon* trayIcon() const { return m_tray; }
        static void handleCliArgs();
        static void initCliArgs( int argc, char *argv[] );
        static void initCliArgs();

        static int mainThreadId;

        virtual int newInstance();

        inline MainWindow *mainWindow() const { return m_mainWindow; }

        /**
         * Determines location of the "amarokcollectionscanner" tool.
         *
         * @return path of the collection scanner binary.
         */
        static QString collectionScannerLocation();

        // FRIENDS
        friend class MainWindow; //requires access to applySettings()

    signals:
        void prepareToQuit();
        void settingsChanged();

    private slots:
        void continueInit();
        void resizeMainWindow();

    public slots:
        void applySettings( bool firstTime = false );
#ifdef DEBUG
        static void runUnitTests( const QStringList options, bool _stdout );
#endif // DEBUG
        void slotConfigAmarok( const QString& page = QString() );
        void slotConfigShortcuts();
        KIO::Job *trashFiles( const KUrl::List &files );
        void quit();

    protected:
        virtual bool event( QEvent *event );

    private slots:
        void slotTrashResult( KJob *job );

        /**
         * Checks version of the "amarokcollectionscanner" tool.
         * If the version does not match, it shows an error dialog.
         */
        void checkCollectionScannerVersion();

    private:
        // ATTRIBUTES
        bool                    m_isUniqueInstance;
        QPointer<MainWindow>    m_mainWindow;
        Amarok::TrayIcon        *m_tray;
        MediaDeviceManager      *m_mediaDeviceManager;

        static QStringList       s_delayedAmarokUrls;
};

#define pApp static_cast<App*>(kapp)


#endif  // AMAROK_APP_H