Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/ToolTip.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org> 0003 SPDX-FileCopyrightText: 2017 The Qt Company Ltd. 0004 0005 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later 0006 */ 0007 0008 0009 import QtQuick 2.6 0010 import QtQuick.Controls 2.15 as Controls 0011 import QtQuick.Templates 2.15 as T 0012 import QtQuick.Layouts 1.15 0013 import org.kde.kirigami 2.12 as Kirigami 0014 0015 T.ToolTip { 0016 id: control 0017 0018 palette: Kirigami.Theme.inherit ? Kirigami.Theme.palette : undefined 0019 Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip 0020 Kirigami.Theme.inherit: false 0021 0022 x: parent ? Math.round((parent.width - implicitWidth) / 2) : 0 0023 y: -implicitHeight - 3 0024 0025 // Always show the tooltip on top of everything else 0026 z: 999 0027 0028 // Math.ceil() prevents blurry edges and prevents unnecessary text wrapping 0029 // (vs using floor or sometimes round). 0030 implicitWidth: Math.ceil(contentItem.implicitWidth) + leftPadding + rightPadding 0031 implicitHeight: Math.ceil(contentItem.implicitHeight) + topPadding + bottomPadding 0032 0033 margins: 6 0034 padding: 6 0035 0036 visible: parent && text.length > 0 && (Kirigami.Settings.tabletMode ? parent.pressed : (parent.hasOwnProperty("hovered") ? parent.hovered : parent.hasOwnProperty("containsMouse") && parent.containsMouse)) 0037 delay: Kirigami.Settings.tabletMode ? Qt.styleHints.mousePressAndHoldInterval : Kirigami.Units.toolTipDelay 0038 // Never time out while being hovered; it's annoying 0039 timeout: -1 0040 0041 closePolicy: T.Popup.CloseOnEscape | T.Popup.CloseOnPressOutsideParent | T.Popup.CloseOnReleaseOutsideParent 0042 0043 enter: Transition { 0044 NumberAnimation { 0045 property: "opacity" 0046 from: 0.0 0047 to: 1.0 0048 duration: Kirigami.Units.longDuration 0049 easing.type: Easing.OutCubic 0050 } 0051 } 0052 0053 exit: Transition { 0054 NumberAnimation { 0055 property: "opacity" 0056 from: 1.0 0057 to: 0.0 0058 duration: Kirigami.Units.longDuration 0059 easing.type: Easing.OutCubic 0060 } 0061 } 0062 0063 // FIXME: use a top-level Item here so that ToolTip instances with child 0064 // items can safely use anchors 0065 contentItem: RowLayout { 0066 Controls.Label { 0067 // Strip out ampersands right before non-whitespace characters, i.e. 0068 // those used to determine the alt key shortcut 0069 // (except when the word ends in ; (HTML entities)) 0070 text: control.text.replace(/(&)(?!;)\S+(?>\s)/g, "") 0071 // Using Wrap instead of WordWrap to prevent tooltips with long URLs 0072 // from overflowing 0073 wrapMode: Text.Wrap 0074 font: control.font 0075 color: Kirigami.Theme.textColor 0076 0077 Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip 0078 Layout.fillWidth: true 0079 // This value is basically arbitrary. It just looks nice. 0080 Layout.maximumWidth: Kirigami.Units.gridUnit * 14 0081 } 0082 } 0083 0084 // TODO: Consider replacing this with a StyleItem 0085 background: Kirigami.ShadowedRectangle { 0086 radius: 3 0087 color: Kirigami.Theme.backgroundColor 0088 Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip 0089 0090 // Roughly but doesn't exactly match the medium shadow setting for Breeze menus/tooltips. 0091 // TODO: Find a way to more closely match the user's Breeze settings. 0092 shadow.xOffset: 0 0093 shadow.yOffset: 4 0094 shadow.size: 16 0095 shadow.color: Qt.rgba(0, 0, 0, 0.2) 0096 0097 border.width: 1 0098 // TODO: Replace this with a frame or separator color role if that becomes a thing. 0099 // Matches the color used by Breeze::Style::drawPanelTipLabelPrimitive() 0100 border.color: Kirigami.ColorUtils.linearInterpolation(background.color, Kirigami.Theme.textColor, 0.25) 0101 } 0102 }