summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-07-22 08:25:32 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-07-24 05:42:34 +0200
commit92454bca2045b9e9ca636d086cb8520ccf03be22 (patch)
tree9b9a20073d9593b22680d5014828fd5b8a4c5895 /vcl/qt5
parent57f46e0244bdc1165ebbc5e09e4069cc075ff7ae (diff)
tdf#161501 vcl: Make TabitemValue position-aware
Add a new `TabBarPosition` enum that describes whether a tab bar is at the top, left, right, or bottom (relative to the tab page content) and make use of that for the new `meTabBarPosition` member for `TabitemValue` that gets used for drawing tab items via the native rendering API. Set the position accordingly for both the vertical tab control (`TabControl`) and `SvxIconChoiceCtrl_Impl`, which implements the tab bar for `VerticalTabControl`. For Qt-based VCL plugins, implement mapping to the corresponding `QTabBar::Shape`. [1] At least the Breeze Qt style uses that shape to decide whether on what side of the tab item to draw the selection/focus indicator. This change by itself doesn't yet make any visual difference for the Breeze style, as the "Top" value/ `QTabBar::RoundedNorth` is the default anyway, and `SvxIconChoiceCtrl_Impl` doesn't yet use the native drawing API for drawing focus/selection, but only for mousehover feedback. The plan is to implement that in a follow-up change. [1] https://doc.qt.io/qt-6/qtabbar.html#Shape-enum Change-Id: Idf1e41d3bc309d152a4a36d14e8617bd6429940c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170841 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/QtGraphics_Controls.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx
index b24b46b28a8d..9dd0b3a4f61e 100644
--- a/vcl/qt5/QtGraphics_Controls.cxx
+++ b/vcl/qt5/QtGraphics_Controls.cxx
@@ -223,6 +223,24 @@ void QtGraphics_Controls::drawFrame(QStyle::PrimitiveElement element, QImage* im
QApplication::style()->drawPrimitive(element, &option, &painter);
}
+static QTabBar::Shape lcl_mapTabBarPosition(TabBarPosition eTabPos)
+{
+ switch (eTabPos)
+ {
+ case TabBarPosition::Bottom:
+ return QTabBar::RoundedSouth;
+ case TabBarPosition::Left:
+ return QTabBar::RoundedWest;
+ case TabBarPosition::Right:
+ return QTabBar::RoundedEast;
+ case TabBarPosition::Top:
+ return QTabBar::RoundedNorth;
+ default:
+ assert(false && "Unhandled tab bar position");
+ return QTabBar::RoundedNorth;
+ }
+}
+
void QtGraphics_Controls::fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot)
{
const TabitemValue& rValue = static_cast<const TabitemValue&>(value);
@@ -232,6 +250,8 @@ void QtGraphics_Controls::fillQStyleOptionTab(const ImplControlValue& value, QSt
sot.position = rValue.isFirst() ? QStyleOptionTab::OnlyOneTab : QStyleOptionTab::End;
else
sot.position = QStyleOptionTab::Middle;
+
+ sot.shape = lcl_mapTabBarPosition(rValue.meTabBarPosition);
}
void QtGraphics_Controls::fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option,