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); QNetworkProxy::setApplicationProxy(proxy);
// now make sure that the cloud menu items are enabled IFF cloud account is verified
enableDisableCloudActions();
#if !defined(SUBSURFACE_MOBILE) #if !defined(SUBSURFACE_MOBILE)
loadRecentFiles(&s); loadRecentFiles(&s);
if (firstRun) { if (firstRun) {

View file

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

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

View file

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