/*SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuick 2.10import QtQuick.Controls 2.10import QtQuick.Layouts 1.11import org.kde.kirigami as Kirigamiimport QtQuick.Dialogs 6.3import org.kde.desktopsession.private 1.0import org.kde.kcmutils as KCMKCM.SimpleKCM {id: rootimplicitHeight: Kirigami.Units.gridUnit * 28implicitWidth: Kirigami.Units.gridUnit * 28headerPaddingEnabled: false // Let the InlineMessage touch the edgesheader: ColumnLayout {spacing : 0Kirigami.InlineMessage {id: manualSessionRestoreRebootMessageLayout.fillWidth: trueposition: Kirigami.InlineMessage.Position.Headertype: Kirigami.MessageType.Informationvisible: falsetext: i18n("The system must be restarted before manual session saving becomes active.")showCloseButton: trueactions: [Kirigami.Action {icon.name: "system-reboot"text: i18n("Restart")onTriggered: kcm.reboot();}]Connections {target: kcmfunction onKsmserverSettingsChanged() {if (loginManual.checked) {manualSessionRestoreRebootMessage.visible = true;} else {manualSessionRestoreRebootMessage.visible = false;}}}}Kirigami.InlineMessage {Layout.fillWidth: trueposition: Kirigami.InlineMessage.Position.Headertype: kcm.error.length > 0 ? Kirigami.MessageType.Error : Kirigami.MessageType.Informationvisible: kcm.restartInSetupScreen || kcm.error.length > 0text: kcm.error.length > 0? i18n("Failed to request restart to firmware setup: %1", kcm.error): kcm.isUefi ? i18n("Next time the computer is restarted, it will enter the UEFI setup screen."): i18n("Next time the computer is restarted, it will enter the firmware setup screen.")showCloseButton: trueactions: Kirigami.Action {icon.name: "system-reboot"onTriggered: kcm.reboot();text: i18n("Restart Now")}}}Kirigami.FormLayout {Item {Kirigami.FormData.isSection: trueKirigami.FormData.label: i18nc("@title:group", "General")}CheckBox {id: logoutScreenCheckboxKirigami.FormData.label: i18nc("@label beginning of the logical sentence 'Ask for confirmation on shutdown, restart, and logout.'", "Ask for confirmation:")text: i18nc("@option:check end of the logical sentence 'Ask for confirmation on shutdown, restart, and logout.'", "On shutdown, restart, and logout")checked: Settings.confirmLogoutonToggled: Settings.confirmLogout = checkedKCM.SettingStateBinding {configObject: SettingssettingName: "confirmLogout"}}Item {Kirigami.FormData.isSection: trueKirigami.FormData.label: i18nc("@title:group", "Session Restore")}ButtonGroup {buttons: [loginRestore, loginManual, loginEmpty]}RadioButton {id: loginRestoreKirigami.FormData.label: i18n("On login, launch apps that were open:")text: i18nc("@option:radio Automatic style of session restoration", "On last logout")checked: Settings.loginMode === 0onToggled: Settings.loginMode = 0KCM.SettingStateBinding {configObject: SettingssettingName: "loginMode"}}RowLayout {spacing: 0RadioButton {id: loginManualtext: i18nc("@option:radio Manual style of session restoration", "When session was manually saved")checked: Settings.loginMode === 1onToggled: Settings.loginMode = 1KCM.SettingStateBinding {configObject: SettingssettingName: "loginMode"}}Kirigami.ContextualHelpButton {toolTipText: xi18nc("@info", "A <interface>Save Session</interface> button will appear in the <interface>Application Launcher</interface> menu. When you click it, Plasma will remember the apps that are open and restore them on the next login. Click it again to replace the set of remembered apps.")}}RadioButton {id: loginEmptytext: i18nc("@option:radio Here 'session' refers to the technical concept of session restoration, whereby the windows that were open on logout are re-opened on the next login", "Start with an empty session")checked: Settings.loginMode === 2onToggled: Settings.loginMode = 2KCM.SettingStateBinding {configObject: SettingssettingName: "loginMode"}}Item {Kirigami.FormData.isSection: true}ColumnLayout {Kirigami.FormData.label: i18n("Ignored applications:")Kirigami.FormData.buddyFor: ignoredAppsTextFieldspacing: Kirigami.Units.smallSpacingRowLayout {spacing: 0TextField {id: ignoredAppsTextFieldLayout.preferredWidth: Kirigami.Units.gridUnit * 16text: Settings.excludeAppsenabled: !loginEmpty.checked// onTextEdited instead of onAccepted because otherwise the apply and// reset buttons won't work, since otherwise in many case no change will// be sent to the kconfigXt backend.onTextEdited: Settings.excludeApps = textKCM.SettingStateBinding {configObject: SettingssettingName: "excludeApps"}}Kirigami.ContextualHelpButton {toolTipText: i18n("Write apps' executable names here (separated by commas or colons, for example 'xterm:konsole' or 'xterm,konsole') to prevent them from autostarting along with other session-restored apps.")}}}Item {Kirigami.FormData.isSection: trueKirigami.FormData.label: i18nc("@title:group", "Firmware")visible: uefi.visible}CheckBox {id: uefiKirigami.FormData.label: i18nc("@label:check part of a sentence: After next restart enter UEFI/Firmware setup screen", "After next restart:")text: kcm.isUefi ? i18nc("@option:check", "Enter UEFI setup screen"): i18nc("@option:check", "Enter firmware setup screen")visible: kcm.canFirmwareSetupchecked: kcm.restartInSetupScreenonToggled: kcm.restartInSetupScreen = checked}}}