File indexing completed on 2024-10-06 04:25:57
0001 /* 0002 SPDX-FileCopyrightText: 2003-2009 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-FileCopyrightText: 2010-2010 Michal Malek <michalm@jabster.pl> 0004 SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 0010 #ifndef _K3B_APPLICATION_H_ 0011 #define _K3B_APPLICATION_H_ 0012 0013 #include "k3bcore.h" 0014 0015 #include <QMap> 0016 #include <QScopedPointer> 0017 #include <QApplication> 0018 0019 #define k3bappcore K3b::Application::Core::k3bAppCore() 0020 0021 class QCommandLineParser; 0022 0023 namespace K3b { 0024 class MainWindow; 0025 class ThemeManager; 0026 class ProjectManager; 0027 class AppDeviceManager; 0028 0029 class Application : public QApplication 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 Application( int& argc, char** argv ); 0035 ~Application() override; 0036 0037 void init( QCommandLineParser* commandLineParser ); 0038 0039 class Core; 0040 0041 private Q_SLOTS: 0042 void slotShutDown(); 0043 0044 private: 0045 Q_INVOKABLE void checkSystemConfig(); 0046 Q_INVOKABLE void processCmdLineArgs(); 0047 0048 QScopedPointer<QCommandLineParser> m_cmdLine; 0049 Core* m_core; 0050 MainWindow* m_mainWindow; 0051 }; 0052 0053 0054 /** 0055 * The application's core which extends Core with some additional features 0056 * like the thememanager or an enhanced device manager. 0057 */ 0058 class Application::Core : public K3b::Core 0059 { 0060 Q_OBJECT 0061 0062 public: 0063 Core( QObject* parent ); 0064 ~Core() override; 0065 0066 Q_INVOKABLE void init() override; 0067 0068 Q_INVOKABLE void readSettings( KSharedConfig::Ptr c ) override; 0069 Q_INVOKABLE void saveSettings( KSharedConfig::Ptr c ) override; 0070 0071 AppDeviceManager* appDeviceManager() const; 0072 0073 ThemeManager* themeManager() const { return m_themeManager; } 0074 0075 ProjectManager* projectManager() const { return m_projectManager; } 0076 0077 MainWindow* k3bMainWindow() const { return m_mainWindow; } 0078 0079 static Core* k3bAppCore() { return s_k3bAppCore; } 0080 0081 Q_SIGNALS: 0082 /** 0083 * Any component may request busy info 0084 * In the K3b main app this will be displayed 0085 * as a moving square in the taskbar 0086 * 0087 * FIXME: this is bad design 0088 */ 0089 void busyInfoRequested( const QString& ); 0090 0091 /** 0092 * FIXME: this is bad design 0093 */ 0094 void busyFinishRequested(); 0095 0096 private: 0097 Device::DeviceManager* createDeviceManager() const override; 0098 0099 bool internalBlockDevice( Device::Device* ) override; 0100 void internalUnblockDevice( Device::Device* ) override; 0101 0102 ThemeManager* m_themeManager; 0103 MainWindow* m_mainWindow; 0104 ProjectManager* m_projectManager; 0105 0106 QMap<Device::Device*, int> m_deviceBlockMap; 0107 0108 static Core* s_k3bAppCore; 0109 0110 friend class K3b::Application; 0111 }; 0112 } 0113 0114 #endif