Warning, /frameworks/kcmutils/src/qml/components/ContextualHelpButton.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2020 Felix Ernst <fe.a.ernst@gmail.com>
0003
0004 SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.1
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Controls 2.7 as QQC2
0010 import QtQuick.Window 2.15
0011 import org.kde.kirigami 2.3 as Kirigami
0012
0013 QQC2.Button {
0014 id: root
0015
0016 icon.name: "help-contextual"
0017 flat: true
0018 property alias toolTipText: toolTip.text
0019 property var toolTipVisible: false
0020
0021 onReleased: {
0022 toolTipVisible ? toolTip.delay = Kirigami.Units.toolTipDelay : toolTip.delay = 0;
0023 toolTipVisible = !toolTipVisible;
0024 }
0025 onActiveFocusChanged: {
0026 toolTip.delay = Kirigami.Units.toolTipDelay;
0027 toolTipVisible = false;
0028 }
0029 Layout.maximumHeight: parent.height
0030 QQC2.ToolTip {
0031 id: toolTip
0032 implicitWidth: Math.min(21 * Kirigami.Units.gridUnit, root.Window.width) // Wikipedia says anything between 45 and 75 characters per line is acceptable. 21 * Kirigami.Units.gridUnit feels right.
0033 visible: parent.hovered || parent.toolTipVisible
0034 onVisibleChanged: {
0035 if (!visible && parent.toolTipVisible) {
0036 parent.toolTipVisible = false;
0037 delay = Kirigami.Units.toolTipDelay;
0038 }
0039 }
0040 timeout: -1
0041 }
0042 MouseArea {
0043 anchors.fill: parent
0044 hoverEnabled: true
0045 cursorShape: Qt.WhatsThisCursor
0046 acceptedButtons: Qt.NoButton
0047 }
0048 Accessible.name: i18nc("@action:button", "Show Contextual Help")
0049 }
0050