2014-07-11 16:54:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-07-11 16:54:04 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
2014-07-11 16:54:04 +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.
|
2014-07-11 16:54:04 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
2016-01-15 14:57:40 +01:00
|
|
|
|
2014-07-11 16:54:04 +02:00
|
|
|
#include "panelswidget.h"
|
|
|
|
|
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
|
|
#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>
|
2014-07-11 16:54:04 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2016-07-22 15:53:01 +02:00
|
|
|
#include <utils/styledbar.h>
|
2014-07-11 16:54:04 +02:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
const int ICON_SIZE(64);
|
|
|
|
|
|
|
|
|
|
const int ABOVE_HEADING_MARGIN(10);
|
|
|
|
|
const int ABOVE_CONTENTS_MARGIN(4);
|
|
|
|
|
const int BELOW_CONTENTS_MARGIN(16);
|
|
|
|
|
const int PANEL_LEFT_MARGIN = 70;
|
|
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
///
|
|
|
|
|
// OnePixelBlackLine
|
|
|
|
|
///
|
|
|
|
|
/// \brief The OnePixelBlackLine class
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
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;
|
2014-07-11 16:54:04 +02:00
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
class OnePixelBlackLine : public QWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OnePixelBlackLine(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
setMinimumHeight(1);
|
|
|
|
|
setMaximumHeight(1);
|
|
|
|
|
}
|
|
|
|
|
void paintEvent(QPaintEvent *e)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(e);
|
|
|
|
|
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
|
|
|
QColor fillColor = creatorTheme()->color(Theme::PanelsWidgetSeparatorLineColor);
|
2014-07-11 16:54:04 +02:00
|
|
|
p.fillRect(contentsRect(), fillColor);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class RootWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RootWidget(QWidget *parent) : QWidget(parent) {
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
}
|
|
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void RootWidget::paintEvent(QPaintEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QWidget::paintEvent(e);
|
|
|
|
|
|
2016-06-15 17:41:33 +02:00
|
|
|
if (!creatorTheme()->flag(Theme::FlatToolBars)) {
|
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
|
|
|
// draw separator line to the right of the settings panel
|
|
|
|
|
QPainter painter(this);
|
2015-02-03 23:59:04 +02:00
|
|
|
QColor light = StyleHelper::mergedColors(
|
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
|
|
|
palette().button().color(), Qt::white, 30);
|
2015-02-03 23:59:04 +02:00
|
|
|
QColor dark = StyleHelper::mergedColors(
|
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
|
|
|
palette().button().color(), Qt::black, 85);
|
|
|
|
|
|
|
|
|
|
painter.setPen(light);
|
|
|
|
|
painter.drawLine(rect().topRight(), rect().bottomRight());
|
|
|
|
|
painter.setPen(dark);
|
|
|
|
|
painter.drawLine(rect().topRight() - QPoint(1,0), rect().bottomRight() - QPoint(1,0));
|
|
|
|
|
}
|
2014-07-11 16:54:04 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
// PanelsWidget
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
PanelsWidget::PanelsWidget(QWidget *parent) :
|
2016-07-22 15:53:01 +02:00
|
|
|
QWidget(parent),
|
2014-07-11 16:54:04 +02:00
|
|
|
m_root(new RootWidget(this))
|
|
|
|
|
{
|
|
|
|
|
// We want a 900px wide widget with and the scrollbar at the
|
|
|
|
|
// side of the screen.
|
|
|
|
|
m_root->setMaximumWidth(900);
|
|
|
|
|
m_root->setContentsMargins(0, 0, 40, 0);
|
|
|
|
|
QPalette pal;
|
2015-02-03 23:59:04 +02:00
|
|
|
QColor background = StyleHelper::mergedColors(
|
2014-07-11 16:54:04 +02:00
|
|
|
palette().window().color(), Qt::white, 85);
|
|
|
|
|
pal.setColor(QPalette::All, QPalette::Window, background.darker(102));
|
|
|
|
|
setPalette(pal);
|
|
|
|
|
pal.setColor(QPalette::All, QPalette::Window, background);
|
|
|
|
|
m_root->setPalette(pal);
|
|
|
|
|
|
2016-07-22 15:53:01 +02:00
|
|
|
m_scroller = new QScrollArea(this);
|
|
|
|
|
m_scroller->setWidget(m_root);
|
|
|
|
|
m_scroller->setFrameStyle(QFrame::NoFrame);
|
|
|
|
|
m_scroller->setWidgetResizable(true);
|
|
|
|
|
m_scroller->setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
|
2014-07-11 16:54:04 +02:00
|
|
|
// The layout holding the individual panels:
|
2016-04-13 15:52:14 +02:00
|
|
|
auto topLayout = new QVBoxLayout(m_root);
|
2014-07-11 16:54:04 +02:00
|
|
|
topLayout->setMargin(0);
|
|
|
|
|
topLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_layout = new QGridLayout;
|
|
|
|
|
m_layout->setColumnMinimumWidth(0, ICON_SIZE + 4);
|
|
|
|
|
m_layout->setSpacing(0);
|
2016-07-22 15:53:01 +02:00
|
|
|
|
2014-07-11 16:54:04 +02:00
|
|
|
topLayout->addLayout(m_layout);
|
|
|
|
|
topLayout->addStretch(100);
|
|
|
|
|
|
2016-07-22 15:53:01 +02:00
|
|
|
auto layout = new QVBoxLayout(this);
|
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
layout->setSpacing(0);
|
|
|
|
|
layout->addWidget(new Utils::StyledBar(this));
|
|
|
|
|
layout->addWidget(m_scroller);
|
|
|
|
|
|
|
|
|
|
//layout->addWidget(new FindToolBarPlaceHolder(this));
|
2014-07-11 16:54:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PanelsWidget::~PanelsWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Add a widget with heading information into the grid
|
|
|
|
|
* layout of the PanelsWidget.
|
|
|
|
|
*
|
|
|
|
|
* ...
|
|
|
|
|
* +--------+-------------------------------------------+ ABOVE_HEADING_MARGIN
|
|
|
|
|
* | icon | name |
|
|
|
|
|
* + +-------------------------------------------+
|
|
|
|
|
* | | line |
|
|
|
|
|
* + +-------------------------------------------+ ABOVE_CONTENTS_MARGIN
|
|
|
|
|
* | | widget (with contentsmargins adjusted!) |
|
|
|
|
|
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
|
|
|
|
*/
|
2016-09-30 12:59:54 +02:00
|
|
|
void PanelsWidget::addPropertiesPanel(const QString &displayName, const QIcon &icon, QWidget *widget)
|
2014-07-11 16:54:04 +02:00
|
|
|
{
|
|
|
|
|
const int headerRow = m_layout->rowCount();
|
|
|
|
|
|
|
|
|
|
// icon:
|
2016-09-30 12:59:54 +02:00
|
|
|
if (!icon.isNull()) {
|
2016-04-13 15:52:14 +02:00
|
|
|
auto iconLabel = new QLabel(m_root);
|
2016-09-30 12:59:54 +02:00
|
|
|
iconLabel->setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE));
|
2014-07-11 16:54:04 +02:00
|
|
|
iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
|
|
|
|
m_layout->addWidget(iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// name:
|
2016-04-13 15:52:14 +02:00
|
|
|
auto nameLabel = new QLabel(m_root);
|
2016-09-30 12:59:54 +02:00
|
|
|
nameLabel->setText(displayName);
|
2014-07-11 16:54:04 +02:00
|
|
|
QPalette palette = nameLabel->palette();
|
|
|
|
|
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
|
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
|
|
|
// FIXME: theming
|
2014-07-11 16:54:04 +02:00
|
|
|
QColor foregroundColor = palette.color(QPalette::ColorGroup(i), QPalette::Foreground);
|
|
|
|
|
foregroundColor.setAlpha(110);
|
|
|
|
|
palette.setBrush(QPalette::ColorGroup(i), QPalette::Foreground, foregroundColor);
|
|
|
|
|
}
|
|
|
|
|
nameLabel->setPalette(palette);
|
|
|
|
|
nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
|
|
|
|
QFont f = nameLabel->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.6);
|
|
|
|
|
nameLabel->setFont(f);
|
|
|
|
|
m_layout->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
|
|
|
|
|
|
|
|
|
|
// line:
|
2016-09-30 12:59:54 +02:00
|
|
|
const int lineRow = headerRow + 1;
|
2016-04-13 15:52:14 +02:00
|
|
|
auto line = new OnePixelBlackLine(m_root);
|
2014-07-11 16:54:04 +02:00
|
|
|
m_layout->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);
|
|
|
|
|
|
|
|
|
|
// add the widget:
|
2016-09-30 12:59:54 +02:00
|
|
|
const int widgetRow = lineRow + 1;
|
2014-07-11 16:54:04 +02:00
|
|
|
|
|
|
|
|
widget->setContentsMargins(PANEL_LEFT_MARGIN,
|
|
|
|
|
ABOVE_CONTENTS_MARGIN, 0,
|
|
|
|
|
BELOW_CONTENTS_MARGIN);
|
|
|
|
|
widget->setParent(m_root);
|
2016-09-30 12:59:54 +02:00
|
|
|
m_layout->addWidget(widget, widgetRow, 0, 1, 2);
|
2014-07-11 16:54:04 +02:00
|
|
|
}
|