Warning, /plasma/qqc2-breeze-style/style/qtquickcontrols/DialogButtonBox.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.DialogButtonBox { 0012 id: control 0013 0014 readonly property bool __isHeader: control.position === T.DialogButtonBox.Header 0015 readonly property bool __isFooter: control.position === T.DialogButtonBox.Footer 0016 0017 // Children of QML Popup elements and subclasses of Popup are actually 0018 // children of an internal QQuickPopupItem, a subclass of QQuickPage. 0019 property bool __isInPopup: parent ? parent.toString().includes("QQuickPopupItem") : false 0020 0021 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, 0022 contentWidth + leftPadding + rightPadding) 0023 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 0024 contentHeight + topPadding + bottomPadding) 0025 0026 spacing: Kirigami.Units.smallSpacing 0027 0028 padding: Kirigami.Units.smallSpacing 0029 0030 alignment: Qt.AlignRight 0031 0032 delegate: Button { 0033 width: Math.round(Math.min(implicitWidth, (control.availableWidth / control.count) - (control.spacing * (control.count-1)))) 0034 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.DialogButton 0035 } 0036 0037 contentItem: ListView { 0038 pixelAligned: true 0039 model: control.contentModel 0040 spacing: control.spacing 0041 orientation: ListView.Horizontal 0042 boundsBehavior: Flickable.StopAtBounds 0043 snapMode: ListView.SnapToItem 0044 } 0045 0046 background: Kirigami.ShadowedRectangle { 0047 property real topRadius: control.__isHeader ? radius : 0 0048 property real bottomRadius: control.__isFooter ? radius : 0 0049 radius: control.__isInPopup ? Impl.Units.smallRadius : 0 0050 corners { 0051 topLeftRadius: topRadius 0052 topRightRadius: topRadius 0053 bottomLeftRadius: bottomRadius 0054 bottomRightRadius: bottomRadius 0055 } 0056 // Enough height for Buttons/ComboBoxes/TextFields with smallSpacing padding on top and bottom 0057 implicitHeight: Impl.Units.mediumControlHeight + (Kirigami.Units.smallSpacing * 2) 0058 color: control.__isInPopup ? "transparent" : Kirigami.Theme.backgroundColor 0059 } 0060 0061 // Standard buttons are destroyed and then recreated every time 0062 // the `standardButtons` property changes, so it is necessary to 0063 // run this code every time standardButtonsChanged() is emitted. 0064 // See QQuickDialogButtonBox::setStandardButtons() 0065 onStandardButtonsChanged: { 0066 // standardButton() returns a pointer to an existing standard button. 0067 // If no such button exists, it returns nullptr. 0068 // Icon names are copied from KStyle::standardIcon() 0069 function setStandardIcon(buttonType, iconName) { 0070 let button = standardButton(buttonType) 0071 // For some reason, `== ""` works, but `=== ""` and `!name && !source` doesn't. 0072 if (button && button.icon.name == "" && button.icon.source == "") { 0073 button.icon.name = iconName 0074 } 0075 } 0076 setStandardIcon(T.Dialog.Ok, "dialog-ok") 0077 setStandardIcon(T.Dialog.Save, "document-save") 0078 setStandardIcon(T.Dialog.SaveAll, "document-save-all") 0079 setStandardIcon(T.Dialog.Open, "document-open") 0080 setStandardIcon(T.Dialog.Yes, "dialog-ok-apply") 0081 setStandardIcon(T.Dialog.YesToAll, "dialog-ok") 0082 setStandardIcon(T.Dialog.No, "dialog-cancel") 0083 setStandardIcon(T.Dialog.NoToAll, "dialog-cancel") 0084 setStandardIcon(T.Dialog.Abort, "dialog-cancel") 0085 setStandardIcon(T.Dialog.Retry, "view-refresh") 0086 setStandardIcon(T.Dialog.Ignore, "dialog-cancel") 0087 setStandardIcon(T.Dialog.Close, "dialog-close") 0088 setStandardIcon(T.Dialog.Cancel, "dialog-cancel") 0089 setStandardIcon(T.Dialog.Discard, "edit-delete") 0090 setStandardIcon(T.Dialog.Help, "help-contents") 0091 setStandardIcon(T.Dialog.Apply, "dialog-ok-apply") 0092 setStandardIcon(T.Dialog.Reset, "edit-undo") 0093 setStandardIcon(T.Dialog.RestoreDefaults, "document-revert") 0094 } 0095 }