mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 23:17:13 +03:00
Improve account connectivity tooltips. #3200
* Show connection errors for all failing accounts in the tooltip. * Don't hide the 'service unavailable' state. We don't want intrusive pop ups, but we don't want to pretend we're syncing when we aren't. * Show sync-running icon also for SyncPrepare state. In my tests I very rarely saw the sync-running icon before.
This commit is contained in:
parent
2fa00168cf
commit
8aeb3cc8d2
7 changed files with 54 additions and 96 deletions
|
@ -91,19 +91,19 @@ QString AccountState::stateString(State state)
|
|||
switch (state)
|
||||
{
|
||||
case SignedOut:
|
||||
return QLatin1String("SignedOut");
|
||||
return tr("Signed out");
|
||||
case Disconnected:
|
||||
return QLatin1String("Disconnected");
|
||||
return tr("Disconnected");
|
||||
case Connected:
|
||||
return QLatin1String("Connected");
|
||||
return tr("Connected");
|
||||
case ServiceUnavailable:
|
||||
return QLatin1String("ServiceUnavailable");
|
||||
return tr("Service unavailable");
|
||||
case NetworkError:
|
||||
return QLatin1String("NetworkError");
|
||||
return tr("Network error");
|
||||
case ConfigurationError:
|
||||
return QLatin1String("ConfigurationError");
|
||||
return tr("Configuration error");
|
||||
}
|
||||
return QLatin1String("Unknown");
|
||||
return tr("Unknown account state");
|
||||
}
|
||||
|
||||
bool AccountState::isSignedOut() const
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
static QString connectionStatusString(ConnectionStatus status);
|
||||
|
||||
State state() const;
|
||||
static QString stateString(State status);
|
||||
static QString stateString(State state);
|
||||
|
||||
bool isSignedOut() const;
|
||||
void setSignedOut(bool signedOut);
|
||||
|
|
|
@ -89,7 +89,6 @@ Application::Application(int &argc, char **argv) :
|
|||
_gui(0),
|
||||
_theme(Theme::instance()),
|
||||
_helpOnly(false),
|
||||
_startupNetworkError(false),
|
||||
_showLogWindow(false),
|
||||
_logExpire(0),
|
||||
_logFlush(false),
|
||||
|
@ -218,8 +217,6 @@ void Application::slotLogout()
|
|||
|
||||
void Application::slotAccountStateRemoved(AccountState *accountState)
|
||||
{
|
||||
disconnect(accountState, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(slotAccountStateChanged(int)));
|
||||
if (_gui) {
|
||||
disconnect(accountState, SIGNAL(stateChanged(int)),
|
||||
_gui, SLOT(slotAccountStateChanged()));
|
||||
|
@ -232,8 +229,6 @@ void Application::slotAccountStateRemoved(AccountState *accountState)
|
|||
|
||||
void Application::slotAccountStateAdded(AccountState *accountState)
|
||||
{
|
||||
connect(accountState, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(slotAccountStateChanged(int)));
|
||||
connect(accountState, SIGNAL(stateChanged(int)),
|
||||
_gui, SLOT(slotAccountStateChanged()));
|
||||
connect(accountState, SIGNAL(stateChanged(int)),
|
||||
|
@ -259,7 +254,14 @@ void Application::slotCheckConnection()
|
|||
{
|
||||
auto list = AccountManager::instance()->accounts();
|
||||
foreach (const auto &accountState , list) {
|
||||
accountState->checkConnectivity();
|
||||
AccountState::State state = accountState->state();
|
||||
|
||||
// Don't check if we're manually signed out or
|
||||
// when the error is permanent.
|
||||
if (state != AccountState::SignedOut
|
||||
&& state != AccountState::ConfigurationError) {
|
||||
accountState->checkConnectivity();
|
||||
}
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
|
@ -270,43 +272,11 @@ void Application::slotCheckConnection()
|
|||
}
|
||||
}
|
||||
|
||||
void Application::slotAccountStateChanged(int state)
|
||||
{
|
||||
// THE FOLLOWING STILL NEEDS FIXING!
|
||||
|
||||
// Stop checking the connection if we're manually signed out or
|
||||
// when the error is permanent.
|
||||
if (state == AccountState::SignedOut
|
||||
|| state == AccountState::ConfigurationError) {
|
||||
_checkConnectionTimer.stop();
|
||||
} else if (! _checkConnectionTimer.isActive()) {
|
||||
_checkConnectionTimer.start();
|
||||
}
|
||||
|
||||
slotUpdateConnectionErrors(state);
|
||||
}
|
||||
|
||||
void Application::slotCrash()
|
||||
{
|
||||
Utility::crash();
|
||||
}
|
||||
|
||||
void Application::slotUpdateConnectionErrors(int accountState)
|
||||
{
|
||||
bool isConnected = accountState == AccountState::Connected;
|
||||
if( !isConnected ) {
|
||||
_startupNetworkError = accountState == AccountState::NetworkError;
|
||||
}
|
||||
|
||||
#warning FIXME: connection errors should be shown per account
|
||||
#if 0
|
||||
AccountState *as = AccountStateManager::instance()->accountState();
|
||||
if (as) {
|
||||
_gui->setConnectionErrors( isConnected, as->connectionErrors() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::slotownCloudWizardDone( int res )
|
||||
{
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
|
|
|
@ -78,7 +78,6 @@ signals:
|
|||
protected slots:
|
||||
void slotParseMessage(const QString&, QObject*);
|
||||
void slotCheckConnection();
|
||||
void slotUpdateConnectionErrors(int accountState);
|
||||
void slotStartUpdateDetector();
|
||||
void slotUseMonoIconsChanged( bool );
|
||||
void slotLogin();
|
||||
|
@ -86,7 +85,6 @@ protected slots:
|
|||
void slotCleanup();
|
||||
void slotAccountStateAdded(AccountState *accountState);
|
||||
void slotAccountStateRemoved(AccountState *accountState);
|
||||
void slotAccountStateChanged(int state);
|
||||
void slotCrash();
|
||||
|
||||
private:
|
||||
|
@ -97,7 +95,6 @@ private:
|
|||
Theme *_theme;
|
||||
|
||||
bool _helpOnly;
|
||||
bool _startupNetworkError;
|
||||
|
||||
// options from command line:
|
||||
bool _showLogWindow;
|
||||
|
@ -116,8 +113,6 @@ private:
|
|||
QScopedPointer<CrashReporter::Handler> _crashHandler;
|
||||
#endif
|
||||
QScopedPointer<FolderMan> _folderManager;
|
||||
|
||||
friend class ownCloudGui; // for _startupNetworkError
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -1010,9 +1010,9 @@ SyncResult FolderMan::accountStatus(const QList<Folder*> &folders)
|
|||
switch( syncStatus ) {
|
||||
case SyncResult::Undefined:
|
||||
case SyncResult::NotYetStarted:
|
||||
case SyncResult::SyncPrepare:
|
||||
various++;
|
||||
break;
|
||||
case SyncResult::SyncPrepare:
|
||||
case SyncResult::SyncRunning:
|
||||
runSeen++;
|
||||
break;
|
||||
|
|
|
@ -205,27 +205,36 @@ void ownCloudGui::slotAccountStateChanged()
|
|||
slotComputeOverallSyncStatus();
|
||||
}
|
||||
|
||||
void ownCloudGui::setConnectionErrors( bool /*connected*/, const QStringList& fails )
|
||||
{
|
||||
_startupFails = fails; // store that for the settings dialog once it appears.
|
||||
|
||||
slotComputeOverallSyncStatus();
|
||||
}
|
||||
|
||||
void ownCloudGui::slotComputeOverallSyncStatus()
|
||||
{
|
||||
bool allSignedOut = true;
|
||||
QVector<AccountStatePtr> problemAccounts;
|
||||
foreach (auto a, AccountManager::instance()->accounts()) {
|
||||
if (!a->isSignedOut()) {
|
||||
allSignedOut = false;
|
||||
}
|
||||
if (!a->isConnectedOrTemporarilyUnavailable()) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true));
|
||||
_tray->setToolTip(tr("Disconnected from server"));
|
||||
return;
|
||||
if (!a->isConnected()) {
|
||||
problemAccounts.append(a);
|
||||
}
|
||||
}
|
||||
|
||||
if (!problemAccounts.empty()) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true));
|
||||
QStringList messages;
|
||||
messages.append(tr("Disconnected from accounts:"));
|
||||
foreach (AccountStatePtr a, problemAccounts) {
|
||||
QString message = tr("Account %1: %2").arg(
|
||||
a->account()->displayName(), a->stateString(a->state()));
|
||||
if (! a->connectionErrors().empty()) {
|
||||
message += QLatin1String("\n");
|
||||
message += a->connectionErrors().join(QLatin1String("\n"));
|
||||
}
|
||||
messages.append(message);
|
||||
}
|
||||
_tray->setToolTip(messages.join(QLatin1String("\n\n")));
|
||||
return;
|
||||
}
|
||||
|
||||
if (allSignedOut) {
|
||||
_tray->setIcon(Theme::instance()->folderOfflineIcon(true));
|
||||
_tray->setToolTip(tr("Please sign in"));
|
||||
|
@ -238,42 +247,29 @@ void ownCloudGui::slotComputeOverallSyncStatus()
|
|||
Folder::Map map = folderMan->map();
|
||||
SyncResult overallResult = FolderMan::accountStatus(map.values());
|
||||
|
||||
if( !_startupFails.isEmpty() ) {
|
||||
trayMessage = _startupFails.join(QLatin1String("\n"));
|
||||
QIcon statusIcon;
|
||||
if (_app->_startupNetworkError) {
|
||||
statusIcon = Theme::instance()->syncStateIcon( SyncResult::NotYetStarted, true );
|
||||
// create the tray blob message, check if we have an defined state
|
||||
if( overallResult.status() != SyncResult::Undefined ) {
|
||||
QStringList allStatusStrings;
|
||||
if( map.count() > 0 ) {
|
||||
foreach(Folder* folder, map.values()) {
|
||||
qDebug() << "Folder in overallStatus Message: " << folder << " with name " << folder->alias();
|
||||
QString folderMessage = folderMan->statusToString(folder->syncResult().status(), folder->syncPaused());
|
||||
allStatusStrings += tr("Folder %1: %2").arg(folder->alias(), folderMessage);
|
||||
}
|
||||
|
||||
trayMessage = allStatusStrings.join(QLatin1String("\n"));
|
||||
} else {
|
||||
statusIcon = Theme::instance()->syncStateIcon( SyncResult::Error, true );
|
||||
trayMessage = tr("No sync folders configured.");
|
||||
}
|
||||
|
||||
QIcon statusIcon = Theme::instance()->syncStateIcon( overallResult.status(), true);
|
||||
_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;
|
||||
if( map.count() > 0 ) {
|
||||
foreach(Folder* folder, map.values()) {
|
||||
qDebug() << "Folder in overallStatus Message: " << folder << " with name " << folder->alias();
|
||||
QString folderMessage = folderMan->statusToString(folder->syncResult().status(), folder->syncPaused());
|
||||
allStatusStrings += tr("Folder %1: %2").arg(folder->alias(), folderMessage);
|
||||
}
|
||||
|
||||
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);
|
||||
} else {
|
||||
// undefined because there are no folders.
|
||||
QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Problem, true);
|
||||
_tray->setIcon( icon );
|
||||
_tray->setToolTip(tr("There are no sync folders configured."));
|
||||
}
|
||||
// undefined because there are no folders.
|
||||
QIcon icon = Theme::instance()->syncStateIcon(SyncResult::Problem, true);
|
||||
_tray->setIcon( icon );
|
||||
_tray->setToolTip(tr("There are no sync folders configured."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
explicit ownCloudGui(Application *parent = 0);
|
||||
|
||||
void setupContextMenu();
|
||||
void setConnectionErrors(bool connected , const QStringList &fails);
|
||||
|
||||
bool checkAccountExists(bool openSettings);
|
||||
|
||||
|
@ -110,8 +109,6 @@ private:
|
|||
QSignalMapper *_recentItemsMapper;
|
||||
|
||||
Application *_app;
|
||||
|
||||
QStringList _startupFails;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
Loading…
Reference in a new issue