2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "config.h"
|
2010-05-19 17:45:29 +02:00
|
|
|
#include "iconloader.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "mainwindow.h"
|
2010-02-03 17:17:04 +01:00
|
|
|
#include "settingsdialog.h"
|
2010-06-09 00:56:31 +02:00
|
|
|
#include "ui_settingsdialog.h"
|
2010-04-04 19:50:11 +02:00
|
|
|
#include "engines/enginebase.h"
|
2010-08-27 12:36:01 +02:00
|
|
|
#include "playlist/playlistview.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "widgets/osd.h"
|
|
|
|
#include "widgets/osdpretty.h"
|
|
|
|
|
2010-08-24 21:57:43 +02:00
|
|
|
#ifdef ENABLE_WIIMOTEDEV
|
|
|
|
#include "ui/wiimotedevshortcutsconfig.h"
|
2010-08-25 18:19:54 +02:00
|
|
|
#include "ui_wiimotedevshortcutsconfig.h"
|
|
|
|
#include "wiimotedev/shortcuts.h"
|
2010-08-24 21:57:43 +02:00
|
|
|
#endif
|
|
|
|
|
2010-04-16 16:39:55 +02:00
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
# include "engines/gstengine.h"
|
|
|
|
#endif
|
2010-02-03 17:51:56 +01:00
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
#include <QColorDialog>
|
2010-08-02 21:02:21 +02:00
|
|
|
#include <QDir>
|
|
|
|
#include <QSettings>
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
#include <QtDebug>
|
2010-02-03 17:17:04 +01:00
|
|
|
|
|
|
|
SettingsDialog::SettingsDialog(QWidget* parent)
|
2010-03-25 20:30:10 +01:00
|
|
|
: QDialog(parent),
|
2010-08-27 15:57:39 +02:00
|
|
|
gst_engine_(NULL),
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_(new Ui_SettingsDialog),
|
2010-03-25 20:30:10 +01:00
|
|
|
loading_settings_(false),
|
2010-04-20 21:43:56 +02:00
|
|
|
pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable))
|
2010-02-03 17:17:04 +01:00
|
|
|
{
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->setupUi(this);
|
2010-03-25 20:30:10 +01:00
|
|
|
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"),
|
|
|
|
QImage(":nocover.png"));
|
|
|
|
|
2010-05-19 17:45:29 +02:00
|
|
|
// Icons
|
2010-06-23 18:27:23 +02:00
|
|
|
ui_->list->item(Page_Playback)->setIcon(IconLoader::Load("media-playback-start"));
|
2010-09-26 19:04:57 +02:00
|
|
|
ui_->list->item(Page_SongInformation)->setIcon(IconLoader::Load("view-media-lyrics"));
|
2010-06-23 18:27:23 +02:00
|
|
|
ui_->list->item(Page_GlobalShortcuts)->setIcon(IconLoader::Load("input-keyboard"));
|
|
|
|
ui_->list->item(Page_Notifications)->setIcon(IconLoader::Load("help-hint"));
|
|
|
|
ui_->list->item(Page_Library)->setIcon(IconLoader::Load("folder-sound"));
|
2010-05-19 17:45:29 +02:00
|
|
|
|
2010-08-24 21:57:43 +02:00
|
|
|
#ifdef ENABLE_WIIMOTEDEV
|
|
|
|
// Wiimotedev page
|
|
|
|
ui_->list->addItem("Wiimotedev");
|
|
|
|
ui_->list->item(Page_Wiimotedev)->setIcon(QIcon(":/icons/32x32/wiimotedev.png"));
|
|
|
|
|
2010-08-25 18:19:54 +02:00
|
|
|
QWidget* wiimotedev_page = new QWidget(this);
|
2010-08-24 21:57:43 +02:00
|
|
|
wiimotedev_page->setObjectName(QString::fromUtf8("wiimotedev_page"));
|
2010-08-25 18:19:54 +02:00
|
|
|
QVBoxLayout* wiimotedev_layout = new QVBoxLayout(wiimotedev_page);
|
2010-08-24 21:57:43 +02:00
|
|
|
wiimotedev_layout->setObjectName(QString::fromUtf8("wiimotedev_layout"));
|
2010-08-25 18:19:54 +02:00
|
|
|
wiimotedev_config_ = new WiimotedevShortcutsConfig(wiimotedev_page);
|
|
|
|
wiimotedev_config_->setObjectName(QString::fromUtf8("wiimotedev_config"));
|
|
|
|
wiimotedev_layout->addWidget(wiimotedev_config_);
|
2010-08-24 21:57:43 +02:00
|
|
|
|
|
|
|
ui_->stacked_widget->addWidget(wiimotedev_page);
|
2010-08-31 22:35:11 +02:00
|
|
|
|
|
|
|
connect(wiimotedev_config_, SIGNAL(SetWiimotedevInterfaceActived(bool)), this, SIGNAL(SetWiimotedevInterfaceActived(bool)));
|
2010-08-24 21:57:43 +02:00
|
|
|
#endif
|
|
|
|
|
2010-04-08 22:14:11 +02:00
|
|
|
// Playback
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->fading_cross, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
|
|
|
|
connect(ui_->fading_out, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
|
|
|
|
connect(ui_->fading_auto, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
|
2010-04-16 16:39:55 +02:00
|
|
|
#ifdef HAVE_GSTREAMER
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->gst_plugin, SIGNAL(currentIndexChanged(int)), SLOT(GstPluginChanged(int)));
|
2010-04-16 16:39:55 +02:00
|
|
|
#endif
|
2010-02-03 17:17:04 +01:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->replaygain_preamp, SIGNAL(valueChanged(int)), SLOT(RgPreampChanged(int)));
|
|
|
|
ui_->replaygain_preamp_label->setMinimumWidth(
|
|
|
|
QFontMetrics(ui_->replaygain_preamp_label->font()).width("-WW.W dB"));
|
|
|
|
RgPreampChanged(ui_->replaygain_preamp->value());
|
2010-05-23 15:07:15 +02:00
|
|
|
|
2010-04-07 01:46:34 +02:00
|
|
|
// Behaviour
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->b_show_tray_icon_, SIGNAL(toggled(bool)), SLOT(ShowTrayIconToggled(bool)));
|
2010-04-07 01:46:34 +02:00
|
|
|
|
2010-08-02 21:02:21 +02:00
|
|
|
// Populate the language combo box. We do this by looking at all the
|
|
|
|
// compiled in translations.
|
|
|
|
QDir dir(":/translations/");
|
|
|
|
QStringList codes(dir.entryList(QStringList() << "*.qm"));
|
|
|
|
QRegExp lang_re("^clementine_(.*).qm$");
|
|
|
|
foreach (const QString& filename, codes) {
|
|
|
|
// The regex captures the "ru" from "clementine_ru.qm"
|
|
|
|
if (!lang_re.exactMatch(filename))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
QString code = lang_re.cap(1);
|
|
|
|
QString name = QString("%1 (%2)").arg(
|
|
|
|
QLocale::languageToString(QLocale(code).language()), code);
|
|
|
|
|
|
|
|
language_map_[name] = code;
|
|
|
|
}
|
|
|
|
|
|
|
|
language_map_["English (en)"] = "en";
|
|
|
|
|
|
|
|
// Sort the names and show them in the UI
|
|
|
|
QStringList names = language_map_.keys();
|
|
|
|
qStableSort(names);
|
|
|
|
ui_->language->addItems(names);
|
|
|
|
|
2010-06-23 18:27:23 +02:00
|
|
|
// Global shortcuts
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
if (QSysInfo::MacintoshVersion != QSysInfo::MV_SNOWLEOPARD) {
|
|
|
|
ui_->list->item(Page_GlobalShortcuts)->setFlags(Qt::NoItemFlags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
// Last.fm
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->lastfm, SIGNAL(ValidationComplete(bool)), SLOT(LastFMValidationComplete(bool)));
|
2010-02-03 19:32:48 +01:00
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
// List box
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
|
2010-06-23 18:27:23 +02:00
|
|
|
ui_->list->setCurrentRow(Page_Playback);
|
2010-02-03 18:21:25 +01:00
|
|
|
|
|
|
|
// Notifications
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue), Qt::DecorationRole);
|
|
|
|
ui_->notifications_bg_preset->setItemData(1, QColor(OSDPretty::kPresetOrange), Qt::DecorationRole);
|
2010-04-08 22:14:11 +02:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->notifications_none, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
|
|
|
|
connect(ui_->notifications_native, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
|
|
|
|
connect(ui_->notifications_tray, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
|
|
|
|
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
|
|
|
|
connect(ui_->notifications_opacity, SIGNAL(valueChanged(int)), SLOT(PrettyOpacityChanged(int)));
|
|
|
|
connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int)));
|
|
|
|
connect(ui_->notifications_fg_choose, SIGNAL(clicked()), SLOT(ChooseFgColor()));
|
2010-02-03 18:21:25 +01:00
|
|
|
|
2010-02-26 23:37:48 +01:00
|
|
|
if (!OSD::SupportsNativeNotifications())
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_native->setEnabled(false);
|
2010-02-26 23:37:48 +01:00
|
|
|
if (!OSD::SupportsTrayPopups())
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_tray->setEnabled(false);
|
2010-03-25 20:30:10 +01:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
connect(ui_->stacked_widget, SIGNAL(currentChanged(int)), SLOT(UpdatePopupVisible()));
|
|
|
|
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(UpdatePopupVisible()));
|
2010-05-17 02:47:43 +02:00
|
|
|
|
|
|
|
// Make sure the list is big enough to show all the items
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->list->setMinimumWidth(ui_->list->sizeHintForColumn(0));
|
2010-06-18 16:21:46 +02:00
|
|
|
|
|
|
|
#ifdef Q_OS_DARWIN
|
2010-06-23 18:27:23 +02:00
|
|
|
ui_->list->item(Page_Behaviour)->setHidden(true); // Hide "Behaviour" on mac.
|
2010-06-18 16:21:46 +02:00
|
|
|
#endif
|
2010-03-25 20:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SettingsDialog::~SettingsDialog() {
|
|
|
|
delete pretty_popup_;
|
2010-06-09 00:56:31 +02:00
|
|
|
delete ui_;
|
2010-02-03 17:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::CurrentTextChanged(const QString &text) {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->title->setText("<b>" + text + "</b>");
|
2010-02-03 17:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::SetLibraryDirectoryModel(LibraryDirectoryModel* model) {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->library_config->SetModel(model);
|
2010-02-03 17:17:04 +01:00
|
|
|
}
|
2010-02-03 17:51:56 +01:00
|
|
|
|
2010-06-23 18:27:23 +02:00
|
|
|
void SettingsDialog::SetGlobalShortcutManager(GlobalShortcuts *manager) {
|
|
|
|
ui_->global_shortcuts->SetManager(manager);
|
|
|
|
}
|
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
void SettingsDialog::LastFMValidationComplete(bool success) {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->buttonBox->setEnabled(true);
|
2010-02-03 19:32:48 +01:00
|
|
|
|
|
|
|
if (success)
|
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
void SettingsDialog::accept() {
|
2010-06-09 00:56:31 +02:00
|
|
|
if (ui_->lastfm->NeedsValidation()) {
|
|
|
|
ui_->lastfm->Validate();
|
|
|
|
ui_->buttonBox->setEnabled(false);
|
2010-02-03 19:32:48 +01:00
|
|
|
return;
|
|
|
|
} else {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->lastfm->Save();
|
2010-02-03 19:32:48 +01:00
|
|
|
}
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
QSettings s;
|
|
|
|
|
2010-04-07 01:46:34 +02:00
|
|
|
// Behaviour
|
|
|
|
MainWindow::StartupBehaviour behaviour;
|
2010-06-09 00:56:31 +02:00
|
|
|
if (ui_->b_always_hide_->isChecked()) behaviour = MainWindow::Startup_AlwaysHide;
|
|
|
|
if (ui_->b_always_show_->isChecked()) behaviour = MainWindow::Startup_AlwaysShow;
|
|
|
|
if (ui_->b_remember_->isChecked()) behaviour = MainWindow::Startup_Remember;
|
2010-04-07 01:46:34 +02:00
|
|
|
|
|
|
|
s.beginGroup(MainWindow::kSettingsGroup);
|
2010-06-09 00:56:31 +02:00
|
|
|
s.setValue("showtray", ui_->b_show_tray_icon_->isChecked());
|
2010-04-07 01:46:34 +02:00
|
|
|
s.setValue("startupbehaviour", int(behaviour));
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-08-02 21:02:21 +02:00
|
|
|
s.beginGroup("General");
|
|
|
|
s.setValue("language", language_map_.contains(ui_->language->currentText()) ?
|
|
|
|
language_map_[ui_->language->currentText()] : QString());
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
// Playback
|
2010-08-27 12:36:01 +02:00
|
|
|
s.beginGroup(PlaylistView::kSettingsGroup);
|
|
|
|
s.setValue("glow_effect", ui_->current_glow->isChecked());
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
s.beginGroup(Engine::Base::kSettingsGroup);
|
2010-06-09 00:56:31 +02:00
|
|
|
s.setValue("FadeoutEnabled", ui_->fading_out->isChecked());
|
|
|
|
s.setValue("FadeoutDuration", ui_->fading_duration->value());
|
|
|
|
s.setValue("CrossfadeEnabled", ui_->fading_cross->isChecked());
|
|
|
|
s.setValue("AutoCrossfadeEnabled", ui_->fading_auto->isChecked());
|
2010-02-03 17:51:56 +01:00
|
|
|
s.endGroup();
|
|
|
|
|
2010-04-16 16:39:55 +02:00
|
|
|
#ifdef HAVE_GSTREAMER
|
2010-04-07 15:51:14 +02:00
|
|
|
s.beginGroup(GstEngine::kSettingsGroup);
|
2010-06-09 00:56:31 +02:00
|
|
|
s.setValue("sink", ui_->gst_plugin->itemData(ui_->gst_plugin->currentIndex()).toString());
|
|
|
|
s.setValue("device", ui_->gst_device->text());
|
|
|
|
s.setValue("rgenabled", ui_->replaygain->isChecked());
|
|
|
|
s.setValue("rgmode", ui_->replaygain_mode->currentIndex());
|
|
|
|
s.setValue("rgpreamp", float(ui_->replaygain_preamp->value()) / 10 - 15);
|
|
|
|
s.setValue("rgcompression", ui_->replaygain_compression->isChecked());
|
2010-04-07 15:51:14 +02:00
|
|
|
s.endGroup();
|
2010-04-16 16:39:55 +02:00
|
|
|
#endif
|
2010-04-07 15:51:14 +02:00
|
|
|
|
2010-09-26 19:04:57 +02:00
|
|
|
// Lyrics
|
|
|
|
ui_->lyric_settings->Save();
|
|
|
|
|
|
|
|
// Wii remotes
|
2010-08-25 18:19:54 +02:00
|
|
|
#ifdef ENABLE_WIIMOTEDEV
|
2010-08-26 17:37:07 +02:00
|
|
|
s.beginGroup(WiimotedevShortcuts::kActionsGroup);
|
2010-08-27 12:36:01 +02:00
|
|
|
s.remove("");
|
2010-08-31 03:37:17 +02:00
|
|
|
foreach (const WiimotedevShortcutsConfig::Shortcut& shortcut, wiimotedev_config_->actions_)
|
2010-08-26 17:37:07 +02:00
|
|
|
s.setValue(QString::number(shortcut.button), shortcut.action);
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-08-25 18:19:54 +02:00
|
|
|
s.beginGroup(WiimotedevShortcuts::kSettingsGroup);
|
2010-09-01 01:35:39 +02:00
|
|
|
s.setValue("first_conf", false);
|
2010-08-25 18:19:54 +02:00
|
|
|
s.setValue("enabled", wiimotedev_config_->ui_->wiimotedev_enable->isChecked());
|
|
|
|
s.setValue("only_when_focused", wiimotedev_config_->ui_->wiimotedev_focus->isChecked());
|
|
|
|
s.setValue("use_active_action", wiimotedev_config_->ui_->wiimotedev_active->isChecked());
|
|
|
|
s.setValue("use_notification", wiimotedev_config_->ui_->wiimotedev_notification->isChecked());
|
|
|
|
s.setValue("device", wiimotedev_config_->ui_->wiimotedev_device->value());
|
|
|
|
s.endGroup();
|
|
|
|
#endif
|
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
// Notifications
|
2010-04-21 22:57:54 +02:00
|
|
|
OSD::Behaviour osd_behaviour = OSD::Disabled;
|
2010-06-09 00:56:31 +02:00
|
|
|
if (ui_->notifications_none->isChecked()) osd_behaviour = OSD::Disabled;
|
|
|
|
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSD::Native;
|
|
|
|
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSD::TrayPopup;
|
|
|
|
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSD::Pretty;
|
2010-02-03 18:21:25 +01:00
|
|
|
|
|
|
|
s.beginGroup(OSD::kSettingsGroup);
|
|
|
|
s.setValue("Behaviour", int(osd_behaviour));
|
2010-06-09 00:56:31 +02:00
|
|
|
s.setValue("Timeout", ui_->notifications_duration->value() * 1000);
|
|
|
|
s.setValue("ShowOnVolumeChange", ui_->notifications_volume->isChecked());
|
|
|
|
s.setValue("ShowArt", ui_->notifications_art->isChecked());
|
2010-02-03 18:21:25 +01:00
|
|
|
s.endGroup();
|
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
s.beginGroup(OSDPretty::kSettingsGroup);
|
|
|
|
s.setValue("foreground_color", pretty_popup_->foreground_color());
|
|
|
|
s.setValue("background_color", pretty_popup_->background_color());
|
|
|
|
s.setValue("background_opacity", pretty_popup_->background_opacity());
|
2010-04-11 19:19:25 +02:00
|
|
|
s.setValue("popup_display", pretty_popup_->popup_display());
|
|
|
|
s.setValue("popup_pos", pretty_popup_->popup_pos());
|
2010-03-25 20:30:10 +01:00
|
|
|
s.endGroup();
|
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->library_config->Save();
|
2010-06-09 01:18:20 +02:00
|
|
|
ui_->magnatune->Save();
|
2010-06-23 18:27:23 +02:00
|
|
|
ui_->global_shortcuts->Save();
|
2010-04-01 02:12:25 +02:00
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::showEvent(QShowEvent*) {
|
|
|
|
QSettings s;
|
2010-03-25 20:30:10 +01:00
|
|
|
loading_settings_ = true;
|
2010-02-03 17:51:56 +01:00
|
|
|
|
2010-08-27 15:57:39 +02:00
|
|
|
#ifdef HAVE_GSTREAMER
|
2010-08-27 18:41:35 +02:00
|
|
|
if (ui_->gst_plugin->count() <= 1 && gst_engine_) {
|
2010-08-27 15:57:39 +02:00
|
|
|
GstEngine::PluginDetailsList list = gst_engine_->GetOutputsList();
|
|
|
|
|
|
|
|
ui_->gst_plugin->setItemData(0, GstEngine::kAutoSink);
|
|
|
|
foreach (const GstEngine::PluginDetails& details, list) {
|
|
|
|
if (details.name == "autoaudiosink")
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ui_->gst_plugin->addItem(details.long_name, details.name);
|
|
|
|
}
|
|
|
|
ui_->gst_group->setEnabled(true);
|
|
|
|
ui_->replaygain_group->setEnabled(true);
|
|
|
|
}
|
|
|
|
#endif // HAVE_GSTREAMER
|
|
|
|
|
2010-04-07 01:46:34 +02:00
|
|
|
// Behaviour
|
|
|
|
s.beginGroup(MainWindow::kSettingsGroup);
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->b_show_tray_icon_->setChecked(s.value("showtray", true).toBool());
|
2010-04-07 01:46:34 +02:00
|
|
|
MainWindow::StartupBehaviour behaviour = MainWindow::StartupBehaviour(
|
|
|
|
s.value("startupbehaviour", MainWindow::Startup_Remember).toInt());
|
|
|
|
switch (behaviour) {
|
2010-06-09 00:56:31 +02:00
|
|
|
case MainWindow::Startup_AlwaysHide: ui_->b_always_hide_->setChecked(true); break;
|
|
|
|
case MainWindow::Startup_AlwaysShow: ui_->b_always_show_->setChecked(true); break;
|
|
|
|
case MainWindow::Startup_Remember: ui_->b_remember_->setChecked(true); break;
|
2010-04-07 01:46:34 +02:00
|
|
|
}
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-08-02 21:02:21 +02:00
|
|
|
s.beginGroup("General");
|
|
|
|
QString name = language_map_.key(s.value("language").toString());
|
|
|
|
if (name.isEmpty())
|
|
|
|
ui_->language->setCurrentIndex(0);
|
|
|
|
else
|
|
|
|
ui_->language->setCurrentIndex(ui_->language->findText(name));
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-09-26 19:04:57 +02:00
|
|
|
// Lyrics
|
|
|
|
ui_->lyric_settings->Load();
|
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
// Last.fm
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->lastfm->Load();
|
2010-02-03 19:32:48 +01:00
|
|
|
|
2010-06-09 01:18:20 +02:00
|
|
|
// Magnatune
|
|
|
|
ui_->magnatune->Load();
|
|
|
|
|
2010-06-23 18:27:23 +02:00
|
|
|
// Global Shortcuts
|
|
|
|
ui_->global_shortcuts->Load();
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
// Playback
|
2010-08-27 12:36:01 +02:00
|
|
|
s.beginGroup(PlaylistView::kSettingsGroup);
|
|
|
|
ui_->current_glow->setChecked(s.value("glow_effect", true).toBool());
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
s.beginGroup(Engine::Base::kSettingsGroup);
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->fading_out->setChecked(s.value("FadeoutEnabled", true).toBool());
|
|
|
|
ui_->fading_cross->setChecked(s.value("CrossfadeEnabled", true).toBool());
|
|
|
|
ui_->fading_auto->setChecked(s.value("AutoCrossfadeEnabled", false).toBool());
|
|
|
|
ui_->fading_duration->setValue(s.value("FadeoutDuration", 2000).toInt());
|
2010-02-03 17:51:56 +01:00
|
|
|
s.endGroup();
|
2010-02-03 18:21:25 +01:00
|
|
|
|
2010-04-16 16:39:55 +02:00
|
|
|
#ifdef HAVE_GSTREAMER
|
2010-04-07 15:51:14 +02:00
|
|
|
s.beginGroup(GstEngine::kSettingsGroup);
|
|
|
|
QString sink = s.value("sink", GstEngine::kAutoSink).toString();
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->gst_plugin->setCurrentIndex(0);
|
|
|
|
for (int i=0 ; i<ui_->gst_plugin->count() ; ++i) {
|
|
|
|
if (ui_->gst_plugin->itemData(i).toString() == sink) {
|
|
|
|
ui_->gst_plugin->setCurrentIndex(i);
|
2010-04-07 15:51:14 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->gst_device->setText(s.value("device").toString());
|
|
|
|
ui_->replaygain->setChecked(s.value("rgenabled", false).toBool());
|
|
|
|
ui_->replaygain_mode->setCurrentIndex(s.value("rgmode", 0).toInt());
|
|
|
|
ui_->replaygain_preamp->setValue(s.value("rgpreamp", 0.0).toDouble() * 10 + 150);
|
|
|
|
ui_->replaygain_compression->setChecked(s.value("rgcompression", true).toBool());
|
2010-04-07 15:51:14 +02:00
|
|
|
s.endGroup();
|
2010-04-16 16:39:55 +02:00
|
|
|
#endif
|
2010-04-07 15:51:14 +02:00
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
// Notifications
|
|
|
|
s.beginGroup(OSD::kSettingsGroup);
|
|
|
|
OSD::Behaviour osd_behaviour = OSD::Behaviour(s.value("Behaviour", OSD::Native).toInt());
|
|
|
|
switch (osd_behaviour) {
|
2010-02-26 23:37:48 +01:00
|
|
|
case OSD::Native:
|
|
|
|
if (OSD::SupportsNativeNotifications()) {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_native->setChecked(true);
|
2010-02-26 23:37:48 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fallthrough
|
|
|
|
|
2010-03-27 16:15:20 +01:00
|
|
|
case OSD::Pretty:
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_pretty->setChecked(true);
|
2010-03-27 16:15:20 +01:00
|
|
|
break;
|
|
|
|
|
2010-02-26 23:37:48 +01:00
|
|
|
case OSD::TrayPopup:
|
|
|
|
if (OSD::SupportsTrayPopups()) {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_tray->setChecked(true);
|
2010-02-26 23:37:48 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fallthrough
|
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
case OSD::Disabled:
|
2010-02-26 23:37:48 +01:00
|
|
|
default:
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_none->setChecked(true);
|
2010-02-26 23:37:48 +01:00
|
|
|
break;
|
2010-02-03 18:21:25 +01:00
|
|
|
}
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
|
|
|
|
ui_->notifications_volume->setChecked(s.value("ShowOnVolumeChange", false).toBool());
|
|
|
|
ui_->notifications_art->setChecked(s.value("ShowArt", true).toBool());
|
2010-02-03 18:21:25 +01:00
|
|
|
s.endGroup();
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
// Pretty OSD
|
|
|
|
pretty_popup_->ReloadSettings();
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_opacity->setValue(pretty_popup_->background_opacity() * 100);
|
2010-03-25 20:30:10 +01:00
|
|
|
|
|
|
|
QRgb color = pretty_popup_->background_color();
|
|
|
|
if (color == OSDPretty::kPresetBlue)
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_bg_preset->setCurrentIndex(0);
|
2010-03-25 20:30:10 +01:00
|
|
|
else if (color == OSDPretty::kPresetOrange)
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_bg_preset->setCurrentIndex(1);
|
2010-03-25 20:30:10 +01:00
|
|
|
else
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_bg_preset->setCurrentIndex(2);
|
|
|
|
ui_->notifications_bg_preset->setItemData(2, QColor(color), Qt::DecorationRole);
|
2010-03-25 20:30:10 +01:00
|
|
|
UpdatePopupVisible();
|
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->library_config->Load();
|
2010-04-21 13:24:22 +02:00
|
|
|
|
2010-03-25 20:30:10 +01:00
|
|
|
loading_settings_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::hideEvent(QHideEvent *) {
|
|
|
|
pretty_popup_->hide();
|
2010-02-03 18:21:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::NotificationTypeChanged() {
|
2010-06-09 00:56:31 +02:00
|
|
|
bool enabled = !ui_->notifications_none->isChecked();
|
|
|
|
bool pretty = ui_->notifications_pretty->isChecked();
|
2010-03-25 20:30:10 +01:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_general->setEnabled(enabled);
|
|
|
|
ui_->notifications_pretty_group->setEnabled(pretty);
|
2010-03-25 20:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::PrettyOpacityChanged(int value) {
|
|
|
|
pretty_popup_->set_background_opacity(qreal(value) / 100.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::UpdatePopupVisible() {
|
|
|
|
pretty_popup_->setVisible(
|
|
|
|
isVisible() &&
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_pretty->isChecked() &&
|
|
|
|
ui_->stacked_widget->currentWidget() == ui_->notifications_page);
|
2010-03-25 20:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::PrettyColorPresetChanged(int index) {
|
|
|
|
if (loading_settings_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
pretty_popup_->set_background_color(OSDPretty::kPresetBlue);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
pretty_popup_->set_background_color(OSDPretty::kPresetOrange);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
default:
|
|
|
|
ChooseBgColor();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::ChooseBgColor() {
|
|
|
|
QColor color = QColorDialog::getColor(pretty_popup_->background_color(), this);
|
|
|
|
if (!color.isValid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
pretty_popup_->set_background_color(color.rgb());
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole);
|
2010-03-25 20:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::ChooseFgColor() {
|
|
|
|
QColor color = QColorDialog::getColor(pretty_popup_->foreground_color(), this);
|
|
|
|
if (!color.isValid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
pretty_popup_->set_foreground_color(color.rgb());
|
2010-02-03 17:51:56 +01:00
|
|
|
}
|
2010-04-07 01:46:34 +02:00
|
|
|
|
|
|
|
void SettingsDialog::ShowTrayIconToggled(bool on) {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->b_always_hide_->setEnabled(on);
|
|
|
|
if (!on && ui_->b_always_hide_->isChecked())
|
|
|
|
ui_->b_remember_->setChecked(true);
|
2010-04-07 01:46:34 +02:00
|
|
|
}
|
2010-04-07 15:51:14 +02:00
|
|
|
|
2010-06-08 17:55:44 +02:00
|
|
|
void SettingsDialog::GstPluginChanged(int index) {
|
|
|
|
#ifdef HAVE_GSTREAMER
|
2010-06-09 00:56:31 +02:00
|
|
|
QString name = ui_->gst_plugin->itemData(index).toString();
|
2010-04-08 22:14:11 +02:00
|
|
|
|
2010-06-08 17:55:44 +02:00
|
|
|
bool enabled = GstEngine::DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(name);
|
2010-04-08 22:14:11 +02:00
|
|
|
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->gst_device->setEnabled(enabled);
|
|
|
|
ui_->gst_device_label->setEnabled(enabled);
|
2010-05-23 15:07:15 +02:00
|
|
|
#endif // HAVE_GSTREAMER
|
2010-06-08 17:55:44 +02:00
|
|
|
}
|
2010-05-23 15:07:15 +02:00
|
|
|
|
|
|
|
void SettingsDialog::RgPreampChanged(int value) {
|
|
|
|
float db = float(value) / 10 - 15;
|
|
|
|
QString db_str;
|
|
|
|
db_str.sprintf("%+.1f dB", db);
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->replaygain_preamp_label->setText(db_str);
|
2010-04-08 22:14:11 +02:00
|
|
|
}
|
2010-04-12 01:03:39 +02:00
|
|
|
|
|
|
|
void SettingsDialog::FadingOptionsChanged() {
|
2010-06-09 00:56:31 +02:00
|
|
|
ui_->fading_options->setEnabled(
|
|
|
|
ui_->fading_out->isChecked() || ui_->fading_cross->isChecked() ||
|
|
|
|
ui_->fading_auto->isChecked());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::OpenAtPage(Page page) {
|
|
|
|
ui_->list->setCurrentRow(page);
|
|
|
|
show();
|
2010-04-12 01:03:39 +02:00
|
|
|
}
|
2010-10-10 18:46:35 +02:00
|
|
|
|
|
|
|
void SettingsDialog::SetSongInfoView(SongInfoView* view) {
|
|
|
|
ui_->lyric_settings->SetSongInfoView(view);
|
|
|
|
}
|