1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Plurilization capabilities for notification messages

This commit is contained in:
TheSpiritXIII 2015-06-10 13:18:03 -04:00
parent 7e451cc23e
commit 80ea94bcd3
3 changed files with 22 additions and 1 deletions

View File

@ -32,7 +32,7 @@ NotificationEdgeWidget::NotificationEdgeWidget(Position position, QWidget *paren
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addStretch();
QLabel* textLabel = new QLabel(tr("Unread message(s)"), this);
textLabel = new QLabel(this);
textLabel->setMinimumHeight(textLabel->sizeHint().height()); // Prevent cut-off text.
layout->addWidget(textLabel);
@ -49,6 +49,11 @@ NotificationEdgeWidget::NotificationEdgeWidget(Position position, QWidget *paren
setCursor(Qt::PointingHandCursor);
}
void NotificationEdgeWidget::updateNotificationCount(int count)
{
textLabel->setText(tr("Unread message(s)", "", count));
}
void NotificationEdgeWidget::mouseReleaseEvent(QMouseEvent *event)
{
emit clicked();

View File

@ -22,6 +22,8 @@
#include <QWidget>
class QLabel;
class NotificationEdgeWidget final : public QWidget
{
Q_OBJECT
@ -33,12 +35,16 @@ public:
};
explicit NotificationEdgeWidget(Position position, QWidget *parent = 0);
void updateNotificationCount(int count);
signals:
void clicked();
protected:
void mouseReleaseEvent(QMouseEvent* event) final override;
private:
QLabel* textLabel;
};
#endif // NOTIFICATIONEDGEWIDGET_H

View File

@ -47,6 +47,7 @@ void NotificationScrollArea::trackWidget(GenericChatroomWidget* widget)
recalculateTopEdge();
topEdge->show();
}
topEdge->updateNotificationCount(referencesAbove);
}
else
{
@ -58,6 +59,7 @@ void NotificationScrollArea::trackWidget(GenericChatroomWidget* widget)
recalculateBottomEdge();
bottomEdge->show();
}
bottomEdge->updateNotificationCount(referencesBelow);
}
trackedWidgets.insert(widget, visibility);
@ -78,6 +80,10 @@ void NotificationScrollArea::updateTracking()
delete topEdge;
topEdge = nullptr;
}
else
{
topEdge->updateNotificationCount(referencesAbove);
}
}
else
{
@ -86,6 +92,10 @@ void NotificationScrollArea::updateTracking()
delete bottomEdge;
bottomEdge = nullptr;
}
else
{
bottomEdge->updateNotificationCount(referencesBelow);
}
}
i = trackedWidgets.erase(i);
continue;