Added bubble widget for empty list info in modern history view list.
This commit is contained in:
parent
87ca2c891a
commit
95a896004f
|
@ -564,6 +564,8 @@ PRIVATE
|
||||||
history/view/history_view_cursor_state.h
|
history/view/history_view_cursor_state.h
|
||||||
history/view/history_view_element.cpp
|
history/view/history_view_element.cpp
|
||||||
history/view/history_view_element.h
|
history/view/history_view_element.h
|
||||||
|
history/view/history_view_empty_list_bubble.cpp
|
||||||
|
history/view/history_view_empty_list_bubble.h
|
||||||
history/view/history_view_group_call_tracker.cpp
|
history/view/history_view_group_call_tracker.cpp
|
||||||
history/view/history_view_group_call_tracker.h
|
history/view/history_view_group_call_tracker.h
|
||||||
history/view/history_view_list_widget.cpp
|
history/view/history_view_list_widget.cpp
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "history/view/history_view_empty_list_bubble.h"
|
||||||
|
|
||||||
|
#include "history/view/history_view_list_widget.h"
|
||||||
|
#include "history/view/history_view_service_message.h"
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
|
||||||
|
EmptyListBubbleWidget::EmptyListBubbleWidget(
|
||||||
|
not_null<ListWidget*> parent,
|
||||||
|
const style::margins &padding)
|
||||||
|
: RpWidget(parent)
|
||||||
|
, _padding(padding) {
|
||||||
|
|
||||||
|
parent->sizeValue(
|
||||||
|
) | rpl::start_with_next([=](const QSize &s) {
|
||||||
|
updateGeometry(s);
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyListBubbleWidget::updateGeometry(const QSize &size) {
|
||||||
|
const auto w = _forceWidth
|
||||||
|
? _forceWidth
|
||||||
|
: std::min(
|
||||||
|
_text.maxWidth() + _padding.left() + _padding.right(),
|
||||||
|
size.width());
|
||||||
|
_innerWidth = w - _padding.left() - _padding.right();
|
||||||
|
const auto h = _padding.top()
|
||||||
|
+ _text.countHeight(_innerWidth)
|
||||||
|
+ _padding.bottom();
|
||||||
|
resize(w, h);
|
||||||
|
move((size.width() - w) / 2, (size.height() - h) / 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyListBubbleWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
Painter p(this);
|
||||||
|
|
||||||
|
const auto r = rect();
|
||||||
|
HistoryView::ServiceMessagePainter::paintBubble(
|
||||||
|
p,
|
||||||
|
r.x(),
|
||||||
|
r.y(),
|
||||||
|
r.width(),
|
||||||
|
r.height());
|
||||||
|
|
||||||
|
p.setPen(st::msgServiceFg);
|
||||||
|
_text.draw(
|
||||||
|
p,
|
||||||
|
r.x() + _padding.left(),
|
||||||
|
r.y() + _padding.top(),
|
||||||
|
_innerWidth,
|
||||||
|
style::al_top);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyListBubbleWidget::setText(
|
||||||
|
const TextWithEntities &textWithEntities) {
|
||||||
|
auto options = _defaultOptions;
|
||||||
|
options.flags |= TextParseMarkdown;
|
||||||
|
_text.setMarkedText(st::defaultTextStyle, textWithEntities, options);
|
||||||
|
updateGeometry(size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyListBubbleWidget::setForceWidth(int width) {
|
||||||
|
if (_forceWidth != width) {
|
||||||
|
_forceWidth = width;
|
||||||
|
updateGeometry(size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace HistoryView
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui/rp_widget.h"
|
||||||
|
|
||||||
|
namespace HistoryView {
|
||||||
|
|
||||||
|
class ListWidget;
|
||||||
|
|
||||||
|
class EmptyListBubbleWidget : public Ui::RpWidget {
|
||||||
|
public:
|
||||||
|
EmptyListBubbleWidget(
|
||||||
|
not_null<ListWidget*> parent,
|
||||||
|
const style::margins &padding);
|
||||||
|
|
||||||
|
void setText(const TextWithEntities &textWithEntities);
|
||||||
|
void setForceWidth(int width);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateGeometry(const QSize &size);
|
||||||
|
|
||||||
|
const style::margins &_padding;
|
||||||
|
Ui::Text::String _text;
|
||||||
|
int _innerWidth = 0;
|
||||||
|
int _forceWidth = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace HistoryView
|
|
@ -382,6 +382,9 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
|
||||||
if (!_itemsRevealHeight) {
|
if (!_itemsRevealHeight) {
|
||||||
mouseActionUpdate(QCursor::pos());
|
mouseActionUpdate(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
if (_emptyInfo) {
|
||||||
|
_emptyInfo->setVisible(isEmpty());
|
||||||
|
}
|
||||||
_delegate->listContentRefreshed();
|
_delegate->listContentRefreshed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2940,6 +2943,10 @@ void ListWidget::replyNextMessage(FullMsgId fullId, bool next) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListWidget::setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w) {
|
||||||
|
_emptyInfo = std::move(w);
|
||||||
|
}
|
||||||
|
|
||||||
ListWidget::~ListWidget() = default;
|
ListWidget::~ListWidget() = default;
|
||||||
|
|
||||||
void ConfirmDeleteSelectedItems(not_null<ListWidget*> widget) {
|
void ConfirmDeleteSelectedItems(not_null<ListWidget*> widget) {
|
||||||
|
|
|
@ -257,6 +257,8 @@ public:
|
||||||
bool elementIsChatWide() override;
|
bool elementIsChatWide() override;
|
||||||
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
||||||
|
|
||||||
|
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);
|
||||||
|
|
||||||
~ListWidget();
|
~ListWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -524,6 +526,8 @@ private:
|
||||||
|
|
||||||
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
|
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
|
||||||
|
|
||||||
|
base::unique_qptr<Ui::RpWidget> _emptyInfo = nullptr;
|
||||||
|
|
||||||
int _minHeight = 0;
|
int _minHeight = 0;
|
||||||
int _visibleTop = 0;
|
int _visibleTop = 0;
|
||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
|
|
Loading…
Reference in New Issue