KCMUtils

ContextualHelpButton.qml
1/*
2 SPDX-FileCopyrightText: 2020 Felix Ernst <fe.a.ernst@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Layouts 1.1
9import QtQuick.Controls 2.7 as QQC2
10import QtQuick.Window 2.15
11import org.kde.kirigami 2.3 as Kirigami
12
13@Deprecated { reason: "Use the version in Kirigami instead!" }
14QQC2.Button {
15 id: root
16
17 icon.name: "help-contextual"
18 flat: true
19 property alias toolTipText: toolTip.text
20 property var toolTipVisible: false
21
22 onReleased: {
23 toolTipVisible ? toolTip.delay = Kirigami.Units.toolTipDelay : toolTip.delay = 0;
24 toolTipVisible = !toolTipVisible;
25 }
26 onActiveFocusChanged: {
27 toolTip.delay = Kirigami.Units.toolTipDelay;
28 toolTipVisible = false;
29 }
30 Layout.maximumHeight: parent.height
31 QQC2.ToolTip {
32 id: toolTip
33 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.
34 visible: parent.hovered || parent.toolTipVisible
35 onVisibleChanged: {
36 if (!visible && parent.toolTipVisible) {
37 parent.toolTipVisible = false;
38 delay = Kirigami.Units.toolTipDelay;
39 }
40 }
41 timeout: -1
42 }
43 MouseArea {
44 anchors.fill: parent
45 hoverEnabled: true
46 cursorShape: Qt.WhatsThisCursor
47 acceptedButtons: Qt.NoButton
48 }
49 Accessible.name: i18ndc("kcmutils6", "@action:button", "Show Contextual Help")
50}
51
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.