1
/* This file is part of Clementine.
2
Copyright 2010, David Sansome <me@davidsansome.com>
4
Clementine 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 3 of the License, or
7
(at your option) any later version.
9
Clementine 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.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
19
#include "core/backgroundstreams.h"
20
#include "core/networkproxyfactory.h"
21
#include "iconloader.h"
22
#include "mainwindow.h"
23
#include "settingsdialog.h"
24
#include "engines/enginebase.h"
25
#include "engines/gstengine.h"
26
#include "playlist/playlistview.h"
27
#include "songinfo/songinfofetcher.h"
28
#include "songinfo/songinfotextview.h"
29
#include "widgets/osd.h"
30
#include "widgets/osdpretty.h"
32
#include "ui_settingsdialog.h"
35
# include "radio/lastfmconfig.h"
38
#ifdef HAVE_WIIMOTEDEV
39
# include "ui/wiimotedevshortcutsconfig.h"
40
# include "ui_wiimotedevshortcutsconfig.h"
41
# include "wiimotedev/shortcuts.h"
45
# include "remote/remoteconfig.h"
48
#include <QColorDialog>
50
#include <QFontDialog>
55
void SettingsDialog::AddStream(const QString& name) {
56
QGroupBox* box = new QGroupBox(tr(name.toUtf8()));
57
QSlider* slider = new QSlider(Qt::Horizontal, box);
58
QCheckBox* check = new QCheckBox(box);
59
QHBoxLayout* layout = new QHBoxLayout(box);
60
layout->addWidget(slider);
61
layout->addWidget(check);
63
QVBoxLayout* streams_layout = qobject_cast<QVBoxLayout*>(
64
ui_->streams_page->layout());
65
streams_layout->insertWidget(streams_layout->count() - 1, box);
67
slider->setProperty("stream_name", name);
68
check->setProperty("stream_name", name);
70
connect(slider, SIGNAL(valueChanged(int)), SLOT(StreamVolumeChanged(int)));
71
connect(check, SIGNAL(toggled(bool)), SLOT(EnableStream(bool)));
73
slider->setValue(streams_->GetStreamVolume(name));
74
check->setCheckState(streams_->IsPlaying(name) ? Qt::Checked : Qt::Unchecked);
77
void SettingsDialog::EnableStream(bool enabled) {
78
const QString name = sender()->property("stream_name").toString();
79
streams_->EnableStream(name, enabled);
82
void SettingsDialog::StreamVolumeChanged(int value) {
83
const QString name = sender()->property("stream_name").toString();
84
streams_->SetStreamVolume(name, value);
87
void SettingsDialog::AddStreams() {
88
foreach (const QString& name, streams_->streams()) {
93
SettingsDialog::SettingsDialog(BackgroundStreams* streams, QWidget* parent)
96
ui_(new Ui_SettingsDialog),
97
loading_settings_(false),
98
pretty_popup_(new OSDPretty(OSDPretty::Mode_Draggable)),
102
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"),
103
QImage(":nocover.png"));
105
#ifdef HAVE_LIBLASTFM
106
ui_->list->insertItem(Page_Lastfm, tr("Last.fm"));
107
ui_->list->item(Page_Lastfm)->setIcon(QIcon(":/last.fm/as.png"));
109
QWidget* lastfm_page = new QWidget;
110
QVBoxLayout* lastfm_layout = new QVBoxLayout;
111
lastfm_layout->setContentsMargins(0, 0, 0, 0);
112
lastfm_config_ = new LastFMConfig;
113
lastfm_layout->addWidget(lastfm_config_);
114
lastfm_page->setLayout(lastfm_layout);
116
ui_->stacked_widget->insertWidget(Page_Lastfm, lastfm_page);
118
connect(lastfm_config_, SIGNAL(ValidationComplete(bool)), SLOT(ValidationComplete(bool)));
122
ui_->list->insertItem(Page_Remote, tr("Remote Control"));
123
ui_->list->item(Page_Remote)->setIcon(IconLoader::Load("network-server"));
125
QWidget* remote_page = new QWidget;
126
QVBoxLayout* remote_layout = new QVBoxLayout;
127
remote_layout->setContentsMargins(0, 0, 0, 0);
129
remote_config_ = new RemoteConfig;
130
remote_layout->addWidget(remote_config_);
131
remote_page->setLayout(remote_layout);
133
ui_->stacked_widget->insertWidget(Page_Remote, remote_page);
135
connect(remote_config_, SIGNAL(ValidationComplete(bool)), SLOT(ValidationComplete(bool)));
138
connect(ui_->magnatune, SIGNAL(ValidationComplete(bool)), SLOT(ValidationComplete(bool)));
141
ui_->list->item(Page_Playback)->setIcon(IconLoader::Load("media-playback-start"));
142
ui_->list->item(Page_SongInformation)->setIcon(IconLoader::Load("view-media-lyrics"));
143
ui_->list->item(Page_GlobalShortcuts)->setIcon(IconLoader::Load("input-keyboard"));
144
ui_->list->item(Page_Notifications)->setIcon(IconLoader::Load("help-hint"));
145
ui_->list->item(Page_Library)->setIcon(IconLoader::Load("folder-sound"));
146
ui_->list->item(Page_BackgroundStreams)->setIcon(QIcon(":/icons/32x32/weather-showers-scattered.png"));
147
ui_->list->item(Page_Proxy)->setIcon(IconLoader::Load("applications-internet"));
151
#ifdef HAVE_WIIMOTEDEV
153
ui_->list->insertItem(Page_Wiimotedev, "Wiimotedev");
154
ui_->list->item(Page_Wiimotedev)->setIcon(QIcon(":/icons/32x32/wiimotedev.png"));
156
QWidget* wiimotedev_page = new QWidget(this);
157
wiimotedev_page->setObjectName(QString::fromUtf8("wiimotedev_page"));
158
QVBoxLayout* wiimotedev_layout = new QVBoxLayout(wiimotedev_page);
159
wiimotedev_layout->setObjectName(QString::fromUtf8("wiimotedev_layout"));
160
wiimotedev_config_ = new WiimotedevShortcutsConfig(wiimotedev_page);
161
wiimotedev_config_->setObjectName(QString::fromUtf8("wiimotedev_config"));
162
wiimotedev_layout->addWidget(wiimotedev_config_);
164
ui_->stacked_widget->addWidget(wiimotedev_page);
166
connect(wiimotedev_config_, SIGNAL(SetWiimotedevInterfaceActived(bool)), this, SIGNAL(SetWiimotedevInterfaceActived(bool)));
170
connect(ui_->fading_cross, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
171
connect(ui_->fading_out, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
172
connect(ui_->fading_auto, SIGNAL(toggled(bool)), SLOT(FadingOptionsChanged()));
173
connect(ui_->gst_plugin, SIGNAL(currentIndexChanged(int)), SLOT(GstPluginChanged(int)));
175
connect(ui_->replaygain_preamp, SIGNAL(valueChanged(int)), SLOT(RgPreampChanged(int)));
176
ui_->replaygain_preamp_label->setMinimumWidth(
177
QFontMetrics(ui_->replaygain_preamp_label->font()).width("-WW.W dB"));
178
RgPreampChanged(ui_->replaygain_preamp->value());
181
connect(ui_->b_show_tray_icon_, SIGNAL(toggled(bool)), SLOT(ShowTrayIconToggled(bool)));
183
ui_->doubleclick_addmode->setItemData(0, MainWindow::AddBehaviour_Append);
184
ui_->doubleclick_addmode->setItemData(1, MainWindow::AddBehaviour_Load);
185
ui_->doubleclick_addmode->setItemData(2, MainWindow::AddBehaviour_OpenInNew);
186
ui_->doubleclick_addmode->setItemData(3, MainWindow::AddBehaviour_Enqueue);
188
ui_->doubleclick_playmode->setItemData(0, MainWindow::PlayBehaviour_Never);
189
ui_->doubleclick_playmode->setItemData(1, MainWindow::PlayBehaviour_IfStopped);
190
ui_->doubleclick_playmode->setItemData(2, MainWindow::PlayBehaviour_Always);
192
ui_->menu_playmode->setItemData(0, MainWindow::PlayBehaviour_Never);
193
ui_->menu_playmode->setItemData(1, MainWindow::PlayBehaviour_IfStopped);
194
ui_->menu_playmode->setItemData(2, MainWindow::PlayBehaviour_Always);
196
// Populate the language combo box. We do this by looking at all the
197
// compiled in translations.
198
QDir dir(":/translations/");
199
QStringList codes(dir.entryList(QStringList() << "*.qm"));
200
QRegExp lang_re("^clementine_(.*).qm$");
201
foreach (const QString& filename, codes) {
202
// The regex captures the "ru" from "clementine_ru.qm"
203
if (!lang_re.exactMatch(filename))
206
QString code = lang_re.cap(1);
207
QString name = QString("%1 (%2)").arg(
208
QLocale::languageToString(QLocale(code).language()), code);
210
language_map_[name] = code;
213
language_map_["English (en)"] = "en";
215
// Sort the names and show them in the UI
216
QStringList names = language_map_.keys();
218
ui_->language->addItems(names);
221
QFile song_info_preview(":/lumberjacksong.txt");
222
song_info_preview.open(QIODevice::ReadOnly);
223
ui_->song_info_font_preview->setText(QString::fromUtf8(song_info_preview.readAll()));
225
connect(ui_->song_info_font_size, SIGNAL(valueChanged(double)), SLOT(SongInfoFontSizeChanged(double)));
229
if (QSysInfo::MacintoshVersion != QSysInfo::MV_SNOWLEOPARD) {
230
ui_->list->item(Page_GlobalShortcuts)->setFlags(Qt::NoItemFlags);
235
connect(ui_->list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
236
ui_->list->setCurrentRow(Page_Playback);
239
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue), Qt::DecorationRole);
240
ui_->notifications_bg_preset->setItemData(1, QColor(OSDPretty::kPresetOrange), Qt::DecorationRole);
242
connect(ui_->notifications_none, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
243
connect(ui_->notifications_native, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
244
connect(ui_->notifications_tray, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
245
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(NotificationTypeChanged()));
246
connect(ui_->notifications_opacity, SIGNAL(valueChanged(int)), SLOT(PrettyOpacityChanged(int)));
247
connect(ui_->notifications_bg_preset, SIGNAL(activated(int)), SLOT(PrettyColorPresetChanged(int)));
248
connect(ui_->notifications_fg_choose, SIGNAL(clicked()), SLOT(ChooseFgColor()));
250
if (!OSD::SupportsNativeNotifications())
251
ui_->notifications_native->setEnabled(false);
252
if (!OSD::SupportsTrayPopups())
253
ui_->notifications_tray->setEnabled(false);
255
connect(ui_->stacked_widget, SIGNAL(currentChanged(int)), SLOT(UpdatePopupVisible()));
256
connect(ui_->notifications_pretty, SIGNAL(toggled(bool)), SLOT(UpdatePopupVisible()));
258
// Make sure the list is big enough to show all the items
259
ui_->list->setMinimumWidth(ui_->list->sizeHintForColumn(0));
262
ui_->b_show_tray_icon_->setEnabled(false);
263
ui_->startup_group_->setEnabled(false);
266
ui_->buttonBox->button(QDialogButtonBox::Cancel)->setShortcut(QKeySequence::Close);
269
SettingsDialog::~SettingsDialog() {
270
delete pretty_popup_;
274
void SettingsDialog::CurrentTextChanged(const QString &text) {
275
ui_->title->setText("<b>" + text + "</b>");
278
void SettingsDialog::SetLibraryDirectoryModel(LibraryDirectoryModel* model) {
279
ui_->library_config->SetModel(model);
282
void SettingsDialog::SetGlobalShortcutManager(GlobalShortcuts *manager) {
283
ui_->global_shortcuts->SetManager(manager);
286
void SettingsDialog::ValidationComplete(bool success) {
287
ui_->buttonBox->setEnabled(true);
293
void SettingsDialog::accept() {
294
#ifdef HAVE_LIBLASTFM
295
if (lastfm_config_->NeedsValidation()) {
296
lastfm_config_->Validate();
297
ui_->buttonBox->setEnabled(false);
300
lastfm_config_->Save();
305
if (remote_config_->NeedsValidation()) {
306
remote_config_->Validate();
307
ui_->buttonBox->setEnabled(false);
310
remote_config_->Save();
314
if (ui_->magnatune->NeedsValidation()) {
315
ui_->magnatune->Validate();
316
ui_->buttonBox->setEnabled(false);
319
ui_->magnatune->Save();
325
MainWindow::StartupBehaviour behaviour = MainWindow::Startup_Remember;
326
if (ui_->b_always_hide_->isChecked()) behaviour = MainWindow::Startup_AlwaysHide;
327
if (ui_->b_always_show_->isChecked()) behaviour = MainWindow::Startup_AlwaysShow;
328
if (ui_->b_remember_->isChecked()) behaviour = MainWindow::Startup_Remember;
330
MainWindow::AddBehaviour doubleclick_addmode = MainWindow::AddBehaviour(
331
ui_->doubleclick_addmode->itemData(ui_->doubleclick_addmode->currentIndex()).toInt());
332
MainWindow::PlayBehaviour doubleclick_playmode = MainWindow::PlayBehaviour(
333
ui_->doubleclick_playmode->itemData(ui_->doubleclick_playmode->currentIndex()).toInt());
334
MainWindow::PlayBehaviour menu_playmode = MainWindow::PlayBehaviour(
335
ui_->menu_playmode->itemData(ui_->menu_playmode->currentIndex()).toInt());
337
s.beginGroup(MainWindow::kSettingsGroup);
338
s.setValue("showtray", ui_->b_show_tray_icon_->isChecked());
339
s.setValue("keeprunning", ui_->b_keep_running_->isChecked());
340
s.setValue("startupbehaviour", int(behaviour));
341
s.setValue("doubleclick_addmode", doubleclick_addmode);
342
s.setValue("doubleclick_playmode", doubleclick_playmode);
343
s.setValue("menu_playmode", menu_playmode);
346
s.beginGroup("General");
347
s.setValue("language", language_map_.contains(ui_->language->currentText()) ?
348
language_map_[ui_->language->currentText()] : QString());
352
s.beginGroup(Playlist::kSettingsGroup);
353
s.setValue("glow_effect", ui_->current_glow->isChecked());
354
s.setValue("greyoutdeleted", ui_->b_grey_out_deleted_->isChecked());
357
s.beginGroup(Engine::Base::kSettingsGroup);
358
s.setValue("FadeoutEnabled", ui_->fading_out->isChecked());
359
s.setValue("FadeoutDuration", ui_->fading_duration->value());
360
s.setValue("CrossfadeEnabled", ui_->fading_cross->isChecked());
361
s.setValue("AutoCrossfadeEnabled", ui_->fading_auto->isChecked());
362
s.setValue("NoCrossfadeSameAlbum", ui_->fading_samealbum->isChecked());
365
s.beginGroup(GstEngine::kSettingsGroup);
366
s.setValue("sink", ui_->gst_plugin->itemData(ui_->gst_plugin->currentIndex()).toString());
367
s.setValue("device", ui_->gst_device->text());
368
s.setValue("rgenabled", ui_->replaygain->isChecked());
369
s.setValue("rgmode", ui_->replaygain_mode->currentIndex());
370
s.setValue("rgpreamp", float(ui_->replaygain_preamp->value()) / 10 - 15);
371
s.setValue("rgcompression", ui_->replaygain_compression->isChecked());
372
s.setValue("bufferduration", ui_->buffer_duration->value());
376
s.beginGroup(SongInfoTextView::kSettingsGroup);
377
s.setValue("font_size", ui_->song_info_font_preview->font().pointSizeF());
378
s.setValue("timeout", ui_->song_info_timeout->value());
381
ui_->lyric_settings->Save();
384
#ifdef HAVE_WIIMOTEDEV
385
s.beginGroup(WiimotedevShortcuts::kActionsGroup);
387
foreach (const WiimotedevShortcutsConfig::Shortcut& shortcut, wiimotedev_config_->actions_)
388
s.setValue(QString::number(shortcut.button), shortcut.action);
391
s.beginGroup(WiimotedevShortcuts::kSettingsGroup);
392
s.setValue("first_conf", false);
393
s.setValue("enabled", wiimotedev_config_->ui_->wiimotedev_enable->isChecked());
394
s.setValue("only_when_focused", wiimotedev_config_->ui_->wiimotedev_focus->isChecked());
395
s.setValue("use_active_action", wiimotedev_config_->ui_->wiimotedev_active->isChecked());
396
s.setValue("use_notification", wiimotedev_config_->ui_->wiimotedev_notification->isChecked());
397
s.setValue("device", wiimotedev_config_->ui_->wiimotedev_device->value());
402
OSD::Behaviour osd_behaviour = OSD::Disabled;
403
if (ui_->notifications_none->isChecked()) osd_behaviour = OSD::Disabled;
404
else if (ui_->notifications_native->isChecked()) osd_behaviour = OSD::Native;
405
else if (ui_->notifications_tray->isChecked()) osd_behaviour = OSD::TrayPopup;
406
else if (ui_->notifications_pretty->isChecked()) osd_behaviour = OSD::Pretty;
408
s.beginGroup(OSD::kSettingsGroup);
409
s.setValue("Behaviour", int(osd_behaviour));
410
s.setValue("Timeout", ui_->notifications_duration->value() * 1000);
411
s.setValue("ShowOnVolumeChange", ui_->notifications_volume->isChecked());
412
s.setValue("ShowOnPlayModeChange", ui_->notifications_play_mode->isChecked());
413
s.setValue("ShowArt", ui_->notifications_art->isChecked());
416
s.beginGroup(OSDPretty::kSettingsGroup);
417
s.setValue("foreground_color", pretty_popup_->foreground_color());
418
s.setValue("background_color", pretty_popup_->background_color());
419
s.setValue("background_opacity", pretty_popup_->background_opacity());
420
s.setValue("popup_display", pretty_popup_->popup_display());
421
s.setValue("popup_pos", pretty_popup_->popup_pos());
425
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode_System;
426
if (ui_->proxy_direct->isChecked()) mode = NetworkProxyFactory::Mode_Direct;
427
else if (ui_->proxy_system->isChecked()) mode = NetworkProxyFactory::Mode_System;
428
else if (ui_->proxy_manual->isChecked()) mode = NetworkProxyFactory::Mode_Manual;
430
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
431
s.setValue("mode", mode);
432
s.setValue("type", ui_->proxy_type->currentIndex() == 0 ?
433
QNetworkProxy::HttpProxy : QNetworkProxy::Socks5Proxy);
434
s.setValue("hostname", ui_->proxy_hostname->text());
435
s.setValue("port", ui_->proxy_port->value());
436
s.setValue("use_authentication", ui_->proxy_auth->isChecked());
437
s.setValue("username", ui_->proxy_username->text());
438
s.setValue("password", ui_->proxy_password->text());
441
ui_->library_config->Save();
442
ui_->magnatune->Save();
443
ui_->global_shortcuts->Save();
445
streams_->SaveStreams();
449
NetworkProxyFactory::Instance()->ReloadSettings();
452
void SettingsDialog::showEvent(QShowEvent*) {
454
loading_settings_ = true;
456
if (ui_->gst_plugin->count() <= 1 && gst_engine_) {
457
GstEngine::PluginDetailsList list = gst_engine_->GetOutputsList();
459
ui_->gst_plugin->setItemData(0, GstEngine::kAutoSink);
460
foreach (const GstEngine::PluginDetails& details, list) {
461
if (details.name == "autoaudiosink")
464
ui_->gst_plugin->addItem(details.long_name, details.name);
466
ui_->gst_group->setEnabled(true);
467
ui_->replaygain_group->setEnabled(true);
471
s.beginGroup(MainWindow::kSettingsGroup);
472
ui_->b_show_tray_icon_->setChecked(s.value("showtray", true).toBool());
473
ui_->b_keep_running_->setChecked(s.value("keeprunning",
474
ui_->b_show_tray_icon_->isChecked()).toBool());
475
ui_->doubleclick_addmode->setCurrentIndex(ui_->doubleclick_addmode->findData(
476
s.value("doubleclick_addmode", MainWindow::AddBehaviour_Append).toInt()));
477
ui_->doubleclick_playmode->setCurrentIndex(ui_->doubleclick_playmode->findData(
478
s.value("doubleclick_playmode", MainWindow::PlayBehaviour_IfStopped).toInt()));
479
ui_->menu_playmode->setCurrentIndex(ui_->menu_playmode->findData(
480
s.value("menu_playmode", MainWindow::PlayBehaviour_IfStopped).toInt()));
482
MainWindow::StartupBehaviour behaviour = MainWindow::StartupBehaviour(
483
s.value("startupbehaviour", MainWindow::Startup_Remember).toInt());
485
case MainWindow::Startup_AlwaysHide: ui_->b_always_hide_->setChecked(true); break;
486
case MainWindow::Startup_AlwaysShow: ui_->b_always_show_->setChecked(true); break;
487
case MainWindow::Startup_Remember: ui_->b_remember_->setChecked(true); break;
491
s.beginGroup("General");
492
QString name = language_map_.key(s.value("language").toString());
494
ui_->language->setCurrentIndex(0);
496
ui_->language->setCurrentIndex(ui_->language->findText(name));
500
s.beginGroup(SongInfoTextView::kSettingsGroup);
501
ui_->song_info_font_size->setValue(
502
s.value("font_size", SongInfoTextView::kDefaultFontSize).toReal());
503
ui_->song_info_timeout->setValue(
504
s.value("timeout", SongInfoFetcher::kDefaultTimeoutDuration).toInt());
507
ui_->lyric_settings->Load();
510
#ifdef HAVE_LIBLASTFM
511
lastfm_config_->Load();
515
remote_config_->Load();
519
ui_->magnatune->Load();
522
ui_->global_shortcuts->Load();
525
s.beginGroup(Playlist::kSettingsGroup);
526
ui_->current_glow->setChecked(s.value("glow_effect", true).toBool());
527
ui_->b_grey_out_deleted_->setChecked(s.value("greyoutdeleted", false).toBool());
530
s.beginGroup(Engine::Base::kSettingsGroup);
531
ui_->fading_out->setChecked(s.value("FadeoutEnabled", true).toBool());
532
ui_->fading_cross->setChecked(s.value("CrossfadeEnabled", true).toBool());
533
ui_->fading_auto->setChecked(s.value("AutoCrossfadeEnabled", false).toBool());
534
ui_->fading_duration->setValue(s.value("FadeoutDuration", 2000).toInt());
535
ui_->fading_samealbum->setChecked(s.value("NoCrossfadeSameAlbum", true).toBool());
538
s.beginGroup(GstEngine::kSettingsGroup);
539
QString sink = s.value("sink", GstEngine::kAutoSink).toString();
540
ui_->gst_plugin->setCurrentIndex(0);
541
for (int i=0 ; i<ui_->gst_plugin->count() ; ++i) {
542
if (ui_->gst_plugin->itemData(i).toString() == sink) {
543
ui_->gst_plugin->setCurrentIndex(i);
547
ui_->gst_device->setText(s.value("device").toString());
548
ui_->replaygain->setChecked(s.value("rgenabled", false).toBool());
549
ui_->replaygain_mode->setCurrentIndex(s.value("rgmode", 0).toInt());
550
ui_->replaygain_preamp->setValue(s.value("rgpreamp", 0.0).toDouble() * 10 + 150);
551
ui_->replaygain_compression->setChecked(s.value("rgcompression", true).toBool());
552
ui_->buffer_duration->setValue(s.value("bufferduration", 1000).toInt());
556
s.beginGroup(OSD::kSettingsGroup);
557
OSD::Behaviour osd_behaviour = OSD::Behaviour(s.value("Behaviour", OSD::Native).toInt());
558
switch (osd_behaviour) {
560
if (OSD::SupportsNativeNotifications()) {
561
ui_->notifications_native->setChecked(true);
567
ui_->notifications_pretty->setChecked(true);
571
if (OSD::SupportsTrayPopups()) {
572
ui_->notifications_tray->setChecked(true);
579
ui_->notifications_none->setChecked(true);
582
ui_->notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
583
ui_->notifications_volume->setChecked(s.value("ShowOnVolumeChange", false).toBool());
584
ui_->notifications_play_mode->setChecked(s.value("ShowOnPlayModeChange", true).toBool());
585
ui_->notifications_art->setChecked(s.value("ShowArt", true).toBool());
589
pretty_popup_->ReloadSettings();
590
ui_->notifications_opacity->setValue(pretty_popup_->background_opacity() * 100);
592
QRgb color = pretty_popup_->background_color();
593
if (color == OSDPretty::kPresetBlue)
594
ui_->notifications_bg_preset->setCurrentIndex(0);
595
else if (color == OSDPretty::kPresetOrange)
596
ui_->notifications_bg_preset->setCurrentIndex(1);
598
ui_->notifications_bg_preset->setCurrentIndex(2);
599
ui_->notifications_bg_preset->setItemData(2, QColor(color), Qt::DecorationRole);
600
UpdatePopupVisible();
602
ui_->library_config->Load();
605
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
606
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode(
607
s.value("mode", NetworkProxyFactory::Mode_System).toInt());
609
case NetworkProxyFactory::Mode_Manual:
610
ui_->proxy_manual->setChecked(true);
613
case NetworkProxyFactory::Mode_Direct:
614
ui_->proxy_direct->setChecked(true);
617
case NetworkProxyFactory::Mode_System:
619
ui_->proxy_system->setChecked(true);
623
ui_->proxy_type->setCurrentIndex(s.value("type", QNetworkProxy::HttpProxy)
624
.toInt() == QNetworkProxy::HttpProxy ? 0 : 1);
625
ui_->proxy_hostname->setText(s.value("hostname").toString());
626
ui_->proxy_port->setValue(s.value("port").toInt());
627
ui_->proxy_auth->setChecked(s.value("use_authentication", false).toBool());
628
ui_->proxy_username->setText(s.value("username").toString());
629
ui_->proxy_password->setText(s.value("password").toString());
632
loading_settings_ = false;
635
void SettingsDialog::hideEvent(QHideEvent *) {
636
pretty_popup_->hide();
639
void SettingsDialog::NotificationTypeChanged() {
640
bool enabled = !ui_->notifications_none->isChecked();
641
bool pretty = ui_->notifications_pretty->isChecked();
643
ui_->notifications_general->setEnabled(enabled);
644
ui_->notifications_pretty_group->setEnabled(pretty);
647
void SettingsDialog::PrettyOpacityChanged(int value) {
648
pretty_popup_->set_background_opacity(qreal(value) / 100.0);
651
void SettingsDialog::UpdatePopupVisible() {
652
pretty_popup_->setVisible(
654
ui_->notifications_pretty->isChecked() &&
655
ui_->stacked_widget->currentWidget() == ui_->notifications_page);
658
void SettingsDialog::PrettyColorPresetChanged(int index) {
659
if (loading_settings_)
664
pretty_popup_->set_background_color(OSDPretty::kPresetBlue);
668
pretty_popup_->set_background_color(OSDPretty::kPresetOrange);
678
void SettingsDialog::ChooseBgColor() {
679
QColor color = QColorDialog::getColor(pretty_popup_->background_color(), this);
680
if (!color.isValid())
683
pretty_popup_->set_background_color(color.rgb());
684
ui_->notifications_bg_preset->setItemData(2, color, Qt::DecorationRole);
687
void SettingsDialog::ChooseFgColor() {
688
QColor color = QColorDialog::getColor(pretty_popup_->foreground_color(), this);
689
if (!color.isValid())
692
pretty_popup_->set_foreground_color(color.rgb());
695
void SettingsDialog::ShowTrayIconToggled(bool on) {
696
ui_->b_always_hide_->setEnabled(on);
697
if (!on && ui_->b_always_hide_->isChecked())
698
ui_->b_remember_->setChecked(true);
701
void SettingsDialog::GstPluginChanged(int index) {
702
QString name = ui_->gst_plugin->itemData(index).toString();
704
bool enabled = GstEngine::DoesThisSinkSupportChangingTheOutputDeviceToAUserEditableString(name);
706
ui_->gst_device->setEnabled(enabled);
707
ui_->gst_device_label->setEnabled(enabled);
710
void SettingsDialog::RgPreampChanged(int value) {
711
float db = float(value) / 10 - 15;
713
db_str.sprintf("%+.1f dB", db);
714
ui_->replaygain_preamp_label->setText(db_str);
717
void SettingsDialog::FadingOptionsChanged() {
718
ui_->fading_options->setEnabled(
719
ui_->fading_out->isChecked() || ui_->fading_cross->isChecked() ||
720
ui_->fading_auto->isChecked());
723
void SettingsDialog::OpenAtPage(Page page) {
724
ui_->list->setCurrentRow(page);
728
void SettingsDialog::SetSongInfoView(SongInfoView* view) {
729
ui_->lyric_settings->SetSongInfoView(view);
732
void SettingsDialog::SongInfoFontSizeChanged(double value) {
734
font.setPointSizeF(value);
736
ui_->song_info_font_preview->setFont(font);