From 495f5f006f3fe14c7b472ee6a29925c0aa4c640c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 14 Apr 2023 15:43:31 +0200 Subject: [PATCH] Utils: Add toolbarStyle to StyleHelper Task-number: QTCREATORBUG-29054 Change-Id: I01572eb7bdd267ea6aadb9530afc52b3c7834382 Reviewed-by: hjk --- src/libs/utils/stylehelper.cpp | 16 ++++++++++++++++ src/libs/utils/stylehelper.h | 11 ++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index f27fb2f8fcb..690c04b9df0 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -58,6 +58,21 @@ QColor StyleHelper::alphaBlendedColors(const QColor &colorA, const QColor &color ); } +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,6 +104,7 @@ QColor StyleHelper::panelTextColor(bool lightColored) return Qt::black; } +StyleHelper::ToolbarStyle StyleHelper::m_toolbarStyle = StyleHelper::defaultToolbarStyle; // Invalid by default, setBaseColor needs to be called at least once QColor StyleHelper::m_baseColor; QColor StyleHelper::m_requestedBaseColor; diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h index c7766b0ffeb..11fa8a03890 100644 --- a/src/libs/utils/stylehelper.h +++ b/src/libs/utils/stylehelper.h @@ -25,8 +25,16 @@ public: static const unsigned int DEFAULT_BASE_COLOR = 0x666666; static const int progressFadeAnimationDuration = 600; + enum ToolbarStyle { + ToolbarStyleCompact, + ToolbarStyleRelaxed, + }; + // Height of the project explorer navigation bar - static int navigationWidgetHeight() { return 24; } + static int navigationWidgetHeight(); + static void setToolbarStyle(ToolbarStyle style); + static ToolbarStyle toolbarStyle(); + static constexpr ToolbarStyle defaultToolbarStyle = ToolbarStyleCompact; static qreal sidebarFontSize(); static QPalette sidebarFontPalette(const QPalette &original); @@ -122,6 +130,7 @@ public: static QColor ensureReadableOn(const QColor &background, const QColor &desiredForeground); private: + static ToolbarStyle m_toolbarStyle; static QColor m_baseColor; static QColor m_requestedBaseColor; };