Warning, /education/khangman/src/qml/Settings/SettingsPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2012 Laszlo Papp <lpapp@kde.org>
0002 // SPDX-FileCopyrightText: 2014 Rahul Chowdhury <rahul.chowdhury@kdemail.net>
0003 // SPDX-License-Identifier: LGPL-2.1-or-later
0004 
0005 import QtQuick
0006 import QtQuick.Controls as QQC2
0007 import QtQuick.Layouts
0008 import QtQuick.Dialogs
0009 import QtQuick.Window
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.kirigamiaddons.formcard as FormCard
0012 import org.kde.khangman
0013 
0014 FormCard.FormCardPage {
0015     id: mainSettingsDialog
0016 
0017     signal okClicked()
0018     signal cancelClicked()
0019 
0020     title: i18n("KHangMan Settings")
0021 
0022     function saveSettings(): void {
0023         KHangMan.resolveTime = resolveTimeSlider.value;
0024         KHangMan.soundEnabled = soundsSwitch.checked;
0025         KHangMan.scoreMultiplyingFactor = scoreMultiplyingFactor.value;
0026     }
0027 
0028     function resetSettings(): void {
0029         resolveTimeSlider.value = KHangMan.resolveTime;
0030         soundsSwitch.checked = KHangMan.soundEnabled;
0031         scoreMultiplyingFactor.value = KHangMan.scoreMultiplyingFactor;
0032     }
0033 
0034     Component.onCompleted: {
0035         resolveTimeSlider.value = KHangMan.resolveTime;
0036         soundsSwitch.checked = KHangMan.soundEnabled;
0037     }
0038 
0039     topPadding: Kirigami.Units.gridUnit
0040 
0041     FormCard.FormCard {
0042         FormCard.AbstractFormDelegate {
0043             background: null
0044             contentItem: ColumnLayout {
0045                 QQC2.Label {
0046                     id: resolveTimeLabel;
0047                     text: i18n("Word resolve time in seconds");
0048                     wrapMode: Text.WordWrap
0049                 }
0050 
0051                 RowLayout {
0052                     Layout.fillWidth: true
0053                     QQC2.Slider {
0054                         id: resolveTimeSlider;
0055                         stepSize: 15;
0056                         from: 0;
0057                         to: 300;
0058                         Layout.fillWidth: true
0059                     }
0060 
0061                     QQC2.Label {
0062                         text: i18n(resolveTimeSlider.value + (resolveTimeSlider.value == 1 ? " second" : " seconds"))
0063                         wrapMode: Text.WordWrap
0064                     }
0065                 }
0066 
0067                 QQC2.Label {
0068                     text: i18n("The duration for showing the hint for the actual word")
0069                     color: Kirigami.Theme.disabledTextColor
0070                     wrapMode: Text.WordWrap
0071                     Layout.fillWidth: true
0072                 }
0073             }
0074         }
0075 
0076         FormCard.FormDelegateSeparator {}
0077 
0078         FormCard.FormSpinBoxDelegate {
0079             id: scoreMultiplyingFactor
0080 
0081             label: i18n("Score Multiplying Factor:")
0082             value: KHangMan.scoreMultiplyingFactor
0083 
0084             contentItem.data: QQC2.Label {
0085                 text: i18n("Determine the factor by which the scores will be multiplied.")
0086                 color: Kirigami.Theme.disabledTextColor
0087                 wrapMode: Text.WordWrap
0088                 Layout.fillWidth: true
0089             }
0090         }
0091 
0092         FormCard.FormDelegateSeparator {}
0093 
0094         FormCard.FormSwitchDelegate {
0095             id: soundsSwitch
0096             text: i18nc("@option:check", "Enable sounds")
0097         }
0098     }
0099 
0100     footer: QQC2.ToolBar {
0101         contentItem: RowLayout {
0102             Item {
0103                 Layout.fillWidth: true
0104             }
0105 
0106             QQC2.Button {
0107                 text: i18nc("@action:button", "Save")
0108                 icon.name: "document-save"
0109                 onClicked: {
0110                     // save the current settings
0111                     mainSettingsRectangle.saveSettings()
0112                     mainSettingsDialog.okClicked()
0113                 }
0114             }
0115 
0116             QQC2.Button {
0117                 text: i18nc("@action:button", "Cancel")
0118                 icon.name: "dialog-cancel"
0119                 onClicked: {
0120                     // ignore the changes made to the settings
0121                     mainSettingsRectangle.resetSettings()
0122                     mainSettingsDialog.cancelClicked()
0123                 }
0124             }
0125         }
0126     }
0127 }