mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,9 @@ Item {
|
||||
PanelService.showContextMenu(contextMenu, pill, screen);
|
||||
}
|
||||
tooltipText: {
|
||||
if (PanelService.getPanel("bluetoothPanel", screen)?.isPanelOpen) {
|
||||
return "";
|
||||
}
|
||||
if (pill.text !== "") {
|
||||
return pill.text;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 || ({});
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user