From 9d01f80744e74ab1136b911d1de147c27bce1750 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 27 Jun 2013 16:54:33 +0200 Subject: [PATCH] Fix Dialog behavior - Fix proxy dialog being callable multiple times - Use smart pointers in more places - _owncloudSetupWizard was guarded by a smart pointer, this needs to be accounted for in other code pathes. Fixes Setup dialog not showing up when left-clicking on unconfigured instances on Windows. --- src/mirall/application.cpp | 32 ++++++++++++++++---------------- src/mirall/application.h | 9 +++++---- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp index af51cb55a..80be902a9 100644 --- a/src/mirall/application.cpp +++ b/src/mirall/application.cpp @@ -100,15 +100,12 @@ Application::Application(int &argc, char **argv) : _sslErrorDialog(0), _contextMenu(0), _theme(Theme::instance()), - _updateDetector(0), _logBrowser(0), _logExpire(0), _showLogWindow(false), _logFlush(false), _helpOnly(false), - _fileItemDialog(0), - _statusDialog(0), - _folderWizard(0) + _fileItemDialog(0) { setApplicationName( _theme->appNameGUI() ); setWindowIcon( _theme->applicationIcon() ); @@ -159,7 +156,7 @@ Application::Application(int &argc, char **argv) : #endif setupActions(); setupSystemTray(); - setupProxy(); + slotSetupProxy(); int cnt = _folderMan->setupFolders(); @@ -191,8 +188,8 @@ Application::~Application() void Application::slotStartUpdateDetector() { - _updateDetector = new UpdateDetector(this); - _updateDetector->versionCheck(_theme); + UpdateDetector *updateDetector = new UpdateDetector(this); + updateDetector->versionCheck(_theme); } @@ -604,7 +601,7 @@ QNetworkProxy proxyFromConfig(const MirallConfigFile& cfg) return proxy; } -void Application::setupProxy() +void Application::slotSetupProxy() { Mirall::MirallConfigFile cfg; int proxyType = cfg.proxyType(); @@ -698,7 +695,7 @@ void Application::slotAddFolder() Application *_app; }; - if (_folderWizard) { + if (!_folderWizard.isNull()) { raiseDialog(_folderWizard); return; } @@ -732,7 +729,6 @@ void Application::slotAddFolder() qDebug() << "* Folder wizard cancelled"; } _folderWizard->deleteLater(); - _folderWizard = 0; } void Application::slotOpenStatus() @@ -742,7 +738,8 @@ void Application::slotOpenStatus() QWidget *raiseWidget = 0; // check if there is a mirall.cfg already. - if( _owncloudSetupWizard && _owncloudSetupWizard->wizard()->isVisible() ) { + if( !_owncloudSetupWizard.isNull() && + _owncloudSetupWizard->wizard()->isVisible() ) { raiseWidget = _owncloudSetupWizard->wizard(); } @@ -875,7 +872,8 @@ void Application::slotEnableFolder(const QString& alias, const bool enable) void Application::slotConfigure() { - if (_owncloudSetupWizard && !_owncloudSetupWizard->wizard()->isVisible()) { + if (!_owncloudSetupWizard.isNull() && + !_owncloudSetupWizard->wizard()->isVisible()) { raiseDialog(_owncloudSetupWizard->wizard()); return; } @@ -890,10 +888,12 @@ void Application::slotConfigure() void Application::slotConfigureProxy() { - ProxyDialog dlg; - if (dlg.exec() == QDialog::Accepted) - { - setupProxy(); + if (_proxyDialog.isNull()) { + _proxyDialog = new ProxyDialog; + _proxyDialog->open(); + connect(_proxyDialog, SIGNAL(accept()), SLOT(slotSetupProxy())); + } else { + raiseDialog(_proxyDialog); } } diff --git a/src/mirall/application.h b/src/mirall/application.h index ca7ce1614..572c32fa3 100644 --- a/src/mirall/application.h +++ b/src/mirall/application.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "qtsingleapplication.h" @@ -43,7 +44,7 @@ class StatusDialog; class OwncloudSetupWizard; class ownCloudInfo; class SslErrorDialog; -class UpdateDetector; +class ProxyDialog; class Application : public SharedTools::QtSingleApplication { @@ -79,7 +80,6 @@ protected: void setupSystemTray(); void setupContextMenu(); void setupLogBrowser(); - void setupProxy(); void enterNextLogFile(); //folders have to be disabled while making config changes @@ -105,6 +105,7 @@ protected slots: void slotFetchCredentials(); void slotCredentialsFetched( bool ); void slotStartUpdateDetector(); + void slotSetupProxy(); private: void setHelp(); @@ -124,7 +125,7 @@ private: QNetworkConfigurationManager *_networkMgr; #endif - FolderWizard *_folderWizard; + QPointer _folderWizard; QScopedPointer _owncloudSetupWizard; SslErrorDialog *_sslErrorDialog; @@ -136,8 +137,8 @@ private: FolderMan *_folderMan; Theme *_theme; QSignalMapper *_folderOpenActionMapper; - UpdateDetector *_updateDetector; LogBrowser *_logBrowser; + QPointer _proxyDialog; QString _logFile; QString _logDirectory; int _logExpire;