Warning, /plasma/qqc2-breeze-style/style/qtquickcontrols/DelayButton.qml is written in an unsupported language. File is not indexed.
0001 /* SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com> 0002 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0003 */ 0004 0005 import QtQuick 0006 import QtQuick.Templates as T 0007 import org.kde.kirigami as Kirigami 0008 0009 import org.kde.breeze.impl as Impl 0010 0011 T.DelayButton { 0012 id: control 0013 0014 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, 0015 implicitContentWidth + leftPadding + rightPadding) 0016 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 0017 implicitContentHeight + topPadding + bottomPadding, 0018 implicitIndicatorHeight + topPadding + bottomPadding) 0019 0020 // palette: Kirigami.Theme.palette 0021 Kirigami.Theme.colorSet: control.highlighted ? Kirigami.Theme.Selection : Kirigami.Theme.Button 0022 Kirigami.Theme.inherit: false 0023 0024 padding: Kirigami.Units.mediumSpacing 0025 leftPadding: { 0026 if ((!contentItem.hasIcon && contentItem.textBesideIcon) // False if contentItem has been replaced 0027 || display == T.AbstractButton.TextOnly 0028 || display == T.AbstractButton.TextUnderIcon) { 0029 return Impl.Units.mediumHorizontalPadding 0030 } else { 0031 return control.horizontalPadding 0032 } 0033 } 0034 rightPadding: { 0035 if (contentItem.hasLabel && display != T.AbstractButton.IconOnly) { // False if contentItem has been replaced 0036 return Impl.Units.mediumHorizontalPadding 0037 } else { 0038 return control.horizontalPadding 0039 } 0040 } 0041 0042 spacing: Kirigami.Units.mediumSpacing 0043 0044 transition: Transition { 0045 NumberAnimation { 0046 duration: control.delay * (control.pressed ? 1.0 - control.progress : 0.3 * control.progress) 0047 } 0048 } 0049 0050 icon.width: Kirigami.Units.iconSizes.sizeForLabels 0051 icon.height: Kirigami.Units.iconSizes.sizeForLabels 0052 0053 Kirigami.MnemonicData.enabled: control.enabled && control.visible 0054 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.ActionElement 0055 Kirigami.MnemonicData.label: control.display !== T.Button.IconOnly ? control.text : "" 0056 Shortcut { 0057 //in case of explicit & the button manages it by itself 0058 enabled: !(RegExp(/\&[^\&]/).test(control.text)) 0059 sequence: control.Kirigami.MnemonicData.sequence 0060 onActivated: control.clicked() 0061 } 0062 0063 contentItem: Impl.IconLabelContent { 0064 control: control 0065 text: control.Kirigami.MnemonicData.richTextLabel 0066 } 0067 0068 background: Impl.ButtonBackground { 0069 control: control 0070 color: control.palette.button 0071 0072 Kirigami.ShadowedRectangle { 0073 id: progressFillRect 0074 property real radiusThreshold: parent.width - leftRadius 0075 property real leftRadius: Impl.Units.smallRadius 0076 property real rightRadius: width > radiusThreshold ? width - radiusThreshold : 0 0077 0078 visible: width > 0 0079 0080 corners { 0081 topLeftRadius: control.mirrored ? rightRadius : leftRadius 0082 topRightRadius: control.mirrored ? leftRadius : rightRadius 0083 bottomLeftRadius: control.mirrored ? rightRadius : leftRadius 0084 bottomRightRadius: control.mirrored ? leftRadius : rightRadius 0085 } 0086 0087 x: control.mirrored ? (1 - control.progress) * parent.width : 0 0088 width: control.progress * parent.width 0089 0090 y: 0//leftRadius 0091 height: background.height//parent.height - leftRadius*2 0092 0093 color: Kirigami.Theme.alternateBackgroundColor 0094 border { 0095 color: Kirigami.Theme.focusColor 0096 width: parent.border.width 0097 } 0098 0099 /* FIXME: this doesn't perfectly scale the height to the background outline. 0100 * I think it's an issue with ShadowedRectangle. 0101 * Hopefully nobody notices. 0102 */ 0103 states: [ 0104 State { 0105 name: "normalHeight" 0106 when: progressFillRect.width >= progressFillRect.leftRadius 0107 PropertyChanges { 0108 target: progressFillRect 0109 y: 0 0110 height: background.height 0111 } 0112 }, 0113 State { 0114 name: "reducedHeight" 0115 when: progressFillRect.width < progressFillRect.leftRadius 0116 PropertyChanges { 0117 target: progressFillRect 0118 y: progressFillRect.leftRadius/2 0119 height: background.height - progressFillRect.leftRadius 0120 } 0121 } 0122 ] 0123 0124 transitions: Transition { 0125 from: "*" 0126 to: "normalHeight" 0127 NumberAnimation { 0128 property: "height" 0129 duration: control.delay * (progressFillRect.leftRadius/background.width) 0130 } 0131 YAnimator { 0132 duration: control.delay * (progressFillRect.leftRadius/background.width) 0133 } 0134 } 0135 } 0136 } 0137 }