Files
qt-creator/src/plugins/coreplugin/mainwindow.h

206 lines
5.8 KiB
C
Raw Normal View History

/****************************************************************************
2008-12-02 12:01:29 +01:00
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
2008-12-02 12:01:29 +01:00
**
** This file is part of Qt Creator.
2008-12-02 12:01:29 +01:00
**
** 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
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
2010-12-17 16:01:08 +01:00
**
****************************************************************************/
2008-12-02 14:09:21 +01:00
#pragma once
2008-12-02 12:01:29 +01:00
#include "icontext.h"
#include "icore.h"
#include <utils/appmainwindow.h>
#include <utils/dropsupport.h>
#include <QMap>
#include <QColor>
2008-12-02 12:01:29 +01:00
#include <functional>
2008-12-02 12:01:29 +01:00
QT_BEGIN_NAMESPACE
class QSettings;
class QPrinter;
class QToolButton;
2008-12-02 12:01:29 +01:00
QT_END_NAMESPACE
namespace Core {
class StatusBarWidget;
2008-12-02 12:01:29 +01:00
class EditorManager;
class ExternalToolManager;
class DocumentManager;
class HelpManager;
class IDocument;
class IWizardFactory;
class JsExpander;
2008-12-02 12:01:29 +01:00
class MessageManager;
2008-12-02 14:09:21 +01:00
class ModeManager;
class ProgressManager;
class NavigationWidget;
2008-12-02 14:09:21 +01:00
class RightPaneWidget;
class SettingsDatabase;
2010-12-07 17:34:43 +01:00
class VcsManager;
2008-12-02 12:01:29 +01:00
namespace Internal {
class FancyTabWidget;
2008-12-02 14:09:21 +01:00
class GeneralSettings;
class ProgressManagerPrivate;
2008-12-02 14:09:21 +01:00
class ShortcutSettings;
class ToolSettings;
class MimeTypeSettings;
2009-12-09 11:05:18 +01:00
class StatusBarManager;
class VersionDialog;
class WindowSupport;
class SystemEditor;
class SystemSettings;
2008-12-02 12:01:29 +01:00
class MainWindow : public Utils::AppMainWindow
2008-12-02 12:01:29 +01:00
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
bool init(QString *errorMessage);
2008-12-02 12:01:29 +01:00
void extensionsInitialized();
void aboutToShutdown();
2008-12-02 12:01:29 +01:00
IContext *contextObject(QWidget *widget);
void addContextObject(IContext *context);
void removeContextObject(IContext *context);
2008-12-02 12:01:29 +01:00
IDocument *openFiles(const QStringList &fileNames,
ICore::OpenFilesFlags flags,
const QString &workingDirectory = QString());
2008-12-02 12:01:29 +01:00
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
2008-12-02 12:01:29 +01:00
virtual QPrinter *printer() const;
IContext * currentContextObject() const;
QStatusBar *statusBar() const;
void updateAdditionalContexts(const Context &remove, const Context &add,
ICore::ContextPriority priority);
2008-12-02 12:01:29 +01:00
void setSuppressNavigationWidget(bool suppress);
void setOverrideColor(const QColor &color);
QStringList additionalAboutInformation() const;
void appendAboutInformation(const QString &line);
void addPreCloseListener(const std::function<bool()> &listener);
2008-12-02 12:01:29 +01:00
signals:
void newItemDialogRunningChanged();
2008-12-02 12:01:29 +01:00
public slots:
void openFileWith();
void exit();
bool showOptionsDialog(Id page = Id(), QWidget *parent = 0);
2008-12-02 12:01:29 +01:00
bool showWarningWithOptions(const QString &title, const QString &text,
const QString &details = QString(),
Id settingsId = Id(),
QWidget *parent = 0);
2008-12-02 12:01:29 +01:00
protected:
virtual void closeEvent(QCloseEvent *event);
2008-12-02 12:01:29 +01:00
private:
2008-12-02 12:01:29 +01:00
void openFile();
void aboutToShowRecentFiles();
void setFocusToEditor();
void saveAll();
void aboutQtCreator();
void aboutPlugins();
void updateFocusWidget(QWidget *old, QWidget *now);
void setSidebarVisible(bool visible);
void destroyVersionDialog();
void openDroppedFiles(const QList<Utils::DropSupport::FileSpec> &files);
void restoreWindowState();
void newItemDialogFinished();
2008-12-02 12:01:29 +01:00
void updateContextObject(const QList<IContext *> &context);
void updateContext();
2008-12-02 12:01:29 +01:00
void registerDefaultContainers();
void registerDefaultActions();
void readSettings();
void writeSettings();
ICore *m_coreImpl;
QStringList m_aboutInformation;
Context m_highPrioAdditionalContexts;
Context m_lowPrioAdditionalContexts;
SettingsDatabase *m_settingsDatabase;
2008-12-02 12:01:29 +01:00
mutable QPrinter *m_printer;
WindowSupport *m_windowSupport;
2008-12-02 12:01:29 +01:00
EditorManager *m_editorManager;
ExternalToolManager *m_externalToolManager;
2008-12-02 12:01:29 +01:00
MessageManager *m_messageManager;
ProgressManagerPrivate *m_progressManager;
JsExpander *m_jsExpander;
2010-12-07 17:34:43 +01:00
VcsManager *m_vcsManager;
2009-12-09 11:05:18 +01:00
StatusBarManager *m_statusBarManager;
2008-12-02 12:01:29 +01:00
ModeManager *m_modeManager;
HelpManager *m_helpManager;
2008-12-02 12:01:29 +01:00
FancyTabWidget *m_modeStack;
NavigationWidget *m_navigationWidget;
RightPaneWidget *m_rightPaneWidget;
StatusBarWidget *m_outputView;
VersionDialog *m_versionDialog;
2008-12-02 12:01:29 +01:00
QList<IContext *> m_activeContext;
2008-12-02 12:01:29 +01:00
QMap<QWidget *, IContext *> m_contextWidgets;
GeneralSettings *m_generalSettings;
SystemSettings *m_systemSettings;
2008-12-02 12:01:29 +01:00
ShortcutSettings *m_shortcutSettings;
ToolSettings *m_toolSettings;
MimeTypeSettings *m_mimeTypeSettings;
SystemEditor *m_systemEditor;
2008-12-02 12:01:29 +01:00
// actions
QAction *m_focusToEditor;
2008-12-02 12:01:29 +01:00
QAction *m_newAction;
QAction *m_openAction;
QAction *m_openWithAction;
QAction *m_saveAllAction;
QAction *m_exitAction;
QAction *m_optionsAction;
QAction *m_toggleSideBarAction;
QAction *m_toggleModeSelectorAction;
Implement theming for QtCreator Adds a 'Theme' tab to the environment settings and a '-theme' command line option. A theme is a combination of colors, gradients, flags and style information. There are two themes: - 'default': preserves the current default look - 'dark': uses a more flat for many widgets, dark color theme for everything This does not use a stylesheet (too limited), but rather sets the palette via C++ and modifies drawing behavior. Overall, the look is more flat (removed some gradients and bevels). Tested on Ubuntu 14.04 using Qt 5.4 and running on a KDE Desktop (Oxygen base style). For a screenshot, see https://gist.github.com/thorbenk/5ab06bea726de0aa7473 Changes: - Introduce class Theme, defining the interface how to access theme specific settings. The class reads a .creatortheme file (INI file, via QSettings) - Define named colors in the [Palette] section (see dark.creatortheme for example usage) - Use either named colors of AARRGGBB (hex) in the [Colors] section - A file ending with .creatortheme may be supplied to the '-theme' command line option - A global Theme instance can be accessed via creatorTheme() - Query colors, gradients, icons and flags from the theme were possible (TODO: use this in more places...) - There are very many color roles. It seems better to me to describe the role clearly, and then to consolidate later in the actual theme by assigning the same color. For example, one can set the text color of the output pane button individualy. - Many elements are also drawn differently. For the dark theme, I wanted to have a flatter look. - Introduce Theme::WidgetStyle enum, for now {Original, Flat}. - The theme specifies which kind of widget style it wants. - The drawing code queries the theme's style flag and switches between the original, gradient based look and the new, flat look. - Create some custom icons which look better on dark background (wip, currently folder/file icons) - Let ManhattanStyle draw some elements for non-panelwidgets, too (open/close arrows in QTreeView, custom folder/file icons) - For the welcomescreen, pass the WelcomeTheme class. WelcomeTheme exposes theme colors as Q_PROPERTY accessible from .qml - Themes can be modified via the 'Themes' tab in the environment settings. TODO: * Unify image handling * Avoid style name references * Fix gradients Change-Id: I92c2050ab0fb327649ea1eff4adec973d2073944 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
2014-10-14 19:09:48 +02:00
QAction *m_themeAction;
2008-12-02 12:01:29 +01:00
QToolButton *m_toggleSideBarButton;
QColor m_overrideColor;
QList<std::function<bool()>> m_preCloseListeners;
2008-12-02 12:01:29 +01:00
};
} // namespace Internal
} // namespace Core