/*SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Layoutsimport QtQuick.Controls as QQC2import org.kde.draganddrop as DragDropimport org.kde.iconthemes as KIconThemesimport org.kde.kcmutils as KCMUtilsimport org.kde.kirigami as Kirigamiimport org.kde.ksvg as KSvgimport org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.plasmoidKCMUtils.SimpleKCM {id: configGeneralreadonly property 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_showRecentFolders: showRecentFolders.checkedproperty alias cfg_highlightNewlyInstalledApps: highlightNewlyInstalledAppsCheckbox.checkedproperty alias cfg_useExtraRunners: useExtraRunners.checkedproperty alias cfg_alignResultsToBottom: alignResultsToBottom.checkedproperty alias cfg_forceDarkMode: forceDarkMode.checkedKirigami.FormLayout {anchors.left: parent.leftanchors.right: parent.rightQQC2.Button {id: iconButtonKirigami.FormData.label: i18nc("@label prefix for icon-only button", "Icon:")implicitWidth: previewFrame.width + Kirigami.Units.smallSpacing * 2implicitHeight: previewFrame.height + Kirigami.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: event => {// Cannot use string operations (e.g. indexOf()) on "url" basic type.const urlString = event.mimeData.url.toString();// This list is also hardcoded in KIconDialog.const extensions = [".png", ".xpm", ".svg", ".svgz"];containsAcceptableDrag = urlString.startsWith("file:///")&& extensions.some(extension => urlString.endsWith(extension));if (!containsAcceptableDrag) {event.ignore();}}onDragLeave: event => {containsAcceptableDrag = false}onDrop: event => {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;}}KIconThemes.IconDialog {id: iconDialogfunction setCustomButtonImage(image) {configGeneral.cfg_customButtonImage = image || configGeneral.cfg_icon || "start-here-kde-symbolic"configGeneral.cfg_useCustomButtonImage = true;}onAccepted: {if (iconDialog.iconName != "") {setCustomButtonImage(iconDialog.iconName)}}}KSvg.FrameSvgItem {id: previewFrameanchors.centerIn: parentimagePath: Plasmoid.location === PlasmaCore.Types.Vertical || Plasmoid.location === PlasmaCore.Types.Horizontal? "widgets/panel-background" : "widgets/background"width: Kirigami.Units.iconSizes.large + fixedMargins.left + fixedMargins.rightheight: Kirigami.Units.iconSizes.large + fixedMargins.top + fixedMargins.bottomKirigami.Icon {anchors.centerIn: parentwidth: Kirigami.Units.iconSizes.largeheight: widthsource: configGeneral.cfg_useCustomButtonImage ? configGeneral.cfg_customButtonImage : configGeneral.cfg_icon}}QQC2.Menu {id: iconMenu// Appear below the buttony: parent.heightonClosed: iconButton.checked = false;QQC2.MenuItem {text: i18nc("@item:inmenu Open icon chooser dialog", "Chooseβ¦")icon.name: "document-open-folder"onClicked: iconDialog.open()}QQC2.MenuItem {text: i18nc("@item:inmenu Reset icon to default", "Reset to default icon")icon.name: "edit-clear"onClicked: {configGeneral.cfg_icon = "start-here-kde-symbolic"configGeneral.cfg_customButtonImage = ""configGeneral.cfg_useCustomButtonImage = false}}}}Item {Kirigami.FormData.isSection: true}QQC2.ComboBox {id: appNameFormatvisible: !configGeneral.isDashKirigami.FormData.label: i18nc("@label:listbox", "Show applications as:")model: [i18nc("@item:inlistbox", "Name only"), i18nc("@item:inlistbox", "Description only"),i18nc("@item:inlistbox", "Name (Description)"), i18nc("@item:inlistbox", "Description (Name)")]}Item {Kirigami.FormData.isSection: true}QQC2.CheckBox {id: alphaSortKirigami.FormData.label: i18nc("@title:group prefix for checkbox group", "Behavior:")text: i18nc("@option:check", "Sort applications alphabetically")}QQC2.CheckBox {id: limitDepthvisible: !configGeneral.isDashtext: i18nc("@option:check", "Flatten sub-menus to a single level")}QQC2.CheckBox {id: showIconsRootLevelvisible: !configGeneral.isDashtext: i18nc("@option:check", "Show icons on the root level of the menu")}QQC2.CheckBox {id: highlightNewlyInstalledAppsCheckboxtext: i18nc("@option:check", "Highlight newly-installed applications")}Item {Kirigami.FormData.isSection: true}QQC2.CheckBox {id: showRecentAppsKirigami.FormData.label: i18nc("@title:group prefix for checkbox group", "Show categories:")text: recentOrdering.currentIndex == 0? i18nc("@option:check", "Recent applications"): i18nc("@option:check", "Often used applications")}QQC2.CheckBox {id: showRecentDocstext: recentOrdering.currentIndex == 0? i18nc("@option:check", "Recent files"): i18nc("@option:check", "Often used files")}QQC2.CheckBox {id: showRecentFolderstext: recentOrdering.currentIndex == 0? i18nc("@option:check", "Recent places"): i18nc("@option:check", "Often used places")}QQC2.ComboBox {id: recentOrderingKirigami.FormData.label: i18nc("@label:listbox", "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 | Often used]", "Often used")]}Item {Kirigami.FormData.isSection: true}QQC2.CheckBox {id: useExtraRunnersKirigami.FormData.label: i18nc("@title:group prefix for checkbox group", "Search:")text: i18nc("@option:check", "Expand search to bookmarks, files and emails")}QQC2.CheckBox {id: alignResultsToBottomvisible: !configGeneral.isDashtext: i18nc("@option:check", "Align search results to bottom")}RowLayout {visible: configGeneral.isDashKirigami.FormData.label: i18nc("@label prefix for a checkbox toggling Dark Mode", "Appearance:")spacing: Kirigami.Units.smallSpacingQQC2.CheckBox {id: forceDarkModetext: i18nc("@option:check", "Prefer Dark Mode when available")}Kirigami.ContextualHelpButton {toolTipText: xi18nc("@info:tooltip", "This feature uses the complementary colors from your colorscheme, which usually feature a dark background.")}}}}