mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
Notifications: Remove "done" notification widgets after fife seconds.
This commit is contained in:
parent
0a590b7cbe
commit
328d254f7f
4 changed files with 45 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
|||
#include "notificationconfirmjob.h"
|
||||
#include "servernotificationhandler.h"
|
||||
#include "theme.h"
|
||||
#include "ocsjob.h"
|
||||
|
||||
#include "ui_activitywidget.h"
|
||||
|
||||
|
@ -359,8 +360,34 @@ void ActivityWidget::slotNotifyServerFinished( const QString& reply, int replyCo
|
|||
endNotificationRequest(job->widget(), replyCode);
|
||||
// FIXME: remove the widget after a couple of seconds
|
||||
qDebug() << Q_FUNC_INFO << "Server Notification reply code"<< replyCode << reply;
|
||||
|
||||
// if the notification was successful start a timer that triggers
|
||||
// removal of the done widgets in a few seconds
|
||||
// Add 200 millisecs to the predefined value to make sure that the timer in
|
||||
// widget's method readyToClose() has elapsed.
|
||||
if( replyCode == OCS_SUCCESS_STATUS_CODE ) {
|
||||
QTimer::singleShot(NOTIFICATION_WIDGET_CLOSE_AFTER_MILLISECS+200, this, SLOT(slotCleanWidgetList()));
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotCleanWidgetList()
|
||||
{
|
||||
foreach( int id, _widgetForNotifId.keys() ) {
|
||||
Q_ASSERT(_widgetForNotifId[id]);
|
||||
if( _widgetForNotifId[id]->readyToClose() ) {
|
||||
auto *widget = _widgetForNotifId[id];
|
||||
_widgetForNotifId.remove(id);
|
||||
delete widget;
|
||||
}
|
||||
}
|
||||
|
||||
if( _widgetForNotifId.isEmpty() ) {
|
||||
_ui->_notifyLabel->setHidden(true);
|
||||
_ui->_notifyScroll->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ==================================================================== */
|
||||
|
||||
ActivitySettings::ActivitySettings(QWidget *parent)
|
||||
|
|
|
@ -79,6 +79,7 @@ private slots:
|
|||
void slotNotifyNetworkError( QNetworkReply* );
|
||||
void slotNotifyServerFinished( const QString& reply, int replyCode );
|
||||
void endNotificationRequest(NotificationWidget *widget , int replyCode);
|
||||
void slotCleanWidgetList();
|
||||
|
||||
private:
|
||||
void showLabels();
|
||||
|
|
|
@ -112,10 +112,22 @@ void NotificationWidget::slotNotificationRequestFinished(int statusCode)
|
|||
|
||||
//* The second parameter is a time, such as 'selected at 09:58pm'
|
||||
doneText = tr("'%1' selected at %2").arg(_actionLabel).arg(timeStr);
|
||||
|
||||
// start a timer, so that activity widget can remove this widget after a
|
||||
// certain time. It needs to be done by ActivityWidget because it also
|
||||
// needs to hide the scrollview if no widget is left any more.
|
||||
// method readyToClose() checks for the timer value to see if it is expired
|
||||
_closeTimer.start();
|
||||
}
|
||||
_ui._timeLabel->setText( doneText );
|
||||
|
||||
_progressIndi->stopAnimation();
|
||||
|
||||
}
|
||||
|
||||
bool NotificationWidget::readyToClose()
|
||||
{
|
||||
return _closeTimer.isValid() && _closeTimer.elapsed() > NOTIFICATION_WIDGET_CLOSE_AFTER_MILLISECS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "ui_notificationwidget.h"
|
||||
|
||||
#define NOTIFICATION_WIDGET_CLOSE_AFTER_MILLISECS 4800
|
||||
|
||||
class QProgressIndicator;
|
||||
|
||||
namespace OCC {
|
||||
|
@ -30,6 +32,8 @@ class NotificationWidget : public QWidget
|
|||
public:
|
||||
explicit NotificationWidget(QWidget *parent = 0);
|
||||
|
||||
bool readyToClose();
|
||||
|
||||
signals:
|
||||
void sendNotificationRequest( const QString&, const QString& link, const QString& verb);
|
||||
|
||||
|
@ -47,6 +51,7 @@ private:
|
|||
QString _accountName;
|
||||
QProgressIndicator *_progressIndi;
|
||||
QString _actionLabel;
|
||||
QElapsedTimer _closeTimer;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue