#include <QPushButton>
#include <QLabel>
#include <QDebug>
+#include <QNetworkConfiguration>
SettingsDlg::SettingsDlg(QWidget *parent)
: QDialog(parent)
{
QSettings settings(this);
m_layout = new QVBoxLayout(this);
- m_btnLayout = new QHBoxLayout(this);
- m_remoteNameLayout = new QHBoxLayout(this);
+ m_btnLayout = new QHBoxLayout();
+ m_remoteNameLayout = new QHBoxLayout();
m_advSettingsBtn = new QPushButton(tr("Advanced"), this);
m_selectRemoteBtn = new QPushButton(tr("Select remote"), this);
m_layout->addLayout(m_btnLayout);
this->setLayout(m_layout);
- QString selectedRemote = QSettings(this).value("remoteName", "").toString();
+ QString selectedRemote = settings.value("remoteName", "").toString();
if (selectedRemote == "") {
m_remoteNameLabel->setText("No remote selected");
enableRateBtns(false);
} else {
- setRemote(selectedRemote);
- m_remote.updateInfo();
- setBusy();
+ // Create remote by name and update it's info if online
+ m_remote = Remote(selectedRemote);
+ m_remoteNameLabel->setText(selectedRemote);
+ m_netConfMan = new QTM_PREPEND_NAMESPACE(
+ QNetworkConfigurationManager)(this);
+ connect(m_netConfMan, SIGNAL(updateCompleted()),
+ this, SLOT(onNetworkStatusUpdate()));
+ m_netConfMan->updateConfigurations();
+ enableRateBtns(false);
}
}
delete m_btnLayout;
delete m_remoteNameLayout;
delete m_layout;
+ delete m_netConfMan;
}
void SettingsDlg::setBusy(bool busy)
void SettingsDlg::showAdvSettingsDlg()
{
- AdvSettingsDlg dlg(this);
+ AdvSettingsDlg dlg;
dlg.exec();
}
void SettingsDlg::showSelectRemoteDlg()
{
- SelectRemoteDlg dlg(this);
+ SelectRemoteDlg dlg;
connect(&dlg, SIGNAL(remoteChanged(Remote)),
this, SLOT(setRemote(Remote)));
dlg.exec();
void SettingsDlg::showAboutDlg()
{
- AboutDlg dlg(this);
+ AboutDlg dlg;
dlg.exec();
}
void SettingsDlg::setRemote(Remote r)
{
m_remote = r;
- processRemoteChange();
updateRemoteInfo();
+ enableRateBtns();
}
-void SettingsDlg::setRemote(const QString &name)
-{
- setBusy();
- m_remote = Remote(name);
- processRemoteChange();
- m_remote.updateInfo(); // request update from server
-}
-
-void SettingsDlg::processRemoteChange()
+void SettingsDlg::onNetworkStatusUpdate()
{
- connect(&m_remote, SIGNAL(infoUpdated()),
- this, SLOT(updateRemoteInfo()));
- enableRateBtns();
+ if (m_netConfMan->isOnline()) {
+ setBusy();
+ connect(&m_remote, SIGNAL(infoUpdated()),
+ this, SLOT(updateRemoteInfo()));
+ m_remote.updateInfo();
+ enableRateBtns();
+ }
}
void SettingsDlg::updateRemoteInfo()