mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Removed Adaptive namespace from Window::Controller and MainWidget.
This commit is contained in:
parent
824fbc21e8
commit
80fe2f57e9
7 changed files with 76 additions and 70 deletions
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/info_section_widget.h"
|
#include "info/info_section_widget.h"
|
||||||
|
|
||||||
|
#include "window/window_adaptive.h"
|
||||||
#include "window/window_connecting_widget.h"
|
#include "window/window_connecting_widget.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -51,7 +52,7 @@ void SectionWidget::init() {
|
||||||
_connecting = std::make_unique<Window::ConnectionState>(
|
_connecting = std::make_unique<Window::ConnectionState>(
|
||||||
_content.data(),
|
_content.data(),
|
||||||
&controller()->session().account(),
|
&controller()->session().account(),
|
||||||
Window::AdaptiveIsOneColumn());
|
controller()->adaptive().oneColumnValue());
|
||||||
|
|
||||||
_content->contentChanged(
|
_content->contentChanged(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
|
|
@ -380,10 +380,13 @@ MainWidget::MainWidget(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
subscribe(Adaptive::Changed(), [this]() { handleAdaptiveLayoutUpdate(); });
|
_controller->adaptive().changed(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
handleAdaptiveLayoutUpdate();
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
_dialogs->show();
|
_dialogs->show();
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
_history->hide();
|
_history->hide();
|
||||||
} else {
|
} else {
|
||||||
_history->show();
|
_history->show();
|
||||||
|
@ -416,7 +419,7 @@ void MainWidget::setupConnectingWidget() {
|
||||||
_connecting = std::make_unique<Window::ConnectionState>(
|
_connecting = std::make_unique<Window::ConnectionState>(
|
||||||
this,
|
this,
|
||||||
&session().account(),
|
&session().account(),
|
||||||
Window::AdaptiveIsOneColumn() | rpl::map(!_1));
|
_controller->adaptive().oneColumnValue() | rpl::map(!_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<Media::Player::FloatDelegate*> MainWidget::floatPlayerDelegate() {
|
not_null<Media::Player::FloatDelegate*> MainWidget::floatPlayerDelegate() {
|
||||||
|
@ -429,7 +432,7 @@ not_null<Ui::RpWidget*> MainWidget::floatPlayerWidget() {
|
||||||
|
|
||||||
auto MainWidget::floatPlayerGetSection(Window::Column column)
|
auto MainWidget::floatPlayerGetSection(Window::Column column)
|
||||||
-> not_null<Media::Player::FloatSectionDelegate*> {
|
-> not_null<Media::Player::FloatSectionDelegate*> {
|
||||||
if (Adaptive::ThreeColumn()) {
|
if (isThreeColumn()) {
|
||||||
if (column == Window::Column::First) {
|
if (column == Window::Column::First) {
|
||||||
return _dialogs;
|
return _dialogs;
|
||||||
} else if (column == Window::Column::Second
|
} else if (column == Window::Column::Second
|
||||||
|
@ -440,7 +443,7 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
|
||||||
return _history;
|
return _history;
|
||||||
}
|
}
|
||||||
return _thirdSection;
|
return _thirdSection;
|
||||||
} else if (Adaptive::Normal()) {
|
} else if (isNormalColumn()) {
|
||||||
if (column == Window::Column::First) {
|
if (column == Window::Column::First) {
|
||||||
return _dialogs;
|
return _dialogs;
|
||||||
} else if (_mainSection) {
|
} else if (_mainSection) {
|
||||||
|
@ -448,11 +451,11 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
|
||||||
}
|
}
|
||||||
return _history;
|
return _history;
|
||||||
}
|
}
|
||||||
if (Adaptive::OneColumn() && selectingPeer()) {
|
if (isOneColumn() && selectingPeer()) {
|
||||||
return _dialogs;
|
return _dialogs;
|
||||||
} else if (_mainSection) {
|
} else if (_mainSection) {
|
||||||
return _mainSection;
|
return _mainSection;
|
||||||
} else if (!Adaptive::OneColumn() || _history->peer()) {
|
} else if (!isOneColumn() || _history->peer()) {
|
||||||
return _history;
|
return _history;
|
||||||
}
|
}
|
||||||
return _dialogs;
|
return _dialogs;
|
||||||
|
@ -461,7 +464,7 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
|
||||||
void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
||||||
not_null<Media::Player::FloatSectionDelegate*> widget,
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||||
Window::Column widgetColumn)> callback) {
|
Window::Column widgetColumn)> callback) {
|
||||||
if (Adaptive::ThreeColumn()) {
|
if (isThreeColumn()) {
|
||||||
callback(_dialogs, Window::Column::First);
|
callback(_dialogs, Window::Column::First);
|
||||||
if (_mainSection) {
|
if (_mainSection) {
|
||||||
callback(_mainSection, Window::Column::Second);
|
callback(_mainSection, Window::Column::Second);
|
||||||
|
@ -471,7 +474,7 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
||||||
if (_thirdSection) {
|
if (_thirdSection) {
|
||||||
callback(_thirdSection, Window::Column::Third);
|
callback(_thirdSection, Window::Column::Third);
|
||||||
}
|
}
|
||||||
} else if (Adaptive::Normal()) {
|
} else if (isNormalColumn()) {
|
||||||
callback(_dialogs, Window::Column::First);
|
callback(_dialogs, Window::Column::First);
|
||||||
if (_mainSection) {
|
if (_mainSection) {
|
||||||
callback(_mainSection, Window::Column::Second);
|
callback(_mainSection, Window::Column::Second);
|
||||||
|
@ -479,11 +482,11 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
||||||
callback(_history, Window::Column::Second);
|
callback(_history, Window::Column::Second);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Adaptive::OneColumn() && selectingPeer()) {
|
if (isOneColumn() && selectingPeer()) {
|
||||||
callback(_dialogs, Window::Column::First);
|
callback(_dialogs, Window::Column::First);
|
||||||
} else if (_mainSection) {
|
} else if (_mainSection) {
|
||||||
callback(_mainSection, Window::Column::Second);
|
callback(_mainSection, Window::Column::Second);
|
||||||
} else if (!Adaptive::OneColumn() || _history->peer()) {
|
} else if (!isOneColumn() || _history->peer()) {
|
||||||
callback(_history, Window::Column::Second);
|
callback(_history, Window::Column::Second);
|
||||||
} else {
|
} else {
|
||||||
callback(_dialogs, Window::Column::First);
|
callback(_dialogs, Window::Column::First);
|
||||||
|
@ -645,7 +648,7 @@ void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
|
||||||
_hider.release();
|
_hider.release();
|
||||||
controller()->setSelectingPeer(false);
|
controller()->setSelectingPeer(false);
|
||||||
|
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
if (_mainSection || (_history->peer() && _history->peer()->id)) {
|
if (_mainSection || (_history->peer() && _history->peer()->id)) {
|
||||||
auto animationParams = ([=] {
|
auto animationParams = ([=] {
|
||||||
if (_mainSection) {
|
if (_mainSection) {
|
||||||
|
@ -693,7 +696,7 @@ void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) {
|
||||||
_dialogs->onCancelSearch();
|
_dialogs->onCancelSearch();
|
||||||
}, _hider->lifetime());
|
}, _hider->lifetime());
|
||||||
|
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
dialogsToUp();
|
dialogsToUp();
|
||||||
|
|
||||||
_hider->hide();
|
_hider->hide();
|
||||||
|
@ -873,7 +876,7 @@ bool MainWidget::insertBotCommand(const QString &cmd) {
|
||||||
|
|
||||||
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
|
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
|
||||||
_dialogs->searchMessages(query, inChat);
|
_dialogs->searchMessages(query, inChat);
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
Ui::showChatsList(&session());
|
Ui::showChatsList(&session());
|
||||||
} else {
|
} else {
|
||||||
_dialogs->setInnerFocus();
|
_dialogs->setInnerFocus();
|
||||||
|
@ -1541,18 +1544,18 @@ void MainWidget::ui_showPeerHistory(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!peerId) {
|
if (!peerId) {
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
return _dialogs->isHidden();
|
return _dialogs->isHidden();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_history->isHidden()) {
|
if (_history->isHidden()) {
|
||||||
if (!Adaptive::OneColumn() && way == Way::ClearStack) {
|
if (!isOneColumn() && way == Way::ClearStack) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (_mainSection != nullptr)
|
return (_mainSection != nullptr)
|
||||||
|| (Adaptive::OneColumn() && !_dialogs->isHidden());
|
|| (isOneColumn() && !_dialogs->isHidden());
|
||||||
}
|
}
|
||||||
if (back || way == Way::Forward) {
|
if (back || way == Way::Forward) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1573,7 +1576,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
_history->showHistory(peerId, showAtMsgId);
|
_history->showHistory(peerId, showAtMsgId);
|
||||||
|
|
||||||
auto noPeer = !_history->peer();
|
auto noPeer = !_history->peer();
|
||||||
auto onlyDialogs = noPeer && Adaptive::OneColumn();
|
auto onlyDialogs = noPeer && isOneColumn();
|
||||||
_mainSection.destroy();
|
_mainSection.destroy();
|
||||||
|
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
@ -1597,7 +1600,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
if (nowActivePeer && nowActivePeer != wasActivePeer) {
|
if (nowActivePeer && nowActivePeer != wasActivePeer) {
|
||||||
_viewsIncremented.remove(nowActivePeer);
|
_viewsIncremented.remove(nowActivePeer);
|
||||||
}
|
}
|
||||||
if (Adaptive::OneColumn() && !_dialogs->isHidden()) {
|
if (isOneColumn() && !_dialogs->isHidden()) {
|
||||||
_dialogs->hide();
|
_dialogs->hide();
|
||||||
}
|
}
|
||||||
if (!_a_show.animating()) {
|
if (!_a_show.animating()) {
|
||||||
|
@ -1711,7 +1714,7 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation(
|
||||||
bool willHaveTopBarShadow) {
|
bool willHaveTopBarShadow) {
|
||||||
Window::SectionSlideParams result;
|
Window::SectionSlideParams result;
|
||||||
result.withTopBarShadow = willHaveTopBarShadow;
|
result.withTopBarShadow = willHaveTopBarShadow;
|
||||||
if (selectingPeer() && Adaptive::OneColumn()) {
|
if (selectingPeer() && isOneColumn()) {
|
||||||
result.withTopBarShadow = false;
|
result.withTopBarShadow = false;
|
||||||
} else if (_mainSection) {
|
} else if (_mainSection) {
|
||||||
if (!_mainSection->hasTopBarShadow()) {
|
if (!_mainSection->hasTopBarShadow()) {
|
||||||
|
@ -1735,7 +1738,7 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sectionTop = getMainSectionTop();
|
auto sectionTop = getMainSectionTop();
|
||||||
if (selectingPeer() && Adaptive::OneColumn()) {
|
if (selectingPeer() && isOneColumn()) {
|
||||||
result.oldContentCache = Ui::GrabWidget(this, QRect(
|
result.oldContentCache = Ui::GrabWidget(this, QRect(
|
||||||
0,
|
0,
|
||||||
sectionTop,
|
sectionTop,
|
||||||
|
@ -1743,7 +1746,7 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation(
|
||||||
height() - sectionTop));
|
height() - sectionTop));
|
||||||
} else if (_mainSection) {
|
} else if (_mainSection) {
|
||||||
result.oldContentCache = _mainSection->grabForShowAnimation(result);
|
result.oldContentCache = _mainSection->grabForShowAnimation(result);
|
||||||
} else if (!Adaptive::OneColumn() || !_history->isHidden()) {
|
} else if (!isOneColumn() || !_history->isHidden()) {
|
||||||
result.oldContentCache = _history->grabForShowAnimation(result);
|
result.oldContentCache = _history->grabForShowAnimation(result);
|
||||||
} else {
|
} else {
|
||||||
result.oldContentCache = Ui::GrabWidget(this, QRect(
|
result.oldContentCache = Ui::GrabWidget(this, QRect(
|
||||||
|
@ -1791,7 +1794,7 @@ void MainWidget::showNewSection(
|
||||||
thirdSectionTop,
|
thirdSectionTop,
|
||||||
st::columnMinimalWidthThird,
|
st::columnMinimalWidthThird,
|
||||||
height() - thirdSectionTop);
|
height() - thirdSectionTop);
|
||||||
auto newThirdSection = (Adaptive::ThreeColumn() && params.thirdColumn)
|
auto newThirdSection = (isThreeColumn() && params.thirdColumn)
|
||||||
? memento->createWidget(
|
? memento->createWidget(
|
||||||
this,
|
this,
|
||||||
_controller,
|
_controller,
|
||||||
|
@ -1827,7 +1830,7 @@ void MainWidget::showNewSection(
|
||||||
: memento->createWidget(
|
: memento->createWidget(
|
||||||
this,
|
this,
|
||||||
_controller,
|
_controller,
|
||||||
Adaptive::OneColumn() ? Column::First : Column::Second,
|
isOneColumn() ? Column::First : Column::Second,
|
||||||
newMainGeometry);
|
newMainGeometry);
|
||||||
Assert(newMainSection || newThirdSection);
|
Assert(newMainSection || newThirdSection);
|
||||||
|
|
||||||
|
@ -1838,9 +1841,9 @@ void MainWidget::showNewSection(
|
||||||
|| memento->instant()) {
|
|| memento->instant()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Adaptive::OneColumn() && params.way == SectionShow::Way::ClearStack) {
|
if (!isOneColumn() && params.way == SectionShow::Way::ClearStack) {
|
||||||
return false;
|
return false;
|
||||||
} else if (Adaptive::OneColumn()
|
} else if (isOneColumn()
|
||||||
|| (newThirdSection && _thirdSection)
|
|| (newThirdSection && _thirdSection)
|
||||||
|| (newMainSection && isMainSectionShown())) {
|
|| (newMainSection && isMainSectionShown())) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1876,7 +1879,7 @@ void MainWidget::showNewSection(
|
||||||
_history->finishAnimating();
|
_history->finishAnimating();
|
||||||
_history->showHistory(0, 0);
|
_history->showHistory(0, 0);
|
||||||
_history->hide();
|
_history->hide();
|
||||||
if (Adaptive::OneColumn()) _dialogs->hide();
|
if (isOneColumn()) _dialogs->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animationParams) {
|
if (animationParams) {
|
||||||
|
@ -1884,7 +1887,7 @@ void MainWidget::showNewSection(
|
||||||
auto direction = (back || settingSection->forceAnimateBack())
|
auto direction = (back || settingSection->forceAnimateBack())
|
||||||
? Window::SlideDirection::FromLeft
|
? Window::SlideDirection::FromLeft
|
||||||
: Window::SlideDirection::FromRight;
|
: Window::SlideDirection::FromRight;
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
_controller->removeLayerBlackout();
|
_controller->removeLayerBlackout();
|
||||||
}
|
}
|
||||||
settingSection->showAnimated(direction, animationParams);
|
settingSection->showAnimated(direction, animationParams);
|
||||||
|
@ -2054,7 +2057,7 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sectionTop = getMainSectionTop();
|
auto sectionTop = getMainSectionTop();
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
result = Ui::GrabWidget(this, QRect(
|
result = Ui::GrabWidget(this, QRect(
|
||||||
0,
|
0,
|
||||||
sectionTop,
|
sectionTop,
|
||||||
|
@ -2191,7 +2194,7 @@ void MainWidget::showAll() {
|
||||||
cSetPasswordRecovered(false);
|
cSetPasswordRecovered(false);
|
||||||
Ui::show(Box<InformBox>(tr::lng_signin_password_removed(tr::now)));
|
Ui::show(Box<InformBox>(tr::lng_signin_password_removed(tr::now)));
|
||||||
}
|
}
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
_sideShadow->hide();
|
_sideShadow->hide();
|
||||||
if (_hider) {
|
if (_hider) {
|
||||||
_hider->hide();
|
_hider->hide();
|
||||||
|
@ -2266,7 +2269,7 @@ void MainWidget::updateControlsGeometry() {
|
||||||
if (!_a_dialogsWidth.animating()) {
|
if (!_a_dialogsWidth.animating()) {
|
||||||
_dialogs->stopWidthAnimation();
|
_dialogs->stopWidthAnimation();
|
||||||
}
|
}
|
||||||
if (Adaptive::ThreeColumn()) {
|
if (isThreeColumn()) {
|
||||||
if (!_thirdSection
|
if (!_thirdSection
|
||||||
&& !_controller->takeThirdSectionFromLayer()) {
|
&& !_controller->takeThirdSectionFromLayer()) {
|
||||||
auto params = Window::SectionShow(
|
auto params = Window::SectionShow(
|
||||||
|
@ -2294,7 +2297,7 @@ void MainWidget::updateControlsGeometry() {
|
||||||
}
|
}
|
||||||
auto mainSectionTop = getMainSectionTop();
|
auto mainSectionTop = getMainSectionTop();
|
||||||
auto dialogsWidth = qRound(_a_dialogsWidth.value(_dialogsWidth));
|
auto dialogsWidth = qRound(_a_dialogsWidth.value(_dialogsWidth));
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
if (_callTopBar) {
|
if (_callTopBar) {
|
||||||
_callTopBar->resizeToWidth(dialogsWidth);
|
_callTopBar->resizeToWidth(dialogsWidth);
|
||||||
_callTopBar->moveToLeft(0, 0);
|
_callTopBar->moveToLeft(0, 0);
|
||||||
|
@ -2375,7 +2378,7 @@ void MainWidget::updateControlsGeometry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::refreshResizeAreas() {
|
void MainWidget::refreshResizeAreas() {
|
||||||
if (!Adaptive::OneColumn()) {
|
if (!isOneColumn()) {
|
||||||
ensureFirstColumnResizeAreaCreated();
|
ensureFirstColumnResizeAreaCreated();
|
||||||
_firstColumnResizeArea->setGeometryToLeft(
|
_firstColumnResizeArea->setGeometryToLeft(
|
||||||
_history->x(),
|
_history->x(),
|
||||||
|
@ -2386,7 +2389,7 @@ void MainWidget::refreshResizeAreas() {
|
||||||
_firstColumnResizeArea.destroy();
|
_firstColumnResizeArea.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Adaptive::ThreeColumn() && _thirdSection) {
|
if (isThreeColumn() && _thirdSection) {
|
||||||
ensureThirdColumnResizeAreaCreated();
|
ensureThirdColumnResizeAreaCreated();
|
||||||
_thirdColumnResizeArea->setGeometryToLeft(
|
_thirdColumnResizeArea->setGeometryToLeft(
|
||||||
_thirdSection->x(),
|
_thirdSection->x(),
|
||||||
|
@ -2424,7 +2427,7 @@ void MainWidget::ensureFirstColumnResizeAreaCreated() {
|
||||||
Core::App().settings().setDialogsWidthRatio(newRatio);
|
Core::App().settings().setDialogsWidthRatio(newRatio);
|
||||||
};
|
};
|
||||||
auto moveFinishedCallback = [=] {
|
auto moveFinishedCallback = [=] {
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||||
|
@ -2448,7 +2451,7 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
|
||||||
Core::App().settings().setThirdColumnWidth(newWidth);
|
Core::App().settings().setThirdColumnWidth(newWidth);
|
||||||
};
|
};
|
||||||
auto moveFinishedCallback = [=] {
|
auto moveFinishedCallback = [=] {
|
||||||
if (!Adaptive::ThreeColumn() || !_thirdSection) {
|
if (!isThreeColumn() || !_thirdSection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Core::App().settings().setThirdColumnWidth(std::clamp(
|
Core::App().settings().setThirdColumnWidth(std::clamp(
|
||||||
|
@ -2523,7 +2526,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
||||||
//
|
//
|
||||||
// Like in _controller->showPeerInfo()
|
// Like in _controller->showPeerInfo()
|
||||||
//
|
//
|
||||||
if (Adaptive::ThreeColumn()
|
if (isThreeColumn()
|
||||||
&& !settings.thirdSectionInfoEnabled()) {
|
&& !settings.thirdSectionInfoEnabled()) {
|
||||||
settings.setThirdSectionInfoEnabled(true);
|
settings.setThirdSectionInfoEnabled(true);
|
||||||
Core::App().saveSettingsDelayed();
|
Core::App().saveSettingsDelayed();
|
||||||
|
@ -2539,7 +2542,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
||||||
? _mainSection->pushTabbedSelectorToThirdSection(peer, params)
|
? _mainSection->pushTabbedSelectorToThirdSection(peer, params)
|
||||||
: _history->pushTabbedSelectorToThirdSection(peer, params);
|
: _history->pushTabbedSelectorToThirdSection(peer, params);
|
||||||
};
|
};
|
||||||
if (Adaptive::ThreeColumn()
|
if (isThreeColumn()
|
||||||
&& settings.tabbedSelectorSectionEnabled()
|
&& settings.tabbedSelectorSectionEnabled()
|
||||||
&& key) {
|
&& key) {
|
||||||
if (!canWrite) {
|
if (!canWrite) {
|
||||||
|
@ -2559,7 +2562,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
|
||||||
_thirdShadow.destroy();
|
_thirdShadow.destroy();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
} else if (Adaptive::ThreeColumn()
|
} else if (isThreeColumn()
|
||||||
&& settings.thirdSectionInfoEnabled()) {
|
&& settings.thirdSectionInfoEnabled()) {
|
||||||
switchInfoFast();
|
switchInfoFast();
|
||||||
}
|
}
|
||||||
|
@ -2626,7 +2629,7 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
||||||
|
|
||||||
void MainWidget::handleAdaptiveLayoutUpdate() {
|
void MainWidget::handleAdaptiveLayoutUpdate() {
|
||||||
showAll();
|
showAll();
|
||||||
_sideShadow->setVisible(!Adaptive::OneColumn());
|
_sideShadow->setVisible(!isOneColumn());
|
||||||
if (_player) {
|
if (_player) {
|
||||||
_player->updateAdaptiveLayout();
|
_player->updateAdaptiveLayout();
|
||||||
}
|
}
|
||||||
|
@ -2653,7 +2656,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
|
|
||||||
// Check if we are in a single-column layout in a wide enough window
|
// Check if we are in a single-column layout in a wide enough window
|
||||||
// for the normal layout. If so, switch to the normal layout.
|
// for the normal layout. If so, switch to the normal layout.
|
||||||
if (layout.windowLayout == Adaptive::WindowLayout::OneColumn) {
|
if (layout.windowLayout == Window::AdaptiveModern::WindowLayout::OneColumn) {
|
||||||
auto chatWidth = layout.chatWidth;
|
auto chatWidth = layout.chatWidth;
|
||||||
//if (session().settings().tabbedSelectorSectionEnabled()
|
//if (session().settings().tabbedSelectorSectionEnabled()
|
||||||
// && chatWidth >= _history->minimalWidthForTabbedSelectorSection()) {
|
// && chatWidth >= _history->minimalWidthForTabbedSelectorSection()) {
|
||||||
|
@ -2663,7 +2666,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
+ st::columnMinimalWidthMain;
|
+ st::columnMinimalWidthMain;
|
||||||
if (chatWidth >= minimalNormalWidth) {
|
if (chatWidth >= minimalNormalWidth) {
|
||||||
// Switch layout back to normal in a wide enough window.
|
// Switch layout back to normal in a wide enough window.
|
||||||
layout.windowLayout = Adaptive::WindowLayout::Normal;
|
layout.windowLayout = Window::AdaptiveModern::WindowLayout::Normal;
|
||||||
layout.dialogsWidth = st::columnMinimalWidthLeft;
|
layout.dialogsWidth = st::columnMinimalWidthLeft;
|
||||||
layout.chatWidth = layout.bodyWidth - layout.dialogsWidth;
|
layout.chatWidth = layout.bodyWidth - layout.dialogsWidth;
|
||||||
dialogsWidthRatio = float64(layout.dialogsWidth) / layout.bodyWidth;
|
dialogsWidthRatio = float64(layout.dialogsWidth) / layout.bodyWidth;
|
||||||
|
@ -2673,7 +2676,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
// Check if we are going to create the third column and shrink the
|
// Check if we are going to create the third column and shrink the
|
||||||
// dialogs widget to provide a wide enough chat history column.
|
// dialogs widget to provide a wide enough chat history column.
|
||||||
// Don't shrink the column on the first call, when window is inited.
|
// Don't shrink the column on the first call, when window is inited.
|
||||||
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn
|
if (layout.windowLayout == Window::AdaptiveModern::WindowLayout::ThreeColumn
|
||||||
&& _controller->widget()->positionInited()) {
|
&& _controller->widget()->positionInited()) {
|
||||||
//auto chatWidth = layout.chatWidth;
|
//auto chatWidth = layout.chatWidth;
|
||||||
//if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) {
|
//if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) {
|
||||||
|
@ -2694,17 +2697,14 @@ void MainWidget::updateWindowAdaptiveLayout() {
|
||||||
|
|
||||||
Core::App().settings().setDialogsWidthRatio(dialogsWidthRatio);
|
Core::App().settings().setDialogsWidthRatio(dialogsWidthRatio);
|
||||||
|
|
||||||
auto useSmallColumnWidth = !Adaptive::OneColumn()
|
auto useSmallColumnWidth = !isOneColumn()
|
||||||
&& !dialogsWidthRatio
|
&& !dialogsWidthRatio
|
||||||
&& !_controller->forceWideDialogs();
|
&& !_controller->forceWideDialogs();
|
||||||
_dialogsWidth = useSmallColumnWidth
|
_dialogsWidth = useSmallColumnWidth
|
||||||
? _controller->dialogsSmallColumnWidth()
|
? _controller->dialogsSmallColumnWidth()
|
||||||
: layout.dialogsWidth;
|
: layout.dialogsWidth;
|
||||||
_thirdColumnWidth = layout.thirdWidth;
|
_thirdColumnWidth = layout.thirdWidth;
|
||||||
if (layout.windowLayout != Global::AdaptiveWindowLayout()) {
|
_controller->adaptive().setWindowLayout(layout.windowLayout);
|
||||||
Global::SetAdaptiveWindowLayout(layout.windowLayout);
|
|
||||||
Adaptive::Changed().notify(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MainWidget::backgroundFromY() const {
|
int MainWidget::backgroundFromY() const {
|
||||||
|
@ -2716,7 +2716,7 @@ void MainWidget::searchInChat(Dialogs::Key chat) {
|
||||||
_controller->closeFolder();
|
_controller->closeFolder();
|
||||||
}
|
}
|
||||||
_dialogs->searchInChat(chat);
|
_dialogs->searchInChat(chat);
|
||||||
if (Adaptive::OneColumn()) {
|
if (isOneColumn()) {
|
||||||
Ui::showChatsList(&session());
|
Ui::showChatsList(&session());
|
||||||
} else {
|
} else {
|
||||||
_dialogs->setInnerFocus();
|
_dialogs->setInnerFocus();
|
||||||
|
@ -2778,6 +2778,18 @@ void MainWidget::saveFieldToHistoryLocalDraft() {
|
||||||
_history->saveFieldToHistoryLocalDraft();
|
_history->saveFieldToHistoryLocalDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWidget::isOneColumn() const {
|
||||||
|
return _controller->adaptive().isOneColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWidget::isNormalColumn() const {
|
||||||
|
return _controller->adaptive().isNormal();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MainWidget::isThreeColumn() const {
|
||||||
|
return _controller->adaptive().isThreeColumn();
|
||||||
|
}
|
||||||
|
|
||||||
namespace App {
|
namespace App {
|
||||||
|
|
||||||
MainWidget *main() {
|
MainWidget *main() {
|
||||||
|
|
|
@ -344,6 +344,10 @@ private:
|
||||||
|
|
||||||
void handleHistoryBack();
|
void handleHistoryBack();
|
||||||
|
|
||||||
|
bool isOneColumn() const;
|
||||||
|
bool isNormalColumn() const;
|
||||||
|
bool isThreeColumn() const;
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
|
|
||||||
|
|
|
@ -623,14 +623,4 @@ void ConnectionState::Widget::refreshRetryLink(bool hasRetry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> AdaptiveIsOneColumn() {
|
|
||||||
return rpl::single(
|
|
||||||
Adaptive::OneColumn()
|
|
||||||
) | rpl::then(base::ObservableViewer(
|
|
||||||
Adaptive::Changed()
|
|
||||||
) | rpl::map([] {
|
|
||||||
return Adaptive::OneColumn();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
|
@ -92,6 +92,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
rpl::producer<bool> AdaptiveIsOneColumn();
|
|
||||||
|
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/add_contact_box.h"
|
#include "boxes/add_contact_box.h"
|
||||||
#include "boxes/peers/edit_peer_info_box.h"
|
#include "boxes/peers/edit_peer_info_box.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
|
#include "window/window_adaptive.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/main_window.h"
|
#include "window/main_window.h"
|
||||||
#include "window/window_filters_menu.h"
|
#include "window/window_filters_menu.h"
|
||||||
|
@ -802,7 +803,7 @@ bool SessionController::forceWideDialogs() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
||||||
auto layout = Adaptive::WindowLayout::OneColumn;
|
auto layout = AdaptiveModern::WindowLayout::OneColumn;
|
||||||
|
|
||||||
auto bodyWidth = widget()->bodyWidget()->width() - filtersWidth();
|
auto bodyWidth = widget()->bodyWidget()->width() - filtersWidth();
|
||||||
auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0;
|
auto dialogsWidth = 0, chatWidth = 0, thirdWidth = 0;
|
||||||
|
@ -831,12 +832,12 @@ auto SessionController::computeColumnLayout() const -> ColumnLayout {
|
||||||
if (useOneColumnLayout()) {
|
if (useOneColumnLayout()) {
|
||||||
dialogsWidth = chatWidth = bodyWidth;
|
dialogsWidth = chatWidth = bodyWidth;
|
||||||
} else if (useNormalLayout()) {
|
} else if (useNormalLayout()) {
|
||||||
layout = Adaptive::WindowLayout::Normal;
|
layout = AdaptiveModern::WindowLayout::Normal;
|
||||||
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
||||||
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
|
||||||
chatWidth = bodyWidth - dialogsWidth;
|
chatWidth = bodyWidth - dialogsWidth;
|
||||||
} else {
|
} else {
|
||||||
layout = Adaptive::WindowLayout::ThreeColumn;
|
layout = AdaptiveModern::WindowLayout::ThreeColumn;
|
||||||
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
dialogsWidth = countDialogsWidthFromRatio(bodyWidth);
|
||||||
thirdWidth = countThirdColumnWidthFromRatio(bodyWidth);
|
thirdWidth = countThirdColumnWidthFromRatio(bodyWidth);
|
||||||
auto shrink = shrinkDialogsAndThirdColumns(
|
auto shrink = shrinkDialogsAndThirdColumns(
|
||||||
|
@ -906,7 +907,7 @@ bool SessionController::takeThirdSectionFromLayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionController::resizeForThirdSection() {
|
void SessionController::resizeForThirdSection() {
|
||||||
if (Adaptive::ThreeColumn()) {
|
if (adaptive().isThreeColumn()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -959,7 +960,7 @@ void SessionController::closeThirdSection() {
|
||||||
auto &settings = Core::App().settings();
|
auto &settings = Core::App().settings();
|
||||||
auto newWindowSize = widget()->size();
|
auto newWindowSize = widget()->size();
|
||||||
auto layout = computeColumnLayout();
|
auto layout = computeColumnLayout();
|
||||||
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) {
|
if (layout.windowLayout == AdaptiveModern::WindowLayout::ThreeColumn) {
|
||||||
auto noResize = widget()->isFullScreen()
|
auto noResize = widget()->isFullScreen()
|
||||||
|| widget()->isMaximized();
|
|| widget()->isMaximized();
|
||||||
auto savedValue = settings.thirdSectionExtendedBy();
|
auto savedValue = settings.thirdSectionExtendedBy();
|
||||||
|
@ -1182,7 +1183,7 @@ void SessionController::setActiveChatsFilter(FilterId id) {
|
||||||
if (id) {
|
if (id) {
|
||||||
closeFolder();
|
closeFolder();
|
||||||
}
|
}
|
||||||
if (Adaptive::OneColumn()) {
|
if (adaptive().isOneColumn()) {
|
||||||
Ui::showChatsList(&session());
|
Ui::showChatsList(&session());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
#include "ui/effects/animation_value.h"
|
#include "ui/effects/animation_value.h"
|
||||||
|
#include "window/window_adaptive.h"
|
||||||
|
|
||||||
class PhotoData;
|
class PhotoData;
|
||||||
class MainWidget;
|
class MainWidget;
|
||||||
|
@ -53,7 +54,6 @@ class MainWindow;
|
||||||
class SectionMemento;
|
class SectionMemento;
|
||||||
class Controller;
|
class Controller;
|
||||||
class FiltersMenu;
|
class FiltersMenu;
|
||||||
class AdaptiveModern;
|
|
||||||
|
|
||||||
enum class GifPauseReason {
|
enum class GifPauseReason {
|
||||||
Any = 0,
|
Any = 0,
|
||||||
|
@ -287,7 +287,7 @@ public:
|
||||||
int dialogsWidth;
|
int dialogsWidth;
|
||||||
int chatWidth;
|
int chatWidth;
|
||||||
int thirdWidth;
|
int thirdWidth;
|
||||||
Adaptive::WindowLayout windowLayout;
|
AdaptiveModern::WindowLayout windowLayout;
|
||||||
};
|
};
|
||||||
[[nodiscard]] ColumnLayout computeColumnLayout() const;
|
[[nodiscard]] ColumnLayout computeColumnLayout() const;
|
||||||
int dialogsSmallColumnWidth() const;
|
int dialogsSmallColumnWidth() const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue