mainwindow.h 7.06 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
con's avatar
con committed
9
** No Commercial Usage
10
**
con's avatar
con committed
11 12 13 14
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
15
**
16
** GNU Lesser General Public License Usage
17
**
18 19 20 21 22 23
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
con's avatar
con committed
25 26 27 28 29 30
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
con's avatar
con committed
31
**
32
**************************************************************************/
hjk's avatar
hjk committed
33

con's avatar
con committed
34 35 36
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

37
#include "eventfilteringmainwindow.h"
38
#include "icontext.h"
39
#include "icore.h"
40

con's avatar
con committed
41
#include <QtCore/QMap>
42
#include <QtGui/QColor>
con's avatar
con committed
43 44 45 46

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

namespace Core {

53
class ActionManager;
54
class StatusBarWidget;
con's avatar
con committed
55
class EditorManager;
56
class ExternalToolManager;
con's avatar
con committed
57
class FileManager;
kh1's avatar
kh1 committed
58
class HelpManager;
59
class IWizard;
con's avatar
con committed
60 61
class MessageManager;
class MimeDatabase;
hjk's avatar
hjk committed
62
class ModeManager;
63
class ProgressManager;
64
class NavigationWidget;
hjk's avatar
hjk committed
65
class RightPaneWidget;
66
class ScriptManager;
67
class SettingsDatabase;
con's avatar
con committed
68 69
class UniqueIDManager;
class VariableManager;
hjk's avatar
hjk committed
70
class VcsManager;
con's avatar
con committed
71 72 73

namespace Internal {

74
class ActionManagerPrivate;
hjk's avatar
hjk committed
75
class CoreImpl;
con's avatar
con committed
76
class FancyTabWidget;
hjk's avatar
hjk committed
77
class GeneralSettings;
78
class ProgressManagerPrivate;
hjk's avatar
hjk committed
79
class ShortcutSettings;
80
class ToolSettings;
81
class MimeTypeSettings;
con's avatar
con committed
82
class StatusBarManager;
83
class VersionDialog;
84
class SystemEditor;
con's avatar
con committed
85

86
class MainWindow : public EventFilteringMainWindow
con's avatar
con committed
87 88 89 90 91 92 93
{
    Q_OBJECT

public:
    MainWindow();
    ~MainWindow();

94
    bool init(QString *errorMessage);
con's avatar
con committed
95
    void extensionsInitialized();
96
    void aboutToShutdown();
con's avatar
con committed
97 98 99 100 101 102

    IContext *contextObject(QWidget *widget);
    void addContextObject(IContext *contex);
    void removeContextObject(IContext *contex);
    void resetContext();

103
    void openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags);
con's avatar
con committed
104

105
    Core::ActionManager *actionManager() const;
con's avatar
con committed
106 107 108 109
    Core::FileManager *fileManager() const;
    Core::UniqueIDManager *uniqueIDManager() const;
    Core::MessageManager *messageManager() const;
    Core::EditorManager *editorManager() const;
110
    Core::ProgressManager *progressManager() const;
111
    Core::ScriptManager *scriptManager() const;
con's avatar
con committed
112 113 114
    Core::VariableManager *variableManager() const;
    Core::ModeManager *modeManager() const;
    Core::MimeDatabase *mimeDatabase() const;
kh1's avatar
kh1 committed
115
    Core::HelpManager *helpManager() const;
con's avatar
con committed
116

hjk's avatar
hjk committed
117
    VcsManager *vcsManager() const;
118
    QSettings *settings(QSettings::Scope scope) const;
119
    inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
con's avatar
con committed
120 121 122 123
    virtual QPrinter *printer() const;
    IContext * currentContextObject() const;
    QStatusBar *statusBar() const;

124
    void updateAdditionalContexts(const Context &remove, const Context &add);
125
    bool hasContext(int context) const;
con's avatar
con committed
126 127 128

    void setSuppressNavigationWidget(bool suppress);

129 130
    void setOverrideColor(const QColor &color);

con's avatar
con committed
131 132 133 134 135 136 137
signals:
    void windowActivated();

public slots:
    void newFile();
    void openFileWith();
    void exit();
hjk's avatar
hjk committed
138
    void setFullScreen(bool on);
con's avatar
con committed
139

140 141 142
    void showNewItemDialog(const QString &title,
                           const QList<IWizard *> &wizards,
                           const QString &defaultLocation = QString());
con's avatar
con committed
143

144 145 146
    bool showOptionsDialog(const QString &category = QString(),
                           const QString &page = QString(),
                           QWidget *parent = 0);
con's avatar
con committed
147

148 149 150 151 152 153
    bool showWarningWithOptions(const QString &title, const QString &text,
                                const QString &details = QString(),
                                const QString &settingsCategory = QString(),
                                const QString &settingsId = QString(),
                                QWidget *parent = 0);

con's avatar
con committed
154
protected:
155 156 157 158
    virtual void changeEvent(QEvent *e);
    virtual void closeEvent(QCloseEvent *event);
    virtual void dragEnterEvent(QDragEnterEvent *event);
    virtual void dropEvent(QDropEvent *event);
con's avatar
con committed
159 160 161 162 163 164 165 166 167 168

private slots:
    void openFile();
    void aboutToShowRecentFiles();
    void openRecentFile();
    void setFocusToEditor();
    void saveAll();
    void aboutQtCreator();
    void aboutPlugins();
    void updateFocusWidget(QWidget *old, QWidget *now);
169
    void setSidebarVisible(bool visible);
170
    void destroyVersionDialog();
171
    void openDelayedFiles();
con's avatar
con committed
172 173 174

private:
    void updateContextObject(IContext *context);
175 176
    void updateContext();

con's avatar
con committed
177 178 179 180 181 182 183 184
    void registerDefaultContainers();
    void registerDefaultActions();

    void readSettings();
    void writeSettings();

    CoreImpl *m_coreImpl;
    UniqueIDManager *m_uniqueIDManager;
185
    Context m_additionalContexts;
con's avatar
con committed
186
    QSettings *m_settings;
187
    QSettings *m_globalSettings;
188
    SettingsDatabase *m_settingsDatabase;
con's avatar
con committed
189
    mutable QPrinter *m_printer;
190
    ActionManagerPrivate *m_actionManager;
con's avatar
con committed
191
    EditorManager *m_editorManager;
192
    ExternalToolManager *m_externalToolManager;
con's avatar
con committed
193 194
    FileManager *m_fileManager;
    MessageManager *m_messageManager;
195
    ProgressManagerPrivate *m_progressManager;
196
    ScriptManager *m_scriptManager;
Friedemann Kleint's avatar
Friedemann Kleint committed
197
    QScopedPointer<VariableManager> m_variableManager;
hjk's avatar
hjk committed
198
    VcsManager *m_vcsManager;
con's avatar
con committed
199
    StatusBarManager *m_statusBarManager;
con's avatar
con committed
200 201
    ModeManager *m_modeManager;
    MimeDatabase *m_mimeDatabase;
kh1's avatar
kh1 committed
202
    HelpManager *m_helpManager;
con's avatar
con committed
203 204 205
    FancyTabWidget *m_modeStack;
    NavigationWidget *m_navigationWidget;
    RightPaneWidget *m_rightPaneWidget;
206
    Core::StatusBarWidget *m_outputView;
207
    VersionDialog *m_versionDialog;
con's avatar
con committed
208

209
    IContext *m_activeContext;
con's avatar
con committed
210 211 212 213 214

    QMap<QWidget *, IContext *> m_contextWidgets;

    GeneralSettings *m_generalSettings;
    ShortcutSettings *m_shortcutSettings;
215
    ToolSettings *m_toolSettings;
216
    MimeTypeSettings *m_mimeTypeSettings;
217
    SystemEditor *m_systemEditor;
con's avatar
con committed
218 219 220 221 222 223 224 225 226 227

    // actions
    QShortcut *m_focusToEditor;
    QAction *m_newAction;
    QAction *m_openAction;
    QAction *m_openWithAction;
    QAction *m_saveAllAction;
    QAction *m_exitAction;
    QAction *m_optionsAction;
    QAction *m_toggleSideBarAction;
hjk's avatar
hjk committed
228
    QAction *m_toggleFullScreenAction;
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
229
#ifdef Q_WS_MAC
con's avatar
con committed
230 231 232 233 234
    QAction *m_minimizeAction;
    QAction *m_zoomAction;
#endif

    QToolButton *m_toggleSideBarButton;
235
    QColor m_overrideColor;
236 237

    QStringList m_filesToOpenDelayed;
con's avatar
con committed
238 239 240 241 242 243
};

} // namespace Internal
} // namespace Core

#endif // MAINWINDOW_H