Slightly improved style of top bar in admin log section.

This commit is contained in:
23rd
2026-01-02 09:45:02 +03:00
parent 34c35ece99
commit 3ac4eefe1d
4 changed files with 124 additions and 6 deletions
@@ -11,12 +11,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/admin_log/history_admin_log_filter.h"
#include "profile/profile_back_button.h"
#include "core/shortcuts.h"
#include "info/profile/info_profile_values.h"
#include "ui/chat/chat_style.h"
#include "ui/controls/swipe_handler.h"
#include "ui/effects/animations.h"
#include "ui/widgets/scroll_area.h"
#include "ui/widgets/shadow.h"
#include "ui/widgets/buttons.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/fields/input_field.h"
#include "ui/ui_utility.h"
#include "apiwrap.h"
@@ -132,6 +134,15 @@ FixedBar::FixedBar(
_searchTimer.setCallback([=] { applySearch(); });
_cancel->hide(anim::type::instant);
_backButton->setSubtext(tr::lng_admin_log_title_all(tr::now));
Info::Profile::NameValue(channel) | rpl::on_next([=](QString name) {
_backButton->setText(name);
}, _backButton->lifetime());
_backButton->setWidget(Ui::CreateChild<Ui::UserpicButton>(
_backButton.get(),
channel,
st::topBarInfoButton));
}
void FixedBar::applyFilter(const FilterValue &value) {
@@ -178,6 +189,7 @@ void FixedBar::searchAnimationCallback() {
_searchShown ? &st::topBarBg : nullptr);
_search->setCursor(
_searchShown ? style::cur_default : style::cur_pointer);
_backButton->setOpacity(1.);
}
resizeToWidth(width());
}
@@ -218,6 +230,7 @@ int FixedBar::resizeGetHeight(int newWidth) {
searchShownLeft,
searchShown);
_search->moveToLeft(searchCurrentLeft, 0);
_backButton->setOpacity(1. - searchShown);
_backButton->resizeToWidth(searchCurrentLeft);
_backButton->moveToLeft(0, 0);
@@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "profile/profile_back_button.h"
//#include "history/view/history_view_top_bar_widget.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "ui/painter.h"
@@ -15,6 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_window.h"
#include "styles/style_profile.h"
#include "styles/style_info.h"
#include "styles/style_chat.h"
#include "styles/style_dialogs.h"
#include <QGraphicsOpacityEffect>
namespace Profile {
@@ -48,22 +51,106 @@ BackButton::BackButton(
void BackButton::setText(const QString &text) {
_text = text;
_cachedWidth = -1;
update();
}
void BackButton::setSubtext(const QString &subtext) {
_subtext = subtext;
_cachedWidth = -1;
update();
}
void BackButton::setWidget(not_null<Ui::RpWidget*> widget) {
_widget = widget;
_widget->setParent(this);
_widget->show();
_widget->move(
st::historyAdminLogTopBarLeft + st::historyAdminLogTopBarUserpicSkip,
(st::profileTopBarHeight - _widget->height()) / 2);
_cachedWidth = -1;
update();
}
void BackButton::setOpacity(float64 opacity) {
_opacity = opacity;
if (_widget) {
if (opacity < 1.) {
if (!_opacityEffect) {
_opacityEffect = Ui::CreateChild<QGraphicsOpacityEffect>(
_widget);
_widget->setGraphicsEffect(_opacityEffect);
}
_opacityEffect->setOpacity(opacity);
} else {
_widget->setGraphicsEffect(nullptr);
_opacityEffect = nullptr;
}
}
update();
}
int BackButton::resizeGetHeight(int newWidth) {
_cachedWidth = -1;
return st::profileTopBarHeight;
}
void BackButton::updateCache() {
if (_cachedWidth == width()) {
return;
}
_cachedWidth = width();
const auto widgetWidth = _widget
? _widget->width() + st::historyAdminLogTopBarUserpicSkip
: 0;
const auto availableWidth = width()
- st::historyAdminLogTopBarLeft
- widgetWidth;
_cachedElidedText = st::semiboldFont->elided(
_text,
availableWidth);
_cachedElidedSubtext = st::dialogsTextFont->elided(
_subtext,
availableWidth);
}
void BackButton::paintEvent(QPaintEvent *e) {
Painter p(this);
updateCache();
auto p = Painter(this);
p.setOpacity(_opacity);
p.fillRect(e->rect(), st::profileBg);
st::topBarBack.paint(p, (st::topBarArrowPadding.left() - st::topBarBack.width()) / 2, (st::topBarHeight - st::topBarBack.height()) / 2, width());
st::topBarBack.paint(
p,
st::historyAdminLogTopBarLeft,
(st::topBarHeight - st::topBarBack.height()) / 2,
width());
p.setFont(st::topBarButton.style.font);
p.setPen(st::topBarButton.textFg);
p.drawTextLeft(st::topBarArrowPadding.left(), st::topBarButton.padding.top() + st::topBarButton.textTop, width(), _text);
const auto textHeight = st::semiboldFont->height;
const auto subtextHeight = st::dialogsTextFont->height;
const auto totalHeight = _subtext.isEmpty()
? textHeight
: textHeight + subtextHeight;
const auto startY = (height() - totalHeight) / 2 - st::lineWidth;
const auto widgetWidth = _widget
? _widget->width() + st::historyAdminLogTopBarUserpicSkip
: 0;
const auto textX = st::historyAdminLogTopBarLeft + widgetWidth;
p.setFont(st::semiboldFont);
p.setPen(st::dialogsNameFg);
p.drawTextLeft(textX, startY, width(), _cachedElidedText);
if (!_subtext.isEmpty()) {
p.setFont(st::dialogsTextFont);
p.setPen(st::historyStatusFg);
p.drawTextLeft(
textX,
startY + textHeight + st::lineWidth * 2,
width(),
_cachedElidedSubtext);
}
}
void BackButton::onStateChanged(State was, StateChangeSource source) {
@@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/abstract_button.h"
class QGraphicsOpacityEffect;
namespace Main {
class Session;
} // namespace Main
@@ -24,6 +26,9 @@ public:
rpl::producer<bool> oneColumnValue);
void setText(const QString &text);
void setSubtext(const QString &subtext);
void setWidget(not_null<Ui::RpWidget*> widget);
void setOpacity(float64 opacity);
protected:
void paintEvent(QPaintEvent *e) override;
@@ -32,10 +37,21 @@ protected:
void onStateChanged(State was, StateChangeSource source) override;
private:
void updateCache();
const not_null<Main::Session*> _session;
rpl::lifetime _unreadBadgeLifetime;
QString _text;
QString _subtext;
Ui::RpWidget *_widget = nullptr;
int _cachedWidth = -1;
QString _cachedElidedText;
QString _cachedElidedSubtext;
float64 _opacity = 1.0;
QGraphicsOpacityEffect *_opacityEffect = nullptr;
};
+2
View File
@@ -582,6 +582,8 @@ historyAdminLogCancelSearch: CrossButton {
}
historyAdminLogSearchTop: 11px;
historyAdminLogSearchSlideDuration: 150;
historyAdminLogTopBarLeft: 17px;
historyAdminLogTopBarUserpicSkip: 35px;
historyAdminLogWhatIsThis: IconButton(historyAttach) {
icon: icon {{ "menu/faq", windowActiveTextFg }};
iconOver: icon {{ "menu/faq", windowActiveTextFg }};