File indexing completed on 2024-05-12 16:01:44
0001 /* 0002 * SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org> 0003 * SPDX-FileCopyrightText: 2012 Boudewijn Rempt <boud@valdyas.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KIS_APPLICATION_H 0009 #define KIS_APPLICATION_H 0010 0011 #include <QPointer> 0012 #include <QScopedPointer> 0013 #include <qtsingleapplication/qtsingleapplication.h> 0014 #include "kritaui_export.h" 0015 0016 class KisMainWindow; 0017 class KisApplicationPrivate; 0018 class QWidget; 0019 class KisApplicationArguments; 0020 class KisAutoSaveRecoveryDialog; 0021 0022 #include <KisImportExportManager.h> 0023 0024 /** 0025 * @brief Base class for the %Krita app 0026 * 0027 * This class handles arguments given on the command line and 0028 * shows a generic about dialog for the Krita app. 0029 * 0030 * In addition it adds the standard directories where Krita 0031 * can find its images etc. 0032 * 0033 * If the last mainwindow becomes closed, KisApplication automatically 0034 * calls QApplication::quit. 0035 */ 0036 class KRITAUI_EXPORT KisApplication : public QtSingleApplication 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 /** 0042 * Creates an application object, adds some standard directories and 0043 * initializes kimgio. 0044 */ 0045 explicit KisApplication(const QString &key, int &argc, char **argv); 0046 0047 /** 0048 * Destructor. 0049 */ 0050 ~KisApplication() override; 0051 0052 /** 0053 * Call this to start the application. 0054 * 0055 * Parses command line arguments and creates the initial main windowss and docs 0056 * from them (or an empty doc if no cmd-line argument is specified ). 0057 * 0058 * You must call this method directly before calling QApplication::exec. 0059 * 0060 * It is valid behaviour not to call this method at all. In this case you 0061 * have to process your command line parameters by yourself. 0062 */ 0063 virtual bool start(const KisApplicationArguments &args); 0064 0065 bool event(QEvent *event) override; 0066 0067 /** 0068 * Checks if user is holding ctrl+alt+shift keys and asks if the settings file should be cleared. 0069 * 0070 * Typically called during startup before reading the config. 0071 */ 0072 void askResetConfig(); 0073 0074 /** 0075 * Tell KisApplication to show this splashscreen when you call start(); 0076 * when start returns, the splashscreen is hidden. Use KSplashScreen 0077 * to have the splash show correctly on Xinerama displays. 0078 */ 0079 void setSplashScreen(QWidget *splash); 0080 void hideSplashScreen(); 0081 0082 /// Overridden to handle exceptions from event handlers. 0083 bool notify(QObject *receiver, QEvent *event) override; 0084 0085 void addResourceTypes(); 0086 bool registerResources(); 0087 void loadPlugins(); 0088 void initializeGlobals(const KisApplicationArguments &args); 0089 void processPostponedSynchronizationEvents(); 0090 0091 0092 public Q_SLOTS: 0093 0094 void executeRemoteArguments(QByteArray message, KisMainWindow *mainWindow); 0095 void remoteArguments(QByteArray message, QObject*socket); 0096 void fileOpenRequested(const QString & url); 0097 void setSplashScreenLoadingText(const QString&); 0098 0099 private: 0100 /// @return the number of autosavefiles opened 0101 void checkAutosaveFiles(); 0102 bool createNewDocFromTemplate(const QString &fileName, KisMainWindow *m_mainWindow); 0103 void resetConfig(); 0104 0105 private: 0106 class Private; 0107 QScopedPointer<Private> d; 0108 class ResetStarting; 0109 friend class ResetStarting; 0110 }; 0111 0112 #endif