Skip to content

Commit

Permalink
Confirm notifications.
Browse files Browse the repository at this point in the history
Issue #3148
Implement the tray notification as specified.
Unfortunately, the tray notification cannot be clicked
  • Loading branch information
ogoffart committed Jul 20, 2015
1 parent a9dfcdd commit da19380
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
48 changes: 48 additions & 0 deletions src/gui/accountsettings.cpp
Expand Up @@ -28,6 +28,7 @@
#include "quotainfo.h"
#include "accountmanager.h"
#include "creds/abstractcredentials.h"
#include <logger.h>

#include <math.h>

Expand Down Expand Up @@ -472,6 +473,10 @@ void AccountSettings::refreshSelectiveSyncStatus()
tr("There are new shared folders that were not synchronized because they are too big: %1")
.arg(undecidedFolder.join(tr(", "))));
shouldBeVisible = true;

if (!_newBigFolderNotificationTimer) {
newBigFolderNotificationTimeout();
}
}

ui->selectiveSyncApply->setEnabled(_model->isDirty() || !undecidedFolder.isEmpty());
Expand All @@ -492,6 +497,49 @@ void AccountSettings::refreshSelectiveSyncStatus()
}
}

/**
* From the acceptence criteria of issue #3148:
*
* - The notification includes a message “A Folder larger than [setting] has been shared with you.
* Do you want to sync this folder to this device?".
* - This notification appears every 15 minutes as long as there is a decision in the activity list
* for the user to make. When the activity menu is viewed the notification can go away.
* (this is so users will be forced to decide what to do)
*/
void AccountSettings::newBigFolderNotificationTimeout()
{
bool hasUndecidedFolder = false;
foreach (Folder *folder, FolderMan::instance()->map().values()) {
if (folder->accountState() != _accountState) { continue; }
auto undecidedList = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList);
if (!undecidedList.isEmpty()) {
hasUndecidedFolder = true;
break;
}
}

if (!hasUndecidedFolder) {
delete _newBigFolderNotificationTimer;
return;
}

if (!_newBigFolderNotificationTimer) {
// Repeat every 15 minutes
_newBigFolderNotificationTimer = new QTimer(this);
connect(_newBigFolderNotificationTimer,SIGNAL(timeout()),this, SLOT(newBigFolderNotificationTimeout()));
_newBigFolderNotificationTimer->start(15 * 60 * 1000);
}

QString message = tr("A Folder larger than %1 MB has been shared with you. "
"Do you want to sync this folder to this device?")
.arg(ConfigFile().newSharedFolderSizeLimit().second);

auto logger = Logger::instance();
logger->postOptionalGuiLog(Theme::instance()->appNameGUI(), message);

}


void AccountSettings::slotDeleteAccount()
{
int ret = QMessageBox::question( this, tr("Confirm Account Delete"),
Expand Down
2 changes: 2 additions & 0 deletions src/gui/accountsettings.h
Expand Up @@ -80,6 +80,7 @@ protected slots:
void slotDeleteAccount();
void refreshSelectiveSyncStatus();
void slotCustomContextMenuRequested(const QPoint&);
void newBigFolderNotificationTimeout();

private:
void showConnectionLabel(const QString& message,
Expand All @@ -94,6 +95,7 @@ protected slots:
AccountState *_accountState;
QLabel *_quotaLabel;
QuotaInfo _quotaInfo;
QPointer<QTimer> _newBigFolderNotificationTimer;
};

} // namespace OCC
Expand Down
5 changes: 2 additions & 3 deletions src/gui/folder.cpp
Expand Up @@ -1061,11 +1061,10 @@ void Folder::slotNewSharedBigFolderDiscovered(const QString &newF)
if (!undecidedList.contains(newFolder)) {
undecidedList.append(newFolder);
journal->setSelectiveSyncList(SyncJournalDb::SelectiveSyncUndecidedList, undecidedList);
emit newSharedBigFolderDiscovered(newFolder);
}
}


emit newSharedBigFolderDiscovered(newFolder);
}

void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
{
Expand Down

0 comments on commit da19380

Please sign in to comment.