forked from Shinonome/dots-hyprland
sidebar: make quick toggle behave more similar to on android
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ AndroidQuickToggleButton {
|
|||||||
statusText: toggled ? Translation.tr("Unmuted") : Translation.tr("Muted")
|
statusText: toggled ? Translation.tr("Unmuted") : Translation.tr("Muted")
|
||||||
toggled: !Audio.sink?.audio?.muted
|
toggled: !Audio.sink?.audio?.muted
|
||||||
buttonIcon: Audio.sink?.audio?.muted ? "volume_off" : "volume_up"
|
buttonIcon: Audio.sink?.audio?.muted ? "volume_off" : "volume_up"
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
Audio.sink.audio.muted = !Audio.sink.audio.muted
|
Audio.sink.audio.muted = !Audio.sink.audio.muted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ AndroidQuickToggleButton {
|
|||||||
|
|
||||||
toggled: BluetoothStatus.enabled
|
toggled: BluetoothStatus.enabled
|
||||||
buttonIcon: BluetoothStatus.connected ? "bluetooth_connected" : BluetoothStatus.enabled ? "bluetooth" : "bluetooth_disabled"
|
buttonIcon: BluetoothStatus.connected ? "bluetooth_connected" : BluetoothStatus.enabled ? "bluetooth" : "bluetooth_disabled"
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
Bluetooth.defaultAdapter.enabled = !Bluetooth.defaultAdapter?.enabled
|
Bluetooth.defaultAdapter.enabled = !Bluetooth.defaultAdapter?.enabled
|
||||||
}
|
}
|
||||||
altAction: () => {
|
altAction: () => {
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ AndroidQuickToggleButton {
|
|||||||
toggled: false
|
toggled: false
|
||||||
buttonIcon: "cloud_lock"
|
buttonIcon: "cloud_lock"
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
if (toggled) {
|
if (toggled) {
|
||||||
root.toggled = false
|
root.toggled = false
|
||||||
Quickshell.execDetached(["warp-cli", "disconnect"])
|
Quickshell.execDetached(["warp-cli", "disconnect"])
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ AndroidQuickToggleButton {
|
|||||||
toggled: false
|
toggled: false
|
||||||
buttonIcon: "colorize"
|
buttonIcon: "colorize"
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
GlobalStates.sidebarRightOpen = false;
|
GlobalStates.sidebarRightOpen = false;
|
||||||
delayedActionTimer.start()
|
delayedActionTimer.start()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ AndroidQuickToggleButton {
|
|||||||
toggled: Appearance.m3colors.darkmode
|
toggled: Appearance.m3colors.darkmode
|
||||||
buttonIcon: "contrast"
|
buttonIcon: "contrast"
|
||||||
|
|
||||||
onClicked: event => {
|
mainAction: () => {
|
||||||
if (Appearance.m3colors.darkmode) {
|
if (Appearance.m3colors.darkmode) {
|
||||||
Quickshell.execDetached([Directories.wallpaperSwitchScriptPath, "--mode", "light", "--noswitch"]);
|
Quickshell.execDetached([Directories.wallpaperSwitchScriptPath, "--mode", "light", "--noswitch"]);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ AndroidQuickToggleButton {
|
|||||||
EasyEffects.fetchActiveState()
|
EasyEffects.fetchActiveState()
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
EasyEffects.toggle()
|
EasyEffects.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ AndroidQuickToggleButton {
|
|||||||
toggled: toggled
|
toggled: toggled
|
||||||
buttonIcon: "gamepad"
|
buttonIcon: "gamepad"
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
root.toggled = !root.toggled
|
root.toggled = !root.toggled
|
||||||
if (root.toggled) {
|
if (root.toggled) {
|
||||||
Quickshell.execDetached(["bash", "-c", `hyprctl --batch "keyword animations:enabled 0; keyword decoration:shadow:enabled 0; keyword decoration:blur:enabled 0; keyword general:gaps_in 0; keyword general:gaps_out 0; keyword general:border_size 1; keyword decoration:rounding 0; keyword general:allow_tearing 1"`])
|
Quickshell.execDetached(["bash", "-c", `hyprctl --batch "keyword animations:enabled 0; keyword decoration:shadow:enabled 0; keyword decoration:blur:enabled 0; keyword general:gaps_in 0; keyword general:gaps_out 0; keyword general:border_size 1; keyword decoration:rounding 0; keyword general:allow_tearing 1"`])
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ AndroidQuickToggleButton {
|
|||||||
|
|
||||||
toggled: Idle.inhibit
|
toggled: Idle.inhibit
|
||||||
buttonIcon: "coffee"
|
buttonIcon: "coffee"
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
Idle.toggleInhibit()
|
Idle.toggleInhibit()
|
||||||
}
|
}
|
||||||
StyledToolTip {
|
StyledToolTip {
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ AndroidQuickToggleButton {
|
|||||||
statusText: toggled ? Translation.tr("Enabled") : Translation.tr("Muted")
|
statusText: toggled ? Translation.tr("Enabled") : Translation.tr("Muted")
|
||||||
toggled: !Audio.source?.audio?.muted
|
toggled: !Audio.source?.audio?.muted
|
||||||
buttonIcon: Audio.source?.audio?.muted ? "mic_off" : "mic"
|
buttonIcon: Audio.source?.audio?.muted ? "mic_off" : "mic"
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
Audio.source.audio.muted = !Audio.source.audio.muted
|
Audio.source.audio.muted = !Audio.source.audio.muted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ AndroidQuickToggleButton {
|
|||||||
text: Translation.tr("Recognize music | Right-click to toggle source")
|
text: Translation.tr("Recognize music | Right-click to toggle source")
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
SongRec.toggleRunning()
|
SongRec.toggleRunning()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ AndroidQuickToggleButton {
|
|||||||
|
|
||||||
toggled: Network.wifiStatus !== "disabled"
|
toggled: Network.wifiStatus !== "disabled"
|
||||||
buttonIcon: Network.materialSymbol
|
buttonIcon: Network.materialSymbol
|
||||||
onClicked: Network.toggleWifi()
|
mainAction: () => Network.toggleWifi()
|
||||||
altAction: () => {
|
altAction: () => {
|
||||||
root.openMenu()
|
root.openMenu()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -14,7 +14,8 @@ AndroidQuickToggleButton {
|
|||||||
|
|
||||||
toggled: Hyprsunset.active
|
toggled: Hyprsunset.active
|
||||||
buttonIcon: auto ? "night_sight_auto" : "bedtime"
|
buttonIcon: auto ? "night_sight_auto" : "bedtime"
|
||||||
onClicked: {
|
|
||||||
|
mainAction: () => {
|
||||||
Hyprsunset.toggle()
|
Hyprsunset.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ AndroidQuickToggleButton {
|
|||||||
toggled: !Notifications.silent
|
toggled: !Notifications.silent
|
||||||
buttonIcon: toggled ? "notifications_active" : "notifications_paused"
|
buttonIcon: toggled ? "notifications_active" : "notifications_paused"
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
Notifications.silent = !Notifications.silent;
|
Notifications.silent = !Notifications.silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -11,7 +11,8 @@ AndroidQuickToggleButton {
|
|||||||
name: Translation.tr("Virtual Keyboard")
|
name: Translation.tr("Virtual Keyboard")
|
||||||
toggled: GlobalStates.oskOpen
|
toggled: GlobalStates.oskOpen
|
||||||
buttonIcon: toggled ? "keyboard_hide" : "keyboard"
|
buttonIcon: toggled ? "keyboard_hide" : "keyboard"
|
||||||
onClicked: {
|
|
||||||
|
mainAction: () => {
|
||||||
GlobalStates.oskOpen = !GlobalStates.oskOpen
|
GlobalStates.oskOpen = !GlobalStates.oskOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ AndroidQuickToggleButton {
|
|||||||
case PowerProfile.Performance: return "Performance"
|
case PowerProfile.Performance: return "Performance"
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: (event) => {
|
mainAction: () => {
|
||||||
if (PowerProfiles.hasPerformanceProfile) {
|
if (PowerProfiles.hasPerformanceProfile) {
|
||||||
switch(PowerProfiles.profile) {
|
switch(PowerProfiles.profile) {
|
||||||
case PowerProfile.PowerSaver: PowerProfiles.profile = PowerProfile.Balanced
|
case PowerProfile.PowerSaver: PowerProfiles.profile = PowerProfile.Balanced
|
||||||
|
|||||||
+54
-20
@@ -13,6 +13,7 @@ GroupButton {
|
|||||||
required property bool expandedSize
|
required property bool expandedSize
|
||||||
required property string buttonIcon
|
required property string buttonIcon
|
||||||
required property string name
|
required property string name
|
||||||
|
required property var mainAction
|
||||||
property string statusText: toggled ? Translation.tr("Active") : Translation.tr("Inactive")
|
property string statusText: toggled ? Translation.tr("Active") : Translation.tr("Inactive")
|
||||||
|
|
||||||
required property real baseCellWidth
|
required property real baseCellWidth
|
||||||
@@ -54,6 +55,11 @@ GroupButton {
|
|||||||
property color colText: (toggled && !(altAction && expandedSize)) ? Appearance.colors.colOnPrimary : Appearance.colors.colOnLayer2
|
property color colText: (toggled && !(altAction && expandedSize)) ? Appearance.colors.colOnPrimary : Appearance.colors.colOnLayer2
|
||||||
property color colIcon: expandedSize ? (root.toggled ? Appearance.colors.colOnPrimary : Appearance.colors.colOnLayer3) : colText
|
property color colIcon: expandedSize ? (root.toggled ? Appearance.colors.colOnPrimary : Appearance.colors.colOnLayer3) : colText
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (root.expandedSize && root.altAction) root.altAction();
|
||||||
|
else root.mainAction();
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: RowLayout {
|
contentItem: RowLayout {
|
||||||
id: contentItem
|
id: contentItem
|
||||||
spacing: 4
|
spacing: 4
|
||||||
@@ -64,35 +70,63 @@ GroupButton {
|
|||||||
rightMargin: root.horizontalPadding
|
rightMargin: root.horizontalPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
// Icon
|
||||||
|
MouseArea {
|
||||||
|
id: iconMouseArea
|
||||||
|
hoverEnabled: true
|
||||||
|
acceptedButtons: (root.expandedSize && root.altAction) ? Qt.LeftButton : Qt.NoButton
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.topMargin: root.verticalPadding
|
Layout.topMargin: root.verticalPadding
|
||||||
Layout.bottomMargin: root.verticalPadding
|
Layout.bottomMargin: root.verticalPadding
|
||||||
implicitWidth: height
|
implicitHeight: iconBackground.implicitHeight
|
||||||
radius: root.radius - root.verticalPadding
|
implicitWidth: iconBackground.implicitWidth
|
||||||
color: {
|
cursorShape: Qt.PointingHandCursor
|
||||||
const baseColor = root.toggled ? Appearance.colors.colPrimary : Appearance.colors.colLayer3
|
|
||||||
const transparentizeAmount = (root.altAction && root.expandedSize) ? 0 : 1
|
|
||||||
return ColorUtils.transparentize(baseColor, transparentizeAmount)
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on radius {
|
onClicked: root.mainAction()
|
||||||
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
|
|
||||||
}
|
|
||||||
Behavior on color {
|
|
||||||
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
MaterialSymbol {
|
Rectangle {
|
||||||
anchors.centerIn: parent
|
id: iconBackground
|
||||||
fill: root.toggled ? 1 : 0
|
anchors.fill: parent
|
||||||
iconSize: root.expandedSize ? 22 : 24
|
implicitWidth: height
|
||||||
color: root.colIcon
|
radius: root.radius - root.verticalPadding
|
||||||
text: root.buttonIcon
|
color: {
|
||||||
|
const baseColor = root.toggled ? Appearance.colors.colPrimary : Appearance.colors.colLayer3
|
||||||
|
const transparentizeAmount = (root.altAction && root.expandedSize) ? 0 : 1
|
||||||
|
return ColorUtils.transparentize(baseColor, transparentizeAmount)
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on radius {
|
||||||
|
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
|
||||||
|
}
|
||||||
|
Behavior on color {
|
||||||
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
fill: root.toggled ? 1 : 0
|
||||||
|
iconSize: root.expandedSize ? 22 : 24
|
||||||
|
color: root.colIcon
|
||||||
|
text: root.buttonIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
// State layer
|
||||||
|
Loader {
|
||||||
|
anchors.fill: parent
|
||||||
|
active: (root.expandedSize && root.altAction)
|
||||||
|
sourceComponent: Rectangle {
|
||||||
|
radius: iconBackground.radius
|
||||||
|
color: ColorUtils.transparentize(root.colIcon, iconMouseArea.containsPress ? 0.88 : iconMouseArea.containsMouse ? 0.95 : 1)
|
||||||
|
Behavior on color {
|
||||||
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Text column for expanded size
|
||||||
Loader {
|
Loader {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ AndroidQuickToggleButton {
|
|||||||
toggled: false
|
toggled: false
|
||||||
buttonIcon: "screenshot_region"
|
buttonIcon: "screenshot_region"
|
||||||
|
|
||||||
onClicked: {
|
mainAction: () => {
|
||||||
GlobalStates.sidebarRightOpen = false;
|
GlobalStates.sidebarRightOpen = false;
|
||||||
delayedActionTimer.start()
|
delayedActionTimer.start()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user