/*SPDX-FileCopyrightText: 2018 Tomaz Canabrava <tcanabrava@kde.org>SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL*/import QtQuickimport QtQuick.Layoutsimport QtQuick.Controls as QQC2import QtQuick.Dialogs as Dialogsimport org.kde.kcmutils as KCMUtilsimport org.kde.kquickcontrols as KQuickAddonsimport org.kde.kirigami as KirigamiKirigami.FormLayout {Dialogs.FileDialog {id: fileDialogtitle: i18n("Please choose an audio file")nameFilters: [i18nc("Name filters in a file dialog. Do not translate `(*.ogg *.oga *.wav)`","ogg, oga, and wav audio files (*.ogg *.oga *.wav)")]onAccepted: {kcm.bellSettings.customBellFile = fileDialog.selectedFile}}QQC2.CheckBox {id: systemBellKirigami.FormData.label: i18n("Audible bell:")text: i18nc("Enable the system bell", "Enable")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "SystemBell"}checked: kcm.bellSettings.systemBellonToggled: kcm.bellSettings.systemBell = checked}QQC2.Label {Layout.fillWidth: truetext: i18nc("@label", "Emits a sound whenever certain keys are pressed")leftPadding: systemBell.indicator.widthtextFormat: Text.PlainTextelide: Text.ElideRightfont: Kirigami.Theme.smallFont}RowLayout {Kirigami.FormData.label: i18nc("Defines if the system will use a sound system bell", "Custom sound:")spacing: 0QQC2.CheckBox {id: customBellLayout.alignment: Qt.AlignVCenterKCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "CustomBell"extraEnabledConditions: kcm.bellSettings.systemBell}checked: kcm.bellSettings.customBellonToggled: kcm.bellSettings.customBell= checked}QQC2.TextField {id: textEdittext: kcm.bellSettings.customBellFileKCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "CustomBellFile"extraEnabledConditions: kcm.bellSettings.customBell}onEditingFinished: kcm.bellSettings.customBellFile = textEdit.text}QQC2.Button {icon.name: "folder"QQC2.ToolTip.visible: downQQC2.ToolTip.text: i18n("Search audio file for the system bell")Accessible.name: i18n("Button search audio file")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "CustomBellFile"extraEnabledConditions: kcm.bellSettings.customBell}onClicked: fileDialog.open()}}Item {Kirigami.FormData.isSection: true}QQC2.CheckBox {id: visibleBellKirigami.FormData.label: i18n("Visual bell:")text: i18nc("Enable visual bell", "Enable")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "VisibleBell"}checked: kcm.bellSettings.visibleBellonToggled: kcm.bellSettings.visibleBell = checked}QQC2.Label {Layout.fillWidth: truetext: i18nc("@label", "Flashes the screen whenever certain keys are pressed")leftPadding: visibleBell.indicator.widthtextFormat: Text.PlainTextelide: Text.ElideRightfont: Kirigami.Theme.smallFont}QQC2.RadioButton {id: invertScreentext: i18nc("@option:radio Invert screen colors when a system bell is rung", "Invert screen colors")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "InvertScreen"extraEnabledConditions: kcm.bellSettings.visibleBell}checked: kcm.bellSettings.invertScreenonToggled: kcm.bellSettings.invertScreen = checked}RowLayout {spacing: Kirigami.Units.smallSpacingenabled: kcm.bellSettings.visibleBellQQC2.RadioButton {id: flashScreentext: i18nc("@option:radio Flash screen when a system bell is rung", "Flash screen")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "InvertScreen"}checked: !kcm.bellSettings.invertScreenonToggled: kcm.bellSettings.invertScreen = !checked}KQuickAddons.ColorButton {text: i18nc("Color of the system bell","Color")// avoid to show text outside buttondisplay: QQC2.AbstractButton.IconOnlyKCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "VisibleBellColor"}color: kcm.bellSettings.visibleBellColoronAccepted: color => kcm.bellSettings.visibleBellColor = color}}QQC2.SpinBox {Kirigami.FormData.label: i18nc("Duration of the system bell", "Duration:")from: 100to: 2000KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "VisibleBellPause"extraEnabledConditions: kcm.bellSettings.visibleBell}value: kcm.bellSettings.visibleBellPauseonValueModified: kcm.bellSettings.visibleBellPause = valuetextFromValue: function(value, locale) {return i18np("%1 ms", "%1 ms", value)}valueFromText: (text, locale) => {return Number.fromLocaleString(locale, text.replace(i18ncp("short for millisecond(s)", "ms", "ms"), ""))}}}