Tooltip: different approach to get the current screen.

This commit is contained in:
ItsLemmy
2025-10-03 23:27:07 -04:00
parent b85576653a
commit 86127660fe
33 changed files with 32 additions and 83 deletions
-4
View File
@@ -8,8 +8,6 @@ import qs.Widgets
Item {
id: root
property ShellScreen screen
property string icon: ""
property string text: ""
property string suffix: ""
@@ -46,7 +44,6 @@ Item {
Component {
id: verticalPillComponent
BarPillVertical {
screen: root.screen
icon: root.icon
text: root.text
suffix: root.suffix
@@ -72,7 +69,6 @@ Item {
Component {
id: horizontalPillComponent
BarPillHorizontal {
screen: root.screen
icon: root.icon
text: root.text
suffix: root.suffix
+1 -3
View File
@@ -59,8 +59,6 @@ Item {
Rectangle {
id: pill
property ShellScreen screen: root.screen
width: revealed ? pillMaxWidth : 1
height: pillHeight
@@ -225,7 +223,7 @@ Item {
onEntered: {
hovered = true
root.entered()
TooltipService.show(pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong)
TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong)
if (disableOpen || forceClose) {
return
}
+1 -4
View File
@@ -8,7 +8,6 @@ import qs.Widgets
Item {
id: root
property ShellScreen screen
property string icon: ""
property string text: ""
property string suffix: ""
@@ -70,8 +69,6 @@ Item {
Rectangle {
id: pill
property ShellScreen screen: root.screen
width: revealed ? maxPillWidth : 1
height: revealed ? maxPillHeight : 1
@@ -265,7 +262,7 @@ Item {
onEntered: {
hovered = true
root.entered()
TooltipService.show(pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong)
TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong)
if (disableOpen || forceClose) {
return
}
+1 -1
View File
@@ -329,7 +329,7 @@ Item {
acceptedButtons: Qt.LeftButton
onEntered: {
if ((windowTitle !== "") && (barPosition === "left" || barPosition === "right") || (scrollingMode === "never")) {
TooltipService.show(root, windowTitle, BarService.getTooltipDirection())
TooltipService.show(Screen, root, windowTitle, BarService.getTooltipDirection())
}
}
onExited: {
-1
View File
@@ -87,7 +87,6 @@ Item {
BarPill {
id: pill
screen: root.screen
compact: (Settings.data.bar.density === "compact")
rightOpen: BarService.getPillDirection(root)
icon: testMode ? BatteryService.getIcon(testPercent, testCharging, true) : BatteryService.getIcon(percent, charging, isReady)
-1
View File
@@ -77,7 +77,6 @@ Item {
BarPill {
id: pill
screen: root.screen
compact: (Settings.data.bar.density === "compact")
rightOpen: BarService.getPillDirection(root)
icon: getIcon()
+1 -1
View File
@@ -115,7 +115,7 @@ Rectangle {
hoverEnabled: true
onEntered: {
if (!PanelService.getPanel("calendarPanel")?.active) {
TooltipService.show(root, I18n.tr("clock.tooltip"), BarService.getTooltipDirection())
TooltipService.show(Screen, root, I18n.tr("clock.tooltip"), BarService.getTooltipDirection())
}
}
onExited: {
-1
View File
@@ -47,7 +47,6 @@ Item {
BarPill {
id: pill
screen: root.screen
rightOpen: BarService.getPillDirection(root)
icon: customIcon
text: _dynamicText
-1
View File
@@ -42,7 +42,6 @@ Item {
BarPill {
id: pill
screen: root.screen
anchors.verticalCenter: parent.verticalCenter
compact: (Settings.data.bar.density === "compact")
rightOpen: BarService.getPillDirection(root)
+1 -1
View File
@@ -390,7 +390,7 @@ Item {
onEntered: {
var textToShow = hasActivePlayer ? tooltipText : placeholderText
if ((textToShow !== "") && (barPosition === "left" || barPosition === "right") || (scrollingMode === "never")) {
TooltipService.show(root, textToShow, BarService.getTooltipDirection())
TooltipService.show(Screen, root, textToShow, BarService.getTooltipDirection())
}
}
onExited: {
-1
View File
@@ -90,7 +90,6 @@ Item {
BarPill {
id: pill
screen: root.screen
rightOpen: BarService.getPillDirection(root)
icon: getIcon()
compact: (Settings.data.bar.density === "compact")
+1 -1
View File
@@ -117,7 +117,7 @@ Rectangle {
}
}
}
onEntered: TooltipService.show(taskbarItem, taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown app.", BarService.getTooltipDirection())
onEntered: TooltipService.show(Screen, taskbarItem, taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown app.", BarService.getTooltipDirection())
onExited: TooltipService.hide()
}
}
+1 -1
View File
@@ -140,7 +140,7 @@ Rectangle {
}
onEntered: {
trayPanel.close()
TooltipService.show(trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection())
TooltipService.show(Screen, trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection())
}
onExited: TooltipService.hide()
}
-1
View File
@@ -75,7 +75,6 @@ Item {
BarPill {
id: pill
screen: root.screen
compact: (Settings.data.bar.density === "compact")
rightOpen: BarService.getPillDirection(root)
icon: getIcon()
@@ -10,8 +10,6 @@ import qs.Widgets
NBox {
id: root
property ShellScreen screen
ColumnLayout {
anchors.fill: parent
anchors.margins: Style.marginL * scaling
@@ -282,7 +280,6 @@ NBox {
// Previous button
NIconButton {
icon: "media-prev"
screen: root.screen
tooltipText: I18n.tr("tooltips.previous-media")
visible: MediaService.canGoPrevious
onClicked: MediaService.canGoPrevious ? MediaService.previous() : {}
@@ -291,7 +288,6 @@ NBox {
// Play/Pause button
NIconButton {
icon: MediaService.isPlaying ? "media-pause" : "media-play"
screen: root.screen
tooltipText: MediaService.isPlaying ? I18n.tr("tooltips.pause") : I18n.tr("tooltips.play")
visible: (MediaService.canPlay || MediaService.canPause)
onClicked: (MediaService.canPlay || MediaService.canPause) ? MediaService.playPause() : {}
@@ -300,7 +296,6 @@ NBox {
// Next button
NIconButton {
icon: "media-next"
screen: root.screen
tooltipText: I18n.tr("tooltips.next-media")
visible: MediaService.canGoNext
onClicked: MediaService.canGoNext ? MediaService.next() : {}
@@ -10,7 +10,6 @@ import qs.Widgets
// Power Profiles: performance, balanced, eco
NBox {
property ShellScreen screen
property real spacing: 0
// Centralized service
@@ -27,7 +26,6 @@ NBox {
// Performance
NIconButton {
icon: PowerProfileService.getIcon(PowerProfile.Performance)
screen: root.screen
tooltipText: I18n.tr("tooltips.set-power-profile", {
"profile": PowerProfileService.getName(PowerProfile.Performance)
})
@@ -40,7 +38,6 @@ NBox {
// Balanced
NIconButton {
icon: PowerProfileService.getIcon(PowerProfile.Balanced)
screen: root.screen
tooltipText: I18n.tr("tooltips.set-power-profile", {
"profile": PowerProfileService.getName(PowerProfile.Balanced)
})
@@ -53,7 +50,6 @@ NBox {
// Eco
NIconButton {
icon: PowerProfileService.getIcon(PowerProfile.PowerSaver)
screen: root.screen
tooltipText: I18n.tr("tooltips.set-power-profile", {
"profile": PowerProfileService.getName(PowerProfile.PowerSaver)
})
@@ -14,7 +14,6 @@ import qs.Widgets
NBox {
id: root
property ShellScreen screen
property string uptimeText: "--"
RowLayout {
@@ -59,7 +58,6 @@ NBox {
}
NIconButton {
icon: "settings"
screen: root.screen
tooltipText: I18n.tr("tooltips.open-settings")
onClicked: {
settingsPanel.requestedTab = SettingsPanel.Tab.General
@@ -69,7 +67,6 @@ NBox {
NIconButton {
icon: "power"
screen: root.screen
tooltipText: I18n.tr("tooltips.session-menu")
onClicked: {
sessionMenuPanel.open()
@@ -79,7 +76,6 @@ NBox {
NIconButton {
icon: "close"
screen: root.screen
tooltipText: I18n.tr("tooltips.close")
onClicked: {
controlCenterPanel.close()
@@ -9,8 +9,6 @@ import qs.Widgets
NBox {
id: root
property ShellScreen screen
ColumnLayout {
id: content
anchors.left: parent.left
@@ -10,7 +10,6 @@ import qs.Widgets
// Utilities: record & wallpaper
NBox {
property ShellScreen screen
property real spacing: 0
RowLayout {
@@ -24,7 +23,6 @@ NBox {
// Screen Recorder
NIconButton {
icon: "camera-video"
screen: root.screen
enabled: ScreenRecorderService.isAvailable
tooltipText: ScreenRecorderService.isAvailable ? (ScreenRecorderService.isRecording ? I18n.tr("tooltips.stop-screen-recording") : I18n.tr("tooltips.start-screen-recording")) : I18n.tr("tooltips.screen-recorder-not-installed")
colorBg: ScreenRecorderService.isRecording ? Color.mPrimary : Color.mSurfaceVariant
@@ -44,7 +42,6 @@ NBox {
// Idle Inhibitor
NIconButton {
icon: IdleInhibitorService.isInhibited ? "keep-awake-on" : "keep-awake-off"
screen: root.screen
tooltipText: IdleInhibitorService.isInhibited ? I18n.tr("tooltips.disable-keep-awake") : I18n.tr("tooltips.enable-keep-awake")
colorBg: IdleInhibitorService.isInhibited ? Color.mPrimary : Color.mSurfaceVariant
colorFg: IdleInhibitorService.isInhibited ? Color.mOnPrimary : Color.mPrimary
@@ -57,7 +54,6 @@ NBox {
NIconButton {
visible: Settings.data.wallpaper.enabled
icon: "wallpaper-selector"
screen: root.screen
tooltipText: I18n.tr("tooltips.wallpaper-selector")
onClicked: PanelService.getPanel("wallpaperPanel")?.toggle(this)
onRightClicked: WallpaperService.setRandomWallpaper()
@@ -9,7 +9,6 @@ import qs.Widgets
NBox {
id: root
property ShellScreen screen
readonly property bool weatherReady: (LocationService.data.weather !== null)
ColumnLayout {
@@ -29,13 +29,11 @@ NPanel {
// Cards (consistent inter-card spacing via ColumnLayout spacing)
ProfileCard {
screen: root.screen
Layout.fillWidth: true
Layout.preferredHeight: Math.max(64 * scaling)
}
WeatherCard {
screen: root.screen
Layout.fillWidth: true
Layout.preferredHeight: Math.max(220 * scaling)
}
@@ -48,14 +46,12 @@ NPanel {
// Media card
MediaCard {
screen: root.screen
Layout.fillWidth: true
Layout.fillHeight: true
}
// System monitors combined in one card
SystemMonitorCard {
screen: root.screen
Layout.preferredWidth: Style.baseWidgetSize * 2.625 * scaling
Layout.fillHeight: true
}
@@ -69,7 +65,6 @@ NPanel {
// Power Profiles switcher
PowerProfilesCard {
screen: root.screen
Layout.fillWidth: true
Layout.fillHeight: true
spacing: content.cardSpacing
@@ -77,7 +72,6 @@ NPanel {
// Utilities buttons
UtilitiesCard {
screen: root.screen
Layout.fillWidth: true
Layout.fillHeight: true
spacing: content.cardSpacing
+1 -1
View File
@@ -480,7 +480,7 @@ Variants {
anyAppHovered = true
const appName = appButton.appTitle || appButton.appId || "Unknown"
const tooltipText = appName.length > 40 ? appName.substring(0, 37) + "..." : appName
TooltipService.show(appButton, tooltipText, "top")
TooltipService.show(Screen, appButton, tooltipText, "top")
if (autoHide) {
showTimer.stop()
hideTimer.stop()
@@ -46,7 +46,6 @@ NPanel {
NIconButton {
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
screen: root.screen
tooltipText: Settings.data.notifications.doNotDisturb ? I18n.tr("tooltips.do-not-disturb-enabled") : I18n.tr("tooltips.do-not-disturb-disabled")
baseSize: Style.baseWidgetSize * 0.8
onClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
@@ -54,7 +53,6 @@ NPanel {
NIconButton {
icon: "trash"
screen: root.screen
tooltipText: I18n.tr("tooltips.clear-history")
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
@@ -66,7 +64,6 @@ NPanel {
NIconButton {
icon: "close"
screen: root.screen
tooltipText: I18n.tr("tooltips.close")
baseSize: Style.baseWidgetSize * 0.8
onClicked: root.close()
-1
View File
@@ -288,7 +288,6 @@ NPanel {
NIconButton {
icon: timerActive ? "stop" : "close"
screen: root.screen
tooltipText: timerActive ? I18n.tr("tooltips.cancel-timer") : I18n.tr("tooltips.close")
Layout.alignment: Qt.AlignVCenter
colorBg: timerActive ? Qt.alpha(Color.mError, 0.08) : Color.transparent
@@ -106,7 +106,6 @@ NBox {
NIconButton {
icon: "add"
colorBg: Color.mPrimary
colorFg: Color.mOnPrimary
colorBgHover: Color.mSecondary
+2 -1
View File
@@ -10,12 +10,13 @@ import qs.Widgets
ColumnLayout {
id: root
spacing: Style.marginL * scaling
property string latestVersion: GitHubService.latestVersion
property string currentVersion: UpdateService.currentVersion
property var contributors: GitHubService.contributors
spacing: Style.marginL * scaling
NHeader {
label: I18n.tr("settings.about.noctalia.section.label")
description: I18n.tr("settings.about.noctalia.section.description")
+2 -2
View File
@@ -1,7 +1,6 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Shapes
import Quickshell.Io
import qs.Commons
import qs.Services
@@ -9,7 +8,6 @@ import qs.Widgets
ColumnLayout {
id: root
spacing: Style.marginL * scaling
// Cache for scheme JSON (can be flat or {dark, light})
property var schemeColorsCache: ({})
@@ -18,6 +16,8 @@ ColumnLayout {
property real cardScaleLow: 0.95
property real cardScaleHigh: 1.0
spacing: Style.marginL * scaling
// Helper function to extract scheme name from path
function extractSchemeName(schemePath) {
var pathParts = schemePath.split("/")
+1
View File
@@ -8,6 +8,7 @@ import qs.Widgets
ColumnLayout {
id: root
spacing: Style.marginL * scaling
// Helper functions to update arrays immutably
+2 -1
View File
@@ -9,10 +9,11 @@ import qs.Widgets
ColumnLayout {
id: root
spacing: Style.marginL * scaling
property string specificFolderMonitorName: ""
spacing: Style.marginL * scaling
NHeader {
label: I18n.tr("settings.wallpaper.settings.section.label")
description: I18n.tr("settings.wallpaper.settings.section.description")
+12 -19
View File
@@ -8,6 +8,10 @@ import qs.Widgets
PopupWindow {
id: root
property real scaling: 1.0
property int screenWidth: 0
property int screenHeight: 0
property string text: ""
property string direction: "auto" // "auto", "left", "right", "top", "bottom"
property int margin: Style.marginXS // distance from target
@@ -15,7 +19,7 @@ PopupWindow {
property int delay: 0
property int hideDelay: 0
property int maxWidth: 320
property real scaling: 1.0
property int animationDuration: Style.animationFast
property real animationScale: 0.85
@@ -106,11 +110,15 @@ PopupWindow {
}
// Function to show tooltip
function show(target, tipText, customDirection, showDelay) {
if (!target || !tipText || tipText === "")
function show(screen, target, tipText, customDirection, showDelay) {
if (!screen || !target || !tipText || tipText === "")
return
delay = showDelay
root.scaling = ScalingService.getScreenScaleByName(screen.name)
root.screenWidth = screen.width
root.screenHeight = screen.height
root.delay = showDelay
// Stop any running timers and animations
hideTimer.stop()
@@ -144,21 +152,6 @@ PopupWindow {
return
}
// Get screen dimensions - try multiple methods
var screenWidth = Screen.width
var screenHeight = Screen.height
// Try to get screen from target item
if (targetItem) {
if (targetItem.screen) {
screenWidth = targetItem.screen.width
screenHeight = targetItem.screen.height
scaling = ScalingService.getScreenScale(targetItem.screen)
} else {
Logger.warn("Tooltip", "Could not get screen scale for targetItem:", targetItem)
}
}
// Calculate tooltip dimensions
const tipWidth = Math.min(tooltipText.implicitWidth + (padding * 2 * scaling), maxWidth * scaling)
root.implicitWidth = tipWidth
+3 -3
View File
@@ -15,9 +15,9 @@ Singleton {
Tooltip {}
}
function show(target, text, direction, delay) {
function show(screen, target, text, direction, delay) {
// Don't create if no text
if (!target || !text) {
if (!screen || !target || !text) {
Logger.log("Tooltip", "No target or text")
return
}
@@ -74,7 +74,7 @@ Singleton {
})
// Show the tooltip
newTooltip.show(target, text, direction || "auto", delay || Style.tooltipDelay)
newTooltip.show(screen, target, text, direction || "auto", delay || Style.tooltipDelay)
return newTooltip
} else {
+1 -1
View File
@@ -138,7 +138,7 @@ Rectangle {
onEntered: {
root.hovered = true
if (tooltipText) {
TooltipService.show(root, root.tooltipText)
TooltipService.show(Screen, root, root.tooltipText)
}
}
onExited: {
+1 -2
View File
@@ -7,7 +7,6 @@ import qs.Services
Rectangle {
id: root
property ShellScreen screen
property real baseSize: Style.baseWidgetSize
property string icon
@@ -74,7 +73,7 @@ Rectangle {
onEntered: {
hovering = root.enabled ? true : false
if (tooltipText) {
TooltipService.show(parent, tooltipText, tooltipDirection)
TooltipService.show(Screen, parent, tooltipText, tooltipDirection)
}
root.entered()
}