Notifications: Display timestamp of the notification in the widget

This commit is contained in:
Klaas Freitag 2016-03-18 08:21:54 +01:00
parent f71fdab997
commit 05de710b67
2 changed files with 31 additions and 8 deletions

View File

@ -13,6 +13,7 @@
#include "notificationwidget.h"
#include "QProgressIndicator.h"
#include "utility.h"
#include <QPushButton>
@ -30,6 +31,7 @@ NotificationWidget::NotificationWidget(QWidget *parent) : QWidget(parent)
void NotificationWidget::setActivity(const Activity& activity)
{
_myActivity = activity;
QLocale locale;
Q_ASSERT( !activity._accName.isEmpty() );
_accountName = activity._accName;
@ -46,6 +48,9 @@ void NotificationWidget::setActivity(const Activity& activity)
_ui._notifIcon->setMinimumHeight(64);
_ui._notifIcon->show();
QString tText = tr("Created at %1").arg(Utility::timeAgoInWords(activity._dateTime));
_ui._timeLabel->setText(tText);
// always remove the buttons
foreach( auto button, _ui._buttonBox->buttons() ) {
_ui._buttonBox->removeButton(button);
@ -96,7 +101,6 @@ void NotificationWidget::slotNotificationRequestFinished(int statusCode)
} else {
// the call to the ocs API succeeded.
_ui._buttonBox->hide();
}
_progressIndi->stopAnimation();
}

View File

@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="_notifIcon">
<property name="sizePolicy">
@ -28,7 +28,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap>../../resources/bell.png</pixmap>
<pixmap>../../../../resources/bell.png</pixmap>
</property>
</widget>
</item>
@ -58,11 +58,30 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="_buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="_timeLabel">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="_buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>