void MainWindow::setup()
{
SettingsDialog dialog;
- dialog.exec();
-
- QNetworkProxy proxy(
- AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
- AppSettings::proxyAddress(),
- AppSettings::proxyPort(),
- PROXY_USERNAME,
- PROXY_PASSWD);
- QNetworkProxy::setApplicationProxy(proxy);
+ dialog.loadDialogData();
+ if (dialog.exec() == QDialog::Accepted) {
+ dialog.saveDialogData();
+ QNetworkProxy proxy(
+ AppSettings::isDirectConnection() ? QNetworkProxy::NoProxy : QNetworkProxy::HttpProxy,
+ AppSettings::proxyAddress(),
+ AppSettings::proxyPort(),
+ PROXY_USERNAME,
+ PROXY_PASSWD);
+ QNetworkProxy::setApplicationProxy(proxy);
+ }
}
/** Create and run ConferenceEditor dialog, making required connections for it.
: QDialog(aParent)
{
setupUi(this);
+ connect(directConnection, SIGNAL(clicked(bool)), SLOT(connectionTypeChanged(bool)));
+}
+
+void SettingsDialog::loadDialogData()
+{
// deserialize dialog data
address->setText(AppSettings::proxyAddress());
port->setValue(AppSettings::proxyPort());
directConnection->setChecked(AppSettings::isDirectConnection());
-
- connect(buttonBox, SIGNAL(accepted()), SLOT(saveDialogData()));
- connect(directConnection, SIGNAL(clicked(bool)), SLOT(connectionTypeChanged(bool)));
-
- if(directConnection->isChecked())
- proxyWidget->hide();
+ proxyWidget->setDisabled(directConnection->isChecked());
}
-void SettingsDialog::connectionTypeChanged(bool aState)
-{
- aState ? proxyWidget->hide() : proxyWidget->show();
-}
void SettingsDialog::saveDialogData()
{
AppSettings::setProxyAddress(address->text());
AppSettings::setProxyPort(port->value());
AppSettings::setDirectConnection(directConnection->isChecked());
+}
+
- close();
+void SettingsDialog::connectionTypeChanged(bool aState)
+{
+ proxyWidget->setDisabled(aState);
}
+
public:
SettingsDialog(QWidget *aParent = NULL);
~SettingsDialog() {}
+ void loadDialogData();
+ void saveDialogData();
private slots:
void connectionTypeChanged(bool aState);
- void saveDialogData();
};
#endif /* PROXYSETTINGSDIALOG_H */
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>500</width>
+ <height>152</height>
+ </rect>
+ </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
</widget>
</item>
<item>
- <widget class="QWidget" name="proxyWidget" native="true">
+ <widget class="QFrame" name="proxyWidget">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
</layout>
</widget>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>288</x>
+ <y>128</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>325</x>
+ <y>147</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>SettingsDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>202</x>
+ <y>130</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>226</x>
+ <y>147</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>