Fix returning of tabbed panel in third column.

This commit is contained in:
John Preston 2020-05-05 16:55:05 +04:00
parent 0e16b3fe69
commit 1fa22398a9
8 changed files with 44 additions and 24 deletions

View File

@ -4066,20 +4066,22 @@ void HistoryWidget::onModerateKeyActivate(int index, bool *outHandled) {
*outHandled = _keyboard->isHidden() ? false : _keyboard->moderateKeyActivate(index); *outHandled = _keyboard->isHidden() ? false : _keyboard->moderateKeyActivate(index);
} }
void HistoryWidget::pushTabbedSelectorToThirdSection( bool HistoryWidget::pushTabbedSelectorToThirdSection(
not_null<PeerData*> peer,
const Window::SectionShow &params) { const Window::SectionShow &params) {
if (!_history || !_tabbedPanel) { if (!_tabbedPanel) {
return; return true;
} else if (!_canSendMessages) { } else if (!peer->canWrite()) {
session().settings().setTabbedReplacedWithInfo(true); session().settings().setTabbedReplacedWithInfo(true);
controller()->showPeerInfo(_peer, params.withThirdColumn()); controller()->showPeerInfo(peer, params.withThirdColumn());
return; return false;
} }
session().settings().setTabbedReplacedWithInfo(false); session().settings().setTabbedReplacedWithInfo(false);
controller()->resizeForThirdSection(); controller()->resizeForThirdSection();
controller()->showSection( controller()->showSection(
ChatHelpers::TabbedMemento(), ChatHelpers::TabbedMemento(),
params.withThirdColumn()); params.withThirdColumn());
return true;
} }
bool HistoryWidget::returnTabbedSelector() { bool HistoryWidget::returnTabbedSelector() {
@ -4109,11 +4111,15 @@ void HistoryWidget::setTabbedPanel(std::unique_ptr<TabbedPanel> panel) {
} }
void HistoryWidget::toggleTabbedSelectorMode() { void HistoryWidget::toggleTabbedSelectorMode() {
if (!_peer) {
return;
}
if (_tabbedPanel) { if (_tabbedPanel) {
if (controller()->canShowThirdSection() && !Adaptive::OneColumn()) { if (controller()->canShowThirdSection() && !Adaptive::OneColumn()) {
session().settings().setTabbedSelectorSectionEnabled(true); session().settings().setTabbedSelectorSectionEnabled(true);
session().saveSettingsDelayed(); session().saveSettingsDelayed();
pushTabbedSelectorToThirdSection( pushTabbedSelectorToThirdSection(
_peer,
Window::SectionShow::Way::ClearStack); Window::SectionShow::Way::ClearStack);
} else { } else {
_tabbedPanel->toggleAnimated(); _tabbedPanel->toggleAnimated();

View File

@ -251,7 +251,8 @@ public:
void hideInfoTooltip(anim::type animated); void hideInfoTooltip(anim::type animated);
// Tabbed selector management. // Tabbed selector management.
void pushTabbedSelectorToThirdSection( bool pushTabbedSelectorToThirdSection(
not_null<PeerData*> peer,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
bool returnTabbedSelector() override; bool returnTabbedSelector() override;

View File

@ -337,10 +337,11 @@ void ComposeControls::escape() {
_cancelRequests.fire({}); _cancelRequests.fire({});
} }
void ComposeControls::pushTabbedSelectorToThirdSection( bool ComposeControls::pushTabbedSelectorToThirdSection(
not_null<PeerData*> peer,
const Window::SectionShow &params) { const Window::SectionShow &params) {
if (!_tabbedPanel) { if (!_tabbedPanel) {
return; return true;
//} else if (!_canSendMessages) { //} else if (!_canSendMessages) {
// session().settings().setTabbedReplacedWithInfo(true); // session().settings().setTabbedReplacedWithInfo(true);
// _window->showPeerInfo(_peer, params.withThirdColumn()); // _window->showPeerInfo(_peer, params.withThirdColumn());
@ -355,6 +356,7 @@ void ComposeControls::pushTabbedSelectorToThirdSection(
_window->showSection( _window->showSection(
ChatHelpers::TabbedMemento(), ChatHelpers::TabbedMemento(),
params.withThirdColumn()); params.withThirdColumn());
return true;
} }
bool ComposeControls::returnTabbedSelector() { bool ComposeControls::returnTabbedSelector() {
@ -385,11 +387,15 @@ void ComposeControls::setTabbedPanel(
} }
void ComposeControls::toggleTabbedSelectorMode() { void ComposeControls::toggleTabbedSelectorMode() {
if (!_history) {
return;
}
if (_tabbedPanel) { if (_tabbedPanel) {
if (_window->canShowThirdSection() && !Adaptive::OneColumn()) { if (_window->canShowThirdSection() && !Adaptive::OneColumn()) {
session().settings().setTabbedSelectorSectionEnabled(true); session().settings().setTabbedSelectorSectionEnabled(true);
session().saveSettingsDelayed(); session().saveSettingsDelayed();
pushTabbedSelectorToThirdSection( pushTabbedSelectorToThirdSection(
_history->peer,
Window::SectionShow::Way::ClearStack); Window::SectionShow::Way::ClearStack);
} else { } else {
_tabbedPanel->toggleAnimated(); _tabbedPanel->toggleAnimated();

View File

@ -76,7 +76,9 @@ public:
[[nodiscard]] auto inlineResultChosen() const [[nodiscard]] auto inlineResultChosen() const
-> rpl::producer<ChatHelpers::TabbedSelector::InlineChosen>; -> rpl::producer<ChatHelpers::TabbedSelector::InlineChosen>;
void pushTabbedSelectorToThirdSection(const Window::SectionShow &params); bool pushTabbedSelectorToThirdSection(
not_null<PeerData*> peer,
const Window::SectionShow &params);
bool returnTabbedSelector(); bool returnTabbedSelector();
void showForGrab(); void showForGrab();

View File

@ -706,9 +706,10 @@ void ScheduledWidget::setInternalState(
restoreState(memento); restoreState(memento);
} }
void ScheduledWidget::pushTabbedSelectorToThirdSection( bool ScheduledWidget::pushTabbedSelectorToThirdSection(
not_null<PeerData*> peer,
const Window::SectionShow &params) { const Window::SectionShow &params) {
_composeControls->pushTabbedSelectorToThirdSection(params); return _composeControls->pushTabbedSelectorToThirdSection(peer, params);
} }
bool ScheduledWidget::returnTabbedSelector() { bool ScheduledWidget::returnTabbedSelector() {

View File

@ -82,7 +82,8 @@ public:
not_null<ScheduledMemento*> memento); not_null<ScheduledMemento*> memento);
// Tabbed selector management. // Tabbed selector management.
void pushTabbedSelectorToThirdSection( bool pushTabbedSelectorToThirdSection(
not_null<PeerData*> peer,
const Window::SectionShow &params) override; const Window::SectionShow &params) override;
bool returnTabbedSelector() override; bool returnTabbedSelector() override;

View File

@ -2380,11 +2380,11 @@ void MainWidget::updateControlsGeometry() {
Window::SectionShow::Way::ClearStack, Window::SectionShow::Way::ClearStack,
anim::type::instant, anim::type::instant,
anim::activation::background); anim::activation::background);
if (session().settings().tabbedSelectorSectionEnabled()) { const auto active = _controller->activeChatCurrent();
_history->pushTabbedSelectorToThirdSection(params); if (const auto peer = active.peer()) {
} else if (session().settings().thirdSectionInfoEnabled()) { if (session().settings().tabbedSelectorSectionEnabled()) {
const auto active = _controller->activeChatCurrent(); _history->pushTabbedSelectorToThirdSection(peer, params);
if (const auto peer = active.peer()) { } else if (session().settings().thirdSectionInfoEnabled()) {
_controller->showSection( _controller->showSection(
Info::Memento::Default(peer), Info::Memento::Default(peer),
params.withThirdColumn()); params.withThirdColumn());
@ -2633,9 +2633,9 @@ void MainWidget::updateThirdColumnToCurrentChat(
std::move(*thirdSectionForCurrentMainSection(key)), std::move(*thirdSectionForCurrentMainSection(key)),
params.withThirdColumn()); params.withThirdColumn());
}; };
auto switchTabbedFast = [&] { auto switchTabbedFast = [&](not_null<PeerData*> peer) {
saveOldThirdSection(); saveOldThirdSection();
_history->pushTabbedSelectorToThirdSection(params); return _history->pushTabbedSelectorToThirdSection(peer, params);
}; };
if (Adaptive::ThreeColumn() if (Adaptive::ThreeColumn()
&& session().settings().tabbedSelectorSectionEnabled() && session().settings().tabbedSelectorSectionEnabled()
@ -2644,9 +2644,10 @@ void MainWidget::updateThirdColumnToCurrentChat(
switchInfoFast(); switchInfoFast();
session().settings().setTabbedSelectorSectionEnabled(true); session().settings().setTabbedSelectorSectionEnabled(true);
session().settings().setTabbedReplacedWithInfo(true); session().settings().setTabbedReplacedWithInfo(true);
} else if (session().settings().tabbedReplacedWithInfo()) { } else if (session().settings().tabbedReplacedWithInfo()
&& key.history()
&& switchTabbedFast(key.history()->peer)) {
session().settings().setTabbedReplacedWithInfo(false); session().settings().setTabbedReplacedWithInfo(false);
switchTabbedFast();
} }
} else { } else {
session().settings().setTabbedReplacedWithInfo(false); session().settings().setTabbedReplacedWithInfo(false);

View File

@ -46,8 +46,10 @@ public:
[[nodiscard]] Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
// Tabbed selector management. // Tabbed selector management.
virtual void pushTabbedSelectorToThirdSection( virtual bool pushTabbedSelectorToThirdSection(
const Window::SectionShow &params) { not_null<PeerData*> peer,
const Window::SectionShow &params) {
return false;
} }
virtual bool returnTabbedSelector() { virtual bool returnTabbedSelector() {
return false; return false;