1 /* VLC-REMOTE for MAEMO 5
2 * Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>, Dru Moore <usr@dru-id.co.uk>, Yann Nave <yannux@onbebop.net>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #include "settingsdialog.h"
19 #include "ui_settingsdialog.h"
20 #include "appsettings.h"
24 SettingsDialog::SettingsDialog(QWidget *parent) :
26 ui(new Ui::SettingsDialog)
29 ui->scrollArea->setWidget(ui->scrollAreaWidgetContents);
30 connect(ui->radioButtonAutoRotate, SIGNAL(released()), this, SLOT(setOrientationAutoRotate()));
31 connect(ui->radioButtonLandscape, SIGNAL(released()), this, SLOT(setOrientationLandscape()));
32 connect(ui->radioButtonPortrait, SIGNAL(released()), this, SLOT(setOrientationPortrait()));
33 connect(ui->checkBoxAlertOnClose, SIGNAL(toggled(bool)), this, SLOT(setAlertOnClose(bool)));
34 connect(ui->checkBoxShowArt, SIGNAL(toggled(bool)), this, SLOT(setShowAlbumArt(bool)));
35 connect(ui->checkBoxUnknownFiles, SIGNAL(toggled(bool)), this, SLOT(setShowUnknownFileTypes(bool)));
36 connect(ui->comboBoxPollFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(setStatusPollTimeout(int)));
37 connect(ui->comboBoxPingTimeout, SIGNAL(currentIndexChanged(int)), this, SLOT(setPingTimeout(int)));
38 connect(ui->comboBoxConnectionTimeout, SIGNAL(currentIndexChanged(int)), this, SLOT(setConnectionTimeout(int)));
39 connect(ui->comboBoxRetryNetworkDelay, SIGNAL(currentIndexChanged(int)), this, SLOT(setRetryNetworkTimeout(int)));
40 connect(ui->comboBoxRetrieveArtDelay, SIGNAL(currentIndexChanged(int)), this, SLOT(setRetrieveArtTimeout(int)));
45 SettingsDialog::~SettingsDialog()
50 void SettingsDialog::init()
52 switch (AppSettings::getOrientation()) {
54 ui->radioButtonLandscape->setChecked(true);
57 ui->radioButtonPortrait->setChecked(true);
61 ui->radioButtonAutoRotate->setChecked(true);
65 ui->checkBoxAlertOnClose->setChecked(AppSettings::getAlertOnClose());
66 ui->checkBoxShowArt->setChecked(AppSettings::getShowAlbumArt());
67 ui->checkBoxUnknownFiles->setChecked(AppSettings::getShowUnknownFileTypes());
69 idx = ui->comboBoxPollFrequency->findText(QString::number(AppSettings::getStatusPollTimeout()));
70 ui->comboBoxPollFrequency->setCurrentIndex(-1 < idx ? idx : 0);
71 idx = ui->comboBoxConnectionTimeout->findText(QString::number(AppSettings::getConnectionTimeout()));
72 ui->comboBoxConnectionTimeout->setCurrentIndex(-1 < idx ? idx : 0);
73 idx = ui->comboBoxPingTimeout->findText(QString::number(AppSettings::getPingTimeout()));
74 ui->comboBoxPingTimeout->setCurrentIndex(-1 < idx ? idx : 0);
75 idx = ui->comboBoxRetryNetworkDelay->findText(QString::number(AppSettings::getRetryNetworkTimeout()));
76 ui->comboBoxRetryNetworkDelay->setCurrentIndex(-1 < idx ? idx : 0);
77 idx = ui->comboBoxRetrieveArtDelay->findText(QString::number(AppSettings::getRetrieveArtTimeout()));
78 ui->comboBoxRetrieveArtDelay->setCurrentIndex(-1 < idx ? idx : 0);
81 void SettingsDialog::setOrientationLandscape() {
82 setOrientation(LANDSCAPE);
84 void SettingsDialog::setOrientationPortrait() {
85 setOrientation(PORTRAIT);
87 void SettingsDialog::setOrientationAutoRotate() {
88 setOrientation(AUTO_ROTATE);
90 void SettingsDialog::setOrientation(Orientation orientation) {
91 AppSettings::setOrientation(orientation);
93 void SettingsDialog::setStatusPollTimeout(int idx) {
95 AppSettings::setStatusPollTimeout(ui->comboBoxPollFrequency->currentText().toInt());
97 void SettingsDialog::setPingTimeout(int idx) {
99 AppSettings::setPingTimeout(ui->comboBoxPingTimeout->currentText().toInt());
101 void SettingsDialog::setConnectionTimeout(int idx) {
103 AppSettings::setConnectionTimeout(ui->comboBoxConnectionTimeout->currentText().toInt());
105 void SettingsDialog::setRetrieveArtTimeout(int idx) {
107 AppSettings::setRetrieveArtTimeout(ui->comboBoxRetrieveArtDelay->currentText().toInt());
109 void SettingsDialog::setRetryNetworkTimeout(int idx) {
111 AppSettings::setRetryNetworkTimeout(ui->comboBoxRetryNetworkDelay->currentText().toInt());
113 void SettingsDialog::setShowUnknownFileTypes(bool state) {
114 AppSettings::setShowUnknownFileTypes(state);
116 void SettingsDialog::setShowAlbumArt(bool state) {
117 AppSettings::setShowAlbumArt(state);
119 void SettingsDialog::setAlertOnClose(bool state) {
120 AppSettings::setAlertOnClose(state);
123 void SettingsDialog::closeEvent(QCloseEvent * event) {