/*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.Form {Dialogs.FileDialog {id: fileDialogtitle: i18nc("@title:window dialog","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}}Kirigami.FormGroup {Kirigami.FormEntry {title: i18nc("@label prefix for checkbox", "Audible bell:")contentItem: QQC2.CheckBox {id: systemBelltext: i18nc("Enable the system bell", "Enable")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "SystemBell"}checked: kcm.bellSettings.systemBellonToggled: kcm.bellSettings.systemBell = checked}}Kirigami.FormEntry {title: i18nc("Defines if the system will use a sound system bell", "Custom sound:")contentItem: QQC2.CheckBox {id: customBellKCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "CustomBell"extraEnabledConditions: kcm.bellSettings.systemBell}checked: kcm.bellSettings.customBellonToggled: kcm.bellSettings.customBell= checked}trailingItems: [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: i18nc("@action:button icononly tooltip", "Choose audio file for the system bell")Accessible.name: i18nc("@action button accessible only", "Choose audio file")Accessible.description: i18nc("@info:usagetip accessible description for button", "Opens dialog")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "CustomBellFile"extraEnabledConditions: kcm.bellSettings.customBell}onClicked: fileDialog.open()}]}}Kirigami.FormGroup {Kirigami.FormEntry {title: i18nc("@label prefix for checkbox", "Visual bell:")contentItem: QQC2.CheckBox {id: visibleBelltext: i18nc("@option:check Enable visual bell", "Enable")KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "VisibleBell"}checked: kcm.bellSettings.visibleBellonToggled: kcm.bellSettings.visibleBell = checked}}Kirigami.FormEntry {contentItem: 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}}Kirigami.FormEntry {enabled: kcm.bellSettings.visibleBellcontentItem: QQC2.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}trailingItems: [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}]}Kirigami.FormEntry {title: i18nc("Duration of the system bell", "Duration:")contentItem: QQC2.SpinBox {from: 100to: 2000KCMUtils.SettingStateBinding {configObject: kcm.bellSettingssettingName: "VisibleBellPause"extraEnabledConditions: kcm.bellSettings.visibleBell}value: kcm.bellSettings.visibleBellPauseonValueModified: kcm.bellSettings.visibleBellPause = valuetextFromValue: function(value, locale) {return i18ncp("@label:valuesuffix %1 is visible bell duration", "%1 ms", "%1 ms", value)}valueFromText: (text, locale) => {return Number.fromLocaleString(locale, text.replace(i18ncp("@label:valuesuffix short for millisecond(s)", "ms", "ms"), ""))}}}}}