forked from qt-creator/qt-creator
Add QDSTheme to theming and use it in ManhattanStyle
Change-Id: If3f634cd96665150b27605eaf7a2a5d4ea7078b6 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -513,3 +513,4 @@ FlatMenuBar=true
|
|||||||
ToolBarIconShadow=true
|
ToolBarIconShadow=true
|
||||||
WindowColorAsBase=false
|
WindowColorAsBase=false
|
||||||
DarkUserInterface=true
|
DarkUserInterface=true
|
||||||
|
QDSTheme=true
|
||||||
|
|||||||
@@ -101,6 +101,14 @@ QColor StyleHelper::baseColor(bool lightColored)
|
|||||||
return (lightColored || windowColorAsBase) ? windowColor : m_baseColor;
|
return (lightColored || windowColorAsBase) ? windowColor : m_baseColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor StyleHelper::toolbarBaseColor(bool lightColored)
|
||||||
|
{
|
||||||
|
if (creatorTheme()->flag(Theme::QDSTheme))
|
||||||
|
return creatorTheme()->color(Utils::Theme::DStoolbarBackground);
|
||||||
|
else
|
||||||
|
return StyleHelper::baseColor(lightColored);
|
||||||
|
}
|
||||||
|
|
||||||
QColor StyleHelper::highlightColor(bool lightColored)
|
QColor StyleHelper::highlightColor(bool lightColored)
|
||||||
{
|
{
|
||||||
QColor result = baseColor(lightColored);
|
QColor result = baseColor(lightColored);
|
||||||
@@ -626,6 +634,11 @@ QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect)
|
|||||||
return grad;
|
return grad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StyleHelper::isQDSTheme()
|
||||||
|
{
|
||||||
|
return creatorTheme()->flag(Theme::QDSTheme);
|
||||||
|
}
|
||||||
|
|
||||||
QIcon StyleHelper::getIconFromIconFont(const QString &fontName, const QList<IconFontHelper> ¶meters)
|
QIcon StyleHelper::getIconFromIconFont(const QString &fontName, const QList<IconFontHelper> ¶meters)
|
||||||
{
|
{
|
||||||
QFontDatabase a;
|
QFontDatabase a;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
// This is our color table, all colors derive from baseColor
|
// This is our color table, all colors derive from baseColor
|
||||||
static QColor requestedBaseColor() { return m_requestedBaseColor; }
|
static QColor requestedBaseColor() { return m_requestedBaseColor; }
|
||||||
static QColor baseColor(bool lightColored = false);
|
static QColor baseColor(bool lightColored = false);
|
||||||
|
static QColor toolbarBaseColor(bool lightColored = false);
|
||||||
static QColor panelTextColor(bool lightColored = false);
|
static QColor panelTextColor(bool lightColored = false);
|
||||||
static QColor highlightColor(bool lightColored = false);
|
static QColor highlightColor(bool lightColored = false);
|
||||||
static QColor shadowColor(bool lightColored = false);
|
static QColor shadowColor(bool lightColored = false);
|
||||||
@@ -72,6 +73,8 @@ public:
|
|||||||
static void tintImage(QImage &img, const QColor &tintColor);
|
static void tintImage(QImage &img, const QColor &tintColor);
|
||||||
static QLinearGradient statusBarGradient(const QRect &statusBarRect);
|
static QLinearGradient statusBarGradient(const QRect &statusBarRect);
|
||||||
|
|
||||||
|
static bool isQDSTheme();
|
||||||
|
|
||||||
class IconFontHelper
|
class IconFontHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -448,7 +448,8 @@ public:
|
|||||||
FlatMenuBar,
|
FlatMenuBar,
|
||||||
ToolBarIconShadow,
|
ToolBarIconShadow,
|
||||||
WindowColorAsBase,
|
WindowColorAsBase,
|
||||||
DarkUserInterface
|
DarkUserInterface,
|
||||||
|
QDSTheme
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_ENUM(Color)
|
Q_ENUM(Color)
|
||||||
|
|||||||
@@ -522,9 +522,16 @@ int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
|
|||||||
case PM_ButtonShiftHorizontal:
|
case PM_ButtonShiftHorizontal:
|
||||||
case PM_MenuBarPanelWidth:
|
case PM_MenuBarPanelWidth:
|
||||||
case PM_ToolBarItemMargin:
|
case PM_ToolBarItemMargin:
|
||||||
|
if (StyleHelper::isQDSTheme()) {
|
||||||
|
retval = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
[[fallthrough]];
|
||||||
case PM_ToolBarItemSpacing:
|
case PM_ToolBarItemSpacing:
|
||||||
if (panelWidget(widget))
|
if (panelWidget(widget))
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
if (StyleHelper::isQDSTheme())
|
||||||
|
retval = 4;
|
||||||
break;
|
break;
|
||||||
case PM_DefaultFrameWidth:
|
case PM_DefaultFrameWidth:
|
||||||
if (qobject_cast<const QLineEdit*>(widget) && panelWidget(widget))
|
if (qobject_cast<const QLineEdit*>(widget) && panelWidget(widget))
|
||||||
@@ -1030,7 +1037,7 @@ void ManhattanStyle::drawPrimitiveForPanelWidget(PrimitiveElement element,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PE_IndicatorToolBarSeparator:
|
case PE_IndicatorToolBarSeparator:
|
||||||
{
|
if (!StyleHelper::isQDSTheme()) {
|
||||||
QRect separatorRect = rect;
|
QRect separatorRect = rect;
|
||||||
separatorRect.setLeft(rect.width() / 2);
|
separatorRect.setLeft(rect.width() / 2);
|
||||||
separatorRect.setWidth(1);
|
separatorRect.setWidth(1);
|
||||||
@@ -1147,6 +1154,7 @@ void ManhattanStyle::drawControlForQmlEditor(ControlElement element,
|
|||||||
QPainter *painter,
|
QPainter *painter,
|
||||||
const QWidget *widget) const
|
const QWidget *widget) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(element)
|
||||||
if (const auto mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
if (const auto mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||||
painter->save();
|
painter->save();
|
||||||
const int iconHeight = pixelMetric(QStyle::PM_SmallIconSize, option, widget);
|
const int iconHeight = pixelMetric(QStyle::PM_SmallIconSize, option, widget);
|
||||||
@@ -1518,7 +1526,7 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
|||||||
bool drawLightColored = lightColored(widget);
|
bool drawLightColored = lightColored(widget);
|
||||||
// draws the background of the 'Type hierarchy', 'Projects' headers
|
// draws the background of the 'Type hierarchy', 'Projects' headers
|
||||||
if (creatorTheme()->flag(Theme::FlatToolBars))
|
if (creatorTheme()->flag(Theme::FlatToolBars))
|
||||||
painter->fillRect(rect, StyleHelper::baseColor(drawLightColored));
|
painter->fillRect(rect, StyleHelper::toolbarBaseColor(drawLightColored));
|
||||||
else if (horizontal)
|
else if (horizontal)
|
||||||
StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
|
StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user