2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "fancyactionbar.h"
|
2018-02-20 18:11:23 +01:00
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
#include "coreconstants.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-03-14 10:44:46 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2011-11-14 17:33:28 +01:00
|
|
|
#include <utils/stringutils.h>
|
2018-02-20 18:11:23 +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>
|
2018-02-20 18:11:23 +01:00
|
|
|
#include <utils/tooltip/tooltip.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
2018-02-20 18:11:23 +01:00
|
|
|
#include <QDebug>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QEvent>
|
2018-02-20 18:11:23 +01:00
|
|
|
#include <QMouseEvent>
|
|
|
|
|
#include <QPainter>
|
2015-10-22 13:40:44 +02:00
|
|
|
#include <QPixmapCache>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QPropertyAnimation>
|
2018-02-20 18:11:23 +01:00
|
|
|
#include <QStyle>
|
|
|
|
|
#include <QStyleOption>
|
|
|
|
|
#include <QVBoxLayout>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-11 17:11:15 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-11-06 08:33:17 +01:00
|
|
|
FancyToolButton::FancyToolButton(QAction *action, QWidget *parent)
|
2018-02-20 18:11:23 +01:00
|
|
|
: QToolButton(parent)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2015-11-06 08:33:17 +01:00
|
|
|
setDefaultAction(action);
|
|
|
|
|
connect(action, &QAction::changed, this, &FancyToolButton::actionChanged);
|
2015-11-06 08:33:44 +01:00
|
|
|
actionChanged();
|
2015-11-06 08:33:17 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
setAttribute(Qt::WA_Hover, true);
|
2009-07-13 18:04:08 +02:00
|
|
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-17 17:09:00 +01:00
|
|
|
bool FancyToolButton::event(QEvent *e)
|
|
|
|
|
{
|
2012-11-28 20:44:03 +02:00
|
|
|
switch (e->type()) {
|
2018-02-20 18:11:23 +01:00
|
|
|
case QEvent::Enter: {
|
|
|
|
|
auto animation = new QPropertyAnimation(this, "fader");
|
|
|
|
|
animation->setDuration(125);
|
|
|
|
|
animation->setEndValue(1.0);
|
|
|
|
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
|
|
|
|
} break;
|
|
|
|
|
case QEvent::Leave: {
|
|
|
|
|
auto animation = new QPropertyAnimation(this, "fader");
|
|
|
|
|
animation->setDuration(125);
|
|
|
|
|
animation->setEndValue(0.0);
|
|
|
|
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
|
|
|
|
} break;
|
|
|
|
|
case QEvent::ToolTip: {
|
|
|
|
|
auto he = static_cast<QHelpEvent *>(e);
|
|
|
|
|
ToolTip::show(mapToGlobal(he->pos()), toolTip(), this);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-02-17 17:09:00 +01:00
|
|
|
default:
|
2018-02-20 18:11:23 +01:00
|
|
|
break;
|
2010-02-17 17:09:00 +01:00
|
|
|
}
|
2018-02-20 18:11:23 +01:00
|
|
|
return QToolButton::event(e);
|
2010-02-17 17:09:00 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-04 10:50:51 +02:00
|
|
|
static int findSplitPos(const QString &text, const QFontMetrics &fontMetrics, qreal availableWidth)
|
|
|
|
|
{
|
|
|
|
|
if (text.length() == 0)
|
|
|
|
|
return -1;
|
|
|
|
|
int splitPos = -1;
|
|
|
|
|
int lastWhiteSpace;
|
|
|
|
|
int firstWhiteSpace = text.length();
|
|
|
|
|
do {
|
|
|
|
|
// search backwards for ranges of whitespaces
|
|
|
|
|
// search first whitespace (backwards)
|
|
|
|
|
lastWhiteSpace = firstWhiteSpace - 1; // start before last blob (or at end of text)
|
|
|
|
|
while (lastWhiteSpace >= 0) {
|
|
|
|
|
if (text.at(lastWhiteSpace).isSpace())
|
|
|
|
|
break;
|
|
|
|
|
--lastWhiteSpace;
|
|
|
|
|
}
|
|
|
|
|
// search last whitespace (backwards)
|
|
|
|
|
firstWhiteSpace = lastWhiteSpace;
|
|
|
|
|
while (firstWhiteSpace > 0) {
|
|
|
|
|
if (!text.at(firstWhiteSpace - 1).isSpace())
|
|
|
|
|
break;
|
|
|
|
|
--firstWhiteSpace;
|
|
|
|
|
}
|
|
|
|
|
// if the text after the whitespace range fits into the available width, that's a great
|
|
|
|
|
// position for splitting, but look if we can fit more
|
|
|
|
|
if (firstWhiteSpace != -1) {
|
|
|
|
|
if (fontMetrics.horizontalAdvance(text.mid(lastWhiteSpace + 1)) <= availableWidth)
|
|
|
|
|
splitPos = lastWhiteSpace + 1;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (firstWhiteSpace > 0
|
|
|
|
|
&& fontMetrics.horizontalAdvance(text.left(firstWhiteSpace)) > availableWidth);
|
|
|
|
|
return splitPos;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-20 18:11:23 +01:00
|
|
|
static QVector<QString> splitInTwoLines(const QString &text,
|
|
|
|
|
const QFontMetrics &fontMetrics,
|
2011-11-14 17:33:28 +01:00
|
|
|
qreal availableWidth)
|
|
|
|
|
{
|
|
|
|
|
// split in two lines.
|
|
|
|
|
// this looks if full words can be split off at the end of the string,
|
|
|
|
|
// to put them in the second line. First line is drawn with ellipsis,
|
|
|
|
|
// second line gets ellipsis if it couldn't split off full words.
|
|
|
|
|
QVector<QString> splitLines(2);
|
2021-06-04 10:50:51 +02:00
|
|
|
const int splitPos = findSplitPos(text, fontMetrics, availableWidth);
|
2011-11-14 17:33:28 +01:00
|
|
|
// check if we could split at white space at all
|
|
|
|
|
if (splitPos < 0) {
|
2018-02-20 18:11:23 +01:00
|
|
|
splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, int(availableWidth));
|
2017-02-22 15:09:35 +01:00
|
|
|
QString common = Utils::commonPrefix(QStringList({splitLines[0], text}));
|
2011-11-14 17:33:28 +01:00
|
|
|
splitLines[1] = text.mid(common.length());
|
|
|
|
|
// elide the second line even if it fits, since it is cut off in mid-word
|
2019-02-11 10:32:46 +01:00
|
|
|
while (fontMetrics.horizontalAdvance(QChar(0x2026) /*'...'*/ + splitLines[1]) > availableWidth
|
2011-11-14 17:33:28 +01:00
|
|
|
&& splitLines[1].length() > 3
|
|
|
|
|
/*keep at least three original characters (should not happen)*/) {
|
|
|
|
|
splitLines[1].remove(0, 1);
|
|
|
|
|
}
|
|
|
|
|
splitLines[1] = QChar(0x2026) /*'...'*/ + splitLines[1];
|
|
|
|
|
} else {
|
2018-02-20 18:11:23 +01:00
|
|
|
splitLines[0] = fontMetrics.elidedText(text.left(splitPos).trimmed(),
|
|
|
|
|
Qt::ElideRight,
|
|
|
|
|
int(availableWidth));
|
2011-11-14 17:33:28 +01:00
|
|
|
splitLines[1] = text.mid(splitPos);
|
|
|
|
|
}
|
|
|
|
|
return splitLines;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void FancyToolButton::paintEvent(QPaintEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(event)
|
2010-01-22 18:04:24 +01:00
|
|
|
QPainter painter(this);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2010-01-22 18:04:24 +01:00
|
|
|
// draw borders
|
2015-02-03 23:48:19 +02:00
|
|
|
if (!HostOsInfo::isMacHost() // Mac UIs usually don't hover
|
2018-02-20 18:11:23 +01:00
|
|
|
&& m_fader > 0 && isEnabled() && !isDown() && !isChecked()) {
|
2010-02-17 17:09:00 +01:00
|
|
|
painter.save();
|
2016-06-15 17:41:33 +02:00
|
|
|
if (creatorTheme()->flag(Theme::FlatToolBars)) {
|
2015-10-22 13:40:44 +02:00
|
|
|
const QColor hoverColor = creatorTheme()->color(Theme::FancyToolButtonHoverColor);
|
|
|
|
|
QColor fadedHoverColor = hoverColor;
|
|
|
|
|
fadedHoverColor.setAlpha(int(m_fader * hoverColor.alpha()));
|
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
|
|
|
painter.fillRect(rect(), fadedHoverColor);
|
2016-06-15 17:41:33 +02:00
|
|
|
} else {
|
|
|
|
|
painter.setOpacity(m_fader);
|
|
|
|
|
FancyToolButton::hoverOverlay(&painter, 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
|
|
|
}
|
2010-02-17 17:09:00 +01:00
|
|
|
painter.restore();
|
2013-03-14 10:44:46 +01:00
|
|
|
} else if (isDown() || isChecked()) {
|
2010-02-17 17:09:00 +01:00
|
|
|
painter.save();
|
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
|
|
|
const QColor selectedColor = creatorTheme()->color(Theme::FancyToolButtonSelectedColor);
|
2016-06-15 17:41:33 +02:00
|
|
|
if (creatorTheme()->flag(Theme::FlatToolBars)) {
|
|
|
|
|
painter.fillRect(rect(), selectedColor);
|
|
|
|
|
} else {
|
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
|
|
|
QLinearGradient grad(rect().topLeft(), rect().topRight());
|
|
|
|
|
grad.setColorAt(0, Qt::transparent);
|
|
|
|
|
grad.setColorAt(0.5, selectedColor);
|
|
|
|
|
grad.setColorAt(1, Qt::transparent);
|
|
|
|
|
painter.fillRect(rect(), grad);
|
|
|
|
|
painter.setPen(QPen(grad, 1.0));
|
2015-10-22 13:40:44 +02:00
|
|
|
const QRectF borderRectF(QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5));
|
|
|
|
|
painter.drawLine(borderRectF.topLeft(), borderRectF.topRight());
|
|
|
|
|
painter.drawLine(borderRectF.topLeft(), borderRectF.topRight());
|
2018-02-20 18:11:23 +01:00
|
|
|
painter.drawLine(borderRectF.topLeft() + QPointF(0, 1),
|
|
|
|
|
borderRectF.topRight() + QPointF(0, 1));
|
2015-10-22 13:40:44 +02:00
|
|
|
painter.drawLine(borderRectF.bottomLeft(), borderRectF.bottomRight());
|
|
|
|
|
painter.drawLine(borderRectF.bottomLeft(), borderRectF.bottomRight());
|
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
|
|
|
}
|
2010-02-17 17:09:00 +01:00
|
|
|
painter.restore();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-20 18:11:23 +01:00
|
|
|
const QIcon::Mode iconMode = isEnabled()
|
|
|
|
|
? ((isDown() || isChecked()) ? QIcon::Active : QIcon::Normal)
|
|
|
|
|
: QIcon::Disabled;
|
2017-09-12 18:55:14 +02:00
|
|
|
QRect iconRect(0, 0, Constants::MODEBAR_ICON_SIZE, Constants::MODEBAR_ICON_SIZE);
|
2018-04-26 16:09:16 +02:00
|
|
|
|
2019-10-15 14:08:02 +02:00
|
|
|
const bool isTitledAction = defaultAction() && defaultAction()->property("titledAction").toBool();
|
2010-01-22 18:04:24 +01:00
|
|
|
// draw popup texts
|
2018-04-26 16:09:16 +02:00
|
|
|
if (isTitledAction && !m_iconsOnly) {
|
2010-01-22 18:04:24 +01:00
|
|
|
QFont normalFont(painter.font());
|
2010-03-23 15:47:43 +01:00
|
|
|
QRect centerRect = rect();
|
2015-02-03 23:48:19 +02:00
|
|
|
normalFont.setPointSizeF(StyleHelper::sidebarFontSize());
|
2010-01-22 18:04:24 +01:00
|
|
|
QFont boldFont(normalFont);
|
|
|
|
|
boldFont.setBold(true);
|
2018-02-20 18:11:23 +01:00
|
|
|
const QFontMetrics fm(normalFont);
|
|
|
|
|
const QFontMetrics boldFm(boldFont);
|
|
|
|
|
const int lineHeight = boldFm.height();
|
|
|
|
|
const int textFlags = Qt::AlignVCenter | Qt::AlignHCenter;
|
2010-01-22 18:04:24 +01:00
|
|
|
|
2010-03-12 18:46:25 +01:00
|
|
|
const QString projectName = defaultAction()->property("heading").toString();
|
|
|
|
|
if (!projectName.isNull())
|
2010-03-23 15:47:43 +01:00
|
|
|
centerRect.adjust(0, lineHeight + 4, 0, 0);
|
2010-03-12 18:46:25 +01:00
|
|
|
|
2018-02-20 18:11:23 +01:00
|
|
|
centerRect.adjust(0, 0, 0, -lineHeight * 2 - 4);
|
2010-03-12 18:46:25 +01:00
|
|
|
|
2010-03-23 15:47:43 +01:00
|
|
|
iconRect.moveCenter(centerRect.center());
|
2015-11-11 19:26:58 +01:00
|
|
|
StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, iconMode);
|
2010-01-22 18:04:24 +01:00
|
|
|
painter.setFont(normalFont);
|
|
|
|
|
|
2018-02-20 18:11:23 +01:00
|
|
|
QPoint textOffset = centerRect.center()
|
|
|
|
|
- QPoint(iconRect.width() / 2, iconRect.height() / 2);
|
2017-09-12 18:55:14 +02:00
|
|
|
textOffset = textOffset - QPoint(0, lineHeight + 3);
|
2018-02-20 18:11:23 +01:00
|
|
|
const QRectF r(0, textOffset.y(), rect().width(), lineHeight);
|
|
|
|
|
painter.setPen(creatorTheme()->color(isEnabled() ? Theme::PanelTextColorLight
|
|
|
|
|
: Theme::IconsDisabledColor));
|
2010-03-12 18:46:25 +01:00
|
|
|
|
2011-11-14 17:33:28 +01:00
|
|
|
// draw project name
|
2010-04-14 17:59:31 +02:00
|
|
|
const int margin = 6;
|
2011-11-14 17:33:28 +01:00
|
|
|
const qreal availableWidth = r.width() - margin;
|
2018-02-20 18:11:23 +01:00
|
|
|
const QString ellidedProjectName = fm.elidedText(projectName,
|
|
|
|
|
Qt::ElideMiddle,
|
|
|
|
|
int(availableWidth));
|
2010-01-22 18:04:24 +01:00
|
|
|
painter.drawText(r, textFlags, ellidedProjectName);
|
2011-11-14 17:33:28 +01:00
|
|
|
|
|
|
|
|
// draw build configuration name
|
2018-02-20 18:11:23 +01:00
|
|
|
textOffset = iconRect.center() + QPoint(iconRect.width() / 2, iconRect.height() / 2);
|
2011-11-14 17:33:28 +01:00
|
|
|
QRectF buildConfigRect[2];
|
2017-09-12 18:55:14 +02:00
|
|
|
buildConfigRect[0] = QRectF(0, textOffset.y() + 4, rect().width(), lineHeight);
|
|
|
|
|
buildConfigRect[1] = QRectF(0, textOffset.y() + 4 + lineHeight, rect().width(), lineHeight);
|
2010-01-22 18:04:24 +01:00
|
|
|
painter.setFont(boldFont);
|
2011-11-14 17:33:28 +01:00
|
|
|
QVector<QString> splitBuildConfiguration(2);
|
2012-01-26 13:06:30 +01:00
|
|
|
const QString buildConfiguration = defaultAction()->property("subtitle").toString();
|
2019-02-11 10:32:46 +01:00
|
|
|
if (boldFm.horizontalAdvance(buildConfiguration) <= availableWidth)
|
2011-11-14 17:33:28 +01:00
|
|
|
// text fits in one line
|
|
|
|
|
splitBuildConfiguration[0] = buildConfiguration;
|
2018-02-20 18:11:23 +01:00
|
|
|
else
|
2011-11-14 17:33:28 +01:00
|
|
|
splitBuildConfiguration = splitInTwoLines(buildConfiguration, boldFm, availableWidth);
|
2016-07-06 18:15:44 +02:00
|
|
|
|
|
|
|
|
// draw the two text lines for the build configuration
|
2018-02-20 18:11:23 +01:00
|
|
|
painter.setPen(
|
|
|
|
|
creatorTheme()->color(isEnabled()
|
|
|
|
|
// Intentionally using the "Unselected" colors,
|
|
|
|
|
// because the text color won't change in the pressed
|
|
|
|
|
// state as they would do on the mode buttons.
|
|
|
|
|
? Theme::FancyTabWidgetEnabledUnselectedTextColor
|
|
|
|
|
: Theme::FancyTabWidgetDisabledUnselectedTextColor));
|
2016-07-06 18:15:44 +02:00
|
|
|
|
2011-11-14 17:33:28 +01:00
|
|
|
for (int i = 0; i < 2; ++i) {
|
2018-02-20 18:11:23 +01:00
|
|
|
const QString &buildConfigText = splitBuildConfiguration[i];
|
|
|
|
|
if (buildConfigText.isEmpty())
|
2011-11-14 17:33:28 +01:00
|
|
|
continue;
|
2018-02-20 18:11:23 +01:00
|
|
|
painter.drawText(buildConfigRect[i], textFlags, buildConfigText);
|
2011-11-14 17:33:28 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-12 18:46:25 +01:00
|
|
|
} else {
|
2010-03-23 15:47:43 +01:00
|
|
|
iconRect.moveCenter(rect().center());
|
2015-11-11 19:26:58 +01:00
|
|
|
StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, iconMode);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2018-04-26 16:09:16 +02:00
|
|
|
|
|
|
|
|
// pop up arrow next to icon
|
|
|
|
|
if (isTitledAction && isEnabled() && !icon().isNull()) {
|
|
|
|
|
QStyleOption opt;
|
|
|
|
|
opt.initFrom(this);
|
|
|
|
|
opt.rect = rect().adjusted(rect().width() -
|
|
|
|
|
(m_iconsOnly ? 6 : 16), 0, -(m_iconsOnly ? 0 : 8), 0);
|
|
|
|
|
StyleHelper::drawArrow(QStyle::PE_IndicatorArrowRight, &painter, &opt);
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FancyActionBar::paintEvent(QPaintEvent *event)
|
|
|
|
|
{
|
2010-02-17 17:09:00 +01:00
|
|
|
QPainter painter(this);
|
2016-03-02 18:25:42 +01:00
|
|
|
const QRectF borderRect = QRectF(rect()).adjusted(0.5, 0.5, -0.5, -0.5);
|
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
|
|
|
// this paints the background of the bottom portion of the
|
|
|
|
|
// left tab bar
|
2016-03-21 12:48:06 +01:00
|
|
|
painter.fillRect(event->rect(), StyleHelper::baseColor());
|
2016-03-03 12:28:27 +01:00
|
|
|
painter.setPen(creatorTheme()->color(Theme::FancyToolBarSeparatorColor));
|
2016-03-02 18:25:42 +01:00
|
|
|
painter.drawLine(borderRect.topLeft(), borderRect.topRight());
|
|
|
|
|
} else {
|
|
|
|
|
painter.setPen(StyleHelper::sidebarShadow());
|
|
|
|
|
painter.drawLine(borderRect.topLeft(), borderRect.topRight());
|
|
|
|
|
painter.setPen(StyleHelper::sidebarHighlight());
|
2018-02-20 18:11:23 +01:00
|
|
|
painter.drawLine(borderRect.topLeft() + QPointF(1, 1),
|
|
|
|
|
borderRect.topRight() + QPointF(0, 1));
|
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
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-02-17 17:09:00 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QSize FancyToolButton::sizeHint() const
|
|
|
|
|
{
|
2018-04-26 16:09:16 +02:00
|
|
|
if (m_iconsOnly) {
|
|
|
|
|
return {Core::Constants::MODEBAR_ICONSONLY_BUTTON_SIZE,
|
|
|
|
|
Core::Constants::MODEBAR_ICONSONLY_BUTTON_SIZE};
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-11 18:05:29 +01:00
|
|
|
QSizeF buttonSize = iconSize().expandedTo(QSize(64, 38));
|
2019-10-15 14:08:02 +02:00
|
|
|
if (defaultAction() && defaultAction()->property("titledAction").toBool()) {
|
2010-01-22 18:04:24 +01:00
|
|
|
QFont boldFont(font());
|
2015-02-03 23:48:19 +02:00
|
|
|
boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
|
2010-01-22 18:04:24 +01:00
|
|
|
boldFont.setBold(true);
|
2018-02-20 18:11:23 +01:00
|
|
|
const QFontMetrics fm(boldFont);
|
|
|
|
|
const qreal lineHeight = fm.height();
|
2010-03-12 18:46:25 +01:00
|
|
|
const QString projectName = defaultAction()->property("heading").toString();
|
2010-03-19 18:40:00 +01:00
|
|
|
buttonSize += QSizeF(0, 10);
|
2010-03-12 18:46:25 +01:00
|
|
|
if (!projectName.isEmpty())
|
2010-03-19 18:40:00 +01:00
|
|
|
buttonSize += QSizeF(0, lineHeight + 2);
|
2010-03-12 18:46:25 +01:00
|
|
|
|
2018-02-20 18:11:23 +01:00
|
|
|
buttonSize += QSizeF(0, lineHeight * 2 + 2);
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
2010-01-22 18:04:24 +01:00
|
|
|
return buttonSize.toSize();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-13 18:04:08 +02:00
|
|
|
QSize FancyToolButton::minimumSizeHint() const
|
|
|
|
|
{
|
2018-02-20 18:11:23 +01:00
|
|
|
return {8, 8};
|
2009-07-13 18:04:08 +02:00
|
|
|
}
|
|
|
|
|
|
2018-04-26 16:09:16 +02:00
|
|
|
void FancyToolButton::setIconsOnly(bool iconsOnly)
|
|
|
|
|
{
|
|
|
|
|
m_iconsOnly = iconsOnly;
|
|
|
|
|
updateGeometry();
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-22 13:40:44 +02:00
|
|
|
void FancyToolButton::hoverOverlay(QPainter *painter, const QRect &spanRect)
|
|
|
|
|
{
|
|
|
|
|
const QSize logicalSize = spanRect.size();
|
|
|
|
|
const QString cacheKey = QLatin1String(Q_FUNC_INFO) + QString::number(logicalSize.width())
|
2018-02-20 18:11:23 +01:00
|
|
|
+ QLatin1Char('x') + QString::number(logicalSize.height());
|
2015-10-22 13:40:44 +02:00
|
|
|
QPixmap overlay;
|
|
|
|
|
if (!QPixmapCache::find(cacheKey, &overlay)) {
|
|
|
|
|
const int dpr = painter->device()->devicePixelRatio();
|
|
|
|
|
overlay = QPixmap(logicalSize * dpr);
|
|
|
|
|
overlay.fill(Qt::transparent);
|
|
|
|
|
overlay.setDevicePixelRatio(dpr);
|
|
|
|
|
|
|
|
|
|
const QColor hoverColor = creatorTheme()->color(Theme::FancyToolButtonHoverColor);
|
|
|
|
|
const QRect rect(QPoint(), logicalSize);
|
|
|
|
|
const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5);
|
|
|
|
|
|
|
|
|
|
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
|
|
|
|
grad.setColorAt(0, Qt::transparent);
|
|
|
|
|
grad.setColorAt(0.5, hoverColor);
|
|
|
|
|
grad.setColorAt(1, Qt::transparent);
|
|
|
|
|
|
|
|
|
|
QPainter p(&overlay);
|
|
|
|
|
p.fillRect(rect, grad);
|
|
|
|
|
p.setPen(QPen(grad, 1.0));
|
|
|
|
|
p.drawLine(borderRect.topLeft(), borderRect.topRight());
|
|
|
|
|
p.drawLine(borderRect.bottomLeft(), borderRect.bottomRight());
|
2017-02-06 12:25:15 +01:00
|
|
|
p.end();
|
2015-10-22 13:40:44 +02:00
|
|
|
|
|
|
|
|
QPixmapCache::insert(cacheKey, overlay);
|
|
|
|
|
}
|
|
|
|
|
painter->drawPixmap(spanRect.topLeft(), overlay);
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 15:50:52 +02:00
|
|
|
void FancyToolButton::actionChanged()
|
|
|
|
|
{
|
|
|
|
|
// the default action changed in some way, e.g. it might got hidden
|
|
|
|
|
// since we inherit a tool button we won't get invisible, so do this here
|
2018-02-20 18:11:23 +01:00
|
|
|
if (QAction *action = defaultAction())
|
2013-06-19 12:54:53 +02:00
|
|
|
setVisible(action->isVisible());
|
2009-10-16 15:50:52 +02:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
FancyActionBar::FancyActionBar(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
2018-02-20 18:11:23 +01:00
|
|
|
setObjectName("actionbar");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_actionsLayout = new QVBoxLayout;
|
2019-08-29 10:36:01 +02:00
|
|
|
m_actionsLayout->setContentsMargins(0, 0, 0, 0);
|
2018-04-26 16:09:16 +02:00
|
|
|
m_actionsLayout->setSpacing(0);
|
|
|
|
|
setLayout(m_actionsLayout);
|
|
|
|
|
setContentsMargins(0, 2, 0, 8);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
void FancyActionBar::addProjectSelector(QAction *action)
|
|
|
|
|
{
|
2018-04-26 16:09:16 +02:00
|
|
|
insertAction(0, action);
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
2018-04-26 16:09:16 +02:00
|
|
|
|
2010-01-22 18:04:24 +01:00
|
|
|
void FancyActionBar::insertAction(int index, QAction *action)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2018-04-26 16:09:16 +02:00
|
|
|
auto *button = new FancyToolButton(action, this);
|
2018-12-10 17:10:17 +01:00
|
|
|
if (!action->objectName().isEmpty())
|
|
|
|
|
button->setObjectName(action->objectName() + ".Button"); // used for UI introduction
|
2018-04-26 16:09:16 +02:00
|
|
|
button->setIconsOnly(m_iconsOnly);
|
|
|
|
|
m_actionsLayout->insertWidget(index, button);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-08-20 18:44:02 +02:00
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
QLayout *FancyActionBar::actionsLayout() const
|
|
|
|
|
{
|
|
|
|
|
return m_actionsLayout;
|
|
|
|
|
}
|
2010-03-31 18:51:06 +02:00
|
|
|
|
|
|
|
|
QSize FancyActionBar::minimumSizeHint() const
|
|
|
|
|
{
|
|
|
|
|
return sizeHint();
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-26 16:09:16 +02:00
|
|
|
void FancyActionBar::setIconsOnly(bool iconsOnly)
|
|
|
|
|
{
|
|
|
|
|
m_iconsOnly = iconsOnly;
|
|
|
|
|
for (int i = 0, c = m_actionsLayout->count(); i < c; ++i) {
|
|
|
|
|
if (auto *button = qobject_cast<FancyToolButton*>(m_actionsLayout->itemAt(i)->widget()))
|
|
|
|
|
button->setIconsOnly(iconsOnly);
|
|
|
|
|
}
|
|
|
|
|
setContentsMargins(0, iconsOnly ? 7 : 2, 0, iconsOnly ? 2 : 8);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-11 17:11:15 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Core
|