From 01b0ee49dece7d32e21db667b69ccba7635b8df2 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 13:58:20 +0200 Subject: [PATCH 1/8] Status Icons: Rename the syncEnable method to isPaused. Previously, in folder and folderman there have been the syncEnabled properties, but they confused the semantics: While in FolderMan the syncEnabled flag represents the network connection and stuff, in Folder it represented if the user paused or resumed the folder. This resulted in mixed use of both, which lead to wrong icon states. This patch renames the folder methods and properties to isPaused to make more clear about what it is. --- src/mirall/accountsettings.cpp | 116 ++++++++++++++-------------- src/mirall/folder.cpp | 10 +-- src/mirall/folder.h | 6 +- src/mirall/folderman.cpp | 135 ++++++++++++++++++--------------- src/mirall/folderman.h | 6 +- src/mirall/folderstatusmodel.h | 2 +- src/mirall/owncloudgui.cpp | 2 +- 7 files changed, 145 insertions(+), 132 deletions(-) diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp index 7298c2c13..93479cb34 100644 --- a/src/mirall/accountsettings.cpp +++ b/src/mirall/accountsettings.cpp @@ -159,8 +159,8 @@ void AccountSettings::slotFolderActivated( const QModelIndex& indx ) ui->_buttonEnable->setEnabled( isValid ); if ( isValid ) { - bool folderEnabled = _model->data( indx, FolderStatusDelegate::FolderSyncEnabled).toBool(); - if ( folderEnabled ) { + bool folderPaused = _model->data( indx, FolderStatusDelegate::FolderSyncPaused).toBool(); + if ( !folderPaused) { ui->_buttonEnable->setText( tr( "Pause" ) ); } else { ui->_buttonEnable->setText( tr( "Resume" ) ); @@ -256,8 +256,7 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f ) item->setData( f->nativePath(), FolderStatusDelegate::FolderPathRole ); item->setData( f->remotePath(), FolderStatusDelegate::FolderSecondPathRole ); item->setData( f->alias(), FolderStatusDelegate::FolderAliasRole ); - item->setData( f->syncEnabled(), FolderStatusDelegate::FolderSyncEnabled ); - + item->setData( f->syncPaused(), FolderStatusDelegate::FolderSyncPaused ); SyncResult res = f->syncResult(); SyncResult::Status status = res.status(); @@ -266,7 +265,10 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f ) Theme *theme = Theme::instance(); item->setData( theme->statusHeaderText( status ), Qt::ToolTipRole ); if (_account->state() == Account::Connected) { - if( f->syncEnabled() ) { + if( f->syncPaused() ) { + item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before + _wasDisabledBefore = false; + } else { if( status == SyncResult::SyncPrepare ) { if( _wasDisabledBefore ) { // if the folder was disabled before, set the sync icon @@ -284,9 +286,6 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f ) item->setData( theme->syncStateIcon( status ), FolderStatusDelegate::FolderStatusIconRole ); } } - } else { - item->setData( theme->folderDisabledIcon( ), FolderStatusDelegate::FolderStatusIconRole ); // size 48 before - _wasDisabledBefore = false; } } else { item->setData( theme->folderOfflineIcon(), FolderStatusDelegate::FolderStatusIconRole); @@ -431,57 +430,60 @@ void AccountSettings::slotEnableCurrentFolder() if( selected.isValid() ) { QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString(); - bool folderEnabled = _model->data( selected, FolderStatusDelegate::FolderSyncEnabled).toBool(); - qDebug() << "Toggle enabled/disabled Folder alias " << alias << " - current state: " << folderEnabled; - if( !alias.isEmpty() ) { - FolderMan *folderMan = FolderMan::instance(); - qDebug() << "Application: enable folder with alias " << alias; - bool terminate = false; - - // this sets the folder status to disabled but does not interrupt it. - Folder *f = folderMan->folder( alias ); - if (!f) { - return; - } - - if( folderEnabled ) { - // check if a sync is still running and if so, ask if we should terminate. - if( f->isBusy() ) { // its still running -#if defined(Q_OS_MAC) - QWidget *parent = this; - Qt::WindowFlags flags = Qt::Sheet; -#else - QWidget *parent = 0; - Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint; // default flags -#endif - QMessageBox msgbox(QMessageBox::Question, tr("Sync Running"), - tr("The syncing operation is running.
Do you want to terminate it?"), - QMessageBox::Yes | QMessageBox::No, parent, flags); - msgbox.setDefaultButton(QMessageBox::Yes); - int reply = msgbox.exec(); - if ( reply == QMessageBox::Yes ) - terminate = true; - else - return; // do nothing - } - } - - // message box can return at any time while the thread keeps running, - // so better check again after the user has responded. - if ( f->isBusy() && terminate ) { - f->slotTerminateSync(); - } - - folderMan->slotEnableFolder( alias, !folderEnabled ); - - // keep state for the icon setting. - if( !folderEnabled ) _wasDisabledBefore = true; - - slotUpdateFolderState (f); - // set the button text accordingly. - slotFolderActivated( selected ); + if( alias.isEmpty() ) { + qDebug() << "Empty alias to enable."; + return; } + + FolderMan *folderMan = FolderMan::instance(); + + qDebug() << "Application: enable folder with alias " << alias; + bool terminate = false; + bool currentlyPaused = false; + + // this sets the folder status to disabled but does not interrupt it. + Folder *f = folderMan->folder( alias ); + if (!f) { + return; + } + currentlyPaused = f->syncPaused(); + if( ! currentlyPaused ) { + // check if a sync is still running and if so, ask if we should terminate. + if( f->isBusy() ) { // its still running +#if defined(Q_OS_MAC) + QWidget *parent = this; + Qt::WindowFlags flags = Qt::Sheet; +#else + QWidget *parent = 0; + Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint; // default flags +#endif + QMessageBox msgbox(QMessageBox::Question, tr("Sync Running"), + tr("The syncing operation is running.
Do you want to terminate it?"), + QMessageBox::Yes | QMessageBox::No, parent, flags); + msgbox.setDefaultButton(QMessageBox::Yes); + int reply = msgbox.exec(); + if ( reply == QMessageBox::Yes ) + terminate = true; + else + return; // do nothing + } + } + + // message box can return at any time while the thread keeps running, + // so better check again after the user has responded. + if ( f->isBusy() && terminate ) { + f->slotTerminateSync(); + } + f->setSyncPaused(!currentlyPaused); // toggle the pause setting + folderMan->slotSetFolderPaused( alias, !currentlyPaused ); + + // keep state for the icon setting. + if( currentlyPaused ) _wasDisabledBefore = true; + + slotUpdateFolderState (f); + // set the button text accordingly. + slotFolderActivated( selected ); } } diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index 6844e4999..6660d0a2a 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -54,7 +54,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP , _path(path) , _remotePath(secondPath) , _alias(alias) - , _enabled(true) + , _paused(false) , _csyncError(false) , _csyncUnavail(false) , _wipeDb(false) @@ -215,14 +215,14 @@ QString Folder::nativePath() const return QDir::toNativeSeparators(_path); } -bool Folder::syncEnabled() const +bool Folder::syncPaused() const { - return _enabled; + return _paused; } -void Folder::setSyncEnabled( bool doit ) +void Folder::setSyncPaused( bool doit ) { - _enabled = doit; + _paused = doit; if( doit ) { // qDebug() << "Syncing enabled on folder " << name(); diff --git a/src/mirall/folder.h b/src/mirall/folder.h index 0e5656c98..dcea1a2d3 100644 --- a/src/mirall/folder.h +++ b/src/mirall/folder.h @@ -85,9 +85,9 @@ public: * If the sync is switched off, the startSync method is not going to * be called. */ - void setSyncEnabled( bool ); + void setSyncPaused( bool ); - bool syncEnabled() const; + bool syncPaused() const; void prepareToSync(); @@ -185,7 +185,7 @@ private: QString _remotePath; QString _alias; QString _configFile; - bool _enabled; + bool _paused; SyncResult _syncResult; QScopedPointer _engine; QStringList _errors; diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp index 7ec10a3d6..11da86494 100644 --- a/src/mirall/folderman.cpp +++ b/src/mirall/folderman.cpp @@ -330,7 +330,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) { qDebug() << "Adding folder to Folder Map " << folder; _folderMap[alias] = folder; if (paused) { - folder->setSyncEnabled(!paused); + folder->setSyncPaused(paused); _disabledFolders.insert(folder); } @@ -361,7 +361,7 @@ void FolderMan::slotEnableFolder( const QString& alias, bool enable ) // FIXME: Use MirallConfigFile QSettings settings(_folderConfigPath + QLatin1Char('/') + f->configFile(), QSettings::IniFormat); settings.beginGroup(escapeAlias(f->alias())); - if (enable) { + if (!paused) { settings.remove("paused"); _disabledFolders.remove(f); } else { @@ -410,7 +410,7 @@ SyncResult FolderMan::syncResult( const QString& alias ) void FolderMan::slotScheduleAllFolders() { foreach( Folder *f, _folderMap.values() ) { - if (f && f->syncEnabled()) { + if (f && ! f->syncPaused()) { slotScheduleSync( f->alias() ); } } @@ -433,7 +433,7 @@ void FolderMan::slotScheduleSync( const QString& alias ) if( ! _scheduleQueue.contains(alias ) && _folderMap.contains(alias) ) { Folder *f = _folderMap[alias]; if( f ) { - if( f->syncEnabled() ) { + if( !f->syncPaused() ) { f->prepareToSync(); } else { qDebug() << "Folder is not enabled, not scheduled!"; @@ -487,7 +487,7 @@ void FolderMan::slotScheduleFolderSync() const QString alias = _scheduleQueue.dequeue(); if( _folderMap.contains( alias ) ) { Folder *f = _folderMap[alias]; - if( f && f->syncEnabled() ) { + if( f && !f->syncPaused() ) { _currentSyncFolder = alias; f->startSync( QStringList() ); @@ -585,7 +585,7 @@ void FolderMan::removeFolder( const QString& alias ) f->wipe(); // can be removed if we are able to delete the folder object. - f->setSyncEnabled(false); + f->setSyncPaused(true); // remove the folder configuration QFile file( _folderConfigPath + QLatin1Char('/') + f->configFile() ); @@ -680,39 +680,44 @@ SyncResult FolderMan::accountStatus(const QList &folders) if( cnt == 1 ) { Folder *folder = folders.at(0); if( folder ) { - SyncResult::Status syncStatus = folder->syncResult().status(); + if( folder->syncPaused() ) { + overallResult.setStatus(SyncResult::Paused); + } else { + SyncResult::Status syncStatus = folder->syncResult().status(); - switch( syncStatus ) { - case SyncResult::Undefined: - overallResult.setStatus(SyncResult::Error); - break; - case SyncResult::NotYetStarted: - overallResult.setStatus( SyncResult::NotYetStarted ); - break; - case SyncResult::SyncPrepare: - overallResult.setStatus( SyncResult::SyncPrepare ); - break; - case SyncResult::SyncRunning: - overallResult.setStatus( SyncResult::SyncRunning ); - break; - case SyncResult::Problem: // don't show the problem icon in tray. - case SyncResult::Success: - if( overallResult.status() == SyncResult::Undefined ) - overallResult.setStatus( SyncResult::Success ); - break; - case SyncResult::Error: - overallResult.setStatus( SyncResult::Error ); - break; - case SyncResult::SetupError: - if ( overallResult.status() != SyncResult::Error ) - overallResult.setStatus( SyncResult::SetupError ); - break; - case SyncResult::SyncAbortRequested: - overallResult.setStatus( SyncResult::SyncAbortRequested); - break; - case SyncResult::Paused: - overallResult.setStatus( SyncResult::Paused); - break; + + switch( syncStatus ) { + case SyncResult::Undefined: + overallResult.setStatus(SyncResult::Error); + break; + case SyncResult::NotYetStarted: + overallResult.setStatus( SyncResult::NotYetStarted ); + break; + case SyncResult::SyncPrepare: + overallResult.setStatus( SyncResult::SyncPrepare ); + break; + case SyncResult::SyncRunning: + overallResult.setStatus( SyncResult::SyncRunning ); + break; + case SyncResult::Problem: // don't show the problem icon in tray. + case SyncResult::Success: + if( overallResult.status() == SyncResult::Undefined ) + overallResult.setStatus( SyncResult::Success ); + break; + case SyncResult::Error: + overallResult.setStatus( SyncResult::Error ); + break; + case SyncResult::SetupError: + if ( overallResult.status() != SyncResult::Error ) + overallResult.setStatus( SyncResult::SetupError ); + break; + case SyncResult::SyncAbortRequested: + overallResult.setStatus( SyncResult::SyncAbortRequested); + break; + case SyncResult::Paused: + overallResult.setStatus( SyncResult::Paused); + break; + } } } } else { @@ -723,30 +728,34 @@ SyncResult FolderMan::accountStatus(const QList &folders) int various = 0; foreach ( Folder *folder, folders ) { - SyncResult folderResult = folder->syncResult(); - SyncResult::Status syncStatus = folderResult.status(); - - switch( syncStatus ) { - case SyncResult::Undefined: - case SyncResult::NotYetStarted: - case SyncResult::SyncPrepare: - various++; - break; - case SyncResult::SyncRunning: - runSeen++; - break; - case SyncResult::Problem: // don't show the problem icon in tray. - case SyncResult::Success: - goodSeen++; - break; - case SyncResult::Error: - case SyncResult::SetupError: - errorsSeen++; - break; - case SyncResult::SyncAbortRequested: - case SyncResult::Paused: + if( folder->syncPaused() ) { abortSeen++; - // no default case on purpose, check compiler warnings + } else { + SyncResult folderResult = folder->syncResult(); + SyncResult::Status syncStatus = folderResult.status(); + + switch( syncStatus ) { + case SyncResult::Undefined: + case SyncResult::NotYetStarted: + case SyncResult::SyncPrepare: + various++; + break; + case SyncResult::SyncRunning: + runSeen++; + break; + case SyncResult::Problem: // don't show the problem icon in tray. + case SyncResult::Success: + goodSeen++; + break; + case SyncResult::Error: + case SyncResult::SetupError: + errorsSeen++; + break; + case SyncResult::SyncAbortRequested: + case SyncResult::Paused: + abortSeen++; + // no default case on purpose, check compiler warnings + } } } bool set = false; @@ -772,7 +781,7 @@ SyncResult FolderMan::accountStatus(const QList &folders) return overallResult; } -QString FolderMan::statusToString( SyncResult syncStatus, bool enabled ) const +QString FolderMan::statusToString( SyncResult syncStatus, bool paused ) const { QString folderMessage; switch( syncStatus.status() ) { @@ -807,7 +816,7 @@ QString FolderMan::statusToString( SyncResult syncStatus, bool enabled ) const break; // no default case on purpose, check compiler warnings } - if( !enabled ) { + if( paused ) { // sync is disabled. folderMessage = tr( "%1 (Sync is paused)" ).arg(folderMessage); } diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h index c3a8d0012..1b4c55188 100644 --- a/src/mirall/folderman.h +++ b/src/mirall/folderman.h @@ -77,7 +77,7 @@ public: /** Creates a new and empty local directory. */ bool startFromScratch( const QString& ); - QString statusToString( SyncResult, bool enabled ) const; + QString statusToString(SyncResult, bool paused ) const; static SyncResult accountStatus( const QList &folders ); @@ -88,6 +88,8 @@ signals: /** * signal to indicate a folder named by alias has changed its sync state. * Get the state via the Folder Map or the syncResult and syncState methods. + * + * Attention: The alias string may be zero. Do a general update of the state than. */ void folderSyncStateChange( const QString & ); @@ -95,7 +97,7 @@ signals: public slots: void slotRemoveFolder( const QString& ); - void slotEnableFolder( const QString&, bool ); + void slotSetFolderPaused(const QString&, bool paused); void slotFolderSyncStarted(); void slotFolderSyncFinished( const SyncResult& ); diff --git a/src/mirall/folderstatusmodel.h b/src/mirall/folderstatusmodel.h index 74acaa08a..77120b324 100644 --- a/src/mirall/folderstatusmodel.h +++ b/src/mirall/folderstatusmodel.h @@ -42,7 +42,7 @@ class FolderStatusDelegate : public QStyledItemDelegate FolderRemotePath, FolderStatus, FolderErrorMsg, - FolderSyncEnabled, + FolderSyncPaused, FolderStatusIconRole, SyncProgressOverallPercent, diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp index baa84bb1f..9bb2743b9 100644 --- a/src/mirall/owncloudgui.cpp +++ b/src/mirall/owncloudgui.cpp @@ -249,7 +249,7 @@ void ownCloudGui::slotComputeOverallSyncStatus() QStringList allStatusStrings; foreach(Folder* folder, map.values()) { qDebug() << "Folder in overallStatus Message: " << folder << " with name " << folder->alias(); - QString folderMessage = folderMan->statusToString(folder->syncResult().status(), folder->syncEnabled()); + QString folderMessage = folderMan->statusToString(folder->syncResult().status(), folder->syncPaused()); allStatusStrings += tr("Folder %1: %2").arg(folder->alias(), folderMessage); } From 1245ed6f0650193874fef99224f006d0bb6087d6 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 14:03:41 +0200 Subject: [PATCH 2/8] Status Icons: Let FolderMan only write the folder config files. Remove the setSyncEnabled() call to individual folders which mistakenly set the folders to pause. Let the folders keep their pause state on their own. If FolderMan is set to be enabled emit a general refresh signal rather than one for each folder. --- src/mirall/folder.cpp | 2 +- src/mirall/folderman.cpp | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index 6660d0a2a..fb296e430 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -482,7 +482,7 @@ void Folder::slotTerminateSync() // Do not display an error message, user knows his own actions. // _errors.append( tr("The CSync thread terminated.") ); // _csyncError = true; - setSyncEnabled(false); + FolderMan::instance()->slotSetFolderPaused(alias(), true); setSyncState(SyncResult::SyncAbortRequested); return; } diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp index 11da86494..99ea90146 100644 --- a/src/mirall/folderman.cpp +++ b/src/mirall/folderman.cpp @@ -346,7 +346,7 @@ Folder* FolderMan::setupFolderFromConfigFile(const QString &file) { return folder; } -void FolderMan::slotEnableFolder( const QString& alias, bool enable ) +void FolderMan::slotSetFolderPaused( const QString& alias, bool paused ) { if( ! _folderMap.contains( alias ) ) { qDebug() << "!! Can not enable alias " << alias << ", can not be found in folderMap."; @@ -355,7 +355,6 @@ void FolderMan::slotEnableFolder( const QString& alias, bool enable ) Folder *f = _folderMap[alias]; if( f ) { - f->setSyncEnabled(enable); slotScheduleSync(alias); // FIXME: Use MirallConfigFile @@ -442,7 +441,6 @@ void FolderMan::slotScheduleSync( const QString& alias ) } } _scheduleQueue.enqueue(alias); - } else { qDebug() << " II> Sync for folder " << alias << " already scheduled, do not enqueue!"; } @@ -450,6 +448,8 @@ void FolderMan::slotScheduleSync( const QString& alias ) QTimer::singleShot(500, this, SLOT(slotScheduleFolderSync())); } +// only enable or disable foldermans will to schedule and do syncs. +// this is not the same as Pause and Resume of folders. void FolderMan::setSyncEnabled( bool enabled ) { if (!_syncEnabled && enabled && !_scheduleQueue.isEmpty()) { @@ -457,12 +457,8 @@ void FolderMan::setSyncEnabled( bool enabled ) QTimer::singleShot(200, this, SLOT(slotScheduleFolderSync())); } _syncEnabled = enabled; - - foreach( Folder *f, _folderMap.values() ) { - if(f) { // check for f != 0. That can happen, do not remove the check! - f->setSyncEnabled(enabled && !_disabledFolders.contains(f)); - } - } + // force a redraw in case the network connect status changed + emit( folderSyncStateChange(QString::null) ); } /* From bb3bd6930a9d2ab59151a2085ba5bccc1e4efe84 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 14:06:28 +0200 Subject: [PATCH 3/8] StatusModel: Have another property accountConnected. With that , make the status model aware of the account connection state. With that, we can grey out the correct state icon if the account is not connected and display the normal icon if the account is connected. --- src/mirall/accountsettings.cpp | 11 ++++++----- src/mirall/accountsettings.h | 2 +- src/mirall/folderstatusmodel.cpp | 3 ++- src/mirall/folderstatusmodel.h | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mirall/accountsettings.cpp b/src/mirall/accountsettings.cpp index 93479cb34..dadce7122 100644 --- a/src/mirall/accountsettings.cpp +++ b/src/mirall/accountsettings.cpp @@ -227,7 +227,7 @@ void AccountSettings::slotAddFolder( Folder *folder ) if( ! folder || folder->alias().isEmpty() ) return; QStandardItem *item = new QStandardItem(); - folderToModelItem( item, folder ); + folderToModelItem( item, folder, _account->state() == Account::Connected ); _model->appendRow( item ); // in order to update the enabled state of the "Sync now" button connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection); @@ -249,7 +249,7 @@ void AccountSettings::setGeneralErrors( const QStringList& errors ) } } -void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f ) +void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f, bool accountConnected ) { if( ! item || !f ) return; @@ -257,6 +257,7 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f ) item->setData( f->remotePath(), FolderStatusDelegate::FolderSecondPathRole ); item->setData( f->alias(), FolderStatusDelegate::FolderAliasRole ); item->setData( f->syncPaused(), FolderStatusDelegate::FolderSyncPaused ); + item->setData( accountConnected, FolderStatusDelegate::FolderAccountConnected ); SyncResult res = f->syncResult(); SyncResult::Status status = res.status(); @@ -516,7 +517,7 @@ void AccountSettings::slotUpdateFolderState( Folder *folder ) } if( item ) { - folderToModelItem( item, folder ); + folderToModelItem( item, folder, _account->state() == Account::Connected ); } else { // the dialog is not visible. } @@ -782,10 +783,10 @@ void AccountSettings::slotSyncStateChange(const QString& alias) { Q_UNUSED(alias); - FolderMan *folderMan = FolderMan::instance(); - SyncResult state = folderMan->accountStatus(folderMan->map().values()); QIcon icon; if (_account && _account->state() == Account::Connected) { + FolderMan *folderMan = FolderMan::instance(); + SyncResult state = folderMan->accountStatus(folderMan->map().values()); icon = Theme::instance()->syncStateIcon(state.status()); } else { icon = Theme::instance()->folderOfflineIcon(); diff --git a/src/mirall/accountsettings.h b/src/mirall/accountsettings.h index ee3bfd439..56753605a 100644 --- a/src/mirall/accountsettings.h +++ b/src/mirall/accountsettings.h @@ -86,7 +86,7 @@ protected slots: private: QString shortenFilename( const QString& folder, const QString& file ) const; - void folderToModelItem( QStandardItem *, Folder * ); + void folderToModelItem(QStandardItem *, Folder * , bool accountConnected); QStandardItem* itemForFolder(const QString& ); void showConnectionLabel( const QString& message, const QString& tooltip = QString() ); diff --git a/src/mirall/folderstatusmodel.cpp b/src/mirall/folderstatusmodel.cpp index c4eea0f97..2cf9d6a1f 100644 --- a/src/mirall/folderstatusmodel.cpp +++ b/src/mirall/folderstatusmodel.cpp @@ -133,8 +133,9 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem & QString itemString = qvariant_cast(index.data(SyncProgressItemString)); int warningCount = qvariant_cast(index.data(WarningCount)); bool syncOngoing = qvariant_cast(index.data(SyncRunning)); + // QString statusText = qvariant_cast(index.data(FolderStatus)); - bool syncEnabled = index.data(FolderSyncEnabled).toBool(); + bool syncEnabled = index.data(FolderAccountConnected).toBool(); // QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" ); QRect iconRect = option.rect; diff --git a/src/mirall/folderstatusmodel.h b/src/mirall/folderstatusmodel.h index 77120b324..4cd36a9b0 100644 --- a/src/mirall/folderstatusmodel.h +++ b/src/mirall/folderstatusmodel.h @@ -44,6 +44,7 @@ class FolderStatusDelegate : public QStyledItemDelegate FolderErrorMsg, FolderSyncPaused, FolderStatusIconRole, + FolderAccountConnected, SyncProgressOverallPercent, SyncProgressOverallString, From 924d9b985ffc6db564fe8e18c8a08ad88d3d9416 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 14:08:31 +0200 Subject: [PATCH 4/8] Some minor cleanups. --- src/mirall/folder.cpp | 3 ++- src/mirall/owncloudgui.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index fb296e430..4a2fadf9f 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -260,6 +260,7 @@ void Folder::slotPollTimerTimeout() qDebug() << "** Force Sync now, state is " << _syncResult.statusString(); emit scheduleToSync(alias()); } else { + // do the ordinary etag chech for the root folder. RequestEtagJob* job = new RequestEtagJob(AccountManager::instance()->account(), remotePath(), this); // check if the etag is different QObject::connect(job, SIGNAL(etagRetreived(QString)), this, SLOT(etagRetreived(QString))); @@ -689,7 +690,7 @@ void Folder::slotEmitFinishedDelayed() } -void Folder::slotFolderDiscovered(bool local, QString folderName) +void Folder::slotFolderDiscovered(bool, QString folderName) { Progress::Info pi; pi._currentDiscoveredFolder = folderName; diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp index 9bb2743b9..9af03690b 100644 --- a/src/mirall/owncloudgui.cpp +++ b/src/mirall/owncloudgui.cpp @@ -164,12 +164,12 @@ void ownCloudGui::slotSyncStateChange( const QString& alias ) slotComputeOverallSyncStatus(); + if( alias.isEmpty() ) { + return; // Valid, just a general GUI redraw was needed. + } + qDebug() << "Sync state changed for folder " << alias << ": " << result.statusString(); - // Promote sync result to settings-dialog for sync protocol? - // if( _progressDialog ) { - // _progressDialog->setSyncResult(result); - // } if (result.status() == SyncResult::Success || result.status() == SyncResult::Error) { Logger::instance()->enterNextLogFile(); } @@ -204,8 +204,10 @@ void ownCloudGui::startupConnected( bool connected, const QStringList& fails ) } _startupFails = fails; // store that for the settings dialog once it appears. - if( !_settingsDialog.isNull() ) + if( !_settingsDialog.isNull() ) { _settingsDialog->setGeneralErrors( _startupFails ); + } + } void ownCloudGui::slotComputeOverallSyncStatus() From dc0a054d9420f31cb325c683347e64758d093ebe Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 14:09:53 +0200 Subject: [PATCH 5/8] Status icons: Set the offline icon at the very beginning. Otherwise, if the account is signed out and opens the credential popup, there is a wrong icon displayed. If the account is coming from keychain this icon is quickly overwritten. --- src/mirall/owncloudgui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp index 9af03690b..0fc9ff63d 100644 --- a/src/mirall/owncloudgui.cpp +++ b/src/mirall/owncloudgui.cpp @@ -54,7 +54,9 @@ ownCloudGui::ownCloudGui(Application *parent) : { _tray = new Systray(); _tray->setParent(this); - _tray->setIcon( Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true ) ); + + // for the beginning, set the offline icon until the account was verified + _tray->setIcon( Theme::instance()->folderOfflineIcon(true)); connect(_tray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason))); From e4fe4cb4d31e43c26916eeed5bf7e03e9e6e77d4 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 14:10:57 +0200 Subject: [PATCH 6/8] Status icons: Display the correct icons after startup connect. --- src/mirall/owncloudgui.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp index 0fc9ff63d..a46b31d97 100644 --- a/src/mirall/owncloudgui.cpp +++ b/src/mirall/owncloudgui.cpp @@ -201,8 +201,8 @@ void ownCloudGui::startupConnected( bool connected, const QStringList& fails ) if( connected ) { qDebug() << "######## connected to ownCloud Server!"; folderMan->setSyncEnabled(true); - _tray->setIcon( Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true ) ); - _tray->show(); + // _tray->setIcon( Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true ) ); + // _tray->show(); } _startupFails = fails; // store that for the settings dialog once it appears. @@ -210,6 +210,7 @@ void ownCloudGui::startupConnected( bool connected, const QStringList& fails ) _settingsDialog->setGeneralErrors( _startupFails ); } + slotComputeOverallSyncStatus(); } void ownCloudGui::slotComputeOverallSyncStatus() From 617887a0c6a5aa8bf39407992ab2591ad777b58c Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 14:14:01 +0200 Subject: [PATCH 7/8] Propagator: If the sync was interrupted by pausing, do not show error. Handle problems which happen because of pausing the sync as soft errors rather than normal errors which are blacklisted and displayed in the gui. This fixes bug #1959 --- src/mirall/owncloudpropagator.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp index 9a651f025..46985c470 100644 --- a/src/mirall/owncloudpropagator.cpp +++ b/src/mirall/owncloudpropagator.cpp @@ -53,6 +53,14 @@ void PropagateItemJob::done(SyncFileItem::Status status, const QString &errorStr } else { _item._errorString = errorString; } + + if( _propagator->_abortRequested.fetchAndAddRelaxed(0) ) { + // an abort request is ongoing. Change the status to Soft-Error + + status = SyncFileItem::SoftError; + _item._errorString = tr("Operation was canceled by user interaction."); + } + _item._status = status; // Blacklisting From d02175210bc8e6088e77f4f9989fe0428888b0c3 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Aug 2014 17:46:47 +0200 Subject: [PATCH 8/8] Status Icon: Set a proper icon if no sync is configured. This fixes bug #1956 --- src/mirall/owncloudgui.cpp | 8 ++++++++ src/mirall/settingsdialog.h | 2 +- src/mirall/theme.cpp | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mirall/owncloudgui.cpp b/src/mirall/owncloudgui.cpp index a46b31d97..7e9e71064 100644 --- a/src/mirall/owncloudgui.cpp +++ b/src/mirall/owncloudgui.cpp @@ -266,6 +266,14 @@ void ownCloudGui::slotComputeOverallSyncStatus() QIcon statusIcon = Theme::instance()->syncStateIcon( overallResult.status(), true); _tray->setIcon( statusIcon ); _tray->setToolTip(trayMessage); + } else { + // undefined because there are no folders. + QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Problem); + _tray->setIcon( icon ); + _tray->setToolTip(tr("There are no sync folders configured.")); + if( _settingsDialog ) { + _settingsDialog->slotUpdateAccountIcon(icon); + } } } } diff --git a/src/mirall/settingsdialog.h b/src/mirall/settingsdialog.h index 1e60f6d21..f5ce4dbd8 100644 --- a/src/mirall/settingsdialog.h +++ b/src/mirall/settingsdialog.h @@ -46,13 +46,13 @@ public: public slots: void showActivityPage(); + void slotUpdateAccountIcon(const QIcon& icon); protected: void reject() Q_DECL_OVERRIDE; void accept() Q_DECL_OVERRIDE; private slots: - void slotUpdateAccountIcon(const QIcon& icon); private: Ui::SettingsDialog *_ui; diff --git a/src/mirall/theme.cpp b/src/mirall/theme.cpp index d6f332132..94bead60e 100644 --- a/src/mirall/theme.cpp +++ b/src/mirall/theme.cpp @@ -282,6 +282,9 @@ QIcon Theme::syncStateIcon( SyncResult::Status status, bool sysTray ) const switch( status ) { case SyncResult::Undefined: + // this can happen if no sync connections are configured. + statusIcon = QLatin1String("state-information"); + break; case SyncResult::NotYetStarted: case SyncResult::SyncRunning: statusIcon = QLatin1String("state-sync");