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 "futureprogress.h"
|
2010-02-25 18:53:42 +01:00
|
|
|
#include "progressbar.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-06 08:35:20 +02:00
|
|
|
#include <coreplugin/id.h>
|
|
|
|
|
2013-03-22 14:14:21 +01:00
|
|
|
#include <utils/stylehelper.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-03-22 14:14:21 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QCoreApplication>
|
2013-03-20 16:02:53 +01:00
|
|
|
#include <QFutureWatcher>
|
|
|
|
#include <QGraphicsOpacityEffect>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPropertyAnimation>
|
2013-03-22 14:14:21 +01:00
|
|
|
#include <QPainter>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSequentialAnimationGroup>
|
2013-03-20 16:02:53 +01:00
|
|
|
#include <QTimer>
|
2010-09-16 12:26:28 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QMouseEvent>
|
2009-10-01 16:38:08 +02:00
|
|
|
|
2010-03-12 17:24:20 +01:00
|
|
|
const int notificationTimeout = 8000;
|
2010-03-29 13:43:36 +02:00
|
|
|
const int shortNotificationTimeout = 1000;
|
2010-03-12 17:24:20 +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
|
|
|
using namespace Utils;
|
|
|
|
|
2010-03-22 15:02:16 +01:00
|
|
|
namespace Core {
|
|
|
|
|
2013-03-20 16:02:53 +01:00
|
|
|
class FutureProgressPrivate : public QObject
|
2010-03-22 15:02:16 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2010-03-12 16:26:42 +01:00
|
|
|
|
2013-03-20 16:02:53 +01:00
|
|
|
public:
|
2010-09-16 12:26:28 +02:00
|
|
|
explicit FutureProgressPrivate(FutureProgress *q);
|
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
void fadeAway();
|
2010-10-15 17:22:45 +02:00
|
|
|
void tryToFadeAway();
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
QFutureWatcher<void> m_watcher;
|
|
|
|
Internal::ProgressBar *m_progress;
|
|
|
|
QWidget *m_widget;
|
|
|
|
QHBoxLayout *m_widgetLayout;
|
2013-04-08 15:02:30 +02:00
|
|
|
QWidget *m_statusBarWidget;
|
2013-09-03 15:18:37 +02:00
|
|
|
Id m_type;
|
2010-10-15 17:22:45 +02:00
|
|
|
FutureProgress::KeepOnFinishType m_keep;
|
2010-09-16 12:26:28 +02:00
|
|
|
bool m_waitingForUserInteraction;
|
2010-10-15 17:22:45 +02:00
|
|
|
FutureProgress *m_q;
|
2013-03-22 14:14:21 +01:00
|
|
|
bool m_fadeStarting;
|
2010-10-15 17:22:45 +02:00
|
|
|
bool m_isFading;
|
2010-09-16 12:26:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
FutureProgressPrivate::FutureProgressPrivate(FutureProgress *q) :
|
|
|
|
m_progress(new Internal::ProgressBar), m_widget(0), m_widgetLayout(new QHBoxLayout),
|
2013-04-08 15:02:30 +02:00
|
|
|
m_statusBarWidget(0),
|
2011-06-24 16:00:47 +02:00
|
|
|
m_keep(FutureProgress::HideOnFinish), m_waitingForUserInteraction(false),
|
2013-03-22 14:14:21 +01:00
|
|
|
m_q(q), m_fadeStarting(false), m_isFading(false)
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
\mainclass
|
|
|
|
\class Core::FutureProgress
|
|
|
|
\brief The FutureProgress class is used to adapt the appearance of
|
|
|
|
progress indicators that were created through the ProgressManager class.
|
|
|
|
|
|
|
|
Use the instance of this class that was returned by
|
|
|
|
ProgressManager::addTask() to define a widget that
|
|
|
|
should be shown below the progress bar, or to change the
|
|
|
|
progress title.
|
|
|
|
Also use it to react on the event that the user clicks on
|
|
|
|
the progress indicator (which can be used to e.g. open a more detailed
|
|
|
|
view, or the results of the task).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void FutureProgress::clicked()
|
|
|
|
Connect to this signal to get informed when the user clicks on the
|
|
|
|
progress indicator.
|
|
|
|
*/
|
|
|
|
|
2012-05-12 17:25:37 +02:00
|
|
|
/*!
|
|
|
|
\fn void FutureProgress::canceled()
|
|
|
|
Connect to this signal to get informed when the operation is canceled.
|
|
|
|
*/
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
\fn void FutureProgress::finished()
|
|
|
|
Another way to get informed when the task has finished.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn QWidget FutureProgress::widget() const
|
|
|
|
Returns the custom widget that is shown below the progress indicator.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn FutureProgress::FutureProgress(QWidget *parent)
|
|
|
|
\internal
|
|
|
|
*/
|
2010-09-16 12:26:28 +02:00
|
|
|
FutureProgress::FutureProgress(QWidget *parent) :
|
|
|
|
QWidget(parent), d(new FutureProgressPrivate(this))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
setLayout(layout);
|
2010-09-16 12:26:28 +02:00
|
|
|
layout->addWidget(d->m_progress);
|
2008-12-02 12:01:29 +01:00
|
|
|
layout->setMargin(0);
|
|
|
|
layout->setSpacing(0);
|
2010-09-16 12:26:28 +02:00
|
|
|
layout->addLayout(d->m_widgetLayout);
|
|
|
|
d->m_widgetLayout->setContentsMargins(7, 0, 7, 2);
|
|
|
|
d->m_widgetLayout->setSpacing(0);
|
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(&d->m_watcher, &QFutureWatcherBase::started, this, &FutureProgress::setStarted);
|
|
|
|
connect(&d->m_watcher, &QFutureWatcherBase::finished, this, &FutureProgress::setFinished);
|
|
|
|
connect(&d->m_watcher, &QFutureWatcherBase::canceled, this, &FutureProgress::canceled);
|
|
|
|
connect(&d->m_watcher, &QFutureWatcherBase::progressRangeChanged,
|
|
|
|
this, &FutureProgress::setProgressRange);
|
|
|
|
connect(&d->m_watcher, &QFutureWatcherBase::progressValueChanged,
|
|
|
|
this, &FutureProgress::setProgressValue);
|
|
|
|
connect(&d->m_watcher, &QFutureWatcherBase::progressTextChanged,
|
|
|
|
this, &FutureProgress::setProgressText);
|
|
|
|
connect(d->m_progress, &Internal::ProgressBar::clicked, this, &FutureProgress::cancel);
|
2014-04-17 13:49:14 +02:00
|
|
|
setMinimumWidth(100);
|
|
|
|
setMaximumWidth(300);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
FutureProgress::~FutureProgress()
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d->m_widget;
|
|
|
|
delete d;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
Sets the \a widget to show below the progress bar.
|
|
|
|
This will be destroyed when the progress indicator is destroyed.
|
|
|
|
Default is to show no widget below the progress indicator.
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::setWidget(QWidget *widget)
|
|
|
|
{
|
2011-09-16 15:00:41 +02:00
|
|
|
delete d->m_widget;
|
2008-12-02 12:01:29 +01:00
|
|
|
QSizePolicy sp = widget->sizePolicy();
|
|
|
|
sp.setHorizontalPolicy(QSizePolicy::Ignored);
|
|
|
|
widget->setSizePolicy(sp);
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_widget = widget;
|
|
|
|
if (d->m_widget)
|
|
|
|
d->m_widgetLayout->addWidget(d->m_widget);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
Changes the \a title of the progress indicator.
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::setTitle(const QString &title)
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_progress->setTitle(title);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
Returns the title of the progress indicator.
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
QString FutureProgress::title() const
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_progress->title();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FutureProgress::cancel()
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_watcher.future().cancel();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-03-09 19:31:06 +01:00
|
|
|
void FutureProgress::updateToolTip(const QString &text)
|
|
|
|
{
|
2011-12-22 14:44:14 +01:00
|
|
|
setToolTip(QLatin1String("<b>") + title() + QLatin1String("</b><br>") + text);
|
2010-03-09 19:31:06 +01:00
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::setStarted()
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_progress->reset();
|
|
|
|
d->m_progress->setError(false);
|
|
|
|
d->m_progress->setRange(d->m_watcher.progressMinimum(), d->m_watcher.progressMaximum());
|
|
|
|
d->m_progress->setValue(d->m_watcher.progressValue());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-03-12 16:26:42 +01:00
|
|
|
|
|
|
|
bool FutureProgress::eventFilter(QObject *, QEvent *e)
|
|
|
|
{
|
2010-10-15 17:22:45 +02:00
|
|
|
if (d->m_keep != KeepOnFinish && d->m_waitingForUserInteraction
|
2013-03-20 16:02:53 +01:00
|
|
|
&& (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) {
|
2010-03-12 16:26:42 +01:00
|
|
|
qApp->removeEventFilter(this);
|
2016-02-02 09:10:54 +02:00
|
|
|
QTimer::singleShot(notificationTimeout, d, &FutureProgressPrivate::fadeAway);
|
2010-03-12 16:26:42 +01:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::setFinished()
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
updateToolTip(d->m_watcher.future().progressText());
|
2010-03-22 14:58:41 +01:00
|
|
|
|
2011-05-12 13:21:41 +02:00
|
|
|
d->m_progress->setFinished(true);
|
2010-03-22 14:58:41 +01:00
|
|
|
|
2013-03-22 14:14:21 +01:00
|
|
|
if (d->m_watcher.future().isCanceled()) {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_progress->setError(true);
|
2013-03-22 14:14:21 +01:00
|
|
|
emit hasErrorChanged();
|
|
|
|
} else {
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_progress->setError(false);
|
2013-03-22 14:14:21 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
emit finished();
|
2010-10-15 17:22:45 +02:00
|
|
|
d->tryToFadeAway();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FutureProgressPrivate::tryToFadeAway()
|
|
|
|
{
|
2013-03-22 14:14:21 +01:00
|
|
|
if (m_fadeStarting)
|
2010-10-15 17:22:45 +02:00
|
|
|
return;
|
2011-06-24 15:47:48 +02:00
|
|
|
if (m_keep == FutureProgress::KeepOnFinishTillUserInteraction
|
2011-06-24 16:00:47 +02:00
|
|
|
|| (m_keep == FutureProgress::HideOnFinish && m_progress->hasError())) {
|
2010-10-15 17:22:45 +02:00
|
|
|
m_waitingForUserInteraction = true;
|
|
|
|
//eventfilter is needed to get user interaction
|
|
|
|
//events to start QTimer::singleShot later
|
|
|
|
qApp->installEventFilter(m_q);
|
2013-03-22 14:14:21 +01:00
|
|
|
m_fadeStarting = true;
|
2011-06-24 16:00:47 +02:00
|
|
|
} else if (m_keep == FutureProgress::HideOnFinish) {
|
2016-02-02 09:10:54 +02:00
|
|
|
QTimer::singleShot(shortNotificationTimeout, this, &FutureProgressPrivate::fadeAway);
|
2013-03-22 14:14:21 +01:00
|
|
|
m_fadeStarting = true;
|
2010-03-12 16:26:42 +01:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2010-10-15 17:22:45 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::setProgressRange(int min, int max)
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_progress->setRange(min, max);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FutureProgress::setProgressValue(int val)
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_progress->setValue(val);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FutureProgress::setProgressText(const QString &text)
|
|
|
|
{
|
2010-03-09 19:31:06 +01:00
|
|
|
updateToolTip(text);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::setFuture(const QFuture<void> &future)
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
d->m_watcher.setFuture(future);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
Returns a QFuture object that represents this running task.
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
QFuture<void> FutureProgress::future() const
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_watcher.future();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
\internal
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
void FutureProgress::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
|
emit clicked();
|
|
|
|
QWidget::mousePressEvent(event);
|
|
|
|
}
|
|
|
|
|
2013-03-22 14:14:21 +01:00
|
|
|
void FutureProgress::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QPainter p(this);
|
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 (creatorTheme()->widgetStyle() == Theme::StyleFlat) {
|
2016-03-21 12:48:06 +01:00
|
|
|
p.fillRect(rect(), StyleHelper::baseColor());
|
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
|
|
|
} else {
|
2015-02-03 23:48:19 +02:00
|
|
|
QLinearGradient grad = StyleHelper::statusBarGradient(rect());
|
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
|
|
|
p.fillRect(rect(), grad);
|
|
|
|
}
|
2013-03-22 14:14:21 +01:00
|
|
|
}
|
|
|
|
|
2009-12-21 17:11:47 +01:00
|
|
|
/*!
|
|
|
|
Returns the error state of this progress indicator.
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
bool FutureProgress::hasError() const
|
|
|
|
{
|
2010-09-16 12:26:28 +02:00
|
|
|
return d->m_progress->hasError();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-03-12 16:26:42 +01:00
|
|
|
|
2013-09-03 15:18:37 +02:00
|
|
|
void FutureProgress::setType(Id type)
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
|
|
|
d->m_type = type;
|
|
|
|
}
|
|
|
|
|
2013-09-03 15:18:37 +02:00
|
|
|
Id FutureProgress::type() const
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
|
|
|
return d->m_type;
|
|
|
|
}
|
|
|
|
|
2010-10-15 17:22:45 +02:00
|
|
|
void FutureProgress::setKeepOnFinish(KeepOnFinishType keepType)
|
2010-09-16 12:26:28 +02:00
|
|
|
{
|
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 (d->m_keep == keepType)
|
2010-10-15 17:22:45 +02:00
|
|
|
return;
|
|
|
|
d->m_keep = keepType;
|
|
|
|
|
|
|
|
//if it is not finished tryToFadeAway is called by setFinished at the end
|
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 (d->m_watcher.isFinished())
|
2010-10-15 17:22:45 +02:00
|
|
|
d->tryToFadeAway();
|
2010-09-16 12:26:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FutureProgress::keepOnFinish() const
|
|
|
|
{
|
|
|
|
return d->m_keep;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *FutureProgress::widget() const
|
|
|
|
{
|
|
|
|
return d->m_widget;
|
|
|
|
}
|
|
|
|
|
2013-04-08 15:02:30 +02:00
|
|
|
void FutureProgress::setStatusBarWidget(QWidget *widget)
|
|
|
|
{
|
|
|
|
if (widget == d->m_statusBarWidget)
|
|
|
|
return;
|
|
|
|
delete d->m_statusBarWidget;
|
|
|
|
d->m_statusBarWidget = widget;
|
|
|
|
emit statusBarWidgetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *FutureProgress::statusBarWidget() const
|
|
|
|
{
|
|
|
|
return d->m_statusBarWidget;
|
|
|
|
}
|
|
|
|
|
2013-03-22 14:14:21 +01:00
|
|
|
bool FutureProgress::isFading() const
|
|
|
|
{
|
|
|
|
return d->m_isFading;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize FutureProgress::sizeHint() const
|
|
|
|
{
|
2014-04-17 13:49:14 +02:00
|
|
|
return QSize(QWidget::sizeHint().width(), minimumHeight());
|
2013-03-22 14:14:21 +01:00
|
|
|
}
|
|
|
|
|
2013-03-20 16:02:53 +01:00
|
|
|
void FutureProgressPrivate::fadeAway()
|
|
|
|
{
|
2013-03-22 14:14:21 +01:00
|
|
|
m_isFading = true;
|
|
|
|
|
2013-03-20 16:02:53 +01:00
|
|
|
QGraphicsOpacityEffect *opacityEffect = new QGraphicsOpacityEffect;
|
|
|
|
opacityEffect->setOpacity(1.);
|
|
|
|
m_q->setGraphicsEffect(opacityEffect);
|
|
|
|
|
|
|
|
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(this);
|
|
|
|
QPropertyAnimation *animation = new QPropertyAnimation(opacityEffect, "opacity");
|
2015-02-03 23:48:19 +02:00
|
|
|
animation->setDuration(StyleHelper::progressFadeAnimationDuration);
|
2013-03-20 16:02:53 +01:00
|
|
|
animation->setEndValue(0.);
|
|
|
|
group->addAnimation(animation);
|
|
|
|
animation = new QPropertyAnimation(m_q, "maximumHeight");
|
|
|
|
animation->setDuration(120);
|
|
|
|
animation->setEasingCurve(QEasingCurve::InCurve);
|
|
|
|
animation->setStartValue(m_q->sizeHint().height());
|
|
|
|
animation->setEndValue(0.0);
|
|
|
|
group->addAnimation(animation);
|
|
|
|
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(group, &QAbstractAnimation::finished, m_q, &FutureProgress::removeMe);
|
2013-03-22 14:14:21 +01:00
|
|
|
group->start(QAbstractAnimation::DeleteWhenStopped);
|
|
|
|
emit m_q->fadeStarted();
|
2013-03-20 16:02:53 +01:00
|
|
|
}
|
|
|
|
|
2010-09-16 12:26:28 +02:00
|
|
|
} // namespace Core
|
|
|
|
|
2010-03-22 15:02:16 +01:00
|
|
|
#include "futureprogress.moc"
|