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 {
// extraVisibleCondition: tooltipText.length > 0
// content: tooltipText
// text: tooltipText
// }
ColumnLayout {
@@ -31,10 +31,10 @@ MouseArea {
event.accepted = true;
}
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);
if (item.tooltipDescription.length > 0) tooltip.content += " • " + item.tooltipDescription;
if (Config.options.bar.tray.showItemId) tooltip.content += "\n[" + item.id + "]";
if (item.tooltipDescription.length > 0) tooltip.text += " • " + item.tooltipDescription;
if (Config.options.bar.tray.showItemId) tooltip.text += "\n[" + item.id + "]";
}
Loader {
@@ -113,7 +113,7 @@ Rectangle {
}
StyledToolTip {
content: Translation.tr("Edit directory")
text: Translation.tr("Edit directory")
}
}
}
@@ -32,7 +32,7 @@ ColumnLayout {
StyledToolTip {
extraVisibleCondition: false
alternativeVisibleCondition: infoMouseArea.containsMouse
content: root.tooltip
text: root.tooltip
}
}
}
@@ -6,7 +6,7 @@ StyledText {
property real iconSize: Appearance?.font.pixelSize.small ?? 16
property real fill: 0
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 {
hintingPreference: Font.PreferFullHinting
family: Appearance?.font.family.iconMaterial ?? "Material Symbols Rounded"
@@ -215,7 +215,7 @@ MouseArea { // Notification group area
altAction: () => { root.toggleExpanded() }
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
text: {
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) => {
@@ -149,7 +149,7 @@ Slider {
StyledToolTip {
extraVisibleCondition: root.pressed
content: root.tooltipContent
text: root.tooltipContent
}
}
}
@@ -6,55 +6,20 @@ import QtQuick.Layouts
ToolTip {
id: root
property string content
property bool extraVisibleCondition: true
property bool alternativeVisibleCondition: false
property bool internalVisibleCondition: {
const ans = (extraVisibleCondition && (parent.hovered === undefined || parent?.hovered)) || alternativeVisibleCondition
return ans
}
readonly property bool internalVisibleCondition: (extraVisibleCondition && (parent.hovered === undefined || parent?.hovered)) || alternativeVisibleCondition
verticalPadding: 5
horizontalPadding: 10
opacity: internalVisibleCondition ? 1 : 0
visible: opacity > 0
Behavior on opacity {
animation: Appearance?.animation.elementMoveFast.numberAnimation.createObject(this)
}
horizontalPadding: 10
background: null
visible: internalVisibleCondition
contentItem: Item {
id: contentItemBackground
implicitWidth: tooltipTextObject.width + 2 * root.horizontalPadding
implicitHeight: tooltipTextObject.height + 2 * root.verticalPadding
Rectangle {
id: backgroundRectangle
anchors.bottom: contentItemBackground.bottom
anchors.horizontalCenter: contentItemBackground.horizontalCenter
color: Appearance?.colors.colTooltip ?? "#3C4043"
radius: Appearance?.rounding.verysmall ?? 7
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
}
}
contentItem: StyledToolTipContent {
id: contentItem
text: root.text
shown: root.internalVisibleCondition
horizontalPadding: root.horizontalPadding
verticalPadding: root.verticalPadding
}
}
}
@@ -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 {
extraVisibleCondition: false
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()
StyledToolTip {
content: modelData.name
text: modelData.name
}
}
}
@@ -52,7 +52,7 @@ RippleButton {
}
StyledToolTip {
content: buttonText
text: buttonText
}
}
@@ -27,7 +27,7 @@ ContentPage {
Config.options.appearance.wallpaperTheming.enableQtApps = checked;
}
StyledToolTip {
content: Translation.tr("Shell & utilities theming must also be enabled")
text: Translation.tr("Shell & utilities theming must also be enabled")
}
}
ConfigSwitch {
@@ -38,7 +38,7 @@ ContentPage {
Config.options.appearance.wallpaperTheming.enableTerminal = checked;
}
StyledToolTip {
content: Translation.tr("Shell & utilities theming must also be enabled")
text: Translation.tr("Shell & utilities theming must also be enabled")
}
}
ConfigRow {
@@ -51,7 +51,7 @@ ContentPage {
Config.options.appearance.wallpaperTheming.terminalGenerationProps.forceDarkMode= checked;
}
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;
}
StyledToolTip {
content: Translation.tr("Prevents abrupt increments and restricts volume limit")
text: Translation.tr("Prevents abrupt increments and restricts volume limit")
}
}
ConfigRow {
@@ -85,7 +85,7 @@ ContentPage {
Config.options.battery.automaticSuspend = checked;
}
StyledToolTip {
content: Translation.tr("Automatically suspends the system when battery is low")
text: Translation.tr("Automatically suspends the system when battery is low")
}
}
ConfigSpinBox {
@@ -168,7 +168,7 @@ ContentPage {
Config.options.sidebar.keepRightSidebarLoaded = checked;
}
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 {
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 {
content: Translation.tr("Place the corners to trigger at the bottom")
text: Translation.tr("Place the corners to trigger at the bottom")
}
}
ConfigSwitch {
@@ -217,7 +217,7 @@ ContentPage {
}
StyledToolTip {
content: Translation.tr("Brightness and volume")
text: Translation.tr("Brightness and volume")
}
}
}
@@ -326,7 +326,7 @@ ContentPage {
Config.options.screenshotTool.showContentRegions = checked;
}
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;
}
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 {
Layout.fillWidth: true
materialIcon: "wallpaper"
StyledToolTip {
content: Translation.tr("Pick wallpaper image on your system")
text: Translation.tr("Pick wallpaper image on your system")
}
onClicked: {
Quickshell.execDetached(`${Directories.wallpaperSwitchScriptPath}`);
@@ -161,7 +161,7 @@ ContentPage {
Config.options.appearance.transparency.enable = checked;
}
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;
}
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 {
content: statusItem.description
text: statusItem.description
extraVisibleCondition: false
alternativeVisibleCondition: statusItem.containsMouse
}
@@ -41,7 +41,7 @@ Item { // Model indicator
id: toolTip
extraVisibleCondition: false
alternativeVisibleCondition: mouseArea.containsMouse // Show tooltip when hovered
content: root.tooltipText
text: root.tooltipText
}
}
}
@@ -164,7 +164,7 @@ Rectangle {
text: "visibility_off"
}
StyledToolTip {
content: Translation.tr("Not visible to model")
text: Translation.tr("Not visible to model")
}
}
@@ -191,7 +191,7 @@ Rectangle {
}
StyledToolTip {
content: Translation.tr("Copy")
text: Translation.tr("Copy")
}
}
AiMessageControlButton {
@@ -206,7 +206,7 @@ Rectangle {
}
}
StyledToolTip {
content: root.editing ? Translation.tr("Save") : Translation.tr("Edit")
text: root.editing ? Translation.tr("Save") : Translation.tr("Edit")
}
}
AiMessageControlButton {
@@ -217,7 +217,7 @@ Rectangle {
root.renderMarkdown = !root.renderMarkdown
}
StyledToolTip {
content: Translation.tr("View Markdown source")
text: Translation.tr("View Markdown source")
}
}
AiMessageControlButton {
@@ -227,7 +227,7 @@ Rectangle {
Ai.removeMessage(root.messageIndex)
}
StyledToolTip {
content: Translation.tr("Delete")
text: Translation.tr("Delete")
}
}
}
@@ -84,7 +84,7 @@ ColumnLayout {
}
}
StyledToolTip {
content: Translation.tr("Copy code")
text: Translation.tr("Copy code")
}
}
AiMessageControlButton {
@@ -114,7 +114,7 @@ ColumnLayout {
}
}
StyledToolTip {
content: Translation.tr("Save to Downloads")
text: Translation.tr("Save to Downloads")
}
}
}
@@ -41,7 +41,7 @@ Button {
}
StyledToolTip {
content: `${StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)}`
text: `${StringUtils.wordWrap(root.imageData.tags, root.maxTagStringLineLength)}`
}
padding: 0
@@ -88,7 +88,7 @@ Item {
Quickshell.reload(true);
}
StyledToolTip {
content: Translation.tr("Reload Hyprland & Quickshell")
text: Translation.tr("Reload Hyprland & Quickshell")
}
}
QuickToggleButton {
@@ -99,7 +99,7 @@ Item {
Quickshell.execDetached(["qs", "-p", root.settingsQmlPath]);
}
StyledToolTip {
content: Translation.tr("Settings")
text: Translation.tr("Settings")
}
}
QuickToggleButton {
@@ -109,7 +109,7 @@ Item {
GlobalStates.sessionOpen = true;
}
StyledToolTip {
content: Translation.tr("Session")
text: Translation.tr("Session")
}
}
}
@@ -30,7 +30,7 @@ RippleButton {
}
StyledToolTip {
content: tooltipText
text: tooltipText
extraVisibleCondition: tooltipText.length > 0
}
}
@@ -21,7 +21,7 @@ QuickToggleButton {
GlobalStates.sidebarRightOpen = false
}
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.activeDeviceCount > 1 ? ` +${BluetoothStatus.activeDeviceCount - 1}` : "")
)
@@ -87,6 +87,6 @@ QuickToggleButton {
}
}
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 {
content: Translation.tr("EasyEffects | Right-click to configure")
text: Translation.tr("EasyEffects | Right-click to configure")
}
}
@@ -26,6 +26,6 @@ QuickToggleButton {
}
}
StyledToolTip {
content: Translation.tr("Game mode")
text: Translation.tr("Game mode")
}
}
@@ -10,7 +10,7 @@ QuickToggleButton {
Idle.toggleInhibit()
}
StyledToolTip {
content: Translation.tr("Keep system awake")
text: Translation.tr("Keep system awake")
}
}
@@ -18,6 +18,6 @@ QuickToggleButton {
GlobalStates.sidebarRightOpen = false
}
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 {
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 {
content: tooltipText
text: tooltipText
extraVisibleCondition: tooltipText.length > 0
}
}
@@ -334,7 +334,7 @@ MouseArea {
iconSize: Appearance.font.pixelSize.larger
}
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
}
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
}
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
}
StyledToolTip {
content: Translation.tr("Cancel wallpaper selection")
text: Translation.tr("Cancel wallpaper selection")
}
}
}
+1 -1
View File
@@ -177,7 +177,7 @@ ApplicationWindow {
}
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 {
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;
}
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 {
materialIcon: "wallpaper"
StyledToolTip {
content: Translation.tr("Pick wallpaper image on your system")
text: Translation.tr("Pick wallpaper image on your system")
}
onClicked: {
Quickshell.execDetached([`${Directories.wallpaperSwitchScriptPath}`]);