mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 05:25:50 +03:00
AccountSettings: Add a "Force sync now" context menu option
This commit is contained in:
parent
7523db354d
commit
68f99bcc27
4 changed files with 57 additions and 9 deletions
|
@ -111,7 +111,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) :
|
||||||
|
|
||||||
QAction *syncNowAction = new QAction(this);
|
QAction *syncNowAction = new QAction(this);
|
||||||
syncNowAction->setShortcut(QKeySequence(Qt::Key_F6));
|
syncNowAction->setShortcut(QKeySequence(Qt::Key_F6));
|
||||||
connect(syncNowAction, SIGNAL(triggered()), SLOT(slotSyncCurrentFolderNow()));
|
connect(syncNowAction, SIGNAL(triggered()), SLOT(slotScheduleCurrentFolder()));
|
||||||
addAction(syncNowAction);
|
addAction(syncNowAction);
|
||||||
|
|
||||||
connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
|
connect(ui->_folderList, SIGNAL(clicked(const QModelIndex &)),
|
||||||
|
@ -229,6 +229,11 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
|
||||||
connect(ac, SIGNAL(triggered(bool)), this, SLOT(doExpand()));
|
connect(ac, SIGNAL(triggered(bool)), this, SLOT(doExpand()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!folderPaused) {
|
||||||
|
ac = menu->addAction(tr("Force sync now"));
|
||||||
|
connect(ac, SIGNAL(triggered(bool)), this, SLOT(slotForceSyncCurrentFolder()));
|
||||||
|
}
|
||||||
|
|
||||||
ac = menu->addAction(folderPaused ? tr("Resume sync") : tr("Pause sync"));
|
ac = menu->addAction(folderPaused ? tr("Resume sync") : tr("Pause sync"));
|
||||||
connect(ac, SIGNAL(triggered(bool)), this, SLOT(slotEnableCurrentFolder()));
|
connect(ac, SIGNAL(triggered(bool)), this, SLOT(slotEnableCurrentFolder()));
|
||||||
|
|
||||||
|
@ -463,7 +468,7 @@ void AccountSettings::slotEnableCurrentFolder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountSettings::slotSyncCurrentFolderNow()
|
void AccountSettings::slotScheduleCurrentFolder()
|
||||||
{
|
{
|
||||||
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||||
if( !selected.isValid() )
|
if( !selected.isValid() )
|
||||||
|
@ -474,6 +479,24 @@ void AccountSettings::slotSyncCurrentFolderNow()
|
||||||
folderMan->scheduleFolder(folderMan->folder(alias));
|
folderMan->scheduleFolder(folderMan->folder(alias));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountSettings::slotForceSyncCurrentFolder()
|
||||||
|
{
|
||||||
|
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
|
||||||
|
if( !selected.isValid() )
|
||||||
|
return;
|
||||||
|
QString alias = _model->data( selected, FolderStatusDelegate::FolderAliasRole ).toString();
|
||||||
|
FolderMan *folderMan = FolderMan::instance();
|
||||||
|
|
||||||
|
// Terminate and reschedule any running sync
|
||||||
|
if (Folder* current = folderMan->currentSyncFolder()) {
|
||||||
|
folderMan->terminateSyncProcess();
|
||||||
|
folderMan->scheduleFolder(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the selected folder at the front of the queue
|
||||||
|
folderMan->scheduleFolderNext(folderMan->folder(alias));
|
||||||
|
}
|
||||||
|
|
||||||
void AccountSettings::slotOpenOC()
|
void AccountSettings::slotOpenOC()
|
||||||
{
|
{
|
||||||
if( _OCUrl.isValid() )
|
if( _OCUrl.isValid() )
|
||||||
|
|
|
@ -71,7 +71,8 @@ public slots:
|
||||||
protected slots:
|
protected slots:
|
||||||
void slotAddFolder();
|
void slotAddFolder();
|
||||||
void slotEnableCurrentFolder();
|
void slotEnableCurrentFolder();
|
||||||
void slotSyncCurrentFolderNow();
|
void slotScheduleCurrentFolder();
|
||||||
|
void slotForceSyncCurrentFolder();
|
||||||
void slotRemoveCurrentFolder();
|
void slotRemoveCurrentFolder();
|
||||||
void slotOpenCurrentFolder();
|
void slotOpenCurrentFolder();
|
||||||
void slotFolderWizardAccepted();
|
void slotFolderWizardAccepted();
|
||||||
|
|
|
@ -520,6 +520,26 @@ void FolderMan::scheduleFolder( Folder *f )
|
||||||
startScheduledSyncSoon();
|
startScheduledSyncSoon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FolderMan::scheduleFolderNext(Folder* f)
|
||||||
|
{
|
||||||
|
auto alias = f->alias();
|
||||||
|
qDebug() << "Schedule folder " << alias << " to sync! Front-of-queue.";
|
||||||
|
|
||||||
|
if( !f->canSync() ) {
|
||||||
|
qDebug() << "Folder is not ready to sync, not scheduled!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_scheduledFolders.removeAll(f);
|
||||||
|
|
||||||
|
f->prepareToSync();
|
||||||
|
emit folderSyncStateChange(f);
|
||||||
|
_scheduledFolders.prepend(f);
|
||||||
|
emit scheduleQueueChanged();
|
||||||
|
|
||||||
|
startScheduledSyncSoon();
|
||||||
|
}
|
||||||
|
|
||||||
void FolderMan::slotScheduleETagJob(const QString &/*alias*/, RequestEtagJob *job)
|
void FolderMan::slotScheduleETagJob(const QString &/*alias*/, RequestEtagJob *job)
|
||||||
{
|
{
|
||||||
QObject::connect(job, SIGNAL(destroyed(QObject*)), this, SLOT(slotEtagJobDestroyed(QObject*)));
|
QObject::connect(job, SIGNAL(destroyed(QObject*)), this, SLOT(slotEtagJobDestroyed(QObject*)));
|
||||||
|
|
|
@ -161,12 +161,22 @@ public:
|
||||||
/** Queues a folder for syncing. */
|
/** Queues a folder for syncing. */
|
||||||
void scheduleFolder(Folder*);
|
void scheduleFolder(Folder*);
|
||||||
|
|
||||||
|
/** Puts a folder in the very front of the queue. */
|
||||||
|
void scheduleFolderNext(Folder*);
|
||||||
|
|
||||||
/** Queues all folders for syncing. */
|
/** Queues all folders for syncing. */
|
||||||
void scheduleAllFolders();
|
void scheduleAllFolders();
|
||||||
|
|
||||||
void setDirtyProxy(bool value = true);
|
void setDirtyProxy(bool value = true);
|
||||||
void setDirtyNetworkLimits();
|
void setDirtyNetworkLimits();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminates the current folder sync.
|
||||||
|
*
|
||||||
|
* It does not switch the folder to paused state.
|
||||||
|
*/
|
||||||
|
void terminateSyncProcess();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* signal to indicate a folder has changed its sync state.
|
* signal to indicate a folder has changed its sync state.
|
||||||
|
@ -247,12 +257,6 @@ private slots:
|
||||||
void slotScheduleFolderByTime();
|
void slotScheduleFolderByTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
|
||||||
* Terminates the current folder sync.
|
|
||||||
*
|
|
||||||
* It does not switch the folder to paused state.
|
|
||||||
*/
|
|
||||||
void terminateSyncProcess();
|
|
||||||
|
|
||||||
/** Adds a new folder, does not add it to the account settings and
|
/** Adds a new folder, does not add it to the account settings and
|
||||||
* does not set an account on the new folder.
|
* does not set an account on the new folder.
|
||||||
|
|
Loading…
Reference in a new issue