| 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 QtCore |
| 8 |
import QtQuick |
| 9 |
import QtQuick.Layouts |
| 10 |
import QtQuick.Controls |
| 11 |
import QtQuick.Dialogs |
| 12 |
|
| 13 |
import org.kde.kirigami as Kirigami |
| 14 |
import org.kde.haruna |
| 15 |
import org.kde.haruna.settings |
| 16 |
|
| 17 |
SettingsBasePage { |
| 18 |
id: root |
| 19 |
|
| 20 |
required property MpvVideo m_mpv |
| 21 |
|
| 22 |
GridLayout { |
| 23 |
id: content |
| 24 |
|
| 25 |
columns: 2 |
| 26 |
|
| 27 |
Label { |
| 28 |
text: i18nc("@label:listbox", "Default cover") |
| 29 |
Layout.alignment: Qt.AlignRight |
| 30 |
} |
| 31 |
|
| 32 |
RowLayout { |
| 33 |
TextField { |
| 34 |
id: defaultCover |
| 35 |
|
| 36 |
text: VideoSettings.defaultCover |
| 37 |
placeholderText: i18nc("placeholder text", "path to image") |
| 38 |
Layout.fillWidth: true |
| 39 |
onEditingFinished: save() |
| 40 |
|
| 41 |
Connections { |
| 42 |
target: root |
| 43 |
function onSave() { |
| 44 |
defaultCover.save() |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
ToolTip { |
| 49 |
text: i18nc("@info:tooltip", "Used for music files that don’t have a video track, " |
| 50 |
+ "an embedded cover image or a cover/folder image " |
| 51 |
+ "in the same folder as the played file.") |
| 52 |
} |
| 53 |
|
| 54 |
function save() : void { |
| 55 |
VideoSettings.defaultCover = defaultCover.text |
| 56 |
VideoSettings.save() |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
Button { |
| 61 |
icon.name: "folder" |
| 62 |
onClicked: fileDialog.open() |
| 63 |
} |
| 64 |
|
| 65 |
FileDialog { |
| 66 |
id: fileDialog |
| 67 |
|
| 68 |
currentFolder: StandardPaths.writableLocation(StandardPaths.PicturesLocation) |
| 69 |
title: i18nc("@title:window", "Select file") |
| 70 |
fileMode: FileDialog.OpenFile |
| 71 |
|
| 72 |
onAccepted: { |
| 73 |
VideoSettings.defaultCover = fileDialog.selectedFile |
| 74 |
} |
| 75 |
onRejected: root.m_mpv.focus = true |
| 76 |
onVisibleChanged: { |
| 77 |
HarunaApp.actionsEnabled = !visible |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
SettingsHeader { |
| 83 |
text: i18nc("@title", "Screenshots") |
| 84 |
Layout.columnSpan: 2 |
| 85 |
Layout.fillWidth: true |
| 86 |
} |
| 87 |
|
| 88 |
// ------------------------------------ |
| 89 |
// Screenshot Format |
| 90 |
// ------------------------------------ |
| 91 |
Label { |
| 92 |
text: i18nc("@label:listbox", "Format") |
| 93 |
Layout.alignment: Qt.AlignRight |
| 94 |
} |
| 95 |
|
| 96 |
ComboBox { |
| 97 |
id: screenshotFormat |
| 98 |
textRole: "key" |
| 99 |
model: ListModel { |
| 100 |
ListElement { key: "PNG"; value: "png" } |
| 101 |
ListElement { key: "JPG"; value: "jpg" } |
| 102 |
ListElement { key: "WebP"; value: "webp" } |
| 103 |
ListElement { key: "JPEG XL"; value: "jxl" } |
| 104 |
} |
| 105 |
|
| 106 |
onActivated: function(index) { |
| 107 |
VideoSettings.screenshotFormat = model.get(index).value |
| 108 |
VideoSettings.save() |
| 109 |
} |
| 110 |
|
| 111 |
Component.onCompleted: { |
| 112 |
if (VideoSettings.screenshotFormat === "png") { |
| 113 |
currentIndex = 0 |
| 114 |
} |
| 115 |
if (VideoSettings.screenshotFormat === "jpg") { |
| 116 |
currentIndex = 1 |
| 117 |
} |
| 118 |
if (VideoSettings.screenshotFormat === "webp") { |
| 119 |
currentIndex = 2 |
| 120 |
} |
| 121 |
if (VideoSettings.screenshotFormat === "jxl") { |
| 122 |
currentIndex = 3 |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
// ------------------------------------ |
| 128 |
// Screenshot template |
| 129 |
// ------------------------------------ |
| 130 |
Label { |
| 131 |
text: i18nc("@label:textbox", "Template") |
| 132 |
Layout.alignment: Qt.AlignRight |
| 133 |
} |
| 134 |
|
| 135 |
RowLayout { |
| 136 |
TextField { |
| 137 |
id: screenshotTemplate |
| 138 |
|
| 139 |
text: VideoSettings.screenshotTemplate |
| 140 |
Layout.fillWidth: true |
| 141 |
onEditingFinished: save() |
| 142 |
|
| 143 |
Connections { |
| 144 |
target: root |
| 145 |
function onSave() { |
| 146 |
screenshotTemplate.save() |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
function save() : void { |
| 151 |
VideoSettings.screenshotTemplate = text |
| 152 |
VideoSettings.save() |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
ToolTipButton { |
| 157 |
toolTipWidth: 500 |
| 158 |
toolTipHeight: 300 |
| 159 |
toolTipText: i18nc("@info:tooltip", |
| 160 |
"Specify the filename template used to save screenshots. The template specifies the " + |
| 161 |
"filename without file extension, and can contain format specifiers, which will be " + |
| 162 |
"substituted when taking a screenshot. By default, the template is “%F-%n”. <br>" + |
| 163 |
"The template can start with a relative or absolute path, in order to specify " + |
| 164 |
"a directory location where screenshots should be saved.<br>" + |
| 165 |
"If the final screenshot filename points to an already existing file, the file " + |
| 166 |
"will not be overwritten. The screenshot will either not be saved, or if the template " + |
| 167 |
"contains %n, saved using different, newly generated filename.<br>" + |
| 168 |
"For full info checkout <a href='https://mpv.io/manual/stable/#options-screenshot-template'>https://mpv.io/manual/stable/#options-screenshot-template</a><br><br>" + |
| 169 |
"<strong>Allowed format specifiers:</strong><br>" + |
| 170 |
"<ul><li><strong>%[#][0X]n</strong> A sequence number, padded with zeros to length X.<br>" + |
| 171 |
"<li><strong>%f</strong> Filename of the currently played video.<br>" + |
| 172 |
"<li><strong>%F</strong> Same as %f, but without the file extension.<br>" + |
| 173 |
"<li><strong>%x</strong> Directory path of the currently played video. "+ |
| 174 |
"If the video is not on the filesystem (http:// urls), this expands to an empty string.<br>" + |
| 175 |
"<li><strong>%X{fallback}</strong> Same as %x, but if the video file is not on the " + |
| 176 |
"filesystem, return the fallback string inside the {…}.<br>" + |
| 177 |
"<li><strong>%p</strong> Current playback time. The result is a " + |
| 178 |
"string of the form “HH:MM:SS”.<br>" + |
| 179 |
"<li><strong>%P</strong> Similar to %p, but extended with the playback time in milliseconds “HH:MM:SS.mmm”.<br>" + |
| 180 |
"<li><strong>%wX</strong> Specify the current playback time using the format string X.<br>" + |
| 181 |
"Valid format specifiers:<br>" + |
| 182 |
"<ul><li><strong>%wH</strong> hour (padded with 0 to two digits)</li>" + |
| 183 |
"<li><strong>%wh</strong> hour (not padded)</li>" + |
| 184 |
"<li><strong>%wM</strong> minutes (00–59)</li>" + |
| 185 |
"<li><strong>%wm</strong> total minutes (includes hours, unlike %wM)</li>" + |
| 186 |
"<li><strong>%wS</strong> seconds (00–59)</li>" + |
| 187 |
"<li><strong>%ws</strong> total seconds (includes hours and minutes)</li>" + |
| 188 |
"<li><strong>%wf</strong> like %ws, but as float</li>" + |
| 189 |
"<li><strong>%wT</strong> milliseconds (000–999)</li>" + |
| 190 |
"<li><strong>%%</strong> Replaced with the % character itself.</li></ul><br>") |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
SettingsHeader { |
| 195 |
text: i18nc("@title", "Image adjustments") |
| 196 |
Layout.columnSpan: 2 |
| 197 |
Layout.fillWidth: true |
| 198 |
} |
| 199 |
|
| 200 |
|
| 201 |
// ------------------------------------ |
| 202 |
// CONTRAST |
| 203 |
// ------------------------------------ |
| 204 |
Label { |
| 205 |
text: i18nc("@label:slider", "Contrast") |
| 206 |
Layout.alignment: Qt.AlignRight |
| 207 |
} |
| 208 |
|
| 209 |
ImageAdjustmentSlider { |
| 210 |
id: contrastSlider |
| 211 |
|
| 212 |
value: root.m_mpv.getProperty(MpvProperties.Contrast) |
| 213 |
onSliderValueChanged: function(value) { |
| 214 |
root.m_mpv.setProperty(MpvProperties.Contrast, value.toFixed(0)) |
| 215 |
} |
| 216 |
|
| 217 |
Layout.topMargin: Kirigami.Units.largeSpacing |
| 218 |
} |
| 219 |
|
| 220 |
// ------------------------------------ |
| 221 |
// BRIGHTNESS |
| 222 |
// ------------------------------------ |
| 223 |
Label { |
| 224 |
text: i18nc("@label:slider", "Brightness") |
| 225 |
Layout.alignment: Qt.AlignRight |
| 226 |
} |
| 227 |
|
| 228 |
ImageAdjustmentSlider { |
| 229 |
id: brightnessSlider |
| 230 |
|
| 231 |
value: root.m_mpv.getProperty(MpvProperties.Brightness) |
| 232 |
onSliderValueChanged: function(value) { |
| 233 |
root.m_mpv.setProperty(MpvProperties.Brightness, value.toFixed(0)) |
| 234 |
} |
| 235 |
|
| 236 |
Layout.topMargin: Kirigami.Units.largeSpacing |
| 237 |
} |
| 238 |
|
| 239 |
// ------------------------------------ |
| 240 |
// GAMMA |
| 241 |
// ------------------------------------ |
| 242 |
Label { |
| 243 |
text: i18nc("@label:slider", "Gamma") |
| 244 |
Layout.alignment: Qt.AlignRight |
| 245 |
} |
| 246 |
|
| 247 |
ImageAdjustmentSlider { |
| 248 |
id: gammaSlider |
| 249 |
|
| 250 |
value: root.m_mpv.getProperty(MpvProperties.Gamma) |
| 251 |
onSliderValueChanged: function(value) { |
| 252 |
root.m_mpv.setProperty(MpvProperties.Gamma, value.toFixed(0)) |
| 253 |
} |
| 254 |
|
| 255 |
Layout.topMargin: Kirigami.Units.largeSpacing |
| 256 |
} |
| 257 |
|
| 258 |
// ------------------------------------ |
| 259 |
// SATURATION |
| 260 |
// ------------------------------------ |
| 261 |
Label { |
| 262 |
text: i18nc("@label:slider", "Saturation") |
| 263 |
Layout.alignment: Qt.AlignRight |
| 264 |
} |
| 265 |
|
| 266 |
ImageAdjustmentSlider { |
| 267 |
id: saturationSlider |
| 268 |
|
| 269 |
value: root.m_mpv.getProperty(MpvProperties.Saturation) |
| 270 |
onSliderValueChanged: function(value) { |
| 271 |
root.m_mpv.setProperty(MpvProperties.Saturation, value.toFixed(0)) |
| 272 |
} |
| 273 |
|
| 274 |
Layout.topMargin: Kirigami.Units.largeSpacing |
| 275 |
} |
| 276 |
|
| 277 |
Label { |
| 278 |
text: i18nc("@info", "Middle click on the sliders to reset them") |
| 279 |
Layout.columnSpan: 2 |
| 280 |
Layout.topMargin: Kirigami.Units.largeSpacing |
| 281 |
} |
| 282 |
|
| 283 |
} |
| 284 |
} |