mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Merge pull request #2075 from owncloud/use_folder_paused
Rework of the status icons in FolderMan and Folder objects.
This commit is contained in:
commit
988fe70771
12 changed files with 196 additions and 159 deletions
|
@ -164,8 +164,8 @@ void AccountSettings::slotFolderActivated( const QModelIndex& indx )
|
|||
ui->_buttonSelectiveSync->setEnabled(isConnected && 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" ) );
|
||||
|
@ -235,7 +235,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);
|
||||
|
@ -257,15 +257,15 @@ 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;
|
||||
|
||||
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 );
|
||||
item->setData( accountConnected, FolderStatusDelegate::FolderAccountConnected );
|
||||
SyncResult res = f->syncResult();
|
||||
SyncResult::Status status = res.status();
|
||||
|
||||
|
@ -274,7 +274,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
|
||||
|
@ -292,9 +295,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);
|
||||
|
@ -453,57 +453,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.<br/>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.<br/>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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,7 +539,7 @@ void AccountSettings::slotUpdateFolderState( Folder *folder )
|
|||
}
|
||||
|
||||
if( item ) {
|
||||
folderToModelItem( item, folder );
|
||||
folderToModelItem( item, folder, _account->state() == Account::Connected );
|
||||
} else {
|
||||
// the dialog is not visible.
|
||||
}
|
||||
|
@ -802,10 +805,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();
|
||||
|
|
|
@ -87,7 +87,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() );
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
@ -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)));
|
||||
|
@ -482,7 +483,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;
|
||||
}
|
||||
|
@ -690,7 +691,7 @@ void Folder::slotEmitFinishedDelayed()
|
|||
}
|
||||
|
||||
|
||||
void Folder::slotFolderDiscovered(bool local, QString folderName)
|
||||
void Folder::slotFolderDiscovered(bool, QString folderName)
|
||||
{
|
||||
Progress::Info pi;
|
||||
pi._currentDiscoveredFolder = folderName;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -189,7 +189,7 @@ private:
|
|||
QString _remotePath;
|
||||
QString _alias;
|
||||
QString _configFile;
|
||||
bool _enabled;
|
||||
bool _paused;
|
||||
SyncResult _syncResult;
|
||||
QScopedPointer<SyncEngine> _engine;
|
||||
QStringList _errors;
|
||||
|
|
|
@ -332,7 +332,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);
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,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.";
|
||||
|
@ -357,13 +357,12 @@ void FolderMan::slotEnableFolder( const QString& alias, bool enable )
|
|||
|
||||
Folder *f = _folderMap[alias];
|
||||
if( f ) {
|
||||
f->setSyncEnabled(enable);
|
||||
slotScheduleSync(alias);
|
||||
|
||||
// FIXME: Use MirallConfigFile
|
||||
QSettings settings(f->configFile(), QSettings::IniFormat);
|
||||
settings.beginGroup(escapeAlias(f->alias()));
|
||||
if (enable) {
|
||||
if (!paused) {
|
||||
settings.remove("paused");
|
||||
_disabledFolders.remove(f);
|
||||
} else {
|
||||
|
@ -412,7 +411,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() );
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +434,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!";
|
||||
|
@ -444,7 +443,6 @@ void FolderMan::slotScheduleSync( const QString& alias )
|
|||
}
|
||||
}
|
||||
_scheduleQueue.enqueue(alias);
|
||||
|
||||
} else {
|
||||
qDebug() << " II> Sync for folder " << alias << " already scheduled, do not enqueue!";
|
||||
}
|
||||
|
@ -452,6 +450,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()) {
|
||||
|
@ -459,12 +459,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) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -489,7 +485,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() );
|
||||
|
@ -589,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(f->configFile() );
|
||||
|
@ -684,39 +680,44 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &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 {
|
||||
|
@ -727,30 +728,34 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &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;
|
||||
|
@ -776,7 +781,7 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
|
|||
return overallResult;
|
||||
}
|
||||
|
||||
QString FolderMan::statusToString( SyncResult syncStatus, bool enabled ) const
|
||||
QString FolderMan::statusToString( SyncResult syncStatus, bool paused ) const
|
||||
{
|
||||
QString folderMessage;
|
||||
switch( syncStatus.status() ) {
|
||||
|
@ -811,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);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,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<Folder*> &folders );
|
||||
|
||||
|
@ -93,6 +93,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 & );
|
||||
|
||||
|
@ -100,7 +102,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& );
|
||||
|
|
|
@ -133,8 +133,9 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
QString itemString = qvariant_cast<QString>(index.data(SyncProgressItemString));
|
||||
int warningCount = qvariant_cast<int>(index.data(WarningCount));
|
||||
bool syncOngoing = qvariant_cast<bool>(index.data(SyncRunning));
|
||||
|
||||
// QString statusText = qvariant_cast<QString>(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;
|
||||
|
|
|
@ -42,8 +42,9 @@ class FolderStatusDelegate : public QStyledItemDelegate
|
|||
FolderRemotePath,
|
||||
FolderStatus,
|
||||
FolderErrorMsg,
|
||||
FolderSyncEnabled,
|
||||
FolderSyncPaused,
|
||||
FolderStatusIconRole,
|
||||
FolderAccountConnected,
|
||||
|
||||
SyncProgressOverallPercent,
|
||||
SyncProgressOverallString,
|
||||
|
|
|
@ -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)));
|
||||
|
@ -164,12 +166,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();
|
||||
}
|
||||
|
@ -199,13 +201,16 @@ 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.
|
||||
if( !_settingsDialog.isNull() )
|
||||
if( !_settingsDialog.isNull() ) {
|
||||
_settingsDialog->setGeneralErrors( _startupFails );
|
||||
}
|
||||
|
||||
slotComputeOverallSyncStatus();
|
||||
}
|
||||
|
||||
void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
|
@ -249,7 +254,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);
|
||||
}
|
||||
|
||||
|
@ -261,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue