mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Improve scheduled messages top bar.
This commit is contained in:
parent
ea0a616453
commit
99037d3d46
6 changed files with 43 additions and 30 deletions
|
@ -1259,6 +1259,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_saved_short" = "Save";
|
||||
"lng_saved_forward_here" = "Forward messages here for quick access";
|
||||
|
||||
"lng_scheduled_messages" = "Scheduled Messages";
|
||||
|
||||
"lng_archived_name" = "Archived chats";
|
||||
"lng_archived_add" = "Archive";
|
||||
"lng_archived_remove" = "Unarchive";
|
||||
|
|
|
@ -444,7 +444,9 @@ void Widget::refreshFolderTopBar() {
|
|||
_folderTopBar.create(this, controller());
|
||||
updateControlsGeometry();
|
||||
}
|
||||
_folderTopBar->setActiveChat(_openedFolder);
|
||||
_folderTopBar->setActiveChat(
|
||||
_openedFolder,
|
||||
HistoryView::TopBarWidget::Section::History);
|
||||
} else {
|
||||
_folderTopBar.destroy();
|
||||
}
|
||||
|
|
|
@ -1761,7 +1761,9 @@ void HistoryWidget::showHistory(
|
|||
_migrated->clear(History::ClearType::Unload);
|
||||
}
|
||||
|
||||
_topBar->setActiveChat(_history);
|
||||
_topBar->setActiveChat(
|
||||
_history,
|
||||
HistoryView::TopBarWidget::Section::History);
|
||||
updateTopBarSelection();
|
||||
|
||||
if (_channel) {
|
||||
|
@ -1837,7 +1839,9 @@ void HistoryWidget::showHistory(
|
|||
}
|
||||
unreadCountUpdated(); // set _historyDown badge.
|
||||
} else {
|
||||
_topBar->setActiveChat(Dialogs::Key());
|
||||
_topBar->setActiveChat(
|
||||
Dialogs::Key(),
|
||||
HistoryView::TopBarWidget::Section::History);
|
||||
updateTopBarSelection();
|
||||
|
||||
clearFieldText();
|
||||
|
|
|
@ -50,7 +50,7 @@ ScheduledWidget::ScheduledWidget(
|
|||
, _topBar(this, controller)
|
||||
, _topBarShadow(this)
|
||||
, _scrollDown(_scroll, st::historyToDown) {
|
||||
_topBar->setActiveChat(_history);
|
||||
_topBar->setActiveChat(_history, TopBarWidget::Section::Scheduled);
|
||||
|
||||
_topBar->move(0, 0);
|
||||
_topBar->resizeToWidth(width());
|
||||
|
@ -200,6 +200,7 @@ Dialogs::RowDescriptor ScheduledWidget::activeChat() const {
|
|||
}
|
||||
|
||||
QPixmap ScheduledWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) {
|
||||
_topBar->updateControlsVisibility();
|
||||
if (params.withTopBarShadow) _topBarShadow->hide();
|
||||
auto result = Ui::GrabWidget(this);
|
||||
if (params.withTopBarShadow) _topBarShadow->show();
|
||||
|
@ -315,7 +316,9 @@ void ScheduledWidget::updateInnerVisibleArea() {
|
|||
void ScheduledWidget::showAnimatedHook(
|
||||
const Window::SectionSlideParams ¶ms) {
|
||||
_topBar->setAnimatingMode(true);
|
||||
if (params.withTopBarShadow) _topBarShadow->show();
|
||||
if (params.withTopBarShadow) {
|
||||
_topBarShadow->show();
|
||||
}
|
||||
}
|
||||
|
||||
void ScheduledWidget::showFinishedHook() {
|
||||
|
|
|
@ -313,23 +313,17 @@ void TopBarWidget::paintTopBar(Painter &p) {
|
|||
auto statustop = st::topBarHeight - st::topBarArrowPadding.bottom() - st::dialogsTextFont->height;
|
||||
auto availableWidth = width() - _rightTaken - nameleft;
|
||||
|
||||
auto history = _activeChat.history();
|
||||
|
||||
if (const auto folder = _activeChat.folder()) {
|
||||
auto text = folder->chatListName(); // TODO feed name emoji
|
||||
const auto textWidth = st::historySavedFont->width(text);
|
||||
if (availableWidth < textWidth) {
|
||||
text = st::historySavedFont->elided(text, availableWidth);
|
||||
}
|
||||
p.setPen(st::dialogsNameFg);
|
||||
p.setFont(st::historySavedFont);
|
||||
p.drawTextLeft(
|
||||
nameleft,
|
||||
(height() - st::historySavedFont->height) / 2,
|
||||
width(),
|
||||
text);
|
||||
} else if (_activeChat.peer()->isSelf()) {
|
||||
auto text = tr::lng_saved_messages(tr::now);
|
||||
const auto history = _activeChat.history();
|
||||
const auto folder = _activeChat.folder();
|
||||
if (folder
|
||||
|| history->peer->isSelf()
|
||||
|| (_section == Section::Scheduled)) {
|
||||
// #TODO feed name emoji.
|
||||
auto text = (_section == Section::Scheduled)
|
||||
? tr::lng_scheduled_messages(tr::now)
|
||||
: folder
|
||||
? folder->chatListName()
|
||||
: tr::lng_saved_messages(tr::now);
|
||||
const auto textWidth = st::historySavedFont->width(text);
|
||||
if (availableWidth < textWidth) {
|
||||
text = st::historySavedFont->elided(text, availableWidth);
|
||||
|
@ -468,11 +462,12 @@ void TopBarWidget::backClicked() {
|
|||
}
|
||||
}
|
||||
|
||||
void TopBarWidget::setActiveChat(Dialogs::Key chat) {
|
||||
if (_activeChat == chat) {
|
||||
void TopBarWidget::setActiveChat(Dialogs::Key chat, Section section) {
|
||||
if (_activeChat == chat && _section == section) {
|
||||
return;
|
||||
}
|
||||
_activeChat = chat;
|
||||
_section = section;
|
||||
_back->clearState();
|
||||
update();
|
||||
|
||||
|
@ -611,11 +606,13 @@ void TopBarWidget::updateControlsVisibility() {
|
|||
if (_unreadBadge) {
|
||||
_unreadBadge->show();
|
||||
}
|
||||
const auto historyMode = (_section == Section::History);
|
||||
const auto smallDialogsColumn = _activeChat.folder()
|
||||
&& (width() < _back->width() + _search->width());
|
||||
_search->setVisible(!smallDialogsColumn);
|
||||
_menuToggle->setVisible(!_activeChat.folder());
|
||||
_infoToggle->setVisible(!_activeChat.folder()
|
||||
_search->setVisible(historyMode && !smallDialogsColumn);
|
||||
_menuToggle->setVisible(historyMode && !_activeChat.folder());
|
||||
_infoToggle->setVisible(historyMode
|
||||
&& !_activeChat.folder()
|
||||
&& !Adaptive::OneColumn()
|
||||
&& _controller->canShowThirdSection());
|
||||
const auto callsEnabled = [&] {
|
||||
|
@ -626,7 +623,7 @@ void TopBarWidget::updateControlsVisibility() {
|
|||
}
|
||||
return false;
|
||||
}();
|
||||
_call->setVisible(callsEnabled);
|
||||
_call->setVisible(historyMode && callsEnabled);
|
||||
|
||||
if (_membersShowArea) {
|
||||
_membersShowArea->show();
|
||||
|
|
|
@ -39,6 +39,10 @@ public:
|
|||
int canDeleteCount = 0;
|
||||
int canForwardCount = 0;
|
||||
};
|
||||
enum class Section {
|
||||
History,
|
||||
Scheduled,
|
||||
};
|
||||
|
||||
TopBarWidget(
|
||||
QWidget *parent,
|
||||
|
@ -55,7 +59,7 @@ public:
|
|||
}
|
||||
void setAnimatingMode(bool enabled);
|
||||
|
||||
void setActiveChat(Dialogs::Key chat);
|
||||
void setActiveChat(Dialogs::Key chat, Section section);
|
||||
|
||||
rpl::producer<> forwardSelectionRequest() const {
|
||||
return _forwardSelection.events();
|
||||
|
@ -112,8 +116,9 @@ private:
|
|||
void refreshUnreadBadge();
|
||||
void updateUnreadBadge();
|
||||
|
||||
not_null<Window::SessionController*> _controller;
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
Dialogs::Key _activeChat;
|
||||
Section _section = Section::History;
|
||||
|
||||
int _selectedCount = 0;
|
||||
bool _canDelete = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue