1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "icontext.h" 29 #include "icore.h" 30 31 #include <utils/appmainwindow.h> 32 #include <utils/dropsupport.h> 33 34 #include <QColor> 35 36 #include <functional> 37 #include <unordered_map> 38 39 QT_BEGIN_NAMESPACE 40 class QPrinter; 41 class QToolButton; 42 QT_END_NAMESPACE 43 44 namespace Utils { 45 class InfoBar; 46 } 47 48 namespace Core { 49 50 class EditorManager; 51 class ExternalToolManager; 52 class IDocument; 53 class JsExpander; 54 class MessageManager; 55 class ModeManager; 56 class ProgressManager; 57 class NavigationWidget; 58 enum class Side; 59 class RightPaneWidget; 60 class SettingsDatabase; 61 class VcsManager; 62 63 namespace Internal { 64 65 class FancyTabWidget; 66 class GeneralSettings; 67 class ProgressManagerPrivate; 68 class ShortcutSettings; 69 class ToolSettings; 70 class MimeTypeSettings; 71 class VersionDialog; 72 class WindowSupport; 73 class SystemEditor; 74 class SystemSettings; 75 76 class MainWindow : public Utils::AppMainWindow 77 { 78 Q_OBJECT 79 80 public: 81 MainWindow(); 82 ~MainWindow() override; 83 84 void init(); 85 void extensionsInitialized(); 86 void aboutToShutdown(); 87 88 IContext *contextObject(QWidget *widget) const; 89 void addContextObject(IContext *context); 90 void removeContextObject(IContext *context); 91 92 static IDocument *openFiles(const QStringList &fileNames, 93 ICore::OpenFilesFlags flags, 94 const QString &workingDirectory = QString()); 95 settingsDatabase()96 inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; } 97 virtual QPrinter *printer() const; 98 IContext * currentContextObject() const; 99 QStatusBar *statusBar() const; 100 Utils::InfoBar *infoBar() const; 101 102 void updateAdditionalContexts(const Context &remove, const Context &add, 103 ICore::ContextPriority priority); 104 105 bool askConfirmationBeforeExit() const; 106 void setAskConfirmationBeforeExit(bool ask); 107 108 void setOverrideColor(const QColor &color); 109 110 QStringList additionalAboutInformation() const; 111 void appendAboutInformation(const QString &line); 112 113 void addPreCloseListener(const std::function<bool()> &listener); 114 115 void saveSettings(); 116 117 void restart(); 118 119 public slots: 120 static void openFileWith(); 121 void exit(); 122 123 protected: 124 void closeEvent(QCloseEvent *event) override; 125 126 private: 127 static void openFile(); 128 void aboutToShowRecentFiles(); 129 static void setFocusToEditor(); 130 void aboutQtCreator(); 131 void aboutPlugins(); 132 void contact(); 133 void updateFocusWidget(QWidget *old, QWidget *now); 134 NavigationWidget *navigationWidget(Side side) const; 135 void setSidebarVisible(bool visible, Side side); 136 void destroyVersionDialog(); 137 void openDroppedFiles(const QList<Utils::DropSupport::FileSpec> &files); 138 void restoreWindowState(); 139 140 void updateContextObject(const QList<IContext *> &context); 141 void updateContext(); 142 143 void registerDefaultContainers(); 144 void registerDefaultActions(); 145 void registerModeSelectorStyleActions(); 146 147 void readSettings(); 148 void saveWindowSettings(); 149 150 void updateModeSelectorStyleMenu(); 151 152 ICore *m_coreImpl = nullptr; 153 QStringList m_aboutInformation; 154 Context m_highPrioAdditionalContexts; 155 Context m_lowPrioAdditionalContexts; 156 SettingsDatabase *m_settingsDatabase = nullptr; 157 mutable QPrinter *m_printer = nullptr; 158 WindowSupport *m_windowSupport = nullptr; 159 EditorManager *m_editorManager = nullptr; 160 ExternalToolManager *m_externalToolManager = nullptr; 161 MessageManager *m_messageManager = nullptr; 162 ProgressManagerPrivate *m_progressManager = nullptr; 163 JsExpander *m_jsExpander = nullptr; 164 VcsManager *m_vcsManager = nullptr; 165 ModeManager *m_modeManager = nullptr; 166 FancyTabWidget *m_modeStack = nullptr; 167 NavigationWidget *m_leftNavigationWidget = nullptr; 168 NavigationWidget *m_rightNavigationWidget = nullptr; 169 RightPaneWidget *m_rightPaneWidget = nullptr; 170 VersionDialog *m_versionDialog = nullptr; 171 172 QList<IContext *> m_activeContext; 173 174 std::unordered_map<QWidget *, IContext *> m_contextWidgets; 175 176 GeneralSettings *m_generalSettings = nullptr; 177 SystemSettings *m_systemSettings = nullptr; 178 ShortcutSettings *m_shortcutSettings = nullptr; 179 ToolSettings *m_toolSettings = nullptr; 180 MimeTypeSettings *m_mimeTypeSettings = nullptr; 181 SystemEditor *m_systemEditor = nullptr; 182 183 // actions 184 QAction *m_focusToEditor = nullptr; 185 QAction *m_newAction = nullptr; 186 QAction *m_openAction = nullptr; 187 QAction *m_openWithAction = nullptr; 188 QAction *m_saveAllAction = nullptr; 189 QAction *m_exitAction = nullptr; 190 QAction *m_optionsAction = nullptr; 191 QAction *m_toggleLeftSideBarAction = nullptr; 192 QAction *m_toggleRightSideBarAction = nullptr; 193 QAction *m_cycleModeSelectorStyleAction = nullptr; 194 QAction *m_setModeSelectorStyleIconsAndTextAction = nullptr; 195 QAction *m_setModeSelectorStyleHiddenAction = nullptr; 196 QAction *m_setModeSelectorStyleIconsOnlyAction = nullptr; 197 QAction *m_themeAction = nullptr; 198 199 QToolButton *m_toggleLeftSideBarButton = nullptr; 200 QToolButton *m_toggleRightSideBarButton = nullptr; 201 bool m_askConfirmationBeforeExit = false; 202 QColor m_overrideColor; 203 QList<std::function<bool()>> m_preCloseListeners; 204 }; 205 206 } // namespace Internal 207 } // namespace Core 208