make some buttons trigger on mouse down to feel faster

This commit is contained in:
end-4
2025-10-12 16:30:41 +02:00
parent edde61a46c
commit 36b33ba4f1
18 changed files with 35 additions and 34 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ Scope {
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
onPressed: {
popupLoader.active = false
}
@@ -75,7 +75,7 @@ Item {
toggled: root.trayOverflowOpen
property bool containsMouse: hovered
onClicked: root.trayOverflowOpen = !root.trayOverflowOpen
downAction: () => root.trayOverflowOpen = !root.trayOverflowOpen
Layout.fillHeight: !root.vertical
Layout.fillWidth: root.vertical
@@ -48,7 +48,7 @@ PopupWindow {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.BackButton | Qt.RightButton
onClicked: event => {
onPressed: event => {
if ((event.button === Qt.BackButton || event.button === Qt.RightButton) && stackView.depth > 1)
stackView.pop();
}
@@ -152,7 +152,7 @@ PopupWindow {
implicitWidth: contentItem.implicitWidth + horizontalPadding * 2
implicitHeight: 36
onClicked: stackView.pop()
downAction: () => stackView.pop()
contentItem: RowLayout {
anchors {
@@ -15,7 +15,7 @@ MouseArea {
hoverEnabled: true
onClicked: {
onPressed: {
Weather.getData();
Quickshell.execDetached(["notify-send",
Translation.tr("Weather"),
@@ -35,7 +35,7 @@ Rectangle {
RippleButton {
id: parentDirButton
onClicked: root.navigateToDirectory(FileUtils.parentDirectory(root.directory))
downAction: () => root.navigateToDirectory(FileUtils.parentDirectory(root.directory))
contentItem: MaterialSymbol {
text: "drive_folder_upload"
iconSize: Appearance.font.pixelSize.larger
@@ -105,7 +105,7 @@ Rectangle {
RippleButton {
id: dirEditButton
toggled: !root.showBreadcrumb
onClicked: root.showBreadcrumb = !root.showBreadcrumb
downAction: () => root.showBreadcrumb = !root.showBreadcrumb
contentItem: MaterialSymbol {
text: "edit"
iconSize: Appearance.font.pixelSize.larger
@@ -9,7 +9,7 @@ RippleButton {
implicitWidth: 40
implicitHeight: 40
Layout.leftMargin: 8
onClicked: {
downAction: () => {
parent.expanded = !parent.expanded;
}
buttonRadius: Appearance.rounding.full
@@ -32,7 +32,8 @@ TabButton {
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onPressed: (event) => {
onPressed: (event) => {
button.click() // Because the MouseArea already consumed the event
const {x,y} = event
const stateY = buttonBackground.y;
rippleAnim.x = x;
@@ -46,7 +47,6 @@ TabButton {
rippleAnim.restart();
}
onReleased: (event) => {
button.click() // Because the MouseArea already consumed the event
rippleFadeAnim.restart();
}
}
@@ -30,7 +30,8 @@ TabButton {
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onPressed: (event) => {
onPressed: (event) => {
root.click() // Because the MouseArea already consumed the event
const {x,y} = event
const stateY = buttonBackground.y;
rippleAnim.x = x;
@@ -44,7 +45,6 @@ TabButton {
rippleAnim.restart();
}
onReleased: (event) => {
root.click() // Because the MouseArea already consumed the event
rippleFadeAnim.restart();
}
}
@@ -234,7 +234,7 @@ Item { // Player instance
}
TrackChangeButton {
iconName: "skip_previous"
onClicked: root.player?.previous()
downAction: () => root.player?.previous()
}
Item {
id: progressBarContainer
@@ -277,7 +277,7 @@ Item { // Player instance
}
TrackChangeButton {
iconName: "skip_next"
onClicked: root.player?.next()
downAction: () => root.player?.next()
}
}
@@ -289,7 +289,7 @@ Item { // Player instance
property real size: 44
implicitWidth: size
implicitHeight: size
onClicked: root.player.togglePlaying();
downAction: () => root.player.togglePlaying();
buttonRadius: root.player?.isPlaying ? Appearance?.rounding.normal : size / 2
colBackground: root.player?.isPlaying ? blendedColors.colPrimary : blendedColors.colSecondaryContainer
@@ -18,7 +18,7 @@ Scope { // Scope
baseWidth: 40
baseHeight: 40
clickedWidth: baseWidth
clickedHeight: baseHeight + 20
clickedHeight: baseHeight + 10
buttonRadius: Appearance.rounding.normal
}
@@ -84,7 +84,7 @@ Scope { // Scope
VerticalButtonGroup {
OskControlButton { // Pin button
toggled: root.pinned
onClicked: root.pinned = !root.pinned
downAction: () => root.pinned = !root.pinned
contentItem: MaterialSymbol {
text: "keep"
horizontalAlignment: Text.AlignHCenter
@@ -111,7 +111,7 @@ Item {
id: workspaceArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
onPressed: {
if (root.draggingTargetWorkspace === -1) {
GlobalStates.overviewOpen = false
Hyprland.dispatch(`workspace ${workspaceValue}`)
@@ -757,8 +757,8 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
delegate: ApiCommandButton {
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
onClicked: {
if(modelData.sendDirectly) {
downAction: () => {
if (modelData.sendDirectly) {
root.handleInput(commandRepresentation)
} else {
messageInputField.text = commandRepresentation + (modelData.dontAddSpace ? "" : " ")
@@ -525,9 +525,10 @@ Item {
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
hoverEnabled: true
PointingHandInteraction {}
onClicked: {
onPressed: {
nsfwSwitch.checked = !nsfwSwitch.checked
}
}
@@ -566,8 +567,8 @@ Item {
buttonText: commandRepresentation
colBackground: Appearance.colors.colLayer2
onClicked: {
if(modelData.sendDirectly) {
downAction: () => {
if (modelData.sendDirectly) {
root.handleInput(commandRepresentation)
} else {
tagInputField.text = commandRepresentation + " "
@@ -10,7 +10,7 @@ GroupButton {
verticalPadding: 6
baseWidth: contentItem.implicitWidth + horizontalPadding * 2
clickedWidth: baseWidth + 20
clickedWidth: baseWidth + 14
baseHeight: contentItem.implicitHeight + verticalPadding * 2
buttonRadius: down ? Appearance.rounding.verysmall : Appearance.rounding.small
@@ -83,7 +83,7 @@ Rectangle {
Layout.margins: 10
Layout.rightMargin: 0
forceCircle: true
onClicked: {
downAction: () => {
root.setCollapsed(false)
}
contentItem: MaterialSymbol {
@@ -146,7 +146,7 @@ Rectangle {
toggled: root.selectedTab == index
buttonText: modelData.name
buttonIcon: modelData.icon
onClicked: {
onPressed: {
root.selectedTab = index
Persistent.states.sidebar.bottomGroup.tab = index
}
@@ -158,7 +158,7 @@ Rectangle {
anchors.left: parent.left
anchors.top: parent.top
forceCircle: true
onClicked: {
downAction: () => {
root.setCollapsed(true)
}
contentItem: MaterialSymbol {
@@ -50,7 +50,7 @@ Item {
clip: true
buttonText: `${monthShift != 0 ? "• " : ""}${viewingDate.toLocaleDateString(Qt.locale(), "MMMM yyyy")}`
tooltipText: (monthShift === 0) ? "" : Translation.tr("Jump to current month")
onClicked: {
downAction: () => {
monthShift = 0;
}
}
@@ -60,7 +60,7 @@ Item {
}
CalendarHeaderButton {
forceCircle: true
onClicked: {
downAction: () => {
monthShift--;
}
contentItem: MaterialSymbol {
@@ -72,7 +72,7 @@ Item {
}
CalendarHeaderButton {
forceCircle: true
onClicked: {
downAction: () => {
monthShift++;
}
contentItem: MaterialSymbol {
@@ -109,12 +109,12 @@ Item {
AudioDeviceSelectorButton {
Layout.fillWidth: true
input: false
onClicked: root.showDeviceSelectorDialog(input)
downAction: () => root.showDeviceSelectorDialog(input)
}
AudioDeviceSelectorButton {
Layout.fillWidth: true
input: true
onClicked: root.showDeviceSelectorDialog(input)
downAction: () => root.showDeviceSelectorDialog(input)
}
}
}
+2 -2
View File
@@ -172,7 +172,7 @@ ApplicationWindow {
iconText: "edit"
buttonText: Translation.tr("Config file")
expanded: navRail.expanded
onClicked: {
downAction: () => {
Qt.openUrlExternally(`${Directories.config}/illogical-impulse/config.json`);
}
@@ -190,7 +190,7 @@ ApplicationWindow {
required property var index
required property var modelData
toggled: root.currentPage === index
onClicked: root.currentPage = index;
onPressed: root.currentPage = index;
expanded: navRail.expanded
buttonIcon: modelData.icon
buttonIconRotation: modelData.iconRotation || 0