Preferences: correctly hook up the signals to enable/disable cloud storage

This way the menu state matches the actual verification state again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-11-10 13:45:13 -08:00
parent 77d7e773b9
commit 111a153295
4 changed files with 11 additions and 5 deletions

View file

@ -1244,6 +1244,9 @@ void MainWindow::readSettings()
}
QNetworkProxy::setApplicationProxy(proxy);
// now make sure that the cloud menu items are enabled IFF cloud account is verified
enableDisableCloudActions();
#if !defined(SUBSURFACE_MOBILE)
loadRecentFiles(&s);
if (firstRun) {

View file

@ -19,6 +19,9 @@ public:
/* gets the values from the interface and set in the preferences object. */
virtual void syncSettings() = 0;
signals:
void settingsChanged();
private:
QIcon _icon;
QString _name;

View file

@ -96,7 +96,7 @@ void PreferencesNetwork::syncSettings()
report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
} else {
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::cloudPinNeeded);
cloudAuth->backend(email, password);
}
}
@ -146,8 +146,7 @@ void PreferencesNetwork::cloudPinNeeded()
} else {
ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
}
//TODO: Do not call mainWindow here. Verify things on SettingsChanged.
//MainWindow::instance()->enableDisableCloudActions();
emit settingsChanged();
}
void PreferencesNetwork::proxyType_changed(int idx)

View file

@ -121,6 +121,7 @@ void PreferencesDialog::refreshPages()
void PreferencesDialog::applyRequested(bool closeIt)
{
Q_FOREACH(AbstractPreferencesWidget *page, pages) {
connect(page, &AbstractPreferencesWidget::settingsChanged, this, &PreferencesDialog::settingsChanged, Qt::UniqueConnection);
page->syncSettings();
}
emit settingsChanged();