Warning, /plasma/plasma-desktop/kcms/runners/krunner/ui/main.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15 as QQC2
0009 
0010 import org.kde.kirigami 2.19 as Kirigami
0011 import org.kde.kcmutils as KCM
0012 import org.kde.config as KConfig
0013 
0014 import org.kde.plasma.runners.kcm
0015 
0016 KCM.SimpleKCM {
0017     id: root
0018 
0019     implicitWidth: Kirigami.Units.gridUnit * 32
0020     implicitHeight: Kirigami.Units.gridUnit * 18
0021 
0022     Kirigami.FormLayout {
0023         width: parent.width
0024         anchors.top: parent.top
0025 
0026         QQC2.ButtonGroup {
0027             id: positionGroup
0028         }
0029 
0030         QQC2.RadioButton {
0031             Kirigami.FormData.label: i18n("Position on screen:")
0032             onToggled: kcm.krunnerSettings.freeFloating = false
0033             checked: !kcm.krunnerSettings.freeFloating
0034             QQC2.ButtonGroup.group: positionGroup
0035             text: i18n("Top")
0036         }
0037 
0038         QQC2.RadioButton {
0039             checked: kcm.krunnerSettings.freeFloating
0040             onToggled: kcm.krunnerSettings.freeFloating = true
0041             QQC2.ButtonGroup.group: positionGroup
0042             text: i18n("Center")
0043 
0044             KCM.SettingStateBinding {
0045                 configObject: kcm.krunnerSettings
0046                 settingName: "freeFloating"
0047             }
0048         }
0049 
0050         Item {
0051             Kirigami.FormData.isSection: false
0052         }
0053 
0054         QQC2.CheckBox {
0055             Kirigami.FormData.label: i18n("Activation:")
0056             checked: kcm.krunnerSettings.activateWhenTypingOnDesktop
0057             onToggled: kcm.krunnerSettings.activateWhenTypingOnDesktop = checked
0058             text: i18nc("@option:check", "Activate when pressing any key on the desktop")
0059 
0060             KCM.SettingStateBinding {
0061                 configObject: kcm.krunnerSettings
0062                 settingName: "activateWhenTypingOnDesktop"
0063             }
0064         }
0065 
0066         Item {
0067             Kirigami.FormData.isSection: false
0068         }
0069 
0070         QQC2.RadioButton {
0071             Kirigami.FormData.label: i18n("History:")
0072             checked: kcm.krunnerSettings.historyBehavior === KRunnerSettings.Disabled
0073             onToggled: kcm.krunnerSettings.historyBehavior = KRunnerSettings.Disabled
0074             text: i18nc("@option:check", "Disabled")
0075         }
0076         QQC2.RadioButton {
0077             checked: kcm.krunnerSettings.historyBehavior === KRunnerSettings.CompletionSuggestion
0078             onToggled: kcm.krunnerSettings.historyBehavior = KRunnerSettings.CompletionSuggestion
0079             text: i18nc("@option:check The thing being enabled is search history", "Enable suggestions")
0080         }
0081         QQC2.RadioButton {
0082             checked: kcm.krunnerSettings.historyBehavior === KRunnerSettings.ImmediateCompletion
0083             onToggled: kcm.krunnerSettings.historyBehavior = KRunnerSettings.ImmediateCompletion
0084             text: i18nc("@option:check The thing being enabled is search history", "Enabled auto-complete")
0085         }
0086 
0087         QQC2.Button {
0088             id: clearHistoryButton
0089             enabled: kcm.krunnerSettings.historyBehavior !== KRunnerSettings.Disabled && kcm.historyKeys.length > 0
0090 
0091             icon.name: Qt.application.layoutDirection === Qt.LeftToRight ? "edit-clear-locationbar-ltr" : "edit-clear-locationbar-rtl"
0092             text: i18n("Clear History…")
0093 
0094             checked: activityMenu.visible
0095 
0096             // NOTE: Use onReleased to avoid race condition
0097             onReleased: {
0098                 if (!activityList.model) {
0099                     activityList.model = Qt.createQmlObject("import org.kde.activities 0.1; ActivityModel {}", root); // Lazy load
0100                 }
0101 
0102                 if (activityMenu.visible) {
0103                     activityMenu.close();
0104                 } else {
0105                     activityMenu.popup(x, y + implicitHeight);
0106                 }
0107             }
0108         }
0109 
0110         QQC2.Menu {
0111             id: activityMenu
0112 
0113             QQC2.MenuItem {
0114                 icon.name: clearHistoryButton.icon.name
0115                 text: i18nc("@item:inmenu delete krunner history for all activities", "For all activities")
0116 
0117                 onTriggered: kcm.deleteAllHistory()
0118             }
0119 
0120             Repeater {
0121                 id: activityList
0122 
0123                 QQC2.MenuItem {
0124                     enabled: kcm.historyKeys.includes(model.id)
0125 
0126                     icon.source: model.iconSource
0127                     text: i18nc("@item:inmenu delete krunner history for this activity", "For activity \"%1\"", model.name)
0128 
0129                     onTriggered: kcm.deleteHistoryGroup(model.id)
0130                 }
0131             }
0132         }
0133 
0134         Item {
0135             visible: pluginButton.visible
0136             Kirigami.FormData.isSection: false
0137         }
0138 
0139         Loader {
0140             id: pluginButton
0141             active: kcm.doesShowPluginButton
0142             visible: active
0143 
0144             Kirigami.FormData.label: i18nc("@label", "Plugins:")
0145 
0146             sourceComponent: QQC2.Button {
0147                 enabled: KConfig.KAuthorized.authorizeControlModule("kcm_krunnersettings")
0148                 text: i18nc("@action:button", "Configure Enabled Search Plugins…")
0149                 icon.name: "settings-configure"
0150 
0151                 onClicked: KCM.KCMLauncher.openSystemSettings("kcm_plasmasearch")
0152             }
0153         }
0154     }
0155 }