/*SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuick 2.15import QtQuick.Controls 2.15import org.kde.draganddrop 2.0 as DragDropimport org.kde.kirigami 2.5 as Kirigamiimport org.kde.kquickcontrolsaddons 2.0 as KQuickAddonsimport org.kde.plasma.core 2.0 as PlasmaCoreimport org.kde.plasma.private.kicker 0.1 as KickerKirigami.FormLayout {id: configGeneralanchors.left: parent.leftanchors.right: parent.rightproperty bool isDash: (plasmoid.pluginName === "org.kde.plasma.kickerdash")property string cfg_icon: plasmoid.configuration.iconproperty bool cfg_useCustomButtonImage: plasmoid.configuration.useCustomButtonImageproperty string cfg_customButtonImage: plasmoid.configuration.customButtonImageproperty alias cfg_appNameFormat: appNameFormat.currentIndexproperty alias cfg_limitDepth: limitDepth.checkedproperty alias cfg_alphaSort: alphaSort.checkedproperty alias cfg_showIconsRootLevel: showIconsRootLevel.checkedproperty alias cfg_recentOrdering: recentOrdering.currentIndexproperty alias cfg_showRecentApps: showRecentApps.checkedproperty alias cfg_showRecentDocs: showRecentDocs.checkedproperty alias cfg_showRecentContacts: showRecentContacts.checkedproperty alias cfg_useExtraRunners: useExtraRunners.checkedproperty alias cfg_alignResultsToBottom: alignResultsToBottom.checkedButton {id: iconButtonKirigami.FormData.label: i18n("Icon:")implicitWidth: previewFrame.width + PlasmaCore.Units.smallSpacing * 2implicitHeight: previewFrame.height + PlasmaCore.Units.smallSpacing * 2// Just to provide some visual feedback when dragging;// cannot have checked without checkable enabledcheckable: truechecked: dropArea.containsAcceptableDragonPressed: iconMenu.opened ? iconMenu.close() : iconMenu.open()DragDrop.DropArea {id: dropAreaproperty bool containsAcceptableDrag: falseanchors.fill: parentonDragEnter: {// Cannot use string operations (e.g. indexOf()) on "url" basic type.var urlString = event.mimeData.url.toString();// This list is also hardcoded in KIconDialog.var extensions = [".png", ".xpm", ".svg", ".svgz"];containsAcceptableDrag = urlString.indexOf("file:///") === 0 && extensions.some(function (extension) {return urlString.indexOf(extension) === urlString.length - extension.length; // "endsWith"});if (!containsAcceptableDrag) {event.ignore();}}onDragLeave: containsAcceptableDrag = falseonDrop: {if (containsAcceptableDrag) {// Strip file:// prefix, we already verified in onDragEnter that we have only local URLs.iconDialog.setCustomButtonImage(event.mimeData.url.toString().substr("file://".length));}containsAcceptableDrag = false;}}KQuickAddons.IconDialog {id: iconDialogfunction setCustomButtonImage(image) {configGeneral.cfg_customButtonImage = image || configGeneral.cfg_icon || "start-here-kde"configGeneral.cfg_useCustomButtonImage = true;}onIconNameChanged: setCustomButtonImage(iconName);}PlasmaCore.FrameSvgItem {id: previewFrameanchors.centerIn: parentimagePath: plasmoid.location === PlasmaCore.Types.Vertical || plasmoid.location === PlasmaCore.Types.Horizontal? "widgets/panel-background" : "widgets/background"width: PlasmaCore.Units.iconSizes.large + fixedMargins.left + fixedMargins.rightheight: PlasmaCore.Units.iconSizes.large + fixedMargins.top + fixedMargins.bottomPlasmaCore.IconItem {anchors.centerIn: parentwidth: PlasmaCore.Units.iconSizes.largeheight: widthsource: configGeneral.cfg_useCustomButtonImage ? configGeneral.cfg_customButtonImage : configGeneral.cfg_icon}}Menu {id: iconMenu// Appear below the buttony: +parent.heightonClosed: iconButton.checked = false;MenuItem {text: i18nc("@item:inmenu Open icon chooser dialog", "Chooseβ¦")icon.name: "document-open-folder"onClicked: iconDialog.open()}MenuItem {text: i18nc("@item:inmenu Reset icon to default", "Clear Icon")icon.name: "edit-clear"onClicked: {configGeneral.cfg_icon = "start-here-kde"configGeneral.cfg_useCustomButtonImage = false}}}}Item {Kirigami.FormData.isSection: true}ComboBox {id: appNameFormatKirigami.FormData.label: i18n("Show applications as:")model: [i18n("Name only"), i18n("Description only"), i18n("Name (Description)"), i18n("Description (Name)")]}Item {Kirigami.FormData.isSection: true}CheckBox {id: alphaSortKirigami.FormData.label: i18n("Behavior:")text: i18n("Sort applications alphabetically")}CheckBox {id: limitDepthvisible: !isDashtext: i18n("Flatten sub-menus to a single level")}CheckBox {id: showIconsRootLevelvisible: !configGeneral.isDashtext: i18n("Show icons on the root level of the menu")}Item {Kirigami.FormData.isSection: true}CheckBox {id: showRecentAppsKirigami.FormData.label: i18n("Show categories:")text: recentOrdering.currentIndex == 0? i18n("Recent applications"): i18n("Often used applications")}CheckBox {id: showRecentDocstext: recentOrdering.currentIndex == 0? i18n("Recent files"): i18n("Often used files")}CheckBox {id: showRecentContactstext: recentOrdering.currentIndex == 0? i18n("Recent contacts"): i18n("Often used contacts")}ComboBox {id: recentOrderingKirigami.FormData.label: i18n("Sort items in categories by:")model: [i18nc("@item:inlistbox Sort items in categories by [Recently used | Often used]", "Recently used"), i18nc("@item:inlistbox Sort items in categories by [Recently used | Ofetn used]", "Often used")]}Item {Kirigami.FormData.isSection: true}CheckBox {id: useExtraRunnersKirigami.FormData.label: i18n("Search:")text: i18n("Expand search to bookmarks, files and emails")}CheckBox {id: alignResultsToBottomvisible: !configGeneral.isDashtext: i18n("Align search results to bottom")}}