2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02: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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "coreplugin.h"
|
2012-02-02 10:47:33 +01:00
|
|
|
#include "designmode.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "editmode.h"
|
2015-02-26 13:38:54 +01:00
|
|
|
#include "idocument.h"
|
2012-02-02 10:47:33 +01:00
|
|
|
#include "helpmanager.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "modemanager.h"
|
2013-01-10 18:18:28 +02:00
|
|
|
#include "infobar.h"
|
2014-07-29 16:39:03 +02:00
|
|
|
#include "iwizardfactory.h"
|
2016-01-20 22:20:59 +02:00
|
|
|
#include "themechooser.h"
|
2014-01-13 16:17:34 +01:00
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2015-06-09 13:56:08 +02:00
|
|
|
#include <coreplugin/documentmanager.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2014-01-13 16:17:34 +01:00
|
|
|
#include <coreplugin/find/findplugin.h>
|
2014-01-10 18:02:20 +01:00
|
|
|
#include <coreplugin/locator/locator.h>
|
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
|
|
|
#include <coreplugin/coreconstants.h>
|
2015-08-03 12:44:48 +02:00
|
|
|
#include <coreplugin/fileutils.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-04-14 10:13:25 +03:00
|
|
|
#include <extensionsystem/pluginerroroverview.h>
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2015-10-27 08:46:02 +01:00
|
|
|
#include <utils/algorithm.h>
|
2015-08-03 12:44:48 +02:00
|
|
|
#include <utils/pathchooser.h>
|
2014-10-15 09:59:55 +02:00
|
|
|
#include <utils/macroexpander.h>
|
2013-01-28 21:15:04 +01:00
|
|
|
#include <utils/savefile.h>
|
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
|
|
|
#include <utils/stringutils.h>
|
|
|
|
#include <utils/theme/theme.h>
|
2014-11-14 09:53:44 +02:00
|
|
|
#include <utils/theme/theme_p.h>
|
2009-01-19 12:39:20 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
#include <QDebug>
|
2013-02-28 11:42:50 +02:00
|
|
|
#include <QDateTime>
|
2015-08-03 12:44:48 +02:00
|
|
|
#include <QMenu>
|
2015-11-30 14:55:40 +01:00
|
|
|
#include <QUuid>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
using namespace Core;
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Core::Internal;
|
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
|
|
|
using namespace Utils;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
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
|
|
|
CorePlugin::CorePlugin()
|
|
|
|
: m_mainWindow(0)
|
|
|
|
, m_editMode(0)
|
|
|
|
, m_designMode(0)
|
|
|
|
, m_locator(0)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-02-03 23:48:19 +02:00
|
|
|
qRegisterMetaType<Id>();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CorePlugin::~CorePlugin()
|
|
|
|
{
|
2014-07-29 16:39:03 +02:00
|
|
|
IWizardFactory::destroyFeatureProvider();
|
2016-03-11 19:12:07 +01:00
|
|
|
Find::destroy();
|
2014-07-29 16:39:03 +02:00
|
|
|
|
2014-01-10 18:02:20 +01:00
|
|
|
delete m_locator;
|
2014-01-13 16:17:34 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
if (m_editMode) {
|
|
|
|
removeObject(m_editMode);
|
|
|
|
delete m_editMode;
|
|
|
|
}
|
|
|
|
|
2010-02-26 11:08:17 +01:00
|
|
|
if (m_designMode) {
|
2011-10-19 13:05:53 +02:00
|
|
|
if (m_designMode->designModeIsRequired())
|
|
|
|
removeObject(m_designMode);
|
2010-02-26 11:08:17 +01:00
|
|
|
delete m_designMode;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_mainWindow;
|
2014-10-16 23:04:24 +03:00
|
|
|
setCreatorTheme(0);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-11-25 18:44:54 +01:00
|
|
|
void CorePlugin::parseArguments(const QStringList &arguments)
|
|
|
|
{
|
2015-10-27 08:46:02 +01:00
|
|
|
const Id settingsThemeId = Id::fromSetting(ICore::settings()->value(
|
2016-03-18 11:15:20 +01:00
|
|
|
QLatin1String(Constants::SETTINGS_THEME), QLatin1String(Constants::DEFAULT_THEME)));
|
2015-10-27 08:46:02 +01:00
|
|
|
Id themeId = settingsThemeId;
|
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
|
|
|
QColor overrideColor;
|
2014-11-07 18:56:48 +01:00
|
|
|
bool presentationMode = false;
|
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
|
|
|
|
2011-10-14 13:01:07 +00:00
|
|
|
for (int i = 0; i < arguments.size(); ++i) {
|
2009-11-25 18:44:54 +01:00
|
|
|
if (arguments.at(i) == QLatin1String("-color")) {
|
|
|
|
const QString colorcode(arguments.at(i + 1));
|
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
|
|
|
overrideColor = QColor(colorcode);
|
2009-11-25 18:44:54 +01:00
|
|
|
i++; // skip the argument
|
|
|
|
}
|
2011-10-14 13:01:07 +00:00
|
|
|
if (arguments.at(i) == QLatin1String("-presentationMode"))
|
2014-11-07 18:56:48 +01:00
|
|
|
presentationMode = true;
|
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
|
|
|
if (arguments.at(i) == QLatin1String("-theme")) {
|
2015-10-27 08:46:02 +01:00
|
|
|
themeId = Id::fromString(arguments.at(i + 1));
|
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
|
|
|
i++;
|
|
|
|
}
|
2009-11-25 18:44:54 +01:00
|
|
|
}
|
2016-01-11 22:56:00 +02:00
|
|
|
const QList<ThemeEntry> availableThemes = ThemeEntry::availableThemes();
|
2015-10-27 08:46:02 +01:00
|
|
|
int themeIndex = Utils::indexOf(availableThemes, Utils::equal(&ThemeEntry::id, themeId));
|
|
|
|
if (themeIndex < 0) {
|
|
|
|
themeIndex = Utils::indexOf(availableThemes,
|
|
|
|
Utils::equal(&ThemeEntry::id, settingsThemeId));
|
|
|
|
}
|
|
|
|
if (themeIndex < 0)
|
|
|
|
themeIndex = 0;
|
|
|
|
if (themeIndex < availableThemes.size()) {
|
|
|
|
const ThemeEntry themeEntry = availableThemes.at(themeIndex);
|
|
|
|
QSettings themeSettings(themeEntry.filePath(), QSettings::IniFormat);
|
|
|
|
Theme *theme = new Theme(themeEntry.id().toString(), qApp);
|
|
|
|
theme->readSettings(themeSettings);
|
|
|
|
if (theme->flag(Theme::ApplyThemePaletteGlobally))
|
|
|
|
QApplication::setPalette(theme->palette());
|
|
|
|
setCreatorTheme(theme);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// defer creation of these widgets until here,
|
|
|
|
// because they need a valid theme set
|
|
|
|
m_mainWindow = new MainWindow;
|
2014-11-07 18:56:48 +01:00
|
|
|
ActionManager::setPresentationModeEnabled(presentationMode);
|
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
|
|
|
m_locator = new Locator;
|
|
|
|
|
|
|
|
if (overrideColor.isValid())
|
|
|
|
m_mainWindow->setOverrideColor(overrideColor);
|
2009-11-25 18:44:54 +01:00
|
|
|
}
|
|
|
|
|
2009-01-26 14:25:03 +01:00
|
|
|
bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-01-11 22:56:00 +02:00
|
|
|
if (ThemeEntry::availableThemes().isEmpty()) {
|
2015-10-27 08:46:02 +01:00
|
|
|
*errorMessage = tr("No themes found in installation.");
|
|
|
|
return false;
|
|
|
|
}
|
2015-03-16 17:07:50 +01:00
|
|
|
new ActionManager(this);
|
2014-11-17 08:07:28 +02:00
|
|
|
Theme::initialPalette(); // Initialize palette before setting it
|
2013-02-28 11:42:50 +02:00
|
|
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
2009-11-25 18:44:54 +01:00
|
|
|
parseArguments(arguments);
|
2009-01-26 14:25:03 +01:00
|
|
|
const bool success = m_mainWindow->init(errorMessage);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (success) {
|
2011-04-14 12:28:21 +02:00
|
|
|
m_editMode = new EditMode;
|
2008-12-02 12:01:29 +01:00
|
|
|
addObject(m_editMode);
|
2012-05-07 18:28:03 +02:00
|
|
|
ModeManager::activateMode(m_editMode->id());
|
2011-04-14 12:28:21 +02:00
|
|
|
m_designMode = new DesignMode;
|
2013-01-10 18:18:28 +02:00
|
|
|
InfoBar::initializeGloballySuppressed();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2013-01-28 21:15:04 +01:00
|
|
|
|
2015-05-22 17:16:36 +02:00
|
|
|
IWizardFactory::initialize();
|
|
|
|
|
2013-01-28 21:15:04 +01:00
|
|
|
// Make sure we respect the process's umask when creating new files
|
2015-02-03 23:48:19 +02:00
|
|
|
SaveFile::initializeUmask();
|
2013-01-28 21:15:04 +01:00
|
|
|
|
2016-03-11 19:12:07 +01:00
|
|
|
Find::initialize();
|
2014-01-10 18:02:20 +01:00
|
|
|
m_locator->initialize(this, arguments, errorMessage);
|
2014-01-13 16:17:34 +01:00
|
|
|
|
2015-02-03 23:48:19 +02:00
|
|
|
MacroExpander *expander = Utils::globalMacroExpander();
|
2014-10-15 09:59:55 +02:00
|
|
|
expander->registerVariable("CurrentDate:ISO", tr("The current date (ISO)."),
|
|
|
|
[]() { return QDate::currentDate().toString(Qt::ISODate); });
|
|
|
|
expander->registerVariable("CurrentTime:ISO", tr("The current time (ISO)."),
|
|
|
|
[]() { return QTime::currentTime().toString(Qt::ISODate); });
|
|
|
|
expander->registerVariable("CurrentDate:RFC", tr("The current date (RFC2822)."),
|
|
|
|
[]() { return QDate::currentDate().toString(Qt::RFC2822Date); });
|
|
|
|
expander->registerVariable("CurrentTime:RFC", tr("The current time (RFC2822)."),
|
|
|
|
[]() { return QTime::currentTime().toString(Qt::RFC2822Date); });
|
|
|
|
expander->registerVariable("CurrentDate:Locale", tr("The current date (Locale)."),
|
|
|
|
[]() { return QDate::currentDate().toString(Qt::DefaultLocaleShortDate); });
|
|
|
|
expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."),
|
|
|
|
[]() { return QTime::currentTime().toString(Qt::DefaultLocaleShortDate); });
|
2015-06-09 13:56:08 +02:00
|
|
|
expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."),
|
|
|
|
[]() { return DocumentManager::projectsDirectory(); });
|
|
|
|
expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."),
|
|
|
|
[]() { return DocumentManager::fileDialogLastVisitedDirectory(); });
|
2015-06-09 15:38:00 +02:00
|
|
|
expander->registerVariable("HostOs:isWindows", tr("Is Qt Creator running on Windows?"),
|
|
|
|
[]() { return QVariant(Utils::HostOsInfo::isWindowsHost()).toString(); });
|
|
|
|
expander->registerVariable("HostOs:isOSX", tr("Is Qt Creator running on OS X?"),
|
|
|
|
[]() { return QVariant(Utils::HostOsInfo::isMacHost()).toString(); });
|
|
|
|
expander->registerVariable("HostOs:isLinux", tr("Is Qt Creator running on Linux?"),
|
|
|
|
[]() { return QVariant(Utils::HostOsInfo::isLinuxHost()).toString(); });
|
|
|
|
expander->registerVariable("HostOs:isUnix", tr("Is Qt Creator running on any unix-based platform?"),
|
|
|
|
[]() { return QVariant(Utils::HostOsInfo::isAnyUnixHost()).toString(); });
|
2014-12-05 16:39:29 +01:00
|
|
|
expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."),
|
2014-10-15 09:59:55 +02:00
|
|
|
[](const QString &fmt) { return QDate::currentDate().toString(fmt); });
|
2014-12-05 16:39:29 +01:00
|
|
|
expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."),
|
2014-10-15 09:59:55 +02:00
|
|
|
[](const QString &fmt) { return QTime::currentTime().toString(fmt); });
|
2015-11-30 14:55:40 +01:00
|
|
|
expander->registerVariable("UUID", tr("Generate a new UUID."),
|
|
|
|
[]() { return QUuid::createUuid().toString(); });
|
2014-10-15 09:59:55 +02:00
|
|
|
|
2015-06-04 16:25:38 +02:00
|
|
|
expander->registerPrefix("#:", tr("A comment."), [](const QString &) { return QStringLiteral(""); });
|
|
|
|
|
2015-05-19 15:52:16 +02:00
|
|
|
// Make sure all wizards are there when the user might access the keyboard shortcuts:
|
|
|
|
connect(ICore::instance(), &ICore::optionsDialogRequested, []() { IWizardFactory::allWizardFactories(); });
|
|
|
|
|
2015-08-03 12:44:48 +02:00
|
|
|
Utils::PathChooser::setAboutToShowContextMenuHandler(&CorePlugin::addToPathChooserContextMenu);
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CorePlugin::extensionsInitialized()
|
|
|
|
{
|
2011-10-19 13:05:53 +02:00
|
|
|
if (m_designMode->designModeIsRequired())
|
|
|
|
addObject(m_designMode);
|
2016-03-11 19:12:07 +01:00
|
|
|
Find::extensionsInitialized();
|
2014-01-10 18:02:20 +01:00
|
|
|
m_locator->extensionsInitialized();
|
2014-02-24 17:05:33 +01:00
|
|
|
m_mainWindow->extensionsInitialized();
|
2015-04-14 10:13:25 +03:00
|
|
|
if (ExtensionSystem::PluginManager::hasError()) {
|
|
|
|
auto errorOverview = new ExtensionSystem::PluginErrorOverview(m_mainWindow);
|
|
|
|
errorOverview->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
errorOverview->setModal(true);
|
|
|
|
errorOverview->show();
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2012-02-02 10:47:33 +01:00
|
|
|
bool CorePlugin::delayedInitialize()
|
|
|
|
{
|
2013-08-29 19:00:34 +02:00
|
|
|
HelpManager::setupHelpManager();
|
2014-01-10 18:02:20 +01:00
|
|
|
m_locator->delayedInitialize();
|
2015-05-19 15:52:16 +02:00
|
|
|
IWizardFactory::allWizardFactories(); // scan for all wizard factories
|
2012-02-02 10:47:33 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-03-09 10:59:58 +02:00
|
|
|
QObject *CorePlugin::remoteCommand(const QStringList & /* options */,
|
|
|
|
const QString &workingDirectory,
|
|
|
|
const QStringList &args)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-05-02 15:39:52 +02:00
|
|
|
if (!ExtensionSystem::PluginManager::isInitializationDone()) {
|
|
|
|
connect(ExtensionSystem::PluginManager::instance(), &ExtensionSystem::PluginManager::initializationDone,
|
|
|
|
this, [this, workingDirectory, args]() {
|
|
|
|
remoteCommand(QStringList(), workingDirectory, args);
|
|
|
|
});
|
|
|
|
return nullptr;
|
|
|
|
}
|
2013-03-11 18:15:49 +02:00
|
|
|
IDocument *res = m_mainWindow->openFiles(
|
2015-03-11 10:35:49 +01:00
|
|
|
args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineAndColumnNumbers),
|
2015-03-09 10:59:58 +02:00
|
|
|
workingDirectory);
|
2013-04-15 12:53:34 +02:00
|
|
|
m_mainWindow->raiseWindow();
|
2013-03-11 18:15:49 +02:00
|
|
|
return res;
|
2009-12-14 18:01:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CorePlugin::fileOpenRequest(const QString &f)
|
|
|
|
{
|
2015-03-09 10:59:58 +02:00
|
|
|
remoteCommand(QStringList(), QString(), QStringList(f));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2015-08-03 12:44:48 +02:00
|
|
|
void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QMenu *menu)
|
|
|
|
{
|
|
|
|
QList<QAction*> actions = menu->actions();
|
|
|
|
QAction *firstAction = actions.isEmpty() ? nullptr : actions.first();
|
|
|
|
|
|
|
|
auto *showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), menu);
|
|
|
|
connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser]() {
|
|
|
|
Core::FileUtils::showInGraphicalShell(pathChooser, pathChooser->path());
|
|
|
|
});
|
|
|
|
menu->insertAction(firstAction, showInGraphicalShell);
|
|
|
|
|
|
|
|
auto *showInTerminal = new QAction(Core::FileUtils::msgTerminalAction(), menu);
|
|
|
|
connect(showInTerminal, &QAction::triggered, pathChooser, [pathChooser]() {
|
|
|
|
Core::FileUtils::openTerminal(pathChooser->path());
|
|
|
|
});
|
|
|
|
menu->insertAction(firstAction, showInTerminal);
|
|
|
|
|
|
|
|
if (firstAction)
|
|
|
|
menu->insertSeparator(firstAction);
|
|
|
|
}
|
|
|
|
|
2010-07-13 13:36:47 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag CorePlugin::aboutToShutdown()
|
2009-06-23 14:59:01 +02:00
|
|
|
{
|
2016-03-11 19:12:07 +01:00
|
|
|
Find::aboutToShutdown();
|
2010-04-28 16:59:03 +02:00
|
|
|
m_mainWindow->aboutToShutdown();
|
2010-07-13 13:36:47 +02:00
|
|
|
return SynchronousShutdown;
|
2009-06-23 14:59:01 +02:00
|
|
|
}
|