mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Create dialogs widget only in the primary window.
This commit is contained in:
parent
8b0725650d
commit
54247cd11b
8 changed files with 181 additions and 102 deletions
|
@ -994,7 +994,7 @@ Window::Controller *Application::ensureSeparateWindowForPeer(
|
|||
}
|
||||
const auto result = _separateWindows.emplace(
|
||||
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->sessionController()->showPeerHistory(peer);
|
||||
result->widget()->show();
|
||||
|
|
|
@ -749,13 +749,13 @@ void Widget::escape() {
|
|||
controller()->closeFolder();
|
||||
} else if (!onCancelSearch()) {
|
||||
if (controller()->activeChatEntryCurrent().key) {
|
||||
cancelled();
|
||||
controller()->content()->dialogsCancelled();
|
||||
} else if (controller()->activeChatsFilterCurrent()) {
|
||||
controller()->setActiveChatsFilter(FilterId(0));
|
||||
}
|
||||
} else if (!_searchInChat && !controller()->selectingPeer()) {
|
||||
if (controller()->activeChatEntryCurrent().key) {
|
||||
cancelled();
|
||||
controller()->content()->dialogsCancelled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1808,7 +1808,7 @@ void Widget::onCancelSearchInChat() {
|
|||
}
|
||||
applyFilterUpdate(true);
|
||||
if (!isOneColumn && !controller()->selectingPeer()) {
|
||||
cancelled();
|
||||
controller()->content()->dialogsCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -97,9 +97,6 @@ public:
|
|||
|
||||
~Widget();
|
||||
|
||||
Q_SIGNALS:
|
||||
void cancelled();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onDraggingScrollDelta(int delta);
|
||||
|
||||
|
|
|
@ -223,15 +223,17 @@ MainWidget::MainWidget(
|
|||
, _controller(controller)
|
||||
, _dialogsWidth(st::columnMinimalWidthLeft)
|
||||
, _thirdColumnWidth(st::columnMinimalWidthThird)
|
||||
, _sideShadow(this)
|
||||
, _dialogs(this, _controller)
|
||||
, _history(this, _controller)
|
||||
, _sideShadow(isPrimary()
|
||||
? base::make_unique_q<Ui::PlainShadow>(this)
|
||||
: nullptr)
|
||||
, _dialogs(isPrimary()
|
||||
? base::make_unique_q<Dialogs::Widget>(this, _controller)
|
||||
: nullptr)
|
||||
, _history(std::in_place, this, _controller)
|
||||
, _playerPlaylist(this, _controller)
|
||||
, _changelogs(Core::Changelogs::Create(&controller->session())) {
|
||||
setupConnectingWidget();
|
||||
|
||||
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
|
||||
|
||||
_history->cancelRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
handleHistoryBack();
|
||||
|
@ -351,13 +353,14 @@ MainWidget::MainWidget(
|
|||
handleAdaptiveLayoutUpdate();
|
||||
}, lifetime());
|
||||
|
||||
_dialogs->show();
|
||||
if (isOneColumn()) {
|
||||
if (_dialogs) {
|
||||
_dialogs->show();
|
||||
}
|
||||
if (_dialogs && isOneColumn()) {
|
||||
_history->hide();
|
||||
} else {
|
||||
_history->show();
|
||||
}
|
||||
|
||||
orderWidgets();
|
||||
|
||||
if (!Core::UpdaterDisabled()) {
|
||||
|
@ -399,9 +402,10 @@ not_null<Ui::RpWidget*> MainWidget::floatPlayerWidget() {
|
|||
auto MainWidget::floatPlayerGetSection(Window::Column column)
|
||||
-> not_null<Media::Player::FloatSectionDelegate*> {
|
||||
if (isThreeColumn()) {
|
||||
if (column == Window::Column::First) {
|
||||
if (_dialogs && column == Window::Column::First) {
|
||||
return _dialogs;
|
||||
} else if (column == Window::Column::Second
|
||||
|| !_dialogs
|
||||
|| !_thirdSection) {
|
||||
if (_mainSection) {
|
||||
return _mainSection;
|
||||
|
@ -410,7 +414,7 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
|
|||
}
|
||||
return _thirdSection;
|
||||
} else if (isNormalColumn()) {
|
||||
if (column == Window::Column::First) {
|
||||
if (_dialogs && column == Window::Column::First) {
|
||||
return _dialogs;
|
||||
} else if (_mainSection) {
|
||||
return _mainSection;
|
||||
|
@ -418,12 +422,14 @@ auto MainWidget::floatPlayerGetSection(Window::Column column)
|
|||
return _history;
|
||||
}
|
||||
if (isOneColumn() && selectingPeer()) {
|
||||
Assert(_dialogs != nullptr);
|
||||
return _dialogs;
|
||||
} else if (_mainSection) {
|
||||
return _mainSection;
|
||||
} else if (!isOneColumn() || _history->peer()) {
|
||||
return _history;
|
||||
}
|
||||
Assert(_dialogs != nullptr);
|
||||
return _dialogs;
|
||||
}
|
||||
|
||||
|
@ -431,7 +437,9 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
|||
not_null<Media::Player::FloatSectionDelegate*> widget,
|
||||
Window::Column widgetColumn)> callback) {
|
||||
if (isThreeColumn()) {
|
||||
callback(_dialogs, Window::Column::First);
|
||||
if (_dialogs) {
|
||||
callback(_dialogs, Window::Column::First);
|
||||
}
|
||||
if (_mainSection) {
|
||||
callback(_mainSection, Window::Column::Second);
|
||||
} else {
|
||||
|
@ -441,7 +449,9 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
|||
callback(_thirdSection, Window::Column::Third);
|
||||
}
|
||||
} else if (isNormalColumn()) {
|
||||
callback(_dialogs, Window::Column::First);
|
||||
if (_dialogs) {
|
||||
callback(_dialogs, Window::Column::First);
|
||||
}
|
||||
if (_mainSection) {
|
||||
callback(_mainSection, Window::Column::Second);
|
||||
} else {
|
||||
|
@ -449,12 +459,14 @@ void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
|||
}
|
||||
} else {
|
||||
if (isOneColumn() && selectingPeer()) {
|
||||
Assert(_dialogs != nullptr);
|
||||
callback(_dialogs, Window::Column::First);
|
||||
} else if (_mainSection) {
|
||||
callback(_mainSection, Window::Column::Second);
|
||||
} else if (!isOneColumn() || _history->peer()) {
|
||||
callback(_history, Window::Column::Second);
|
||||
} else {
|
||||
Assert(_dialogs != nullptr);
|
||||
callback(_dialogs, Window::Column::First);
|
||||
}
|
||||
}
|
||||
|
@ -616,6 +628,7 @@ void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
|
|||
_hider.release();
|
||||
controller()->setSelectingPeer(false);
|
||||
|
||||
Assert(_dialogs != nullptr);
|
||||
if (isOneColumn()) {
|
||||
if (_mainSection || (_history->peer() && _history->peer()->id)) {
|
||||
auto animationParams = ([=] {
|
||||
|
@ -638,7 +651,7 @@ void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
|
|||
}
|
||||
|
||||
void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) {
|
||||
if (controller()->window().locked()) {
|
||||
if (!_dialogs || controller()->window().locked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -764,6 +777,10 @@ bool MainWidget::insertBotCommand(const QString &cmd) {
|
|||
}
|
||||
|
||||
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
|
||||
// #TODO windows
|
||||
if (!_dialogs) {
|
||||
return;
|
||||
}
|
||||
_dialogs->searchMessages(query, inChat);
|
||||
if (isOneColumn()) {
|
||||
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 {
|
||||
return _history->sendMenuType();
|
||||
}
|
||||
|
@ -1195,6 +1194,7 @@ Image *MainWidget::newBackgroundThumb() {
|
|||
|
||||
void MainWidget::setInnerFocus() {
|
||||
if (_hider || !_history->peer()) {
|
||||
Assert(_dialogs != nullptr);
|
||||
if (!_hider && _mainSection) {
|
||||
_mainSection->setInnerFocus();
|
||||
} else if (!_hider && _thirdSection) {
|
||||
|
@ -1257,7 +1257,9 @@ void MainWidget::ui_showPeerHistory(
|
|||
PeerId peerId,
|
||||
const SectionShow ¶ms,
|
||||
MsgId showAtMsgId) {
|
||||
if (peerId && _controller->window().locked()) {
|
||||
if (!peerId && !isPrimary()) {
|
||||
return;
|
||||
} else if (peerId && _controller->window().locked()) {
|
||||
return;
|
||||
} else if (auto peer = session().data().peerLoaded(peerId)) {
|
||||
if (peer->migrateTo()) {
|
||||
|
@ -1350,7 +1352,7 @@ void MainWidget::ui_showPeerHistory(
|
|||
}
|
||||
if (!peerId) {
|
||||
if (isOneColumn()) {
|
||||
return _dialogs->isHidden();
|
||||
return _dialogs && _dialogs->isHidden();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -1360,7 +1362,7 @@ void MainWidget::ui_showPeerHistory(
|
|||
return false;
|
||||
}
|
||||
return (_mainSection != nullptr)
|
||||
|| (isOneColumn() && !_dialogs->isHidden());
|
||||
|| (isOneColumn() && _dialogs && !_dialogs->isHidden());
|
||||
}
|
||||
if (back || way == Way::Forward) {
|
||||
return true;
|
||||
|
@ -1392,6 +1394,7 @@ void MainWidget::ui_showPeerHistory(
|
|||
}
|
||||
|
||||
if (onlyDialogs) {
|
||||
Assert(_dialogs != nullptr);
|
||||
_history->hide();
|
||||
if (!_a_show.animating()) {
|
||||
if (animationParams) {
|
||||
|
@ -1406,7 +1409,7 @@ void MainWidget::ui_showPeerHistory(
|
|||
if (nowActivePeer && nowActivePeer != wasActivePeer) {
|
||||
session().api().views().removeIncremented(nowActivePeer);
|
||||
}
|
||||
if (isOneColumn() && !_dialogs->isHidden()) {
|
||||
if (isOneColumn() && _dialogs && !_dialogs->isHidden()) {
|
||||
_dialogs->hide();
|
||||
}
|
||||
if (!_a_show.animating()) {
|
||||
|
@ -1425,7 +1428,7 @@ void MainWidget::ui_showPeerHistory(
|
|||
}
|
||||
}
|
||||
|
||||
if (!_dialogs->isHidden()) {
|
||||
if (_dialogs && !_dialogs->isHidden()) {
|
||||
if (!back) {
|
||||
if (const auto history = _history->history()) {
|
||||
_dialogs->scrollToEntry(Dialogs::RowDescriptor(
|
||||
|
@ -1676,7 +1679,9 @@ void MainWidget::showNewSection(
|
|||
_history->finishAnimating();
|
||||
_history->showHistory(0, 0);
|
||||
_history->hide();
|
||||
if (isOneColumn()) _dialogs->hide();
|
||||
if (isOneColumn() && _dialogs) {
|
||||
_dialogs->hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (animationParams) {
|
||||
|
@ -1726,6 +1731,14 @@ void MainWidget::dropMainSection(Window::SectionWidget *widget) {
|
|||
anim::activation::background));
|
||||
}
|
||||
|
||||
PeerData *MainWidget::singlePeer() const {
|
||||
return _controller->singlePeer();
|
||||
}
|
||||
|
||||
bool MainWidget::isPrimary() const {
|
||||
return _controller->isPrimary();
|
||||
}
|
||||
|
||||
bool MainWidget::isMainSectionShown() const {
|
||||
return _mainSection || _history->peer();
|
||||
}
|
||||
|
@ -1802,7 +1815,9 @@ void MainWidget::showBackFromStack(
|
|||
}
|
||||
|
||||
void MainWidget::orderWidgets() {
|
||||
_dialogs->raise();
|
||||
if (_dialogs) {
|
||||
_dialogs->raise();
|
||||
}
|
||||
if (_player) {
|
||||
_player->raise();
|
||||
}
|
||||
|
@ -1812,7 +1827,9 @@ void MainWidget::orderWidgets() {
|
|||
if (_callTopBar) {
|
||||
_callTopBar->raise();
|
||||
}
|
||||
_sideShadow->raise();
|
||||
if (_sideShadow) {
|
||||
_sideShadow->raise();
|
||||
}
|
||||
if (_thirdShadow) {
|
||||
_thirdShadow->raise();
|
||||
}
|
||||
|
@ -1850,7 +1867,9 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m
|
|||
_dialogsWidth,
|
||||
height() - sectionTop));
|
||||
} else {
|
||||
_sideShadow->hide();
|
||||
if (_sideShadow) {
|
||||
_sideShadow->hide();
|
||||
}
|
||||
if (_thirdShadow) {
|
||||
_thirdShadow->hide();
|
||||
}
|
||||
|
@ -1859,7 +1878,9 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m
|
|||
sectionTop,
|
||||
width() - _dialogsWidth,
|
||||
height() - sectionTop));
|
||||
_sideShadow->show();
|
||||
if (_sideShadow) {
|
||||
_sideShadow->show();
|
||||
}
|
||||
if (_thirdShadow) {
|
||||
_thirdShadow->show();
|
||||
}
|
||||
|
@ -1879,7 +1900,9 @@ void MainWidget::windowShown() {
|
|||
}
|
||||
|
||||
void MainWidget::dialogsToUp() {
|
||||
_dialogs->jumpToTop();
|
||||
if (_dialogs) {
|
||||
_dialogs->jumpToTop();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::checkHistoryActivation() {
|
||||
|
@ -1950,7 +1973,9 @@ int MainWidget::getThirdSectionTop() const {
|
|||
}
|
||||
|
||||
void MainWidget::hideAll() {
|
||||
_dialogs->hide();
|
||||
if (_dialogs) {
|
||||
_dialogs->hide();
|
||||
}
|
||||
_history->hide();
|
||||
if (_mainSection) {
|
||||
_mainSection->hide();
|
||||
|
@ -1958,7 +1983,9 @@ void MainWidget::hideAll() {
|
|||
if (_thirdSection) {
|
||||
_thirdSection->hide();
|
||||
}
|
||||
_sideShadow->hide();
|
||||
if (_sideShadow) {
|
||||
_sideShadow->hide();
|
||||
}
|
||||
if (_thirdShadow) {
|
||||
_thirdShadow->hide();
|
||||
}
|
||||
|
@ -1978,11 +2005,14 @@ void MainWidget::showAll() {
|
|||
Ui::show(Box<Ui::InformBox>(tr::lng_cloud_password_updated(tr::now)));
|
||||
}
|
||||
if (isOneColumn()) {
|
||||
_sideShadow->hide();
|
||||
if (_sideShadow) {
|
||||
_sideShadow->hide();
|
||||
}
|
||||
if (_hider) {
|
||||
_hider->hide();
|
||||
}
|
||||
if (selectingPeer()) {
|
||||
Assert(_dialogs != nullptr);
|
||||
_dialogs->showFast();
|
||||
_history->hide();
|
||||
if (_mainSection) _mainSection->hide();
|
||||
|
@ -1992,22 +2022,23 @@ void MainWidget::showAll() {
|
|||
_history->show();
|
||||
_history->updateControlsGeometry();
|
||||
} else {
|
||||
Assert(_dialogs != nullptr);
|
||||
_dialogs->showFast();
|
||||
_history->hide();
|
||||
}
|
||||
if (!selectingPeer()) {
|
||||
if (_mainSection) {
|
||||
_dialogs->hide();
|
||||
} else if (isMainSectionShown()) {
|
||||
_dialogs->hide();
|
||||
}
|
||||
if (!selectingPeer() && _dialogs && isMainSectionShown()) {
|
||||
_dialogs->hide();
|
||||
}
|
||||
} else {
|
||||
_sideShadow->show();
|
||||
if (_sideShadow) {
|
||||
_sideShadow->show();
|
||||
}
|
||||
if (_hider) {
|
||||
_hider->show();
|
||||
}
|
||||
_dialogs->showFast();
|
||||
if (_dialogs) {
|
||||
_dialogs->showFast();
|
||||
}
|
||||
if (_mainSection) {
|
||||
_mainSection->show();
|
||||
} else {
|
||||
|
@ -2046,11 +2077,13 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
|
|||
|
||||
void MainWidget::updateControlsGeometry() {
|
||||
updateWindowAdaptiveLayout();
|
||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
_a_dialogsWidth.stop();
|
||||
}
|
||||
if (!_a_dialogsWidth.animating()) {
|
||||
_dialogs->stopWidthAnimation();
|
||||
if (_dialogs) {
|
||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
_a_dialogsWidth.stop();
|
||||
}
|
||||
if (!_a_dialogsWidth.animating()) {
|
||||
_dialogs->stopWidthAnimation();
|
||||
}
|
||||
}
|
||||
if (isThreeColumn()) {
|
||||
if (!_thirdSection
|
||||
|
@ -2078,8 +2111,12 @@ void MainWidget::updateControlsGeometry() {
|
|||
_thirdSection.destroy();
|
||||
_thirdShadow.destroy();
|
||||
}
|
||||
auto mainSectionTop = getMainSectionTop();
|
||||
auto dialogsWidth = qRound(_a_dialogsWidth.value(_dialogsWidth));
|
||||
const auto mainSectionTop = getMainSectionTop();
|
||||
auto dialogsWidth = _dialogs
|
||||
? qRound(_a_dialogsWidth.value(_dialogsWidth))
|
||||
: isOneColumn()
|
||||
? _dialogsWidth
|
||||
: 0;
|
||||
if (isOneColumn()) {
|
||||
if (_callTopBar) {
|
||||
_callTopBar->resizeToWidth(dialogsWidth);
|
||||
|
@ -2093,13 +2130,19 @@ void MainWidget::updateControlsGeometry() {
|
|||
_player->resizeToWidth(dialogsWidth);
|
||||
_player->moveToLeft(0, _callTopBarHeight + _exportTopBarHeight);
|
||||
}
|
||||
auto mainSectionGeometry = QRect(
|
||||
const auto mainSectionGeometry = QRect(
|
||||
0,
|
||||
mainSectionTop,
|
||||
dialogsWidth,
|
||||
height() - mainSectionTop);
|
||||
_dialogs->setGeometryWithTopMoved(mainSectionGeometry, _contentScrollAddToY);
|
||||
_history->setGeometryWithTopMoved(mainSectionGeometry, _contentScrollAddToY);
|
||||
if (_dialogs) {
|
||||
_dialogs->setGeometryWithTopMoved(
|
||||
mainSectionGeometry,
|
||||
_contentScrollAddToY);
|
||||
}
|
||||
_history->setGeometryWithTopMoved(
|
||||
mainSectionGeometry,
|
||||
_contentScrollAddToY);
|
||||
if (_hider) _hider->setGeometry(0, 0, dialogsWidth, height());
|
||||
} else {
|
||||
auto thirdSectionWidth = _thirdSection ? _thirdColumnWidth : 0;
|
||||
|
@ -2111,17 +2154,21 @@ void MainWidget::updateControlsGeometry() {
|
|||
thirdSectionWidth,
|
||||
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 shadowHeight = height() - shadowTop;
|
||||
_sideShadow->setGeometryToLeft(
|
||||
dialogsWidth,
|
||||
shadowTop,
|
||||
st::lineWidth,
|
||||
shadowHeight);
|
||||
if (_dialogs) {
|
||||
accumulate_min(
|
||||
dialogsWidth,
|
||||
width() - st::columnMinimalWidthMain);
|
||||
_dialogs->setGeometryToLeft(0, 0, dialogsWidth, height());
|
||||
}
|
||||
if (_sideShadow) {
|
||||
_sideShadow->setGeometryToLeft(
|
||||
dialogsWidth,
|
||||
shadowTop,
|
||||
st::lineWidth,
|
||||
shadowHeight);
|
||||
}
|
||||
if (_thirdShadow) {
|
||||
_thirdShadow->setGeometryToLeft(
|
||||
width() - thirdSectionWidth - st::lineWidth,
|
||||
|
@ -2129,6 +2176,9 @@ void MainWidget::updateControlsGeometry() {
|
|||
st::lineWidth,
|
||||
shadowHeight);
|
||||
}
|
||||
const auto mainSectionWidth = width()
|
||||
- dialogsWidth
|
||||
- thirdSectionWidth;
|
||||
if (_callTopBar) {
|
||||
_callTopBar->resizeToWidth(mainSectionWidth);
|
||||
_callTopBar->moveToLeft(dialogsWidth, 0);
|
||||
|
@ -2143,14 +2193,29 @@ void MainWidget::updateControlsGeometry() {
|
|||
dialogsWidth,
|
||||
_callTopBarHeight + _exportTopBarHeight);
|
||||
}
|
||||
_history->setGeometryWithTopMoved({ dialogsWidth, mainSectionTop, mainSectionWidth, height() - mainSectionTop }, _contentScrollAddToY);
|
||||
_history->setGeometryWithTopMoved(QRect(
|
||||
dialogsWidth,
|
||||
mainSectionTop,
|
||||
mainSectionWidth,
|
||||
height() - mainSectionTop
|
||||
), _contentScrollAddToY);
|
||||
if (_hider) {
|
||||
_hider->setGeometryToLeft(dialogsWidth, 0, mainSectionWidth, height());
|
||||
_hider->setGeometryToLeft(
|
||||
dialogsWidth,
|
||||
0,
|
||||
mainSectionWidth,
|
||||
height());
|
||||
}
|
||||
}
|
||||
if (_mainSection) {
|
||||
auto mainSectionGeometry = QRect(_history->x(), mainSectionTop, _history->width(), height() - mainSectionTop);
|
||||
_mainSection->setGeometryWithTopMoved(mainSectionGeometry, _contentScrollAddToY);
|
||||
const auto mainSectionGeometry = QRect(
|
||||
_history->x(),
|
||||
mainSectionTop,
|
||||
_history->width(),
|
||||
height() - mainSectionTop);
|
||||
_mainSection->setGeometryWithTopMoved(
|
||||
mainSectionGeometry,
|
||||
_contentScrollAddToY);
|
||||
}
|
||||
refreshResizeAreas();
|
||||
if (_player) {
|
||||
|
@ -2252,7 +2317,7 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
|
|||
}
|
||||
|
||||
void MainWidget::updateDialogsWidthAnimated() {
|
||||
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
if (!_dialogs || Core::App().settings().dialogsWidthRatio() > 0) {
|
||||
return;
|
||||
}
|
||||
auto dialogsWidth = _dialogsWidth;
|
||||
|
@ -2383,7 +2448,8 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
|||
|| (_mainSection && (_mainSection == widget || _mainSection->isAncestorOf(widget)))
|
||||
|| (_thirdSection && (_thirdSection == widget || _thirdSection->isAncestorOf(widget)))) {
|
||||
_controller->dialogsListFocused().set(false);
|
||||
} else if (_dialogs == widget || _dialogs->isAncestorOf(widget)) {
|
||||
} else if (_dialogs
|
||||
&& (_dialogs == widget || _dialogs->isAncestorOf(widget))) {
|
||||
_controller->dialogsListFocused().set(true);
|
||||
}
|
||||
}
|
||||
|
@ -2404,13 +2470,19 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
|||
|
||||
void MainWidget::handleAdaptiveLayoutUpdate() {
|
||||
showAll();
|
||||
_sideShadow->setVisible(!isOneColumn());
|
||||
if (_sideShadow) {
|
||||
_sideShadow->setVisible(!isOneColumn());
|
||||
}
|
||||
if (_player) {
|
||||
_player->updateAdaptiveLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::handleHistoryBack() {
|
||||
// #TODO windows
|
||||
if (!_dialogs) {
|
||||
return;
|
||||
}
|
||||
const auto historyFromFolder = _history->history()
|
||||
? _history->history()->folder()
|
||||
: nullptr;
|
||||
|
@ -2487,6 +2559,11 @@ int MainWidget::backgroundFromY() const {
|
|||
}
|
||||
|
||||
void MainWidget::searchInChat(Dialogs::Key chat) {
|
||||
// #TODO windows
|
||||
if (!_dialogs) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_controller->openedFolder().current()) {
|
||||
_controller->closeFolder();
|
||||
}
|
||||
|
@ -2508,6 +2585,7 @@ void MainWidget::activate() {
|
|||
return;
|
||||
} else if (!_mainSection) {
|
||||
if (_hider) {
|
||||
Assert(_dialogs != nullptr);
|
||||
_dialogs->setInnerFocus();
|
||||
} else if (!Ui::isLayerShown()) {
|
||||
if (!cSendPaths().isEmpty()) {
|
||||
|
@ -2527,6 +2605,7 @@ void MainWidget::activate() {
|
|||
} else if (_history->peer()) {
|
||||
_history->activate();
|
||||
} else {
|
||||
Assert(_dialogs != nullptr);
|
||||
_dialogs->setInnerFocus();
|
||||
}
|
||||
}
|
||||
|
@ -2544,10 +2623,6 @@ bool MainWidget::doWeMarkAsRead() const {
|
|||
return isActive() && !_mainSection;
|
||||
}
|
||||
|
||||
int32 MainWidget::dlgsWidth() const {
|
||||
return _dialogs->width();
|
||||
}
|
||||
|
||||
void MainWidget::saveFieldToHistoryLocalDraft() {
|
||||
_history->saveFieldToHistoryLocalDraft();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "base/weak_ptr.h"
|
||||
#include "base/unique_qptr.h"
|
||||
#include "chat_helpers/bot_command.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/effects/animations.h"
|
||||
|
@ -112,8 +113,6 @@ class MainWidget
|
|||
: public Ui::RpWidget
|
||||
, private Media::Player::FloatDelegate
|
||||
, private base::Subscriber {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using SectionShow = Window::SectionShow;
|
||||
|
||||
|
@ -124,7 +123,8 @@ public:
|
|||
|
||||
[[nodiscard]] Main::Session &session() const;
|
||||
[[nodiscard]] not_null<Window::SessionController*> controller() const;
|
||||
|
||||
[[nodiscard]] PeerData *singlePeer() const;
|
||||
[[nodiscard]] bool isPrimary() const;
|
||||
[[nodiscard]] bool isMainSectionShown() const;
|
||||
[[nodiscard]] bool isThirdSectionShown() const;
|
||||
|
||||
|
@ -164,8 +164,6 @@ public:
|
|||
|
||||
void saveFieldToHistoryLocalDraft();
|
||||
|
||||
int32 dlgsWidth() const;
|
||||
|
||||
void showForwardLayer(Data::ForwardDraft &&draft);
|
||||
void showSendPathsLayer();
|
||||
void shareUrlLayer(const QString &url, const QString &text);
|
||||
|
@ -231,10 +229,6 @@ public:
|
|||
Fn<void()> callback,
|
||||
const SectionShow ¶ms) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void inlineResultLoadProgress(FileLoader *loader);
|
||||
void inlineResultLoadFailed(FileLoader *loader, bool started);
|
||||
|
||||
void dialogsCancelled();
|
||||
|
||||
protected:
|
||||
|
@ -340,12 +334,12 @@ private:
|
|||
int _thirdColumnWidth = 0;
|
||||
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::ResizeArea> _firstColumnResizeArea = { nullptr };
|
||||
object_ptr<Ui::ResizeArea> _thirdColumnResizeArea = { nullptr };
|
||||
object_ptr<Dialogs::Widget> _dialogs;
|
||||
object_ptr<HistoryWidget> _history;
|
||||
const base::unique_qptr<Dialogs::Widget> _dialogs;
|
||||
const base::unique_qptr<HistoryWidget> _history;
|
||||
object_ptr<Window::SectionWidget> _mainSection = { nullptr };
|
||||
object_ptr<Window::SectionWidget> _thirdSection = { nullptr };
|
||||
std::shared_ptr<Window::SectionMemento> _thirdSectionFromStack;
|
||||
|
|
|
@ -337,6 +337,9 @@ void MainWindow::setupMain() {
|
|||
auto created = object_ptr<MainWidget>(bodyWidget(), sessionController());
|
||||
clearWidgets();
|
||||
_main = std::move(created);
|
||||
if (const auto peer = singlePeer()) {
|
||||
_main->controller()->showPeerHistory(peer);
|
||||
}
|
||||
if (_passcodeLock) {
|
||||
_main->hide();
|
||||
} else {
|
||||
|
|
|
@ -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 {
|
||||
return _window->widget();
|
||||
}
|
||||
|
|
|
@ -252,6 +252,8 @@ public:
|
|||
[[nodiscard]] Controller &window() const {
|
||||
return *_window;
|
||||
}
|
||||
[[nodiscard]] PeerData *singlePeer() const;
|
||||
[[nodiscard]] bool isPrimary() const;
|
||||
[[nodiscard]] not_null<::MainWindow*> widget() const;
|
||||
[[nodiscard]] not_null<MainWidget*> content() const;
|
||||
[[nodiscard]] Adaptive &adaptive() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue