Warning, /multimedia/elisa/src/qml/FlatButtonWithToolTip.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2018 (c) Alexander Stippich <a.stippich@gmx.net>
0003
0004 SPDX-License-Identifier: LGPL-3.0-or-later
0005 */
0006
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15
0009 import QtQuick.Templates 2.15 as T
0010 import org.kde.kirigami 2.15 as Kirigami
0011 import org.kde.elisa 1.0
0012
0013 // Keep in sync with ButtonWithToolTip
0014 ToolButton {
0015 property T.Popup menu
0016
0017 readonly property bool __exclusive: autoExclusive || (ButtonGroup.group?.exclusive ?? false)
0018
0019 display: AbstractButton.IconOnly
0020
0021 ToolTip.visible: hovered
0022 && text.length > 0
0023 && display === AbstractButton.IconOnly
0024 && (menu === null || !menu.visible)
0025 ToolTip.delay: Kirigami.Units.toolTipDelay
0026 ToolTip.text: text
0027
0028 Keys.onReturnPressed: __emulateClick()
0029 Keys.onEnterPressed: __emulateClick()
0030 Accessible.onPressAction: clicked()
0031
0032 function __toggleChecked() {
0033 if (!checkable) {
0034 return
0035 }
0036 if (!__exclusive) {
0037 toggle()
0038 toggled() // NOTE: toggle() does not emit this automatically
0039 return
0040 }
0041 if (!checked) {
0042 toggle()
0043 toggled() // NOTE: toggle() does not emit this automatically
0044 }
0045 }
0046
0047 function __trigger() {
0048 if (action) {
0049 action.trigger()
0050 } else {
0051 clicked()
0052 }
0053 }
0054
0055 function __emulateClick() {
0056 __toggleChecked()
0057 __trigger()
0058 }
0059 }