2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-07-20 19:08:09 +02: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.
|
2009-07-20 19:08:09 +02: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
|
|
|
****************************************************************************/
|
2009-07-20 19:08:09 +02:00
|
|
|
|
|
|
|
|
#include "welcomeplugin.h"
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-07-27 13:55:30 +02:00
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/imode.h>
|
2014-12-19 12:05:40 +01:00
|
|
|
#include <coreplugin/iwelcomepage.h>
|
2014-05-02 17:38:42 +02:00
|
|
|
#include <coreplugin/iwizardfactory.h>
|
2014-12-18 17:52:49 +01:00
|
|
|
#include <coreplugin/modemanager.h>
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2015-11-11 19:26:58 +01:00
|
|
|
#include <utils/icon.h>
|
2013-10-23 22:07:46 +03:00
|
|
|
#include <utils/fileutils.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2014-12-18 17:52:49 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2011-04-13 17:09:44 +02:00
|
|
|
#include <utils/styledbar.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/theme/theme.h>
|
|
|
|
|
|
2013-01-16 10:26:26 +01:00
|
|
|
#include <QVBoxLayout>
|
2014-03-05 11:52:24 +01:00
|
|
|
#include <QMessageBox>
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
2014-10-17 13:29:56 +02:00
|
|
|
#include <QQmlPropertyMap>
|
2016-03-14 16:17:30 +01:00
|
|
|
#include <QQuickImageProvider>
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2014-06-16 14:55:37 +02:00
|
|
|
#ifdef USE_QUICK_WIDGET
|
|
|
|
|
#include <QtQuickWidgets/QQuickWidget>
|
|
|
|
|
typedef QQuickWidget QuickContainer;
|
|
|
|
|
#else
|
|
|
|
|
#include <QtQuick/QQuickView>
|
|
|
|
|
typedef QQuickView QuickContainer;
|
|
|
|
|
#endif
|
2013-09-02 17:29:30 +02:00
|
|
|
#include <QtQml/QQmlContext>
|
|
|
|
|
#include <QtQml/QQmlEngine>
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2011-07-22 16:45:41 +02:00
|
|
|
enum { debug = 0 };
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
using namespace Core;
|
2011-04-13 17:09:44 +02:00
|
|
|
using namespace ExtensionSystem;
|
2012-08-23 15:53:58 +02:00
|
|
|
using namespace Utils;
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
static const char currentPageSettingsKeyC[] = "WelcomeTab";
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
namespace Welcome {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-12-18 17:52:49 +01:00
|
|
|
static QString applicationDirPath()
|
|
|
|
|
{
|
|
|
|
|
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
2015-01-06 13:58:00 +01:00
|
|
|
return FileUtils::normalizePathName(QCoreApplication::applicationDirPath());
|
2014-12-18 17:52:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString resourcePath()
|
|
|
|
|
{
|
|
|
|
|
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
2015-01-06 13:58:00 +01:00
|
|
|
return FileUtils::normalizePathName(ICore::resourcePath());
|
2014-12-18 17:52:49 +01:00
|
|
|
}
|
|
|
|
|
|
2016-03-14 16:17:30 +01:00
|
|
|
class WelcomeImageIconProvider : public QQuickImageProvider
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
WelcomeImageIconProvider()
|
|
|
|
|
: QQuickImageProvider(Pixmap)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(requestedSize)
|
|
|
|
|
|
|
|
|
|
QString maskFile;
|
|
|
|
|
Theme::Color themeColor = Theme::Welcome_ForegroundPrimaryColor;
|
|
|
|
|
|
|
|
|
|
const QStringList elements = id.split(QLatin1Char('/'));
|
|
|
|
|
|
|
|
|
|
if (!elements.empty())
|
|
|
|
|
maskFile = elements.first();
|
|
|
|
|
|
|
|
|
|
if (elements.count() >= 2) {
|
|
|
|
|
const static QMetaObject &m = Theme::staticMetaObject;
|
|
|
|
|
const static QMetaEnum e = m.enumerator(m.indexOfEnumerator("Color"));
|
|
|
|
|
bool success = false;
|
|
|
|
|
int value = e.keyToValue(elements.at(1).toLatin1(), &success);
|
|
|
|
|
if (success)
|
|
|
|
|
themeColor = Theme::Color(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString fileName = QString::fromLatin1(":/welcome/images/%1.png").arg(maskFile);
|
|
|
|
|
const Icon icon({{fileName, themeColor}}, Icon::Tint);
|
|
|
|
|
const QPixmap result = icon.pixmap();
|
|
|
|
|
if (size)
|
|
|
|
|
*size = result.size();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
class WelcomeMode : public IMode
|
2011-04-13 17:09:44 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-11-11 16:49:17 +01:00
|
|
|
Q_PROPERTY(int activePlugin READ activePlugin WRITE setActivePlugin NOTIFY activePluginChanged)
|
2011-04-13 17:09:44 +02:00
|
|
|
public:
|
|
|
|
|
WelcomeMode();
|
|
|
|
|
~WelcomeMode();
|
|
|
|
|
|
|
|
|
|
void activated();
|
|
|
|
|
void initPlugins();
|
2010-11-11 16:49:17 +01:00
|
|
|
int activePlugin() const { return m_activePlugin; }
|
|
|
|
|
|
2013-03-25 11:24:00 +01:00
|
|
|
public slots:
|
2010-11-11 16:49:17 +01:00
|
|
|
void setActivePlugin(int pos)
|
|
|
|
|
{
|
|
|
|
|
if (m_activePlugin != pos) {
|
|
|
|
|
m_activePlugin = pos;
|
|
|
|
|
emit activePluginChanged(pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void activePluginChanged(int pos);
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
private:
|
2011-04-13 17:09:44 +02:00
|
|
|
void welcomePluginAdded(QObject*);
|
2014-03-05 11:52:24 +01:00
|
|
|
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
2013-09-02 17:29:30 +02:00
|
|
|
void facilitateQml(QQmlEngine *engine);
|
2015-01-06 13:58:00 +01:00
|
|
|
void addPages(const QList<IWelcomePage *> &pages);
|
2016-01-08 12:37:27 +01:00
|
|
|
void applyTheme();
|
2011-07-15 15:24:43 +02:00
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
QWidget *m_modeWidget;
|
2014-06-16 14:55:37 +02:00
|
|
|
QuickContainer *m_welcomePage;
|
2015-01-06 13:58:00 +01:00
|
|
|
QMap<Id, IWelcomePage *> m_idPageMap;
|
|
|
|
|
QList<IWelcomePage *> m_pluginList;
|
2010-11-11 16:49:17 +01:00
|
|
|
int m_activePlugin;
|
2014-10-17 13:29:56 +02:00
|
|
|
QQmlPropertyMap m_themeProperties;
|
2011-04-13 17:09:44 +02:00
|
|
|
};
|
|
|
|
|
|
2014-10-17 13:29:56 +02:00
|
|
|
WelcomeMode::WelcomeMode()
|
|
|
|
|
: m_activePlugin(0)
|
2011-04-13 17:09:44 +02:00
|
|
|
{
|
|
|
|
|
setDisplayName(tr("Welcome"));
|
2015-11-11 19:26:58 +01:00
|
|
|
|
|
|
|
|
const Utils::Icon MODE_WELCOME_CLASSIC(
|
|
|
|
|
QLatin1String(":/welcome/images/mode_welcome.png"));
|
|
|
|
|
const Utils::Icon MODE_WELCOME_FLAT({
|
|
|
|
|
{QLatin1String(":/welcome/images/mode_welcome_mask.png"), Utils::Theme::IconsBaseColor}});
|
|
|
|
|
const Utils::Icon MODE_WELCOME_FLAT_ACTIVE({
|
|
|
|
|
{QLatin1String(":/welcome/images/mode_welcome_mask.png"), Utils::Theme::IconsModeWelcomeActiveColor}});
|
|
|
|
|
|
|
|
|
|
setIcon(Utils::Icon::modeIcon(MODE_WELCOME_CLASSIC,
|
|
|
|
|
MODE_WELCOME_FLAT, MODE_WELCOME_FLAT_ACTIVE));
|
2015-01-06 13:58:00 +01:00
|
|
|
setPriority(Constants::P_MODE_WELCOME);
|
|
|
|
|
setId(Constants::MODE_WELCOME);
|
2011-04-13 17:09:44 +02:00
|
|
|
setContextHelpId(QLatin1String("Qt Creator Manual"));
|
2015-01-06 13:58:00 +01:00
|
|
|
setContext(Context(Constants::C_WELCOME_MODE));
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
m_modeWidget = new QWidget;
|
2013-09-27 10:47:34 +03:00
|
|
|
m_modeWidget->setObjectName(QLatin1String("WelcomePageModeWidget"));
|
2014-06-16 14:55:37 +02:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout(m_modeWidget);
|
2011-06-29 12:17:52 +02:00
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(0);
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2014-06-16 14:55:37 +02:00
|
|
|
m_welcomePage = new QuickContainer();
|
2016-01-08 12:37:27 +01:00
|
|
|
applyTheme(); // initialize background color and theme properties
|
2014-06-16 14:55:37 +02:00
|
|
|
m_welcomePage->setResizeMode(QuickContainer::SizeRootObjectToView);
|
|
|
|
|
|
|
|
|
|
m_welcomePage->setObjectName(QLatin1String("WelcomePage"));
|
|
|
|
|
|
2015-01-07 17:46:44 +01:00
|
|
|
connect(m_welcomePage, &QuickContainer::sceneGraphError,
|
2015-01-06 13:58:00 +01:00
|
|
|
this, &WelcomeMode::sceneGraphError);
|
2014-06-16 14:55:37 +02:00
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
StyledBar *styledBar = new StyledBar(m_modeWidget);
|
2013-09-27 10:47:34 +03:00
|
|
|
styledBar->setObjectName(QLatin1String("WelcomePageStyledBar"));
|
2012-02-08 13:02:40 +01:00
|
|
|
layout->addWidget(styledBar);
|
2013-09-02 17:29:30 +02:00
|
|
|
|
2014-06-16 14:55:37 +02:00
|
|
|
#ifdef USE_QUICK_WIDGET
|
|
|
|
|
m_welcomePage->setParent(m_modeWidget);
|
|
|
|
|
layout->addWidget(m_welcomePage);
|
|
|
|
|
#else
|
2013-11-19 11:04:26 +01:00
|
|
|
QWidget *container = QWidget::createWindowContainer(m_welcomePage, m_modeWidget);
|
2014-06-20 17:24:18 +02:00
|
|
|
container->setProperty("nativeAncestors", true);
|
2013-09-02 17:29:30 +02:00
|
|
|
m_modeWidget->setLayout(layout);
|
2013-11-19 11:04:26 +01:00
|
|
|
layout->addWidget(container);
|
2014-06-16 14:55:37 +02:00
|
|
|
#endif // USE_QUICK_WIDGET
|
2013-09-02 17:29:30 +02:00
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
setWidget(m_modeWidget);
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-08 12:37:27 +01:00
|
|
|
void WelcomeMode::applyTheme()
|
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
|
|
|
{
|
2014-10-17 13:29:56 +02:00
|
|
|
const QVariantHash creatorTheme = Utils::creatorTheme()->values();
|
2015-01-06 13:58:00 +01:00
|
|
|
for (auto it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
|
2014-10-17 13:29:56 +02:00
|
|
|
m_themeProperties.insert(it.key(), it.value());
|
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-04-13 17:09:44 +02:00
|
|
|
WelcomeMode::~WelcomeMode()
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
2015-01-06 13:58:00 +01:00
|
|
|
QSettings *settings = ICore::settings();
|
2010-11-11 16:49:17 +01:00
|
|
|
settings->setValue(QLatin1String(currentPageSettingsKeyC), activePlugin());
|
2011-06-29 12:17:52 +02:00
|
|
|
delete m_modeWidget;
|
2009-07-20 19:08:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-05 11:52:24 +01:00
|
|
|
void WelcomeMode::sceneGraphError(QQuickWindow::SceneGraphError, const QString &message)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox *messageBox =
|
|
|
|
|
new QMessageBox(QMessageBox::Warning,
|
|
|
|
|
tr("Welcome Mode Load Error"), message,
|
|
|
|
|
QMessageBox::Close, m_modeWidget);
|
|
|
|
|
messageBox->setModal(false);
|
|
|
|
|
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
messageBox->show();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-18 17:52:49 +01:00
|
|
|
void WelcomeMode::facilitateQml(QQmlEngine *engine)
|
2011-07-15 15:24:43 +02:00
|
|
|
{
|
2012-03-15 11:45:05 +01:00
|
|
|
QStringList importPathList = engine->importPathList();
|
2012-11-28 14:25:18 +01:00
|
|
|
importPathList << resourcePath() + QLatin1String("/welcomescreen");
|
2012-03-15 11:45:05 +01:00
|
|
|
engine->setImportPathList(importPathList);
|
2016-03-14 16:17:30 +01:00
|
|
|
engine->addImageProvider(QLatin1String("icons"), new WelcomeImageIconProvider);
|
2011-07-20 14:33:44 +02:00
|
|
|
if (!debug)
|
|
|
|
|
engine->setOutputWarningsToStandardError(false);
|
2014-12-18 17:52:49 +01:00
|
|
|
|
2012-11-28 14:25:18 +01:00
|
|
|
QString pluginPath = applicationDirPath();
|
2012-08-23 15:53:58 +02:00
|
|
|
if (HostOsInfo::isMacHost())
|
|
|
|
|
pluginPath += QLatin1String("/../PlugIns");
|
|
|
|
|
else
|
|
|
|
|
pluginPath += QLatin1String("/../" IDE_LIBRARY_BASENAME "/qtcreator");
|
2011-08-02 17:11:29 +02:00
|
|
|
engine->addImportPath(QDir::cleanPath(pluginPath));
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2014-12-18 17:52:49 +01:00
|
|
|
QQmlContext *ctx = engine->rootContext();
|
|
|
|
|
ctx->setContextProperty(QLatin1String("welcomeMode"), this);
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2014-10-17 13:29:56 +02:00
|
|
|
ctx->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties);
|
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
|
|
|
|
2015-04-16 13:34:18 +02:00
|
|
|
#if defined(USE_QUICK_WIDGET) && (QT_VERSION < QT_VERSION_CHECK(5, 5, 0))
|
2015-01-06 13:58:00 +01:00
|
|
|
bool useNativeText = !HostOsInfo::isMacHost();
|
2014-12-17 18:16:41 +01:00
|
|
|
#else
|
|
|
|
|
bool useNativeText = true;
|
|
|
|
|
#endif
|
|
|
|
|
ctx->setContextProperty(QLatin1String("useNativeText"), useNativeText);
|
2014-12-18 17:52:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WelcomeMode::initPlugins()
|
|
|
|
|
{
|
2015-01-06 13:58:00 +01:00
|
|
|
QSettings *settings = ICore::settings();
|
2014-12-18 17:52:49 +01:00
|
|
|
setActivePlugin(settings->value(QLatin1String(currentPageSettingsKeyC)).toInt());
|
|
|
|
|
|
|
|
|
|
facilitateQml(m_welcomePage->engine());
|
|
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
QList<IWelcomePage *> availablePages = PluginManager::getObjects<IWelcomePage>();
|
2014-12-18 17:52:49 +01:00
|
|
|
addPages(availablePages);
|
|
|
|
|
// make sure later added pages are made available too:
|
|
|
|
|
connect(PluginManager::instance(), &PluginManager::objectAdded,
|
|
|
|
|
this, &WelcomeMode::welcomePluginAdded);
|
2014-12-17 18:16:41 +01:00
|
|
|
|
2012-11-28 14:25:18 +01:00
|
|
|
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
// finally, load the root page
|
2014-12-18 17:52:49 +01:00
|
|
|
m_welcomePage->setSource(QUrl::fromLocalFile(path));
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WelcomeMode::welcomePluginAdded(QObject *obj)
|
|
|
|
|
{
|
2015-01-06 13:58:00 +01:00
|
|
|
IWelcomePage *page = qobject_cast<IWelcomePage*>(obj);
|
2014-12-18 17:52:49 +01:00
|
|
|
if (!page)
|
|
|
|
|
return;
|
2015-01-06 13:58:00 +01:00
|
|
|
addPages(QList<IWelcomePage *>() << page);
|
2014-12-18 17:52:49 +01:00
|
|
|
}
|
2012-03-06 12:26:18 +01:00
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
void WelcomeMode::addPages(const QList<IWelcomePage *> &pages)
|
2014-12-18 17:52:49 +01:00
|
|
|
{
|
2015-01-06 13:58:00 +01:00
|
|
|
QList<IWelcomePage *> addedPages = pages;
|
|
|
|
|
Utils::sort(addedPages, [](const IWelcomePage *l, const IWelcomePage *r) {
|
2014-12-18 17:52:49 +01:00
|
|
|
return l->priority() < r->priority();
|
|
|
|
|
});
|
|
|
|
|
// insert into m_pluginList, keeping m_pluginList sorted by priority
|
|
|
|
|
QQmlEngine *engine = m_welcomePage->engine();
|
|
|
|
|
auto addIt = addedPages.begin();
|
|
|
|
|
auto currentIt = m_pluginList.begin();
|
|
|
|
|
while (addIt != addedPages.end()) {
|
2015-01-06 13:58:00 +01:00
|
|
|
IWelcomePage *page = *addIt;
|
2014-12-18 17:52:49 +01:00
|
|
|
QTC_ASSERT(!m_idPageMap.contains(page->id()), ++addIt; continue);
|
|
|
|
|
while (currentIt != m_pluginList.end() && (*currentIt)->priority() <= page->priority())
|
|
|
|
|
++currentIt;
|
|
|
|
|
// currentIt is now either end() or a page with higher value
|
|
|
|
|
currentIt = m_pluginList.insert(currentIt, page);
|
|
|
|
|
m_idPageMap.insert(page->id(), page);
|
|
|
|
|
page->facilitateQml(engine);
|
|
|
|
|
++currentIt;
|
|
|
|
|
++addIt;
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
2014-12-18 17:52:49 +01:00
|
|
|
// update model through reset
|
|
|
|
|
QQmlContext *ctx = engine->rootContext();
|
|
|
|
|
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(
|
|
|
|
|
Utils::transform(m_pluginList, // transform into QList<QObject *>
|
2015-01-06 13:58:00 +01:00
|
|
|
[](IWelcomePage *page) -> QObject * {
|
2014-12-18 17:52:49 +01:00
|
|
|
return page;
|
|
|
|
|
})));
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WelcomePlugin::WelcomePlugin()
|
|
|
|
|
: m_welcomeMode(0)
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-25 13:15:28 +02:00
|
|
|
bool WelcomePlugin::initialize(const QStringList & /* arguments */, QString *errorMessage)
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
2015-09-29 16:43:42 +02:00
|
|
|
if (!Utils::HostOsInfo::canCreateOpenGLContext(errorMessage))
|
2015-09-25 13:15:28 +02:00
|
|
|
return false;
|
|
|
|
|
|
2009-07-20 19:08:09 +02:00
|
|
|
m_welcomeMode = new WelcomeMode;
|
2010-03-31 11:49:06 +02:00
|
|
|
addAutoReleasedObject(m_welcomeMode);
|
2009-07-20 19:08:09 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WelcomePlugin::extensionsInitialized()
|
|
|
|
|
{
|
2009-07-27 13:55:30 +02:00
|
|
|
m_welcomeMode->initPlugins();
|
2015-01-06 13:58:00 +01:00
|
|
|
ModeManager::activateMode(m_welcomeMode->id());
|
2009-07-20 19:08:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
} // namespace Internal
|
2010-11-11 16:49:17 +01:00
|
|
|
} // namespace Welcome
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
#include "welcomeplugin.moc"
|