diff options
Diffstat (limited to 'src/libs/utils/stylehelper.cpp')
-rw-r--r-- | src/libs/utils/stylehelper.cpp | 83 |
1 files changed, 78 insertions, 5 deletions
diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 9f849b9a61..cc860e715a 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -12,6 +12,7 @@ #include <QFileInfo> #include <QFontDatabase> #include <QPainter> +#include <QPainterPath> #include <QPixmapCache> #include <QStyleOption> #include <QWindow> @@ -36,6 +37,11 @@ static int range(float x, int min, int max) namespace Utils { +static StyleHelper::ToolbarStyle m_toolbarStyle = StyleHelper::defaultToolbarStyle; +// Invalid by default, setBaseColor needs to be called at least once +static QColor m_baseColor; +static QColor m_requestedBaseColor; + QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int factor) { const int maxFactor = 100; @@ -58,6 +64,36 @@ QColor StyleHelper::alphaBlendedColors(const QColor &colorA, const QColor &color ); } +QColor StyleHelper::sidebarHighlight() +{ + return QColor(255, 255, 255, 40); +} + +QColor StyleHelper::sidebarShadow() +{ + return QColor(0, 0, 0, 40); +} + +QColor StyleHelper::toolBarDropShadowColor() +{ + return QColor(0, 0, 0, 70); +} + +int StyleHelper::navigationWidgetHeight() +{ + return m_toolbarStyle == ToolbarStyleCompact ? 24 : 30; +} + +void StyleHelper::setToolbarStyle(ToolbarStyle style) +{ + m_toolbarStyle = style; +} + +StyleHelper::ToolbarStyle StyleHelper::toolbarStyle() +{ + return m_toolbarStyle; +} + qreal StyleHelper::sidebarFontSize() { return HostOsInfo::isMacHost() ? 10 : 7.5; @@ -89,10 +125,6 @@ QColor StyleHelper::panelTextColor(bool lightColored) return Qt::black; } -// Invalid by default, setBaseColor needs to be called at least once -QColor StyleHelper::m_baseColor; -QColor StyleHelper::m_requestedBaseColor; - QColor StyleHelper::baseColor(bool lightColored) { static const QColor windowColor = QApplication::palette().color(QPalette::Window); @@ -101,6 +133,11 @@ QColor StyleHelper::baseColor(bool lightColored) return (lightColored || windowColorAsBase) ? windowColor : m_baseColor; } +QColor StyleHelper::requestedBaseColor() +{ + return m_requestedBaseColor; +} + QColor StyleHelper::toolbarBaseColor(bool lightColored) { if (creatorTheme()->flag(Theme::QDSTheme)) @@ -149,6 +186,11 @@ QColor StyleHelper::toolBarBorderColor() clamp(base.value() * 0.80f)); } +QColor StyleHelper::buttonTextColor() +{ + return QColor(0x4c4c4c); +} + // We try to ensure that the actual color used are within // reasonalbe bounds while generating the actual baseColor // from the users request. @@ -173,7 +215,7 @@ void StyleHelper::setBaseColor(const QColor &newcolor) if (color.isValid() && color != m_baseColor) { m_baseColor = color; - const QList<QWidget *> widgets = QApplication::topLevelWidgets(); + const QWidgetList widgets = QApplication::allWidgets(); for (QWidget *w : widgets) w->update(); } @@ -439,6 +481,22 @@ void StyleHelper::drawMinimalArrow(QStyle::PrimitiveElement element, QPainter *p painter->drawPixmap(xOffset, yOffset, pixmap); } +void StyleHelper::drawPanelBgRect(QPainter *painter, const QRectF &rect, const QBrush &brush) +{ + if (toolbarStyle() == ToolbarStyleCompact) { + painter->fillRect(rect.toRect(), brush); + } else { + constexpr int margin = 2; + constexpr int radius = 5; + QPainterPath path; + path.addRoundedRect(rect.adjusted(margin, margin, -margin, -margin), radius, radius); + painter->save(); + painter->setRenderHint(QPainter::Antialiasing); + painter->fillPath(path, brush); + painter->restore(); + } +} + void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect) { if (StyleHelper::usePixmapCache()) { @@ -462,6 +520,11 @@ void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const Q } } +bool StyleHelper::usePixmapCache() +{ + return true; +} + QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon) { QImage im = enabledicon.toImage().convertToFormat(QImage::Format_ARGB32); @@ -634,6 +697,16 @@ QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect) return grad; } +void StyleHelper::setPanelWidget(QWidget *widget, bool value) +{ + widget->setProperty(C_PANEL_WIDGET, value); +} + +void StyleHelper::setPanelWidgetSingleRow(QWidget *widget, bool value) +{ + widget->setProperty(C_PANEL_WIDGET_SINGLE_ROW, value); +} + bool StyleHelper::isQDSTheme() { return creatorTheme() ? creatorTheme()->flag(Theme::QDSTheme) : false; |