/*SPDX-FileCopyrightText: 2021 Marco Martin <mart@kde.org>SPDX-FileCopyrightText: 2018 Furkan Tokac <furkantokac34@gmail.com>SPDX-FileCopyrightText: 2019-2022 Nate Graham <nate@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/pragma ComponentBehavior: Boundimport QtQuickimport QtQuick.Controls as QQC2import QtQuick.Layoutsimport org.kde.kirigami as Kirigamiimport org.kde.kcmutils as KCMUtilsimport org.kde.plasma.landingpage.kcmimport org.kde.plasma.core as PlasmaCoreKCMUtils.SimpleKCM {id: rootimplicitWidth: Kirigami.Units.gridUnit * 44implicitHeight: Kirigami.Units.gridUnit * 33Kirigami.Form {Kirigami.FormGroup {Kirigami.FormEntry {title: i18nc("@title:group for light/dark quick switch", "Theme:")contentItem: RowLayout {Layout.alignment: Qt.AlignCenterspacing: Kirigami.Units.largeSpacingQQC2.ButtonGroup { id: themeGroup }LookAndFeelBox {id: lightLookAndFeelBoxLayout.alignment: Qt.AlignToppackageId: kcm.globalsSettings.defaultLightLookAndFeelvariant: LookAndFeel.Variant.Lightchecked: !kcm.globalsSettings.automaticLookAndFeel && kcm.globalsSettings.lookAndFeelPackage === kcm.globalsSettings.defaultLightLookAndFeelgroup: themeGrouponToggled: {kcm.globalsSettings.automaticLookAndFeel = false;kcm.globalsSettings.lookAndFeelPackage = kcm.globalsSettings.defaultLightLookAndFeel;}onAccepted: (lnfId) => {kcm.globalsSettings.defaultLightLookAndFeel = lnfId;}KCMUtils.SettingHighlighter {highlight: kcm.globalsSettings.automaticLookAndFeel || kcm.globalsSettings.lookAndFeelPackage != kcm.defaultLookAndFeelPackage}}LookAndFeelBox {id: darkLookAndFeelBoxLayout.alignment: Qt.AlignToppackageId: kcm.globalsSettings.defaultDarkLookAndFeelvariant: LookAndFeel.Variant.Darkchecked: !kcm.globalsSettings.automaticLookAndFeel && kcm.globalsSettings.lookAndFeelPackage === kcm.globalsSettings.defaultDarkLookAndFeelgroup: themeGrouponToggled: {kcm.globalsSettings.automaticLookAndFeel = false;kcm.globalsSettings.lookAndFeelPackage = kcm.globalsSettings.defaultDarkLookAndFeel;}onAccepted: (lnfId) => {kcm.globalsSettings.defaultDarkLookAndFeel = lnfId;}KCMUtils.SettingHighlighter {highlight: kcm.globalsSettings.automaticLookAndFeel || kcm.globalsSettings.lookAndFeelPackage != kcm.defaultLookAndFeelPackage}}LookAndFeelBox {id: automaticLookAndFeelBoxLayout.alignment: Qt.AlignToppopupEnabled: falsegroup: themeGrouptext: i18nc("Switch between dark and light look and feel packages automatically", "Automatic")checked: kcm.globalsSettings.automaticLookAndFeelonToggled: kcm.globalsSettings.automaticLookAndFeel = true;preview: SplitView {first: lightLookAndFeelBox.previewImagesecond: darkLookAndFeelBox.previewImageshutter: 0.15Kirigami.Icon {anchors.right: parent.rightanchors.top: parent.topanchors.margins: Kirigami.Units.smallSpacingsource: "lighttable"isMask: truecolor: "white"width: Kirigami.Units.iconSizes.smallMediumheight: width}}KCMUtils.SettingHighlighter {highlight: kcm.globalsSettings.automaticLookAndFeel || kcm.globalsSettings.lookAndFeelPackage != kcm.defaultLookAndFeelPackage}QQC2.ToolTip.text: i18nc("@info:tooltip 1 is the name of a light global theme, 2 is the name of a dark global theme", "Use “%1” during the day and “%2” at night", lightLookAndFeelBox.text, darkLookAndFeelBox.text)QQC2.ToolTip.visible: automaticLookAndFeelBox.hoveredQQC2.ToolTip.delay: Kirigami.Units.toolTipDelay}}}Kirigami.FormSeparator {}Kirigami.FormEntry {title: i18nc("@title:group translate as short as possible", "More appearance settings:")contentItem: RowLayout {id: appearanceButtonsRowLayout.fillWidth: truespacing: Kirigami.Units.smallSpacingMostUsedIcon {id: wallpaperKCMButtonLayout.fillWidth: trueLayout.preferredWidth: 50 // 50% of the available widthkcmId: "kcm_wallpaper"visible: kcmAction !== null}MostUsedIcon {Layout.fillWidth: trueLayout.preferredWidth: 50 // 50% of the available widthkcmId: "kcm_lookandfeel"visible: kcmAction !== null}}}}Kirigami.FormGroup {Kirigami.FormEntry {title: slider.Accessible.namecontentItem: ColumnLayout {// We want to show the slider in a logarithmic way. ie// move from 4x, 3x, 2x, 1x, 0.5x, 0.25x, 0.125x// 0 is a special case, which means "instant speed / no animations"Layout.fillWidth: trueKirigami.FormData.label: slider.Accessible.nameKirigami.FormData.buddyFor: sliderQQC2.Slider {id: sliderLayout.fillWidth: true// Map from slider value (simple integer) to an animation// duration factor. This allows controlling the exact values for// the slider.property var valueMapping: [4,2,1.5,1,0.75,0.5,0,]from: 0to: valueMapping.length - 1stepSize: 1Kirigami.StyleHints.tickMarkStepSize: 1snapMode: QQC2.Slider.SnapAlwaysonMoved: kcm.globalsSettings.animationDurationFactor = valueMapping[value]value: {let factor = kcm.globalsSettings.animationDurationFactorlet index = valueMapping.findIndex(item => item <= factor)return index >= 0 ? index : valueMapping.length - 1}Accessible.name: i18nc("@title:slider", "Animation speed:")KCMUtils.SettingStateBinding {configObject: kcm.globalsSettingssettingName: "animationDurationFactor"}}RowLayout {QQC2.Label {text: i18nc("Animation speed", "Slow")textFormat: Text.PlainText}Item {Layout.fillWidth: true}QQC2.Label {text: i18nc("Animation speed", "Instant")textFormat: Text.PlainText}}}}Kirigami.FormSeparator {}Kirigami.FormEntry {title: i18nc("part of a sentence: 'Clicking files or folders [opens them/selects them]'", "Clicking files or folders:")subtitle: doubleClick.Accessible.description// Click behavior settingscontentItem: QQC2.RadioButton {id: doubleClicktext: i18nc("part of a sentence: 'Clicking files or folders selects them'", "Selects them")checked: !kcm.globalsSettings.singleClickonToggled: kcm.globalsSettings.singleClick = falseQQC2.ButtonGroup { id: singleClickGroup }QQC2.ButtonGroup.group: singleClickGroupAccessible.description: i18nc("@info:usagetip", "Open by double-clicking instead")KCMUtils.SettingStateBinding {configObject: kcm.globalsSettingssettingName: "singleClick"extraEnabledConditions: singleClick.enabled}}}Kirigami.FormEntry {// Click behavior settingssubtitle: singleClick.Accessible.descriptioncontentItem: QQC2.RadioButton {id: singleClickLayout.topMargin: Kirigami.Units.mediumSpacingtext: i18nc("part of a sentence: 'Clicking files or folders opens them'", "Opens them")checked: kcm.globalsSettings.singleClickonToggled: kcm.globalsSettings.singleClick = trueQQC2.ButtonGroup.group: singleClickGroupAccessible.description: i18nc("@info:usagetip", "Select by clicking on item's selection marker")KCMUtils.SettingStateBinding {configObject: kcm.globalsSettingssettingName: "singleClick"}}}Kirigami.FormSeparator {}Kirigami.FormAction {title: i18nc("@title:group translate as short as possible", "More behavior settings:")action: Kirigami.Action {readonly property PlasmaCore.Action kcmAction: kcm.kcmAction("kcm_workspace")fromQAction: kcmActiononTriggered: kcmAction.trigger();}}}Kirigami.FormGroup {Kirigami.FormEntry {title: i18nc("@title:group for grid of buttons opening kcms", "Most used pages:")contentItem: GridLayout {id: mostUsedGridvisible: recentlyUsedRepeater.count > 0Layout.fillWidth: truerows: 3columns: 2rowSpacing: Kirigami.Units.smallSpacingcolumnSpacing: Kirigami.Units.smallSpacingKirigami.SizeGroup {id: mostUsedPagesSizeGroupmode: Kirigami.SizeGroup.Width}Repeater {id: recentlyUsedRepeatermodel: kcm.mostUsedModeldelegate: MostUsedIcon {required property var modelLayout.fillWidth: truekcmIcon: model.decorationkcmName: model.displayonClicked: kcm.openKCM(model.kcmPlugin)}onItemAdded: (index, item) => {if (index === 0) {// Set buddy once, for an item in the first row.// No, it doesn't work as a binding on children list.mostUsedGrid.Kirigami.FormData.buddyFor = item;}mostUsedPagesSizeGroup.items.push(item);}}}}}}}