mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
- Added info dialog with file listing
- Added overall status display on the tray icon plus tooltip -> patches from Alvaro Soliverez
This commit is contained in:
parent
128223553c
commit
ad0be9f6ee
8 changed files with 171 additions and 68 deletions
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QHash>
|
||||
#include <QHashIterator>
|
||||
|
||||
#include "mirall/constants.h"
|
||||
#include "mirall/application.h"
|
||||
|
@ -52,16 +54,14 @@ Application::Application(int argc, char **argv) :
|
|||
|
||||
connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
|
||||
SLOT(slotRemoveFolder(const QString&)));
|
||||
|
||||
connect( _statusDialog, SIGNAL(fetchFolderAlias(const QString&)),
|
||||
SLOT(slotFetchFolder( const QString&)));
|
||||
|
||||
connect( _statusDialog, SIGNAL(pushFolderAlias(const QString&)),
|
||||
SLOT(slotPushFolder( const QString&)));
|
||||
|
||||
connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
|
||||
SLOT(slotEnableFolder(QString,bool)));
|
||||
|
||||
connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
|
||||
SLOT(slotInfoFolder( const QString&)));
|
||||
|
||||
setupActions();
|
||||
setupSystemTray();
|
||||
|
@ -321,6 +321,62 @@ void Application::slotPushFolder( const QString& alias )
|
|||
|
||||
}
|
||||
|
||||
void Application::slotInfoFolder( const QString& alias )
|
||||
{
|
||||
qDebug() << "details of folder with alias " << alias;
|
||||
|
||||
if( ! _folderMap.contains( alias ) ) {
|
||||
qDebug() << "!! Can not get details of alias " << alias << ", can not be found in folderMap.";
|
||||
return;
|
||||
}
|
||||
|
||||
Folder *folder = _folderMap[alias];
|
||||
|
||||
QString folderMessage = tr( "Last sync was succesful" );
|
||||
SyncResult folderResult = folder->lastSyncResult();
|
||||
SyncResult::Result syncResult = folderResult.result();
|
||||
if ( syncResult == SyncResult::Error ) {
|
||||
folderMessage = tr( "%1" ).arg( folderResult.errorString() );
|
||||
} else if ( syncResult == SyncResult::SetupError ) {
|
||||
folderMessage = tr( "Setup error" );
|
||||
} else if ( syncResult == SyncResult::Disabled ) {
|
||||
folderMessage = tr( "%1" ).arg( folderResult.errorString() );
|
||||
} else if ( syncResult == SyncResult::Undefined ) {
|
||||
folderMessage = tr( "Undefined state" );
|
||||
}
|
||||
|
||||
QMessageBox infoBox( QMessageBox::Information, tr( "Folder information" ), folder->alias(), QMessageBox::Ok );
|
||||
|
||||
infoBox.setInformativeText(folderMessage);
|
||||
qDebug() << "informative text: " << infoBox.informativeText();
|
||||
|
||||
if ( !folderResult.syncChanges().isEmpty() ) {
|
||||
QString details;
|
||||
QHash < QString, QStringList > changes = folderResult.syncChanges();
|
||||
QHash< QString, QStringList >::const_iterator change_it = changes.constBegin();
|
||||
for(; change_it != changes.constEnd(); ++change_it ) {
|
||||
QString changeType = tr( "Unknown" );
|
||||
if ( change_it.key() == "changed" ) {
|
||||
changeType = tr( "Changed files:\n" );
|
||||
} else if ( change_it.key() == "added" ) {
|
||||
changeType = tr( "Added files:\n" );
|
||||
} else if ( change_it.key() == "deleted" ) {
|
||||
changeType = tr( "New files in the server, or files deleted locally:\n");
|
||||
}
|
||||
|
||||
QStringList files = change_it.value();
|
||||
QString fileList;
|
||||
foreach( QString file, files) {
|
||||
fileList += file + "\n";
|
||||
}
|
||||
details += changeType + fileList;
|
||||
}
|
||||
infoBox.setDetailedText(details);
|
||||
qDebug() << "detailed text: " << infoBox.detailedText();
|
||||
}
|
||||
infoBox.exec();
|
||||
}
|
||||
|
||||
void Application::slotEnableFolder(const QString& alias, const bool enable)
|
||||
{
|
||||
qDebug() << "enable folder with alias " << alias;
|
||||
|
@ -437,69 +493,75 @@ void Application::slotFolderSyncStarted()
|
|||
|
||||
void Application::slotFolderSyncFinished(const SyncResult &result)
|
||||
{
|
||||
_folderSyncCount--;
|
||||
_folderSyncCount--;
|
||||
|
||||
Folder *folder = dynamic_cast<Folder *>(sender());
|
||||
// in case the sending folder is needed:
|
||||
// Folder *folder = dynamic_cast<Folder *>(sender());
|
||||
|
||||
if (_folderSyncCount < 1) {
|
||||
if (result.result() != SyncResult::Success) {
|
||||
_tray->setIcon(QIcon::fromTheme(FOLDER_SYNC_ERROR, QIcon( QString( ":/mirall/resources/%1").arg(FOLDER_SYNC_ERROR))));
|
||||
_tray->setToolTip(tr("Folder %1: %2").arg(folder->alias(), result.errorString()));
|
||||
} else {
|
||||
// if succesful, display the info of the least succesful sync (eg. not just display the result of the latest sync
|
||||
SyncResult overallResult = SyncResult::Success;
|
||||
QString trayMessage;
|
||||
foreach ( Folder *syncedFolder, _folderMap ) {
|
||||
QString folderMessage;
|
||||
if ( syncedFolder->lastSyncResult().result() == SyncResult::Error ) {
|
||||
overallResult = SyncResult::Error;
|
||||
folderMessage = tr( "There was an error syncing folder %1" ).arg( syncedFolder->alias() );
|
||||
} else if ( syncedFolder->lastSyncResult().result() == SyncResult::SetupError ) {
|
||||
if ( overallResult.result() != SyncResult::Error ) {
|
||||
overallResult = SyncResult::SetupError;
|
||||
}
|
||||
folderMessage = tr( "Folder %1 has a configuration error" ).arg( syncedFolder->alias() );
|
||||
} else if ( syncedFolder->lastSyncResult().result() == SyncResult::Disabled ) {
|
||||
if ( overallResult.result() != SyncResult::SetupError
|
||||
&& overallResult.result() != SyncResult::Error ) {
|
||||
overallResult = SyncResult::Disabled;
|
||||
}
|
||||
folderMessage = tr( "Folder %1 has been disabled" ).arg( syncedFolder->alias() );
|
||||
} else if ( syncedFolder->lastSyncResult().result() == SyncResult::Undefined ) {
|
||||
if ( overallResult.result() == SyncResult::Success ) {
|
||||
overallResult = SyncResult::Undefined;
|
||||
}
|
||||
folderMessage = tr( "Folder %1 is in an undefined state" ).arg( syncedFolder->alias() );
|
||||
}
|
||||
if ( !trayMessage.isEmpty() ) {
|
||||
trayMessage += "\n";
|
||||
}
|
||||
trayMessage += folderMessage;
|
||||
}
|
||||
if( _folderSyncCount == 0 ) {
|
||||
computeOverallSyncStatus();
|
||||
}
|
||||
}
|
||||
|
||||
QString statusIcon = MIRALL_ICON;
|
||||
qDebug() << "overall result is " << overallResult.result();
|
||||
if( overallResult.result() == SyncResult::Error ) {
|
||||
statusIcon = "dialog-close";
|
||||
} else if( overallResult.result() == SyncResult::Success ) {
|
||||
statusIcon = MIRALL_ICON;
|
||||
} else if( overallResult.result() == SyncResult::Disabled ) {
|
||||
statusIcon = "dialog-cancel";
|
||||
} else if( overallResult.result() == SyncResult::SetupError ) {
|
||||
statusIcon = "dialog-cancel";
|
||||
} else if( overallResult.result() == SyncResult::Undefined ) {
|
||||
statusIcon = "view-refresh";
|
||||
}
|
||||
void Application::computeOverallSyncStatus()
|
||||
{
|
||||
|
||||
_tray->setIcon(QIcon::fromTheme(statusIcon, QIcon( QString( ":/mirall/resources/%1").arg(statusIcon))));
|
||||
_tray->setToolTip(trayMessage);
|
||||
}
|
||||
// display the info of the least succesful sync (eg. not just display the result of the latest sync
|
||||
SyncResult overallResult = SyncResult::Success;
|
||||
QString trayMessage;
|
||||
foreach ( Folder *syncedFolder, _folderMap ) {
|
||||
QString folderMessage;
|
||||
SyncResult folderResult = syncedFolder->lastSyncResult();
|
||||
SyncResult::Result syncResult = folderResult.result();
|
||||
if ( syncResult == SyncResult::Success ) {
|
||||
folderMessage = tr( "Folder %1: Ok." ).arg( syncedFolder->alias() );
|
||||
} else if ( syncResult == SyncResult::Error ) {
|
||||
overallResult = SyncResult::Error;
|
||||
folderMessage = tr( "Folder %1: %2" ).arg( syncedFolder->alias(), folderResult.errorString() );
|
||||
} else if ( syncResult == SyncResult::SetupError ) {
|
||||
if ( overallResult.result() != SyncResult::Error ) {
|
||||
overallResult = SyncResult::SetupError;
|
||||
}
|
||||
folderMessage = tr( "Folder %1: setup error" ).arg( syncedFolder->alias() );
|
||||
} else if ( syncResult == SyncResult::Disabled ) {
|
||||
if ( overallResult.result() != SyncResult::SetupError
|
||||
&& overallResult.result() != SyncResult::Error ) {
|
||||
overallResult = SyncResult::Disabled;
|
||||
}
|
||||
folderMessage = tr( "Folder %1: %2" ).arg( syncedFolder->alias(), folderResult.errorString() );
|
||||
} else if ( syncResult == SyncResult::Undefined ) {
|
||||
if ( overallResult.result() == SyncResult::Success ) {
|
||||
overallResult = SyncResult::Undefined;
|
||||
}
|
||||
folderMessage = tr( "Folder %1: undefined state" ).arg( syncedFolder->alias() );
|
||||
}
|
||||
|
||||
// Only refresh the folder if it is being shown
|
||||
if( _statusDialog->isVisible() ) {
|
||||
_statusDialog->setFolderList( _folderMap );
|
||||
if ( !trayMessage.isEmpty() ) {
|
||||
trayMessage += "\n";
|
||||
}
|
||||
trayMessage += folderMessage;
|
||||
}
|
||||
|
||||
QString statusIcon = MIRALL_ICON;
|
||||
qDebug() << "overall result is " << overallResult.result();
|
||||
if( overallResult.result() == SyncResult::Error ) {
|
||||
statusIcon = "dialog-close";
|
||||
} else if( overallResult.result() == SyncResult::Success ) {
|
||||
statusIcon = MIRALL_ICON;
|
||||
} else if( overallResult.result() == SyncResult::Disabled ) {
|
||||
statusIcon = "dialog-cancel";
|
||||
} else if( overallResult.result() == SyncResult::SetupError ) {
|
||||
statusIcon = "dialog-cancel";
|
||||
} else if( overallResult.result() == SyncResult::Undefined ) {
|
||||
statusIcon = "view-refresh";
|
||||
}
|
||||
|
||||
_tray->setIcon(QIcon::fromTheme(statusIcon, QIcon( QString( ":/mirall/resources/%1").arg(statusIcon))));
|
||||
_tray->setToolTip(trayMessage);
|
||||
|
||||
// Only refresh the folder if it is being shown
|
||||
if( _statusDialog->isVisible() ) {
|
||||
_statusDialog->setFolderList( _folderMap );
|
||||
}
|
||||
}
|
||||
|
||||
void Application::disableFoldersWithRestore()
|
||||
|
|
|
@ -49,6 +49,7 @@ protected slots:
|
|||
void slotFetchFolder( const QString& );
|
||||
void slotPushFolder( const QString& );
|
||||
void slotEnableFolder( const QString&, const bool );
|
||||
void slotInfoFolder( const QString& );
|
||||
void slotConfigure();
|
||||
|
||||
void slotFolderSyncStarted();
|
||||
|
@ -73,6 +74,7 @@ protected:
|
|||
//folders have to be disabled while making config changes
|
||||
void disableFoldersWithRestore();
|
||||
void restoreEnabledFolders();
|
||||
void computeOverallSyncStatus();
|
||||
|
||||
protected slots:
|
||||
void slotTrayClicked( QSystemTrayIcon::ActivationReason );
|
||||
|
|
|
@ -157,7 +157,6 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if( _NextStep == Sync ) {
|
||||
startSiteCopy( "--sync", Finish ); // sync local with cloud data.
|
||||
} else if( _NextStep == Update ) {
|
||||
|
@ -171,7 +170,7 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
} else if( _NextStep == FlatList ) {
|
||||
startSiteCopy( "--flatlist", ExecuteStatus );
|
||||
} else if( _NextStep == ExecuteStatus ) {
|
||||
if( exitCode == 1 ) {
|
||||
if( exitCode == 1 ) {
|
||||
qDebug() << "Exit-Code: Sync Needed!";
|
||||
analyzeStatus();
|
||||
if( _ChangesHash.contains("deleted") && _pathListEmpty ) {
|
||||
|
@ -180,6 +179,7 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
qDebug() << "!!!! Better not call update, changes happened on the cloud!";
|
||||
SyncResult res( SyncResult::Disabled );
|
||||
res.setErrorString( tr("The ownCloud changed. Disabling syncing for security reasons."));
|
||||
res.setSyncChanges( _ChangesHash );
|
||||
setSyncEnabled( false );
|
||||
emit syncFinished( res );
|
||||
} else {
|
||||
|
@ -187,8 +187,11 @@ void SiteCopyFolder::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||
}
|
||||
} else if( exitCode == 0 ) {
|
||||
qDebug() << "No update needed, remote is in sync.";
|
||||
SyncResult res( SyncResult::Success );
|
||||
// store the analyze results into the sync result data structure.
|
||||
res.setSyncChanges( _ChangesHash );
|
||||
// No update needed
|
||||
emit syncFinished( SyncResult( SyncResult::Success ) );
|
||||
emit syncFinished( res );
|
||||
} else {
|
||||
qDebug() << "Got an unknown exit code " << exitCode;
|
||||
emit syncFinished( SyncResult( SyncResult::Error ) );
|
||||
|
|
|
@ -128,12 +128,14 @@ StatusDialog::StatusDialog(QWidget *parent) :
|
|||
connect(_ButtonPush, SIGNAL(clicked()), this, SLOT(slotPushFolder()));
|
||||
connect(_ButtonOpenOC, SIGNAL(clicked()), this, SLOT(slotOpenOC()));
|
||||
connect(_ButtonEnable, SIGNAL(clicked()), this, SLOT(slotEnableFolder()));
|
||||
connect(_ButtonInfo, SIGNAL(clicked()), this, SLOT(slotInfoFolder()));
|
||||
|
||||
_ButtonOpenOC->setEnabled(false);
|
||||
_ButtonRemove->setEnabled(false);
|
||||
_ButtonFetch->setEnabled(false);
|
||||
_ButtonPush->setEnabled(false);
|
||||
_ButtonEnable->setEnabled(false);
|
||||
_ButtonInfo->setEnabled(false);
|
||||
|
||||
connect(_folderList, SIGNAL(activated(QModelIndex)), SLOT(slotFolderActivated(QModelIndex)));
|
||||
}
|
||||
|
@ -146,6 +148,7 @@ void StatusDialog::slotFolderActivated( const QModelIndex& indx )
|
|||
_ButtonFetch->setEnabled( state );
|
||||
_ButtonPush->setEnabled( state );
|
||||
_ButtonEnable->setEnabled( state );
|
||||
_ButtonInfo->setEnabled( state );
|
||||
|
||||
if ( state ) {
|
||||
bool folderEnabled = _model->data( indx, FolderViewDelegate::FolderSyncEnabled).toBool();
|
||||
|
@ -246,6 +249,18 @@ void StatusDialog::slotEnableFolder()
|
|||
}
|
||||
}
|
||||
|
||||
void StatusDialog::slotInfoFolder()
|
||||
{
|
||||
QModelIndex selected = _folderList->selectionModel()->currentIndex();
|
||||
if( selected.isValid() ) {
|
||||
QString alias = _model->data( selected, FolderViewDelegate::FolderNameRole ).toString();
|
||||
qDebug() << "Info Folder alias " << alias;
|
||||
if( !alias.isEmpty() ) {
|
||||
emit(infoFolderAlias( alias ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatusDialog::setOCUrl( const QUrl& url )
|
||||
{
|
||||
_OCUrl = url;
|
||||
|
|
|
@ -57,6 +57,7 @@ signals:
|
|||
void fetchFolderAlias( const QString& );
|
||||
void pushFolderAlias( const QString& );
|
||||
void enableFolderAlias( const QString&, const bool );
|
||||
void infoFolderAlias( const QString& );
|
||||
|
||||
public slots:
|
||||
void slotRemoveFolder();
|
||||
|
@ -65,6 +66,7 @@ public slots:
|
|||
void slotFolderActivated( const QModelIndex& );
|
||||
void slotOpenOC();
|
||||
void slotEnableFolder();
|
||||
void slotInfoFolder();
|
||||
|
||||
private:
|
||||
QStandardItemModel *_model;
|
||||
|
|
|
@ -65,6 +65,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="_ButtonInfo">
|
||||
<property name="text">
|
||||
<string>info...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -20,13 +20,11 @@ namespace Mirall
|
|||
SyncResult::SyncResult()
|
||||
: _result( Undefined )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SyncResult::SyncResult(SyncResult::Result result)
|
||||
: _result(result)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SyncResult::Result SyncResult::result() const
|
||||
|
@ -36,14 +34,23 @@ SyncResult::Result SyncResult::result() const
|
|||
|
||||
void SyncResult::setErrorString( const QString& err )
|
||||
{
|
||||
_errorMsg = err;
|
||||
_errorMsg = err;
|
||||
}
|
||||
|
||||
QString SyncResult::errorString() const
|
||||
{
|
||||
return _errorMsg;
|
||||
return _errorMsg;
|
||||
}
|
||||
|
||||
void SyncResult::setSyncChanges(const QHash< QString, QStringList >& changes)
|
||||
{
|
||||
_syncChanges = changes;
|
||||
}
|
||||
|
||||
QHash< QString, QStringList > SyncResult::syncChanges() const
|
||||
{
|
||||
return _syncChanges;
|
||||
}
|
||||
|
||||
SyncResult::~SyncResult()
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define MIRALL_SYNCRESULT_H
|
||||
|
||||
#include <QStringList>
|
||||
#include <QHash>
|
||||
|
||||
namespace Mirall
|
||||
{
|
||||
|
@ -37,11 +38,15 @@ public:
|
|||
~SyncResult();
|
||||
void setErrorString( const QString& );
|
||||
QString errorString() const;
|
||||
void setSyncChanges( const QHash<QString, QStringList> &changes );
|
||||
QHash<QString, QStringList> syncChanges() const;
|
||||
|
||||
Result result() const;
|
||||
|
||||
private:
|
||||
Result _result;
|
||||
QHash<QString, QStringList> _syncChanges;
|
||||
|
||||
/**
|
||||
* when the sync tool support this...
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue