mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 05:55:37 -05:00
refactor: create DankActionButton and implement
This commit is contained in:
@@ -605,59 +605,33 @@ 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"
|
onClicked: {
|
||||||
size: 20
|
viewMode = "list";
|
||||||
color: viewMode === "list" ? Theme.primary : Theme.surfaceText
|
Prefs.setAppLauncherViewMode("list");
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: listViewArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
viewMode = "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"
|
onClicked: {
|
||||||
size: 20
|
viewMode = "grid";
|
||||||
color: viewMode === "grid" ? Theme.primary : Theme.surfaceText
|
Prefs.setAppLauncherViewMode("grid");
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: gridViewArea
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: {
|
|
||||||
viewMode = "grid";
|
|
||||||
Prefs.setAppLauncherViewMode("grid");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,70 +217,26 @@ 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
|
||||||
|
onClicked: showClearConfirmation = true
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
onClicked: clipboardHistory.hide()
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,39 +352,17 @@ 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
|
onClicked: {
|
||||||
name: "settings"
|
controlCenterVisible = false;
|
||||||
size: Theme.iconSize - 2
|
settingsPopup.settingsVisible = true;
|
||||||
color: Theme.surfaceText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,31 +122,15 @@ 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)
|
||||||
|
onClicked: {
|
||||||
DankIcon {
|
inputDialog.cancelled();
|
||||||
anchors.centerIn: parent
|
hideDialog();
|
||||||
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: {
|
|
||||||
inputDialog.cancelled();
|
|
||||||
hideDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,30 +78,14 @@ 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)
|
||||||
|
onClicked: {
|
||||||
DankIcon {
|
powerMenuVisible = false;
|
||||||
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: {
|
|
||||||
powerMenuVisible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,28 +204,13 @@ 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 {
|
onClicked: settingsPopup.settingsVisible = false
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,31 +96,15 @@ 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)
|
||||||
|
onClicked: {
|
||||||
DankIcon {
|
wifiPasswordDialogVisible = false;
|
||||||
anchors.centerIn: parent
|
wifiPasswordInput = "";
|
||||||
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: {
|
|
||||||
wifiPasswordDialogVisible = false;
|
|
||||||
wifiPasswordInput = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
44
Widgets/DankActionButton.qml
Normal file
44
Widgets/DankActionButton.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user