Warning, /multimedia/elisa/src/qml/ButtonWithToolTip.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 FlatButtonWithToolTip
0014 Button {
0015     property T.Popup menu
0016 
0017     readonly property bool __exclusive: autoExclusive || (ButtonGroup.group?.exclusive ?? false)
0018 
0019     ToolTip.visible: hovered
0020                      && text.length > 0
0021                      && display === AbstractButton.IconOnly
0022                      && (menu === null || !menu.visible)
0023     ToolTip.delay: Kirigami.Units.toolTipDelay
0024     ToolTip.text: text
0025 
0026     Keys.onReturnPressed: __emulateClick()
0027     Keys.onEnterPressed: __emulateClick()
0028     Accessible.onPressAction: clicked()
0029 
0030     function __toggleChecked() {
0031         if (!checkable) {
0032             return
0033         }
0034         if (!__exclusive) {
0035             toggle()
0036             return
0037         }
0038         if (!checked) {
0039             toggle()
0040         }
0041     }
0042 
0043     function __trigger() {
0044         if (action) {
0045             action.trigger()
0046         } else {
0047             clicked()
0048         }
0049     }
0050 
0051     function __emulateClick() {
0052         __toggleChecked()
0053         __trigger()
0054     }
0055 }