From 4d0041abeeb7f71724560134d20aff5b9788c0df Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Thu, 9 Oct 2025 19:57:12 -0400 Subject: [PATCH] Quicksettings: polishing, fixed all scaling issues. --- Assets/settings-default.json | 19 +- Commons/Settings.qml | 2 +- Modules/Bar/Widgets/ActiveWindow.qml | 1 + Modules/Bar/Widgets/Bluetooth.qml | 2 +- Modules/Bar/Widgets/ControlCenter.qml | 2 +- Modules/Bar/Widgets/CustomButton.qml | 1 - Modules/Bar/Widgets/DarkMode.qml | 2 +- Modules/Bar/Widgets/KeepAwake.qml | 2 +- Modules/Bar/Widgets/NightLight.qml | 2 +- Modules/Bar/Widgets/NotificationHistory.qml | 2 +- Modules/Bar/Widgets/PowerProfile.qml | 2 +- Modules/Bar/Widgets/ScreenRecorder.qml | 2 +- Modules/Bar/Widgets/Spacer.qml | 1 - Modules/Bar/Widgets/WallpaperSelector.qml | 2 +- Modules/Bar/Widgets/WiFi.qml | 2 +- Modules/ControlCenter/Cards/TopCard.qml | 4 +- Modules/ControlCenter/ControlCenterPanel.qml | 16 +- Modules/ControlCenter/Widgets/Bluetooth.qml | 2 - Modules/ControlCenter/Widgets/KeepAwake.qml | 2 +- Modules/ControlCenter/Widgets/NightLight.qml | 2 +- .../ControlCenter/Widgets/Notifications.qml | 2 +- .../ControlCenter/Widgets/PowerProfile.qml | 2 +- .../ControlCenter/Widgets/ScreenRecorder.qml | 2 +- .../Widgets/WallpaperSelector.qml | 1 - Modules/ControlCenter/Widgets/WiFi.qml | 18 -- .../Bar/WidgetSettings/TaskbarSettings.qml | 1 - Modules/Settings/Tabs/ControlCenterTab.qml | 8 +- Services/PowerProfileService.qml | 6 + Widgets/NCircleStat.qml | 2 +- Widgets/NIconButton.qml | 1 - Widgets/NQuickSetting.qml | 166 +++++------------- 31 files changed, 87 insertions(+), 192 deletions(-) diff --git a/Assets/settings-default.json b/Assets/settings-default.json index fd3707c43..05ccde057 100644 --- a/Assets/settings-default.json +++ b/Assets/settings-default.json @@ -36,12 +36,6 @@ { "id": "NotificationHistory" }, - { - "id": "WiFi" - }, - { - "id": "Bluetooth" - }, { "id": "Battery" }, @@ -113,7 +107,7 @@ }, "controlCenter": { "position": "close_to_bar_button", - "quickSettingsStyle": "modern", + "quickSettingsStyle": "compact", "widgets": { "quickSettings": [ { @@ -125,20 +119,11 @@ { "id": "Notifications" }, - { - "id": "NightLight" - }, - { - "id": "KeepAwake" - }, - { - "id": "PowerProfile" - }, { "id": "ScreenRecorder" }, { - "id": "WallpaperSelector" + "id": "PowerProfile" } ] } diff --git a/Commons/Settings.qml b/Commons/Settings.qml index ffe9039a3..960edd678 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -242,7 +242,7 @@ Singleton { property JsonObject controlCenter: JsonObject { // Position: close_to_bar_button, center, top_left, top_right, bottom_left, bottom_right, bottom_center, top_center property string position: "close_to_bar_button" - property string quickSettingsStyle: "compact" // "modern", "classic", or "compact" + property string quickSettingsStyle: "compact" // "compact", "classic", or "modern" property JsonObject widgets widgets: JsonObject { property list quickSettings: [{ diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index 91c05f1de..de10760db 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -10,6 +10,7 @@ import qs.Widgets Item { id: root + property ShellScreen screen property real scaling: 1.0 diff --git a/Modules/Bar/Widgets/Bluetooth.qml b/Modules/Bar/Widgets/Bluetooth.qml index 520455e41..e76fa2342 100644 --- a/Modules/Bar/Widgets/Bluetooth.qml +++ b/Modules/Bar/Widgets/Bluetooth.qml @@ -10,8 +10,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 baseSize: Style.capsuleHeight compact: (Settings.data.bar.density === "compact") diff --git a/Modules/Bar/Widgets/ControlCenter.qml b/Modules/Bar/Widgets/ControlCenter.qml index 993e2f0b6..65eb3b8cf 100644 --- a/Modules/Bar/Widgets/ControlCenter.qml +++ b/Modules/Bar/Widgets/ControlCenter.qml @@ -9,8 +9,8 @@ import qs.Services NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 // Widget properties passed from Bar.qml for per-instance settings property string widgetId: "" diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index 11a1b7d66..50310b246 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -11,7 +11,6 @@ import qs.Modules.Bar.Extras Item { id: root - // Widget properties passed from Bar.qml property ShellScreen screen property real scaling: 1.0 diff --git a/Modules/Bar/Widgets/DarkMode.qml b/Modules/Bar/Widgets/DarkMode.qml index 139984146..b35dd236d 100644 --- a/Modules/Bar/Widgets/DarkMode.qml +++ b/Modules/Bar/Widgets/DarkMode.qml @@ -6,8 +6,8 @@ import qs.Services NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 icon: "dark-mode" tooltipText: Settings.data.colorSchemes.darkMode ? I18n.tr("tooltips.switch-to-light-mode") : I18n.tr("tooltips.switch-to-dark-mode") diff --git a/Modules/Bar/Widgets/KeepAwake.qml b/Modules/Bar/Widgets/KeepAwake.qml index 058a512d6..ba09d92a9 100644 --- a/Modules/Bar/Widgets/KeepAwake.qml +++ b/Modules/Bar/Widgets/KeepAwake.qml @@ -8,8 +8,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 baseSize: Style.capsuleHeight compact: (Settings.data.bar.density === "compact") diff --git a/Modules/Bar/Widgets/NightLight.qml b/Modules/Bar/Widgets/NightLight.qml index 065f67993..b972d37d9 100644 --- a/Modules/Bar/Widgets/NightLight.qml +++ b/Modules/Bar/Widgets/NightLight.qml @@ -11,8 +11,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 compact: (Settings.data.bar.density === "compact") baseSize: Style.capsuleHeight diff --git a/Modules/Bar/Widgets/NotificationHistory.qml b/Modules/Bar/Widgets/NotificationHistory.qml index a5448ae17..aee735980 100644 --- a/Modules/Bar/Widgets/NotificationHistory.qml +++ b/Modules/Bar/Widgets/NotificationHistory.qml @@ -10,8 +10,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 // Widget properties passed from Bar.qml for per-instance settings property string widgetId: "" diff --git a/Modules/Bar/Widgets/PowerProfile.qml b/Modules/Bar/Widgets/PowerProfile.qml index ad1dc21de..fbd2a719b 100644 --- a/Modules/Bar/Widgets/PowerProfile.qml +++ b/Modules/Bar/Widgets/PowerProfile.qml @@ -9,8 +9,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 baseSize: Style.capsuleHeight visible: PowerProfileService.available diff --git a/Modules/Bar/Widgets/ScreenRecorder.qml b/Modules/Bar/Widgets/ScreenRecorder.qml index 068696897..16b57804c 100644 --- a/Modules/Bar/Widgets/ScreenRecorder.qml +++ b/Modules/Bar/Widgets/ScreenRecorder.qml @@ -7,8 +7,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 icon: "camera-video" tooltipText: ScreenRecorderService.isRecording ? I18n.tr("tooltips.click-to-stop-recording") : I18n.tr("tooltips.click-to-start-recording") diff --git a/Modules/Bar/Widgets/Spacer.qml b/Modules/Bar/Widgets/Spacer.qml index 811bcb532..d8e4abcb8 100644 --- a/Modules/Bar/Widgets/Spacer.qml +++ b/Modules/Bar/Widgets/Spacer.qml @@ -8,7 +8,6 @@ import qs.Widgets Item { id: root - // Widget properties passed from Bar.qml property ShellScreen screen property real scaling: 1.0 diff --git a/Modules/Bar/Widgets/WallpaperSelector.qml b/Modules/Bar/Widgets/WallpaperSelector.qml index cbed457fd..4be3e9a1b 100644 --- a/Modules/Bar/Widgets/WallpaperSelector.qml +++ b/Modules/Bar/Widgets/WallpaperSelector.qml @@ -8,8 +8,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 baseSize: Style.capsuleHeight compact: (Settings.data.bar.density === "compact") diff --git a/Modules/Bar/Widgets/WiFi.qml b/Modules/Bar/Widgets/WiFi.qml index 55b2ebb85..00fefab69 100644 --- a/Modules/Bar/Widgets/WiFi.qml +++ b/Modules/Bar/Widgets/WiFi.qml @@ -10,8 +10,8 @@ import qs.Widgets NIconButton { id: root - // NIconButton must only define screen, not scaling property ShellScreen screen + property real scaling: 1.0 compact: (Settings.data.bar.density === "compact") baseSize: Style.capsuleHeight diff --git a/Modules/ControlCenter/Cards/TopCard.qml b/Modules/ControlCenter/Cards/TopCard.qml index 643200e20..16336beb3 100644 --- a/Modules/ControlCenter/Cards/TopCard.qml +++ b/Modules/ControlCenter/Cards/TopCard.qml @@ -31,7 +31,7 @@ NBox { NImageCircled { width: Style.baseWidgetSize * 1.25 * scaling - height: Style.baseWidgetSize * 1.25 * scaling + height: width imagePath: Settings.data.general.avatarImage fallbackIcon: "person" borderColor: Color.mPrimary @@ -105,7 +105,7 @@ NBox { GridLayout { id: grid Layout.fillWidth: true - columns: (Settings.data.controlCenter.quickSettingsStyle === "compact") ? 4 : 3 + columns: (Settings.data.controlCenter.quickSettingsStyle === "compact") ? 5 : 3 columnSpacing: Style.marginM * scaling rowSpacing: Style.marginS * scaling diff --git a/Modules/ControlCenter/ControlCenterPanel.qml b/Modules/ControlCenter/ControlCenterPanel.qml index 4f76e0299..254584016 100644 --- a/Modules/ControlCenter/ControlCenterPanel.qml +++ b/Modules/ControlCenter/ControlCenterPanel.qml @@ -11,12 +11,12 @@ NPanel { id: root preferredWidth: 440 - preferredHeight: topHeight + bottomHeight + Math.round(Style.marginL * scaling * 3) + preferredHeight: topHeight + bottomHeight + Math.round(Style.marginL * 3) panelKeyboardFocus: true - readonly property int bottomHeight: Math.round(Math.max(196 * scaling)) + readonly property int bottomHeight: 196 readonly property int topHeight: { - const columns = (Settings.data.controlCenter.quickSettingsStyle === "compact") ? 4 : 3 + const columns = (Settings.data.controlCenter.quickSettingsStyle === "compact") ? 5 : 3 const rowsCount = Math.ceil(Settings.data.controlCenter.widgets.quickSettings.length / columns) var buttonHeight @@ -28,7 +28,7 @@ NPanel { buttonHeight = 56 } - return (rowsCount * buttonHeight) + (120 * scaling) + return (rowsCount * buttonHeight) + 120 } // Positioning @@ -56,26 +56,26 @@ NPanel { TopCard { id: topCard Layout.fillWidth: true - Layout.preferredHeight: topHeight + Layout.preferredHeight: topHeight * scaling } // Media + stats column RowLayout { id: bottomCard Layout.fillWidth: true - Layout.preferredHeight: bottomHeight + Layout.preferredHeight: bottomHeight * scaling spacing: content.cardSpacing // Media card MediaCard { Layout.preferredWidth: Math.max(250 * scaling) - Layout.preferredHeight: bottomHeight + Layout.preferredHeight: bottomHeight * scaling } // System monitors combined in one card SystemMonitorCard { Layout.preferredWidth: Math.max(140 * scaling) - Layout.preferredHeight: bottomHeight + Layout.preferredHeight: bottomHeight * scaling } } } diff --git a/Modules/ControlCenter/Widgets/Bluetooth.qml b/Modules/ControlCenter/Widgets/Bluetooth.qml index e44d98442..9150004dd 100644 --- a/Modules/ControlCenter/Widgets/Bluetooth.qml +++ b/Modules/ControlCenter/Widgets/Bluetooth.qml @@ -12,9 +12,7 @@ NQuickSetting { fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium icon: BluetoothService.enabled ? "bluetooth" : "bluetooth-off" - active: BluetoothService.enabled tooltipText: I18n.tr("quickSettings.bluetooth.tooltip.action") style: Settings.data.controlCenter.quickSettingsStyle || "modern" - onClicked: PanelService.getPanel("bluetoothPanel")?.toggle(this) } diff --git a/Modules/ControlCenter/Widgets/KeepAwake.qml b/Modules/ControlCenter/Widgets/KeepAwake.qml index e384272ae..fff72489c 100644 --- a/Modules/ControlCenter/Widgets/KeepAwake.qml +++ b/Modules/ControlCenter/Widgets/KeepAwake.qml @@ -12,7 +12,7 @@ NQuickSetting { fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium icon: IdleInhibitorService.isInhibited ? "keep-awake-on" : "keep-awake-off" - active: IdleInhibitorService.isInhibited + hot: IdleInhibitorService.isInhibited tooltipText: I18n.tr("quickSettings.keepAwake.tooltip.action") style: Settings.data.controlCenter.quickSettingsStyle || "modern" diff --git a/Modules/ControlCenter/Widgets/NightLight.qml b/Modules/ControlCenter/Widgets/NightLight.qml index a2d6bfc17..dac6dd980 100644 --- a/Modules/ControlCenter/Widgets/NightLight.qml +++ b/Modules/ControlCenter/Widgets/NightLight.qml @@ -13,7 +13,7 @@ NQuickSetting { fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium icon: Settings.data.nightLight.enabled ? (Settings.data.nightLight.forced ? "nightlight-forced" : "nightlight-on") : "nightlight-off" - active: Settings.data.nightLight.enabled + hot: !Settings.data.nightLight.enabled || Settings.data.nightLight.forced style: Settings.data.controlCenter.quickSettingsStyle || "modern" tooltipText: I18n.tr("quickSettings.nightLight.tooltip.action") diff --git a/Modules/ControlCenter/Widgets/Notifications.qml b/Modules/ControlCenter/Widgets/Notifications.qml index 131db7f9d..7d8085e49 100644 --- a/Modules/ControlCenter/Widgets/Notifications.qml +++ b/Modules/ControlCenter/Widgets/Notifications.qml @@ -12,7 +12,7 @@ NQuickSetting { fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell" - active: Settings.data.notifications.doNotDisturb + hot: Settings.data.notifications.doNotDisturb tooltipText: I18n.tr("quickSettings.notifications.tooltip.action") style: Settings.data.controlCenter.quickSettingsStyle || "modern" diff --git a/Modules/ControlCenter/Widgets/PowerProfile.qml b/Modules/ControlCenter/Widgets/PowerProfile.qml index 1c57f9fa6..442cc9c52 100644 --- a/Modules/ControlCenter/Widgets/PowerProfile.qml +++ b/Modules/ControlCenter/Widgets/PowerProfile.qml @@ -16,7 +16,7 @@ NQuickSetting { fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium icon: PowerProfileService.getIcon() - active: hasPP + hot: !PowerProfileService.isDefault() tooltipText: I18n.tr("quickSettings.powerProfile.tooltip.action") style: Settings.data.controlCenter.quickSettingsStyle || "modern" diff --git a/Modules/ControlCenter/Widgets/ScreenRecorder.qml b/Modules/ControlCenter/Widgets/ScreenRecorder.qml index a9560bdf1..a53e39506 100644 --- a/Modules/ControlCenter/Widgets/ScreenRecorder.qml +++ b/Modules/ControlCenter/Widgets/ScreenRecorder.qml @@ -13,7 +13,7 @@ NQuickSetting { text: ScreenRecorderService.isRecording ? I18n.tr("quickSettings.screenRecorder.label.recording") : I18n.tr("quickSettings.screenRecorder.label.stopped") fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium - active: ScreenRecorderService.isRecording + hot: ScreenRecorderService.isRecording tooltipText: I18n.tr("quickSettings.screenRecorder.tooltip.action") style: Settings.data.controlCenter.quickSettingsStyle || "modern" diff --git a/Modules/ControlCenter/Widgets/WallpaperSelector.qml b/Modules/ControlCenter/Widgets/WallpaperSelector.qml index a46393830..e4531ecda 100644 --- a/Modules/ControlCenter/Widgets/WallpaperSelector.qml +++ b/Modules/ControlCenter/Widgets/WallpaperSelector.qml @@ -13,7 +13,6 @@ NQuickSetting { text: I18n.tr("quickSettings.wallpaperSelector.label") fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium - active: Settings.data.wallpaper.enabled tooltipText: I18n.tr("quickSettings.wallpaperSelector.tooltip.action") style: Settings.data.controlCenter.quickSettingsStyle || "modern" diff --git a/Modules/ControlCenter/Widgets/WiFi.qml b/Modules/ControlCenter/Widgets/WiFi.qml index 9d896a5cc..29c89a8a8 100644 --- a/Modules/ControlCenter/Widgets/WiFi.qml +++ b/Modules/ControlCenter/Widgets/WiFi.qml @@ -46,24 +46,6 @@ NQuickSetting { fontSize: Style.fontSizeS * scaling fontWeight: Style.fontWeightMedium style: Settings.data.controlCenter.quickSettingsStyle || "modern" - - active: { - if (NetworkService.ethernetConnected) { - return true - } - try { - for (const net in NetworkService.networks) { - if (NetworkService.networks[net].connected) { - return true - } - } - return false - } catch (error) { - return false - } - } - tooltipText: I18n.tr("quickSettings.wifi.tooltip.action") - onClicked: PanelService.getPanel("wifiPanel")?.toggle(this) } diff --git a/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml b/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml index 98df4c3fc..c80dd09f0 100644 --- a/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml +++ b/Modules/Settings/Bar/WidgetSettings/TaskbarSettings.qml @@ -21,7 +21,6 @@ ColumnLayout { var settings = Object.assign({}, widgetData || {}) settings.onlySameOutput = valueOnlySameOutput settings.onlyActiveWorkspaces = valueOnlyActiveWorkspaces - console.log(JSON.stringify(settings)) return settings } diff --git a/Modules/Settings/Tabs/ControlCenterTab.qml b/Modules/Settings/Tabs/ControlCenterTab.qml index 8b7fe2653..a880334c5 100644 --- a/Modules/Settings/Tabs/ControlCenterTab.qml +++ b/Modules/Settings/Tabs/ControlCenterTab.qml @@ -43,14 +43,14 @@ ColumnLayout { description: I18n.tr("settings.control-center.quickSettingsStyle.style.description") Layout.fillWidth: true model: [{ - "key": "modern", - "name": I18n.tr("options.control-center.quickSettingsStyle.modern") + "key": "compact", + "name": I18n.tr("options.control-center.quickSettingsStyle.compact") }, { "key": "classic", "name": I18n.tr("options.control-center.quickSettingsStyle.classic") }, { - "key": "compact", - "name": I18n.tr("options.control-center.quickSettingsStyle.compact") + "key": "modern", + "name": I18n.tr("options.control-center.quickSettingsStyle.modern") }] currentKey: Settings.data.controlCenter.quickSettingsStyle || "compact" onSelected: function (key) { diff --git a/Services/PowerProfileService.qml b/Services/PowerProfileService.qml index 98acfb71b..9a43217e1 100644 --- a/Services/PowerProfileService.qml +++ b/Services/PowerProfileService.qml @@ -71,6 +71,12 @@ Singleton { setProfile(PowerProfile.Balanced) } + function isDefault() { + if (!available) + return true + return (profile === PowerProfile.Balanced) + } + Connections { target: powerProfiles function onProfileChanged() { diff --git a/Widgets/NCircleStat.qml b/Widgets/NCircleStat.qml index 53177d07e..9c9248834 100644 --- a/Widgets/NCircleStat.qml +++ b/Widgets/NCircleStat.qml @@ -84,7 +84,7 @@ Rectangle { anchors.centerIn: parent anchors.verticalCenterOffset: -4 * scaling * contentScale text: `${root.value}${root.suffix}` - pointSize: Style.fontSizeM * scaling * contentScale + pointSize: Style.fontSizeM * scaling * contentScale * 0.9 font.weight: Style.fontWeightBold color: Color.mOnSurface horizontalAlignment: Text.AlignHCenter diff --git a/Widgets/NIconButton.qml b/Widgets/NIconButton.qml index 57df95a21..e2d0d0fa6 100644 --- a/Widgets/NIconButton.qml +++ b/Widgets/NIconButton.qml @@ -8,7 +8,6 @@ Rectangle { id: root property real baseSize: Style.baseWidgetSize - property real scaling: 1.0 property string icon property string tooltipText diff --git a/Widgets/NQuickSetting.qml b/Widgets/NQuickSetting.qml index 755177180..c5706cf91 100644 --- a/Widgets/NQuickSetting.qml +++ b/Widgets/NQuickSetting.qml @@ -13,8 +13,7 @@ Rectangle { property string icon: "" property string tooltipText: "" property bool enabled: true - property bool active: false - property bool compact: false + property bool hot: false property string style: "modern" // "modern", "classic", or "compact" // Styling properties @@ -23,56 +22,54 @@ Rectangle { property real iconSize: Style.fontSizeL * scaling property real cornerRadius: Style.radiusM * scaling + // Internal properties + property bool hovered: false + property bool pressed: false + // Colors - Style-dependent colors property color backgroundColor: { + if (pressed) { + return Color.mTertiary + } + if (hot) { + return Color.mPrimary + } if (style === "classic") return Color.mSurfaceVariant if (style === "compact") return Color.mSurface return Color.mSurface } - property color textColor: Color.mOnSurface + property color textColor: { + if (pressed) { + return Color.mOnTertiary + } + if (hot) { + return Color.mOnPrimary + } + return Color.mOnSurface + } property color iconColor: { - if (style === "classic") + if (pressed) { + return Color.mOnTertiary + } + if (hot) { + return Color.mOnPrimary + } + if (style !== "compact") return Color.mPrimary - if (style === "compact") - return active ? Color.mPrimary : Color.mOnSurface - return active ? Color.mPrimary : Color.mOnSurface + return Color.mOnSurface } property color borderColor: Color.mOutline - property color hoverColor: { - if (style === "classic") - return Color.mTertiary - if (style === "compact") - return Color.mPrimary - return Color.mPrimary - } - property color pressedColor: { - if (style === "classic") - return Color.mTertiary - if (style === "compact") - return Qt.darker(Color.mPrimary, 1.1) - return Qt.darker(Color.mPrimary, 1.1) - } - property color hoverTextColor: Color.mOnPrimary - property color hoverIconColor: { - if (style === "classic") - return Color.mOnTertiary - if (style === "compact") - return Color.mOnPrimary - return Color.mOnPrimary - } + property color hoverColor: Color.mTertiary + property color hoverTextColor: Color.mOnTertiary + property color hoverIconColor: Color.mOnTertiary // Signals signal clicked signal rightClicked signal middleClicked - // Internal properties - property bool hovered: false - property bool pressed: false - property real scaling: 1.0 - // Dimensions - Style-dependent sizing implicitWidth: { if (style === "classic") { @@ -81,7 +78,7 @@ Rectangle { if (style === "compact") { return Style.baseWidgetSize * 0.8 * scaling } - return compact ? Math.max(100 * scaling, contentRow.implicitWidth + (Style.marginL * scaling)) : Math.max(120 * scaling, contentRow.implicitWidth + (Style.marginL * scaling)) + return Math.max(120 * scaling, contentRow.implicitWidth + (Style.marginL * scaling)) } implicitHeight: { if (style === "classic") { @@ -90,7 +87,7 @@ Rectangle { if (style === "compact") { return Style.baseWidgetSize * 0.8 * scaling } - return compact ? Math.max(48 * scaling, contentRow.implicitHeight + (Style.marginM * scaling)) : Math.max(56 * scaling, contentRow.implicitHeight + (Style.marginL * scaling)) + return Math.max(48 * scaling, contentRow.implicitHeight + (Style.marginL * scaling)) } // Appearance - Style-dependent styling @@ -104,8 +101,6 @@ Rectangle { color: { if (!enabled) return Qt.lighter(Color.mSurface, 1.1) - if (pressed) - return pressedColor if (hovered) return hoverColor return backgroundColor @@ -128,14 +123,14 @@ Rectangle { Behavior on color { ColorAnimation { - duration: style === "classic" ? Style.animationNormal : Style.animationFast + duration: Style.animationFast easing.type: style === "classic" ? Easing.InOutQuad : Easing.OutCubic } } Behavior on border.color { ColorAnimation { - duration: style === "classic" ? Style.animationNormal : Style.animationFast + duration: Style.animationFast easing.type: style === "classic" ? Easing.InOutQuad : Easing.OutCubic } } @@ -147,25 +142,6 @@ Rectangle { } } - // Hover scale effect - scale: hovered ? 1.02 : 1.0 - - // Subtle shadow/elevation effect - Rectangle { - anchors.fill: parent - radius: parent.radius - color: Qt.rgba(0, 0, 0, 0.1) - visible: active - z: -1 - - Behavior on color { - ColorAnimation { - duration: Style.animationFast - easing.type: Easing.OutCubic - } - } - } - // Modern style - icon above text ColumnLayout { id: contentRow @@ -198,7 +174,7 @@ Rectangle { // Text content NText { Layout.alignment: Qt.AlignHCenter - visible: root.text !== "" && !compact + visible: root.text !== "" text: root.text pointSize: root.fontSize font.weight: root.fontWeight @@ -315,22 +291,25 @@ Rectangle { onPressed: mouse => { root.pressed = true - root.scale = 0.95 + root.scale = 0.92 if (tooltipText) { TooltipService.hide() } } onReleased: mouse => { - root.pressed = false root.scale = 1.0 + root.pressed = false - if (mouse.button === Qt.LeftButton) { - root.clicked() - } else if (mouse.button === Qt.RightButton) { - root.rightClicked() - } else if (mouse.button === Qt.MiddleButton) { - root.middleClicked() + // Only trigger actions if released while hovering + if (root.hovered) { + if (mouse.button === Qt.LeftButton) { + root.clicked() + } else if (mouse.button === Qt.RightButton) { + root.rightClicked() + } else if (mouse.button === Qt.MiddleButton) { + root.middleClicked() + } } } @@ -343,55 +322,4 @@ Rectangle { } } } - - Rectangle { - id: ripple - anchors.fill: parent - radius: parent.radius - color: Qt.rgba(1, 1, 1, 0.2) - scale: 0 - opacity: 0 - visible: false - - SequentialAnimation { - id: rippleAnimation - running: false - - ParallelAnimation { - NumberAnimation { - target: ripple - property: "scale" - from: 0 - to: 1.2 - duration: Style.animationNormal - easing.type: Easing.OutCubic - } - NumberAnimation { - target: ripple - property: "opacity" - from: 0.6 - to: 0 - duration: Style.animationNormal - easing.type: Easing.OutCubic - } - } - } - } - - Connections { - target: root - function onClicked() { - ripple.visible = true - rippleAnimation.start() - } - } - - Connections { - target: rippleAnimation - function onFinished() { - ripple.visible = false - ripple.scale = 0 - ripple.opacity = 0 - } - } }