Warning, /utilities/krecorder/src/contents/ui/settings/SettingsComponent.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 import QtQuick 0005 import QtQuick.Controls as Controls 0006 import QtQuick.Layouts 0007 import QtMultimedia 0008 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.kirigamiaddons.formcard as FormCard 0011 0012 import KRecorder 0013 0014 ColumnLayout { 0015 id: root 0016 property var dialog: null // dialog component if this is within a dialog 0017 0018 spacing: 0 0019 0020 signal closeRequested() 0021 0022 // HACK: dialog switching requires some time between closing and opening 0023 Timer { 0024 id: dialogTimer 0025 interval: 1 0026 property var dialog 0027 onTriggered: { 0028 root.dialog.close(); 0029 dialog.open(); 0030 } 0031 } 0032 0033 FormCard.FormHeader { 0034 title: i18n("General") 0035 } 0036 0037 FormCard.FormCard { 0038 FormCard.FormButtonDelegate { 0039 id: aboutDelegate 0040 text: i18n("About") 0041 onClicked: { 0042 if (applicationWindow().isWidescreen) { 0043 applicationWindow().pageStack.layers.push("qrc:/AboutPage.qml"); 0044 } else { 0045 applicationWindow().pageStack.push("qrc:/AboutPage.qml"); 0046 } 0047 0048 if (root.dialog) { 0049 root.dialog.close(); 0050 } 0051 } 0052 } 0053 0054 FormCard.FormDelegateSeparator { above: aboutDelegate; below: audioInputDropdown } 0055 0056 FormCard.FormComboBoxDelegate { 0057 id: audioInputDropdown 0058 text: i18n("Audio Input") 0059 displayMode: FormCard.FormComboBoxDelegate.Dialog 0060 0061 textRole: 'name' 0062 valueRole: 'deviceId' 0063 onCurrentValueChanged: { 0064 for (let device of mediaDevices.audioInputs) { 0065 if (device.id === currentValue) { 0066 AudioRecorder.setAudioInput(device); 0067 } 0068 } 0069 } 0070 0071 model: ListModel { 0072 id: inputModel 0073 } 0074 0075 function refreshAudioInputs() { 0076 currentIndex = 0; 0077 for (let i = 0; i < mediaDevices.audioInputs.length; i++) { 0078 let device = mediaDevices.audioInputs[i]; 0079 inputModel.append({"name": device.description, "deviceId": device.id}); 0080 if (device.id == AudioRecorder.audioInput) { 0081 currentIndex = i; 0082 } 0083 } 0084 } 0085 0086 Component.onCompleted: { 0087 refreshAudioInputs(); 0088 } 0089 0090 Connections { 0091 target: AudioRecorder 0092 function onAudioInputChanged() { 0093 audioInputDropdown.refreshAudioInputs(); 0094 } 0095 } 0096 0097 Connections { 0098 target: mediaDevices 0099 function onAudioInputsChanged() { 0100 audioInputDropdown.refreshAudioInputs(); 0101 } 0102 } 0103 0104 MediaDevices { 0105 id: mediaDevices 0106 } 0107 0108 onClicked: if (root.dialog && audioInputDropdown.displayMode === FormCard.FormComboBoxDelegate.Dialog) { 0109 dialogTimer.dialog = audioInputDropdown.dialog; 0110 dialogTimer.restart(); 0111 } 0112 0113 Connections { 0114 target: audioInputDropdown.dialog 0115 function onClosed() { 0116 if (root.dialog) { 0117 root.dialog.open(); 0118 } 0119 } 0120 } 0121 } 0122 } 0123 0124 FormCard.FormHeader { 0125 title: i18n("Advanced") 0126 } 0127 0128 FormCard.FormCard { 0129 0130 FormCard.FormComboBoxDelegate { 0131 id: audioCodecDropdown 0132 text: i18n("Audio Codec") 0133 model: AudioRecorder.supportedAudioCodecs 0134 onCurrentValueChanged: AudioRecorder.audioCodec = currentValue; 0135 displayMode: FormCard.FormComboBoxDelegate.Dialog 0136 0137 Binding on currentIndex { 0138 value: audioCodecDropdown.indexOfValue(SettingsModel.audioCodec) 0139 } 0140 0141 Component.onCompleted: { 0142 // HACK: the values don't load until after the component completes 0143 currentIndex = audioCodecDropdown.indexOfValue(SettingsModel.audioCodec) 0144 } 0145 0146 onClicked: if (root.dialog && audioCodecDropdown.displayMode === FormCard.FormComboBoxDelegate.Dialog) { 0147 dialogTimer.dialog = audioCodecDropdown.dialog; 0148 dialogTimer.restart(); 0149 } 0150 0151 Connections { 0152 target: audioCodecDropdown.dialog 0153 function onClosed() { 0154 if (root.dialog) { 0155 root.dialog.open(); 0156 } 0157 } 0158 } 0159 } 0160 0161 FormCard.FormDelegateSeparator { above: audioCodecDropdown; below: containerFormatDropdown } 0162 0163 FormCard.FormComboBoxDelegate { 0164 id: containerFormatDropdown 0165 text: i18n("Container Format") 0166 model: AudioRecorder.supportedContainers 0167 onCurrentValueChanged: SettingsModel.containerFormat = currentValue; 0168 displayMode: FormCard.FormComboBoxDelegate.Dialog 0169 0170 Binding on currentIndex { 0171 value: containerFormatDropdown.indexOfValue(SettingsModel.containerFormat) 0172 } 0173 0174 Component.onCompleted: { 0175 // HACK: the values don't load until after the component completes 0176 currentIndex = containerFormatDropdown.indexOfValue(SettingsModel.containerFormat) 0177 } 0178 0179 onClicked: if (root.dialog && containerFormatDropdown.displayMode === FormCard.FormComboBoxDelegate.Dialog) { 0180 dialogTimer.dialog = containerFormatDropdown.dialog; 0181 dialogTimer.restart(); 0182 } 0183 0184 Connections { 0185 target: containerFormatDropdown.dialog 0186 function onClosed() { 0187 if (root.dialog) { 0188 root.dialog.open(); 0189 } 0190 } 0191 } 0192 } 0193 0194 FormCard.FormDelegateSeparator { above: containerFormatDropdown; below: audioQualityDropdown } 0195 0196 FormCard.FormComboBoxDelegate { 0197 id: audioQualityDropdown 0198 text: i18n("Audio Quality") 0199 model: [i18n("Lowest"), i18n("Low"), i18n("Medium"), i18n("High"), i18n("Highest")] 0200 description: i18n("Higher audio quality also increases file size.") 0201 onCurrentValueChanged: SettingsModel.audioQuality = currentIndex; 0202 displayMode: FormCard.FormComboBoxDelegate.Dialog 0203 0204 Binding on currentIndex { 0205 value: SettingsModel.audioQuality 0206 } 0207 0208 onClicked: if (root.dialog && audioQualityDropdown.displayMode === FormCard.FormComboBoxDelegate.Dialog) { 0209 dialogTimer.dialog = audioQualityDropdown.dialog; 0210 dialogTimer.restart(); 0211 } 0212 0213 Connections { 0214 target: audioQualityDropdown.dialog 0215 function onClosed() { 0216 if (root.dialog) { 0217 root.dialog.open(); 0218 } 0219 } 0220 } 0221 } 0222 } 0223 0224 FormCard.FormSectionText { 0225 text: i18n("Some combinations of codecs and container formats may not be compatible.") 0226 } 0227 }