File indexing completed on 2024-04-21 05:51:21
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef APPLICATION_H 0008 #define APPLICATION_H 0009 0010 // Qt 0011 #include <QCommandLineParser> 0012 0013 // Konsole 0014 #include "konsoleapp_export.h" 0015 #include "pluginsystem/PluginManager.h" 0016 #include "profile/Profile.h" 0017 #include "terminalDisplay/TerminalDisplay.h" 0018 #include "widgets/ViewSplitter.h" 0019 0020 namespace Konsole 0021 { 0022 class MainWindow; 0023 class Session; 0024 class Profile; 0025 0026 /** 0027 * The Konsole Application. 0028 * 0029 * The application consists of one or more main windows and a set of 0030 * factories to create new sessions and views. 0031 * 0032 * To create a new main window with a default terminal session, call 0033 * the newInstance(). Empty main windows can be created using newMainWindow(). 0034 * 0035 * The factory used to create new terminal sessions can be retrieved using 0036 * the sessionManager() accessor. 0037 */ 0038 class KONSOLEAPP_EXPORT Application : public QObject 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 /** Constructs a new Konsole application. */ 0044 explicit Application(QSharedPointer<QCommandLineParser> parser, const QStringList &customCommand); 0045 0046 static void populateCommandLineParser(QCommandLineParser *parser); 0047 static QStringList getCustomCommand(QStringList &args); 0048 0049 ~Application() override; 0050 0051 /** Creates a new main window and opens a default terminal session */ 0052 int newInstance(); 0053 0054 /** 0055 * Creates a new, empty main window and connects to its newSessionRequest() 0056 * and newWindowRequest() signals to trigger creation of new sessions or 0057 * windows when then they are emitted. 0058 */ 0059 MainWindow *newMainWindow(); 0060 0061 private Q_SLOTS: 0062 void createWindow(const QExplicitlySharedDataPointer<Profile> &profile, const QString &directory); 0063 void detachTerminals(MainWindow *currentWindow, ViewSplitter *splitter, const QHash<TerminalDisplay *, Session *> &sessionsMap); 0064 0065 void toggleBackgroundInstance(); 0066 0067 public Q_SLOTS: 0068 void slotActivateRequested(QStringList args, const QString &workingDir); 0069 0070 private: 0071 Q_DISABLE_COPY(Application) 0072 0073 void listAvailableProfiles(); 0074 void listProfilePropertyInfo(); 0075 void startBackgroundMode(MainWindow *window); 0076 bool processHelpArgs(); 0077 MainWindow *processWindowArgs(bool &createdNewMainWindow); 0078 QExplicitlySharedDataPointer<Profile> processProfileSelectArgs(); 0079 QExplicitlySharedDataPointer<Profile> processProfileChangeArgs(QExplicitlySharedDataPointer<Profile> baseProfile); 0080 bool processTabsFromFileArgs(MainWindow *window); 0081 void createTabFromArgs(MainWindow *window, const QHash<QString, QString> &); 0082 0083 MainWindow *_backgroundInstance; 0084 QSharedPointer<QCommandLineParser> m_parser; 0085 QStringList m_customCommand; 0086 PluginManager m_pluginManager; 0087 }; 0088 } 0089 #endif // APPLICATION_H