tooltips: use builtin text prop, fix crash (#1956)

This commit is contained in:
end-4
2025-09-20 11:55:38 +02:00
parent 3a01dad945
commit 429cb50ff7
36 changed files with 116 additions and 103 deletions
@@ -24,7 +24,7 @@ Revealer { // Scroll hint
// StyledToolTip { // StyledToolTip {
// extraVisibleCondition: tooltipText.length > 0 // extraVisibleCondition: tooltipText.length > 0
// content: tooltipText // text: tooltipText
// } // }
ColumnLayout { ColumnLayout {
@@ -31,10 +31,10 @@ MouseArea {
event.accepted = true; event.accepted = true;
} }
onEntered: { onEntered: {
tooltip.content = item.tooltipTitle.length > 0 ? item.tooltipTitle tooltip.text = item.tooltipTitle.length > 0 ? item.tooltipTitle
: (item.title.length > 0 ? item.title : item.id); : (item.title.length > 0 ? item.title : item.id);
if (item.tooltipDescription.length > 0) tooltip.content += " • " + item.tooltipDescription; if (item.tooltipDescription.length > 0) tooltip.text += " • " + item.tooltipDescription;
if (Config.options.bar.tray.showItemId) tooltip.content += "\n[" + item.id + "]"; if (Config.options.bar.tray.showItemId) tooltip.text += "\n[" + item.id + "]";
} }
Loader { Loader {
@@ -113,7 +113,7 @@ Rectangle {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Edit directory") text: Translation.tr("Edit directory")
} }
} }
} }
@@ -32,7 +32,7 @@ ColumnLayout {
StyledToolTip { StyledToolTip {
extraVisibleCondition: false extraVisibleCondition: false
alternativeVisibleCondition: infoMouseArea.containsMouse alternativeVisibleCondition: infoMouseArea.containsMouse
content: root.tooltip text: root.tooltip
} }
} }
} }
@@ -6,7 +6,7 @@ StyledText {
property real iconSize: Appearance?.font.pixelSize.small ?? 16 property real iconSize: Appearance?.font.pixelSize.small ?? 16
property real fill: 0 property real fill: 0
property real truncatedFill: Math.round(fill * 100) / 100 // Reduce memory consumption spikes from constant font remapping property real truncatedFill: Math.round(fill * 100) / 100 // Reduce memory consumption spikes from constant font remapping
renderType: Text.CurveRendering renderType: fill !== 0 ? Text.CurveRendering : Text.NativeRendering
font { font {
hintingPreference: Font.PreferFullHinting hintingPreference: Font.PreferFullHinting
family: Appearance?.font.family.iconMaterial ?? "Material Symbols Rounded" family: Appearance?.font.family.iconMaterial ?? "Material Symbols Rounded"
@@ -215,7 +215,7 @@ MouseArea { // Notification group area
altAction: () => { root.toggleExpanded() } altAction: () => { root.toggleExpanded() }
StyledToolTip { StyledToolTip {
content: Translation.tr("Tip: right-clicking a group\nalso expands it") text: Translation.tr("Tip: right-clicking a group\nalso expands it")
} }
} }
} }
@@ -209,7 +209,7 @@ Item { // Notification item area
textFormat: Text.RichText textFormat: Text.RichText
text: { text: {
return `<style>img{max-width:${300 /* binding to notificationBodyText.width would cause a binding loop */}px;}</style>` + return `<style>img{max-width:${300 /* binding to notificationBodyText.width would cause a binding loop */}px;}</style>` +
`${processNotificationBody(notificationObject.body, notificationObject.appName || notificationObject.summary).replace(/\n/g, "<br/>")}` `${processNotificationBody(notificationObject.body, notificationObject.appName || notificationObject.summary).replace(/\n/g, "<br/>")}`
} }
onLinkActivated: (link) => { onLinkActivated: (link) => {
@@ -149,7 +149,7 @@ Slider {
StyledToolTip { StyledToolTip {
extraVisibleCondition: root.pressed extraVisibleCondition: root.pressed
content: root.tooltipContent text: root.tooltipContent
} }
} }
} }
@@ -6,55 +6,20 @@ import QtQuick.Layouts
ToolTip { ToolTip {
id: root id: root
property string content
property bool extraVisibleCondition: true property bool extraVisibleCondition: true
property bool alternativeVisibleCondition: false property bool alternativeVisibleCondition: false
property bool internalVisibleCondition: { readonly property bool internalVisibleCondition: (extraVisibleCondition && (parent.hovered === undefined || parent?.hovered)) || alternativeVisibleCondition
const ans = (extraVisibleCondition && (parent.hovered === undefined || parent?.hovered)) || alternativeVisibleCondition
return ans
}
verticalPadding: 5 verticalPadding: 5
horizontalPadding: 10 horizontalPadding: 10
opacity: internalVisibleCondition ? 1 : 0
visible: opacity > 0
Behavior on opacity {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
background: null background: null
contentItem: Item { visible: internalVisibleCondition
id: contentItemBackground
implicitWidth: tooltipTextObject.width + 2 * root.horizontalPadding
implicitHeight: tooltipTextObject.height + 2 * root.verticalPadding
Rectangle { contentItem: StyledToolTipContent {
id: backgroundRectangle id: contentItem
anchors.bottom: contentItemBackground.bottom text: root.text
anchors.horizontalCenter: contentItemBackground.horizontalCenter shown: root.internalVisibleCondition
color: Appearance?.colors.colTooltip ?? "#3C4043" horizontalPadding: root.horizontalPadding
radius: Appearance?.rounding.verysmall ?? 7 verticalPadding: root.verticalPadding
width: internalVisibleCondition ? (tooltipTextObject.width + 2 * padding) : 0
height: internalVisibleCondition ? (tooltipTextObject.height + 2 * padding) : 0
clip: true
Behavior on width {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
Behavior on height {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
StyledText {
id: tooltipTextObject
anchors.centerIn: parent
text: content
font.pixelSize: Appearance?.font.pixelSize.smaller ?? 14
font.hintingPreference: Font.PreferNoHinting // Prevent shaky text
color: Appearance?.colors.colOnTooltip ?? "#FFFFFF"
wrapMode: Text.Wrap
}
}
} }
} }
@@ -0,0 +1,48 @@
import qs.modules.common
import qs.modules.common.widgets
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item {
id: root
required property string text
property bool shown: true
property real horizontalPadding: 10
property real verticalPadding: 5
implicitWidth: tooltipTextObject.implicitWidth + 2 * root.horizontalPadding
implicitHeight: tooltipTextObject.implicitHeight + 2 * root.verticalPadding
Rectangle {
id: backgroundRectangle
anchors.bottom: root.bottom
anchors.horizontalCenter: root.horizontalCenter
color: Appearance?.colors.colTooltip ?? "#3C4043"
radius: Appearance?.rounding.verysmall ?? 7
opacity: shown ? 1 : 0
implicitWidth: shown ? (tooltipTextObject.implicitWidth + 2 * padding) : 0
implicitHeight: shown ? (tooltipTextObject.implicitHeight + 2 * padding) : 0
clip: true
Behavior on implicitWidth {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
Behavior on implicitHeight {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
Behavior on opacity {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
StyledText {
id: tooltipTextObject
anchors.centerIn: parent
text: root.text
font.pixelSize: Appearance?.font.pixelSize.smaller ?? 14
font.hintingPreference: Font.PreferNoHinting // Prevent shaky text
color: Appearance?.colors.colOnTooltip ?? "#FFFFFF"
wrapMode: Text.Wrap
}
}
}
@@ -235,7 +235,7 @@ Item {
StyledToolTip { StyledToolTip {
extraVisibleCondition: false extraVisibleCondition: false
alternativeVisibleCondition: dragArea.containsMouse && !window.Drag.active alternativeVisibleCondition: dragArea.containsMouse && !window.Drag.active
content: `${windowData.title}\n[${windowData.class}] ${windowData.xwayland ? "[XWayland] " : ""}\n` text: `${windowData.title}\n[${windowData.class}] ${windowData.xwayland ? "[XWayland] " : ""}\n`
} }
} }
} }
@@ -266,7 +266,7 @@ RippleButton {
onClicked: modelData.execute() onClicked: modelData.execute()
StyledToolTip { StyledToolTip {
content: modelData.name text: modelData.name
} }
} }
} }
@@ -52,7 +52,7 @@ RippleButton {
} }
StyledToolTip { StyledToolTip {
content: buttonText text: buttonText
} }
} }
@@ -27,7 +27,7 @@ ContentPage {
Config.options.appearance.wallpaperTheming.enableQtApps = checked; Config.options.appearance.wallpaperTheming.enableQtApps = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Shell & utilities theming must also be enabled") text: Translation.tr("Shell & utilities theming must also be enabled")
} }
} }
ConfigSwitch { ConfigSwitch {
@@ -38,7 +38,7 @@ ContentPage {
Config.options.appearance.wallpaperTheming.enableTerminal = checked; Config.options.appearance.wallpaperTheming.enableTerminal = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Shell & utilities theming must also be enabled") text: Translation.tr("Shell & utilities theming must also be enabled")
} }
} }
ConfigRow { ConfigRow {
@@ -51,7 +51,7 @@ ContentPage {
Config.options.appearance.wallpaperTheming.terminalGenerationProps.forceDarkMode= checked; Config.options.appearance.wallpaperTheming.terminalGenerationProps.forceDarkMode= checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Ignored if terminal theming is not enabled") text: Translation.tr("Ignored if terminal theming is not enabled")
} }
} }
} }
@@ -21,7 +21,7 @@ ContentPage {
Config.options.audio.protection.enable = checked; Config.options.audio.protection.enable = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Prevents abrupt increments and restricts volume limit") text: Translation.tr("Prevents abrupt increments and restricts volume limit")
} }
} }
ConfigRow { ConfigRow {
@@ -85,7 +85,7 @@ ContentPage {
Config.options.battery.automaticSuspend = checked; Config.options.battery.automaticSuspend = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Automatically suspends the system when battery is low") text: Translation.tr("Automatically suspends the system when battery is low")
} }
} }
ConfigSpinBox { ConfigSpinBox {
@@ -168,7 +168,7 @@ ContentPage {
Config.options.sidebar.keepRightSidebarLoaded = checked; Config.options.sidebar.keepRightSidebarLoaded = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("When enabled keeps the content of the right sidebar loaded to reduce the delay when opening,\nat the cost of around 15MB of consistent RAM usage. Delay significance depends on your system's performance.\nUsing a custom kernel like linux-cachyos might help") text: Translation.tr("When enabled keeps the content of the right sidebar loaded to reduce the delay when opening,\nat the cost of around 15MB of consistent RAM usage. Delay significance depends on your system's performance.\nUsing a custom kernel like linux-cachyos might help")
} }
} }
@@ -192,7 +192,7 @@ ContentPage {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("When this is off you'll have to click") text: Translation.tr("When this is off you'll have to click")
} }
} }
} }
@@ -206,7 +206,7 @@ ContentPage {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Place the corners to trigger at the bottom") text: Translation.tr("Place the corners to trigger at the bottom")
} }
} }
ConfigSwitch { ConfigSwitch {
@@ -217,7 +217,7 @@ ContentPage {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Brightness and volume") text: Translation.tr("Brightness and volume")
} }
} }
} }
@@ -326,7 +326,7 @@ ContentPage {
Config.options.screenshotTool.showContentRegions = checked; Config.options.screenshotTool.showContentRegions = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Such regions could be images or parts of the screen that have some containment.\nMight not always be accurate.\nThis is done with an image processing algorithm run locally and no AI is used.") text: Translation.tr("Such regions could be images or parts of the screen that have some containment.\nMight not always be accurate.\nThis is done with an image processing algorithm run locally and no AI is used.")
} }
} }
} }
@@ -99,14 +99,14 @@ ContentPage {
konachanWallProc.running = true; konachanWallProc.running = true;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers") text: Translation.tr("Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers")
} }
} }
RippleButtonWithIcon { RippleButtonWithIcon {
Layout.fillWidth: true Layout.fillWidth: true
materialIcon: "wallpaper" materialIcon: "wallpaper"
StyledToolTip { StyledToolTip {
content: Translation.tr("Pick wallpaper image on your system") text: Translation.tr("Pick wallpaper image on your system")
} }
onClicked: { onClicked: {
Quickshell.execDetached(`${Directories.wallpaperSwitchScriptPath}`); Quickshell.execDetached(`${Directories.wallpaperSwitchScriptPath}`);
@@ -161,7 +161,7 @@ ContentPage {
Config.options.appearance.transparency.enable = checked; Config.options.appearance.transparency.enable = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Might look ass. Unsupported.") text: Translation.tr("Might look ass. Unsupported.")
} }
} }
} }
@@ -69,7 +69,7 @@ ContentPage {
Config.options.search.sloppy = checked; Config.options.search.sloppy = checked;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Could be better if you make a ton of typos,\nbut results can be weird and might not work with acronyms\n(e.g. \"GIMP\" might not give you the paint program)") text: Translation.tr("Could be better if you make a ton of typos,\nbut results can be weird and might not work with acronyms\n(e.g. \"GIMP\" might not give you the paint program)")
} }
} }
@@ -257,7 +257,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
} }
StyledToolTip { StyledToolTip {
content: statusItem.description text: statusItem.description
extraVisibleCondition: false extraVisibleCondition: false
alternativeVisibleCondition: statusItem.containsMouse alternativeVisibleCondition: statusItem.containsMouse
} }
@@ -41,7 +41,7 @@ Item { // Model indicator
id: toolTip id: toolTip
extraVisibleCondition: false extraVisibleCondition: false
alternativeVisibleCondition: mouseArea.containsMouse // Show tooltip when hovered alternativeVisibleCondition: mouseArea.containsMouse // Show tooltip when hovered
content: root.tooltipText text: root.tooltipText
} }
} }
} }
@@ -164,7 +164,7 @@ Rectangle {
text: "visibility_off" text: "visibility_off"
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Not visible to model") text: Translation.tr("Not visible to model")
} }
} }
@@ -191,7 +191,7 @@ Rectangle {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Copy") text: Translation.tr("Copy")
} }
} }
AiMessageControlButton { AiMessageControlButton {
@@ -206,7 +206,7 @@ Rectangle {
} }
} }
StyledToolTip { StyledToolTip {
content: root.editing ? Translation.tr("Save") : Translation.tr("Edit") text: root.editing ? Translation.tr("Save") : Translation.tr("Edit")
} }
} }
AiMessageControlButton { AiMessageControlButton {
@@ -217,7 +217,7 @@ Rectangle {
root.renderMarkdown = !root.renderMarkdown root.renderMarkdown = !root.renderMarkdown
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("View Markdown source") text: Translation.tr("View Markdown source")
} }
} }
AiMessageControlButton { AiMessageControlButton {
@@ -227,7 +227,7 @@ Rectangle {
Ai.removeMessage(root.messageIndex) Ai.removeMessage(root.messageIndex)
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Delete") text: Translation.tr("Delete")
} }
} }
} }
@@ -84,7 +84,7 @@ ColumnLayout {
} }
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Copy code") text: Translation.tr("Copy code")
} }
} }
AiMessageControlButton { AiMessageControlButton {
@@ -114,7 +114,7 @@ ColumnLayout {
} }
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Save to Downloads") text: Translation.tr("Save to Downloads")
} }
} }
} }
@@ -41,7 +41,7 @@ Button {
} }
StyledToolTip { StyledToolTip {
content: `${StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)}` text: `${StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)}`
} }
padding: 0 padding: 0
@@ -88,7 +88,7 @@ Item {
Quickshell.reload(true); Quickshell.reload(true);
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Reload Hyprland & Quickshell") text: Translation.tr("Reload Hyprland & Quickshell")
} }
} }
QuickToggleButton { QuickToggleButton {
@@ -99,7 +99,7 @@ Item {
Quickshell.execDetached(["qs", "-p", root.settingsQmlPath]); Quickshell.execDetached(["qs", "-p", root.settingsQmlPath]);
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Settings") text: Translation.tr("Settings")
} }
} }
QuickToggleButton { QuickToggleButton {
@@ -109,7 +109,7 @@ Item {
GlobalStates.sessionOpen = true; GlobalStates.sessionOpen = true;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Session") text: Translation.tr("Session")
} }
} }
} }
@@ -30,7 +30,7 @@ RippleButton {
} }
StyledToolTip { StyledToolTip {
content: tooltipText text: tooltipText
extraVisibleCondition: tooltipText.length > 0 extraVisibleCondition: tooltipText.length > 0
} }
} }
@@ -21,7 +21,7 @@ QuickToggleButton {
GlobalStates.sidebarRightOpen = false GlobalStates.sidebarRightOpen = false
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("%1 | Right-click to configure").arg( text: Translation.tr("%1 | Right-click to configure").arg(
(BluetoothStatus.firstActiveDevice?.name ?? Translation.tr("Bluetooth")) (BluetoothStatus.firstActiveDevice?.name ?? Translation.tr("Bluetooth"))
+ (BluetoothStatus.activeDeviceCount > 1 ? ` +${BluetoothStatus.activeDeviceCount - 1}` : "") + (BluetoothStatus.activeDeviceCount > 1 ? ` +${BluetoothStatus.activeDeviceCount - 1}` : "")
) )
@@ -87,6 +87,6 @@ QuickToggleButton {
} }
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Cloudflare WARP (1.1.1.1)") text: Translation.tr("Cloudflare WARP (1.1.1.1)")
} }
} }
@@ -26,6 +26,6 @@ QuickToggleButton {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("EasyEffects | Right-click to configure") text: Translation.tr("EasyEffects | Right-click to configure")
} }
} }
@@ -26,6 +26,6 @@ QuickToggleButton {
} }
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Game mode") text: Translation.tr("Game mode")
} }
} }
@@ -10,7 +10,7 @@ QuickToggleButton {
Idle.toggleInhibit() Idle.toggleInhibit()
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Keep system awake") text: Translation.tr("Keep system awake")
} }
} }
@@ -18,6 +18,6 @@ QuickToggleButton {
GlobalStates.sidebarRightOpen = false GlobalStates.sidebarRightOpen = false
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("%1 | Right-click to configure").arg(Network.networkName) text: Translation.tr("%1 | Right-click to configure").arg(Network.networkName)
} }
} }
@@ -23,6 +23,6 @@ QuickToggleButton {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Night Light | Right-click to toggle Auto mode") text: Translation.tr("Night Light | Right-click to toggle Auto mode")
} }
} }
@@ -26,7 +26,7 @@ RippleButton {
} }
StyledToolTip { StyledToolTip {
content: tooltipText text: tooltipText
extraVisibleCondition: tooltipText.length > 0 extraVisibleCondition: tooltipText.length > 0
} }
} }
@@ -334,7 +334,7 @@ MouseArea {
iconSize: Appearance.font.pixelSize.larger iconSize: Appearance.font.pixelSize.larger
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Use the system file picker instead\nRight-click to make this the default behavior") text: Translation.tr("Use the system file picker instead\nRight-click to make this the default behavior")
} }
} }
@@ -352,7 +352,7 @@ MouseArea {
iconSize: Appearance.font.pixelSize.larger iconSize: Appearance.font.pixelSize.larger
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Pick random from this folder") text: Translation.tr("Pick random from this folder")
} }
} }
@@ -366,7 +366,7 @@ MouseArea {
iconSize: Appearance.font.pixelSize.larger iconSize: Appearance.font.pixelSize.larger
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Click to toggle light/dark mode\n(applied when wallpaper is chosen)") text: Translation.tr("Click to toggle light/dark mode\n(applied when wallpaper is chosen)")
} }
} }
@@ -417,7 +417,7 @@ MouseArea {
iconSize: Appearance.font.pixelSize.larger iconSize: Appearance.font.pixelSize.larger
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Cancel wallpaper selection") text: Translation.tr("Cancel wallpaper selection")
} }
} }
} }
+1 -1
View File
@@ -177,7 +177,7 @@ ApplicationWindow {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Open the shell config file.\nIf the button doesn't work or doesn't open in your favorite editor,\nyou can manually open ~/.config/illogical-impulse/config.json") text: Translation.tr("Open the shell config file.\nIf the button doesn't work or doesn't open in your favorite editor,\nyou can manually open ~/.config/illogical-impulse/config.json")
} }
} }
+3 -3
View File
@@ -111,7 +111,7 @@ ApplicationWindow {
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Tip: Close a window with Super+Q") text: Translation.tr("Tip: Close a window with Super+Q")
} }
} }
} }
@@ -250,13 +250,13 @@ ApplicationWindow {
konachanWallProc.running = true; konachanWallProc.running = true;
} }
StyledToolTip { StyledToolTip {
content: Translation.tr("Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers") text: Translation.tr("Random SFW Anime wallpaper from Konachan\nImage is saved to ~/Pictures/Wallpapers")
} }
} }
RippleButtonWithIcon { RippleButtonWithIcon {
materialIcon: "wallpaper" materialIcon: "wallpaper"
StyledToolTip { StyledToolTip {
content: Translation.tr("Pick wallpaper image on your system") text: Translation.tr("Pick wallpaper image on your system")
} }
onClicked: { onClicked: {
Quickshell.execDetached([`${Directories.wallpaperSwitchScriptPath}`]); Quickshell.execDetached([`${Directories.wallpaperSwitchScriptPath}`]);