mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Forward bar and unread counter added to top bar in OneColumn layout.
This commit is contained in:
@@ -22,6 +22,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "window/top_bar_widget.h"
|
||||
|
||||
#include "styles/style_history.h"
|
||||
#include "styles/style_window.h"
|
||||
#include "boxes/addcontactbox.h"
|
||||
#include "boxes/confirmbox.h"
|
||||
#include "mainwidget.h"
|
||||
@@ -33,6 +34,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "ui/buttons/icon_button.h"
|
||||
#include "ui/widgets/dropdown_menu.h"
|
||||
#include "ui/flatbutton.h"
|
||||
#include "dialogs/dialogs_layout.h"
|
||||
|
||||
namespace Window {
|
||||
|
||||
@@ -57,6 +59,11 @@ TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
||||
_menuToggle->setClickedCallback([this] { showMenu(); });
|
||||
|
||||
subscribe(Adaptive::Changed(), [this]() { updateAdaptiveLayout(); });
|
||||
if (Adaptive::OneColumn()) {
|
||||
_unreadCounterSubscription = subscribe(Global::RefUnreadCounterUpdate(), [this] {
|
||||
rtlupdate(0, 0, st::titleUnreadCounterRight, st::titleUnreadCounterTop);
|
||||
});
|
||||
}
|
||||
|
||||
setCursor(style::cur_pointer);
|
||||
showAll();
|
||||
@@ -171,8 +178,27 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
|
||||
if (!_search->isHidden()) {
|
||||
decreaseWidth += _search->width();
|
||||
}
|
||||
main()->paintTopBar(p, a_over.current(), decreaseWidth);
|
||||
auto paintCounter = main()->paintTopBar(p, a_over.current(), decreaseWidth);
|
||||
p.restore();
|
||||
|
||||
if (paintCounter) {
|
||||
paintUnreadCounter(p, width());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TopBarWidget::paintUnreadCounter(Painter &p, int outerWidth) {
|
||||
if (!Adaptive::OneColumn()) {
|
||||
return;
|
||||
}
|
||||
if (auto counter = App::histories().unreadBadge()) {
|
||||
auto counterText = (counter > 99) ? qsl("..%1").arg(counter % 100) : QString::number(counter);
|
||||
Dialogs::Layout::UnreadBadgeStyle unreadSt;
|
||||
unreadSt.muted = App::histories().unreadOnlyMuted();
|
||||
auto unreadRight = st::titleUnreadCounterRight;
|
||||
if (rtl()) unreadRight = outerWidth - st::titleUnreadCounterRight;
|
||||
auto unreadTop = st::titleUnreadCounterTop;
|
||||
Dialogs::Layout::paintUnreadCount(p, counterText, unreadRight, unreadTop, unreadSt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +342,13 @@ void TopBarWidget::showSelected(uint32 selCount, bool canDelete) {
|
||||
void TopBarWidget::updateAdaptiveLayout() {
|
||||
updateMembersShowArea();
|
||||
showAll();
|
||||
if (!Adaptive::OneColumn()) {
|
||||
unsubscribe(base::take(_unreadCounterSubscription));
|
||||
} else if (!_unreadCounterSubscription) {
|
||||
_unreadCounterSubscription = subscribe(Global::RefUnreadCounterUpdate(), [this] {
|
||||
rtlupdate(0, 0, st::titleUnreadCounterRight, st::titleUnreadCounterTop);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ui::RoundButton *TopBarWidget::mediaTypeButton() {
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
Ui::RoundButton *mediaTypeButton();
|
||||
|
||||
static void paintUnreadCounter(Painter &p, int outerWidth);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||
|
||||
@@ -94,6 +96,8 @@ private:
|
||||
|
||||
ChildWidget<TWidget> _membersShowArea = { nullptr };
|
||||
|
||||
int _unreadCounterSubscription = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Window
|
||||
|
||||
@@ -82,6 +82,11 @@ notifySendReply: IconButton {
|
||||
iconPositionDown: point(0px, 1px);
|
||||
}
|
||||
|
||||
titleUnreadCounterTop: 5px;
|
||||
titleUnreadCounterRight: 35px;
|
||||
|
||||
// Windows specific title
|
||||
|
||||
titleHeight: 21px;
|
||||
titleButtonMinimize: IconButton {
|
||||
width: 24px;
|
||||
|
||||
Reference in New Issue
Block a user