1 | /* smplayer, GUI front-end for mplayer.
|
---|
2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
3 |
|
---|
4 | This program is free software; you can redistribute it and/or modify
|
---|
5 | it under the terms of the GNU General Public License as published by
|
---|
6 | the Free Software Foundation; either version 2 of the License, or
|
---|
7 | (at your option) any later version.
|
---|
8 |
|
---|
9 | This program is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | GNU General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU General Public License
|
---|
15 | along with this program; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | #include "prefinterface.h"
|
---|
21 | #include "images.h"
|
---|
22 | #include "preferences.h"
|
---|
23 | #include "paths.h"
|
---|
24 | #include "languages.h"
|
---|
25 | #include "recents.h"
|
---|
26 | #include "urlhistory.h"
|
---|
27 | #include "autohidewidget.h"
|
---|
28 |
|
---|
29 | #include <QDir>
|
---|
30 | #include <QStyleFactory>
|
---|
31 | #include <QFontDialog>
|
---|
32 |
|
---|
33 | #ifdef HDPI_SUPPORT
|
---|
34 | #include "hdpisupport.h"
|
---|
35 |
|
---|
36 | #if QT_VERSION >= 0x050600
|
---|
37 | #define HDPI_USE_SCALE_FACTOR
|
---|
38 | #endif
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | #define SINGLE_INSTANCE_TAB 2
|
---|
42 | #define HDPI_TAB 5
|
---|
43 |
|
---|
44 | PrefInterface::PrefInterface(QWidget * parent, Qt::WindowFlags f)
|
---|
45 | : PrefWidget(parent, f )
|
---|
46 | {
|
---|
47 | setupUi(this);
|
---|
48 | /* volume_icon->hide(); */
|
---|
49 |
|
---|
50 | // Style combo
|
---|
51 | #if !STYLE_SWITCHING
|
---|
52 | style_label->hide();
|
---|
53 | style_combo->hide();
|
---|
54 | #else
|
---|
55 | style_combo->addItem( "<default>" );
|
---|
56 | style_combo->addItems( QStyleFactory::keys() );
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | // Icon set combo
|
---|
60 | iconset_combo->addItem( "Default" );
|
---|
61 |
|
---|
62 | #ifdef SKINS
|
---|
63 | n_skins = 0;
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | // User
|
---|
67 | QDir icon_dir = Paths::configPath() + "/themes";
|
---|
68 | qDebug("icon_dir: %s", icon_dir.absolutePath().toUtf8().data());
|
---|
69 | QStringList iconsets = icon_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
---|
70 | for (int n=0; n < iconsets.count(); n++) {
|
---|
71 | #ifdef SKINS
|
---|
72 | QString css_file = Paths::configPath() + "/themes/" + iconsets[n] + "/main.css";
|
---|
73 | bool is_skin = QFile::exists(css_file);
|
---|
74 | //qDebug("***** %s %d", css_file.toUtf8().constData(), is_skin);
|
---|
75 | if (is_skin) {
|
---|
76 | skin_combo->addItem( iconsets[n] );
|
---|
77 | n_skins++;
|
---|
78 | }
|
---|
79 | else
|
---|
80 | #endif
|
---|
81 | iconset_combo->addItem( iconsets[n] );
|
---|
82 | }
|
---|
83 | // Global
|
---|
84 | icon_dir = Paths::themesPath();
|
---|
85 | qDebug("icon_dir: %s", icon_dir.absolutePath().toUtf8().data());
|
---|
86 | iconsets = icon_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
---|
87 | for (int n=0; n < iconsets.count(); n++) {
|
---|
88 | #ifdef SKINS
|
---|
89 | QString css_file = Paths::themesPath() + "/" + iconsets[n] + "/main.css";
|
---|
90 | bool is_skin = QFile::exists(css_file);
|
---|
91 | //qDebug("***** %s %d", css_file.toUtf8().constData(), is_skin);
|
---|
92 | if ((is_skin) && (skin_combo->findText( iconsets[n] ) == -1)) {
|
---|
93 | skin_combo->addItem( iconsets[n] );
|
---|
94 | n_skins++;
|
---|
95 | }
|
---|
96 | else
|
---|
97 | #endif
|
---|
98 | if (iconset_combo->findText( iconsets[n] ) == -1) {
|
---|
99 | iconset_combo->addItem( iconsets[n] );
|
---|
100 | }
|
---|
101 | }
|
---|
102 | #ifdef SKINS
|
---|
103 | if (skin_combo->itemText(0) == "Black") {
|
---|
104 | skin_combo->removeItem(0);
|
---|
105 | skin_combo->addItem("Black");
|
---|
106 | }
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | #ifdef SINGLE_INSTANCE
|
---|
110 | connect(single_instance_check, SIGNAL(toggled(bool)),
|
---|
111 | this, SLOT(changeInstanceImages()));
|
---|
112 | #else
|
---|
113 | tabWidget->setTabEnabled(SINGLE_INSTANCE_TAB, false);
|
---|
114 | #endif
|
---|
115 |
|
---|
116 | #ifdef SKINS
|
---|
117 | connect(gui_combo, SIGNAL(currentIndexChanged(int)),
|
---|
118 | this, SLOT(GUIChanged(int)));
|
---|
119 | #endif
|
---|
120 |
|
---|
121 | connect(mainwindow_resize_combo, SIGNAL(currentIndexChanged(int)),
|
---|
122 | this, SLOT(resizeMethodChanged(int)));
|
---|
123 |
|
---|
124 | #ifndef SEEKBAR_RESOLUTION
|
---|
125 | seeking_method_group->hide();
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | #ifndef SKINS
|
---|
129 | skin_combo->hide();
|
---|
130 | skin_label->hide();
|
---|
131 | skin_sp->hide();
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | #ifdef HDPI_SUPPORT
|
---|
135 | scale_group->setEnabled(false);
|
---|
136 | connect(hdpi_scale_slider, SIGNAL(valueChanged(int)), this, SLOT(updateHDPIScaleNumber(int)));
|
---|
137 | #ifndef HDPI_STORE_DATA
|
---|
138 | tabWidget->setTabEnabled(HDPI_TAB, false);
|
---|
139 | #endif
|
---|
140 | #else
|
---|
141 | tabWidget->setTabEnabled(HDPI_TAB, false);
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | retranslateStrings();
|
---|
145 | }
|
---|
146 |
|
---|
147 | PrefInterface::~PrefInterface()
|
---|
148 | {
|
---|
149 | }
|
---|
150 |
|
---|
151 | QString PrefInterface::sectionName() {
|
---|
152 | return tr("Interface");
|
---|
153 | }
|
---|
154 |
|
---|
155 | QPixmap PrefInterface::sectionIcon() {
|
---|
156 | return Images::icon("pref_gui");
|
---|
157 | }
|
---|
158 |
|
---|
159 | void PrefInterface::createLanguageCombo() {
|
---|
160 | QMap <QString,QString> m = Languages::translations();
|
---|
161 |
|
---|
162 | // Language combo
|
---|
163 | QDir translation_dir = Paths::translationPath();
|
---|
164 | QStringList languages = translation_dir.entryList( QStringList() << "*.qm");
|
---|
165 | QRegExp rx_lang("smplayer_(.*)\\.qm");
|
---|
166 | language_combo->clear();
|
---|
167 | language_combo->addItem("<" + tr("System language") + ">");
|
---|
168 | for (int n=0; n < languages.count(); n++) {
|
---|
169 | if (rx_lang.indexIn(languages[n]) > -1) {
|
---|
170 | QString l = rx_lang.cap(1);
|
---|
171 | QString text = l;
|
---|
172 | if (m.contains(l)) text = m[l] + " ("+l+")";
|
---|
173 | language_combo->addItem( text, l );
|
---|
174 | }
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | void PrefInterface::retranslateStrings() {
|
---|
179 | int mainwindow_resize = mainwindow_resize_combo->currentIndex();
|
---|
180 | int timeslider_pos = timeslider_behaviour_combo->currentIndex();
|
---|
181 |
|
---|
182 | retranslateUi(this);
|
---|
183 |
|
---|
184 | mainwindow_resize_combo->setCurrentIndex(mainwindow_resize);
|
---|
185 | timeslider_behaviour_combo->setCurrentIndex(timeslider_pos);
|
---|
186 |
|
---|
187 | // Icons
|
---|
188 | /* resize_window_icon->setPixmap( Images::icon("resize_window") ); */
|
---|
189 | /* volume_icon->setPixmap( Images::icon("speaker") ); */
|
---|
190 |
|
---|
191 | #ifdef SINGLE_INSTANCE
|
---|
192 | changeInstanceImages();
|
---|
193 | #endif
|
---|
194 |
|
---|
195 | // Seek widgets
|
---|
196 | seek1->setLabel( tr("&Short jump") );
|
---|
197 | seek2->setLabel( tr("&Medium jump") );
|
---|
198 | seek3->setLabel( tr("&Long jump") );
|
---|
199 | seek4->setLabel( tr("Mouse &wheel jump") );
|
---|
200 |
|
---|
201 | if (qApp->isLeftToRight()) {
|
---|
202 | seek1->setIcon( Images::icon("forward10s", 32) );
|
---|
203 | seek2->setIcon( Images::icon("forward1m", 32) );
|
---|
204 | seek3->setIcon( Images::icon("forward10m", 32) );
|
---|
205 | } else {
|
---|
206 | seek1->setIcon( Images::flippedIcon("forward10s", 32) );
|
---|
207 | seek2->setIcon( Images::flippedIcon("forward1m", 32) );
|
---|
208 | seek3->setIcon( Images::flippedIcon("forward10m", 32) );
|
---|
209 | }
|
---|
210 | seek4->setIcon( Images::icon("mouse",32) );
|
---|
211 |
|
---|
212 | // Language combo
|
---|
213 | int language_item = language_combo->currentIndex();
|
---|
214 | createLanguageCombo();
|
---|
215 | language_combo->setCurrentIndex( language_item );
|
---|
216 |
|
---|
217 | // Iconset combo
|
---|
218 | iconset_combo->setItemText( 0, tr("Default") );
|
---|
219 |
|
---|
220 | #if STYLE_SWITCHING
|
---|
221 | style_combo->setItemText( 0, tr("Default") );
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | int gui_index = gui_combo->currentIndex();
|
---|
225 | gui_combo->clear();
|
---|
226 | #ifdef DEFAULTGUI
|
---|
227 | gui_combo->addItem( tr("Basic GUI"), "DefaultGUI");
|
---|
228 | #endif
|
---|
229 | #ifdef MINIGUI
|
---|
230 | gui_combo->addItem( tr("Mini GUI"), "MiniGUI");
|
---|
231 | #endif
|
---|
232 | #ifdef MPCGUI
|
---|
233 | gui_combo->addItem( tr("Mpc GUI"), "MpcGUI");
|
---|
234 | #endif
|
---|
235 | #ifdef SKINS
|
---|
236 | gui_combo->addItem( tr("Skinnable GUI"), "SkinGUI");
|
---|
237 | if (n_skins == 0) {
|
---|
238 | QModelIndex index = gui_combo->model()->index(gui_combo->count()-1,0);
|
---|
239 | gui_combo->model()->setData(index, QVariant(0), Qt::UserRole -1);
|
---|
240 | }
|
---|
241 | #endif
|
---|
242 | gui_combo->setCurrentIndex(gui_index);
|
---|
243 |
|
---|
244 | floating_width_label->setNum(floating_width_slider->value());
|
---|
245 | floating_margin_label->setNum(floating_margin_slider->value());
|
---|
246 |
|
---|
247 | #ifdef HDPI_SUPPORT
|
---|
248 | #ifdef HDPI_USE_SCALE_FACTOR
|
---|
249 | hdpi_scale_label->setText(tr("Scale fact&or:"));
|
---|
250 | hdpi_scale_num_label->setNum((double) hdpi_scale_slider->value() / 10);
|
---|
251 | #else
|
---|
252 | hdpi_scale_label->setText(tr("Pixel rati&o:"));
|
---|
253 | hdpi_scale_num_label->setNum(hdpi_scale_slider->value());
|
---|
254 | #endif
|
---|
255 | #endif
|
---|
256 |
|
---|
257 | createHelp();
|
---|
258 | }
|
---|
259 |
|
---|
260 | void PrefInterface::setData(Preferences * pref) {
|
---|
261 | setLanguage( pref->language );
|
---|
262 | setIconSet( pref->iconset );
|
---|
263 |
|
---|
264 | setResizeMethod( pref->resize_method );
|
---|
265 | setSaveSize( pref->save_window_size_on_exit );
|
---|
266 |
|
---|
267 | center_window_check->setChecked(pref->center_window);
|
---|
268 | center_if_outside_check->setChecked(pref->center_window_if_outside);
|
---|
269 |
|
---|
270 | #ifdef SINGLE_INSTANCE
|
---|
271 | setUseSingleInstance(pref->use_single_instance);
|
---|
272 | #endif
|
---|
273 | setSeeking1(pref->seeking1);
|
---|
274 | setSeeking2(pref->seeking2);
|
---|
275 | setSeeking3(pref->seeking3);
|
---|
276 | setSeeking4(pref->seeking4);
|
---|
277 |
|
---|
278 | setUpdateWhileDragging(pref->update_while_seeking);
|
---|
279 | #ifdef SEEKBAR_RESOLUTION
|
---|
280 | setRelativeSeeking(pref->relative_seeking);
|
---|
281 | #endif
|
---|
282 | setPreciseSeeking(pref->precise_seeking);
|
---|
283 |
|
---|
284 | reset_stop_check->setChecked(pref->reset_stop);
|
---|
285 |
|
---|
286 | setDefaultFont(pref->default_font);
|
---|
287 |
|
---|
288 | setHideVideoOnAudioFiles(pref->hide_video_window_on_audio_files);
|
---|
289 |
|
---|
290 | #if STYLE_SWITCHING
|
---|
291 | setStyle( pref->style );
|
---|
292 | #endif
|
---|
293 |
|
---|
294 | setGUI(pref->gui);
|
---|
295 |
|
---|
296 | setFloatingAnimated(pref->floating_control_animated);
|
---|
297 | setFloatingWidth(pref->floating_control_width);
|
---|
298 | setFloatingMargin(pref->floating_control_margin);
|
---|
299 | setDisplayFloatingInCompactMode(pref->floating_display_in_compact_mode);
|
---|
300 | floating_move_bottom_check->setChecked(pref->floating_activation_area == AutohideWidget::Bottom);
|
---|
301 | floating_hide_delay_spin->setValue(pref->floating_hide_delay);
|
---|
302 |
|
---|
303 | setRecentsMaxItems(pref->history_recents->maxItems());
|
---|
304 | setURLMaxItems(pref->history_urls->maxItems());
|
---|
305 | setRememberDirs(pref->save_dirs);
|
---|
306 |
|
---|
307 | #ifdef HDPI_SUPPORT
|
---|
308 | loadHDPIData();
|
---|
309 | #endif
|
---|
310 | }
|
---|
311 |
|
---|
312 | void PrefInterface::getData(Preferences * pref) {
|
---|
313 | requires_restart = false;
|
---|
314 | language_changed = false;
|
---|
315 | iconset_changed = false;
|
---|
316 | gui_changed = false;
|
---|
317 | style_changed = false;
|
---|
318 | recents_changed = false;
|
---|
319 |
|
---|
320 | if (pref->language != language()) {
|
---|
321 | pref->language = language();
|
---|
322 | language_changed = true;
|
---|
323 | qDebug("PrefInterface::getData: chosen language: '%s'", pref->language.toUtf8().data());
|
---|
324 | }
|
---|
325 |
|
---|
326 | if (pref->iconset != iconSet()) {
|
---|
327 | pref->iconset = iconSet();
|
---|
328 | iconset_changed = true;
|
---|
329 | }
|
---|
330 |
|
---|
331 | if (pref->gui != GUI()) {
|
---|
332 | pref->gui = GUI();
|
---|
333 | gui_changed = true;
|
---|
334 | }
|
---|
335 |
|
---|
336 | pref->resize_method = resizeMethod();
|
---|
337 | pref->save_window_size_on_exit = saveSize();
|
---|
338 |
|
---|
339 | pref->center_window = center_window_check->isChecked();
|
---|
340 | pref->center_window_if_outside = center_if_outside_check->isChecked();
|
---|
341 |
|
---|
342 | #ifdef SINGLE_INSTANCE
|
---|
343 | pref->use_single_instance = useSingleInstance();
|
---|
344 | #endif
|
---|
345 |
|
---|
346 | pref->seeking1 = seeking1();
|
---|
347 | pref->seeking2 = seeking2();
|
---|
348 | pref->seeking3 = seeking3();
|
---|
349 | pref->seeking4 = seeking4();
|
---|
350 |
|
---|
351 | pref->update_while_seeking = updateWhileDragging();
|
---|
352 | #ifdef SEEKBAR_RESOLUTION
|
---|
353 | pref->relative_seeking= relativeSeeking();
|
---|
354 | #endif
|
---|
355 | pref->precise_seeking = preciseSeeking();
|
---|
356 |
|
---|
357 | pref->reset_stop = reset_stop_check->isChecked();
|
---|
358 |
|
---|
359 | pref->default_font = defaultFont();
|
---|
360 |
|
---|
361 | pref->hide_video_window_on_audio_files = hideVideoOnAudioFiles();
|
---|
362 |
|
---|
363 | #if STYLE_SWITCHING
|
---|
364 | if ( pref->style != style() ) {
|
---|
365 | pref->style = style();
|
---|
366 | style_changed = true;
|
---|
367 | }
|
---|
368 | #endif
|
---|
369 |
|
---|
370 | pref->floating_control_animated = floatingAnimated();
|
---|
371 | pref->floating_control_width = floatingWidth();
|
---|
372 | pref->floating_control_margin = floatingMargin();
|
---|
373 | pref->floating_display_in_compact_mode = displayFloatingInCompactMode();
|
---|
374 | pref->floating_activation_area = floating_move_bottom_check->isChecked() ? AutohideWidget::Bottom : AutohideWidget::Anywhere;
|
---|
375 | pref->floating_hide_delay = floating_hide_delay_spin->value();
|
---|
376 |
|
---|
377 | if (pref->history_recents->maxItems() != recentsMaxItems()) {
|
---|
378 | pref->history_recents->setMaxItems( recentsMaxItems() );
|
---|
379 | recents_changed = true;
|
---|
380 | }
|
---|
381 |
|
---|
382 | if (pref->history_urls->maxItems() != urlMaxItems()) {
|
---|
383 | pref->history_urls->setMaxItems( urlMaxItems() );
|
---|
384 | url_max_changed = true;
|
---|
385 | }
|
---|
386 |
|
---|
387 | pref->save_dirs = rememberDirs();
|
---|
388 |
|
---|
389 | #ifdef HDPI_SUPPORT
|
---|
390 | saveHDPIData();
|
---|
391 | #endif
|
---|
392 | }
|
---|
393 |
|
---|
394 | void PrefInterface::setLanguage(QString lang) {
|
---|
395 | if (lang.isEmpty()) {
|
---|
396 | language_combo->setCurrentIndex(0);
|
---|
397 | }
|
---|
398 | else {
|
---|
399 | int pos = language_combo->findData(lang);
|
---|
400 | if (pos != -1)
|
---|
401 | language_combo->setCurrentIndex( pos );
|
---|
402 | else
|
---|
403 | language_combo->setCurrentText(lang);
|
---|
404 | }
|
---|
405 | }
|
---|
406 |
|
---|
407 | QString PrefInterface::language() {
|
---|
408 | if (language_combo->currentIndex()==0)
|
---|
409 | return "";
|
---|
410 | else
|
---|
411 | return language_combo->itemData( language_combo->currentIndex() ).toString();
|
---|
412 | }
|
---|
413 |
|
---|
414 | void PrefInterface::setIconSet(QString set) {
|
---|
415 | /*
|
---|
416 | if (set.isEmpty())
|
---|
417 | iconset_combo->setCurrentIndex(0);
|
---|
418 | else
|
---|
419 | iconset_combo->setCurrentText(set);
|
---|
420 | */
|
---|
421 | iconset_combo->setCurrentIndex(0);
|
---|
422 | for (int n=0; n < iconset_combo->count(); n++) {
|
---|
423 | if (iconset_combo->itemText(n) == set) {
|
---|
424 | iconset_combo->setCurrentIndex(n);
|
---|
425 | break;
|
---|
426 | }
|
---|
427 | }
|
---|
428 | #ifdef SKINS
|
---|
429 | skin_combo->setCurrentIndex(0);
|
---|
430 | for (int n=0; n < skin_combo->count(); n++) {
|
---|
431 | if (skin_combo->itemText(n) == set) {
|
---|
432 | skin_combo->setCurrentIndex(n);
|
---|
433 | break;
|
---|
434 | }
|
---|
435 | }
|
---|
436 | #endif
|
---|
437 | }
|
---|
438 |
|
---|
439 | QString PrefInterface::iconSet() {
|
---|
440 | #ifdef SKINS
|
---|
441 | QString GUI = gui_combo->itemData(gui_combo->currentIndex()).toString();
|
---|
442 | if (GUI == "SkinGUI") {
|
---|
443 | return skin_combo->currentText();
|
---|
444 | }
|
---|
445 | else
|
---|
446 | #endif
|
---|
447 | if (iconset_combo->currentIndex()==0)
|
---|
448 | return "";
|
---|
449 | else
|
---|
450 | return iconset_combo->currentText();
|
---|
451 | }
|
---|
452 |
|
---|
453 | void PrefInterface::setResizeMethod(int v) {
|
---|
454 | mainwindow_resize_combo->setCurrentIndex(v);
|
---|
455 | }
|
---|
456 |
|
---|
457 | int PrefInterface::resizeMethod() {
|
---|
458 | return mainwindow_resize_combo->currentIndex();
|
---|
459 | }
|
---|
460 |
|
---|
461 | void PrefInterface::setSaveSize(bool b) {
|
---|
462 | save_size_check->setChecked(b);
|
---|
463 | }
|
---|
464 |
|
---|
465 | bool PrefInterface::saveSize() {
|
---|
466 | return save_size_check->isChecked();
|
---|
467 | }
|
---|
468 |
|
---|
469 |
|
---|
470 | void PrefInterface::setStyle(QString style) {
|
---|
471 | if (style.isEmpty()) {
|
---|
472 | style_combo->setCurrentIndex(0);
|
---|
473 | } else {
|
---|
474 | int i = style_combo->findText(style, Qt::MatchFixedString);
|
---|
475 | if (i < 0) i = 0;
|
---|
476 | style_combo->setCurrentIndex(i);
|
---|
477 | }
|
---|
478 | }
|
---|
479 |
|
---|
480 | QString PrefInterface::style() {
|
---|
481 | if (style_combo->currentIndex() == 0)
|
---|
482 | return "";
|
---|
483 | else
|
---|
484 | return style_combo->currentText();
|
---|
485 | }
|
---|
486 |
|
---|
487 | void PrefInterface::setGUI(QString gui_name) {
|
---|
488 | #ifdef SKINS
|
---|
489 | if ((n_skins == 0) && (gui_name == "SkinGUI")) gui_name = "DefaultGUI";
|
---|
490 | #endif
|
---|
491 | int i = gui_combo->findData(gui_name);
|
---|
492 | if (i < 0) i=0;
|
---|
493 | gui_combo->setCurrentIndex(i);
|
---|
494 | }
|
---|
495 |
|
---|
496 | QString PrefInterface::GUI() {
|
---|
497 | return gui_combo->itemData(gui_combo->currentIndex()).toString();
|
---|
498 | }
|
---|
499 |
|
---|
500 | #ifdef SKINS
|
---|
501 | void PrefInterface::GUIChanged(int index) {
|
---|
502 | if (gui_combo->itemData(index).toString() == "SkinGUI") {
|
---|
503 | iconset_combo->hide();
|
---|
504 | iconset_label->hide();
|
---|
505 | iconset_sp->hide();
|
---|
506 | skin_combo->show();
|
---|
507 | skin_label->show();
|
---|
508 | skin_sp->show();
|
---|
509 | } else {
|
---|
510 | iconset_combo->show();
|
---|
511 | iconset_label->show();
|
---|
512 | iconset_sp->show();
|
---|
513 | skin_combo->hide();
|
---|
514 | skin_label->hide();
|
---|
515 | skin_sp->hide();
|
---|
516 | }
|
---|
517 | }
|
---|
518 | #endif
|
---|
519 |
|
---|
520 | void PrefInterface::resizeMethodChanged(int index) {
|
---|
521 | center_if_outside_check->setEnabled(index != 0);
|
---|
522 | }
|
---|
523 |
|
---|
524 | #ifdef SINGLE_INSTANCE
|
---|
525 | void PrefInterface::setUseSingleInstance(bool b) {
|
---|
526 | single_instance_check->setChecked(b);
|
---|
527 | //singleInstanceButtonToggled(b);
|
---|
528 | }
|
---|
529 |
|
---|
530 | bool PrefInterface::useSingleInstance() {
|
---|
531 | return single_instance_check->isChecked();
|
---|
532 | }
|
---|
533 | #endif
|
---|
534 |
|
---|
535 | void PrefInterface::setSeeking1(int n) {
|
---|
536 | seek1->setTime(n);
|
---|
537 | }
|
---|
538 |
|
---|
539 | int PrefInterface::seeking1() {
|
---|
540 | return seek1->time();
|
---|
541 | }
|
---|
542 |
|
---|
543 | void PrefInterface::setSeeking2(int n) {
|
---|
544 | seek2->setTime(n);
|
---|
545 | }
|
---|
546 |
|
---|
547 | int PrefInterface::seeking2() {
|
---|
548 | return seek2->time();
|
---|
549 | }
|
---|
550 |
|
---|
551 | void PrefInterface::setSeeking3(int n) {
|
---|
552 | seek3->setTime(n);
|
---|
553 | }
|
---|
554 |
|
---|
555 | int PrefInterface::seeking3() {
|
---|
556 | return seek3->time();
|
---|
557 | }
|
---|
558 |
|
---|
559 | void PrefInterface::setSeeking4(int n) {
|
---|
560 | seek4->setTime(n);
|
---|
561 | }
|
---|
562 |
|
---|
563 | int PrefInterface::seeking4() {
|
---|
564 | return seek4->time();
|
---|
565 | }
|
---|
566 |
|
---|
567 | void PrefInterface::setUpdateWhileDragging(bool b) {
|
---|
568 | if (b)
|
---|
569 | timeslider_behaviour_combo->setCurrentIndex(0);
|
---|
570 | else
|
---|
571 | timeslider_behaviour_combo->setCurrentIndex(1);
|
---|
572 | }
|
---|
573 |
|
---|
574 | bool PrefInterface::updateWhileDragging() {
|
---|
575 | return (timeslider_behaviour_combo->currentIndex() == 0);
|
---|
576 | }
|
---|
577 |
|
---|
578 | #ifdef SEEKBAR_RESOLUTION
|
---|
579 | void PrefInterface::setRelativeSeeking(bool b) {
|
---|
580 | relative_seeking_button->setChecked(b);
|
---|
581 | absolute_seeking_button->setChecked(!b);
|
---|
582 | }
|
---|
583 |
|
---|
584 | bool PrefInterface::relativeSeeking() {
|
---|
585 | return relative_seeking_button->isChecked();
|
---|
586 | }
|
---|
587 | #endif
|
---|
588 |
|
---|
589 | void PrefInterface::setPreciseSeeking(bool b) {
|
---|
590 | precise_seeking_check->setChecked(b);
|
---|
591 | }
|
---|
592 |
|
---|
593 | bool PrefInterface::preciseSeeking() {
|
---|
594 | return precise_seeking_check->isChecked();
|
---|
595 | }
|
---|
596 |
|
---|
597 | void PrefInterface::setDefaultFont(QString font_desc) {
|
---|
598 | default_font_edit->setText(font_desc);
|
---|
599 | }
|
---|
600 |
|
---|
601 | QString PrefInterface::defaultFont() {
|
---|
602 | return default_font_edit->text();
|
---|
603 | }
|
---|
604 |
|
---|
605 | void PrefInterface::on_changeFontButton_clicked() {
|
---|
606 | QFont f = qApp->font();
|
---|
607 |
|
---|
608 | if (!default_font_edit->text().isEmpty()) {
|
---|
609 | f.fromString(default_font_edit->text());
|
---|
610 | }
|
---|
611 |
|
---|
612 | bool ok;
|
---|
613 | f = QFontDialog::getFont( &ok, f, this);
|
---|
614 |
|
---|
615 | if (ok) {
|
---|
616 | default_font_edit->setText( f.toString() );
|
---|
617 | }
|
---|
618 | }
|
---|
619 |
|
---|
620 | #ifdef SINGLE_INSTANCE
|
---|
621 | void PrefInterface::changeInstanceImages() {
|
---|
622 | if (single_instance_check->isChecked())
|
---|
623 | instances_icon->setPixmap( Images::icon("instance1") );
|
---|
624 | else
|
---|
625 | instances_icon->setPixmap( Images::icon("instance2") );
|
---|
626 | }
|
---|
627 | #endif
|
---|
628 |
|
---|
629 | void PrefInterface::setHideVideoOnAudioFiles(bool b) {
|
---|
630 | hide_video_window_on_audio_check->setChecked(b);
|
---|
631 | }
|
---|
632 |
|
---|
633 | bool PrefInterface::hideVideoOnAudioFiles() {
|
---|
634 | return hide_video_window_on_audio_check->isChecked();
|
---|
635 | }
|
---|
636 |
|
---|
637 | // Floating tab
|
---|
638 | void PrefInterface::setFloatingAnimated(bool b) {
|
---|
639 | floating_animated_check->setChecked(b);
|
---|
640 | }
|
---|
641 |
|
---|
642 | bool PrefInterface::floatingAnimated() {
|
---|
643 | return floating_animated_check->isChecked();
|
---|
644 | }
|
---|
645 |
|
---|
646 | void PrefInterface::setFloatingWidth(int percentage) {
|
---|
647 | floating_width_slider->setValue(percentage);
|
---|
648 | }
|
---|
649 |
|
---|
650 | int PrefInterface::floatingWidth() {
|
---|
651 | return floating_width_slider->value();
|
---|
652 | }
|
---|
653 |
|
---|
654 | void PrefInterface::setFloatingMargin(int pixels) {
|
---|
655 | floating_margin_slider->setValue(pixels);
|
---|
656 | }
|
---|
657 |
|
---|
658 | int PrefInterface::floatingMargin() {
|
---|
659 | return floating_margin_slider->value();
|
---|
660 | }
|
---|
661 |
|
---|
662 | void PrefInterface::setDisplayFloatingInCompactMode(bool b) {
|
---|
663 | floating_compact_check->setChecked(b);
|
---|
664 | }
|
---|
665 |
|
---|
666 | bool PrefInterface::displayFloatingInCompactMode() {
|
---|
667 | return floating_compact_check->isChecked();
|
---|
668 | }
|
---|
669 |
|
---|
670 | void PrefInterface::setRecentsMaxItems(int n) {
|
---|
671 | recents_max_items_spin->setValue(n);
|
---|
672 | }
|
---|
673 |
|
---|
674 | int PrefInterface::recentsMaxItems() {
|
---|
675 | return recents_max_items_spin->value();
|
---|
676 | }
|
---|
677 |
|
---|
678 | void PrefInterface::setURLMaxItems(int n) {
|
---|
679 | url_max_items_spin->setValue(n);
|
---|
680 | }
|
---|
681 |
|
---|
682 | int PrefInterface::urlMaxItems() {
|
---|
683 | return url_max_items_spin->value();
|
---|
684 | }
|
---|
685 |
|
---|
686 | void PrefInterface::setRememberDirs(bool b) {
|
---|
687 | save_dirs_check->setChecked(b);
|
---|
688 | }
|
---|
689 |
|
---|
690 | bool PrefInterface::rememberDirs() {
|
---|
691 | return save_dirs_check->isChecked();
|
---|
692 | }
|
---|
693 |
|
---|
694 | #ifdef HDPI_SUPPORT
|
---|
695 | void PrefInterface::loadHDPIData() {
|
---|
696 | HDPISupport * hdpi = HDPISupport::instance();
|
---|
697 | enable_hdpi_check->setChecked(hdpi->isHDPIEnabled());
|
---|
698 | auto_scale_check->setChecked(hdpi->autoScale());
|
---|
699 |
|
---|
700 | #ifdef HDPI_USE_SCALE_FACTOR
|
---|
701 | hdpi_scale_slider->setMinimum(5);
|
---|
702 | hdpi_scale_slider->setMaximum(4*10);
|
---|
703 | hdpi_scale_slider->setValue(hdpi->scaleFactor() * 10);
|
---|
704 | #else
|
---|
705 | hdpi_scale_slider->setMinimum(0);
|
---|
706 | hdpi_scale_slider->setMaximum(4);
|
---|
707 | hdpi_scale_slider->setValue(hdpi->pixelRatio());
|
---|
708 | #endif
|
---|
709 | }
|
---|
710 |
|
---|
711 | void PrefInterface::updateHDPIScaleNumber(int v) {
|
---|
712 | #ifdef HDPI_USE_SCALE_FACTOR
|
---|
713 | hdpi_scale_num_label->setNum((double) v / 10);
|
---|
714 | #else
|
---|
715 | hdpi_scale_num_label->setNum(v);
|
---|
716 | #endif
|
---|
717 | }
|
---|
718 |
|
---|
719 | void PrefInterface::saveHDPIData() {
|
---|
720 | HDPISupport * hdpi = HDPISupport::instance();
|
---|
721 | hdpi->setHDPIEnabled(enable_hdpi_check->isChecked());
|
---|
722 | hdpi->setAutoScale(auto_scale_check->isChecked());
|
---|
723 | #ifdef HDPI_USE_SCALE_FACTOR
|
---|
724 | hdpi->setScaleFactor((double) hdpi_scale_slider->value() / 10);
|
---|
725 | #else
|
---|
726 | hdpi->setPixelRatio(hdpi_scale_slider->value());
|
---|
727 | #endif
|
---|
728 | #ifdef HDPI_STORE_DATA
|
---|
729 | hdpi->save();
|
---|
730 | #endif
|
---|
731 | }
|
---|
732 | #endif
|
---|
733 |
|
---|
734 | void PrefInterface::createHelp() {
|
---|
735 | clearHelp();
|
---|
736 |
|
---|
737 | addSectionTitle(tr("Interface"));
|
---|
738 |
|
---|
739 | setWhatsThis(mainwindow_resize_combo, tr("Autoresize"),
|
---|
740 | tr("The main window can be resized automatically. Select the option "
|
---|
741 | "you prefer.") );
|
---|
742 |
|
---|
743 | setWhatsThis(center_if_outside_check, tr("Prevent window to get outside of screen"),
|
---|
744 | tr("If after an autoresize the main window gets outside of the screen this option "
|
---|
745 | "will center the window to prevent it.") );
|
---|
746 |
|
---|
747 | setWhatsThis(center_window_check, tr("Center window"),
|
---|
748 | tr("When this option is enabled, the main window will be centered on the desktop.") );
|
---|
749 |
|
---|
750 | setWhatsThis(save_size_check, tr("Remember position and size"),
|
---|
751 | tr("If you check this option, the position and size of the main "
|
---|
752 | "window will be saved and restored when you run SMPlayer again.") );
|
---|
753 |
|
---|
754 | setWhatsThis(hide_video_window_on_audio_check, tr("Hide video window when playing audio files"),
|
---|
755 | tr("If this option is enabled the video window will be hidden when playing audio files.") );
|
---|
756 |
|
---|
757 | setWhatsThis(language_combo, tr("Language"),
|
---|
758 | tr("Here you can change the language of the application.") );
|
---|
759 |
|
---|
760 | setWhatsThis(gui_combo, tr("GUI"),
|
---|
761 | tr("Select the graphic interface you prefer for the application.") +"<br>"+
|
---|
762 | tr("The <b>Basic GUI</b> provides the traditional interface, with the "
|
---|
763 | "toolbar and control bar.") +" "+
|
---|
764 | tr("The <b>Mini GUI</b> provides a more simple interface, without toolbar and a control bar with few "
|
---|
765 | "buttons.")
|
---|
766 | #ifdef MPCGUI
|
---|
767 | +" "+
|
---|
768 | tr("The <b>Mpc GUI</b> looks like the interface in Media Player Classic.")
|
---|
769 | #endif
|
---|
770 | #ifdef SKINS
|
---|
771 | +" "+
|
---|
772 | tr("The <b>Skinnable GUI</b> provides an interface where several skins are available.")
|
---|
773 | #endif
|
---|
774 |
|
---|
775 | );
|
---|
776 |
|
---|
777 | setWhatsThis(iconset_combo, tr("Icon set"),
|
---|
778 | tr("Select the icon set you prefer for the application.") );
|
---|
779 |
|
---|
780 | #ifdef SKINS
|
---|
781 | setWhatsThis(skin_combo, tr("Skin"),
|
---|
782 | tr("Select the skin you prefer for the application. Only available with the skinnable GUI.") );
|
---|
783 | #endif
|
---|
784 |
|
---|
785 | setWhatsThis(style_combo, tr("Style"),
|
---|
786 | tr("Select the style you prefer for the application.") );
|
---|
787 |
|
---|
788 |
|
---|
789 | setWhatsThis(changeFontButton, tr("Default font"),
|
---|
790 | tr("You can change here the application's font.") );
|
---|
791 |
|
---|
792 | addSectionTitle(tr("Seeking"));
|
---|
793 |
|
---|
794 | setWhatsThis(seek1, tr("Short jump"),
|
---|
795 | tr("Select the time that should be go forward or backward when you "
|
---|
796 | "choose the %1 action.").arg(tr("short jump")) );
|
---|
797 |
|
---|
798 | setWhatsThis(seek2, tr("Medium jump"),
|
---|
799 | tr("Select the time that should be go forward or backward when you "
|
---|
800 | "choose the %1 action.").arg(tr("medium jump")) );
|
---|
801 |
|
---|
802 | setWhatsThis(seek3, tr("Long jump"),
|
---|
803 | tr("Select the time that should be go forward or backward when you "
|
---|
804 | "choose the %1 action.").arg(tr("long jump")) );
|
---|
805 |
|
---|
806 | setWhatsThis(seek4, tr("Mouse wheel jump"),
|
---|
807 | tr("Select the time that should be go forward or backward when you "
|
---|
808 | "move the mouse wheel.") );
|
---|
809 |
|
---|
810 | setWhatsThis(timeslider_behaviour_combo, tr("Behaviour of time slider"),
|
---|
811 | tr("Select what to do when dragging the time slider.") );
|
---|
812 |
|
---|
813 | #ifdef SEEKBAR_RESOLUTION
|
---|
814 | setWhatsThis(seeking_method_group, tr("Seeking method"),
|
---|
815 | tr("Sets the method to be used when seeking with the slider. "
|
---|
816 | "Absolute seeking may be a little bit more accurate, while "
|
---|
817 | "relative seeking may work better with files with a wrong length.") );
|
---|
818 | #endif
|
---|
819 |
|
---|
820 | setWhatsThis(precise_seeking_check, tr("Precise seeking"),
|
---|
821 | tr("If this option is enabled, seeks are more accurate but they "
|
---|
822 | "can be a little bit slower. May not work with some video formats.") +"<br>"+
|
---|
823 | tr("Note: this option only works with MPlayer2") );
|
---|
824 |
|
---|
825 | setWhatsThis(reset_stop_check, tr("Pressing the stop button once resets the time position"),
|
---|
826 | tr("By default when the stop button is pressed the time position is remembered "
|
---|
827 | "so if you press play button the media will resume at the same point. You need "
|
---|
828 | "to press the stop button twice to reset the time position, but if this "
|
---|
829 | "option is checked the time position will be set to 0 with only one "
|
---|
830 | "press of the stop button.") );
|
---|
831 |
|
---|
832 | #ifdef SINGLE_INSTANCE
|
---|
833 | addSectionTitle(tr("Instances"));
|
---|
834 |
|
---|
835 | setWhatsThis(single_instance_check,
|
---|
836 | tr("Use only one running instance of SMPlayer"),
|
---|
837 | tr("Check this option if you want to use an already running instance "
|
---|
838 | "of SMPlayer when opening other files.") );
|
---|
839 | #endif
|
---|
840 |
|
---|
841 | addSectionTitle(tr("Floating control"));
|
---|
842 |
|
---|
843 | setWhatsThis(floating_animated_check, tr("Animated"),
|
---|
844 | tr("If this option is enabled, the floating control will appear "
|
---|
845 | "with an animation.") );
|
---|
846 |
|
---|
847 | setWhatsThis(floating_width_slider, tr("Width"),
|
---|
848 | tr("Specifies the width of the control (as a percentage).") );
|
---|
849 |
|
---|
850 | setWhatsThis(floating_margin_slider, tr("Margin"),
|
---|
851 | tr("This option sets the number of pixels that the floating control "
|
---|
852 | "will be away from the bottom of the screen. Useful when the "
|
---|
853 | "screen is a TV, as the overscan might prevent the control to be "
|
---|
854 | "visible.") );
|
---|
855 |
|
---|
856 | setWhatsThis(floating_move_bottom_check, tr("Show only when moving the mouse to the bottom of the screen"),
|
---|
857 | tr("If this option is checked, the floating control will only be displayed when the mouse is moved "
|
---|
858 | "to the bottom of the screen. Otherwise the control will appear whenever the mouse is moved, no matter "
|
---|
859 | "its position.") );
|
---|
860 |
|
---|
861 | setWhatsThis(floating_compact_check, tr("Display in compact mode too"),
|
---|
862 | tr("If this option is enabled, the floating control will appear "
|
---|
863 | "in compact mode too.") +" " +
|
---|
864 | tr("This option only works with the basic GUI.") +" "+
|
---|
865 | tr("<b>Warning:</b> the floating control has not been "
|
---|
866 | "designed for compact mode and it might not work properly.") );
|
---|
867 |
|
---|
868 | setWhatsThis(floating_hide_delay_spin, tr("Time to hide the control"),
|
---|
869 | tr("Sets the time (in milliseconds) to hide the control after the mouse went away from the control."));
|
---|
870 |
|
---|
871 | addSectionTitle(tr("Privacy"));
|
---|
872 |
|
---|
873 | setWhatsThis(recents_max_items_spin, tr("Recent files"),
|
---|
874 | tr("Select the maximum number of items that will be shown in the "
|
---|
875 | "<b>Open->Recent files</b> submenu. If you set it to 0 that "
|
---|
876 | "menu won't be shown at all.") );
|
---|
877 |
|
---|
878 | setWhatsThis(url_max_items_spin, tr("Max. URLs"),
|
---|
879 | tr("Select the maximum number of items that the <b>Open->URL</b> "
|
---|
880 | "dialog will remember. Set it to 0 if you don't want any URL "
|
---|
881 | "to be stored.") );
|
---|
882 |
|
---|
883 | setWhatsThis(save_dirs_check, tr("Remember last directory"),
|
---|
884 | tr("If this option is checked, SMPlayer will remember the last folder you use to open a file.") );
|
---|
885 | }
|
---|
886 |
|
---|
887 | #include "moc_prefinterface.cpp"
|
---|