1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 22:15:38 -05:00

refactor: create DankActionButton and implement

This commit is contained in:
bbedward
2025-07-21 21:06:03 -04:00
parent dbf2b58b7f
commit de8235d94f
8 changed files with 122 additions and 233 deletions

View File

@@ -605,53 +605,29 @@ PanelWindow {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
// List view button // List view button
Rectangle { DankActionButton {
width: 36 buttonSize: 36
height: 36 circular: false
radius: Theme.cornerRadius iconName: "view_list"
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" iconSize: 20
iconColor: viewMode === "list" ? Theme.primary : Theme.surfaceText
DankIcon { 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)
anchors.centerIn: parent backgroundColor: viewMode === "list" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
name: "view_list"
size: 20
color: viewMode === "list" ? Theme.primary : Theme.surfaceText
}
MouseArea {
id: listViewArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
viewMode = "list"; viewMode = "list";
Prefs.setAppLauncherViewMode("list"); Prefs.setAppLauncherViewMode("list");
} }
} }
}
// Grid view button // Grid view button
Rectangle { DankActionButton {
width: 36 buttonSize: 36
height: 36 circular: false
radius: Theme.cornerRadius iconName: "grid_view"
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" iconSize: 20
iconColor: viewMode === "grid" ? Theme.primary : Theme.surfaceText
DankIcon { 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)
anchors.centerIn: parent backgroundColor: viewMode === "grid" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
name: "grid_view"
size: 20
color: viewMode === "grid" ? Theme.primary : Theme.surfaceText
}
MouseArea {
id: gridViewArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
viewMode = "grid"; viewMode = "grid";
Prefs.setAppLauncherViewMode("grid"); Prefs.setAppLauncherViewMode("grid");
@@ -662,8 +638,6 @@ PanelWindow {
} }
}
// App grid/list container // App grid/list container
Rectangle { Rectangle {
width: parent.width width: parent.width

View File

@@ -217,72 +217,28 @@ PanelWindow {
spacing: activeTheme.spacingS spacing: activeTheme.spacingS
// Clear all button // Clear all button
Rectangle { DankActionButton {
id: clearAllButton buttonSize: 40
circular: false
width: 40 iconName: "delete_sweep"
height: 32 iconSize: activeTheme.iconSize
radius: activeTheme.cornerRadius iconColor: activeTheme.surfaceText
color: clearArea.containsMouse ? Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12) : "transparent" hoverColor: Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12)
visible: clipboardHistory.totalCount > 0 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 onClicked: showClearConfirmation = true
} }
Behavior on color {
ColorAnimation {
duration: activeTheme.shortDuration
}
}
}
// Close button // Close button
Rectangle { DankActionButton {
width: 40 buttonSize: 40
height: 32 circular: false
radius: activeTheme.cornerRadius iconName: "close"
color: closeArea.containsMouse ? Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12) : "transparent" iconSize: activeTheme.iconSize
iconColor: activeTheme.surfaceText
DankIcon { hoverColor: Qt.rgba(activeTheme.primary.r, activeTheme.primary.g, activeTheme.primary.b, 0.12)
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() onClicked: clipboardHistory.hide()
} }
Behavior on color {
ColorAnimation {
duration: activeTheme.shortDuration
}
}
}
} }
} }

View File

@@ -352,41 +352,19 @@ PanelWindow {
} }
// Settings Button // Settings Button
Rectangle { DankActionButton {
width: 40 buttonSize: 40
height: 40 iconName: "settings"
radius: 20 iconSize: Theme.iconSize - 2
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) iconColor: Theme.surfaceText
backgroundColor: Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.5)
DankIcon { hoverColor: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12)
anchors.centerIn: parent
name: "settings"
size: Theme.iconSize - 2
color: Theme.surfaceText
}
MouseArea {
id: settingsButton
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
controlCenterVisible = false; controlCenterVisible = false;
settingsPopup.settingsVisible = true; settingsPopup.settingsVisible = true;
} }
} }
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
} }
} }

View File

@@ -122,25 +122,11 @@ PanelWindow {
} }
Rectangle { DankActionButton {
width: 32 iconName: "close"
height: 32 iconSize: Theme.iconSize - 4
radius: 16 iconColor: Theme.surfaceText
color: closeDialogArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
DankIcon {
anchors.centerIn: parent
name: "close"
size: Theme.iconSize - 4
color: closeDialogArea.containsMouse ? Theme.error : Theme.surfaceText
}
MouseArea {
id: closeDialogArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
inputDialog.cancelled(); inputDialog.cancelled();
hideDialog(); hideDialog();
@@ -149,8 +135,6 @@ PanelWindow {
} }
}
// Text input // Text input
Rectangle { Rectangle {
width: parent.width width: parent.width

View File

@@ -78,25 +78,11 @@ PanelWindow {
height: 1 height: 1
} }
Rectangle { DankActionButton {
width: 32 iconName: "close"
height: 32 iconSize: Theme.iconSize - 4
radius: 16 iconColor: Theme.surfaceText
color: closePowerArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
DankIcon {
anchors.centerIn: parent
name: "close"
size: Theme.iconSize - 4
color: closePowerArea.containsMouse ? Theme.error : Theme.surfaceText
}
MouseArea {
id: closePowerArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
powerMenuVisible = false; powerMenuVisible = false;
} }
@@ -104,8 +90,6 @@ PanelWindow {
} }
}
// Power options // Power options
Column { Column {
width: parent.width width: parent.width

View File

@@ -204,32 +204,17 @@ PanelWindow {
} }
// Close button // Close button
Rectangle { DankActionButton {
width: 32 circular: false
height: 32 iconName: "close"
radius: Theme.cornerRadius iconSize: Theme.iconSize - 4
color: closeButton.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" iconColor: Theme.surfaceText
hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
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 onClicked: settingsPopup.settingsVisible = false
} }
} }
}
// Settings sections // Settings sections
Flickable { Flickable {
id: settingsScrollView id: settingsScrollView

View File

@@ -96,25 +96,11 @@ PanelWindow {
} }
Rectangle { DankActionButton {
width: 32 iconName: "close"
height: 32 iconSize: Theme.iconSize - 4
radius: 16 iconColor: Theme.surfaceText
color: closeDialogArea.containsMouse ? Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12) : "transparent" hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
DankIcon {
anchors.centerIn: parent
name: "close"
size: Theme.iconSize - 4
color: closeDialogArea.containsMouse ? Theme.error : Theme.surfaceText
}
MouseArea {
id: closeDialogArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
wifiPasswordDialogVisible = false; wifiPasswordDialogVisible = false;
wifiPasswordInput = ""; wifiPasswordInput = "";
@@ -123,8 +109,6 @@ PanelWindow {
} }
}
// Password input // Password input
Rectangle { Rectangle {
width: parent.width width: parent.width

View File

@@ -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
}
}
}