aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Portale <[email protected]>2025-07-01 16:17:04 +0200
committerAlessandro Portale <[email protected]>2025-07-01 14:20:20 +0000
commit4d9d215070c1a5e669c570503a3748de9b28b451 (patch)
tree1ec5a9af46b2a53077e4a87ad5a55bed45a2bd2d
parent05bae4aca15a24ed46acf7928a18f0af953c69ec (diff)
Utils: Centralize the value for highlight thicknessHEADmaster
Instad of a magic "2". The same thickness is so far used in the Modebar, the editor manager and in QtcTabBar. Change-Id: I0f14418d6568f9b6e2df2a4d7f0ed7f9ebed1fb1 Reviewed-by: Cristian Adam <[email protected]>
-rw-r--r--src/libs/utils/qtcwidgets.cpp2
-rw-r--r--src/libs/utils/stylehelper.h4
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp4
-rw-r--r--src/plugins/coreplugin/fancytabwidget.cpp2
4 files changed, 8 insertions, 4 deletions
diff --git a/src/libs/utils/qtcwidgets.cpp b/src/libs/utils/qtcwidgets.cpp
index eb644c7426d..0c388c5a364 100644
--- a/src/libs/utils/qtcwidgets.cpp
+++ b/src/libs/utils/qtcwidgets.cpp
@@ -852,7 +852,7 @@ void QtcTabBar::paintEvent([[maybe_unused]] QPaintEvent *event)
const bool hovered = !selected && opt.rect.contains(mapFromGlobal(QCursor::pos()));
if (selected || (hovered && enabled)) {
QRect highLightRect = opt.rect;
- highLightRect.moveTop(highLightRect.height() - 2); // Size of active mode highlight
+ highLightRect.moveTop(highLightRect.height() - StyleHelper::HighlightThickness);
const QColor color = creatorColor(enabled ? hovered ? Theme::Token_Text_Subtle
: Theme::Token_Accent_Default
: Theme::Token_Foreground_Subtle);
diff --git a/src/libs/utils/stylehelper.h b/src/libs/utils/stylehelper.h
index d76ad0ed337..75a1dea3f7e 100644
--- a/src/libs/utils/stylehelper.h
+++ b/src/libs/utils/stylehelper.h
@@ -87,7 +87,9 @@ namespace SpacingTokens {
constexpr int GapHL = PrimitiveL;
constexpr int GapHXl = PrimitiveXl;
constexpr int GapHXxl = PrimitiveXxl;
-}
+};
+
+constexpr int HighlightThickness = SpacingTokens::PrimitiveXxs;
enum class ToolbarStyle {
Compact,
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index f38e944ae0b..a1448352ae6 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -20,6 +20,7 @@
#include <utils/link.h>
#include <utils/overlaywidget.h>
#include <utils/qtcassert.h>
+#include <utils/stylehelper.h>
#include <utils/theme/theme.h>
#include <utils/utilsicons.h>
@@ -225,7 +226,8 @@ EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent)
currentViewOverlay->setAttribute(Qt::WA_OpaquePaintEvent);
currentViewOverlay->setResizeFunction([this](QWidget *w, const QSize &) {
const QRect toolbarRect = m_toolBar->geometry();
- w->setGeometry(toolbarRect.x(), toolbarRect.bottom() - 1, toolbarRect.width(), 2);
+ w->setGeometry(toolbarRect.x(), toolbarRect.bottom() - 1, toolbarRect.width(),
+ StyleHelper::HighlightThickness);
});
currentViewOverlay->setPaintFunction([](QWidget *w, QPainter &p, QPaintEvent *) {
QColor viewHighlight = w->palette().color(QPalette::Highlight);
diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp
index f0be9420690..6caa0c40eba 100644
--- a/src/plugins/coreplugin/fancytabwidget.cpp
+++ b/src/plugins/coreplugin/fancytabwidget.cpp
@@ -290,7 +290,7 @@ static void paintSelectedTabBackground(QPainter *painter, const QRect &spanRect)
static void paintHighlight(QPainter *painter, const QRect &rect)
{
QRect accentRect = rect;
- accentRect.setWidth(2);
+ accentRect.setWidth(StyleHelper::HighlightThickness);
painter->fillRect(accentRect, creatorColor(Theme::FancyToolButtonHighlightColor));
}