Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a7dd3a7
Displays the actual notification subject in the system tray messages.
Feb 12, 2018
b24751b
Adds button to open notification in the browser - to update something…
Feb 14, 2018
bfc7aa1
Adds option to toggle display of Sync and Activity notifications.
Feb 14, 2018
ab7185a
Changes notification text in the checkboxes and adds tooltips with ex…
Feb 15, 2018
20cf4ed
Improves Notification Widget UI.
Feb 16, 2018
32e29fb
Doesn't open the file manager when there isn't a file associated with…
Feb 16, 2018
1a0edc1
Sync activities notifications are never shown unless there is an erro…
Feb 23, 2018
4c79059
Changes notification icon bell size.
Feb 25, 2018
e33d2bf
Removes (s) from time strings.
Feb 25, 2018
4a6a8ca
Removes _appName from Activity data.
Feb 25, 2018
71f4760
Do not display user account when there is only one user in popup mess…
Feb 25, 2018
d71438f
Adds host and scheme to activity link so it can be opened in the
Feb 25, 2018
44f299e
Removes debug messages.
Feb 25, 2018
0f9d8e1
Only uses 'More information' text in button for notification link.
Feb 25, 2018
09a92a5
Align text and changes spacing in notification widget.
Feb 25, 2018
112c5e1
Removes Server Activities option from General settings.
Feb 26, 2018
56709f3
Removes string 'Created' from notifications time.
Feb 26, 2018
6bf9f65
Only notify users of new notifications and only shows them all on sta…
Feb 27, 2018
d42401e
Changes notifications api endpoint to v2.
Mar 1, 2018
621596f
Saves notifications ETag response header to use to request only new n…
Mar 1, 2018
3c77898
Makes sure JsonApiJob::finished won't throw a JSON error when status …
Mar 3, 2018
2e4472a
Enables server notifications by default.
Mar 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified resources/bell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 16 additions & 5 deletions src/common/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,27 +431,38 @@ QString Utility::timeAgoInWords(const QDateTime &dt, const QDateTime &from)
now = from;
}

if (dt.daysTo(now) > 0) {
int dtn = dt.daysTo(now);
return QObject::tr("%n day(s) ago", "", dtn);
if (dt.daysTo(now) == 1) {
return QObject::tr("%n day ago", "", dt.daysTo(now));
} else if (dt.daysTo(now) > 1) {
return QObject::tr("%n days ago", "", dt.daysTo(now));
} else {
qint64 secs = dt.secsTo(now);
if (secs < 0) {
return QObject::tr("in the future");
}

if (floor(secs / 3600.0) > 0) {
int hours = floor(secs / 3600.0);
return (QObject::tr("%n hour(s) ago", "", hours));
if(hours == 1){
return (QObject::tr("%n hour ago", "", hours));
} else {
return (QObject::tr("%n hours ago", "", hours));
}
} else {
int minutes = qRound(secs / 60.0);

if (minutes == 0) {
if (secs < 5) {
return QObject::tr("now");
} else {
return QObject::tr("Less than a minute ago");
}

} else if(minutes == 1){
return (QObject::tr("%n minute ago", "", minutes));
} else {
return (QObject::tr("%n minutes ago", "", minutes));
}
return (QObject::tr("%n minute(s) ago", "", minutes));
}
}
return QObject::tr("Some time ago");
Expand Down
11 changes: 11 additions & 0 deletions src/gui/accountstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ AccountState::AccountState(AccountPtr account)
, _connectionStatus(ConnectionValidator::Undefined)
, _waitingForNewCredentials(false)
, _maintenanceToConnectedDelay(60000 + (qrand() % (4 * 60000))) // 1-5min delay
, _notificationsEtagResponseHeader("*")
{
qRegisterMetaType<AccountState *>("AccountState*");

Expand Down Expand Up @@ -176,6 +177,16 @@ void AccountState::tagLastSuccessfullETagRequest()
_timeSinceLastETagCheck.start();
}

QByteArray AccountState::notificationsEtagResponseHeader() const
{
return _notificationsEtagResponseHeader;
}

void AccountState::setNotificationsEtagResponseHeader(const QByteArray &value)
{
_notificationsEtagResponseHeader = value;
}

void AccountState::checkConnectivity()
{
if (isSignedOut() || _waitingForNewCredentials) {
Expand Down
11 changes: 11 additions & 0 deletions src/gui/accountstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ class AccountState : public QObject, public QSharedData
*/
void tagLastSuccessfullETagRequest();

/** Saves the ETag Response header from the last Notifications api
* request with statusCode 200.
*/
QByteArray notificationsEtagResponseHeader() const;

/** Returns the ETag Response header from the last Notifications api
* request with statusCode 200.
*/
void setNotificationsEtagResponseHeader(const QByteArray &value);

public slots:
/// Triggers a ping to the server to update state and
/// connection status and errors.
Expand All @@ -157,6 +167,7 @@ protected Q_SLOTS:
bool _waitingForNewCredentials;
QElapsedTimer _timeSinceLastETagCheck;
QPointer<ConnectionValidator> _connectionValidator;
QByteArray _notificationsEtagResponseHeader;

/**
* Starts counting when the server starts being back up after 503 or
Expand Down
18 changes: 10 additions & 8 deletions src/gui/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const

switch (role) {
case ActivityItemDelegate::PathRole:
list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
if (list.count() > 0) {
return QVariant(list.at(0));
}
// File does not exist anymore? Let's try to open its path
list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(a._file).path(), ast->account());
if (list.count() > 0) {
return QVariant(list.at(0));
if(!a._file.isEmpty()){
list = FolderMan::instance()->findFileInLocalFolders(a._file, ast->account());
if (list.count() > 0) {
return QVariant(list.at(0));
}
// File does not exist anymore? Let's try to open its path
list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(a._file).path(), ast->account());
if (list.count() > 0) {
return QVariant(list.at(0));
}
}
return QVariant();
break;
Expand Down
36 changes: 13 additions & 23 deletions src/gui/activitywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "servernotificationhandler.h"
#include "theme.h"
#include "ocsjob.h"
#include "configfile.h"

#include "ui_activitywidget.h"

Expand Down Expand Up @@ -303,6 +304,16 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
}
}
_guiLoggedNotifications.insert(activity._id);

// Assemble a tray notification for the NEW notification
ConfigFile cfg;
if(cfg.optionalServerNotifications()){
if(AccountManager::instance()->accounts().count() == 1){
emit guiLog(activity._subject, "");
} else {
emit guiLog(activity._subject, activity._accName);
}
}
}
}

Expand Down Expand Up @@ -339,31 +350,9 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)

checkActivityTabVisibility();

int newGuiLogCount = accNotified.count();

if (newGuiLogCount > 0) {
if (newNotificationShown) {
// restart the gui log timer now that we show a notification
_guiLogTimer.start();

// Assemble a tray notification
QString msg = tr("You received %n new notification(s) from %2.", "", accNotified[accNotified.keys().at(0)]).arg(accNotified.keys().at(0));

if (newGuiLogCount >= 2) {
QString acc1 = accNotified.keys().at(0);
QString acc2 = accNotified.keys().at(1);
if (newGuiLogCount == 2) {
int notiCount = accNotified[acc1] + accNotified[acc2];
msg = tr("You received %n new notification(s) from %1 and %2.", "", notiCount).arg(acc1, acc2);
} else {
msg = tr("You received new notifications from %1, %2 and other accounts.").arg(acc1, acc2);
}
}

const QString log = tr("%1 Notifications - Action Required").arg(Theme::instance()->appNameGUI());
emit guiLog(log, msg);
}

if (newNotificationShown) {
emit newNotification();
}
}
Expand Down Expand Up @@ -615,6 +604,7 @@ void ActivitySettings::slotCopyToClipboard()
}

QApplication::clipboard()->setText(text);

emit guiLog(tr("Copied to clipboard"), message);
}

Expand Down
4 changes: 3 additions & 1 deletion src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ void Folder::createGuiLog(const QString &filename, LogStatus status, int count,
}

if (!text.isEmpty()) {
logger->postOptionalGuiLog(tr("Sync Activity"), text);
// Ignores the settings in case of an error or conflict
if(status == LogStatusError || status == LogStatusConflict)
logger->postOptionalGuiLog(tr("Sync Activity"), text);
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ GeneralSettings::GeneralSettings(QWidget *parent)
{
_ui->setupUi(this);

connect(_ui->desktopNotificationsCheckBox, &QAbstractButton::toggled,
this, &GeneralSettings::slotToggleOptionalDesktopNotifications);
connect(_ui->serverNotificationsCheckBox, &QAbstractButton::toggled,
this, &GeneralSettings::slotToggleOptionalServerNotifications);
_ui->serverNotificationsCheckBox->setToolTip(tr("Server notifications that require attention."));

connect(_ui->showInExplorerNavigationPaneCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotShowInExplorerNavigationPane);

_ui->autostartCheckBox->setChecked(Utility::hasLaunchOnStartup(Theme::instance()->appName()));
Expand Down Expand Up @@ -114,7 +116,7 @@ void GeneralSettings::loadMiscSettings()
QScopedValueRollback<bool> scope(_currentlyLoading, true);
ConfigFile cfgFile;
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
_ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications());
_ui->serverNotificationsCheckBox->setChecked(cfgFile.optionalServerNotifications());
_ui->showInExplorerNavigationPaneCheckBox->setChecked(cfgFile.showInExplorerNavigationPane());
_ui->crashreporterCheckBox->setChecked(cfgFile.crashReporter());
auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
Expand Down Expand Up @@ -165,10 +167,10 @@ void GeneralSettings::slotToggleLaunchOnStartup(bool enable)
Utility::setLaunchOnStartup(theme->appName(), theme->appNameGUI(), enable);
}

void GeneralSettings::slotToggleOptionalDesktopNotifications(bool enable)
void GeneralSettings::slotToggleOptionalServerNotifications(bool enable)
{
ConfigFile cfgFile;
cfgFile.setOptionalDesktopNotifications(enable);
cfgFile.setOptionalServerNotifications(enable);
}

void GeneralSettings::slotShowInExplorerNavigationPane(bool checked)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/generalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GeneralSettings : public QWidget
private slots:
void saveMiscSettings();
void slotToggleLaunchOnStartup(bool);
void slotToggleOptionalDesktopNotifications(bool);
void slotToggleOptionalServerNotifications(bool);
void slotShowInExplorerNavigationPane(bool);
void slotUpdateInfo();
void slotIgnoreFilesEditor();
Expand Down
26 changes: 13 additions & 13 deletions src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="autostartCheckBox">
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<property name="text">
<string>&amp;Launch on System Startup</string>
<string>Use &amp;Monochrome Icons</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="desktopNotificationsCheckBox">
<item row="0" column="0">
<widget class="QCheckBox" name="autostartCheckBox">
<property name="text">
<string>Show &amp;Desktop Notifications</string>
<string>&amp;Launch on System Startup</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<item row="0" column="1">
<widget class="QCheckBox" name="serverNotificationsCheckBox">
<property name="text">
<string>Use &amp;Monochrome Icons</string>
<string>Show Server &amp;Notifications</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -253,7 +253,7 @@
</widget>
<tabstops>
<tabstop>autostartCheckBox</tabstop>
<tabstop>desktopNotificationsCheckBox</tabstop>
<tabstop>serverNotificationsCheckBox</tabstop>
<tabstop>monoIconsCheckBox</tabstop>
<tabstop>ignoredFilesButton</tabstop>
<tabstop>newFolderLimitCheckBox</tabstop>
Expand Down
27 changes: 23 additions & 4 deletions src/gui/notificationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "QProgressIndicator.h"
#include "common/utility.h"
#include "common/asserts.h"
#include "guiutility.h"

#include <QPushButton>

Expand All @@ -40,19 +41,18 @@ void NotificationWidget::setActivity(const Activity &activity)
_accountName = activity._accName;
ASSERT(!_accountName.isEmpty());

// _ui._headerLabel->setText( );
_ui._subjectLabel->setVisible(!activity._subject.isEmpty());
_ui._messageLabel->setVisible(!activity._message.isEmpty());

_ui._subjectLabel->setText(activity._subject);
_ui._messageLabel->setText(activity._message);

_ui._notifIcon->setPixmap(QPixmap(":/client/resources/bell.png"));
_ui._notifIcon->setMinimumWidth(64);
_ui._notifIcon->setMinimumHeight(64);
_ui._notifIcon->setMinimumWidth(22);
_ui._notifIcon->setMinimumHeight(22);
_ui._notifIcon->show();

QString tText = tr("Created at %1").arg(Utility::timeAgoInWords(activity._dateTime));
QString tText = tr("%1").arg(Utility::timeAgoInWords(activity._dateTime));
_ui._timeLabel->setText(tText);

// always remove the buttons
Expand All @@ -61,8 +61,18 @@ void NotificationWidget::setActivity(const Activity &activity)
}
_buttons.clear();

// open the notification in the browser if there is a link
if(!_myActivity._link.isEmpty()){
QString buttonText(tr("More information"));
QPushButton *openBrowser = _ui._buttonBox->addButton(buttonText, QDialogButtonBox::AcceptRole);
openBrowser->setDefault(true);
connect(openBrowser, &QAbstractButton::clicked, this, &NotificationWidget::slotOpenBrowserButtonClicked);
_buttons.prepend(openBrowser);
}

// display buttons for the links
if (activity._links.isEmpty()) {
// is there any case where this code is executed?
// in case there is no action defined, do a close button.
QPushButton *b = _ui._buttonBox->addButton(QDialogButtonBox::Close);
b->setDefault(true);
Expand All @@ -83,6 +93,11 @@ Activity NotificationWidget::activity() const
return _myActivity;
}

void NotificationWidget::slotOpenBrowserButtonClicked(){
QUrl url(_myActivity._link);
Utility::openBrowser(url, this);
}

void NotificationWidget::slotButtonClicked()
{
QObject *buttonWidget = QObject::sender();
Expand All @@ -97,6 +112,10 @@ void NotificationWidget::slotButtonClicked()
_buttons.at(i)->setEnabled(false);
}

// there is an extra button: 'Open'
if(!_myActivity._link.isEmpty())
index--;

// if the button was found, the link must be called
if (index > -1 && _myActivity._links.count() == 0) {
// no links, that means it was the close button
Expand Down
1 change: 1 addition & 0 deletions src/gui/notificationwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public slots:

private slots:
void slotButtonClicked();
void slotOpenBrowserButtonClicked();

private:
Ui_NotificationWidget _ui;
Expand Down
Loading