From d761ef4fd74d1562c8fd44809575d4edc39569ea Mon Sep 17 00:00:00 2001 From: talksik Date: Fri, 11 Apr 2025 13:15:50 -0700 Subject: [PATCH] feat: add secondary button --- AppSecondaryButton.qml | 22 ++++++++++++++++++++++ CMakeLists.txt | 1 + gallery/Main.qml | 17 ++++++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 AppSecondaryButton.qml diff --git a/AppSecondaryButton.qml b/AppSecondaryButton.qml new file mode 100644 index 0000000..7af4f0a --- /dev/null +++ b/AppSecondaryButton.qml @@ -0,0 +1,22 @@ +import QtQuick +import QtQuick.Controls.Basic +import QtQuick.Controls.impl // Needed for features like the Control.blend() function +import DesignSystem + +Button { + id: control + font.family: Fonts.dotrice + font.bold: false + + background: Rectangle { + // NOTE: copied from ~/Qt/6.8.3/macos/qml/QtQuick/Controls/Basic/Button.qml + implicitWidth: 100 + implicitHeight: 40 + visible: !control.flat || control.down || control.checked || control.highlighted + color: control.down ? Theme.card : "transparent" + border.color: Theme.softBorder + border.width: 1 + // custom + radius: Theme.radius + } +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 3897cd1..9afcca8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(plain_qml_files AppText.qml AppIcon.qml AppPrimaryButton.qml + AppSecondaryButton.qml AppCard.qml AppCaption.qml AppHeadline.qml diff --git a/gallery/Main.qml b/gallery/Main.qml index dbba12a..197e30d 100644 --- a/gallery/Main.qml +++ b/gallery/Main.qml @@ -21,10 +21,17 @@ AppWindow { AppLogo {} - AppPrimaryButton { - text: "Toggle theme" - onClicked: { - Theme.toggleTheme() + Row { + spacing: 5 + + AppPrimaryButton { + text: "Toggle theme" + onClicked: { + Theme.toggleTheme() + } + } + AppSecondaryButton { + text: "Secondary button" } } @@ -51,7 +58,7 @@ AppWindow { Switch {} - AppPrimaryButton { + AppSecondaryButton { text: "Open message dialog" onClicked: { messageDialog.open()