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
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
#include <extensionsystem/iplugin.h>
|
2011-04-13 17:09:44 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-07-27 13:55:30 +02:00
|
|
|
|
2017-08-29 11:48:48 +02:00
|
|
|
#include <app/app_version.h>
|
|
|
|
|
|
2016-07-22 09:12:27 +03:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
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>
|
2017-01-06 21:41:46 +01:00
|
|
|
#include <utils/treemodel.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>
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
#include <QDesktopServices>
|
|
|
|
|
#include <QHeaderView>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMouseEvent>
|
2017-06-13 11:02:58 +02:00
|
|
|
#include <QOpenGLWidget>
|
2017-01-06 21:41:46 +01:00
|
|
|
#include <QPainter>
|
2017-09-02 00:06:56 +02:00
|
|
|
#include <QScrollArea>
|
2017-01-06 21:41:46 +01:00
|
|
|
#include <QStackedWidget>
|
2016-11-15 15:58:51 +01:00
|
|
|
#include <QTimer>
|
2017-01-06 21:41:46 +01:00
|
|
|
#include <QVBoxLayout>
|
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
|
|
|
|
|
|
|
|
namespace Welcome {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
class SideBar;
|
|
|
|
|
|
|
|
|
|
const int lrPadding = 34;
|
|
|
|
|
const char currentPageSettingsKeyC[] = "Welcome2Tab";
|
|
|
|
|
|
|
|
|
|
static QColor themeColor(Theme::Color role)
|
|
|
|
|
{
|
|
|
|
|
return Utils::creatorTheme()->color(role);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QFont sizedFont(int size, const QWidget *widget, bool underline = false)
|
2014-12-18 17:52:49 +01:00
|
|
|
{
|
2017-01-06 21:41:46 +01:00
|
|
|
QFont f = widget->font();
|
|
|
|
|
f.setPixelSize(size);
|
|
|
|
|
f.setUnderline(underline);
|
|
|
|
|
return f;
|
2014-12-18 17:52:49 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
static QPalette lightText()
|
2014-12-18 17:52:49 +01:00
|
|
|
{
|
2017-01-06 21:41:46 +01:00
|
|
|
QPalette pal;
|
|
|
|
|
pal.setColor(QPalette::Foreground, themeColor(Theme::Welcome_ForegroundPrimaryColor));
|
|
|
|
|
pal.setColor(QPalette::WindowText, themeColor(Theme::Welcome_ForegroundPrimaryColor));
|
|
|
|
|
return pal;
|
2014-12-18 17:52:49 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-14 12:32:19 +01:00
|
|
|
static void addWeakVerticalSpacerToLayout(QVBoxLayout *layout, int maximumSize)
|
|
|
|
|
{
|
|
|
|
|
auto weakSpacer = new QWidget;
|
|
|
|
|
weakSpacer->setMaximumHeight(maximumSize);
|
|
|
|
|
weakSpacer->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
|
|
|
|
|
layout->addWidget(weakSpacer);
|
|
|
|
|
layout->setStretchFactor(weakSpacer, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
class WelcomeMode : public IMode
|
2016-03-14 16:17:30 +01:00
|
|
|
{
|
2017-01-06 21:41:46 +01:00
|
|
|
Q_OBJECT
|
2016-03-14 16:17:30 +01:00
|
|
|
public:
|
2017-01-06 21:41:46 +01:00
|
|
|
WelcomeMode();
|
|
|
|
|
~WelcomeMode();
|
2016-03-14 16:17:30 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
void initPlugins();
|
2016-03-14 16:17:30 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
Q_INVOKABLE bool openDroppedFiles(const QList<QUrl> &urls);
|
2016-03-14 16:17:30 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
private:
|
|
|
|
|
void addPage(IWelcomePage *page);
|
2016-03-14 16:17:30 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
QWidget *m_modeWidget;
|
|
|
|
|
QStackedWidget *m_pageStack;
|
|
|
|
|
SideBar *m_sideBar;
|
|
|
|
|
QList<IWelcomePage *> m_pluginList;
|
|
|
|
|
QList<WelcomePageButton *> m_pageButtons;
|
|
|
|
|
Id m_activePage;
|
|
|
|
|
};
|
2016-03-14 16:17:30 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
class WelcomePlugin : public ExtensionSystem::IPlugin
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Welcome.json")
|
2016-03-14 16:17:30 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
public:
|
2018-02-06 13:33:52 +01:00
|
|
|
~WelcomePlugin() final { delete m_welcomeMode; }
|
2017-01-06 21:41:46 +01:00
|
|
|
|
|
|
|
|
bool initialize(const QStringList &, QString *) final
|
|
|
|
|
{
|
|
|
|
|
m_welcomeMode = new WelcomeMode;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void extensionsInitialized() final
|
|
|
|
|
{
|
|
|
|
|
m_welcomeMode->initPlugins();
|
|
|
|
|
ModeManager::activateMode(m_welcomeMode->id());
|
2016-03-14 16:17:30 +01:00
|
|
|
}
|
2017-01-06 21:41:46 +01:00
|
|
|
|
|
|
|
|
WelcomeMode *m_welcomeMode = nullptr;
|
2016-03-14 16:17:30 +01:00
|
|
|
};
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
class IconAndLink : public QWidget
|
2011-04-13 17:09:44 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2017-01-06 21:41:46 +01:00
|
|
|
IconAndLink(const QString &iconSource,
|
|
|
|
|
const QString &title,
|
|
|
|
|
const QString &openUrl,
|
|
|
|
|
QWidget *parent)
|
|
|
|
|
: QWidget(parent), m_iconSource(iconSource), m_title(title), m_openUrl(openUrl)
|
|
|
|
|
{
|
|
|
|
|
setAutoFillBackground(true);
|
2017-02-17 16:59:32 +01:00
|
|
|
setMinimumHeight(30);
|
2017-10-15 21:57:45 +02:00
|
|
|
setToolTip(m_openUrl);
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
const QString fileName = QString(":/welcome/images/%1.png").arg(iconSource);
|
2017-02-22 15:09:35 +01:00
|
|
|
const Icon icon({{fileName, Theme::Welcome_ForegroundPrimaryColor}}, Icon::Tint);
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
m_icon = new QLabel;
|
|
|
|
|
m_icon->setPixmap(icon.pixmap());
|
2016-07-22 09:12:27 +03:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
m_label = new QLabel(title);
|
|
|
|
|
m_label->setFont(sizedFont(11, m_label, false));
|
2016-11-15 15:58:51 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
auto layout = new QHBoxLayout;
|
|
|
|
|
layout->setContentsMargins(lrPadding, 0, lrPadding, 0);
|
|
|
|
|
layout->addWidget(m_icon);
|
|
|
|
|
layout->addSpacing(2);
|
|
|
|
|
layout->addWidget(m_label);
|
|
|
|
|
layout->addStretch(1);
|
|
|
|
|
setLayout(layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void enterEvent(QEvent *) override
|
2010-11-11 16:49:17 +01:00
|
|
|
{
|
2017-01-06 21:41:46 +01:00
|
|
|
QPalette pal;
|
|
|
|
|
pal.setColor(QPalette::Background, themeColor(Theme::Welcome_HoverColor));
|
|
|
|
|
setPalette(pal);
|
|
|
|
|
m_label->setFont(sizedFont(11, m_label, true));
|
|
|
|
|
update();
|
2010-11-11 16:49:17 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
void leaveEvent(QEvent *) override
|
|
|
|
|
{
|
|
|
|
|
QPalette pal;
|
|
|
|
|
pal.setColor(QPalette::Background, themeColor(Theme::Welcome_BackgroundColor));
|
|
|
|
|
setPalette(pal);
|
|
|
|
|
m_label->setFont(sizedFont(11, m_label, false));
|
|
|
|
|
update();
|
|
|
|
|
}
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
void mousePressEvent(QMouseEvent *) override
|
|
|
|
|
{
|
|
|
|
|
QDesktopServices::openUrl(m_openUrl);
|
|
|
|
|
}
|
2016-07-22 09:12:27 +03:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
QString m_iconSource;
|
|
|
|
|
QString m_title;
|
2017-10-15 21:57:45 +02:00
|
|
|
const QString m_openUrl;
|
2016-07-22 09:12:27 +03:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
QLabel *m_icon;
|
|
|
|
|
QLabel *m_label;
|
|
|
|
|
};
|
2011-07-15 15:24:43 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
class SideBar : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
SideBar(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
setAutoFillBackground(true);
|
|
|
|
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
|
|
|
setPalette(themeColor(Theme::Welcome_BackgroundColor));
|
|
|
|
|
|
|
|
|
|
auto vbox = new QVBoxLayout(this);
|
|
|
|
|
vbox->setSpacing(0);
|
|
|
|
|
vbox->setContentsMargins(0, 27, 0, 0);
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
auto l = m_pluginButtons = new QVBoxLayout;
|
|
|
|
|
l->setContentsMargins(lrPadding, 0, lrPadding, 0);
|
2017-03-24 15:07:49 +01:00
|
|
|
l->setSpacing(19);
|
2017-01-06 21:41:46 +01:00
|
|
|
vbox->addItem(l);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-14 12:32:19 +01:00
|
|
|
addWeakVerticalSpacerToLayout(vbox, 62);
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
{
|
|
|
|
|
auto l = new QVBoxLayout;
|
|
|
|
|
l->setContentsMargins(lrPadding, 0, lrPadding, 0);
|
2017-12-14 12:32:19 +01:00
|
|
|
l->setSpacing(12);
|
2017-01-06 21:41:46 +01:00
|
|
|
|
|
|
|
|
auto newLabel = new QLabel(tr("New to Qt?"), this);
|
|
|
|
|
newLabel->setFont(sizedFont(18, this));
|
|
|
|
|
l->addWidget(newLabel);
|
|
|
|
|
|
|
|
|
|
auto learnLabel = new QLabel(tr("Learn how to develop your own applications "
|
2017-08-29 11:48:48 +02:00
|
|
|
"and explore %1.")
|
|
|
|
|
.arg(Core::Constants::IDE_DISPLAY_NAME), this);
|
2017-01-06 21:41:46 +01:00
|
|
|
learnLabel->setMaximumWidth(200);
|
|
|
|
|
learnLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
|
|
|
learnLabel->setWordWrap(true);
|
|
|
|
|
learnLabel->setFont(sizedFont(12, this));
|
|
|
|
|
learnLabel->setPalette(lightText());
|
|
|
|
|
l->addWidget(learnLabel);
|
|
|
|
|
|
2017-12-14 12:32:19 +01:00
|
|
|
l->addSpacing(8);
|
2017-01-06 21:41:46 +01:00
|
|
|
|
|
|
|
|
auto getStartedButton = new WelcomePageButton(this);
|
|
|
|
|
getStartedButton->setText(tr("Get Started Now"));
|
|
|
|
|
getStartedButton->setOnClicked([] {
|
|
|
|
|
QDesktopServices::openUrl(QString("qthelp://org.qt-project.qtcreator/doc/index.html"));
|
|
|
|
|
});
|
|
|
|
|
l->addWidget(getStartedButton);
|
|
|
|
|
|
|
|
|
|
vbox->addItem(l);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-14 12:32:19 +01:00
|
|
|
vbox->addStretch(1);
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
{
|
|
|
|
|
auto l = new QVBoxLayout;
|
|
|
|
|
l->setContentsMargins(0, 0, 0, 0);
|
2017-02-17 16:59:32 +01:00
|
|
|
l->setSpacing(5);
|
2017-01-06 21:41:46 +01:00
|
|
|
l->addWidget(new IconAndLink("qtaccount", tr("Qt Account"), "https://account.qt.io", this));
|
2017-12-01 17:33:03 +01:00
|
|
|
l->addWidget(new IconAndLink("community", tr("Online Community"), "https://forum.qt.io", this));
|
|
|
|
|
l->addWidget(new IconAndLink("blogs", tr("Blogs"), "https://planet.qt.io", this));
|
2017-01-06 21:41:46 +01:00
|
|
|
l->addWidget(new IconAndLink("userguide", tr("User Guide"),
|
|
|
|
|
"qthelp://org.qt-project.qtcreator/doc/index.html", this));
|
|
|
|
|
vbox->addItem(l);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-14 12:32:19 +01:00
|
|
|
addWeakVerticalSpacerToLayout(vbox, vbox->contentsMargins().top());
|
2017-01-06 21:41:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *m_pluginButtons = nullptr;
|
2011-04-13 17:09:44 +02:00
|
|
|
};
|
|
|
|
|
|
2014-10-17 13:29:56 +02:00
|
|
|
WelcomeMode::WelcomeMode()
|
2011-04-13 17:09:44 +02:00
|
|
|
{
|
|
|
|
|
setDisplayName(tr("Welcome"));
|
2015-11-11 19:26:58 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
const Icon CLASSIC(":/welcome/images/mode_welcome.png");
|
|
|
|
|
const Icon FLAT({{":/welcome/images/mode_welcome_mask.png",
|
|
|
|
|
Theme::IconsBaseColor}});
|
|
|
|
|
const Icon FLAT_ACTIVE({{":/welcome/images/mode_welcome_mask.png",
|
|
|
|
|
Theme::IconsModeWelcomeActiveColor}});
|
|
|
|
|
setIcon(Icon::modeIcon(CLASSIC, FLAT, FLAT_ACTIVE));
|
2015-11-11 19:26:58 +01:00
|
|
|
|
2015-01-06 13:58:00 +01:00
|
|
|
setPriority(Constants::P_MODE_WELCOME);
|
|
|
|
|
setId(Constants::MODE_WELCOME);
|
2017-01-06 21:41:46 +01:00
|
|
|
setContextHelpId("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
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
QPalette palette = creatorTheme()->palette();
|
|
|
|
|
palette.setColor(QPalette::Background, themeColor(Theme::Welcome_BackgroundColor));
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
m_modeWidget = new QWidget;
|
|
|
|
|
m_modeWidget->setPalette(palette);
|
2014-06-16 14:55:37 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
m_sideBar = new SideBar(m_modeWidget);
|
2017-09-02 00:06:56 +02:00
|
|
|
auto scrollableSideBar = new QScrollArea(m_modeWidget);
|
|
|
|
|
scrollableSideBar->setWidget(m_sideBar);
|
|
|
|
|
scrollableSideBar->setWidgetResizable(true);
|
|
|
|
|
scrollableSideBar->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
scrollableSideBar->setFrameShape(QFrame::NoFrame);
|
2014-06-16 14:55:37 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
auto divider = new QWidget(m_modeWidget);
|
|
|
|
|
divider->setMaximumWidth(1);
|
|
|
|
|
divider->setMinimumWidth(1);
|
|
|
|
|
divider->setAutoFillBackground(true);
|
|
|
|
|
divider->setPalette(themeColor(Theme::Welcome_DividerColor));
|
2014-06-16 14:55:37 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
m_pageStack = new QStackedWidget(m_modeWidget);
|
2017-09-06 08:55:03 +02:00
|
|
|
m_pageStack->setObjectName("WelcomeScreenStackedWidget");
|
2017-01-06 21:41:46 +01:00
|
|
|
m_pageStack->setAutoFillBackground(true);
|
2013-09-02 17:29:30 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
auto hbox = new QHBoxLayout;
|
2017-09-02 00:06:56 +02:00
|
|
|
hbox->addWidget(scrollableSideBar);
|
2017-01-06 21:41:46 +01:00
|
|
|
hbox->addWidget(divider);
|
|
|
|
|
hbox->addWidget(m_pageStack);
|
|
|
|
|
hbox->setStretchFactor(m_pageStack, 10);
|
2013-09-02 17:29:30 +02:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
auto layout = new QVBoxLayout(m_modeWidget);
|
|
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->addWidget(new StyledBar(m_modeWidget));
|
|
|
|
|
layout->addItem(hbox);
|
2016-07-22 09:12:27 +03:00
|
|
|
|
2017-06-13 11:02:58 +02:00
|
|
|
if (Utils::HostOsInfo::isMacHost()) { // workaround QTBUG-61384
|
|
|
|
|
auto openglWidget = new QOpenGLWidget;
|
|
|
|
|
openglWidget->hide();
|
|
|
|
|
layout->addWidget(openglWidget);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
setWidget(m_modeWidget);
|
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();
|
2017-01-06 21:41:46 +01:00
|
|
|
settings->setValue(currentPageSettingsKeyC, m_activePage.toSetting());
|
2011-06-29 12:17:52 +02:00
|
|
|
delete m_modeWidget;
|
2009-07-20 19:08:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-12-18 17:52:49 +01:00
|
|
|
void WelcomeMode::initPlugins()
|
|
|
|
|
{
|
2015-01-06 13:58:00 +01:00
|
|
|
QSettings *settings = ICore::settings();
|
2017-01-06 21:41:46 +01:00
|
|
|
m_activePage = Id::fromSetting(settings->value(currentPageSettingsKeyC));
|
2014-12-18 17:52:49 +01:00
|
|
|
|
2017-12-08 17:20:48 +01:00
|
|
|
for (IWelcomePage *page : IWelcomePage::allWelcomePages())
|
2017-01-06 21:41:46 +01:00
|
|
|
addPage(page);
|
2014-12-18 17:52:49 +01:00
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
if (!m_activePage.isValid() && !m_pageButtons.isEmpty()) {
|
2018-07-09 11:05:16 +02:00
|
|
|
const int welcomeIndex = Utils::indexOf(m_pluginList,
|
|
|
|
|
Utils::equal(&IWelcomePage::id,
|
|
|
|
|
Core::Id("Examples")));
|
|
|
|
|
const int defaultIndex = welcomeIndex >= 0 ? welcomeIndex : 0;
|
|
|
|
|
m_activePage = m_pluginList.at(defaultIndex)->id();
|
|
|
|
|
m_pageButtons.at(defaultIndex)->click();
|
2017-01-06 21:41:46 +01:00
|
|
|
}
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
2016-11-15 15:58:51 +01:00
|
|
|
bool WelcomeMode::openDroppedFiles(const QList<QUrl> &urls)
|
|
|
|
|
{
|
2017-01-06 21:41:46 +01:00
|
|
|
// DropArea {
|
|
|
|
|
// anchors.fill: parent
|
|
|
|
|
// keys: ["text/uri-list"]
|
|
|
|
|
// onDropped: {
|
|
|
|
|
// if ((drop.supportedActions & Qt.CopyAction != 0)
|
|
|
|
|
// && welcomeMode.openDroppedFiles(drop.urls))
|
|
|
|
|
// drop.accept(Qt.CopyAction);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2016-11-15 15:58:51 +01:00
|
|
|
const QList<QUrl> localUrls = Utils::filtered(urls, &QUrl::isLocalFile);
|
|
|
|
|
if (!localUrls.isEmpty()) {
|
|
|
|
|
QTimer::singleShot(0, [localUrls]() {
|
|
|
|
|
ICore::openFiles(Utils::transform(localUrls, &QUrl::toLocalFile), ICore::SwitchMode);
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-06 21:41:46 +01:00
|
|
|
void WelcomeMode::addPage(IWelcomePage *page)
|
2014-12-18 17:52:49 +01:00
|
|
|
{
|
2017-01-06 21:41:46 +01:00
|
|
|
int idx;
|
|
|
|
|
int pagePriority = page->priority();
|
|
|
|
|
for (idx = 0; idx != m_pluginList.size(); ++idx) {
|
|
|
|
|
if (m_pluginList.at(idx)->priority() >= pagePriority)
|
|
|
|
|
break;
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
2017-01-06 21:41:46 +01:00
|
|
|
auto pageButton = new WelcomePageButton(m_sideBar);
|
|
|
|
|
auto pageId = page->id();
|
|
|
|
|
pageButton->setText(page->title());
|
|
|
|
|
pageButton->setActiveChecker([this, pageId] { return m_activePage == pageId; });
|
|
|
|
|
|
|
|
|
|
m_pluginList.append(page);
|
|
|
|
|
m_pageButtons.append(pageButton);
|
|
|
|
|
|
|
|
|
|
m_sideBar->m_pluginButtons->insertWidget(idx, pageButton);
|
|
|
|
|
|
|
|
|
|
QWidget *stackPage = page->createWidget();
|
|
|
|
|
stackPage->setAutoFillBackground(true);
|
|
|
|
|
m_pageStack->insertWidget(idx, stackPage);
|
|
|
|
|
|
2017-09-07 17:05:47 +02:00
|
|
|
auto onClicked = [this, pageId, stackPage] {
|
2017-01-06 21:41:46 +01:00
|
|
|
m_activePage = pageId;
|
|
|
|
|
m_pageStack->setCurrentWidget(stackPage);
|
|
|
|
|
for (WelcomePageButton *pageButton : m_pageButtons)
|
|
|
|
|
pageButton->recheckActive();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pageButton->setOnClicked(onClicked);
|
|
|
|
|
if (pageId == m_activePage)
|
|
|
|
|
onClicked();
|
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"
|