mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(tooltips): added support for string vs array content everywhere
This commit is contained in:
@@ -12,7 +12,7 @@ Item {
|
|||||||
property string icon: ""
|
property string icon: ""
|
||||||
property string text: ""
|
property string text: ""
|
||||||
property string suffix: ""
|
property string suffix: ""
|
||||||
property var tooltipText: ""
|
property var tooltipText
|
||||||
property bool autoHide: false
|
property bool autoHide: false
|
||||||
property bool forceOpen: false
|
property bool forceOpen: false
|
||||||
property bool forceClose: false
|
property bool forceClose: false
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Item {
|
|||||||
property string icon: ""
|
property string icon: ""
|
||||||
property string text: ""
|
property string text: ""
|
||||||
property string suffix: ""
|
property string suffix: ""
|
||||||
property var tooltipText: ""
|
property var tooltipText
|
||||||
property bool autoHide: false
|
property bool autoHide: false
|
||||||
property bool forceOpen: false
|
property bool forceOpen: false
|
||||||
property bool forceClose: false
|
property bool forceClose: false
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Item {
|
|||||||
property string icon: ""
|
property string icon: ""
|
||||||
property string text: ""
|
property string text: ""
|
||||||
property string suffix: ""
|
property string suffix: ""
|
||||||
property var tooltipText: ""
|
property var tooltipText
|
||||||
property bool autoHide: false
|
property bool autoHide: false
|
||||||
property bool forceOpen: false
|
property bool forceOpen: false
|
||||||
property bool forceClose: false
|
property bool forceClose: false
|
||||||
|
|||||||
+5
-5
@@ -10,7 +10,7 @@ Rectangle {
|
|||||||
// Public properties
|
// Public properties
|
||||||
property string text: ""
|
property string text: ""
|
||||||
property string icon: ""
|
property string icon: ""
|
||||||
property string tooltipText
|
property var tooltipText
|
||||||
property color backgroundColor: Color.mPrimary
|
property color backgroundColor: Color.mPrimary
|
||||||
property color textColor: Color.mOnPrimary
|
property color textColor: Color.mOnPrimary
|
||||||
property color hoverColor: Color.mHover
|
property color hoverColor: Color.mHover
|
||||||
@@ -142,19 +142,19 @@ Rectangle {
|
|||||||
onEntered: {
|
onEntered: {
|
||||||
root.hovered = true;
|
root.hovered = true;
|
||||||
root.entered();
|
root.entered();
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.show(root, root.tooltipText);
|
TooltipService.show(root, root.tooltipText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
root.hovered = false;
|
root.hovered = false;
|
||||||
root.exited();
|
root.exited();
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onPressed: mouse => {
|
onPressed: mouse => {
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
if (mouse.button === Qt.LeftButton) {
|
if (mouse.button === Qt.LeftButton) {
|
||||||
@@ -168,7 +168,7 @@ Rectangle {
|
|||||||
|
|
||||||
onCanceled: {
|
onCanceled: {
|
||||||
root.hovered = false;
|
root.hovered = false;
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ Item {
|
|||||||
property string suffix: "%"
|
property string suffix: "%"
|
||||||
property real contentScale: 1.0
|
property real contentScale: 1.0
|
||||||
property color fillColor: Color.mPrimary
|
property color fillColor: Color.mPrimary
|
||||||
property string tooltipText: ""
|
property var tooltipText
|
||||||
property string tooltipDirection: "top"
|
property string tooltipDirection: "top"
|
||||||
|
|
||||||
// Arc geometry constants
|
// Arc geometry constants
|
||||||
@@ -151,12 +151,12 @@ Item {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.show(root, root.tooltipText, root.tooltipDirection);
|
TooltipService.show(root, root.tooltipText, root.tooltipDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Slider {
|
|||||||
property var cutoutColor: Color.mSurface
|
property var cutoutColor: Color.mSurface
|
||||||
property bool snapAlways: true
|
property bool snapAlways: true
|
||||||
property real widthRatio: 0.7
|
property real widthRatio: 0.7
|
||||||
property string tooltipText
|
property var tooltipText
|
||||||
property string tooltipDirection: "auto"
|
property string tooltipDirection: "auto"
|
||||||
property bool hovering: false
|
property bool hovering: false
|
||||||
property color topColor: "white"
|
property color topColor: "white"
|
||||||
@@ -212,14 +212,14 @@ Slider {
|
|||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
root.hovering = true;
|
root.hovering = true;
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.show(knob, root.tooltipText, root.tooltipDirection);
|
TooltipService.show(knob, root.tooltipText, root.tooltipDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
root.hovering = false;
|
root.hovering = false;
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ Slider {
|
|||||||
Connections {
|
Connections {
|
||||||
target: root
|
target: root
|
||||||
function onPressedChanged() {
|
function onPressedChanged() {
|
||||||
if (root.pressed && root.tooltipText) {
|
if (root.pressed && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Item {
|
|||||||
property bool applyUiScale: true
|
property bool applyUiScale: true
|
||||||
|
|
||||||
property string icon
|
property string icon
|
||||||
property string tooltipText
|
property var tooltipText
|
||||||
property string tooltipDirection: "auto"
|
property string tooltipDirection: "auto"
|
||||||
property bool allowClickWhenDisabled: false
|
property bool allowClickWhenDisabled: false
|
||||||
property bool handleWheel: false
|
property bool handleWheel: false
|
||||||
@@ -96,20 +96,20 @@ Item {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
hovering = root.enabled ? true : false;
|
hovering = root.enabled ? true : false;
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.show(root, tooltipText, tooltipDirection);
|
TooltipService.show(root, tooltipText, tooltipDirection);
|
||||||
}
|
}
|
||||||
root.entered();
|
root.entered();
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
hovering = false;
|
hovering = false;
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide(root);
|
TooltipService.hide(root);
|
||||||
}
|
}
|
||||||
root.exited();
|
root.exited();
|
||||||
}
|
}
|
||||||
onClicked: mouse => {
|
onClicked: mouse => {
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide(root);
|
TooltipService.hide(root);
|
||||||
}
|
}
|
||||||
if (!root.enabled && !allowClickWhenDisabled) {
|
if (!root.enabled && !allowClickWhenDisabled) {
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ Rectangle {
|
|||||||
// Public properties
|
// Public properties
|
||||||
property real baseSize: Style.baseWidgetSize
|
property real baseSize: Style.baseWidgetSize
|
||||||
property bool applyUiScale: true
|
property bool applyUiScale: true
|
||||||
property string icon: ""
|
property string icon
|
||||||
property string tooltipText: ""
|
property var tooltipText
|
||||||
property string tooltipDirection: "auto"
|
property string tooltipDirection: "auto"
|
||||||
property bool allowClickWhenDisabled: false
|
property bool allowClickWhenDisabled: false
|
||||||
property bool hot: false
|
property bool hot: false
|
||||||
@@ -106,7 +106,7 @@ Rectangle {
|
|||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
hovering = root.enabled ? true : false;
|
hovering = root.enabled ? true : false;
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.show(parent, tooltipText, tooltipDirection);
|
TooltipService.show(parent, tooltipText, tooltipDirection);
|
||||||
}
|
}
|
||||||
root.entered();
|
root.entered();
|
||||||
@@ -114,7 +114,7 @@ Rectangle {
|
|||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
hovering = false;
|
hovering = false;
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
root.exited();
|
root.exited();
|
||||||
@@ -124,7 +124,7 @@ Rectangle {
|
|||||||
if (root.enabled) {
|
if (root.enabled) {
|
||||||
root.pressed = true;
|
root.pressed = true;
|
||||||
}
|
}
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ Rectangle {
|
|||||||
root.hovering = false;
|
root.hovering = false;
|
||||||
root.pressed = false;
|
root.pressed = false;
|
||||||
root.scale = 1.0;
|
root.scale = 1.0;
|
||||||
if (tooltipText) {
|
if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Rectangle {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool show: false
|
property bool show: false
|
||||||
property string tooltipText: ""
|
property var tooltipText
|
||||||
|
|
||||||
implicitWidth: root.show ? 6 * Style.uiScaleRatio : 0
|
implicitWidth: root.show ? 6 * Style.uiScaleRatio : 0
|
||||||
implicitHeight: root.show ? 6 * Style.uiScaleRatio : 0
|
implicitHeight: root.show ? 6 * Style.uiScaleRatio : 0
|
||||||
@@ -26,20 +26,20 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
enabled: root.show && root.tooltipText !== ""
|
enabled: root.show && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
acceptedButtons: Qt.NoButton
|
acceptedButtons: Qt.NoButton
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.show(root, root.tooltipText);
|
TooltipService.show(root, root.tooltipText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -11,7 +11,7 @@ Slider {
|
|||||||
property var cutoutColor: Color.mSurface
|
property var cutoutColor: Color.mSurface
|
||||||
property bool snapAlways: true
|
property bool snapAlways: true
|
||||||
property real heightRatio: 0.7
|
property real heightRatio: 0.7
|
||||||
property string tooltipText
|
property var tooltipText
|
||||||
property string tooltipDirection: "auto"
|
property string tooltipDirection: "auto"
|
||||||
property bool hovering: false
|
property bool hovering: false
|
||||||
|
|
||||||
@@ -226,14 +226,14 @@ Slider {
|
|||||||
|
|
||||||
onEntered: {
|
onEntered: {
|
||||||
root.hovering = true;
|
root.hovering = true;
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.show(knob, root.tooltipText, root.tooltipDirection);
|
TooltipService.show(knob, root.tooltipText, root.tooltipDirection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onExited: {
|
onExited: {
|
||||||
root.hovering = false;
|
root.hovering = false;
|
||||||
if (root.tooltipText) {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,7 +243,7 @@ Slider {
|
|||||||
Connections {
|
Connections {
|
||||||
target: root
|
target: root
|
||||||
function onPressedChanged() {
|
function onPressedChanged() {
|
||||||
if (root.pressed && root.tooltipText) {
|
if (root.pressed && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ import qs.Widgets
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// Public properties
|
|
||||||
// Public properties
|
// Public properties
|
||||||
property string text: ""
|
property string text: ""
|
||||||
property string icon: ""
|
property string icon: ""
|
||||||
property string tooltipText: ""
|
property var tooltipText
|
||||||
property bool checked: false
|
property bool checked: false
|
||||||
property int tabIndex: 0
|
property int tabIndex: 0
|
||||||
property real pointSize: Style.fontSizeM
|
property real pointSize: Style.fontSizeM
|
||||||
@@ -94,7 +93,7 @@ Rectangle {
|
|||||||
id: tooltipTimer
|
id: tooltipTimer
|
||||||
interval: 500
|
interval: 500
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
if (root.isHovered && root.tooltipText !== "") {
|
if (root.isHovered && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.show(root, root.tooltipText);
|
TooltipService.show(root, root.tooltipText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,14 +105,14 @@ Rectangle {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onEntered: {
|
onEntered: {
|
||||||
root.isHovered = true;
|
root.isHovered = true;
|
||||||
if (root.tooltipText !== "") {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
tooltipTimer.start();
|
tooltipTimer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
root.isHovered = false;
|
root.isHovered = false;
|
||||||
tooltipTimer.stop();
|
tooltipTimer.stop();
|
||||||
if (root.tooltipText !== "") {
|
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
|
||||||
TooltipService.hide();
|
TooltipService.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user