mainwindow.h 6.22 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
Eike Ziller's avatar
Eike Ziller committed
12 13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** use the contact form at http://www.qt.io/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18 19 20 21 22 23
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
Eike Ziller's avatar
Eike Ziller committed
25 26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company LGPL Exception
con's avatar
con committed
27 28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
hjk's avatar
hjk committed
30

con's avatar
con committed
31 32 33
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

34
#include "icontext.h"
35
#include "icore.h"
36

37
#include <utils/appmainwindow.h>
38
#include <utils/dropsupport.h>
39

40 41
#include <QMap>
#include <QColor>
con's avatar
con committed
42

43 44
#include <functional>

con's avatar
con committed
45 46
QT_BEGIN_NAMESPACE
class QSettings;
47 48
class QPrinter;
class QToolButton;
con's avatar
con committed
49 50 51 52
QT_END_NAMESPACE

namespace Core {

53
class StatusBarWidget;
con's avatar
con committed
54
class EditorManager;
55
class ExternalToolManager;
56
class DocumentManager;
kh1's avatar
kh1 committed
57
class HelpManager;
58
class IDocument;
Tobias Hunger's avatar
Tobias Hunger committed
59
class IWizardFactory;
60
class JsExpander;
con's avatar
con committed
61
class MessageManager;
hjk's avatar
hjk committed
62
class ModeManager;
63
class ProgressManager;
64
class NavigationWidget;
hjk's avatar
hjk committed
65
class RightPaneWidget;
66
class SettingsDatabase;
hjk's avatar
hjk committed
67
class VcsManager;
con's avatar
con committed
68 69 70 71

namespace Internal {

class FancyTabWidget;
hjk's avatar
hjk committed
72
class GeneralSettings;
73
class ProgressManagerPrivate;
hjk's avatar
hjk committed
74
class ShortcutSettings;
75
class ToolSettings;
76
class MimeTypeSettings;
con's avatar
con committed
77
class StatusBarManager;
78
class VersionDialog;
79
class WindowSupport;
80
class SystemEditor;
81
class SystemSettings;
con's avatar
con committed
82

83
class MainWindow : public Utils::AppMainWindow
con's avatar
con committed
84 85 86 87 88 89 90
{
    Q_OBJECT

public:
    MainWindow();
    ~MainWindow();

91
    bool init(QString *errorMessage);
con's avatar
con committed
92
    void extensionsInitialized();
93
    void aboutToShutdown();
con's avatar
con committed
94 95

    IContext *contextObject(QWidget *widget);
Orgad Shaneh's avatar
Orgad Shaneh committed
96 97
    void addContextObject(IContext *context);
    void removeContextObject(IContext *context);
con's avatar
con committed
98

99 100 101
    IDocument *openFiles(const QStringList &fileNames,
                         ICore::OpenFilesFlags flags,
                         const QString &workingDirectory = QString());
con's avatar
con committed
102

103
    inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
con's avatar
con committed
104 105 106 107
    virtual QPrinter *printer() const;
    IContext * currentContextObject() const;
    QStatusBar *statusBar() const;

108 109
    void updateAdditionalContexts(const Context &remove, const Context &add,
                                  ICore::ContextPriority priority);
con's avatar
con committed
110 111 112

    void setSuppressNavigationWidget(bool suppress);

113 114
    void setOverrideColor(const QColor &color);

115 116 117
    QStringList additionalAboutInformation() const;
    void appendAboutInformation(const QString &line);

118 119
    void addPreCloseListener(const std::function<bool()> &listener);

con's avatar
con committed
120
signals:
121
    void newItemDialogRunningChanged();
con's avatar
con committed
122 123 124 125 126

public slots:
    void openFileWith();
    void exit();

127
    bool showOptionsDialog(Id page = Id(), QWidget *parent = 0);
con's avatar
con committed
128

129 130
    bool showWarningWithOptions(const QString &title, const QString &text,
                                const QString &details = QString(),
hjk's avatar
hjk committed
131
                                Id settingsId = Id(),
132 133
                                QWidget *parent = 0);

con's avatar
con committed
134
protected:
135
    virtual void closeEvent(QCloseEvent *event);
con's avatar
con committed
136 137 138 139 140 141 142 143 144

private slots:
    void openFile();
    void aboutToShowRecentFiles();
    void setFocusToEditor();
    void saveAll();
    void aboutQtCreator();
    void aboutPlugins();
    void updateFocusWidget(QWidget *old, QWidget *now);
145
    void setSidebarVisible(bool visible);
146
    void destroyVersionDialog();
147
    void openDroppedFiles(const QList<Utils::DropSupport::FileSpec> &files);
148
    void restoreWindowState();
149
    void newItemDialogFinished();
con's avatar
con committed
150 151

private:
152
    void updateContextObject(const QList<IContext *> &context);
153 154
    void updateContext();

con's avatar
con committed
155 156 157 158 159 160
    void registerDefaultContainers();
    void registerDefaultActions();

    void readSettings();
    void writeSettings();

hjk's avatar
hjk committed
161
    ICore *m_coreImpl;
162
    QStringList m_aboutInformation;
163 164
    Context m_highPrioAdditionalContexts;
    Context m_lowPrioAdditionalContexts;
165
    SettingsDatabase *m_settingsDatabase;
con's avatar
con committed
166
    mutable QPrinter *m_printer;
167
    WindowSupport *m_windowSupport;
con's avatar
con committed
168
    EditorManager *m_editorManager;
169
    ExternalToolManager *m_externalToolManager;
con's avatar
con committed
170
    MessageManager *m_messageManager;
171
    ProgressManagerPrivate *m_progressManager;
172
    JsExpander *m_jsExpander;
hjk's avatar
hjk committed
173
    VcsManager *m_vcsManager;
con's avatar
con committed
174
    StatusBarManager *m_statusBarManager;
con's avatar
con committed
175
    ModeManager *m_modeManager;
kh1's avatar
kh1 committed
176
    HelpManager *m_helpManager;
con's avatar
con committed
177 178 179
    FancyTabWidget *m_modeStack;
    NavigationWidget *m_navigationWidget;
    RightPaneWidget *m_rightPaneWidget;
Orgad Shaneh's avatar
Orgad Shaneh committed
180
    StatusBarWidget *m_outputView;
181
    VersionDialog *m_versionDialog;
con's avatar
con committed
182

183
    QList<IContext *> m_activeContext;
con's avatar
con committed
184 185 186 187

    QMap<QWidget *, IContext *> m_contextWidgets;

    GeneralSettings *m_generalSettings;
188
    SystemSettings *m_systemSettings;
con's avatar
con committed
189
    ShortcutSettings *m_shortcutSettings;
190
    ToolSettings *m_toolSettings;
191
    MimeTypeSettings *m_mimeTypeSettings;
192
    SystemEditor *m_systemEditor;
con's avatar
con committed
193 194

    // actions
195
    QAction *m_focusToEditor;
con's avatar
con committed
196 197 198 199 200 201 202
    QAction *m_newAction;
    QAction *m_openAction;
    QAction *m_openWithAction;
    QAction *m_saveAllAction;
    QAction *m_exitAction;
    QAction *m_optionsAction;
    QAction *m_toggleSideBarAction;
203
    QAction *m_toggleModeSelectorAction;
204
    QAction *m_themeAction;
con's avatar
con committed
205 206

    QToolButton *m_toggleSideBarButton;
207
    QColor m_overrideColor;
208
    QList<std::function<bool()>> m_preCloseListeners;
con's avatar
con committed
209 210 211 212 213 214
};

} // namespace Internal
} // namespace Core

#endif // MAINWINDOW_H