aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2025-12-02 10:23:43 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2025-12-03 19:56:09 +0100
commitd3afd08372b79653048e41f0cba2550f7d5946b5 (patch)
treecc0606a691ad09191c989e663384d1ddd5ad42b6 /src
parent6c066dc350b5eef8992a8089eec9b1096f51519d (diff)
StyleKit: implement ToolBar and ToolButton
This patch will implement support for styling ToolBar and ToolButton. Change-Id: Ie8cbda5a1ee361e8f2ee1a78ec5634e52811e0cd Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/labs/stylekit/CMakeLists.txt2
-rw-r--r--src/labs/stylekit/ToolBar.qml38
-rw-r--r--src/labs/stylekit/ToolButton.qml57
-rw-r--r--src/labs/stylekit/impl/FallbackStyle.qml3
-rw-r--r--src/labs/stylekit/qqstylekitcontrols.cpp2
-rw-r--r--src/labs/stylekit/qqstylekitcontrols_p.h6
-rw-r--r--src/labs/stylekit/qqstylekitpropertyresolver.cpp4
-rw-r--r--src/labs/stylekit/qqstylekitreader_p.h2
-rw-r--r--src/labs/stylekit/qqstylekitstyle.cpp3
9 files changed, 116 insertions, 1 deletions
diff --git a/src/labs/stylekit/CMakeLists.txt b/src/labs/stylekit/CMakeLists.txt
index ed23c75934..1bd7841de0 100644
--- a/src/labs/stylekit/CMakeLists.txt
+++ b/src/labs/stylekit/CMakeLists.txt
@@ -47,6 +47,8 @@ qt_internal_add_qml_module(QtQuickStyleKit
SpinBox.qml
Switch.qml
TextField.qml
+ ToolBar.qml
+ ToolButton.qml
Page.qml
Pane.qml
Popup.qml
diff --git a/src/labs/stylekit/ToolBar.qml b/src/labs/stylekit/ToolBar.qml
new file mode 100644
index 0000000000..cbe34097c5
--- /dev/null
+++ b/src/labs/stylekit/ToolBar.qml
@@ -0,0 +1,38 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:default
+
+import QtQuick
+import QtQuick.Controls.impl
+import QtQuick.Templates as T
+import Qt.labs.StyleKit
+import Qt.labs.StyleKit.impl
+
+T.ToolBar {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+
+ leftPadding: SafeArea.margins.left + styleReader.leftPadding
+ rightPadding: SafeArea.margins.right + styleReader.rightPadding
+ topPadding: SafeArea.margins.top + styleReader.topPadding
+ bottomPadding: SafeArea.margins.bottom + styleReader.bottomPadding
+
+ StyleKitControl.controlType: styleReader.type
+ StyleKitReader {
+ id: styleReader
+ type: StyleKitReader.ToolBar
+ enabled: control.enabled
+ focused: control.activeFocus
+ palette: control.palette
+ hovered: control.hovered
+ }
+
+ background: BackgroundDelegate {
+ parentControl: control
+ backgroundProperties: styleReader.background
+ }
+}
diff --git a/src/labs/stylekit/ToolButton.qml b/src/labs/stylekit/ToolButton.qml
new file mode 100644
index 0000000000..b06fe71cdd
--- /dev/null
+++ b/src/labs/stylekit/ToolButton.qml
@@ -0,0 +1,57 @@
+// Copyright (C) 2025 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// Qt-Security score:significant reason:default
+
+import QtQuick
+import QtQuick.Controls.impl
+import QtQuick.Templates as T
+import Qt.labs.StyleKit
+import Qt.labs.StyleKit.impl
+
+T.ToolButton {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+
+ leftPadding: styleReader.leftPadding
+ topPadding: styleReader.topPadding
+ rightPadding: styleReader.rightPadding
+ bottomPadding: styleReader.bottomPadding
+ spacing: styleReader.spacing
+
+ icon.width: 24
+ icon.height: 24
+ icon.color: styleReader.text.color
+
+ StyleKitControl.controlType: styleReader.type
+ StyleKitReader {
+ id: styleReader
+ type: StyleKitReader.ToolButton
+ enabled: control.enabled
+ focused: control.activeFocus
+ checked: control.checked
+ hovered: control.hovered || control.pressed
+ pressed: control.pressed
+ palette: control.palette
+ }
+
+ contentItem: IconLabel {
+ spacing: control.spacing
+ mirrored: control.mirrored
+ display: control.display
+
+ icon: control.icon
+ text: control.text
+ font: styleReader.font // FIXME: should be inherited from control
+ color: styleReader.text.color
+ alignment: styleReader.text.alignment
+ }
+
+ background: BackgroundDelegate {
+ parentControl: control
+ backgroundProperties: styleReader.background
+ }
+}
diff --git a/src/labs/stylekit/impl/FallbackStyle.qml b/src/labs/stylekit/impl/FallbackStyle.qml
index d989fcc63a..f9f7199b18 100644
--- a/src/labs/stylekit/impl/FallbackStyle.qml
+++ b/src/labs/stylekit/impl/FallbackStyle.qml
@@ -223,4 +223,7 @@ BaseStyle {
checked.indicator.foreground.color: style.palette.accent
}
+ toolBar {
+ background.implicitHeight: 40
+ }
}
diff --git a/src/labs/stylekit/qqstylekitcontrols.cpp b/src/labs/stylekit/qqstylekitcontrols.cpp
index 21c8e48a2f..c7a0d0e015 100644
--- a/src/labs/stylekit/qqstylekitcontrols.cpp
+++ b/src/labs/stylekit/qqstylekitcontrols.cpp
@@ -75,6 +75,8 @@ IMPLEMENT_ACCESSORS(spinBox, QQStyleKitReader::ControlType::SpinBox)
IMPLEMENT_ACCESSORS(switchControl, QQStyleKitReader::ControlType::SwitchControl)
IMPLEMENT_ACCESSORS(textField, QQStyleKitReader::ControlType::TextField)
IMPLEMENT_ACCESSORS(textInput, QQStyleKitReader::ControlType::TextInput)
+IMPLEMENT_ACCESSORS(toolBar, QQStyleKitReader::ControlType::ToolBar)
+IMPLEMENT_ACCESSORS(toolButton, QQStyleKitReader::ControlType::ToolButton)
IMPLEMENT_ACCESSORS(radioButton, QQStyleKitReader::ControlType::RadioButton)
IMPLEMENT_ACCESSORS(itemDelegate, QQStyleKitReader::ControlType::ItemDelegate)
IMPLEMENT_ACCESSORS(popup, QQStyleKitReader::ControlType::Popup)
diff --git a/src/labs/stylekit/qqstylekitcontrols_p.h b/src/labs/stylekit/qqstylekitcontrols_p.h
index e3abafa052..d9b2638adb 100644
--- a/src/labs/stylekit/qqstylekitcontrols_p.h
+++ b/src/labs/stylekit/qqstylekitcontrols_p.h
@@ -41,6 +41,8 @@ class QQStyleKitControls : public QObject, public QQmlParserStatus
Q_PROPERTY(QQStyleKitControl *spinBox READ spinBox WRITE set_spinBox NOTIFY spinBoxChanged FINAL)
Q_PROPERTY(QQStyleKitControl *textField READ textField WRITE set_textField NOTIFY textFieldChanged FINAL)
Q_PROPERTY(QQStyleKitControl *textInput READ textInput WRITE set_textInput NOTIFY textInputChanged FINAL)
+ Q_PROPERTY(QQStyleKitControl *toolBar READ toolBar WRITE set_toolBar NOTIFY toolBarChanged FINAL)
+ Q_PROPERTY(QQStyleKitControl *toolButton READ toolButton WRITE set_toolButton NOTIFY toolButtonChanged FINAL)
Q_PROPERTY(QQStyleKitControl *switchControl READ switchControl WRITE set_switchControl NOTIFY switchControlChanged FINAL)
Q_PROPERTY(QQStyleKitControl *radioButton READ radioButton WRITE set_radioButton NOTIFY radioButtonChanged FINAL)
Q_PROPERTY(QQStyleKitControl *itemDelegate READ itemDelegate WRITE set_itemDelegate NOTIFY itemDelegateChanged FINAL)
@@ -71,6 +73,8 @@ public:
IMPLEMENT_ACCESSORS(spinBox)
IMPLEMENT_ACCESSORS(textField)
IMPLEMENT_ACCESSORS(textInput)
+ IMPLEMENT_ACCESSORS(toolBar)
+ IMPLEMENT_ACCESSORS(toolButton)
IMPLEMENT_ACCESSORS(switchControl)
IMPLEMENT_ACCESSORS(radioButton)
IMPLEMENT_ACCESSORS(itemDelegate)
@@ -100,6 +104,8 @@ signals:
void spinBoxChanged();
void textFieldChanged();
void textInputChanged();
+ void toolBarChanged();
+ void toolButtonChanged();
void switchControlChanged();
void radioButtonChanged();
void itemDelegateChanged();
diff --git a/src/labs/stylekit/qqstylekitpropertyresolver.cpp b/src/labs/stylekit/qqstylekitpropertyresolver.cpp
index 3bd7533368..b995c5496a 100644
--- a/src/labs/stylekit/qqstylekitpropertyresolver.cpp
+++ b/src/labs/stylekit/qqstylekitpropertyresolver.cpp
@@ -104,6 +104,7 @@ const QList<QQStyleKitExtendedControlType> QQStyleKitPropertyResolver::baseTypes
* is in any case styled quite differently than a button. */
switch (exactType) {
case QQStyleKitReader::Button:
+ case QQStyleKitReader::ToolButton:
case QQStyleKitReader::RadioButton:
case QQStyleKitReader::CheckBox:
case QQStyleKitReader::SwitchControl: {
@@ -116,7 +117,8 @@ const QList<QQStyleKitExtendedControlType> QQStyleKitPropertyResolver::baseTypes
{ QQStyleKitReader::Popup, QQStyleKitReader::Control };
return t; }
case QQStyleKitReader::Page:
- case QQStyleKitReader::Frame: {
+ case QQStyleKitReader::Frame:
+ case QQStyleKitReader::ToolBar: {
static QList<QQStyleKitExtendedControlType> t =
{ QQStyleKitReader::Pane, QQStyleKitReader::Control };
return t; }
diff --git a/src/labs/stylekit/qqstylekitreader_p.h b/src/labs/stylekit/qqstylekitreader_p.h
index 33257141a9..be9f195bd2 100644
--- a/src/labs/stylekit/qqstylekitreader_p.h
+++ b/src/labs/stylekit/qqstylekitreader_p.h
@@ -63,6 +63,8 @@ public:
TextArea,
TextField,
TextInput,
+ ToolBar,
+ ToolButton,
RadioButton,
ItemDelegate,
Popup,
diff --git a/src/labs/stylekit/qqstylekitstyle.cpp b/src/labs/stylekit/qqstylekitstyle.cpp
index e15fa8674d..78143b8994 100644
--- a/src/labs/stylekit/qqstylekitstyle.cpp
+++ b/src/labs/stylekit/qqstylekitstyle.cpp
@@ -284,6 +284,9 @@ QFont QQStyleKitStyle::fontForReader(QQStyleKitReader *reader) const
return m_theme->fonts()->textFieldFont();
case QQStyleKitReader::ControlType::TextArea:
return m_theme->fonts()->textAreaFont();
+ case QQStyleKitReader::ControlType::ToolBar:
+ case QQStyleKitReader::ControlType::ToolButton:
+ return m_theme->fonts()->toolBarFont();
case QQStyleKitReader::ControlType::ItemDelegate:
return m_theme->fonts()->itemViewFont();
default: