/*SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Controls as QQC2import QtQuick.Layoutsimport org.kde.configimport org.kde.kirigami as Kirigamiimport org.kde.kcmutils as KCMUtilsimport org.kde.newstuff as NewStuffKCMUtils.ScrollViewKCM {id: rootimplicitWidth: Kirigami.Units.gridUnit * 32implicitHeight: Kirigami.Units.gridUnit * 18actions: [Kirigami.Action {icon.name: "configure"text: i18nc("@action:button in toolbar", "Configure KRunnerβ¦")Accessible.name: text // https://bugreports.qt.io/browse/QTBUG-130360onTriggered: kcm.showKRunnerKCM()},NewStuff.Action {text: i18nc("@action:button in toolbar", "Get New Pluginsβ¦")visible: KAuthorized.authorize(KAuthorized.GHNS)configFile: "krunner.knsrc"onEntryEvent: (entry, event) => {if (event === NewStuff.Engine.StatusChangedEvent) {kcm.reloadPlugins()}}}]header: ColumnLayout {spacing: Kirigami.Units.smallSpacingQQC2.Label {text: i18nc("@info:usagetip", "Enable or disable plugins (used in KRunner, Application Launcher, and the Overview effect). Mark plugins as favorites and arrange them in order you want to prioritize them.")textFormat: Text.PlainTextwrapMode: Text.WordWrapLayout.fillWidth: true}Kirigami.SearchField {id: searchFieldLayout.fillWidth: true}}view: KCMUtils.PluginSelector {id: pluginSelectorsourceModel: kcm.modelquery: searchField.textreuseItems: true // delegates are fairly expensive to construct due to their use of ActionToolBardelegate: Item { // Needed to avoid visual glitches in ListItemDragHandleid: delegateItemwidth: pluginSelector.widthimplicitHeight: pluginDelegate.implicitHeight// PluginDelegate must either be a direct delegate, or have a model explicitly set// "model: model" would just be a binding loop, so we store the model in a property of the// direct delegate Item and access it from PluginDelegateproperty var modelObject: modelproperty bool isFavorite: model.category === kcm.favoriteCategoryKCMUtils.PluginDelegate {id: pluginDelegatemodel: delegateItem.modelObjectwidth: pluginSelector.widthproperty var drag: Kirigami.ListItemDragHandle {property int dropNewIndexlistItem: pluginDelegatelistView: pluginSelector// Moving the rows now would cause a model reset and we could not drag an entry multiple rows up/downonMoveRequested: (oldIndex, newIndex) => (dropNewIndex = newIndex)onDropped: () => kcm.movePlugin(model.metaData, dropNewIndex)}Component.onCompleted: {if (isFavorite) {leading = drag}}additionalActions: [Kirigami.Action {displayHint: Kirigami.DisplayHint.IconOnlytext: isFavorite ? i18nc("@action:button, icononly", "Remove from favorites") : i18nc("@action:button, icononly", "Add to favorites")Accessible.name: text // https://bugreports.qt.io/browse/QTBUG-130360icon.name: isFavorite ? "starred-symbolic": "non-starred-symbolic"onTriggered: isFavorite ? kcm.removeFromFavorites(model.metaData) : kcm.addToFavorites(model.metaData)}]onConfigTriggered: kcm.showKCM(model.config, [], model.metaData)highlighted: falseKCMUtils.SettingHighlighter {highlight: model.enabled !== enabledByDefault}}}}}