1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
22 #include "configure.h"
23 #include "ui_configurefrm.h"
25 Config::Config(QWidget
*parent
) : QDialog(parent
)
28 ui
.radioManualProxy
->setChecked(true);
29 QRegExpValidator
*proxyValidator
= new QRegExpValidator(this);
30 QRegExp
validate("[0-9]*");
31 proxyValidator
->setRegExp(validate
);
32 ui
.proxyPort
->setValidator(proxyValidator
);
34 ui
.radioSystemProxy
->setEnabled(false); // not implemented yet
36 connect(ui
.buttonOk
, SIGNAL(clicked()), this, SLOT(accept()));
37 connect(ui
.buttonCancel
, SIGNAL(clicked()), this, SLOT(abort()));
38 connect(ui
.radioNoProxy
, SIGNAL(toggled(bool)), this, SLOT(setNoProxy(bool)));
44 qDebug() << "Config::accept()";
46 proxy
.setScheme("http");
47 proxy
.setUserName(ui
.proxyUser
->text());
48 proxy
.setPassword(ui
.proxyPass
->text());
49 proxy
.setHost(ui
.proxyHost
->text());
50 proxy
.setPort(ui
.proxyPort
->text().toInt());
52 userSettings
->setValue("defaults/proxy", proxy
.toString());
53 qDebug() << "new proxy:" << proxy
;
56 if(ui
.radioNoProxy
->isChecked()) proxyType
= "none";
57 else if(ui
.radioSystemProxy
->isChecked()) proxyType
= "system";
58 else proxyType
= "manual";
59 userSettings
->setValue("defaults/proxytype", proxyType
);
63 emit
settingsUpdated();
69 qDebug() << "Config::abort()";
74 void Config::setUserSettings(QSettings
*user
)
77 QUrl proxy
= userSettings
->value("defaults/proxy").toString();
79 ui
.proxyPort
->insert(QString("%1").arg(proxy
.port()));
80 ui
.proxyHost
->insert(proxy
.host());
81 ui
.proxyUser
->insert(proxy
.userName());
82 ui
.proxyPass
->insert(proxy
.password());
84 QString proxyType
= userSettings
->value("defaults/proxytype").toString();
85 if(proxyType
== "manual") ui
.radioManualProxy
->setChecked(true);
86 else if(proxyType
== "system") ui
.radioSystemProxy
->setChecked(true);
87 else if(proxyType
== "none") ui
.radioNoProxy
->setChecked(true);
92 void Config::setNoProxy(bool checked
)
95 ui
.proxyPort
->setEnabled(i
);
96 ui
.proxyHost
->setEnabled(i
);
97 ui
.proxyUser
->setEnabled(i
);
98 ui
.proxyPass
->setEnabled(i
);