First version of progress in the context menu

This commit is contained in:
Daniel Molkentin 2013-07-23 13:18:52 +02:00
parent 274f59f93b
commit da087292fd
2 changed files with 31 additions and 0 deletions

View file

@ -36,6 +36,7 @@
#include "mirall/utility.h"
#include "mirall/inotify.h"
#include "mirall/connectionvalidator.h"
#include "mirall/progressdispatcher.h"
#if defined(Q_OS_WIN)
#include <windows.h>
@ -122,6 +123,10 @@ Application::Application(int &argc, char **argv) :
this, SLOT(slotShowTrayMessage(QString,QString)));
connect( Logger::instance(), SIGNAL(optionalGuiLog(QString,QString)),
this, SLOT(slotShowOptionalTrayMessage(QString,QString)));
ProgressDispatcher *pd = ProgressDispatcher::instance();
connect( pd, SIGNAL(overallProgress(QString,QString,int,int,qlonglong,qlonglong)),
SLOT(slotUpdateProgress(QString,QString,int,int,qlonglong,qlonglong)));
// create folder manager for sync folder management
FolderMan *folderMan = FolderMan::instance();
connect( folderMan, SIGNAL(folderSyncStateChange(QString)),
@ -281,6 +286,8 @@ void Application::setupActions()
QObject::connect(_actionOpenoC, SIGNAL(triggered(bool)), SLOT(slotOpenOwnCloud()));
_actionQuota = new QAction(tr("Calculating quota..."), this);
_actionQuota->setEnabled( false );
_actionStatus = new QAction(tr("Unknown status"), this);
_actionStatus->setEnabled( false );
_actionSettings = new QAction(tr("Settings..."), this);
QObject::connect(_actionSettings, SIGNAL(triggered(bool)), SLOT(slotSettings()));
_actionHelp = new QAction(tr("Help"), this);
@ -355,6 +362,8 @@ void Application::setupContextMenu()
_contextMenu->addSeparator();
_contextMenu->addAction(_actionQuota);
_contextMenu->addSeparator();
_contextMenu->addAction(_actionStatus);
_contextMenu->addSeparator();
_contextMenu->addAction(_actionSettings);
_contextMenu->addAction(_actionHelp);
_contextMenu->addSeparator();
@ -479,6 +488,25 @@ void Application::slotUseMonoIconsChanged(bool)
computeOverallSyncStatus();
}
void Application::slotUpdateProgress(QString folder, QString file, int fileNo, int fileCnt, qlonglong o1, qlonglong o2)
{
Q_UNUSED(folder)
Q_UNUSED(file)
QString curAmount = Utility::octetsToString(o1);
QString totalAmount = Utility::octetsToString(o2);
_actionStatus->setText(tr("Syncing %1 of %2 (%3 of %4) ").arg(fileNo).arg(fileCnt).arg(curAmount, totalAmount));
if (o1 == o2) {
QTimer::singleShot(2000, this, SLOT(slotDisplayIdle()));
}
}
void Application::slotDisplayIdle()
{
_actionStatus->setText(tr("Idle"));
}
void Application::slotHelp()
{
QDesktopServices::openUrl(QUrl(_theme->helpUrl()));

View file

@ -97,6 +97,8 @@ protected slots:
void slotSetupProxy();
void slotRefreshQuotaDisplay( qint64 total, qint64 used );
void slotUseMonoIconsChanged( bool );
void slotUpdateProgress(QString,QString,int,int,qlonglong,qlonglong);
void slotDisplayIdle();
void slotHelp();
private:
void setHelp();
@ -106,6 +108,7 @@ private:
QAction *_actionOpenoC;
QAction *_actionSettings;
QAction *_actionQuota;
QAction *_actionStatus;
QAction *_actionHelp;
QAction *_actionQuit;