Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/DialogButtonBox.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 0005 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later 0006 */ 0007 0008 0009 import QtQuick 2.6 0010 import QtQuick.Templates 2.15 as T 0011 import org.kde.kirigami 2.4 as Kirigami 0012 0013 T.DialogButtonBox { 0014 id: control 0015 0016 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, 0017 contentWidth + leftPadding + rightPadding) 0018 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 0019 contentHeight + topPadding + bottomPadding) 0020 0021 spacing: Kirigami.Units.smallSpacing 0022 padding: Kirigami.Units.smallSpacing 0023 alignment: Qt.AlignRight 0024 0025 delegate: Button { 0026 // Round because fractional width values are possible. 0027 width: Math.round(Math.min( 0028 implicitWidth, 0029 // Divide availableWidth (width - leftPadding - rightPadding) by the number of buttons, 0030 // then subtract the spacing between each button. 0031 (control.availableWidth / control.count) - (control.spacing * (control.count - 1)) 0032 )) 0033 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.DialogButton 0034 } 0035 0036 contentItem: ListView { 0037 implicitWidth: contentWidth 0038 implicitHeight: 32 0039 0040 model: control.contentModel 0041 spacing: control.spacing 0042 orientation: ListView.Horizontal 0043 boundsBehavior: Flickable.StopAtBounds 0044 snapMode: ListView.SnapToItem 0045 } 0046 0047 // Standard buttons are destroyed and then recreated every time 0048 // the `standardButtons` property changes, so it is necessary to 0049 // run this code every time standardButtonsChanged() is emitted. 0050 // See QQuickDialogButtonBox::setStandardButtons() 0051 onStandardButtonsChanged: { 0052 // standardButton() returns a pointer to an existing standard button. 0053 // If no such button exists, it returns nullptr. 0054 // Icon names are copied from KStyle::standardIcon() 0055 function setStandardIcon(buttonType, iconName) { 0056 const button = standardButton(buttonType) 0057 if (button && button.icon.name === "" && button.icon.source.toString() === "") { 0058 button.icon.name = iconName 0059 } 0060 } 0061 setStandardIcon(T.Dialog.Ok, "dialog-ok") 0062 setStandardIcon(T.Dialog.Save, "document-save") 0063 setStandardIcon(T.Dialog.SaveAll, "document-save-all") 0064 setStandardIcon(T.Dialog.Open, "document-open") 0065 setStandardIcon(T.Dialog.Yes, "dialog-ok-apply") 0066 setStandardIcon(T.Dialog.YesToAll, "dialog-ok") 0067 setStandardIcon(T.Dialog.No, "dialog-cancel") 0068 setStandardIcon(T.Dialog.NoToAll, "dialog-cancel") 0069 setStandardIcon(T.Dialog.Abort, "dialog-cancel") 0070 setStandardIcon(T.Dialog.Retry, "view-refresh") 0071 setStandardIcon(T.Dialog.Ignore, "dialog-cancel") 0072 setStandardIcon(T.Dialog.Close, "dialog-close") 0073 setStandardIcon(T.Dialog.Cancel, "dialog-cancel") 0074 setStandardIcon(T.Dialog.Discard, "edit-delete") 0075 setStandardIcon(T.Dialog.Help, "help-contents") 0076 setStandardIcon(T.Dialog.Apply, "dialog-ok-apply") 0077 setStandardIcon(T.Dialog.Reset, "edit-undo") 0078 setStandardIcon(T.Dialog.RestoreDefaults, "document-revert") 0079 } 0080 }