Create dialogs widget only in the primary window.

This commit is contained in:
John Preston 2022-01-04 16:13:00 +03:00
parent 8b0725650d
commit 54247cd11b
8 changed files with 181 additions and 102 deletions

View file

@ -994,7 +994,7 @@ Window::Controller *Application::ensureSeparateWindowForPeer(
} }
const auto result = _separateWindows.emplace( const auto result = _separateWindows.emplace(
peer->owner().history(peer), peer->owner().history(peer),
std::make_unique<Window::Controller>()).first->second.get(); std::make_unique<Window::Controller>(peer)).first->second.get();
result->showAccount(&peer->account()); result->showAccount(&peer->account());
result->sessionController()->showPeerHistory(peer); result->sessionController()->showPeerHistory(peer);
result->widget()->show(); result->widget()->show();

View file

@ -749,13 +749,13 @@ void Widget::escape() {
controller()->closeFolder(); controller()->closeFolder();
} else if (!onCancelSearch()) { } else if (!onCancelSearch()) {
if (controller()->activeChatEntryCurrent().key) { if (controller()->activeChatEntryCurrent().key) {
cancelled(); controller()->content()->dialogsCancelled();
} else if (controller()->activeChatsFilterCurrent()) { } else if (controller()->activeChatsFilterCurrent()) {
controller()->setActiveChatsFilter(FilterId(0)); controller()->setActiveChatsFilter(FilterId(0));
} }
} else if (!_searchInChat && !controller()->selectingPeer()) { } else if (!_searchInChat && !controller()->selectingPeer()) {
if (controller()->activeChatEntryCurrent().key) { if (controller()->activeChatEntryCurrent().key) {
cancelled(); controller()->content()->dialogsCancelled();
} }
} }
} }
@ -1808,7 +1808,7 @@ void Widget::onCancelSearchInChat() {
} }
applyFilterUpdate(true); applyFilterUpdate(true);
if (!isOneColumn && !controller()->selectingPeer()) { if (!isOneColumn && !controller()->selectingPeer()) {
cancelled(); controller()->content()->dialogsCancelled();
} }
} }

View file

@ -97,9 +97,6 @@ public:
~Widget(); ~Widget();
Q_SIGNALS:
void cancelled();
public Q_SLOTS: public Q_SLOTS:
void onDraggingScrollDelta(int delta); void onDraggingScrollDelta(int delta);

View file

@ -223,15 +223,17 @@ MainWidget::MainWidget(
, _controller(controller) , _controller(controller)
, _dialogsWidth(st::columnMinimalWidthLeft) , _dialogsWidth(st::columnMinimalWidthLeft)
, _thirdColumnWidth(st::columnMinimalWidthThird) , _thirdColumnWidth(st::columnMinimalWidthThird)
, _sideShadow(this) , _sideShadow(isPrimary()
, _dialogs(this, _controller) ? base::make_unique_q<Ui::PlainShadow>(this)
, _history(this, _controller) : nullptr)
, _dialogs(isPrimary()
? base::make_unique_q<Dialogs::Widget>(this, _controller)
: nullptr)
, _history(std::in_place, this, _controller)
, _playerPlaylist(this, _controller) , _playerPlaylist(this, _controller)
, _changelogs(Core::Changelogs::Create(&controller->session())) { , _changelogs(Core::Changelogs::Create(&controller->session())) {
setupConnectingWidget(); setupConnectingWidget();
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
_history->cancelRequests( _history->cancelRequests(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
handleHistoryBack(); handleHistoryBack();
@ -351,13 +353,14 @@ MainWidget::MainWidget(
handleAdaptiveLayoutUpdate(); handleAdaptiveLayoutUpdate();
}, lifetime()); }, lifetime());
_dialogs->show(); if (_dialogs) {
if (isOneColumn()) { _dialogs->show();
}
if (_dialogs && isOneColumn()) {
_history->hide(); _history->hide();
} else { } else {
_history->show(); _history->show();
} }
orderWidgets(); orderWidgets();
if (!Core::UpdaterDisabled()) { if (!Core::UpdaterDisabled()) {
@ -399,9 +402,10 @@ 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 (isThreeColumn()) { if (isThreeColumn()) {
if (column == Window::Column::First) { if (_dialogs && column == Window::Column::First) {
return _dialogs; return _dialogs;
} else if (column == Window::Column::Second } else if (column == Window::Column::Second
|| !_dialogs
|| !_thirdSection) { || !_thirdSection) {
if (_mainSection) { if (_mainSection) {
return _mainSection; return _mainSection;
@ -410,7 +414,7 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
} }
return _thirdSection; return _thirdSection;
} else if (isNormalColumn()) { } else if (isNormalColumn()) {
if (column == Window::Column::First) { if (_dialogs && column == Window::Column::First) {
return _dialogs; return _dialogs;
} else if (_mainSection) { } else if (_mainSection) {
return _mainSection; return _mainSection;
@ -418,12 +422,14 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
return _history; return _history;
} }
if (isOneColumn() && selectingPeer()) { if (isOneColumn() && selectingPeer()) {
Assert(_dialogs != nullptr);
return _dialogs; return _dialogs;
} else if (_mainSection) { } else if (_mainSection) {
return _mainSection; return _mainSection;
} else if (!isOneColumn() || _history->peer()) { } else if (!isOneColumn() || _history->peer()) {
return _history; return _history;
} }
Assert(_dialogs != nullptr);
return _dialogs; return _dialogs;
} }
@ -431,7 +437,9 @@ 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 (isThreeColumn()) { if (isThreeColumn()) {
callback(_dialogs, Window::Column::First); if (_dialogs) {
callback(_dialogs, Window::Column::First);
}
if (_mainSection) { if (_mainSection) {
callback(_mainSection, Window::Column::Second); callback(_mainSection, Window::Column::Second);
} else { } else {
@ -441,7 +449,9 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
callback(_thirdSection, Window::Column::Third); callback(_thirdSection, Window::Column::Third);
} }
} else if (isNormalColumn()) { } else if (isNormalColumn()) {
callback(_dialogs, Window::Column::First); if (_dialogs) {
callback(_dialogs, Window::Column::First);
}
if (_mainSection) { if (_mainSection) {
callback(_mainSection, Window::Column::Second); callback(_mainSection, Window::Column::Second);
} else { } else {
@ -449,12 +459,14 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
} }
} else { } else {
if (isOneColumn() && selectingPeer()) { if (isOneColumn() && selectingPeer()) {
Assert(_dialogs != nullptr);
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 (!isOneColumn() || _history->peer()) { } else if (!isOneColumn() || _history->peer()) {
callback(_history, Window::Column::Second); callback(_history, Window::Column::Second);
} else { } else {
Assert(_dialogs != nullptr);
callback(_dialogs, Window::Column::First); callback(_dialogs, Window::Column::First);
} }
} }
@ -616,6 +628,7 @@ void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
_hider.release(); _hider.release();
controller()->setSelectingPeer(false); controller()->setSelectingPeer(false);
Assert(_dialogs != nullptr);
if (isOneColumn()) { if (isOneColumn()) {
if (_mainSection || (_history->peer() && _history->peer()->id)) { if (_mainSection || (_history->peer() && _history->peer()->id)) {
auto animationParams = ([=] { auto animationParams = ([=] {
@ -638,7 +651,7 @@ void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
} }
void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) { void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) {
if (controller()->window().locked()) { if (!_dialogs || controller()->window().locked()) {
return; return;
} }
@ -764,6 +777,10 @@ bool MainWidget::insertBotCommand(const QString &cmd) {
} }
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) { void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
// #TODO windows
if (!_dialogs) {
return;
}
_dialogs->searchMessages(query, inChat); _dialogs->searchMessages(query, inChat);
if (isOneColumn()) { if (isOneColumn()) {
Ui::showChatsList(&session()); Ui::showChatsList(&session());
@ -1048,24 +1065,6 @@ void MainWidget::exportTopBarHeightUpdated() {
} }
} }
void MainWidget::inlineResultLoadProgress(FileLoader *loader) {
//InlineBots::Result *result = InlineBots::resultFromLoader(loader);
//if (!result) return;
//result->loaded();
//Ui::repaintInlineItem();
}
void MainWidget::inlineResultLoadFailed(FileLoader *loader, bool started) {
//InlineBots::Result *result = InlineBots::resultFromLoader(loader);
//if (!result) return;
//result->loaded();
//Ui::repaintInlineItem();
}
SendMenu::Type MainWidget::sendMenuType() const { SendMenu::Type MainWidget::sendMenuType() const {
return _history->sendMenuType(); return _history->sendMenuType();
} }
@ -1195,6 +1194,7 @@ Image *MainWidget::newBackgroundThumb() {
void MainWidget::setInnerFocus() { void MainWidget::setInnerFocus() {
if (_hider || !_history->peer()) { if (_hider || !_history->peer()) {
Assert(_dialogs != nullptr);
if (!_hider && _mainSection) { if (!_hider && _mainSection) {
_mainSection->setInnerFocus(); _mainSection->setInnerFocus();
} else if (!_hider && _thirdSection) { } else if (!_hider && _thirdSection) {
@ -1257,7 +1257,9 @@ void MainWidget::ui_showPeerHistory(
PeerId peerId, PeerId peerId,
const SectionShow &params, const SectionShow &params,
MsgId showAtMsgId) { MsgId showAtMsgId) {
if (peerId && _controller->window().locked()) { if (!peerId && !isPrimary()) {
return;
} else if (peerId && _controller->window().locked()) {
return; return;
} else if (auto peer = session().data().peerLoaded(peerId)) { } else if (auto peer = session().data().peerLoaded(peerId)) {
if (peer->migrateTo()) { if (peer->migrateTo()) {
@ -1350,7 +1352,7 @@ void MainWidget::ui_showPeerHistory(
} }
if (!peerId) { if (!peerId) {
if (isOneColumn()) { if (isOneColumn()) {
return _dialogs->isHidden(); return _dialogs && _dialogs->isHidden();
} else { } else {
return false; return false;
} }
@ -1360,7 +1362,7 @@ void MainWidget::ui_showPeerHistory(
return false; return false;
} }
return (_mainSection != nullptr) return (_mainSection != nullptr)
|| (isOneColumn() && !_dialogs->isHidden()); || (isOneColumn() && _dialogs && !_dialogs->isHidden());
} }
if (back || way == Way::Forward) { if (back || way == Way::Forward) {
return true; return true;
@ -1392,6 +1394,7 @@ void MainWidget::ui_showPeerHistory(
} }
if (onlyDialogs) { if (onlyDialogs) {
Assert(_dialogs != nullptr);
_history->hide(); _history->hide();
if (!_a_show.animating()) { if (!_a_show.animating()) {
if (animationParams) { if (animationParams) {
@ -1406,7 +1409,7 @@ void MainWidget::ui_showPeerHistory(
if (nowActivePeer && nowActivePeer != wasActivePeer) { if (nowActivePeer && nowActivePeer != wasActivePeer) {
session().api().views().removeIncremented(nowActivePeer); session().api().views().removeIncremented(nowActivePeer);
} }
if (isOneColumn() && !_dialogs->isHidden()) { if (isOneColumn() && _dialogs && !_dialogs->isHidden()) {
_dialogs->hide(); _dialogs->hide();
} }
if (!_a_show.animating()) { if (!_a_show.animating()) {
@ -1425,7 +1428,7 @@ void MainWidget::ui_showPeerHistory(
} }
} }
if (!_dialogs->isHidden()) { if (_dialogs && !_dialogs->isHidden()) {
if (!back) { if (!back) {
if (const auto history = _history->history()) { if (const auto history = _history->history()) {
_dialogs->scrollToEntry(Dialogs::RowDescriptor( _dialogs->scrollToEntry(Dialogs::RowDescriptor(
@ -1676,7 +1679,9 @@ void MainWidget::showNewSection(
_history->finishAnimating(); _history->finishAnimating();
_history->showHistory(0, 0); _history->showHistory(0, 0);
_history->hide(); _history->hide();
if (isOneColumn()) _dialogs->hide(); if (isOneColumn() && _dialogs) {
_dialogs->hide();
}
} }
if (animationParams) { if (animationParams) {
@ -1726,6 +1731,14 @@ void MainWidget::dropMainSection(Window::SectionWidget *widget) {
anim::activation::background)); anim::activation::background));
} }
PeerData *MainWidget::singlePeer() const {
return _controller->singlePeer();
}
bool MainWidget::isPrimary() const {
return _controller->isPrimary();
}
bool MainWidget::isMainSectionShown() const { bool MainWidget::isMainSectionShown() const {
return _mainSection || _history->peer(); return _mainSection || _history->peer();
} }
@ -1802,7 +1815,9 @@ void MainWidget::showBackFromStack(
} }
void MainWidget::orderWidgets() { void MainWidget::orderWidgets() {
_dialogs->raise(); if (_dialogs) {
_dialogs->raise();
}
if (_player) { if (_player) {
_player->raise(); _player->raise();
} }
@ -1812,7 +1827,9 @@ void MainWidget::orderWidgets() {
if (_callTopBar) { if (_callTopBar) {
_callTopBar->raise(); _callTopBar->raise();
} }
_sideShadow->raise(); if (_sideShadow) {
_sideShadow->raise();
}
if (_thirdShadow) { if (_thirdShadow) {
_thirdShadow->raise(); _thirdShadow->raise();
} }
@ -1850,7 +1867,9 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams &param
_dialogsWidth, _dialogsWidth,
height() - sectionTop)); height() - sectionTop));
} else { } else {
_sideShadow->hide(); if (_sideShadow) {
_sideShadow->hide();
}
if (_thirdShadow) { if (_thirdShadow) {
_thirdShadow->hide(); _thirdShadow->hide();
} }
@ -1859,7 +1878,9 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams &param
sectionTop, sectionTop,
width() - _dialogsWidth, width() - _dialogsWidth,
height() - sectionTop)); height() - sectionTop));
_sideShadow->show(); if (_sideShadow) {
_sideShadow->show();
}
if (_thirdShadow) { if (_thirdShadow) {
_thirdShadow->show(); _thirdShadow->show();
} }
@ -1879,7 +1900,9 @@ void MainWidget::windowShown() {
} }
void MainWidget::dialogsToUp() { void MainWidget::dialogsToUp() {
_dialogs->jumpToTop(); if (_dialogs) {
_dialogs->jumpToTop();
}
} }
void MainWidget::checkHistoryActivation() { void MainWidget::checkHistoryActivation() {
@ -1950,7 +1973,9 @@ int MainWidget::getThirdSectionTop() const {
} }
void MainWidget::hideAll() { void MainWidget::hideAll() {
_dialogs->hide(); if (_dialogs) {
_dialogs->hide();
}
_history->hide(); _history->hide();
if (_mainSection) { if (_mainSection) {
_mainSection->hide(); _mainSection->hide();
@ -1958,7 +1983,9 @@ void MainWidget::hideAll() {
if (_thirdSection) { if (_thirdSection) {
_thirdSection->hide(); _thirdSection->hide();
} }
_sideShadow->hide(); if (_sideShadow) {
_sideShadow->hide();
}
if (_thirdShadow) { if (_thirdShadow) {
_thirdShadow->hide(); _thirdShadow->hide();
} }
@ -1978,11 +2005,14 @@ void MainWidget::showAll() {
Ui::show(Box<Ui::InformBox>(tr::lng_cloud_password_updated(tr::now))); Ui::show(Box<Ui::InformBox>(tr::lng_cloud_password_updated(tr::now)));
} }
if (isOneColumn()) { if (isOneColumn()) {
_sideShadow->hide(); if (_sideShadow) {
_sideShadow->hide();
}
if (_hider) { if (_hider) {
_hider->hide(); _hider->hide();
} }
if (selectingPeer()) { if (selectingPeer()) {
Assert(_dialogs != nullptr);
_dialogs->showFast(); _dialogs->showFast();
_history->hide(); _history->hide();
if (_mainSection) _mainSection->hide(); if (_mainSection) _mainSection->hide();
@ -1992,22 +2022,23 @@ void MainWidget::showAll() {
_history->show(); _history->show();
_history->updateControlsGeometry(); _history->updateControlsGeometry();
} else { } else {
Assert(_dialogs != nullptr);
_dialogs->showFast(); _dialogs->showFast();
_history->hide(); _history->hide();
} }
if (!selectingPeer()) { if (!selectingPeer() && _dialogs && isMainSectionShown()) {
if (_mainSection) { _dialogs->hide();
_dialogs->hide();
} else if (isMainSectionShown()) {
_dialogs->hide();
}
} }
} else { } else {
_sideShadow->show(); if (_sideShadow) {
_sideShadow->show();
}
if (_hider) { if (_hider) {
_hider->show(); _hider->show();
} }
_dialogs->showFast(); if (_dialogs) {
_dialogs->showFast();
}
if (_mainSection) { if (_mainSection) {
_mainSection->show(); _mainSection->show();
} else { } else {
@ -2046,11 +2077,13 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
void MainWidget::updateControlsGeometry() { void MainWidget::updateControlsGeometry() {
updateWindowAdaptiveLayout(); updateWindowAdaptiveLayout();
if (Core::App().settings().dialogsWidthRatio() > 0) { if (_dialogs) {
_a_dialogsWidth.stop(); if (Core::App().settings().dialogsWidthRatio() > 0) {
} _a_dialogsWidth.stop();
if (!_a_dialogsWidth.animating()) { }
_dialogs->stopWidthAnimation(); if (!_a_dialogsWidth.animating()) {
_dialogs->stopWidthAnimation();
}
} }
if (isThreeColumn()) { if (isThreeColumn()) {
if (!_thirdSection if (!_thirdSection
@ -2078,8 +2111,12 @@ void MainWidget::updateControlsGeometry() {
_thirdSection.destroy(); _thirdSection.destroy();
_thirdShadow.destroy(); _thirdShadow.destroy();
} }
auto mainSectionTop = getMainSectionTop(); const auto mainSectionTop = getMainSectionTop();
auto dialogsWidth = qRound(_a_dialogsWidth.value(_dialogsWidth)); auto dialogsWidth = _dialogs
? qRound(_a_dialogsWidth.value(_dialogsWidth))
: isOneColumn()
? _dialogsWidth
: 0;
if (isOneColumn()) { if (isOneColumn()) {
if (_callTopBar) { if (_callTopBar) {
_callTopBar->resizeToWidth(dialogsWidth); _callTopBar->resizeToWidth(dialogsWidth);
@ -2093,13 +2130,19 @@ void MainWidget::updateControlsGeometry() {
_player->resizeToWidth(dialogsWidth); _player->resizeToWidth(dialogsWidth);
_player->moveToLeft(0, _callTopBarHeight + _exportTopBarHeight); _player->moveToLeft(0, _callTopBarHeight + _exportTopBarHeight);
} }
auto mainSectionGeometry = QRect( const auto mainSectionGeometry = QRect(
0, 0,
mainSectionTop, mainSectionTop,
dialogsWidth, dialogsWidth,
height() - mainSectionTop); height() - mainSectionTop);
_dialogs->setGeometryWithTopMoved(mainSectionGeometry, _contentScrollAddToY); if (_dialogs) {
_history->setGeometryWithTopMoved(mainSectionGeometry, _contentScrollAddToY); _dialogs->setGeometryWithTopMoved(
mainSectionGeometry,
_contentScrollAddToY);
}
_history->setGeometryWithTopMoved(
mainSectionGeometry,
_contentScrollAddToY);
if (_hider) _hider->setGeometry(0, 0, dialogsWidth, height()); if (_hider) _hider->setGeometry(0, 0, dialogsWidth, height());
} else { } else {
auto thirdSectionWidth = _thirdSection ? _thirdColumnWidth : 0; auto thirdSectionWidth = _thirdSection ? _thirdColumnWidth : 0;
@ -2111,17 +2154,21 @@ void MainWidget::updateControlsGeometry() {
thirdSectionWidth, thirdSectionWidth,
height() - thirdSectionTop); height() - thirdSectionTop);
} }
accumulate_min(dialogsWidth, width() - st::columnMinimalWidthMain);
auto mainSectionWidth = width() - dialogsWidth - thirdSectionWidth;
_dialogs->setGeometryToLeft(0, 0, dialogsWidth, height());
const auto shadowTop = _controller->window().verticalShadowTop(); const auto shadowTop = _controller->window().verticalShadowTop();
const auto shadowHeight = height() - shadowTop; const auto shadowHeight = height() - shadowTop;
_sideShadow->setGeometryToLeft( if (_dialogs) {
dialogsWidth, accumulate_min(
shadowTop, dialogsWidth,
st::lineWidth, width() - st::columnMinimalWidthMain);
shadowHeight); _dialogs->setGeometryToLeft(0, 0, dialogsWidth, height());
}
if (_sideShadow) {
_sideShadow->setGeometryToLeft(
dialogsWidth,
shadowTop,
st::lineWidth,
shadowHeight);
}
if (_thirdShadow) { if (_thirdShadow) {
_thirdShadow->setGeometryToLeft( _thirdShadow->setGeometryToLeft(
width() - thirdSectionWidth - st::lineWidth, width() - thirdSectionWidth - st::lineWidth,
@ -2129,6 +2176,9 @@ void MainWidget::updateControlsGeometry() {
st::lineWidth, st::lineWidth,
shadowHeight); shadowHeight);
} }
const auto mainSectionWidth = width()
- dialogsWidth
- thirdSectionWidth;
if (_callTopBar) { if (_callTopBar) {
_callTopBar->resizeToWidth(mainSectionWidth); _callTopBar->resizeToWidth(mainSectionWidth);
_callTopBar->moveToLeft(dialogsWidth, 0); _callTopBar->moveToLeft(dialogsWidth, 0);
@ -2143,14 +2193,29 @@ void MainWidget::updateControlsGeometry() {
dialogsWidth, dialogsWidth,
_callTopBarHeight + _exportTopBarHeight); _callTopBarHeight + _exportTopBarHeight);
} }
_history->setGeometryWithTopMoved({ dialogsWidth, mainSectionTop, mainSectionWidth, height() - mainSectionTop }, _contentScrollAddToY); _history->setGeometryWithTopMoved(QRect(
dialogsWidth,
mainSectionTop,
mainSectionWidth,
height() - mainSectionTop
), _contentScrollAddToY);
if (_hider) { if (_hider) {
_hider->setGeometryToLeft(dialogsWidth, 0, mainSectionWidth, height()); _hider->setGeometryToLeft(
dialogsWidth,
0,
mainSectionWidth,
height());
} }
} }
if (_mainSection) { if (_mainSection) {
auto mainSectionGeometry = QRect(_history->x(), mainSectionTop, _history->width(), height() - mainSectionTop); const auto mainSectionGeometry = QRect(
_mainSection->setGeometryWithTopMoved(mainSectionGeometry, _contentScrollAddToY); _history->x(),
mainSectionTop,
_history->width(),
height() - mainSectionTop);
_mainSection->setGeometryWithTopMoved(
mainSectionGeometry,
_contentScrollAddToY);
} }
refreshResizeAreas(); refreshResizeAreas();
if (_player) { if (_player) {
@ -2252,7 +2317,7 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
} }
void MainWidget::updateDialogsWidthAnimated() { void MainWidget::updateDialogsWidthAnimated() {
if (Core::App().settings().dialogsWidthRatio() > 0) { if (!_dialogs || Core::App().settings().dialogsWidthRatio() > 0) {
return; return;
} }
auto dialogsWidth = _dialogsWidth; auto dialogsWidth = _dialogsWidth;
@ -2383,7 +2448,8 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|| (_mainSection && (_mainSection == widget || _mainSection->isAncestorOf(widget))) || (_mainSection && (_mainSection == widget || _mainSection->isAncestorOf(widget)))
|| (_thirdSection && (_thirdSection == widget || _thirdSection->isAncestorOf(widget)))) { || (_thirdSection && (_thirdSection == widget || _thirdSection->isAncestorOf(widget)))) {
_controller->dialogsListFocused().set(false); _controller->dialogsListFocused().set(false);
} else if (_dialogs == widget || _dialogs->isAncestorOf(widget)) { } else if (_dialogs
&& (_dialogs == widget || _dialogs->isAncestorOf(widget))) {
_controller->dialogsListFocused().set(true); _controller->dialogsListFocused().set(true);
} }
} }
@ -2404,13 +2470,19 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
void MainWidget::handleAdaptiveLayoutUpdate() { void MainWidget::handleAdaptiveLayoutUpdate() {
showAll(); showAll();
_sideShadow->setVisible(!isOneColumn()); if (_sideShadow) {
_sideShadow->setVisible(!isOneColumn());
}
if (_player) { if (_player) {
_player->updateAdaptiveLayout(); _player->updateAdaptiveLayout();
} }
} }
void MainWidget::handleHistoryBack() { void MainWidget::handleHistoryBack() {
// #TODO windows
if (!_dialogs) {
return;
}
const auto historyFromFolder = _history->history() const auto historyFromFolder = _history->history()
? _history->history()->folder() ? _history->history()->folder()
: nullptr; : nullptr;
@ -2487,6 +2559,11 @@ int MainWidget::backgroundFromY() const {
} }
void MainWidget::searchInChat(Dialogs::Key chat) { void MainWidget::searchInChat(Dialogs::Key chat) {
// #TODO windows
if (!_dialogs) {
return;
}
if (_controller->openedFolder().current()) { if (_controller->openedFolder().current()) {
_controller->closeFolder(); _controller->closeFolder();
} }
@ -2508,6 +2585,7 @@ void MainWidget::activate() {
return; return;
} else if (!_mainSection) { } else if (!_mainSection) {
if (_hider) { if (_hider) {
Assert(_dialogs != nullptr);
_dialogs->setInnerFocus(); _dialogs->setInnerFocus();
} else if (!Ui::isLayerShown()) { } else if (!Ui::isLayerShown()) {
if (!cSendPaths().isEmpty()) { if (!cSendPaths().isEmpty()) {
@ -2527,6 +2605,7 @@ void MainWidget::activate() {
} else if (_history->peer()) { } else if (_history->peer()) {
_history->activate(); _history->activate();
} else { } else {
Assert(_dialogs != nullptr);
_dialogs->setInnerFocus(); _dialogs->setInnerFocus();
} }
} }
@ -2544,10 +2623,6 @@ bool MainWidget::doWeMarkAsRead() const {
return isActive() && !_mainSection; return isActive() && !_mainSection;
} }
int32 MainWidget::dlgsWidth() const {
return _dialogs->width();
}
void MainWidget::saveFieldToHistoryLocalDraft() { void MainWidget::saveFieldToHistoryLocalDraft() {
_history->saveFieldToHistoryLocalDraft(); _history->saveFieldToHistoryLocalDraft();
} }

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once #pragma once
#include "base/weak_ptr.h" #include "base/weak_ptr.h"
#include "base/unique_qptr.h"
#include "chat_helpers/bot_command.h" #include "chat_helpers/bot_command.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
@ -112,8 +113,6 @@ class MainWidget
: public Ui::RpWidget : public Ui::RpWidget
, private Media::Player::FloatDelegate , private Media::Player::FloatDelegate
, private base::Subscriber { , private base::Subscriber {
Q_OBJECT
public: public:
using SectionShow = Window::SectionShow; using SectionShow = Window::SectionShow;
@ -124,7 +123,8 @@ public:
[[nodiscard]] Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
[[nodiscard]] not_null<Window::SessionController*> controller() const; [[nodiscard]] not_null<Window::SessionController*> controller() const;
[[nodiscard]] PeerData *singlePeer() const;
[[nodiscard]] bool isPrimary() const;
[[nodiscard]] bool isMainSectionShown() const; [[nodiscard]] bool isMainSectionShown() const;
[[nodiscard]] bool isThirdSectionShown() const; [[nodiscard]] bool isThirdSectionShown() const;
@ -164,8 +164,6 @@ public:
void saveFieldToHistoryLocalDraft(); void saveFieldToHistoryLocalDraft();
int32 dlgsWidth() const;
void showForwardLayer(Data::ForwardDraft &&draft); void showForwardLayer(Data::ForwardDraft &&draft);
void showSendPathsLayer(); void showSendPathsLayer();
void shareUrlLayer(const QString &url, const QString &text); void shareUrlLayer(const QString &url, const QString &text);
@ -231,10 +229,6 @@ public:
Fn<void()> callback, Fn<void()> callback,
const SectionShow &params) const; const SectionShow &params) const;
public Q_SLOTS:
void inlineResultLoadProgress(FileLoader *loader);
void inlineResultLoadFailed(FileLoader *loader, bool started);
void dialogsCancelled(); void dialogsCancelled();
protected: protected:
@ -340,12 +334,12 @@ private:
int _thirdColumnWidth = 0; int _thirdColumnWidth = 0;
Ui::Animations::Simple _a_dialogsWidth; Ui::Animations::Simple _a_dialogsWidth;
object_ptr<Ui::PlainShadow> _sideShadow; const base::unique_qptr<Ui::PlainShadow> _sideShadow;
object_ptr<Ui::PlainShadow> _thirdShadow = { nullptr }; object_ptr<Ui::PlainShadow> _thirdShadow = { nullptr };
object_ptr<Ui::ResizeArea> _firstColumnResizeArea = { nullptr }; object_ptr<Ui::ResizeArea> _firstColumnResizeArea = { nullptr };
object_ptr<Ui::ResizeArea> _thirdColumnResizeArea = { nullptr }; object_ptr<Ui::ResizeArea> _thirdColumnResizeArea = { nullptr };
object_ptr<Dialogs::Widget> _dialogs; const base::unique_qptr<Dialogs::Widget> _dialogs;
object_ptr<HistoryWidget> _history; const base::unique_qptr<HistoryWidget> _history;
object_ptr<Window::SectionWidget> _mainSection = { nullptr }; object_ptr<Window::SectionWidget> _mainSection = { nullptr };
object_ptr<Window::SectionWidget> _thirdSection = { nullptr }; object_ptr<Window::SectionWidget> _thirdSection = { nullptr };
std::shared_ptr<Window::SectionMemento> _thirdSectionFromStack; std::shared_ptr<Window::SectionMemento> _thirdSectionFromStack;

View file

@ -337,6 +337,9 @@ void MainWindow::setupMain() {
auto created = object_ptr<MainWidget>(bodyWidget(), sessionController()); auto created = object_ptr<MainWidget>(bodyWidget(), sessionController());
clearWidgets(); clearWidgets();
_main = std::move(created); _main = std::move(created);
if (const auto peer = singlePeer()) {
_main->controller()->showPeerHistory(peer);
}
if (_passcodeLock) { if (_passcodeLock) {
_main->hide(); _main->hide();
} else { } else {

View file

@ -618,6 +618,14 @@ void SessionController::suggestArchiveAndMute() {
})); }));
} }
PeerData *SessionController::singlePeer() const {
return _window->singlePeer();
}
bool SessionController::isPrimary() const {
return _window->isPrimary();
}
not_null<::MainWindow*> SessionController::widget() const { not_null<::MainWindow*> SessionController::widget() const {
return _window->widget(); return _window->widget();
} }

View file

@ -252,6 +252,8 @@ public:
[[nodiscard]] Controller &window() const { [[nodiscard]] Controller &window() const {
return *_window; return *_window;
} }
[[nodiscard]] PeerData *singlePeer() const;
[[nodiscard]] bool isPrimary() const;
[[nodiscard]] not_null<::MainWindow*> widget() const; [[nodiscard]] not_null<::MainWindow*> widget() const;
[[nodiscard]] not_null<MainWidget*> content() const; [[nodiscard]] not_null<MainWidget*> content() const;
[[nodiscard]] Adaptive &adaptive() const; [[nodiscard]] Adaptive &adaptive() const;