2010-02-03 17:17:04 +01:00
|
|
|
#include "settingsdialog.h"
|
2010-02-03 17:51:56 +01:00
|
|
|
#include "enginebase.h"
|
2010-02-03 18:21:25 +01:00
|
|
|
#include "osd.h"
|
2010-02-03 17:51:56 +01:00
|
|
|
|
|
|
|
#include <QSettings>
|
2010-02-03 17:17:04 +01:00
|
|
|
|
|
|
|
SettingsDialog::SettingsDialog(QWidget* parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
ui_.setupUi(this);
|
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
// Last.fm
|
|
|
|
connect(ui_.lastfm, SIGNAL(ValidationComplete(bool)), SLOT(LastFMValidationComplete(bool)));
|
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
// List box
|
2010-02-03 17:17:04 +01:00
|
|
|
connect(ui_.list, SIGNAL(currentTextChanged(QString)), SLOT(CurrentTextChanged(QString)));
|
|
|
|
ui_.list->setCurrentRow(0);
|
2010-02-03 18:21:25 +01:00
|
|
|
|
|
|
|
// Notifications
|
|
|
|
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()));
|
|
|
|
|
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
// Sucks to be a windows user
|
|
|
|
ui_.notifications_native->setEnabled(false);
|
|
|
|
#endif
|
2010-02-03 17:17:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::CurrentTextChanged(const QString &text) {
|
|
|
|
ui_.title->setText("<b>" + text + "</b>");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::SetLibraryDirectoryModel(LibraryDirectoryModel* model) {
|
|
|
|
ui_.library_config->SetModel(model);
|
|
|
|
}
|
2010-02-03 17:51:56 +01:00
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
void SettingsDialog::LastFMValidationComplete(bool success) {
|
|
|
|
ui_.buttonBox->setEnabled(true);
|
|
|
|
|
|
|
|
if (success)
|
|
|
|
accept();
|
|
|
|
}
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
void SettingsDialog::accept() {
|
2010-02-03 19:32:48 +01:00
|
|
|
if (ui_.lastfm->NeedsValidation()) {
|
|
|
|
ui_.lastfm->Validate();
|
|
|
|
ui_.buttonBox->setEnabled(false);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
ui_.lastfm->Save();
|
|
|
|
}
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
QSettings s;
|
|
|
|
|
|
|
|
// Playback
|
|
|
|
s.beginGroup(Engine::Base::kSettingsGroup);
|
|
|
|
s.setValue("FadeoutEnabled", ui_.fadeout->isChecked());
|
|
|
|
s.setValue("FadeoutDuration", ui_.fadeout_duration->value());
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-02-03 18:21:25 +01:00
|
|
|
// Notifications
|
|
|
|
OSD::Behaviour osd_behaviour;
|
|
|
|
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;
|
|
|
|
|
|
|
|
s.beginGroup(OSD::kSettingsGroup);
|
|
|
|
s.setValue("Behaviour", int(osd_behaviour));
|
|
|
|
s.setValue("Timeout", ui_.notifications_duration->value() * 1000);
|
|
|
|
s.endGroup();
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::showEvent(QShowEvent*) {
|
|
|
|
QSettings s;
|
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
// Last.fm
|
|
|
|
ui_.lastfm->Load();
|
|
|
|
|
2010-02-03 17:51:56 +01:00
|
|
|
// Playback
|
|
|
|
s.beginGroup(Engine::Base::kSettingsGroup);
|
|
|
|
if (s.value("FadeoutEnabled", true).toBool())
|
|
|
|
ui_.fadeout->setChecked(true);
|
|
|
|
else
|
|
|
|
ui_.no_fadeout->setChecked(true);
|
|
|
|
ui_.fadeout_duration->setValue(s.value("FadeoutDuration", 2000).toInt());
|
|
|
|
s.endGroup();
|
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) {
|
|
|
|
case OSD::Native: ui_.notifications_native->setChecked(true); break;
|
|
|
|
case OSD::TrayPopup: ui_.notifications_tray->setChecked(true); break;
|
|
|
|
case OSD::Disabled:
|
|
|
|
default: ui_.notifications_none->setChecked(true); break;
|
|
|
|
}
|
|
|
|
ui_.notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
|
|
|
|
s.endGroup();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::NotificationTypeChanged() {
|
|
|
|
ui_.notifications_options->setEnabled(!ui_.notifications_none->isChecked());
|
2010-02-03 17:51:56 +01:00
|
|
|
}
|