2013-10-01 15:52:07 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mirall/application.h"
|
|
|
|
#include "mirall/owncloudgui.h"
|
|
|
|
#include "mirall/theme.h"
|
|
|
|
#include "mirall/folderman.h"
|
|
|
|
#include "mirall/mirallconfigfile.h"
|
|
|
|
#include "mirall/utility.h"
|
|
|
|
#include "mirall/progressdispatcher.h"
|
|
|
|
#include "mirall/owncloudsetupwizard.h"
|
|
|
|
#include "mirall/settingsdialog.h"
|
2013-10-02 17:28:33 +04:00
|
|
|
#include "mirall/logger.h"
|
|
|
|
#include "mirall/logbrowser.h"
|
2013-10-23 16:48:44 +04:00
|
|
|
#include "mirall/account.h"
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QMessageBox>
|
2013-10-02 20:16:24 +04:00
|
|
|
#include <QSignalMapper>
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
ownCloudGui::ownCloudGui(Application *parent) :
|
|
|
|
QObject(parent),
|
2013-10-02 17:28:33 +04:00
|
|
|
_tray(0),
|
2013-10-01 20:25:30 +04:00
|
|
|
_settingsDialog(0),
|
2013-10-02 17:28:33 +04:00
|
|
|
_logBrowser(0),
|
2013-10-01 15:52:07 +04:00
|
|
|
_contextMenu(0),
|
|
|
|
_recentActionsMenu(0),
|
2013-11-05 21:15:47 +04:00
|
|
|
_quotaInfo(0),
|
2013-10-02 20:16:24 +04:00
|
|
|
_folderOpenActionMapper(new QSignalMapper(this)),
|
|
|
|
_recentItemsMapper(new QSignalMapper(this)),
|
2013-10-01 15:52:07 +04:00
|
|
|
_app(parent)
|
|
|
|
{
|
|
|
|
_tray = new Systray();
|
2013-10-31 13:52:19 +04:00
|
|
|
_tray->setParent(this);
|
2013-10-01 15:52:07 +04:00
|
|
|
_tray->setIcon( Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true ) );
|
|
|
|
|
|
|
|
connect(_tray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
|
|
|
SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)));
|
|
|
|
|
|
|
|
setupActions();
|
|
|
|
setupContextMenu();
|
|
|
|
|
|
|
|
_tray->show();
|
|
|
|
|
|
|
|
/* use a signal mapper to map the open requests to the alias names */
|
2013-10-02 20:16:24 +04:00
|
|
|
connect(_folderOpenActionMapper, SIGNAL(mapped(QString)),
|
|
|
|
this, SLOT(slotFolderOpenAction(QString)));
|
|
|
|
|
|
|
|
connect(_recentItemsMapper, SIGNAL(mapped(QString)),
|
|
|
|
this, SLOT(slotOpenPath(QString)));
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
ProgressDispatcher *pd = ProgressDispatcher::instance();
|
|
|
|
connect( pd, SIGNAL(progressInfo(QString,Progress::Info)), this,
|
|
|
|
SLOT(slotUpdateProgress(QString,Progress::Info)) );
|
|
|
|
connect( pd, SIGNAL(progressSyncProblem(QString,Progress::SyncProblem)),
|
|
|
|
SLOT(slotProgressSyncProblem(QString,Progress::SyncProblem)));
|
|
|
|
|
|
|
|
FolderMan *folderMan = FolderMan::instance();
|
|
|
|
connect( folderMan, SIGNAL(folderSyncStateChange(QString)),
|
|
|
|
this,SLOT(slotSyncStateChange(QString)));
|
|
|
|
|
2013-10-02 17:55:15 +04:00
|
|
|
connect( Logger::instance(), SIGNAL(guiLog(QString,QString)),
|
|
|
|
SLOT(slotShowTrayMessage(QString,QString)));
|
|
|
|
connect( Logger::instance(), SIGNAL(optionalGuiLog(QString,QString)),
|
|
|
|
SLOT(slotShowOptionalTrayMessage(QString,QString)));
|
|
|
|
connect( Logger::instance(), SIGNAL(guiMessage(QString,QString)),
|
|
|
|
SLOT(slotShowGuiMessage(QString,QString)));
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
// This should rather be in application.... or rather in MirallConfigFile?
|
2013-11-04 19:36:23 +04:00
|
|
|
bool ownCloudGui::checkAccountExists(bool openSettings)
|
2013-10-01 15:52:07 +04:00
|
|
|
{
|
2013-10-30 19:31:47 +04:00
|
|
|
// if account is set up, start the configuration wizard.
|
|
|
|
if( AccountManager::instance()->account() ) {
|
2013-10-01 15:52:07 +04:00
|
|
|
if( openSettings ) {
|
|
|
|
this->slotSettings();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
qDebug() << "No configured folders yet, starting setup wizard";
|
2013-11-08 17:02:13 +04:00
|
|
|
OwncloudSetupWizard::runWizard(qApp, SLOT(slotownCloudWizardDone(int)));
|
2013-10-01 15:52:07 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-05 21:15:47 +04:00
|
|
|
QuotaInfo *ownCloudGui::quotaInfo() const
|
|
|
|
{
|
|
|
|
return _quotaInfo;
|
|
|
|
}
|
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
void ownCloudGui::slotTrayClicked( QSystemTrayIcon::ActivationReason reason )
|
|
|
|
{
|
|
|
|
// A click on the tray icon should only open the status window on Win and
|
|
|
|
// Linux, not on Mac. They want a menu entry.
|
|
|
|
#if !defined Q_OS_MAC
|
|
|
|
if( reason == QSystemTrayIcon::Trigger ) {
|
2013-11-04 19:36:23 +04:00
|
|
|
checkAccountExists(true); // start settings if config is existing.
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotSyncStateChange( const QString& alias )
|
|
|
|
{
|
|
|
|
FolderMan *folderMan = FolderMan::instance();
|
|
|
|
const SyncResult& result = folderMan->syncResult( alias );
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
slotComputeOverallSyncStatus();
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
qDebug() << "Sync state changed for folder " << alias << ": " << result.statusString();
|
|
|
|
|
2013-10-08 16:12:05 +04:00
|
|
|
// Promote sync result to settings-dialog for sync protocol?
|
|
|
|
// if( _progressDialog ) {
|
|
|
|
// _progressDialog->setSyncResult(result);
|
|
|
|
// }
|
2013-10-02 17:28:33 +04:00
|
|
|
if (result.status() == SyncResult::Success || result.status() == SyncResult::Error) {
|
|
|
|
Logger::instance()->enterNextLogFile();
|
|
|
|
}
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotFoldersChanged()
|
|
|
|
{
|
2013-10-02 17:28:33 +04:00
|
|
|
slotComputeOverallSyncStatus();
|
2013-10-01 15:52:07 +04:00
|
|
|
setupContextMenu();
|
|
|
|
}
|
|
|
|
|
2013-10-02 20:16:24 +04:00
|
|
|
void ownCloudGui::slotOpenPath(const QString &path)
|
|
|
|
{
|
|
|
|
Utility::showInFileManager(path);
|
|
|
|
}
|
|
|
|
|
2013-10-01 20:25:30 +04:00
|
|
|
void ownCloudGui::startupConnected( bool connected, const QStringList& fails )
|
2013-10-01 15:52:07 +04:00
|
|
|
{
|
|
|
|
FolderMan *folderMan = FolderMan::instance();
|
|
|
|
|
2013-10-01 20:25:30 +04:00
|
|
|
if( connected ) {
|
|
|
|
qDebug() << "######## connected to ownCloud Server!";
|
|
|
|
folderMan->setSyncEnabled(true);
|
|
|
|
_tray->setIcon( Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true ) );
|
|
|
|
_tray->show();
|
|
|
|
} else {
|
|
|
|
int cnt = folderMan->map().size();
|
|
|
|
slotShowOptionalTrayMessage(tr("%1 Sync Started").arg(Theme::instance()->appNameGUI()),
|
|
|
|
tr("Sync started for %n configured sync folder(s).","", cnt));
|
|
|
|
}
|
2013-10-01 15:52:07 +04:00
|
|
|
|
2013-10-01 20:25:30 +04:00
|
|
|
_startupFails = fails; // store that for the settings dialog once it appears.
|
2013-10-01 15:52:07 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
void ownCloudGui::slotComputeOverallSyncStatus()
|
2013-10-01 15:52:07 +04:00
|
|
|
{
|
|
|
|
// display the info of the least successful sync (eg. not just display the result of the latest sync
|
|
|
|
QString trayMessage;
|
|
|
|
FolderMan *folderMan = FolderMan::instance();
|
|
|
|
Folder::Map map = folderMan->map();
|
|
|
|
SyncResult overallResult = FolderMan::accountStatus(map.values());
|
|
|
|
|
|
|
|
// if there have been startup problems, show an error message.
|
2013-10-01 20:25:30 +04:00
|
|
|
if( !_settingsDialog.isNull() )
|
|
|
|
_settingsDialog->setGeneralErrors( _startupFails );
|
|
|
|
|
|
|
|
if( !_startupFails.isEmpty() ) {
|
|
|
|
trayMessage = _startupFails.join(QLatin1String("\n"));
|
2013-10-15 19:00:53 +04:00
|
|
|
QIcon statusIcon;
|
|
|
|
if (_app->_startupNetworkError) {
|
|
|
|
statusIcon = Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true );
|
|
|
|
} else {
|
|
|
|
statusIcon = Theme::instance()->syncStateIcon( SyncResult::Error, true );
|
|
|
|
}
|
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
_tray->setIcon( statusIcon );
|
|
|
|
_tray->setToolTip(trayMessage);
|
|
|
|
} else {
|
|
|
|
// create the tray blob message, check if we have an defined state
|
|
|
|
if( overallResult.status() != SyncResult::Undefined ) {
|
|
|
|
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());
|
|
|
|
allStatusStrings += tr("Folder %1: %2").arg(folder->alias(), folderMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ! allStatusStrings.isEmpty() )
|
|
|
|
trayMessage = allStatusStrings.join(QLatin1String("\n"));
|
|
|
|
else
|
|
|
|
trayMessage = tr("No sync folders configured.");
|
|
|
|
|
|
|
|
QIcon statusIcon = Theme::instance()->syncStateIcon( overallResult.status(), true);
|
|
|
|
_tray->setIcon( statusIcon );
|
|
|
|
_tray->setToolTip(trayMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::setupContextMenu()
|
|
|
|
{
|
|
|
|
FolderMan *folderMan = FolderMan::instance();
|
|
|
|
|
2013-10-23 16:48:44 +04:00
|
|
|
bool isConfigured = (AccountManager::instance()->account() != 0);
|
2013-10-01 15:52:07 +04:00
|
|
|
_actionOpenoC->setEnabled(isConfigured);
|
|
|
|
|
|
|
|
if( _contextMenu ) {
|
|
|
|
_contextMenu->clear();
|
|
|
|
_recentActionsMenu->clear();
|
|
|
|
_recentActionsMenu->addAction(tr("None."));
|
|
|
|
_recentActionsMenu->addAction(_actionRecent);
|
|
|
|
} else {
|
|
|
|
_contextMenu = new QMenu();
|
|
|
|
_recentActionsMenu = _contextMenu->addMenu(tr("Recent Changes"));
|
|
|
|
// this must be called only once after creating the context menu, or
|
|
|
|
// it will trigger a bug in Ubuntu's SNI bridge patch (11.10, 12.04).
|
|
|
|
_tray->setContextMenu(_contextMenu);
|
|
|
|
}
|
|
|
|
_contextMenu->setTitle(Theme::instance()->appNameGUI() );
|
|
|
|
_contextMenu->addAction(_actionOpenoC);
|
|
|
|
|
|
|
|
int folderCnt = folderMan->map().size();
|
|
|
|
// add open actions for all sync folders to the tray menu
|
|
|
|
if( Theme::instance()->singleSyncFolder() ) {
|
|
|
|
// there should be exactly one folder. No sync-folder add action will be shown.
|
|
|
|
QStringList li = folderMan->map().keys();
|
|
|
|
if( li.size() == 1 ) {
|
|
|
|
Folder *folder = folderMan->map().value(li.first());
|
|
|
|
if( folder ) {
|
|
|
|
// if there is singleFolder mode, a generic open action is displayed.
|
|
|
|
QAction *action = new QAction( tr("Open %1 folder").arg(Theme::instance()->appNameGUI()), this);
|
|
|
|
connect( action, SIGNAL(triggered()),_folderOpenActionMapper,SLOT(map()));
|
|
|
|
_folderOpenActionMapper->setMapping( action, folder->alias() );
|
|
|
|
|
|
|
|
_contextMenu->addAction(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// show a grouping with more than one folder.
|
|
|
|
if ( folderCnt > 1) {
|
|
|
|
_contextMenu->addAction(tr("Managed Folders:"))->setDisabled(true);
|
|
|
|
}
|
|
|
|
foreach (Folder *folder, folderMan->map() ) {
|
|
|
|
QAction *action = new QAction( tr("Open folder '%1'").arg(folder->alias()), this );
|
|
|
|
connect( action, SIGNAL(triggered()),_folderOpenActionMapper,SLOT(map()));
|
|
|
|
_folderOpenActionMapper->setMapping( action, folder->alias() );
|
|
|
|
|
|
|
|
_contextMenu->addAction(action);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_contextMenu->addSeparator();
|
|
|
|
_contextMenu->addAction(_actionQuota);
|
|
|
|
_contextMenu->addSeparator();
|
|
|
|
_contextMenu->addAction(_actionStatus);
|
|
|
|
_contextMenu->addMenu(_recentActionsMenu);
|
|
|
|
_contextMenu->addSeparator();
|
|
|
|
_contextMenu->addAction(_actionSettings);
|
|
|
|
if (!Theme::instance()->helpUrl().isEmpty()) {
|
|
|
|
_contextMenu->addAction(_actionHelp);
|
|
|
|
}
|
|
|
|
_contextMenu->addSeparator();
|
|
|
|
|
|
|
|
_contextMenu->addAction(_actionQuit);
|
2013-11-14 18:38:08 +04:00
|
|
|
|
|
|
|
// Populate once at start
|
|
|
|
slotRebuildRecentMenus();
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ownCloudGui::slotShowTrayMessage(const QString &title, const QString &msg)
|
|
|
|
{
|
|
|
|
if( _tray )
|
|
|
|
_tray->showMessage(title, msg);
|
|
|
|
else
|
|
|
|
qDebug() << "Tray not ready: " << msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotShowOptionalTrayMessage(const QString &title, const QString &msg)
|
|
|
|
{
|
|
|
|
MirallConfigFile cfg;
|
|
|
|
if (cfg.optionalDesktopNotifications())
|
|
|
|
slotShowTrayMessage(title, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* open the folder with the given Alais
|
|
|
|
*/
|
|
|
|
void ownCloudGui::slotFolderOpenAction( const QString& alias )
|
|
|
|
{
|
|
|
|
Folder *f = FolderMan::instance()->folder(alias);
|
|
|
|
qDebug() << "opening local url " << f->path();
|
|
|
|
if( f ) {
|
|
|
|
QUrl url(f->path(), QUrl::TolerantMode);
|
|
|
|
url.setScheme( QLatin1String("file") );
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// work around a bug in QDesktopServices on Win32, see i-net
|
|
|
|
QString filePath = f->path();
|
|
|
|
|
|
|
|
if (filePath.startsWith(QLatin1String("\\\\")) || filePath.startsWith(QLatin1String("//")))
|
|
|
|
url.setUrl(QDir::toNativeSeparators(filePath));
|
|
|
|
else
|
|
|
|
url = QUrl::fromLocalFile(filePath);
|
|
|
|
#endif
|
|
|
|
QDesktopServices::openUrl(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::setupActions()
|
|
|
|
{
|
|
|
|
_actionOpenoC = new QAction(tr("Open %1 in browser").arg(Theme::instance()->appNameGUI()), this);
|
|
|
|
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);
|
|
|
|
_actionRecent = new QAction(tr("Details..."), this);
|
|
|
|
_actionRecent->setEnabled( true );
|
|
|
|
|
2013-10-08 16:12:05 +04:00
|
|
|
QObject::connect(_actionRecent, SIGNAL(triggered(bool)), SLOT(slotShowSyncProtocol()));
|
2013-10-01 15:52:07 +04:00
|
|
|
QObject::connect(_actionSettings, SIGNAL(triggered(bool)), SLOT(slotSettings()));
|
|
|
|
_actionHelp = new QAction(tr("Help"), this);
|
|
|
|
QObject::connect(_actionHelp, SIGNAL(triggered(bool)), SLOT(slotHelp()));
|
|
|
|
_actionQuit = new QAction(tr("Quit %1").arg(Theme::instance()->appNameGUI()), this);
|
|
|
|
QObject::connect(_actionQuit, SIGNAL(triggered(bool)), _app, SLOT(quit()));
|
|
|
|
|
2013-11-05 21:15:47 +04:00
|
|
|
_quotaInfo = new QuotaInfo(this);
|
|
|
|
connect(_quotaInfo, SIGNAL(quotaUpdated(qint64,qint64)), SLOT(slotRefreshQuotaDisplay(qint64,qint64)));
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotRefreshQuotaDisplay( qint64 total, qint64 used )
|
|
|
|
{
|
|
|
|
if (total == 0) {
|
|
|
|
_actionQuota->setText(tr("Quota n/a"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
double percent = used/(double)total*100;
|
|
|
|
QString percentFormatted = Utility::compactFormatDouble(percent, 1);
|
|
|
|
QString totalFormatted = Utility::octetsToString(total);
|
|
|
|
_actionQuota->setText(tr("%1% of %2 in use").arg(percentFormatted).arg(totalFormatted));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotProgressSyncProblem(const QString& folder, const Progress::SyncProblem& problem)
|
|
|
|
{
|
|
|
|
Q_UNUSED(folder);
|
|
|
|
Q_UNUSED(problem);
|
|
|
|
|
|
|
|
// display a warn icon if warnings happend.
|
|
|
|
QIcon warnIcon(":/mirall/resources/warning-16");
|
|
|
|
_actionRecent->setIcon(warnIcon);
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
slotRebuildRecentMenus();
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
void ownCloudGui::slotRebuildRecentMenus()
|
2013-10-01 15:52:07 +04:00
|
|
|
{
|
|
|
|
_recentActionsMenu->clear();
|
|
|
|
const QList<Progress::Info>& progressInfoList = ProgressDispatcher::instance()->recentChangedItems(5);
|
|
|
|
|
|
|
|
if( progressInfoList.size() == 0 ) {
|
2013-10-02 20:16:24 +04:00
|
|
|
_recentActionsMenu->addAction(tr("No items synced recently"))->setEnabled(false);
|
2013-10-01 15:52:07 +04:00
|
|
|
} else {
|
|
|
|
QListIterator<Progress::Info> i(progressInfoList);
|
|
|
|
|
|
|
|
while(i.hasNext()) {
|
|
|
|
Progress::Info info = i.next();
|
|
|
|
QString kindStr = Progress::asResultString(info.kind);
|
|
|
|
QString timeStr = info.timestamp.toString("hh:mm");
|
|
|
|
|
|
|
|
QString actionText = tr("%1 (%2, %3)").arg(info.current_file).arg(kindStr).arg(timeStr);
|
2013-10-02 20:16:24 +04:00
|
|
|
QAction *action = _recentActionsMenu->addAction( actionText );
|
|
|
|
|
|
|
|
Folder *folder = FolderMan::instance()->folder(info.folder);
|
|
|
|
if (folder) {
|
|
|
|
QString fullPath = folder->path() + '/' + info.current_file;
|
|
|
|
if (QFile(fullPath).exists()) {
|
|
|
|
_recentItemsMapper->setMapping(action, fullPath);
|
|
|
|
connect(action, SIGNAL(triggered()), _recentItemsMapper, SLOT(map()));
|
|
|
|
} else {
|
|
|
|
action->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// add a more... entry.
|
2013-10-02 20:16:24 +04:00
|
|
|
_recentActionsMenu->addSeparator();
|
2013-10-01 15:52:07 +04:00
|
|
|
_recentActionsMenu->addAction(_actionRecent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info& progress)
|
|
|
|
{
|
|
|
|
Q_UNUSED(folder);
|
|
|
|
|
|
|
|
// shows an entry in the context menu.
|
|
|
|
QString curAmount = Utility::octetsToString(progress.overall_current_bytes);
|
|
|
|
QString totalAmount = Utility::octetsToString(progress.overall_transmission_size);
|
|
|
|
_actionStatus->setText(tr("Syncing %1 of %2 (%3 of %4) ").arg(progress.current_file_no)
|
|
|
|
.arg(progress.overall_file_count).arg(curAmount, totalAmount));
|
|
|
|
|
|
|
|
// wipe the problem list at start of sync.
|
|
|
|
if( progress.kind == Progress::StartSync ) {
|
|
|
|
_actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there was a change in the file list, redo the progress menu.
|
|
|
|
if( progress.kind == Progress::EndDownload || progress.kind == Progress::EndUpload ||
|
2013-11-11 13:06:14 +04:00
|
|
|
progress.kind == Progress::EndDelete || progress.kind == Progress::EndRename ) {
|
2013-10-02 17:28:33 +04:00
|
|
|
slotRebuildRecentMenus();
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (progress.kind == Progress::EndSync) {
|
2013-10-02 17:28:33 +04:00
|
|
|
slotRebuildRecentMenus(); // show errors.
|
2013-10-01 15:52:07 +04:00
|
|
|
QTimer::singleShot(2000, this, SLOT(slotDisplayIdle()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotDisplayIdle()
|
|
|
|
{
|
|
|
|
_actionStatus->setText(tr("Up to date"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &message)
|
|
|
|
{
|
|
|
|
QMessageBox *msgBox = new QMessageBox;
|
|
|
|
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
msgBox->setText(message);
|
|
|
|
msgBox->setWindowTitle(title);
|
|
|
|
msgBox->setIcon(QMessageBox::Information);
|
|
|
|
msgBox->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotSettings()
|
|
|
|
{
|
|
|
|
if (_settingsDialog.isNull()) {
|
|
|
|
_settingsDialog = new SettingsDialog(this);
|
|
|
|
_settingsDialog->setAttribute( Qt::WA_DeleteOnClose, true );
|
|
|
|
_settingsDialog->show();
|
|
|
|
}
|
|
|
|
|
2013-10-01 20:25:30 +04:00
|
|
|
_settingsDialog->setGeneralErrors( _startupFails );
|
2013-10-01 15:52:07 +04:00
|
|
|
Utility::raiseDialog(_settingsDialog.data());
|
|
|
|
}
|
|
|
|
|
2013-10-08 16:12:05 +04:00
|
|
|
// open sync protocol widget
|
|
|
|
void ownCloudGui::slotShowSyncProtocol()
|
2013-10-01 15:52:07 +04:00
|
|
|
{
|
2013-10-08 16:12:05 +04:00
|
|
|
slotSettings(); // FIXME: Show the protocol tab.
|
|
|
|
_settingsDialog->slotShowProtocol();
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
void ownCloudGui::slotShutdown()
|
2013-10-01 15:52:07 +04:00
|
|
|
{
|
|
|
|
// those do delete on close
|
|
|
|
if (!_settingsDialog.isNull()) _settingsDialog->close();
|
2013-10-02 17:28:33 +04:00
|
|
|
if (!_logBrowser.isNull()) _logBrowser->deleteLater();
|
2013-10-01 15:52:07 +04:00
|
|
|
}
|
|
|
|
|
2013-10-02 17:28:33 +04:00
|
|
|
void ownCloudGui::slotToggleLogBrowser()
|
|
|
|
{
|
|
|
|
if (_logBrowser.isNull()) {
|
|
|
|
// init the log browser.
|
|
|
|
_logBrowser = new LogBrowser;
|
|
|
|
// ## TODO: allow new log name maybe?
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_logBrowser->isVisible() ) {
|
|
|
|
_logBrowser->hide();
|
|
|
|
} else {
|
|
|
|
Utility::raiseDialog(_logBrowser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotOpenOwnCloud()
|
|
|
|
{
|
2013-10-30 19:31:47 +04:00
|
|
|
if (Account *account = AccountManager::instance()->account()) {
|
2013-11-04 19:36:23 +04:00
|
|
|
QDesktopServices::openUrl(account->url());
|
2013-10-30 19:31:47 +04:00
|
|
|
}
|
2013-10-02 17:28:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ownCloudGui::slotHelp()
|
|
|
|
{
|
|
|
|
QDesktopServices::openUrl(QUrl(Theme::instance()->helpUrl()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-01 15:52:07 +04:00
|
|
|
} // end namespace
|