Removed Adaptive namespace from sections.

This commit is contained in:
23rd 2021-05-27 00:04:18 +03:00
parent 019fd83c8a
commit 7cf79e1f8a
6 changed files with 55 additions and 34 deletions

View file

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwindow.h" #include "mainwindow.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "base/timer.h" #include "base/timer.h"
@ -295,8 +296,14 @@ Widget::Widget(
_fixedBar->show(); _fixedBar->show();
_fixedBarShadow->raise(); _fixedBarShadow->raise();
updateAdaptiveLayout();
subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); }); rpl::single(
rpl::empty_value()
) | rpl::then(
controller->adaptive().changed()
) | rpl::start_with_next([=] {
updateAdaptiveLayout();
}, lifetime());
_inner = _scroll->setOwnedWidget(object_ptr<InnerWidget>(this, controller, channel)); _inner = _scroll->setOwnedWidget(object_ptr<InnerWidget>(this, controller, channel));
_inner->showSearchSignal( _inner->showSearchSignal(
@ -334,7 +341,11 @@ void Widget::showFilter() {
} }
void Widget::updateAdaptiveLayout() { void Widget::updateAdaptiveLayout() {
_fixedBarShadow->moveToLeft(Adaptive::OneColumn() ? 0 : st::lineWidth, _fixedBar->height()); _fixedBarShadow->moveToLeft(
controller()->adaptive().isOneColumn()
? 0
: st::lineWidth,
_fixedBar->height());
} }
not_null<ChannelData*> Widget::channel() const { not_null<ChannelData*> Widget::channel() const {

View file

@ -30,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/stickers/data_stickers.h" #include "data/stickers/data_stickers.h"
#include "data/data_web_page.h" #include "data/data_web_page.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "facades.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "history/history.h" #include "history/history.h"
@ -52,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/controls/emoji_button.h" #include "ui/controls/emoji_button.h"
#include "ui/controls/send_button.h" #include "ui/controls/send_button.h"
#include "ui/special_buttons.h" #include "ui/special_buttons.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -1919,7 +1919,8 @@ void ComposeControls::toggleTabbedSelectorMode() {
return; return;
} }
if (_tabbedPanel) { if (_tabbedPanel) {
if (_window->canShowThirdSection() && !Adaptive::OneColumn()) { if (_window->canShowThirdSection()
&& !_window->adaptive().isOneColumn()) {
Core::App().settings().setTabbedSelectorSectionEnabled(true); Core::App().settings().setTabbedSelectorSectionEnabled(true);
Core::App().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
pushTabbedSelectorToThirdSection( pushTabbedSelectorToThirdSection(

View file

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/click_handler_types.h" #include "core/click_handler_types.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "layout.h" #include "layout.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "main/main_session.h" #include "main/main_session.h"
@ -2504,7 +2505,7 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
if (!urls.isEmpty()) { if (!urls.isEmpty()) {
mimeData->setUrls(urls); mimeData->setUrls(urls);
} }
if (uponSelected && !Adaptive::OneColumn()) { if (uponSelected && !_controller->adaptive().isOneColumn()) {
const auto canForwardAll = [&] { const auto canForwardAll = [&] {
for (const auto &[itemId, data] : _selected) { for (const auto &[itemId, data] : _selected) {
if (!data.canForward) { if (!data.canForward) {

View file

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toasts/common_toasts.h" #include "ui/toasts/common_toasts.h"
#include "base/timer_rpl.h" #include "base/timer_rpl.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "base/event_filter.h" #include "base/event_filter.h"
@ -127,8 +128,13 @@ PinnedWidget::PinnedWidget(
}, _topBar->lifetime()); }, _topBar->lifetime());
_topBarShadow->raise(); _topBarShadow->raise();
updateAdaptiveLayout(); rpl::single(
subscribe(Adaptive::Changed(), [=] { updateAdaptiveLayout(); }); rpl::empty_value()
) | rpl::then(
controller->adaptive().changed()
) | rpl::start_with_next([=] {
updateAdaptiveLayout();
}, lifetime());
_inner = _scroll->setOwnedWidget(object_ptr<ListWidget>( _inner = _scroll->setOwnedWidget(object_ptr<ListWidget>(
this, this,
@ -297,7 +303,7 @@ void PinnedWidget::scrollDownAnimationFinish() {
void PinnedWidget::updateAdaptiveLayout() { void PinnedWidget::updateAdaptiveLayout() {
_topBarShadow->moveToLeft( _topBarShadow->moveToLeft(
Adaptive::OneColumn() ? 0 : st::lineWidth, controller()->adaptive().isOneColumn() ? 0 : st::lineWidth,
_topBar->height()); _topBar->height());
} }
@ -387,12 +393,9 @@ void PinnedWidget::resizeEvent(QResizeEvent *e) {
void PinnedWidget::recountChatWidth() { void PinnedWidget::recountChatWidth() {
auto layout = (width() < st::adaptiveChatWideWidth) auto layout = (width() < st::adaptiveChatWideWidth)
? Adaptive::ChatLayout::Normal ? Window::AdaptiveModern::ChatLayout::Normal
: Adaptive::ChatLayout::Wide; : Window::AdaptiveModern::ChatLayout::Wide;
if (layout != Global::AdaptiveChatLayout()) { controller()->adaptive().setChatLayout(layout);
Global::SetAdaptiveChatLayout(layout);
Adaptive::Changed().notify(true);
}
} }
void PinnedWidget::setMessagesCount(int count) { void PinnedWidget::setMessagesCount(int count) {

View file

@ -39,6 +39,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/edit_caption_box.h" #include "boxes/edit_caption_box.h"
#include "boxes/send_files_box.h" #include "boxes/send_files_box.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "base/event_filter.h" #include "base/event_filter.h"
@ -191,8 +192,14 @@ RepliesWidget::RepliesWidget(
_rootView->raise(); _rootView->raise();
_topBarShadow->raise(); _topBarShadow->raise();
updateAdaptiveLayout();
subscribe(Adaptive::Changed(), [=] { updateAdaptiveLayout(); }); rpl::single(
rpl::empty_value()
) | rpl::then(
controller->adaptive().changed()
) | rpl::start_with_next([=] {
updateAdaptiveLayout();
}, lifetime());
_inner = _scroll->setOwnedWidget(object_ptr<ListWidget>( _inner = _scroll->setOwnedWidget(object_ptr<ListWidget>(
this, this,
@ -327,13 +334,8 @@ void RepliesWidget::setupRootView() {
}); });
_rootView = std::make_unique<Ui::PinnedBar>(this, std::move(content)); _rootView = std::make_unique<Ui::PinnedBar>(this, std::move(content));
rpl::single( controller()->adaptive().oneColumnValue(
rpl::empty_value() ) | rpl::start_with_next([=](bool one) {
) | rpl::then(
base::ObservableViewer(Adaptive::Changed())
) | rpl::map([] {
return Adaptive::OneColumn();
}) | rpl::start_with_next([=](bool one) {
_rootView->setShadowGeometryPostprocess([=](QRect geometry) { _rootView->setShadowGeometryPostprocess([=](QRect geometry) {
if (!one) { if (!one) {
geometry.setLeft(geometry.left() + st::lineWidth); geometry.setLeft(geometry.left() + st::lineWidth);
@ -1284,7 +1286,7 @@ void RepliesWidget::scrollDownAnimationFinish() {
void RepliesWidget::updateAdaptiveLayout() { void RepliesWidget::updateAdaptiveLayout() {
_topBarShadow->moveToLeft( _topBarShadow->moveToLeft(
Adaptive::OneColumn() ? 0 : st::lineWidth, controller()->adaptive().isOneColumn() ? 0 : st::lineWidth,
_topBar->height()); _topBar->height());
} }
@ -1462,12 +1464,9 @@ void RepliesWidget::resizeEvent(QResizeEvent *e) {
void RepliesWidget::recountChatWidth() { void RepliesWidget::recountChatWidth() {
auto layout = (width() < st::adaptiveChatWideWidth) auto layout = (width() < st::adaptiveChatWideWidth)
? Adaptive::ChatLayout::Normal ? Window::AdaptiveModern::ChatLayout::Normal
: Adaptive::ChatLayout::Wide; : Window::AdaptiveModern::ChatLayout::Wide;
if (layout != Global::AdaptiveChatLayout()) { controller()->adaptive().setChatLayout(layout);
Global::SetAdaptiveChatLayout(layout);
Adaptive::Changed().notify(true);
}
} }
void RepliesWidget::updateControlsGeometry() { void RepliesWidget::updateControlsGeometry() {

View file

@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/edit_caption_box.h" #include "boxes/edit_caption_box.h"
#include "boxes/send_files_box.h" #include "boxes/send_files_box.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "base/event_filter.h" #include "base/event_filter.h"
@ -125,8 +126,13 @@ ScheduledWidget::ScheduledWidget(
}, _topBar->lifetime()); }, _topBar->lifetime());
_topBarShadow->raise(); _topBarShadow->raise();
updateAdaptiveLayout(); rpl::single(
subscribe(Adaptive::Changed(), [=] { updateAdaptiveLayout(); }); rpl::empty_value()
) | rpl::then(
controller->adaptive().changed()
) | rpl::start_with_next([=] {
updateAdaptiveLayout();
}, lifetime());
_inner = _scroll->setOwnedWidget(object_ptr<ListWidget>( _inner = _scroll->setOwnedWidget(object_ptr<ListWidget>(
this, this,
@ -855,7 +861,7 @@ void ScheduledWidget::scrollDownAnimationFinish() {
void ScheduledWidget::updateAdaptiveLayout() { void ScheduledWidget::updateAdaptiveLayout() {
_topBarShadow->moveToLeft( _topBarShadow->moveToLeft(
Adaptive::OneColumn() ? 0 : st::lineWidth, controller()->adaptive().isOneColumn() ? 0 : st::lineWidth,
_topBar->height()); _topBar->height());
} }