diff options
Diffstat (limited to 'src/prefinterface.cpp')
-rw-r--r-- | src/prefinterface.cpp | 207 |
1 files changed, 177 insertions, 30 deletions
diff --git a/src/prefinterface.cpp b/src/prefinterface.cpp index a737f40..e8a6ce2 100644 --- a/src/prefinterface.cpp +++ b/src/prefinterface.cpp @@ -21,9 +21,9 @@ #include "images.h" #include "preferences.h" #include "paths.h" -#include "config.h" #include "languages.h" #include "recents.h" +#include "urlhistory.h" #include <QDir> #include <QStyleFactory> @@ -49,11 +49,25 @@ PrefInterface::PrefInterface(QWidget * parent, Qt::WindowFlags f) // Icon set combo iconset_combo->addItem( "Default" ); +#ifdef SKINS + n_skins = 0; +#endif + // User QDir icon_dir = Paths::configPath() + "/themes"; qDebug("icon_dir: %s", icon_dir.absolutePath().toUtf8().data()); QStringList iconsets = icon_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (int n=0; n < iconsets.count(); n++) { + #ifdef SKINS + QString css_file = Paths::configPath() + "/themes/" + iconsets[n] + "/main.css"; + bool is_skin = QFile::exists(css_file); + //qDebug("***** %s %d", css_file.toUtf8().constData(), is_skin); + if (is_skin) { + skin_combo->addItem( iconsets[n] ); + n_skins++; + } + else + #endif iconset_combo->addItem( iconsets[n] ); } // Global @@ -61,10 +75,26 @@ PrefInterface::PrefInterface(QWidget * parent, Qt::WindowFlags f) qDebug("icon_dir: %s", icon_dir.absolutePath().toUtf8().data()); iconsets = icon_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); for (int n=0; n < iconsets.count(); n++) { + #ifdef SKINS + QString css_file = Paths::themesPath() + "/" + iconsets[n] + "/main.css"; + bool is_skin = QFile::exists(css_file); + //qDebug("***** %s %d", css_file.toUtf8().constData(), is_skin); + if ((is_skin) && (iconset_combo->findText( iconsets[n] ) == -1)) { + skin_combo->addItem( iconsets[n] ); + n_skins++; + } + else + #endif if (iconset_combo->findText( iconsets[n] ) == -1) { iconset_combo->addItem( iconsets[n] ); } } + #ifdef SKINS + if (skin_combo->itemText(0) == "Black") { + skin_combo->removeItem(0); + skin_combo->addItem("Black"); + } + #endif #ifdef SINGLE_INSTANCE connect(single_instance_check, SIGNAL(toggled(bool)), @@ -73,10 +103,25 @@ PrefInterface::PrefInterface(QWidget * parent, Qt::WindowFlags f) tabWidget->setTabEnabled(SINGLE_INSTANCE_TAB, false); #endif +#ifdef SKINS + connect(gui_combo, SIGNAL(currentIndexChanged(int)), + this, SLOT(GUIChanged(int))); +#endif + #ifdef Q_OS_WIN floating_bypass_wm_check->hide(); #endif +#ifndef SEEKBAR_RESOLUTION + seeking_method_group->hide(); +#endif + +#ifndef SKINS + skin_combo->hide(); + skin_label->hide(); + skin_sp->hide(); +#endif + retranslateStrings(); } @@ -162,6 +207,13 @@ void PrefInterface::retranslateStrings() { gui_combo->addItem( tr("Default GUI"), "DefaultGUI"); gui_combo->addItem( tr("Mini GUI"), "MiniGUI"); gui_combo->addItem( tr("Mpc GUI"), "MpcGUI"); +#ifdef SKINS + gui_combo->addItem( tr("Skinnable GUI"), "SkinGUI"); + if (n_skins == 0) { + QModelIndex index = gui_combo->model()->index(gui_combo->count()-1,0); + gui_combo->model()->setData(index, QVariant(0), Qt::UserRole -1); + } +#endif gui_combo->setCurrentIndex(gui_index); floating_width_label->setNum(floating_width_slider->value()); @@ -179,15 +231,15 @@ void PrefInterface::setData(Preferences * pref) { #ifdef SINGLE_INSTANCE setUseSingleInstance(pref->use_single_instance); #endif - setRecentsMaxItems(pref->history_recents->maxItems()); - setSeeking1(pref->seeking1); setSeeking2(pref->seeking2); setSeeking3(pref->seeking3); setSeeking4(pref->seeking4); setUpdateWhileDragging(pref->update_while_seeking); +#ifdef SEEKBAR_RESOLUTION setRelativeSeeking(pref->relative_seeking); +#endif setPreciseSeeking(pref->precise_seeking); setDefaultFont(pref->default_font); @@ -207,6 +259,10 @@ void PrefInterface::setData(Preferences * pref) { #ifndef Q_OS_WIN setFloatingBypassWindowManager(pref->bypass_window_manager); #endif + + setRecentsMaxItems(pref->history_recents->maxItems()); + setURLMaxItems(pref->history_urls->maxItems()); + setRememberDirs(pref->save_dirs); } void PrefInterface::getData(Preferences * pref) { @@ -240,18 +296,15 @@ void PrefInterface::getData(Preferences * pref) { pref->use_single_instance = useSingleInstance(); #endif - if (pref->history_recents->maxItems() != recentsMaxItems()) { - pref->history_recents->setMaxItems( recentsMaxItems() ); - recents_changed = true; - } - pref->seeking1 = seeking1(); pref->seeking2 = seeking2(); pref->seeking3 = seeking3(); pref->seeking4 = seeking4(); pref->update_while_seeking = updateWhileDragging(); +#ifdef SEEKBAR_RESOLUTION pref->relative_seeking= relativeSeeking(); +#endif pref->precise_seeking = preciseSeeking(); pref->default_font = defaultFont(); @@ -272,6 +325,18 @@ void PrefInterface::getData(Preferences * pref) { #ifndef Q_OS_WIN pref->bypass_window_manager = floatingBypassWindowManager(); #endif + + if (pref->history_recents->maxItems() != recentsMaxItems()) { + pref->history_recents->setMaxItems( recentsMaxItems() ); + recents_changed = true; + } + + if (pref->history_urls->maxItems() != urlMaxItems()) { + pref->history_urls->setMaxItems( urlMaxItems() ); + url_max_changed = true; + } + + pref->save_dirs = rememberDirs(); } void PrefInterface::setLanguage(QString lang) { @@ -295,13 +360,38 @@ QString PrefInterface::language() { } void PrefInterface::setIconSet(QString set) { + /* if (set.isEmpty()) iconset_combo->setCurrentIndex(0); else iconset_combo->setCurrentText(set); + */ + iconset_combo->setCurrentIndex(0); + for (int n=0; n < iconset_combo->count(); n++) { + if (iconset_combo->itemText(n) == set) { + iconset_combo->setCurrentIndex(n); + break; + } + } +#ifdef SKINS + skin_combo->setCurrentIndex(0); + for (int n=0; n < skin_combo->count(); n++) { + if (skin_combo->itemText(n) == set) { + skin_combo->setCurrentIndex(n); + break; + } + } +#endif } QString PrefInterface::iconSet() { +#ifdef SKINS + QString GUI = gui_combo->itemData(gui_combo->currentIndex()).toString(); + if (GUI == "SkinGUI") { + return skin_combo->currentText(); + } + else +#endif if (iconset_combo->currentIndex()==0) return ""; else @@ -340,6 +430,9 @@ QString PrefInterface::style() { } void PrefInterface::setGUI(QString gui_name) { +#ifdef SKINS + if ((n_skins == 0) && (gui_name == "SkinGUI")) gui_name = "DefaultGUI"; +#endif int i = gui_combo->findData(gui_name); if (i < 0) i=0; gui_combo->setCurrentIndex(i); @@ -349,6 +442,26 @@ QString PrefInterface::GUI() { return gui_combo->itemData(gui_combo->currentIndex()).toString(); } +#ifdef SKINS +void PrefInterface::GUIChanged(int index) { + if (gui_combo->itemData(index).toString() == "SkinGUI") { + iconset_combo->hide(); + iconset_label->hide(); + iconset_sp->hide(); + skin_combo->show(); + skin_label->show(); + skin_sp->show(); + } else { + iconset_combo->show(); + iconset_label->show(); + iconset_sp->show(); + skin_combo->hide(); + skin_label->hide(); + skin_sp->hide(); + } +} +#endif + #ifdef SINGLE_INSTANCE void PrefInterface::setUseSingleInstance(bool b) { single_instance_check->setChecked(b); @@ -360,14 +473,6 @@ bool PrefInterface::useSingleInstance() { } #endif -void PrefInterface::setRecentsMaxItems(int n) { - recents_max_items_spin->setValue(n); -} - -int PrefInterface::recentsMaxItems() { - return recents_max_items_spin->value(); -} - void PrefInterface::setSeeking1(int n) { seek1->setTime(n); } @@ -411,6 +516,7 @@ bool PrefInterface::updateWhileDragging() { return (timeslider_behaviour_combo->currentIndex() == 0); } +#ifdef SEEKBAR_RESOLUTION void PrefInterface::setRelativeSeeking(bool b) { relative_seeking_button->setChecked(b); absolute_seeking_button->setChecked(!b); @@ -419,6 +525,7 @@ void PrefInterface::setRelativeSeeking(bool b) { bool PrefInterface::relativeSeeking() { return relative_seeking_button->isChecked(); } +#endif void PrefInterface::setPreciseSeeking(bool b) { precise_seeking_check->setChecked(b); @@ -511,6 +618,30 @@ bool PrefInterface::floatingBypassWindowManager() { } #endif +void PrefInterface::setRecentsMaxItems(int n) { + recents_max_items_spin->setValue(n); +} + +int PrefInterface::recentsMaxItems() { + return recents_max_items_spin->value(); +} + +void PrefInterface::setURLMaxItems(int n) { + url_max_items_spin->setValue(n); +} + +int PrefInterface::urlMaxItems() { + return url_max_items_spin->value(); +} + +void PrefInterface::setRememberDirs(bool b) { + save_dirs_check->setChecked(b); +} + +bool PrefInterface::rememberDirs() { + return save_dirs_check->isChecked(); +} + void PrefInterface::createHelp() { clearHelp(); @@ -527,29 +658,28 @@ void PrefInterface::createHelp() { setWhatsThis(hide_video_window_on_audio_check, tr("Hide video window when playing audio files"), tr("If this option is enabled the video window will be hidden when playing audio files.") ); - setWhatsThis(recents_max_items_spin, tr("Recent files"), - tr("Select the maximum number of items that will be shown in the " - "<b>Open->Recent files</b> submenu. If you set it to 0 that " - "menu won't be shown at all.") ); - setWhatsThis(language_combo, tr("Language"), tr("Here you can change the language of the application.") ); - setWhatsThis(iconset_combo, tr("Icon set"), - tr("Select the icon set you prefer for the application.") ); - - setWhatsThis(style_combo, tr("Style"), - tr("Select the style you prefer for the application.") ); - setWhatsThis(gui_combo, tr("GUI"), tr("Select the GUI you prefer for the application. Currently " "there are two available: Default GUI and Mini GUI.<br>" "The <b>Default GUI</b> provides the traditional GUI, with the " "toolbar and control bar. The <b>Mini GUI</b> provides a " "more simple GUI, without toolbar and a control bar with few " - "buttons.<br>" - "<b>Note:</b> this option will take effect the next " - "time you run SMPlayer.") ); + "buttons.") ); + + setWhatsThis(iconset_combo, tr("Icon set"), + tr("Select the icon set you prefer for the application.") ); + +#ifdef SKINS + setWhatsThis(skin_combo, tr("Skin"), + tr("Select the skin you prefer for the application. Only available with the skinnable GUI.") ); +#endif + + setWhatsThis(style_combo, tr("Style"), + tr("Select the style you prefer for the application.") ); + setWhatsThis(changeFontButton, tr("Default font"), tr("You can change here the application's font.") ); @@ -575,10 +705,12 @@ void PrefInterface::createHelp() { setWhatsThis(timeslider_behaviour_combo, tr("Behaviour of time slider"), tr("Select what to do when dragging the time slider.") ); +#ifdef SEEKBAR_RESOLUTION setWhatsThis(seeking_method_group, tr("Seeking method"), tr("Sets the method to be used when seeking with the slider. " "Absolute seeking may be a little bit more accurate, while " "relative seeking may work better with files with a wrong length.") ); +#endif setWhatsThis(precise_seeking_check, tr("Precise seeking"), tr("If this option is enabled, seeks are more accurate but they " @@ -620,6 +752,21 @@ void PrefInterface::createHelp() { "window manager. Disable this option if the floating control " "doesn't work well with your window manager.") ); #endif + + addSectionTitle(tr("Privacy")); + + setWhatsThis(recents_max_items_spin, tr("Recent files"), + tr("Select the maximum number of items that will be shown in the " + "<b>Open->Recent files</b> submenu. If you set it to 0 that " + "menu won't be shown at all.") ); + + setWhatsThis(url_max_items_spin, tr("Max. URLs"), + tr("Select the maximum number of items that the <b>Open->URL</b> " + "dialog will remember. Set it to 0 if you don't want any URL " + "to be stored.") ); + + setWhatsThis(save_dirs_check, tr("Remember last directory"), + tr("If this option is checked, SMPlayer will remember the last folder you use to open a file.") ); } #include "moc_prefinterface.cpp" |