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