forked from Shinonome/dots-hyprland
bouncy button group for toggles
This commit is contained in:
@@ -11,22 +11,12 @@ import Quickshell.Hyprland
|
||||
QuickToggleButton {
|
||||
toggled: Bluetooth.bluetoothEnabled
|
||||
buttonIcon: Bluetooth.bluetoothConnected ? "bluetooth_connected" : Bluetooth.bluetoothEnabled ? "bluetooth" : "bluetooth_disabled"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton | Qt.LeftButton
|
||||
onClicked: (mouse) => {
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
toggleBluetooth.running = true
|
||||
}
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
Hyprland.dispatch(`exec ${ConfigOptions.apps.bluetooth}`)
|
||||
Hyprland.dispatch("global quickshell:sidebarRightClose")
|
||||
|
||||
}
|
||||
}
|
||||
hoverEnabled: false
|
||||
propagateComposedEvents: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
toggleBluetooth.running = true
|
||||
}
|
||||
altAction: () => {
|
||||
Hyprland.dispatch(`exec ${ConfigOptions.apps.bluetooth}`)
|
||||
Hyprland.dispatch("global quickshell:sidebarRightClose")
|
||||
}
|
||||
Process {
|
||||
id: toggleBluetooth
|
||||
|
||||
@@ -17,21 +17,12 @@ QuickToggleButton {
|
||||
Network.networkStrength > 20 ? "network_wifi_1_bar" :
|
||||
"signal_wifi_0_bar"
|
||||
) : "signal_wifi_off"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton | Qt.LeftButton
|
||||
onClicked: (mouse) =>{
|
||||
if (mouse.button === Qt.LeftButton) {
|
||||
toggleNetwork.running = true
|
||||
}
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
Hyprland.dispatch(`exec ${ConfigOptions.apps.network}`)
|
||||
Hyprland.dispatch("global quickshell:sidebarRightClose")
|
||||
}
|
||||
}
|
||||
hoverEnabled: false
|
||||
propagateComposedEvents: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
toggleNetwork.running = true
|
||||
}
|
||||
altAction: () => {
|
||||
Hyprland.dispatch(`exec ${ConfigOptions.apps.network}`)
|
||||
Hyprland.dispatch("global quickshell:sidebarRightClose")
|
||||
}
|
||||
Process {
|
||||
id: toggleNetwork
|
||||
|
||||
@@ -3,17 +3,34 @@ import "root:/modules/common/widgets"
|
||||
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Io
|
||||
|
||||
RippleButton {
|
||||
id: button
|
||||
rippleEnabled: false
|
||||
property string buttonIcon
|
||||
property int clickIndex: parent?.clickIndex ?? -1
|
||||
toggled: false
|
||||
buttonRadius: Appearance?.rounding?.full ?? 9999
|
||||
buttonRadius: Appearance?.rounding?.full
|
||||
buttonRadiusPressed: Appearance?.rounding?.small
|
||||
|
||||
implicitWidth: 40
|
||||
Layout.fillWidth: (clickIndex - 1 <= parent.children.indexOf(button) && parent.children.indexOf(button) <= clickIndex + 1)
|
||||
implicitWidth: button.down ? 60 : 40
|
||||
implicitHeight: 40
|
||||
|
||||
Behavior on implicitWidth {
|
||||
animation: Appearance.animation.clickBounce.numberAnimation.createObject(this)
|
||||
}
|
||||
|
||||
onDownChanged: {
|
||||
if (button.down) {
|
||||
if (button.parent.clickIndex !== undefined) {
|
||||
button.parent.clickIndex = parent.children.indexOf(button)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: MaterialSymbol {
|
||||
anchors.centerIn: parent
|
||||
iconSize: Appearance.font.pixelSize.larger
|
||||
|
||||
Reference in New Issue
Block a user