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

View File

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

View File

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