Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/DelayButton.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 SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk> 0005 0006 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later 0007 */ 0008 0009 import QtQuick 2.6 0010 import QtQuick.Templates 2.15 as T 0011 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate 0012 import org.kde.kirigami 2.4 as Kirigami 0013 0014 T.DelayButton { 0015 id: controlRoot 0016 0017 implicitWidth: Math.max((text && display !== T.AbstractButton.IconOnly ? 0018 implicitBackgroundWidth : implicitHeight) + leftInset + rightInset, 0019 implicitContentWidth + leftPadding + rightPadding) 0020 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 0021 implicitContentHeight + topPadding + bottomPadding) 0022 0023 hoverEnabled: Qt.styleHints.useHoverEffects 0024 0025 Kirigami.MnemonicData.enabled: controlRoot.enabled && controlRoot.visible 0026 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.ActionElement 0027 Kirigami.MnemonicData.label: controlRoot.display !== T.AbstractButton.IconOnly ? controlRoot.text : "" 0028 Shortcut { 0029 //in case of explicit & the button manages it by itself 0030 enabled: !(RegExp(/\&[^\&]/).test(controlRoot.text)) 0031 sequence: controlRoot.Kirigami.MnemonicData.sequence 0032 onActivated: controlRoot.clicked() 0033 } 0034 0035 palette: Kirigami.Theme.inherit ? Kirigami.Theme.palette : undefined 0036 Kirigami.Theme.colorSet: Kirigami.Theme.Button 0037 Kirigami.Theme.inherit: false 0038 0039 transition: Transition { 0040 NumberAnimation { 0041 duration: controlRoot.delay * (controlRoot.pressed ? 1.0 - controlRoot.progress : 0.3 * controlRoot.progress) 0042 } 0043 } 0044 0045 background: StylePrivate.StyleItem { 0046 control: controlRoot 0047 elementType: "delaybutton" 0048 sunken: controlRoot.down 0049 on: controlRoot.checkable && controlRoot.checked 0050 hover: controlRoot.hovered 0051 text: controlRoot.Kirigami.MnemonicData.mnemonicLabel 0052 hasFocus: controlRoot.visualFocus || controlRoot.pressed 0053 flat: false 0054 minimum: 0 0055 maximum: 1000 0056 value: controlRoot.progress * maximum 0057 0058 // note: keep in sync with ToolButton 0059 readonly property int toolButtonStyle: { 0060 switch (controlRoot.display) { 0061 case T.AbstractButton.IconOnly: return Qt.ToolButtonIconOnly; 0062 case T.AbstractButton.TextOnly: return Qt.ToolButtonTextOnly; 0063 case T.AbstractButton.TextBesideIcon: 0064 case T.AbstractButton.TextUnderIcon: 0065 // TODO KF6: check if this condition is still needed 0066 if (controlRoot.icon.name !== "" || controlRoot.icon.source.toString() !== "") { 0067 // has icon 0068 switch (controlRoot.display) { 0069 case T.AbstractButton.TextBesideIcon: return Qt.ToolButtonTextBesideIcon; 0070 case T.AbstractButton.TextUnderIcon: return Qt.ToolButtonTextUnderIcon; 0071 } 0072 } else { 0073 return Qt.ToolButtonTextOnly; 0074 } 0075 default: return Qt.ToolButtonFollowStyle; 0076 } 0077 } 0078 0079 properties: { 0080 "icon": controlRoot.icon.name !== "" ? controlRoot.icon.name : controlRoot.icon.source, 0081 "iconColor": Qt.colorEqual(controlRoot.icon.color, "transparent") ? Kirigami.Theme.textColor : controlRoot.icon.color, 0082 "iconWidth": controlRoot.icon.width, 0083 "iconHeight": controlRoot.icon.height, 0084 0085 "toolButtonStyle": toolButtonStyle, 0086 } 0087 } 0088 }