From 09a58ddd12b60455a4e3b28fd7e5091176b71892 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 24 Apr 2023 18:24:11 +0200 Subject: [PATCH] Tracing: Follow the active toolbar style This makes sure that the toolbar and toolbuttons in the trace resemble the look of the widget based UI in compact and relaxed toolbar style. This comes with the restriction that an already open tracing scene does only adapt to that change after an IDE restart. Task-number: QTCREATORBUG-29082 Change-Id: I6422227256d8e13658ff5565ae640e15c5e61229 Reviewed-by: hjk --- src/libs/tracing/qml/ImageToolButton.qml | 6 ++++-- src/libs/tracing/qml/MainView.qml | 2 +- src/libs/tracing/qml/RangeDetails.qml | 2 +- src/libs/tracing/qml/TimeDisplay.qml | 2 +- src/libs/tracing/timelinetheme.cpp | 13 ++++++++++++- src/libs/tracing/timelinetheme.h | 2 ++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/libs/tracing/qml/ImageToolButton.qml b/src/libs/tracing/qml/ImageToolButton.qml index 2d0231494bc..45ca12b8997 100644 --- a/src/libs/tracing/qml/ImageToolButton.qml +++ b/src/libs/tracing/qml/ImageToolButton.qml @@ -22,10 +22,12 @@ ToolButton { smooth: false } - background: Rectangle { + background: PaddedRectangle { + padding: Theme.compactToolbar() ? 0 : 3 + radius: Theme.compactToolbar() ? 0 : 5 color: (parent.checked || parent.pressed) ? Theme.color(Theme.FancyToolButtonSelectedColor) - : parent.hovered + : (parent.hovered && parent.enabled) ? Theme.color(Theme.FancyToolButtonHoverColor) : "#00000000" } diff --git a/src/libs/tracing/qml/MainView.qml b/src/libs/tracing/qml/MainView.qml index 5aa4e835a37..052ec4aa762 100644 --- a/src/libs/tracing/qml/MainView.qml +++ b/src/libs/tracing/qml/MainView.qml @@ -156,7 +156,7 @@ Rectangle { anchors.top: parent.top anchors.left: parent.left width: 150 - height: 24 + height: Theme.toolBarHeight() onZoomControlChanged: zoomSliderToolBar.visible = !zoomSliderToolBar.visible onJumpToNext: { var next = timelineModelAggregator.nextItem(root.selectedModel, root.selectedItem, diff --git a/src/libs/tracing/qml/RangeDetails.qml b/src/libs/tracing/qml/RangeDetails.qml index 8c0e64f25c2..9ce3e996d94 100644 --- a/src/libs/tracing/qml/RangeDetails.qml +++ b/src/libs/tracing/qml/RangeDetails.qml @@ -9,7 +9,7 @@ import QtCreator.Tracing Item { id: rangeDetails - property real titleBarHeight: 20 + property real titleBarHeight: Theme.toolBarHeight() / 1.2 property real borderWidth: 1 property real outerMargin: 10 property real innerMargin: 5 diff --git a/src/libs/tracing/qml/TimeDisplay.qml b/src/libs/tracing/qml/TimeDisplay.qml index ffcbea2e841..64cb0474cfd 100644 --- a/src/libs/tracing/qml/TimeDisplay.qml +++ b/src/libs/tracing/qml/TimeDisplay.qml @@ -11,7 +11,7 @@ Item { property double rangeDuration property int textMargin: 5 - property int labelsHeight: 24 + property int labelsHeight: Theme.toolBarHeight() property int fontSize: 8 property int initialBlockLength: 120 property double spacing: width / rangeDuration diff --git a/src/libs/tracing/timelinetheme.cpp b/src/libs/tracing/timelinetheme.cpp index df02cb63961..41c0c44b4ff 100644 --- a/src/libs/tracing/timelinetheme.cpp +++ b/src/libs/tracing/timelinetheme.cpp @@ -5,8 +5,9 @@ #include #include -#include +#include #include +#include #include #include @@ -92,4 +93,14 @@ void TimelineTheme::setupTheme(QQmlEngine *engine) engine->addImageProvider(QLatin1String("icons"), new TimelineImageIconProvider); } +bool TimelineTheme::compactToolbar() const +{ + return StyleHelper::toolbarStyle() == StyleHelper::ToolbarStyleCompact; +} + +int TimelineTheme::toolBarHeight() const +{ + return StyleHelper::navigationWidgetHeight(); +} + } // namespace Timeline diff --git a/src/libs/tracing/timelinetheme.h b/src/libs/tracing/timelinetheme.h index ebca62447dd..f15eccbdaf1 100644 --- a/src/libs/tracing/timelinetheme.h +++ b/src/libs/tracing/timelinetheme.h @@ -22,6 +22,8 @@ public: explicit TimelineTheme(QObject *parent = nullptr); static void setupTheme(QQmlEngine* engine); + Q_INVOKABLE bool compactToolbar() const; + Q_INVOKABLE int toolBarHeight() const; }; } // namespace Timeline