diff --git a/sandbox/main.qml b/sandbox/main.qml index 209055a5..fd7e8415 100644 --- a/sandbox/main.qml +++ b/sandbox/main.qml @@ -183,6 +183,11 @@ StatusWindow { selected: viewLoader.source.toString().includes(title) onClicked: mainPageView.control(title); } + StatusNavigationListItem { + title: "StatusTabBarButton" + selected: viewLoader.source.toString().includes(title) + onClicked: mainPageView.page(title); + } StatusNavigationListItem { title: "StatusTabBarIconButton" selected: viewLoader.source.toString().includes(title) diff --git a/sandbox/pages/StatusTabBarButtonPage.qml b/sandbox/pages/StatusTabBarButtonPage.qml new file mode 100644 index 00000000..08b72729 --- /dev/null +++ b/sandbox/pages/StatusTabBarButtonPage.qml @@ -0,0 +1,27 @@ +import QtQuick 2.14 + +import StatusQ.Core 0.1 +import StatusQ.Core.Theme 0.1 +import StatusQ.Controls 0.1 + +import Sandbox 0.1 + +Column { + spacing: 8 + + StatusTabBar { + StatusTabButton { + width: implicitWidth + text: "Button 1" + } + StatusTabButton { + width: implicitWidth + text: "Button 2" + } + StatusTabButton { + width: implicitWidth + text: "Button 3" + badge.value: 42 + } + } +} diff --git a/sandbox/qml.qrc b/sandbox/qml.qrc index c2cd1feb..502c28a2 100644 --- a/sandbox/qml.qrc +++ b/sandbox/qml.qrc @@ -42,5 +42,6 @@ pages/StatusTagSelectorPage.qml pages/StatusToastMessagePage.qml pages/StatusWizardStepperPage.qml + pages/StatusTabBarButtonPage.qml diff --git a/src/StatusQ/Controls/StatusTabBar.qml b/src/StatusQ/Controls/StatusTabBar.qml new file mode 100644 index 00000000..abbab111 --- /dev/null +++ b/src/StatusQ/Controls/StatusTabBar.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.13 + +/*! + \qmltype StatusTabButton + \inherits TabButton + \inqmlmodule StatusQ.Controls + \since StatusQ.Controls 0.1 + \brief StatusTabBar provides a tab-based navigation model + + It's customized from Qt's \l{https://doc.qt.io/qt-6/qml-qtquick-controls2-tabbar.html}{TabBar}, + adding a transparent background. +*/ + + +TabBar { + background: Item { } +} diff --git a/src/StatusQ/Controls/StatusTabButton.qml b/src/StatusQ/Controls/StatusTabButton.qml new file mode 100644 index 00000000..56360733 --- /dev/null +++ b/src/StatusQ/Controls/StatusTabButton.qml @@ -0,0 +1,76 @@ +import QtQuick 2.13 +import QtQuick.Controls 2.13 +import QtQuick.Layouts 1.13 + +import StatusQ.Core 0.1 +import StatusQ.Core.Theme 0.1 +import StatusQ.Components 0.1 + +/*! + \qmltype StatusTabButton + \inherits TabButton + \inqmlmodule StatusQ.Controls + \since StatusQ.Controls 0.1 + \brief StatusTabButton is used in conjunction with a StatusTabBar + + It's customized from Qt's \l{https://doc.qt.io/qt-6/qml-qtquick-controls2-tabbutton.html}{TabButton}, adding: + - transparent background + - theme-styled text + - styled underscore for active state + - `StatusBadge` to the right from the text + + An alias `badge` property is added to control the `StatusBadge` behaviour and content. +*/ + +TabButton { + id: root + + property alias badge: statusBadge + + leftPadding: 12 + rightPadding: 12 + + background: Item { } + + contentItem: Item { + implicitWidth: contentItemGrid.implicitWidth + implicitHeight: contentItemGrid.implicitHeight + 11 + + RowLayout { + id: contentItemGrid + + anchors { + top: parent.top + left: parent.left + right: parent.right + } + + spacing: 0 + + StatusBaseText { + Layout.fillWidth: true + elide: Qt.ElideRight + font.weight: Font.Medium + font.pixelSize: 15 + color: root.checked || root.hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1 + text: root.text + } + + StatusBadge { + id: statusBadge + Layout.leftMargin: 10 + visible: value > 0 + } + } + + Rectangle { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + visible: root.checked || root.hovered + implicitWidth: 24 + implicitHeight: 2 + radius: 4 + color: root.checked ? Theme.palette.primaryColor1 : Theme.palette.primaryColor2 + } + } +} diff --git a/src/StatusQ/Controls/qmldir b/src/StatusQ/Controls/qmldir index 41e60d27..958d3d07 100644 --- a/src/StatusQ/Controls/qmldir +++ b/src/StatusQ/Controls/qmldir @@ -32,6 +32,8 @@ StatusPasswordStrengthIndicator 0.1 StatusPasswordStrengthIndicator.qml StatusSwitchTabButton 0.1 StatusSwitchTabButton.qml StatusSwitchTabBar 0.1 StatusSwitchTabBar.qml StatusSelectableText 0.1 StatusSelectableText.qml +StatusTabBar 0.1 StatusTabBar.qml +StatusTabButton 0.1 StatusTabButton.qml StatusTokenInlineSelector 0.1 StatusTokenInlineSelector.qml StatusWalletColorButton 0.1 StatusWalletColorButton.qml StatusWalletColorSelect 0.1 StatusWalletColorSelect.qml diff --git a/statusq.qrc b/statusq.qrc index ba44702c..1dd850bf 100644 --- a/statusq.qrc +++ b/statusq.qrc @@ -79,6 +79,7 @@ src/StatusQ/Controls/StatusSwitchTabBar.qml src/StatusQ/Controls/StatusSwitchTabButton.qml src/StatusQ/Controls/StatusTabBarIconButton.qml + src/StatusQ/Controls/StatusTabButton.qml src/StatusQ/Controls/StatusTokenInlineSelector.qml src/StatusQ/Controls/StatusToolTip.qml src/StatusQ/Controls/StatusWalletColorButton.qml @@ -10496,5 +10497,6 @@ src/assets/twemoji/svg/ae.svg src/assets/twemoji/svg/e50a.svg src/assets/twemoji/LICENSE + src/StatusQ/Controls/StatusTabBar.qml