Merge pull request #1997 from tmarti2/hide-tooltip-when-opened

Do not display widget tooltips if the panel is open
This commit is contained in:
Lemmy
2026-03-01 14:38:42 -05:00
committed by GitHub
14 changed files with 93 additions and 46 deletions
+12 -8
View File
@@ -194,20 +194,21 @@ Item {
acceptedButtons: Qt.LeftButton | Qt.RightButton
cursorShape: Qt.PointingHandCursor
onEntered: {
if (root.tooltipContent) {
if (!getBatteryPanel()?.isPanelOpen && root.tooltipContent) {
TooltipService.show(root, root.tooltipContent, BarService.getTooltipDirection(root.screen?.name));
tooltipRefreshTimer.start();
}
tooltipRefreshTimer.start();
}
onExited: {
tooltipRefreshTimer.stop();
TooltipService.hide();
}
onClicked: mouse => {
TooltipService.hide();
if (mouse.button === Qt.RightButton) {
PanelService.showContextMenu(contextMenu, nBattery, screen);
} else {
openBatteryPanel();
toggleBatteryPanel();
}
}
}
@@ -238,22 +239,25 @@ Item {
forceClose: root.displayMode === "icon-only" || !root.isReady
customBackgroundColor: root.isCharging ? Color.mPrimary : ((root.isLowBattery || root.isCriticalBattery) ? Color.mError : "transparent")
customTextIconColor: root.isCharging ? Color.mOnPrimary : ((root.isLowBattery || root.isCriticalBattery) ? Color.mOnError : "transparent")
tooltipText: root.tooltipContent
onClicked: openBatteryPanel()
tooltipText: !getBatteryPanel()?.isPanelOpen ? root.tooltipContent : ""
onClicked: toggleBatteryPanel()
onRightClicked: PanelService.showContextMenu(contextMenu, pill, screen)
}
// ==================== SHARED ====================
function openBatteryPanel() {
function getBatteryPanel() {
var panel = PanelService.getPanel("batteryPanel", screen);
if (panel) {
panel.panelID = {
showPowerProfiles: widgetSettings.showPowerProfiles !== undefined ? widgetSettings.showPowerProfiles : widgetMetadata.showPowerProfiles,
showNoctaliaPerformance: widgetSettings.showNoctaliaPerformance !== undefined ? widgetSettings.showNoctaliaPerformance : widgetMetadata.showNoctaliaPerformance
};
panel.toggle(root);
}
return panel;
}
function toggleBatteryPanel() {
getBatteryPanel()?.toggle(root);
}
}
+3
View File
@@ -110,6 +110,9 @@ Item {
PanelService.showContextMenu(contextMenu, pill, screen);
}
tooltipText: {
if (PanelService.getPanel("bluetoothPanel", screen)?.isPanelOpen) {
return "";
}
if (pill.text !== "") {
return pill.text;
}
+2 -1
View File
@@ -163,7 +163,8 @@ Item {
forceClose: displayMode === "alwaysHide"
tooltipText: {
var monitor = brightnessMonitor;
if (!monitor || !monitor.brightnessControlAvailable || isNaN(monitor.brightness))
var panel = PanelService.getPanel("brightnessPanel", screen);
if (panel?.isPanelOpen || !monitor || !monitor.brightnessControlAvailable || isNaN(monitor.brightness))
return "";
return I18n.tr("tooltips.brightness-at", {
"brightness": Math.round(monitor.brightness * 100)
+7 -1
View File
@@ -49,7 +49,13 @@ NIconButton {
// If we have a custom path and not using distro logo, use the theme icon.
// If using distro logo, don't use theme icon.
icon: (customIconPath === "" && !useDistroLogo) ? customIcon : ""
tooltipText: I18n.tr("tooltips.open-control-center")
tooltipText: {
if (PanelService.getPanel("controlCenterPanel", screen)?.isPanelOpen) {
return "";
} else {
return I18n.tr("tooltips.open-control-center");
}
}
tooltipDirection: BarService.getTooltipDirection(screen?.name)
baseSize: Style.getCapsuleHeightForScreen(screen?.name)
applyUiScale: false
+2 -15
View File
@@ -96,16 +96,6 @@ Item {
}
}
readonly property string tooltipText: {
var text = title;
var controls = [];
controls.push("Left click to open player.");
controls.push("Right click for options.");
if (MediaService.canGoPrevious)
controls.push("Middle click for previous.");
return controls.length ? `${text}\n\n${controls.join("\n")}` : text;
}
// Layout
// For horizontal bars, height is always capsuleHeight (no animation needed to prevent jitter)
// For vertical bars, collapse to 0 when hidden
@@ -398,25 +388,22 @@ Item {
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton | Qt.ForwardButton | Qt.BackButton
onClicked: mouse => {
TooltipService.hide();
if (mouse.button === Qt.LeftButton) {
PanelService.getPanel("mediaPlayerPanel", screen)?.toggle(container);
} else if (mouse.button === Qt.RightButton) {
TooltipService.hide();
PanelService.showContextMenu(contextMenu, container, screen);
} else if (mouse.button === Qt.MiddleButton && hasPlayer) {
MediaService.playPause();
TooltipService.hide();
} else if (mouse.button === Qt.ForwardButton && hasPlayer) {
MediaService.next();
TooltipService.hide();
} else if (mouse.button === Qt.BackButton && hasPlayer) {
MediaService.previous();
TooltipService.hide();
}
}
onEntered: {
if (isVertical || scrollingMode === "never") {
if ((isVertical || scrollingMode === "never") && !PanelService.getPanel("mediaPlayerPanel", screen)?.isPanelOpen) {
TooltipService.show(root, title, BarService.getTooltipDirection(root.screen?.name));
}
}
+13 -7
View File
@@ -143,13 +143,19 @@ Item {
suffix: "%"
forceOpen: displayMode === "alwaysShow"
forceClose: displayMode === "alwaysHide"
tooltipText: I18n.tr("tooltips.microphone-volume-at", {
"volume": (() => {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.inputVolume);
return Math.round(displayVolume * 100);
})()
})
tooltipText: {
if (PanelService.getPanel("audioPanel", screen)?.isPanelOpen) {
return "";
} else {
return I18n.tr("tooltips.microphone-volume-at", {
"volume": (() => {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.inputVolume);
return Math.round(displayVolume * 100);
})()
});
}
}
onWheel: function (delta) {
// As soon as we start scrolling to adjust volume, hide the tooltip
+3
View File
@@ -131,6 +131,9 @@ Item {
PanelService.showContextMenu(contextMenu, pill, screen);
}
tooltipText: {
if (PanelService.getPanel("networkPanel", screen)) {
return "";
}
try {
if (NetworkService.ethernetConnected) {
const d = NetworkService.activeEthernetDetails || ({});
+7 -1
View File
@@ -59,7 +59,13 @@ NIconButton {
applyUiScale: false
customRadius: Style.radiusL
icon: NotificationService.doNotDisturb ? "bell-off" : "bell"
tooltipText: NotificationService.doNotDisturb ? I18n.tr("tooltips.open-notification-history-enable-dnd") : I18n.tr("tooltips.open-notification-history-enable-dnd")
tooltipText: {
if (PanelService.getPanel("notificationHistoryPanel", screen)?.isPanelOpen) {
return "";
} else {
return I18n.tr("tooltips.open-notification-history-enable-dnd");
}
}
tooltipDirection: BarService.getTooltipDirection(screen?.name)
colorBg: Style.capsuleColor
colorFg: Color.resolveColorKey(iconColorKey)
+6 -1
View File
@@ -37,7 +37,12 @@ NIconButton {
applyUiScale: false
customRadius: Style.radiusL
icon: "power"
tooltipText: I18n.tr("tooltips.session-menu")
tooltipText: {
if (PanelService.getPanel("sessionMenuPanel", screen)?.isPanelOpen)
return "";
else
return I18n.tr("tooltips.session-menu");
}
tooltipDirection: BarService.getTooltipDirection(screenName)
colorBg: Style.capsuleColor
colorFg: Color.resolveColorKey(iconColorKey)
+7 -1
View File
@@ -34,7 +34,13 @@ NIconButton {
readonly property color iconColor: Color.resolveColorKey(valueIconColor)
icon: "settings"
tooltipText: !PanelService.getPanel("settingsPanel", screen)?.isPanelOpen ? I18n.tr("tooltips.open-settings") : ""
tooltipText: {
if (PanelService.getPanel("settingsPanel", screen)?.isPanelOpen) {
return "";
} else {
return I18n.tr("tooltips.open-settings");
}
}
tooltipDirection: BarService.getTooltipDirection(screen?.name)
baseSize: Style.getCapsuleHeightForScreen(screen?.name)
applyUiScale: false
+4 -2
View File
@@ -924,8 +924,10 @@ Item {
}
}
onEntered: {
TooltipService.show(root, buildTooltipContent(), BarService.getTooltipDirection(root.screen?.name));
tooltipRefreshTimer.start();
if (!PanelService.getPanel("systemStatsPanel", screen).isPanelOpen) {
TooltipService.show(root, buildTooltipContent(), BarService.getTooltipDirection(root.screen?.name));
tooltipRefreshTimer.start();
}
}
onExited: {
tooltipRefreshTimer.stop();
+7 -1
View File
@@ -349,7 +349,13 @@ Item {
visible: root.drawerEnabled && dropdownItems.length > 0 && BarService.getPillDirection(root)
width: isVertical ? barHeight : capsuleHeight
height: isVertical ? capsuleHeight : barHeight
tooltipText: I18n.tr("tooltips.open-tray-dropdown")
tooltipText: {
if (PanelService.getPanel("trayDrawerPanel", root.screen)?.isPanelOpen) {
return "";
} else {
return I18n.tr("tooltips.open-tray-dropdown");
}
}
tooltipDirection: BarService.getTooltipDirection(root.screen?.name)
baseSize: capsuleHeight
applyUiScale: false
+13 -7
View File
@@ -136,13 +136,19 @@ Item {
suffix: "%"
forceOpen: displayMode === "alwaysShow"
forceClose: displayMode === "alwaysHide"
tooltipText: I18n.tr("tooltips.volume-at", {
"volume": (() => {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.volume);
return Math.round(displayVolume * 100);
})()
})
tooltipText: {
if (PanelService.getPanel("audioPanel", screen)?.isPanelOpen) {
return "";
} else {
I18n.tr("tooltips.volume-at", {
"volume": (() => {
const maxVolume = Settings.data.audio.volumeOverdrive ? 1.5 : 1.0;
const displayVolume = Math.min(maxVolume, AudioService.volume);
return Math.round(displayVolume * 100);
})()
});
}
}
onWheel: function (delta) {
// Hide tooltip as soon as the user starts scrolling to adjust volume
+7 -1
View File
@@ -37,7 +37,13 @@ NIconButton {
applyUiScale: false
customRadius: Style.radiusL
icon: "wallpaper-selector"
tooltipText: I18n.tr("tooltips.wallpaper-selector")
tooltipText: {
if (PanelService.getPanel("wallpaperPanel", screen)?.isPanelOpen) {
return "";
} else {
return I18n.tr("tooltips.wallpaper-selector");
}
}
tooltipDirection: BarService.getTooltipDirection(screen?.name)
colorBg: Style.capsuleColor
colorFg: Color.resolveColorKey(iconColorKey)