2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** 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.
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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>
|
2009-07-20 19:08:09 +02:00
|
|
|
#include <coreplugin/modemanager.h>
|
2014-05-02 17:38:42 +02:00
|
|
|
#include <coreplugin/iwizardfactory.h>
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.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>
|
2011-04-13 17:09:44 +02:00
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#include <utils/iwelcomepage.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>
|
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
|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|
class WelcomeMode : public Core::IMode
|
|
|
|
|
{
|
|
|
|
|
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-09-02 17:29:30 +02:00
|
|
|
// bool eventFilter(QObject *, QEvent *);
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2013-03-25 11:24:00 +01:00
|
|
|
public slots:
|
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
|
|
|
void onThemeChanged();
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void welcomePluginAdded(QObject*);
|
2014-03-05 11:52:24 +01:00
|
|
|
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
private:
|
2013-09-02 17:29:30 +02:00
|
|
|
void facilitateQml(QQmlEngine *engine);
|
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;
|
2010-11-11 16:49:17 +01:00
|
|
|
QList<QObject*> m_pluginList;
|
|
|
|
|
int m_activePlugin;
|
2014-10-17 13:29:56 +02:00
|
|
|
QQmlPropertyMap m_themeProperties;
|
2011-04-13 17:09:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// --- WelcomeMode
|
2014-10-17 13:29:56 +02:00
|
|
|
WelcomeMode::WelcomeMode()
|
|
|
|
|
: m_activePlugin(0)
|
2011-04-13 17:09:44 +02:00
|
|
|
{
|
|
|
|
|
setDisplayName(tr("Welcome"));
|
2014-10-08 23:38:43 +02:00
|
|
|
setIcon(QIcon(QLatin1String(":/welcome/images/mode_welcome.png")));
|
2011-04-13 17:09:44 +02:00
|
|
|
setPriority(Core::Constants::P_MODE_WELCOME);
|
2012-05-07 18:28:03 +02:00
|
|
|
setId(Core::Constants::MODE_WELCOME);
|
2011-04-13 17:09:44 +02:00
|
|
|
setContextHelpId(QLatin1String("Qt Creator Manual"));
|
2011-04-13 17:19:55 +02:00
|
|
|
setContext(Core::Context(Core::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();
|
2014-12-17 17:04:43 +01:00
|
|
|
onThemeChanged(); // initialize background color and theme properties
|
2014-06-16 14:55:37 +02:00
|
|
|
m_welcomePage->setResizeMode(QuickContainer::SizeRootObjectToView);
|
|
|
|
|
|
|
|
|
|
m_welcomePage->setObjectName(QLatin1String("WelcomePage"));
|
|
|
|
|
|
|
|
|
|
connect(m_welcomePage, SIGNAL(sceneGraphError(QQuickWindow::SceneGraphError,QString)),
|
|
|
|
|
this, SLOT(sceneGraphError(QQuickWindow::SceneGraphError,QString)));
|
|
|
|
|
|
2012-02-08 13:02:40 +01:00
|
|
|
Utils::StyledBar* styledBar = new Utils::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
|
|
|
|
2013-08-02 11:47:17 +02:00
|
|
|
connect(PluginManager::instance(), SIGNAL(objectAdded(QObject*)), SLOT(welcomePluginAdded(QObject*)));
|
2011-06-29 12:17:52 +02:00
|
|
|
setWidget(m_modeWidget);
|
2011-04-13 17:09:44 +02: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
|
|
|
void WelcomeMode::onThemeChanged()
|
|
|
|
|
{
|
2014-10-17 13:29:56 +02:00
|
|
|
const QVariantHash creatorTheme = Utils::creatorTheme()->values();
|
|
|
|
|
QVariantHash::const_iterator it;
|
|
|
|
|
for (it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
|
|
|
|
|
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
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::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();
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
void WelcomeMode::facilitateQml(QQmlEngine * /*engine*/)
|
2011-07-15 15:24:43 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-28 14:25:18 +01:00
|
|
|
static QString applicationDirPath()
|
|
|
|
|
{
|
|
|
|
|
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
2013-10-23 22:07:46 +03:00
|
|
|
return Utils::FileUtils::normalizePathName(QCoreApplication::applicationDirPath());
|
2012-11-28 14:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString resourcePath()
|
|
|
|
|
{
|
|
|
|
|
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
2013-10-23 22:07:46 +03:00
|
|
|
return Utils::FileUtils::normalizePathName(Core::ICore::resourcePath());
|
2012-11-28 14:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
void WelcomeMode::initPlugins()
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::ICore::settings();
|
2010-11-11 16:49:17 +01:00
|
|
|
setActivePlugin(settings->value(QLatin1String(currentPageSettingsKeyC)).toInt());
|
|
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
QQmlContext *ctx = m_welcomePage->rootContext();
|
2012-01-12 10:15:08 +01:00
|
|
|
ctx->setContextProperty(QLatin1String("welcomeMode"), this);
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2012-06-18 11:34:15 +02:00
|
|
|
QList<Utils::IWelcomePage*> duplicatePlugins = PluginManager::getObjects<Utils::IWelcomePage>();
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(duplicatePlugins, [](const Utils::IWelcomePage *l, const Utils::IWelcomePage *r) {
|
|
|
|
|
return l->priority() < r->priority();
|
|
|
|
|
});
|
2012-03-06 12:26:18 +01:00
|
|
|
|
|
|
|
|
QList<Utils::IWelcomePage*> plugins;
|
2014-12-16 12:01:35 +01:00
|
|
|
QHash<Core::Id, Utils::IWelcomePage*> pluginHash;
|
2012-03-06 12:26:18 +01:00
|
|
|
|
|
|
|
|
//avoid duplicate ids - choose by priority
|
|
|
|
|
foreach (Utils::IWelcomePage* plugin, duplicatePlugins) {
|
|
|
|
|
if (pluginHash.contains(plugin->id())) {
|
|
|
|
|
Utils::IWelcomePage* pluginOther = pluginHash.value(plugin->id());
|
|
|
|
|
|
|
|
|
|
if (pluginOther->priority() > plugin->priority()) {
|
|
|
|
|
plugins.removeAll(pluginOther);
|
|
|
|
|
pluginHash.remove(pluginOther->id());
|
|
|
|
|
plugins << plugin;
|
|
|
|
|
pluginHash.insert(plugin->id(), plugin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
plugins << plugin;
|
|
|
|
|
pluginHash.insert(plugin->id(), plugin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
QQmlEngine *engine = m_welcomePage->engine();
|
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);
|
2011-07-20 14:33:44 +02:00
|
|
|
if (!debug)
|
|
|
|
|
engine->setOutputWarningsToStandardError(false);
|
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-07-15 15:24:43 +02:00
|
|
|
facilitateQml(engine);
|
2011-04-13 17:09:44 +02:00
|
|
|
foreach (Utils::IWelcomePage *plugin, plugins) {
|
2010-11-11 16:49:17 +01:00
|
|
|
plugin->facilitateQml(engine);
|
|
|
|
|
m_pluginList.append(plugin);
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-12 10:15:08 +01:00
|
|
|
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2014-10-17 13:29:56 +02:00
|
|
|
onThemeChanged();
|
2014-11-14 09:53:44 +02:00
|
|
|
connect(Core::ICore::instance(), &Core::ICore::themeChanged, this, &WelcomeMode::onThemeChanged);
|
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
|
|
|
|
2014-12-17 18:16:41 +01:00
|
|
|
#if defined(USE_QUICK_WIDGET)
|
|
|
|
|
bool useNativeText = !Utils::HostOsInfo::isMacHost();
|
|
|
|
|
#else
|
|
|
|
|
bool useNativeText = true;
|
|
|
|
|
#endif
|
|
|
|
|
ctx->setContextProperty(QLatin1String("useNativeText"), useNativeText);
|
|
|
|
|
|
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
|
|
|
|
|
m_welcomePage->setSource(
|
2012-11-28 14:25:18 +01:00
|
|
|
QUrl::fromLocalFile(path));
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WelcomeMode::welcomePluginAdded(QObject *obj)
|
|
|
|
|
{
|
2014-12-16 12:01:35 +01:00
|
|
|
QHash<Core::Id, Utils::IWelcomePage*> pluginHash;
|
2012-03-06 12:26:18 +01:00
|
|
|
|
|
|
|
|
foreach (QObject *obj, m_pluginList) {
|
|
|
|
|
Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj);
|
|
|
|
|
pluginHash.insert(plugin->id(), plugin);
|
|
|
|
|
}
|
2010-11-11 16:49:17 +01:00
|
|
|
if (Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj)) {
|
2012-03-06 12:26:18 +01:00
|
|
|
//check for duplicated id
|
|
|
|
|
if (pluginHash.contains(plugin->id())) {
|
|
|
|
|
Utils::IWelcomePage* pluginOther = pluginHash.value(plugin->id());
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (pluginOther->priority() > plugin->priority())
|
2012-03-06 12:26:18 +01:00
|
|
|
m_pluginList.removeAll(pluginOther);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2012-03-06 12:26:18 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
int insertPos = 0;
|
2012-06-18 11:34:15 +02:00
|
|
|
foreach (Utils::IWelcomePage* p, PluginManager::getObjects<Utils::IWelcomePage>()) {
|
2010-11-11 16:49:17 +01:00
|
|
|
if (plugin->priority() < p->priority())
|
|
|
|
|
insertPos++;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
m_pluginList.insert(insertPos, plugin);
|
|
|
|
|
// update model through reset
|
2013-09-02 17:29:30 +02:00
|
|
|
QQmlContext *ctx = m_welcomePage->rootContext();
|
2012-01-12 10:15:08 +01:00
|
|
|
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WelcomePlugin::WelcomePlugin()
|
|
|
|
|
: m_welcomeMode(0)
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Initializes the plugin. Returns true on success.
|
|
|
|
|
Plugins want to register objects with the plugin manager here.
|
|
|
|
|
|
2011-09-21 13:05:15 +02:00
|
|
|
\a errorMessage can be used to pass an error message to the plugin system,
|
2009-07-20 19:08:09 +02:00
|
|
|
if there was any.
|
|
|
|
|
*/
|
2011-09-21 13:05:15 +02:00
|
|
|
bool WelcomePlugin::initialize(const QStringList & /* arguments */, QString * /* errorMessage */)
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Notification that all extensions that this plugin depends on have been
|
|
|
|
|
initialized. The dependencies are defined in the plugins .qwp file.
|
|
|
|
|
|
2013-10-07 13:34:40 +02:00
|
|
|
Normally this function is used for things that rely on other plugins to have
|
2009-07-20 19:08:09 +02:00
|
|
|
added objects to the plugin manager, that implement interfaces that we're
|
|
|
|
|
interested in. These objects can now be requested through the
|
|
|
|
|
PluginManagerInterface.
|
|
|
|
|
|
|
|
|
|
The WelcomePlugin doesn't need things from other plugins, so it does
|
|
|
|
|
nothing here.
|
|
|
|
|
*/
|
|
|
|
|
void WelcomePlugin::extensionsInitialized()
|
|
|
|
|
{
|
2009-07-27 13:55:30 +02:00
|
|
|
m_welcomeMode->initPlugins();
|
2012-01-26 01:18:02 +01:00
|
|
|
Core::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"
|