add option to open tooltips by pressing the mouse button

This commit is contained in:
Firmino Veras
2025-11-14 09:55:06 -03:00
parent 4b8f294a91
commit 2ccdf3b751
10 changed files with 34 additions and 15 deletions
@@ -264,6 +264,9 @@ Singleton {
property bool showUnreadCount: false property bool showUnreadCount: false
} }
} }
property JsonObject tooltips: JsonObject {
property bool clickToShow: false
}
} }
property JsonObject battery: JsonObject { property JsonObject battery: JsonObject {
@@ -16,7 +16,7 @@ MouseArea {
implicitWidth: batteryProgress.implicitWidth implicitWidth: batteryProgress.implicitWidth
implicitHeight: Appearance.sizes.barHeight implicitHeight: Appearance.sizes.barHeight
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
ClippedProgressBar { ClippedProgressBar {
id: batteryProgress id: batteryProgress
@@ -40,8 +40,7 @@ Item {
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
acceptedButtons: Qt.NoButton
ClockWidgetPopup { ClockWidgetPopup {
hoverTarget: mouseArea hoverTarget: mouseArea
@@ -9,7 +9,7 @@ MouseArea {
property bool alwaysShowAllResources: false property bool alwaysShowAllResources: false
implicitWidth: rowLayout.implicitWidth + rowLayout.anchors.leftMargin + rowLayout.anchors.rightMargin implicitWidth: rowLayout.implicitWidth + rowLayout.anchors.leftMargin + rowLayout.anchors.rightMargin
implicitHeight: Appearance.sizes.barHeight implicitHeight: Appearance.sizes.barHeight
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
RowLayout { RowLayout {
id: rowLayout id: rowLayout
@@ -13,15 +13,19 @@ MouseArea {
implicitWidth: rowLayout.implicitWidth + 10 * 2 implicitWidth: rowLayout.implicitWidth + 10 * 2
implicitHeight: Appearance.sizes.barHeight implicitHeight: Appearance.sizes.barHeight
hoverEnabled: true acceptedButtons: Qt.LeftButton | Qt.RightButton
hoverEnabled: !Config.options.bar.tooltips.clickToShow
onPressed: { onPressed: {
Weather.getData(); if (mouse.button === Qt.RightButton) {
Quickshell.execDetached(["notify-send", Weather.getData();
Translation.tr("Weather"), Quickshell.execDetached(["notify-send",
Translation.tr("Refreshing (manually triggered)") Translation.tr("Weather"),
, "-a", "Shell" Translation.tr("Refreshing (manually triggered)")
]) , "-a", "Shell"
])
mouse.accepted = false
}
} }
RowLayout { RowLayout {
@@ -15,7 +15,7 @@ MouseArea {
readonly property bool isLow: percentage <= Config.options.battery.low / 100 readonly property bool isLow: percentage <= Config.options.battery.low / 100
implicitHeight: batteryProgress.implicitHeight implicitHeight: batteryProgress.implicitHeight
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
ClippedProgressBar { ClippedProgressBar {
id: batteryProgress id: batteryProgress
@@ -9,7 +9,7 @@ MouseArea {
property bool alwaysShowAllResources: false property bool alwaysShowAllResources: false
implicitHeight: columnLayout.implicitHeight implicitHeight: columnLayout.implicitHeight
implicitWidth: columnLayout.implicitWidth implicitWidth: columnLayout.implicitWidth
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
ColumnLayout { ColumnLayout {
id: columnLayout id: columnLayout
@@ -33,7 +33,7 @@ Item {
MouseArea { MouseArea {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
Bar.ClockWidgetPopup { Bar.ClockWidgetPopup {
@@ -28,7 +28,7 @@ MouseArea {
} }
acceptedButtons: Qt.MiddleButton | Qt.BackButton | Qt.ForwardButton | Qt.RightButton | Qt.LeftButton acceptedButtons: Qt.MiddleButton | Qt.BackButton | Qt.ForwardButton | Qt.RightButton | Qt.LeftButton
hoverEnabled: true hoverEnabled: !Config.options.bar.tooltips.clickToShow
onPressed: (event) => { onPressed: (event) => {
if (event.button === Qt.MiddleButton) { if (event.button === Qt.MiddleButton) {
activePlayer.togglePlaying(); activePlayer.togglePlaying();
@@ -334,4 +334,17 @@ ContentPage {
} }
} }
} }
ContentSection {
icon: "tooltip"
title: Translation.tr("Tooltips")
ConfigSwitch {
buttonIcon: "web_traffic"
text: Translation.tr("Click to show")
checked: Config.options.bar.tooltips.clickToShow
onCheckedChanged: {
Config.options.bar.tooltips.clickToShow = checked;
}
}
}
} }