mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Received messages are not marked as read while scroll is at the top.
HistoryToEnd button is always shown if there are unread messages. HistoryToEnd button displayes unread messages count. New service message (HistoryCleared) is handled (not displayed at all).
This commit is contained in:
@@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "ui/buttons/history_down_button.h"
|
||||
|
||||
#include "styles/style_history.h"
|
||||
#include "dialogs/dialogs_layout.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
@@ -29,16 +30,25 @@ HistoryDownButton::HistoryDownButton(QWidget *parent) : Button(parent)
|
||||
, a_arrowOpacity(st::btnAttachEmoji.opacity, st::btnAttachEmoji.opacity)
|
||||
, _a_arrowOver(animation(this, &HistoryDownButton::step_arrowOver)) {
|
||||
setCursor(style::cur_pointer);
|
||||
resize(st::historyToDown.width(), st::historyToDown.height());
|
||||
resize(st::historyToDown.width(), st::historyToDownPaddingTop + st::historyToDown.height());
|
||||
|
||||
connect(this, SIGNAL(stateChanged(int,ButtonStateChangeSource)), this, SLOT(onStateChange(int,ButtonStateChangeSource)));
|
||||
}
|
||||
|
||||
void HistoryDownButton::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
st::historyToDown.paint(p, QPoint(0, 0), width());
|
||||
st::historyToDown.paint(p, QPoint(0, st::historyToDownPaddingTop), width());
|
||||
p.setOpacity(a_arrowOpacity.current());
|
||||
st::historyToDownArrow.paint(p, QPoint(0, 0), width());
|
||||
st::historyToDownArrow.paint(p, QPoint(0, st::historyToDownPaddingTop), width());
|
||||
if (_unreadCount > 0) {
|
||||
p.setOpacity(1);
|
||||
bool active = false, muted = false;
|
||||
auto unreadString = QString::number(_unreadCount);
|
||||
if (unreadString.size() > 4) {
|
||||
unreadString = qsl("..") + unreadString.mid(unreadString.size() - 4);
|
||||
}
|
||||
Dialogs::Layout::paintUnreadCount(p, unreadString, width(), 0, style::al_center, active, muted, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryDownButton::onStateChange(int oldState, ButtonStateChangeSource source) {
|
||||
@@ -53,6 +63,11 @@ void HistoryDownButton::onStateChange(int oldState, ButtonStateChangeSource sour
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryDownButton::setUnreadCount(int unreadCount) {
|
||||
_unreadCount = unreadCount;
|
||||
update();
|
||||
}
|
||||
|
||||
void HistoryDownButton::step_arrowOver(float64 ms, bool timer) {
|
||||
float64 dt = ms / st::btnAttachEmoji.duration;
|
||||
if (dt >= 1) {
|
||||
|
@@ -30,6 +30,11 @@ class HistoryDownButton : public Button {
|
||||
public:
|
||||
HistoryDownButton(QWidget *parent);
|
||||
|
||||
void setUnreadCount(int unreadCount);
|
||||
int unreadCount() const {
|
||||
return _unreadCount;
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
@@ -42,6 +47,8 @@ private:
|
||||
anim::fvalue a_arrowOpacity;
|
||||
Animation _a_arrowOver;
|
||||
|
||||
int _unreadCount = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
|
Reference in New Issue
Block a user