| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2020 George Florea Bănuș <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
import QtQuick |
| 8 |
import QtQuick.Layouts |
| 9 |
import QtQuick.Controls |
| 10 |
|
| 11 |
import org.kde.kirigami as Kirigami |
| 12 |
import org.kde.haruna |
| 13 |
import org.kde.haruna.settings |
| 14 |
|
| 15 |
SettingsBasePage { |
| 16 |
id: root |
| 17 |
|
| 18 |
GridLayout { |
| 19 |
id: content |
| 20 |
|
| 21 |
columns: 2 |
| 22 |
|
| 23 |
Label { |
| 24 |
text: i18nc("@label:textbox", "Preferred language") |
| 25 |
Layout.alignment: Qt.AlignRight |
| 26 |
} |
| 27 |
|
| 28 |
TextField { |
| 29 |
id: preferredLanguage |
| 30 |
|
| 31 |
text: AudioSettings.preferredLanguage |
| 32 |
placeholderText: "eng, ger etc." |
| 33 |
Layout.fillWidth: true |
| 34 |
onEditingFinished: save() |
| 35 |
|
| 36 |
Connections { |
| 37 |
target: root |
| 38 |
function onSave() { |
| 39 |
preferredLanguage.save() |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
function save() { |
| 44 |
AudioSettings.preferredLanguage = text |
| 45 |
AudioSettings.save() |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
Label { |
| 50 |
text: i18nc("@label:spinbox", "Preferred track") |
| 51 |
Layout.alignment: Qt.AlignRight |
| 52 |
} |
| 53 |
|
| 54 |
SpinBox { |
| 55 |
from: 0 |
| 56 |
to: 100 |
| 57 |
value: AudioSettings.preferredTrack |
| 58 |
editable: true |
| 59 |
onValueModified: { |
| 60 |
AudioSettings.preferredTrack = value |
| 61 |
AudioSettings.save() |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
// Volume Step |
| 66 |
Label { |
| 67 |
text: i18nc("@label:spinbox", "Volume step") |
| 68 |
Layout.alignment: Qt.AlignRight |
| 69 |
} |
| 70 |
|
| 71 |
SpinBox { |
| 72 |
id: volumeStep |
| 73 |
editable: true |
| 74 |
from: 0 |
| 75 |
to: 100 |
| 76 |
value: AudioSettings.volumeStep |
| 77 |
onValueModified: { |
| 78 |
AudioSettings.volumeStep = volumeStep.value |
| 79 |
AudioSettings.save() |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
// Replay Gain |
| 84 |
// See: https://mpv.io/manual/stable/#options-replaygain |
| 85 |
SettingsHeader { |
| 86 |
text: i18nc("@title", "Replay gain") |
| 87 |
Layout.columnSpan: 2 |
| 88 |
Layout.fillWidth: true |
| 89 |
} |
| 90 |
|
| 91 |
Label { |
| 92 |
text: i18nc("@label:listbox", "Mode") |
| 93 |
Layout.alignment: Qt.AlignRight |
| 94 |
} |
| 95 |
RowLayout { |
| 96 |
ComboBox { |
| 97 |
textRole: "text" |
| 98 |
valueRole: "value" |
| 99 |
model: ListModel { |
| 100 |
id: replayGainModel |
| 101 |
} |
| 102 |
Component.onCompleted: { |
| 103 |
const noAdjustment = { |
| 104 |
text: i18nc("@item:listbox replay gain", "Disabled"), |
| 105 |
value: "no" |
| 106 |
} |
| 107 |
replayGainModel.append(noAdjustment) |
| 108 |
|
| 109 |
const track = { |
| 110 |
text: i18nc("@item:listbox replay gain", "Track"), |
| 111 |
value: "track" |
| 112 |
} |
| 113 |
replayGainModel.append(track) |
| 114 |
|
| 115 |
const album = { |
| 116 |
text: i18nc("@item:listbox replay gain", "Album"), |
| 117 |
value: "album" |
| 118 |
} |
| 119 |
replayGainModel.append(album) |
| 120 |
|
| 121 |
currentIndex = indexOfValue(AudioSettings.replayGain) |
| 122 |
} |
| 123 |
|
| 124 |
onActivated: function(index) { |
| 125 |
AudioSettings.replayGain = model.get(index).value |
| 126 |
AudioSettings.save() |
| 127 |
} |
| 128 |
} |
| 129 |
ToolTipButton { |
| 130 |
toolTipText: i18nc("@info:tooltip", "Adjust volume gain according to <i>replaygain</i> " + |
| 131 |
"values stored in the file metadata. If set to album gain, " + |
| 132 |
"apply album gain if present and fallback to track gain otherwise.") |
| 133 |
toolTipWidth: 450 |
| 134 |
|
| 135 |
Layout.preferredHeight: Kirigami.Units.iconSizes.medium |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
// Replay Gain Clip |
| 140 |
Item { Layout.preferredWidth: 1 } |
| 141 |
RowLayout { |
| 142 |
CheckBox { |
| 143 |
text: i18nc("@label:spinbox", "Prevent clipping") |
| 144 |
checked: AudioSettings.replayGainPreventClip |
| 145 |
onClicked: { |
| 146 |
AudioSettings.replayGainPreventClip = checked |
| 147 |
AudioSettings.save() |
| 148 |
} |
| 149 |
} |
| 150 |
ToolTipButton { |
| 151 |
toolTipText: i18nc("@info:tooltip", "Prevent clipping by lowering the gain") |
| 152 |
toolTipWidth: 450 |
| 153 |
|
| 154 |
Layout.preferredHeight: Kirigami.Units.iconSizes.medium |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
// Replay Gain Preamp |
| 159 |
Label { |
| 160 |
text: i18nc("@label:spinbox", "Preamp (dB)") |
| 161 |
Layout.alignment: Qt.AlignRight |
| 162 |
} |
| 163 |
RowLayout { |
| 164 |
id: preamp |
| 165 |
SpinBox { |
| 166 |
editable: true |
| 167 |
from: -150 |
| 168 |
to: 150 |
| 169 |
value: AudioSettings.replayGainPreamp |
| 170 |
onValueModified: { |
| 171 |
preamp.setPreamp(value) |
| 172 |
} |
| 173 |
} |
| 174 |
Button { |
| 175 |
flat: true |
| 176 |
icon.name: "edit-reset" |
| 177 |
onClicked: { |
| 178 |
preamp.setPreamp(0) |
| 179 |
} |
| 180 |
ToolTip { |
| 181 |
text: i18nc("@info:tooltip", "Reset to default value") |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
function setPreamp(val) { |
| 186 |
AudioSettings.replayGainPreamp = val |
| 187 |
AudioSettings.save() |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
// Replay Gain Fallback |
| 192 |
Label { |
| 193 |
text: i18nc("@label:spinbox", "Fallback (dB)") |
| 194 |
Layout.alignment: Qt.AlignRight |
| 195 |
} |
| 196 |
RowLayout { |
| 197 |
id: fallback |
| 198 |
SpinBox { |
| 199 |
editable: true |
| 200 |
from: -200 |
| 201 |
to: 60 |
| 202 |
value: AudioSettings.replayGainFallback |
| 203 |
onValueModified: { |
| 204 |
fallback.setFallback(value) |
| 205 |
} |
| 206 |
} |
| 207 |
Button { |
| 208 |
flat: true |
| 209 |
icon.name: "edit-reset" |
| 210 |
onClicked: { |
| 211 |
fallback.setFallback(0) |
| 212 |
} |
| 213 |
ToolTip { |
| 214 |
text: i18nc("@info:tooltip", "Reset to default value") |
| 215 |
} |
| 216 |
} |
| 217 |
ToolTipButton { |
| 218 |
toolTipText: i18nc("@info:tooltip", "Gain in dB to apply if the file has no replay gain tags.<br><br>" + |
| 219 |
"This setting is in effect only when:<br>" + |
| 220 |
"- the replaygain setting is disabled<br>" + |
| 221 |
"- the replaygain setting is enabled and the file has no replaygain metadata<br>" + |
| 222 |
"If this is in effect, other replaygain settings are ignored.") |
| 223 |
toolTipWidth: 450 |
| 224 |
|
| 225 |
Layout.preferredHeight: Kirigami.Units.iconSizes.medium |
| 226 |
} |
| 227 |
|
| 228 |
function setFallback(val) { |
| 229 |
AudioSettings.replayGainFallback = val |
| 230 |
AudioSettings.save() |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
Item { |
| 235 |
Layout.preferredWidth: Kirigami.Units.gridUnit |
| 236 |
Layout.preferredHeight: Kirigami.Units.gridUnit |
| 237 |
} |
| 238 |
} |
| 239 |
} |