kpilot
mal-setup.ccGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "options.h"
00034
00035 #include <qtabwidget.h>
00036 #include <qradiobutton.h>
00037 #include <qbuttongroup.h>
00038 #include <qlineedit.h>
00039 #include <qcheckbox.h>
00040
00041 #include <kcombobox.h>
00042 #include <knuminput.h>
00043 #include <kpassdlg.h>
00044
00045 #include <kapplication.h>
00046 #include <kconfig.h>
00047
00048
00049 #include "mal-setup_dialog.h"
00050
00051 #include "mal-factory.h"
00052 #include "mal-setup.moc"
00053 #include "malconduitSettings.h"
00054
00055
00056 MALWidgetSetup::MALWidgetSetup(QWidget *w, const char *n) :
00057 ConduitConfigBase(w,n),
00058 fConfigWidget(new MALWidget(w))
00059 {
00060 FUNCTIONSETUP;
00061
00062 fConduitName=i18n("MAL");
00063 ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,MALConduitFactory::about());
00064 fWidget = fConfigWidget;
00065
00066 fConfigWidget->tabWidget->adjustSize();
00067 fConfigWidget->resize(fConfigWidget->tabWidget->size());
00068 #define CM(a,b) connect(fConfigWidget->a,b,this,SLOT(modified()));
00069 CM( syncTime, SIGNAL(clicked(int)) );
00070 CM( proxyType, SIGNAL(clicked(int)) );
00071
00072 CM( proxyServerName, SIGNAL(textChanged(const QString &)) );
00073 CM( proxyCustomPortCheck, SIGNAL(clicked()) );
00074 CM( proxyCustomPort, SIGNAL(valueChanged(int)) );
00075 CM( proxyUserName, SIGNAL(textChanged(const QString &)) );
00076 CM( proxyPassword, SIGNAL(textChanged(const QString &)) );
00077
00078 CM( malServerName, SIGNAL(textChanged(const QString &)) );
00079 CM( malCustomPortCheck, SIGNAL(clicked()) );
00080 CM( malCustomPort, SIGNAL(valueChanged(int)) );
00081 CM( malUserName, SIGNAL(textChanged(const QString &)) );
00082 CM( malPassword, SIGNAL(textChanged(const QString &)) );
00083 #undef CM
00084 }
00085
00086 MALWidgetSetup::~MALWidgetSetup()
00087 {
00088 FUNCTIONSETUP;
00089 }
00090
00091 void MALWidgetSetup::commit()
00092 {
00093 FUNCTIONSETUP;
00094
00095 MALConduitSettings::setSyncFrequency(
00096 fConfigWidget->syncTime->id(fConfigWidget->syncTime->selected()));
00097
00098
00099 MALConduitSettings::setProxyType(
00100 fConfigWidget->proxyType->id(fConfigWidget->proxyType->selected()));
00101 MALConduitSettings::setProxyServer( fConfigWidget->proxyServerName->currentText() );
00102
00103 if (fConfigWidget->proxyCustomPortCheck->isChecked() )
00104 {
00105 MALConduitSettings::setProxyPort( fConfigWidget->proxyCustomPort->value());
00106 }
00107 else
00108 {
00109 MALConduitSettings::setProxyPort(0);
00110 }
00111 MALConduitSettings::setProxyUser( fConfigWidget->proxyUserName->text() );
00112 MALConduitSettings::setProxyPassword( fConfigWidget->proxyPassword->password() );
00113
00114
00115 MALConduitSettings::setMALServer( fConfigWidget->malServerName->currentText() );
00116
00117 if (fConfigWidget->malCustomPortCheck->isChecked() )
00118 {
00119 MALConduitSettings::setMALPort( fConfigWidget->malCustomPort->value());
00120 }
00121 else
00122 {
00123 MALConduitSettings::setMALPort(0);
00124 }
00125 MALConduitSettings::setMALUser( fConfigWidget->malUserName->text() );
00126 MALConduitSettings::setMALPassword( fConfigWidget->malPassword->text() );
00127
00128 MALConduitSettings::self()->writeConfig();
00129 unmodified();
00130 }
00131
00132
00133
00134 void MALWidgetSetup::load()
00135 {
00136 FUNCTIONSETUP;
00137 MALConduitSettings::self()->readConfig();
00138
00139 fConfigWidget->syncTime->setButton( MALConduitSettings::syncFrequency() );
00140
00141
00142 fConfigWidget->proxyType->setButton(MALConduitSettings::proxyType());
00143 fConfigWidget->proxyServerName->setEditText(MALConduitSettings::proxyServer());
00144
00145 int proxyPortNr=MALConduitSettings::proxyPort();
00146 if (proxyPortNr>0 && proxyPortNr<65536)
00147 {
00148 fConfigWidget->proxyCustomPortCheck->setChecked(true);
00149 fConfigWidget->proxyCustomPort->setEnabled(true);
00150 fConfigWidget->proxyCustomPort->setValue(proxyPortNr);
00151 }
00152 fConfigWidget->proxyUserName->setText(MALConduitSettings::proxyUser());
00153 fConfigWidget->proxyPassword->setText(QString::null);
00154 fConfigWidget->proxyPassword->insert(MALConduitSettings::proxyPassword());
00155
00156 #ifdef DEBUG
00157 DEBUGKPILOT << fname << ": Got proxy password <"
00158 << MALConduitSettings::proxyPassword()
00159 << "> set Text <"
00160 << fConfigWidget->proxyPassword->text()
00161 << "> and Pwd <"
00162 << fConfigWidget->proxyPassword->password()
00163 << ">" << endl;
00164 #endif
00165
00166
00167 fConfigWidget->malServerName->setEditText(MALConduitSettings::mALServer());
00168
00169 int malPortNr=MALConduitSettings::mALPort();
00170 if (malPortNr>0 && malPortNr<65536)
00171 {
00172 fConfigWidget->malCustomPortCheck->setChecked(true);
00173 fConfigWidget->malCustomPort->setEnabled(true);
00174 fConfigWidget->malCustomPort->setValue(proxyPortNr);
00175 }
00176 fConfigWidget->malUserName->setText(MALConduitSettings::mALUser());
00177 fConfigWidget->malPassword->setText(MALConduitSettings::mALPassword());
00178 unmodified();
00179 }
00180
00181 ConduitConfigBase *MALWidgetSetup::create(QWidget *w, const char *n)
00182 {
00183 return new MALWidgetSetup(w,n);
00184 }
00185
|