diff --git a/Modules/AppLauncher.qml b/Modules/AppLauncher.qml index af54f18a..7c50a311 100644 --- a/Modules/AppLauncher.qml +++ b/Modules/AppLauncher.qml @@ -605,59 +605,33 @@ PanelWindow { anchors.verticalCenter: parent.verticalCenter // List view button - Rectangle { - width: 36 - height: 36 - radius: Theme.cornerRadius - color: viewMode === "list" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : listViewArea.containsMouse ? Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08) : "transparent" - - DankIcon { - anchors.centerIn: parent - name: "view_list" - size: 20 - color: viewMode === "list" ? Theme.primary : Theme.surfaceText + DankActionButton { + buttonSize: 36 + circular: false + iconName: "view_list" + iconSize: 20 + iconColor: viewMode === "list" ? Theme.primary : Theme.surfaceText + hoverColor: viewMode === "list" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08) + backgroundColor: viewMode === "list" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent" + onClicked: { + viewMode = "list"; + Prefs.setAppLauncherViewMode("list"); } - - MouseArea { - id: listViewArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - viewMode = "list"; - Prefs.setAppLauncherViewMode("list"); - } - } - } // Grid view button - Rectangle { - width: 36 - height: 36 - radius: Theme.cornerRadius - color: viewMode === "grid" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : gridViewArea.containsMouse ? Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08) : "transparent" - - DankIcon { - anchors.centerIn: parent - name: "grid_view" - size: 20 - color: viewMode === "grid" ? Theme.primary : Theme.surfaceText + DankActionButton { + buttonSize: 36 + circular: false + iconName: "grid_view" + iconSize: 20 + iconColor: viewMode === "grid" ? Theme.primary : Theme.surfaceText + hoverColor: viewMode === "grid" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08) + backgroundColor: viewMode === "grid" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent" + onClicked: { + viewMode = "grid"; + Prefs.setAppLauncherViewMode("grid"); } - - MouseArea { - id: gridViewArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - viewMode = "grid"; - Prefs.setAppLauncherViewMode("grid"); - } - } - } } diff --git a/Modules/ClipboardHistory.qml b/Modules/ClipboardHistory.qml index 117ad178..2eae1f69 100644 --- a/Modules/ClipboardHistory.qml +++ b/Modules/ClipboardHistory.qml @@ -217,70 +217,26 @@ PanelWindow { spacing: activeTheme.spacingS // Clear all button - Rectangle { - id: clearAllButton - - width: 40 - height: 32 - radius: activeTheme.cornerRadius - color: clearArea.containsMouse ? Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12) : "transparent" + DankActionButton { + buttonSize: 40 + circular: false + iconName: "delete_sweep" + iconSize: activeTheme.iconSize + iconColor: activeTheme.surfaceText + hoverColor: Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12) visible: clipboardHistory.totalCount > 0 - - DankIcon { - anchors.centerIn: parent - name: "delete_sweep" - size: activeTheme.iconSize - color: clearArea.containsMouse ? activeTheme.primary : activeTheme.surfaceText - } - - MouseArea { - id: clearArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: showClearConfirmation = true - } - - Behavior on color { - ColorAnimation { - duration: activeTheme.shortDuration - } - - } - + onClicked: showClearConfirmation = true } // Close button - Rectangle { - width: 40 - height: 32 - radius: activeTheme.cornerRadius - color: closeArea.containsMouse ? Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12) : "transparent" - - DankIcon { - anchors.centerIn: parent - name: "close" - size: activeTheme.iconSize - color: closeArea.containsMouse ? activeTheme.primary : activeTheme.surfaceText - } - - MouseArea { - id: closeArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: clipboardHistory.hide() - } - - Behavior on color { - ColorAnimation { - duration: activeTheme.shortDuration - } - - } - + DankActionButton { + buttonSize: 40 + circular: false + iconName: "close" + iconSize: activeTheme.iconSize + iconColor: activeTheme.surfaceText + hoverColor: Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12) + onClicked: clipboardHistory.hide() } } diff --git a/Modules/ControlCenter/ControlCenterPopup.qml b/Modules/ControlCenter/ControlCenterPopup.qml index 7e454e29..88edda5a 100644 --- a/Modules/ControlCenter/ControlCenterPopup.qml +++ b/Modules/ControlCenter/ControlCenterPopup.qml @@ -352,39 +352,17 @@ PanelWindow { } // Settings Button - Rectangle { - width: 40 - height: 40 - radius: 20 - color: settingsButton.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.5) - - DankIcon { - anchors.centerIn: parent - name: "settings" - size: Theme.iconSize - 2 - color: Theme.surfaceText + DankActionButton { + buttonSize: 40 + iconName: "settings" + iconSize: Theme.iconSize - 2 + iconColor: Theme.surfaceText + backgroundColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.5) + hoverColor: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) + onClicked: { + controlCenterVisible = false; + settingsPopup.settingsVisible = true; } - - MouseArea { - id: settingsButton - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - controlCenterVisible = false; - settingsPopup.settingsVisible = true; - } - } - - Behavior on color { - ColorAnimation { - duration: Theme.shortDuration - easing.type: Theme.standardEasing - } - - } - } } diff --git a/Modules/InputDialog.qml b/Modules/InputDialog.qml index 32dd3c77..29071160 100644 --- a/Modules/InputDialog.qml +++ b/Modules/InputDialog.qml @@ -122,31 +122,15 @@ PanelWindow { } - Rectangle { - width: 32 - height: 32 - radius: 16 - color: closeDialogArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" - - DankIcon { - anchors.centerIn: parent - name: "close" - size: Theme.iconSize - 4 - color: closeDialogArea.containsMouse ? Theme.error : Theme.surfaceText + DankActionButton { + iconName: "close" + iconSize: Theme.iconSize - 4 + iconColor: Theme.surfaceText + hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) + onClicked: { + inputDialog.cancelled(); + hideDialog(); } - - MouseArea { - id: closeDialogArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - inputDialog.cancelled(); - hideDialog(); - } - } - } } diff --git a/Modules/PowerMenuPopup.qml b/Modules/PowerMenuPopup.qml index 80d55e04..282f9732 100644 --- a/Modules/PowerMenuPopup.qml +++ b/Modules/PowerMenuPopup.qml @@ -78,30 +78,14 @@ PanelWindow { height: 1 } - Rectangle { - width: 32 - height: 32 - radius: 16 - color: closePowerArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" - - DankIcon { - anchors.centerIn: parent - name: "close" - size: Theme.iconSize - 4 - color: closePowerArea.containsMouse ? Theme.error : Theme.surfaceText + DankActionButton { + iconName: "close" + iconSize: Theme.iconSize - 4 + iconColor: Theme.surfaceText + hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) + onClicked: { + powerMenuVisible = false; } - - MouseArea { - id: closePowerArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - powerMenuVisible = false; - } - } - } } diff --git a/Modules/SettingsPopup.qml b/Modules/SettingsPopup.qml index 151c348e..2418d106 100644 --- a/Modules/SettingsPopup.qml +++ b/Modules/SettingsPopup.qml @@ -204,28 +204,13 @@ PanelWindow { } // Close button - Rectangle { - width: 32 - height: 32 - radius: Theme.cornerRadius - color: closeButton.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" - - DankIcon { - name: "close" - size: Theme.iconSize - 4 - color: Theme.surfaceText - anchors.centerIn: parent - } - - MouseArea { - id: closeButton - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: settingsPopup.settingsVisible = false - } - + DankActionButton { + circular: false + iconName: "close" + iconSize: Theme.iconSize - 4 + iconColor: Theme.surfaceText + hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) + onClicked: settingsPopup.settingsVisible = false } } diff --git a/Modules/WifiPasswordDialog.qml b/Modules/WifiPasswordDialog.qml index 2f909378..46a60326 100644 --- a/Modules/WifiPasswordDialog.qml +++ b/Modules/WifiPasswordDialog.qml @@ -96,31 +96,15 @@ PanelWindow { } - Rectangle { - width: 32 - height: 32 - radius: 16 - color: closeDialogArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" - - DankIcon { - anchors.centerIn: parent - name: "close" - size: Theme.iconSize - 4 - color: closeDialogArea.containsMouse ? Theme.error : Theme.surfaceText + DankActionButton { + iconName: "close" + iconSize: Theme.iconSize - 4 + iconColor: Theme.surfaceText + hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) + onClicked: { + wifiPasswordDialogVisible = false; + wifiPasswordInput = ""; } - - MouseArea { - id: closeDialogArea - - anchors.fill: parent - hoverEnabled: true - cursorShape: Qt.PointingHandCursor - onClicked: { - wifiPasswordDialogVisible = false; - wifiPasswordInput = ""; - } - } - } } diff --git a/Widgets/DankActionButton.qml b/Widgets/DankActionButton.qml new file mode 100644 index 00000000..1b2cd268 --- /dev/null +++ b/Widgets/DankActionButton.qml @@ -0,0 +1,44 @@ +import QtQuick +import qs.Common +import qs.Widgets + +Rectangle { + id: root + + property string iconName: "" + property int iconSize: Theme.iconSize - 4 + property color iconColor: Theme.surfaceText + property color hoverColor: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) + property color backgroundColor: "transparent" + property bool circular: true + property int buttonSize: 32 + + signal clicked() + + width: buttonSize + height: buttonSize + radius: circular ? buttonSize / 2 : Theme.cornerRadius + color: mouseArea.containsMouse ? hoverColor : backgroundColor + + DankIcon { + anchors.centerIn: parent + name: root.iconName + size: root.iconSize + color: root.iconColor + } + + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.clicked() + } + + Behavior on color { + ColorAnimation { + duration: Theme.shortDuration + easing.type: Theme.standardEasing + } + } +} \ No newline at end of file