| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2012 Ricardo Villalba <[email protected]>
|
|---|
| 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 | #ifdef SINGLE_INSTANCE
|
|---|
| 232 | setUseSingleInstance(pref->use_single_instance);
|
|---|
| 233 | #endif
|
|---|
| 234 | setSeeking1(pref->seeking1);
|
|---|
| 235 | setSeeking2(pref->seeking2);
|
|---|
| 236 | setSeeking3(pref->seeking3);
|
|---|
| 237 | setSeeking4(pref->seeking4);
|
|---|
| 238 |
|
|---|
| 239 | setUpdateWhileDragging(pref->update_while_seeking);
|
|---|
| 240 | #ifdef SEEKBAR_RESOLUTION
|
|---|
| 241 | setRelativeSeeking(pref->relative_seeking);
|
|---|
| 242 | #endif
|
|---|
| 243 | setPreciseSeeking(pref->precise_seeking);
|
|---|
| 244 |
|
|---|
| 245 | setDefaultFont(pref->default_font);
|
|---|
| 246 |
|
|---|
| 247 | setHideVideoOnAudioFiles(pref->hide_video_window_on_audio_files);
|
|---|
| 248 |
|
|---|
| 249 | #if STYLE_SWITCHING
|
|---|
| 250 | setStyle( pref->style );
|
|---|
| 251 | #endif
|
|---|
| 252 |
|
|---|
| 253 | setGUI(pref->gui);
|
|---|
| 254 |
|
|---|
| 255 | setFloatingAnimated(pref->floating_control_animated);
|
|---|
| 256 | setFloatingWidth(pref->floating_control_width);
|
|---|
| 257 | setFloatingMargin(pref->floating_control_margin);
|
|---|
| 258 | setDisplayFloatingInCompactMode(pref->floating_display_in_compact_mode);
|
|---|
| 259 | #ifndef Q_OS_WIN
|
|---|
| 260 | setFloatingBypassWindowManager(pref->bypass_window_manager);
|
|---|
| 261 | #endif
|
|---|
| 262 |
|
|---|
| 263 | setRecentsMaxItems(pref->history_recents->maxItems());
|
|---|
| 264 | setURLMaxItems(pref->history_urls->maxItems());
|
|---|
| 265 | setRememberDirs(pref->save_dirs);
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 | void PrefInterface::getData(Preferences * pref) {
|
|---|
| 269 | requires_restart = false;
|
|---|
| 270 | language_changed = false;
|
|---|
| 271 | iconset_changed = false;
|
|---|
| 272 | gui_changed = false;
|
|---|
| 273 | style_changed = false;
|
|---|
| 274 | recents_changed = false;
|
|---|
| 275 |
|
|---|
| 276 | if (pref->language != language()) {
|
|---|
| 277 | pref->language = language();
|
|---|
| 278 | language_changed = true;
|
|---|
| 279 | qDebug("PrefInterface::getData: chosen language: '%s'", pref->language.toUtf8().data());
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | if (pref->iconset != iconSet()) {
|
|---|
| 283 | pref->iconset = iconSet();
|
|---|
| 284 | iconset_changed = true;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | if (pref->gui != GUI()) {
|
|---|
| 288 | pref->gui = GUI();
|
|---|
| 289 | gui_changed = true;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | pref->resize_method = resizeMethod();
|
|---|
| 293 | pref->save_window_size_on_exit = saveSize();
|
|---|
| 294 |
|
|---|
| 295 | #ifdef SINGLE_INSTANCE
|
|---|
| 296 | pref->use_single_instance = useSingleInstance();
|
|---|
| 297 | #endif
|
|---|
| 298 |
|
|---|
| 299 | pref->seeking1 = seeking1();
|
|---|
| 300 | pref->seeking2 = seeking2();
|
|---|
| 301 | pref->seeking3 = seeking3();
|
|---|
| 302 | pref->seeking4 = seeking4();
|
|---|
| 303 |
|
|---|
| 304 | pref->update_while_seeking = updateWhileDragging();
|
|---|
| 305 | #ifdef SEEKBAR_RESOLUTION
|
|---|
| 306 | pref->relative_seeking= relativeSeeking();
|
|---|
| 307 | #endif
|
|---|
| 308 | pref->precise_seeking = preciseSeeking();
|
|---|
| 309 |
|
|---|
| 310 | pref->default_font = defaultFont();
|
|---|
| 311 |
|
|---|
| 312 | pref->hide_video_window_on_audio_files = hideVideoOnAudioFiles();
|
|---|
| 313 |
|
|---|
| 314 | #if STYLE_SWITCHING
|
|---|
| 315 | if ( pref->style != style() ) {
|
|---|
| 316 | pref->style = style();
|
|---|
| 317 | style_changed = true;
|
|---|
| 318 | }
|
|---|
| 319 | #endif
|
|---|
| 320 |
|
|---|
| 321 | pref->floating_control_animated = floatingAnimated();
|
|---|
| 322 | pref->floating_control_width = floatingWidth();
|
|---|
| 323 | pref->floating_control_margin = floatingMargin();
|
|---|
| 324 | pref->floating_display_in_compact_mode = displayFloatingInCompactMode();
|
|---|
| 325 | #ifndef Q_OS_WIN
|
|---|
| 326 | pref->bypass_window_manager = floatingBypassWindowManager();
|
|---|
| 327 | #endif
|
|---|
| 328 |
|
|---|
| 329 | if (pref->history_recents->maxItems() != recentsMaxItems()) {
|
|---|
| 330 | pref->history_recents->setMaxItems( recentsMaxItems() );
|
|---|
| 331 | recents_changed = true;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | if (pref->history_urls->maxItems() != urlMaxItems()) {
|
|---|
| 335 | pref->history_urls->setMaxItems( urlMaxItems() );
|
|---|
| 336 | url_max_changed = true;
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 | pref->save_dirs = rememberDirs();
|
|---|
| 340 | }
|
|---|
| 341 |
|
|---|
| 342 | void PrefInterface::setLanguage(QString lang) {
|
|---|
| 343 | if (lang.isEmpty()) {
|
|---|
| 344 | language_combo->setCurrentIndex(0);
|
|---|
| 345 | }
|
|---|
| 346 | else {
|
|---|
| 347 | int pos = language_combo->findData(lang);
|
|---|
| 348 | if (pos != -1)
|
|---|
| 349 | language_combo->setCurrentIndex( pos );
|
|---|
| 350 | else
|
|---|
| 351 | language_combo->setCurrentText(lang);
|
|---|
| 352 | }
|
|---|
| 353 | }
|
|---|
| 354 |
|
|---|
| 355 | QString PrefInterface::language() {
|
|---|
| 356 | if (language_combo->currentIndex()==0)
|
|---|
| 357 | return "";
|
|---|
| 358 | else
|
|---|
| 359 | return language_combo->itemData( language_combo->currentIndex() ).toString();
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | void PrefInterface::setIconSet(QString set) {
|
|---|
| 363 | /*
|
|---|
| 364 | if (set.isEmpty())
|
|---|
| 365 | iconset_combo->setCurrentIndex(0);
|
|---|
| 366 | else
|
|---|
| 367 | iconset_combo->setCurrentText(set);
|
|---|
| 368 | */
|
|---|
| 369 | iconset_combo->setCurrentIndex(0);
|
|---|
| 370 | for (int n=0; n < iconset_combo->count(); n++) {
|
|---|
| 371 | if (iconset_combo->itemText(n) == set) {
|
|---|
| 372 | iconset_combo->setCurrentIndex(n);
|
|---|
| 373 | break;
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 | #ifdef SKINS
|
|---|
| 377 | skin_combo->setCurrentIndex(0);
|
|---|
| 378 | for (int n=0; n < skin_combo->count(); n++) {
|
|---|
| 379 | if (skin_combo->itemText(n) == set) {
|
|---|
| 380 | skin_combo->setCurrentIndex(n);
|
|---|
| 381 | break;
|
|---|
| 382 | }
|
|---|
| 383 | }
|
|---|
| 384 | #endif
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | QString PrefInterface::iconSet() {
|
|---|
| 388 | #ifdef SKINS
|
|---|
| 389 | QString GUI = gui_combo->itemData(gui_combo->currentIndex()).toString();
|
|---|
| 390 | if (GUI == "SkinGUI") {
|
|---|
| 391 | return skin_combo->currentText();
|
|---|
| 392 | }
|
|---|
| 393 | else
|
|---|
| 394 | #endif
|
|---|
| 395 | if (iconset_combo->currentIndex()==0)
|
|---|
| 396 | return "";
|
|---|
| 397 | else
|
|---|
| 398 | return iconset_combo->currentText();
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | void PrefInterface::setResizeMethod(int v) {
|
|---|
| 402 | mainwindow_resize_combo->setCurrentIndex(v);
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | int PrefInterface::resizeMethod() {
|
|---|
| 406 | return mainwindow_resize_combo->currentIndex();
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | void PrefInterface::setSaveSize(bool b) {
|
|---|
| 410 | save_size_check->setChecked(b);
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | bool PrefInterface::saveSize() {
|
|---|
| 414 | return save_size_check->isChecked();
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 | void PrefInterface::setStyle(QString style) {
|
|---|
| 419 | if (style.isEmpty())
|
|---|
| 420 | style_combo->setCurrentIndex(0);
|
|---|
| 421 | else
|
|---|
| 422 | style_combo->setCurrentText(style);
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 | QString PrefInterface::style() {
|
|---|
| 426 | if (style_combo->currentIndex()==0)
|
|---|
| 427 | return "";
|
|---|
| 428 | else
|
|---|
| 429 | return style_combo->currentText();
|
|---|
| 430 | }
|
|---|
| 431 |
|
|---|
| 432 | void PrefInterface::setGUI(QString gui_name) {
|
|---|
| 433 | #ifdef SKINS
|
|---|
| 434 | if ((n_skins == 0) && (gui_name == "SkinGUI")) gui_name = "DefaultGUI";
|
|---|
| 435 | #endif
|
|---|
| 436 | int i = gui_combo->findData(gui_name);
|
|---|
| 437 | if (i < 0) i=0;
|
|---|
| 438 | gui_combo->setCurrentIndex(i);
|
|---|
| 439 | }
|
|---|
| 440 |
|
|---|
| 441 | QString PrefInterface::GUI() {
|
|---|
| 442 | return gui_combo->itemData(gui_combo->currentIndex()).toString();
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | #ifdef SKINS
|
|---|
| 446 | void PrefInterface::GUIChanged(int index) {
|
|---|
| 447 | if (gui_combo->itemData(index).toString() == "SkinGUI") {
|
|---|
| 448 | iconset_combo->hide();
|
|---|
| 449 | iconset_label->hide();
|
|---|
| 450 | iconset_sp->hide();
|
|---|
| 451 | skin_combo->show();
|
|---|
| 452 | skin_label->show();
|
|---|
| 453 | skin_sp->show();
|
|---|
| 454 | } else {
|
|---|
| 455 | iconset_combo->show();
|
|---|
| 456 | iconset_label->show();
|
|---|
| 457 | iconset_sp->show();
|
|---|
| 458 | skin_combo->hide();
|
|---|
| 459 | skin_label->hide();
|
|---|
| 460 | skin_sp->hide();
|
|---|
| 461 | }
|
|---|
| 462 | }
|
|---|
| 463 | #endif
|
|---|
| 464 |
|
|---|
| 465 | #ifdef SINGLE_INSTANCE
|
|---|
| 466 | void PrefInterface::setUseSingleInstance(bool b) {
|
|---|
| 467 | single_instance_check->setChecked(b);
|
|---|
| 468 | //singleInstanceButtonToggled(b);
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 | bool PrefInterface::useSingleInstance() {
|
|---|
| 472 | return single_instance_check->isChecked();
|
|---|
| 473 | }
|
|---|
| 474 | #endif
|
|---|
| 475 |
|
|---|
| 476 | void PrefInterface::setSeeking1(int n) {
|
|---|
| 477 | seek1->setTime(n);
|
|---|
| 478 | }
|
|---|
| 479 |
|
|---|
| 480 | int PrefInterface::seeking1() {
|
|---|
| 481 | return seek1->time();
|
|---|
| 482 | }
|
|---|
| 483 |
|
|---|
| 484 | void PrefInterface::setSeeking2(int n) {
|
|---|
| 485 | seek2->setTime(n);
|
|---|
| 486 | }
|
|---|
| 487 |
|
|---|
| 488 | int PrefInterface::seeking2() {
|
|---|
| 489 | return seek2->time();
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | void PrefInterface::setSeeking3(int n) {
|
|---|
| 493 | seek3->setTime(n);
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | int PrefInterface::seeking3() {
|
|---|
| 497 | return seek3->time();
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | void PrefInterface::setSeeking4(int n) {
|
|---|
| 501 | seek4->setTime(n);
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | int PrefInterface::seeking4() {
|
|---|
| 505 | return seek4->time();
|
|---|
| 506 | }
|
|---|
| 507 |
|
|---|
| 508 | void PrefInterface::setUpdateWhileDragging(bool b) {
|
|---|
| 509 | if (b)
|
|---|
| 510 | timeslider_behaviour_combo->setCurrentIndex(0);
|
|---|
| 511 | else
|
|---|
| 512 | timeslider_behaviour_combo->setCurrentIndex(1);
|
|---|
| 513 | }
|
|---|
| 514 |
|
|---|
| 515 | bool PrefInterface::updateWhileDragging() {
|
|---|
| 516 | return (timeslider_behaviour_combo->currentIndex() == 0);
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | #ifdef SEEKBAR_RESOLUTION
|
|---|
| 520 | void PrefInterface::setRelativeSeeking(bool b) {
|
|---|
| 521 | relative_seeking_button->setChecked(b);
|
|---|
| 522 | absolute_seeking_button->setChecked(!b);
|
|---|
| 523 | }
|
|---|
| 524 |
|
|---|
| 525 | bool PrefInterface::relativeSeeking() {
|
|---|
| 526 | return relative_seeking_button->isChecked();
|
|---|
| 527 | }
|
|---|
| 528 | #endif
|
|---|
| 529 |
|
|---|
| 530 | void PrefInterface::setPreciseSeeking(bool b) {
|
|---|
| 531 | precise_seeking_check->setChecked(b);
|
|---|
| 532 | }
|
|---|
| 533 |
|
|---|
| 534 | bool PrefInterface::preciseSeeking() {
|
|---|
| 535 | return precise_seeking_check->isChecked();
|
|---|
| 536 | }
|
|---|
| 537 |
|
|---|
| 538 | void PrefInterface::setDefaultFont(QString font_desc) {
|
|---|
| 539 | default_font_edit->setText(font_desc);
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | QString PrefInterface::defaultFont() {
|
|---|
| 543 | return default_font_edit->text();
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | void PrefInterface::on_changeFontButton_clicked() {
|
|---|
| 547 | QFont f = qApp->font();
|
|---|
| 548 |
|
|---|
| 549 | if (!default_font_edit->text().isEmpty()) {
|
|---|
| 550 | f.fromString(default_font_edit->text());
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | bool ok;
|
|---|
| 554 | f = QFontDialog::getFont( &ok, f, this);
|
|---|
| 555 |
|
|---|
| 556 | if (ok) {
|
|---|
| 557 | default_font_edit->setText( f.toString() );
|
|---|
| 558 | }
|
|---|
| 559 | }
|
|---|
| 560 |
|
|---|
| 561 | #ifdef SINGLE_INSTANCE
|
|---|
| 562 | void PrefInterface::changeInstanceImages() {
|
|---|
| 563 | if (single_instance_check->isChecked())
|
|---|
| 564 | instances_icon->setPixmap( Images::icon("instance1") );
|
|---|
| 565 | else
|
|---|
| 566 | instances_icon->setPixmap( Images::icon("instance2") );
|
|---|
| 567 | }
|
|---|
| 568 | #endif
|
|---|
| 569 |
|
|---|
| 570 | void PrefInterface::setHideVideoOnAudioFiles(bool b) {
|
|---|
| 571 | hide_video_window_on_audio_check->setChecked(b);
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | bool PrefInterface::hideVideoOnAudioFiles() {
|
|---|
| 575 | return hide_video_window_on_audio_check->isChecked();
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | // Floating tab
|
|---|
| 579 | void PrefInterface::setFloatingAnimated(bool b) {
|
|---|
| 580 | floating_animated_check->setChecked(b);
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | bool PrefInterface::floatingAnimated() {
|
|---|
| 584 | return floating_animated_check->isChecked();
|
|---|
| 585 | }
|
|---|
| 586 |
|
|---|
| 587 | void PrefInterface::setFloatingWidth(int percentage) {
|
|---|
| 588 | floating_width_slider->setValue(percentage);
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | int PrefInterface::floatingWidth() {
|
|---|
| 592 | return floating_width_slider->value();
|
|---|
| 593 | }
|
|---|
| 594 |
|
|---|
| 595 | void PrefInterface::setFloatingMargin(int pixels) {
|
|---|
| 596 | floating_margin_slider->setValue(pixels);
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 | int PrefInterface::floatingMargin() {
|
|---|
| 600 | return floating_margin_slider->value();
|
|---|
| 601 | }
|
|---|
| 602 |
|
|---|
| 603 | void PrefInterface::setDisplayFloatingInCompactMode(bool b) {
|
|---|
| 604 | floating_compact_check->setChecked(b);
|
|---|
| 605 | }
|
|---|
| 606 |
|
|---|
| 607 | bool PrefInterface::displayFloatingInCompactMode() {
|
|---|
| 608 | return floating_compact_check->isChecked();
|
|---|
| 609 | }
|
|---|
| 610 |
|
|---|
| 611 | #ifndef Q_OS_WIN
|
|---|
| 612 | void PrefInterface::setFloatingBypassWindowManager(bool b) {
|
|---|
| 613 | floating_bypass_wm_check->setChecked(b);
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | bool PrefInterface::floatingBypassWindowManager() {
|
|---|
| 617 | return floating_bypass_wm_check->isChecked();
|
|---|
| 618 | }
|
|---|
| 619 | #endif
|
|---|
| 620 |
|
|---|
| 621 | void PrefInterface::setRecentsMaxItems(int n) {
|
|---|
| 622 | recents_max_items_spin->setValue(n);
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | int PrefInterface::recentsMaxItems() {
|
|---|
| 626 | return recents_max_items_spin->value();
|
|---|
| 627 | }
|
|---|
| 628 |
|
|---|
| 629 | void PrefInterface::setURLMaxItems(int n) {
|
|---|
| 630 | url_max_items_spin->setValue(n);
|
|---|
| 631 | }
|
|---|
| 632 |
|
|---|
| 633 | int PrefInterface::urlMaxItems() {
|
|---|
| 634 | return url_max_items_spin->value();
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | void PrefInterface::setRememberDirs(bool b) {
|
|---|
| 638 | save_dirs_check->setChecked(b);
|
|---|
| 639 | }
|
|---|
| 640 |
|
|---|
| 641 | bool PrefInterface::rememberDirs() {
|
|---|
| 642 | return save_dirs_check->isChecked();
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 | void PrefInterface::createHelp() {
|
|---|
| 646 | clearHelp();
|
|---|
| 647 |
|
|---|
| 648 | addSectionTitle(tr("Interface"));
|
|---|
| 649 |
|
|---|
| 650 | setWhatsThis(mainwindow_resize_combo, tr("Autoresize"),
|
|---|
| 651 | tr("The main window can be resized automatically. Select the option "
|
|---|
| 652 | "you prefer.") );
|
|---|
| 653 |
|
|---|
| 654 | setWhatsThis(save_size_check, tr("Remember position and size"),
|
|---|
| 655 | tr("If you check this option, the position and size of the main "
|
|---|
| 656 | "window will be saved and restored when you run SMPlayer again.") );
|
|---|
| 657 |
|
|---|
| 658 | setWhatsThis(hide_video_window_on_audio_check, tr("Hide video window when playing audio files"),
|
|---|
| 659 | tr("If this option is enabled the video window will be hidden when playing audio files.") );
|
|---|
| 660 |
|
|---|
| 661 | setWhatsThis(language_combo, tr("Language"),
|
|---|
| 662 | tr("Here you can change the language of the application.") );
|
|---|
| 663 |
|
|---|
| 664 | setWhatsThis(gui_combo, tr("GUI"),
|
|---|
| 665 | tr("Select the GUI you prefer for the application. Currently "
|
|---|
| 666 | "there are two available: Default GUI and Mini GUI.<br>"
|
|---|
| 667 | "The <b>Default GUI</b> provides the traditional GUI, with the "
|
|---|
| 668 | "toolbar and control bar. The <b>Mini GUI</b> provides a "
|
|---|
| 669 | "more simple GUI, without toolbar and a control bar with few "
|
|---|
| 670 | "buttons.") );
|
|---|
| 671 |
|
|---|
| 672 | setWhatsThis(iconset_combo, tr("Icon set"),
|
|---|
| 673 | tr("Select the icon set you prefer for the application.") );
|
|---|
| 674 |
|
|---|
| 675 | #ifdef SKINS
|
|---|
| 676 | setWhatsThis(skin_combo, tr("Skin"),
|
|---|
| 677 | tr("Select the skin you prefer for the application. Only available with the skinnable GUI.") );
|
|---|
| 678 | #endif
|
|---|
| 679 |
|
|---|
| 680 | setWhatsThis(style_combo, tr("Style"),
|
|---|
| 681 | tr("Select the style you prefer for the application.") );
|
|---|
| 682 |
|
|---|
| 683 |
|
|---|
| 684 | setWhatsThis(changeFontButton, tr("Default font"),
|
|---|
| 685 | tr("You can change here the application's font.") );
|
|---|
| 686 |
|
|---|
| 687 | addSectionTitle(tr("Seeking"));
|
|---|
| 688 |
|
|---|
| 689 | setWhatsThis(seek1, tr("Short jump"),
|
|---|
| 690 | tr("Select the time that should be go forward or backward when you "
|
|---|
| 691 | "choose the %1 action.").arg(tr("short jump")) );
|
|---|
| 692 |
|
|---|
| 693 | setWhatsThis(seek2, tr("Medium jump"),
|
|---|
| 694 | tr("Select the time that should be go forward or backward when you "
|
|---|
| 695 | "choose the %1 action.").arg(tr("medium jump")) );
|
|---|
| 696 |
|
|---|
| 697 | setWhatsThis(seek3, tr("Long jump"),
|
|---|
| 698 | tr("Select the time that should be go forward or backward when you "
|
|---|
| 699 | "choose the %1 action.").arg(tr("long jump")) );
|
|---|
| 700 |
|
|---|
| 701 | setWhatsThis(seek4, tr("Mouse wheel jump"),
|
|---|
| 702 | tr("Select the time that should be go forward or backward when you "
|
|---|
| 703 | "move the mouse wheel.") );
|
|---|
| 704 |
|
|---|
| 705 | setWhatsThis(timeslider_behaviour_combo, tr("Behaviour of time slider"),
|
|---|
| 706 | tr("Select what to do when dragging the time slider.") );
|
|---|
| 707 |
|
|---|
| 708 | #ifdef SEEKBAR_RESOLUTION
|
|---|
| 709 | setWhatsThis(seeking_method_group, tr("Seeking method"),
|
|---|
| 710 | tr("Sets the method to be used when seeking with the slider. "
|
|---|
| 711 | "Absolute seeking may be a little bit more accurate, while "
|
|---|
| 712 | "relative seeking may work better with files with a wrong length.") );
|
|---|
| 713 | #endif
|
|---|
| 714 |
|
|---|
| 715 | setWhatsThis(precise_seeking_check, tr("Precise seeking"),
|
|---|
| 716 | tr("If this option is enabled, seeks are more accurate but they "
|
|---|
| 717 | "can be a little bit slower. May not work with some video formats.") +"<br>"+
|
|---|
| 718 | tr("Note: this option only works with MPlayer2") );
|
|---|
| 719 |
|
|---|
| 720 | #ifdef SINGLE_INSTANCE
|
|---|
| 721 | addSectionTitle(tr("Instances"));
|
|---|
| 722 |
|
|---|
| 723 | setWhatsThis(single_instance_check,
|
|---|
| 724 | tr("Use only one running instance of SMPlayer"),
|
|---|
| 725 | tr("Check this option if you want to use an already running instance "
|
|---|
| 726 | "of SMPlayer when opening other files.") );
|
|---|
| 727 | #endif
|
|---|
| 728 |
|
|---|
| 729 | addSectionTitle(tr("Floating control"));
|
|---|
| 730 |
|
|---|
| 731 | setWhatsThis(floating_animated_check, tr("Animated"),
|
|---|
| 732 | tr("If this option is enabled, the floating control will appear "
|
|---|
| 733 | "with an animation.") );
|
|---|
| 734 |
|
|---|
| 735 | setWhatsThis(floating_width_slider, tr("Width"),
|
|---|
| 736 | tr("Specifies the width of the control (as a percentage).") );
|
|---|
| 737 |
|
|---|
| 738 | setWhatsThis(floating_margin_slider, tr("Margin"),
|
|---|
| 739 | tr("This option sets the number of pixels that the floating control "
|
|---|
| 740 | "will be away from the bottom of the screen. Useful when the "
|
|---|
| 741 | "screen is a TV, as the overscan might prevent the control to be "
|
|---|
| 742 | "visible.") );
|
|---|
| 743 |
|
|---|
| 744 | setWhatsThis(floating_compact_check, tr("Display in compact mode too"),
|
|---|
| 745 | tr("If this option is enabled, the floating control will appear "
|
|---|
| 746 | "in compact mode too. <b>Warning:</b> the floating control has not been "
|
|---|
| 747 | "designed for compact mode and it might not work properly.") );
|
|---|
| 748 |
|
|---|
| 749 | #ifndef Q_OS_WIN
|
|---|
| 750 | setWhatsThis(floating_bypass_wm_check, tr("Bypass window manager"),
|
|---|
| 751 | tr("If this option is checked, the control is displayed bypassing the "
|
|---|
| 752 | "window manager. Disable this option if the floating control "
|
|---|
| 753 | "doesn't work well with your window manager.") );
|
|---|
| 754 | #endif
|
|---|
| 755 |
|
|---|
| 756 | addSectionTitle(tr("Privacy"));
|
|---|
| 757 |
|
|---|
| 758 | setWhatsThis(recents_max_items_spin, tr("Recent files"),
|
|---|
| 759 | tr("Select the maximum number of items that will be shown in the "
|
|---|
| 760 | "<b>Open->Recent files</b> submenu. If you set it to 0 that "
|
|---|
| 761 | "menu won't be shown at all.") );
|
|---|
| 762 |
|
|---|
| 763 | setWhatsThis(url_max_items_spin, tr("Max. URLs"),
|
|---|
| 764 | tr("Select the maximum number of items that the <b>Open->URL</b> "
|
|---|
| 765 | "dialog will remember. Set it to 0 if you don't want any URL "
|
|---|
| 766 | "to be stored.") );
|
|---|
| 767 |
|
|---|
| 768 | setWhatsThis(save_dirs_check, tr("Remember last directory"),
|
|---|
| 769 | tr("If this option is checked, SMPlayer will remember the last folder you use to open a file.") );
|
|---|
| 770 | }
|
|---|
| 771 |
|
|---|
| 772 | #include "moc_prefinterface.cpp"
|
|---|