mirror of https://github.com/procxx/kepka.git
Display empty event log placeholder.
Also hide the filter button for now.
This commit is contained in:
parent
ae56c5266f
commit
8c04bed572
|
@ -1321,7 +1321,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
"lng_admin_log_no_results_title" = "No events found";
|
"lng_admin_log_no_results_title" = "No events found";
|
||||||
"lng_admin_log_no_results_text" = "No recent events that match your query have been found.";
|
"lng_admin_log_no_results_text" = "No recent events that match your query have been found.";
|
||||||
"lng_admin_log_no_events_title" = "No events yet";
|
"lng_admin_log_no_events_title" = "No events yet";
|
||||||
"lng_admin_log_no_events_text" = "There were no service actions taken by the group's members and admins in the last 48 hours.";
|
"lng_admin_log_no_events_text" = "There were no service actions\ntaken by the group's members\nand admins in the last 48 hours.";
|
||||||
|
|
||||||
"lng_admin_log_empty_text" = "Empty";
|
"lng_admin_log_empty_text" = "Empty";
|
||||||
"lng_admin_log_changed_title_group" = "{from} changed group name to «{title}»";
|
"lng_admin_log_changed_title_group" = "{from} changed group name to «{title}»";
|
||||||
|
|
|
@ -445,3 +445,6 @@ historyVideoMessageMute: icon {{ "volume_mute", historyFileThumbIconFg }};
|
||||||
historyVideoMessageMuteSelected: icon {{ "volume_mute", historyFileThumbIconFgSelected }};
|
historyVideoMessageMuteSelected: icon {{ "volume_mute", historyFileThumbIconFgSelected }};
|
||||||
historyVideoMessageMuteSize: 25px;
|
historyVideoMessageMuteSize: 25px;
|
||||||
historyVideoMessageProgressOpacity: 0.72;
|
historyVideoMessageProgressOpacity: 0.72;
|
||||||
|
|
||||||
|
historyAdminLogEmptyWidth: 260px;
|
||||||
|
historyAdminLogEmptyPadding: margins(10px, 12px, 10px, 12px);
|
||||||
|
|
|
@ -38,7 +38,8 @@ namespace AdminLog {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kScrollDateHideTimeout = 1000;
|
constexpr auto kScrollDateHideTimeout = 1000;
|
||||||
constexpr auto kEventsPerPage = 1;
|
constexpr auto kEventsFirstPage = 20;
|
||||||
|
constexpr auto kEventsPerPage = 50;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -203,7 +204,8 @@ InnerWidget::InnerWidget(QWidget *parent, gsl::not_null<Window::Controller*> con
|
||||||
, _channel(channel)
|
, _channel(channel)
|
||||||
, _history(App::history(channel))
|
, _history(App::history(channel))
|
||||||
, _scrollTo(std::move(scrollTo))
|
, _scrollTo(std::move(scrollTo))
|
||||||
, _scrollDateCheck([this] { scrollDateCheck(); }) {
|
, _scrollDateCheck([this] { scrollDateCheck(); })
|
||||||
|
, _emptyText(st::historyAdminLogEmptyWidth - st::historyAdminLogEmptyPadding.left() - st::historyAdminLogEmptyPadding.left()) {
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
_scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); });
|
_scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); });
|
||||||
subscribe(AuthSession::Current().data().repaintLogEntry(), [this](gsl::not_null<const HistoryItem*> historyItem) {
|
subscribe(AuthSession::Current().data().repaintLogEntry(), [this](gsl::not_null<const HistoryItem*> historyItem) {
|
||||||
|
@ -221,6 +223,7 @@ InnerWidget::InnerWidget(QWidget *parent, gsl::not_null<Window::Controller*> con
|
||||||
*query.isVisible = true;
|
*query.isVisible = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
updateEmptyText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::setVisibleTopBottom(int visibleTop, int visibleBottom) {
|
void InnerWidget::setVisibleTopBottom(int visibleTop, int visibleBottom) {
|
||||||
|
@ -311,6 +314,17 @@ void InnerWidget::checkPreloadMore() {
|
||||||
void InnerWidget::applyFilter(MTPDchannelAdminLogEventsFilter::Flags flags, const std::vector<gsl::not_null<UserData*>> &admins) {
|
void InnerWidget::applyFilter(MTPDchannelAdminLogEventsFilter::Flags flags, const std::vector<gsl::not_null<UserData*>> &admins) {
|
||||||
_filterFlags = flags;
|
_filterFlags = flags;
|
||||||
_filterAdmins = admins;
|
_filterAdmins = admins;
|
||||||
|
updateEmptyText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InnerWidget::updateEmptyText() {
|
||||||
|
auto options = _defaultOptions;
|
||||||
|
options.flags |= TextParseMono; // For italic :/
|
||||||
|
auto hasFilter = (_filterFlags != 0) || !_filterAdmins.empty();
|
||||||
|
auto text = TextWithEntities { lang(hasFilter ? lng_admin_log_no_results_title : lng_admin_log_no_events_title) };
|
||||||
|
text.entities.append(EntityInText(EntityInTextBold, 0, text.text.size()));
|
||||||
|
text.text.append(qstr("\n\n") + lang(hasFilter ? lng_admin_log_no_results_text : lng_admin_log_no_events_text));
|
||||||
|
_emptyText.setMarkedText(st::defaultTextStyle, text, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString InnerWidget::tooltipText() const {
|
QString InnerWidget::tooltipText() const {
|
||||||
|
@ -374,7 +388,8 @@ void InnerWidget::preloadMore(Direction direction) {
|
||||||
auto query = QString();
|
auto query = QString();
|
||||||
auto maxId = (direction == Direction::Up) ? _minId : 0;
|
auto maxId = (direction == Direction::Up) ? _minId : 0;
|
||||||
auto minId = (direction == Direction::Up) ? 0 : _maxId;
|
auto minId = (direction == Direction::Up) ? 0 : _maxId;
|
||||||
requestId = request(MTPchannels_GetAdminLog(MTP_flags(flags), _channel->inputChannel, MTP_string(query), filter, MTP_vector<MTPInputUser>(admins), MTP_long(maxId), MTP_long(minId), MTP_int(kEventsPerPage))).done([this, &requestId, &loadedFlag, direction](const MTPchannels_AdminLogResults &result) {
|
auto perPage = _items.empty() ? kEventsFirstPage : kEventsPerPage;
|
||||||
|
requestId = request(MTPchannels_GetAdminLog(MTP_flags(flags), _channel->inputChannel, MTP_string(query), filter, MTP_vector<MTPInputUser>(admins), MTP_long(maxId), MTP_long(minId), MTP_int(perPage))).done([this, &requestId, &loadedFlag, direction](const MTPchannels_AdminLogResults &result) {
|
||||||
Expects(result.type() == mtpc_channels_adminLogResults);
|
Expects(result.type() == mtpc_channels_adminLogResults);
|
||||||
requestId = 0;
|
requestId = 0;
|
||||||
|
|
||||||
|
@ -568,14 +583,15 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::paintEmpty(Painter &p) {
|
void InnerWidget::paintEmpty(Painter &p) {
|
||||||
//style::font font(st::msgServiceFont);
|
style::font font(st::msgServiceFont);
|
||||||
//int32 w = font->width(lang(lng_willbe_history)) + st::msgPadding.left() + st::msgPadding.right(), h = font->height + st::msgServicePadding.top() + st::msgServicePadding.bottom() + 2;
|
auto rectWidth = st::historyAdminLogEmptyWidth;
|
||||||
//QRect tr((width() - w) / 2, (height() - _field->height() - 2 * st::historySendPadding - h) / 2, w, h);
|
auto innerWidth = rectWidth - st::historyAdminLogEmptyPadding.left() - st::historyAdminLogEmptyPadding.right();
|
||||||
//HistoryLayout::ServiceMessagePainter::paintBubble(p, tr.x(), tr.y(), tr.width(), tr.height());
|
auto rectHeight = st::historyAdminLogEmptyPadding.top() + _emptyText.countHeight(innerWidth) + st::historyAdminLogEmptyPadding.bottom();
|
||||||
|
auto rect = QRect((width() - rectWidth) / 2, (height() - rectHeight) / 3, rectWidth, rectHeight);
|
||||||
|
HistoryLayout::ServiceMessagePainter::paintBubble(p, rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
|
|
||||||
//p.setPen(st::msgServiceFg);
|
p.setPen(st::msgServiceFg);
|
||||||
//p.setFont(font->f);
|
_emptyText.draw(p, rect.x() + st::historyAdminLogEmptyPadding.left(), rect.y() + st::historyAdminLogEmptyPadding.top(), innerWidth, style::al_top);
|
||||||
//p.drawText(tr.left() + st::msgPadding.left(), tr.top() + st::msgServicePadding.top() + 1 + font->ascent, lang(lng_willbe_history));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextWithEntities InnerWidget::getSelectedText() const {
|
TextWithEntities InnerWidget::getSelectedText() const {
|
||||||
|
|
|
@ -152,6 +152,7 @@ private:
|
||||||
void itemsAdded(Direction direction);
|
void itemsAdded(Direction direction);
|
||||||
void updateSize();
|
void updateSize();
|
||||||
void updateMinMaxIds();
|
void updateMinMaxIds();
|
||||||
|
void updateEmptyText();
|
||||||
void paintEmpty(Painter &p);
|
void paintEmpty(Painter &p);
|
||||||
|
|
||||||
void toggleScrollDateShown();
|
void toggleScrollDateShown();
|
||||||
|
@ -218,6 +219,7 @@ private:
|
||||||
// Don't load anything until the memento was read.
|
// Don't load anything until the memento was read.
|
||||||
bool _upLoaded = true;
|
bool _upLoaded = true;
|
||||||
bool _downLoaded = true;
|
bool _downLoaded = true;
|
||||||
|
Text _emptyText;
|
||||||
|
|
||||||
MouseAction _mouseAction = MouseAction::None;
|
MouseAction _mouseAction = MouseAction::None;
|
||||||
TextSelectType _mouseSelectType = TextSelectType::Letters;
|
TextSelectType _mouseSelectType = TextSelectType::Letters;
|
||||||
|
|
|
@ -73,6 +73,7 @@ FixedBar::FixedBar(QWidget *parent) : TWidget(parent)
|
||||||
_backButton->moveToLeft(0, 0);
|
_backButton->moveToLeft(0, 0);
|
||||||
_backButton->setClickedCallback([this] { goBack(); });
|
_backButton->setClickedCallback([this] { goBack(); });
|
||||||
_filter->setClickedCallback([this] {});
|
_filter->setClickedCallback([this] {});
|
||||||
|
_filter->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedBar::applyFilter(MTPDchannelAdminLogEventsFilter::Flags flags, const std::vector<gsl::not_null<UserData*>> &admins) {
|
void FixedBar::applyFilter(MTPDchannelAdminLogEventsFilter::Flags flags, const std::vector<gsl::not_null<UserData*>> &admins) {
|
||||||
|
@ -88,7 +89,7 @@ int FixedBar::resizeGetHeight(int newWidth) {
|
||||||
auto newHeight = 0;
|
auto newHeight = 0;
|
||||||
|
|
||||||
auto buttonLeft = newWidth;
|
auto buttonLeft = newWidth;
|
||||||
buttonLeft -= _filter->width(); _filter->moveToLeft(buttonLeft, 0);
|
//buttonLeft -= _filter->width(); _filter->moveToLeft(buttonLeft, 0);
|
||||||
_backButton->resizeToWidth(buttonLeft);
|
_backButton->resizeToWidth(buttonLeft);
|
||||||
_backButton->moveToLeft(0, 0);
|
_backButton->moveToLeft(0, 0);
|
||||||
newHeight += _backButton->height();
|
newHeight += _backButton->height();
|
||||||
|
@ -106,6 +107,7 @@ void FixedBar::setAnimatingMode(bool enabled) {
|
||||||
} else {
|
} else {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
showChildren();
|
showChildren();
|
||||||
|
_filter->hide();
|
||||||
}
|
}
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4458,7 +4458,7 @@ HistoryLocation::HistoryLocation(gsl::not_null<HistoryItem*> parent, const Locat
|
||||||
, _data(App::location(coords))
|
, _data(App::location(coords))
|
||||||
, _title(st::msgMinWidth)
|
, _title(st::msgMinWidth)
|
||||||
, _description(st::msgMinWidth)
|
, _description(st::msgMinWidth)
|
||||||
, _link(new LocationClickHandler(coords)) {
|
, _link(MakeShared<LocationClickHandler>(coords)) {
|
||||||
if (!title.isEmpty()) {
|
if (!title.isEmpty()) {
|
||||||
_title.setText(st::webPageTitleStyle, textClean(title), _webpageTitleOptions);
|
_title.setText(st::webPageTitleStyle, textClean(title), _webpageTitleOptions);
|
||||||
}
|
}
|
||||||
|
@ -4474,7 +4474,7 @@ HistoryLocation::HistoryLocation(gsl::not_null<HistoryItem*> parent, const Histo
|
||||||
, _data(other._data)
|
, _data(other._data)
|
||||||
, _title(other._title)
|
, _title(other._title)
|
||||||
, _description(other._description)
|
, _description(other._description)
|
||||||
, _link(new LocationClickHandler(_data->coords)) {
|
, _link(MakeShared<LocationClickHandler>(_data->coords)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryLocation::initDimensions() {
|
void HistoryLocation::initDimensions() {
|
||||||
|
|
|
@ -169,9 +169,9 @@ PluralResult Plural(ushort keyBase, float64 value) {
|
||||||
auto shift = (useNonDefaultPlural ? ChoosePlural : ChoosePluralEn)((integer ? i : -1), i, v, w, f, t);
|
auto shift = (useNonDefaultPlural ? ChoosePlural : ChoosePluralEn)((integer ? i : -1), i, v, w, f, t);
|
||||||
auto string = langpack.getValue(LangKey(keyBase + shift));
|
auto string = langpack.getValue(LangKey(keyBase + shift));
|
||||||
if (i == qCeil(n)) {
|
if (i == qCeil(n)) {
|
||||||
return { string, QString::number(value) };
|
return { string, QString::number(qRound(value)) };
|
||||||
}
|
}
|
||||||
return { string, QString::number(qRound(value)) };
|
return { string, QString::number(value) };
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePluralRules(const QString &languageId) {
|
void UpdatePluralRules(const QString &languageId) {
|
||||||
|
|
Loading…
Reference in New Issue