/** SPDX-FileCopyrightText: 2022 Nate Graham <nate@kde.org>** SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Controls as QQC2import QtQuick.Layoutsimport org.kde.plasma.plasmoidimport org.kde.plasma.core as PlasmaCoreimport org.kde.kirigami as Kirigamiimport org.kde.kcmutils as KCMimport org.kde.taskmanager as TaskManagerKCM.SimpleKCM {id: rootproperty bool cfg_showText: Plasmoid.configuration.showTextproperty bool cfg_showIcon: Plasmoid.configuration.showIconproperty alias cfg_openOnHover: openOnHoverCheckbox.checkedproperty alias cfg_hoverOpenDelay: hoverDelaySpinBox.valueproperty int cfg_sortingStrategy: Plasmoid.configuration.sortingStrategyproperty alias cfg_showOnlyCurrentScreen: showOnlyCurrentScreen.checkedproperty alias cfg_showOnlyCurrentDesktop: showOnlyCurrentDesktop.checkedproperty alias cfg_showOnlyCurrentActivity: showOnlyCurrentActivity.checkedproperty alias cfg_showOnlyMinimized: showOnlyMinimized.checkedKirigami.FormLayout {anchors.right: parent.rightanchors.left: parent.leftQQC2.ComboBox {id: displayModeComboBoxKirigami.FormData.label: i18nc("@label:listbox", "For active application, show:")enabled: Plasmoid.formFactor === PlasmaCore.Types.Horizontalmodel: [i18nc("@item:inlistbox what to show for active application in horizontal panel", "Icon and name"),i18nc("@item:inlistbox what to show for active application in horizontal panel", "Icon"),i18nc("@item:inlistbox what to show for active application in horizontal panel", "Name")]property var mode: 0onModeChanged: {if (mode === 0) {root.cfg_showIcon = trueroot.cfg_showText = true} else if (mode === 1) {root.cfg_showIcon = trueroot.cfg_showText = false} else if (mode === 2) {root.cfg_showIcon = falseroot.cfg_showText = true}}onCurrentIndexChanged: mode = currentIndexComponent.onCompleted: {if (root.cfg_showIcon && root.cfg_showText) {mode = 0} else if (root.cfg_showIcon && !root.cfg_showText) {mode = 1} else if (!root.cfg_showIcon && root.cfg_showText) {mode = 2} else {// Invalid state, fallback to icon onlymode = 1root.cfg_showIcon = trueroot.cfg_showText = false}currentIndex = mode}}QQC2.Label {Layout.fillWidth: true// Arbitrary maximum length to make it wrap earlier, because long// unwrapped text is ugly and harder to read.Layout.maximumWidth: Kirigami.Units.gridUnit * 25visible: !displayModeComboBox.enabledtext: Plasmoid.formFactor === PlasmaCore.Types.Vertical ?// On a vertical paneli18nc("@info:usagetip display mode for active application", "Only icons can be shown when the Panel is vertical.") :// On the desktopi18nc("@info:usagetip display mode for active application", "Not applicable when the widget is on the Desktop.")textFormat: Text.PlainTextwrapMode: Text.Wrapfont: Kirigami.Theme.smallFont}Item {Kirigami.FormData.isSection: true}RowLayout {spacing: Kirigami.Units.smallSpacingKirigami.FormData.label: i18nc("@label:checkbox", "Open on hover:")QQC2.CheckBox {id: openOnHoverCheckboxtext: i18nc("@option:check open-on-hover is enabled, with the following delay:", "Enabled, with delay:")}QQC2.SpinBox {id: hoverDelaySpinBoxfrom: 0to: 1000stepSize: 50enabled: root.cfg_openOnHovertextFromValue: function(value, locale) {return i18ncp("@item:valuesuffix, %1 is hover activation delay in ms", "%1 ms", "%1 ms", value)}validator: IntValidator {bottom: hoverDelaySpinBox.fromtop: hoverDelaySpinBox.to}valueFromText: (text, locale) => {return Number.fromLocaleString(locale, text.replace(i18ncp("short for millisecond(s)", "ms", "ms"), ""))}Accessible.name: i18nc("@label:spinbox accessible %1 is milliseconds", "Hover open delay %1 ms", value)}}Item {Kirigami.FormData.isSection: true}QQC2.CheckBox {id: showOnlyCurrentDesktopKirigami.FormData.label: i18nc("@label for checkbox group, completes sentence like: … from current screen", "Show only windows:")text: i18nc("@option:check completes sentence: show only windows", "From the current desktop")}QQC2.CheckBox {id: showOnlyCurrentActivitytext: i18nc("@option:check completes sentence: show only windows", "From the current activity")}QQC2.CheckBox {id: showOnlyCurrentScreentext: i18nc("@option:check completes sentence: show only windows", "From the current screen")}QQC2.CheckBox {id: showOnlyMinimizedtext: i18nc("@option:check completes sentence: show only windows", "That are minimized")}Item {Kirigami.FormData.isSection: true}QQC2.ComboBox {id: sortingStrategyKirigami.FormData.label: i18nc("@label:listbox sort windows is list", "Sort:")Layout.fillWidth: trueLayout.minimumWidth: Kirigami.Units.gridUnit * 14textRole: "text"valueRole: "value"model: [{"text": i18nc("@item:inlistbox sort windows in list", "By time opened"),"value": TaskManager.TasksModel.SortDisabled},{"text": i18nc("@item:inlistbox sort windows in list", "Alphabetically"),"value": TaskManager.TasksModel.SortAlpha},{"text": i18nc("@item:inlistbox sort windows in list", "Alphabetically, grouped by virtual desktop"),"value": TaskManager.TasksModel.SortVirtualDesktop},{"text": i18nc("@item:inlistbox sort windows in list", "Alphabetically, grouped by activity"),"value": TaskManager.TasksModel.SortActivity},{"text": i18nc("@item:inlistbox sort windows in list", "By last activated time"),"value": TaskManager.TasksModel.SortLastActivated},{"text": i18nc("@item:inlistbox sort windows in list", "By horizontal window position"),"value": TaskManager.TasksModel.SortWindowPositionHorizontal}]onActivated: root.cfg_sortingStrategy = currentValueComponent.onCompleted: currentIndex = indexOfValue(root.cfg_sortingStrategy)}}}