Allow wide chats in empty window.

This commit is contained in:
John Preston 2024-05-16 13:35:21 +04:00
parent 4d4cf472c8
commit d91b75b8f8
9 changed files with 149 additions and 57 deletions

View file

@ -123,7 +123,8 @@ Settings::Settings()
: _sendSubmitWay(Ui::InputSubmitSettings::Enter) : _sendSubmitWay(Ui::InputSubmitSettings::Enter)
, _floatPlayerColumn(Window::Column::Second) , _floatPlayerColumn(Window::Column::Second)
, _floatPlayerCorner(RectPart::TopRight) , _floatPlayerCorner(RectPart::TopRight)
, _dialogsWidthRatio(DefaultDialogsWidthRatio()) { , _dialogsWithChatWidthRatio(DefaultDialogsWidthRatio())
, _dialogsNoChatWidthRatio(DefaultDialogsWidthRatio()) {
} }
Settings::~Settings() = default; Settings::~Settings() = default;
@ -218,7 +219,8 @@ QByteArray Settings::serialize() const {
+ Serialize::stringSize(_callCaptureDeviceId.current()) + Serialize::stringSize(_callCaptureDeviceId.current())
+ Serialize::bytearraySize(ivPosition) + Serialize::bytearraySize(ivPosition)
+ Serialize::stringSize(noWarningExtensions) + Serialize::stringSize(noWarningExtensions)
+ Serialize::stringSize(_customFontFamily); + Serialize::stringSize(_customFontFamily)
+ sizeof(qint32);
auto result = QByteArray(); auto result = QByteArray();
result.reserve(size); result.reserve(size);
@ -280,7 +282,7 @@ QByteArray Settings::serialize() const {
<< qint32(_floatPlayerCorner) << qint32(_floatPlayerCorner)
<< qint32(_thirdSectionInfoEnabled ? 1 : 0) << qint32(_thirdSectionInfoEnabled ? 1 : 0)
<< qint32(std::clamp( << qint32(std::clamp(
qRound(_dialogsWidthRatio.current() * 1000000), qRound(_dialogsWithChatWidthRatio.current() * 1000000),
0, 0,
1000000)) 1000000))
<< qint32(_thirdColumnWidth.current()) << qint32(_thirdColumnWidth.current())
@ -365,7 +367,11 @@ QByteArray Settings::serialize() const {
<< _callCaptureDeviceId.current() << _callCaptureDeviceId.current()
<< ivPosition << ivPosition
<< noWarningExtensions << noWarningExtensions
<< _customFontFamily; << _customFontFamily
<< qint32(std::clamp(
qRound(_dialogsNoChatWidthRatio.current() * 1000000),
0,
1000000));
} }
Ensures(result.size() == size); Ensures(result.size() == size);
@ -434,7 +440,8 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second); qint32 floatPlayerColumn = static_cast<qint32>(Window::Column::Second);
qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight); qint32 floatPlayerCorner = static_cast<qint32>(RectPart::TopRight);
qint32 thirdSectionInfoEnabled = 0; qint32 thirdSectionInfoEnabled = 0;
float64 dialogsWidthRatio = _dialogsWidthRatio.current(); float64 dialogsWithChatWidthRatio = _dialogsWithChatWidthRatio.current();
float64 dialogsNoChatWidthRatio = _dialogsNoChatWidthRatio.current();
qint32 thirdColumnWidth = _thirdColumnWidth.current(); qint32 thirdColumnWidth = _thirdColumnWidth.current();
qint32 thirdSectionExtendedBy = _thirdSectionExtendedBy; qint32 thirdSectionExtendedBy = _thirdSectionExtendedBy;
qint32 notifyFromAll = _notifyFromAll ? 1 : 0; qint32 notifyFromAll = _notifyFromAll ? 1 : 0;
@ -546,18 +553,18 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
>> mainMenuAccountsShown; >> mainMenuAccountsShown;
} }
if (!stream.atEnd()) { if (!stream.atEnd()) {
auto dialogsWidthRatioInt = qint32(); auto dialogsWithChatWidthRatioInt = qint32();
stream stream
>> tabbedSelectorSectionEnabled >> tabbedSelectorSectionEnabled
>> floatPlayerColumn >> floatPlayerColumn
>> floatPlayerCorner >> floatPlayerCorner
>> thirdSectionInfoEnabled >> thirdSectionInfoEnabled
>> dialogsWidthRatioInt >> dialogsWithChatWidthRatioInt
>> thirdColumnWidth >> thirdColumnWidth
>> thirdSectionExtendedBy >> thirdSectionExtendedBy
>> notifyFromAll; >> notifyFromAll;
dialogsWidthRatio = std::clamp( dialogsWithChatWidthRatio = std::clamp(
dialogsWidthRatioInt / 1000000., dialogsWithChatWidthRatioInt / 1000000.,
0., 0.,
1.); 1.);
} }
@ -772,6 +779,15 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> customFontFamily; stream >> customFontFamily;
} }
if (!stream.atEnd()) {
auto dialogsNoChatWidthRatioInt = qint32();
stream
>> dialogsNoChatWidthRatioInt;
dialogsNoChatWidthRatio = std::clamp(
dialogsNoChatWidthRatioInt / 1000000.,
0.,
1.);
}
if (stream.status() != QDataStream::Ok) { if (stream.status() != QDataStream::Ok) {
LOG(("App Error: " LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()")); "Bad data for Core::Settings::constructFromSerialized()"));
@ -872,7 +888,10 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
case RectPart::BottomRight: _floatPlayerCorner = uncheckedCorner; break; case RectPart::BottomRight: _floatPlayerCorner = uncheckedCorner; break;
} }
_thirdSectionInfoEnabled = thirdSectionInfoEnabled; _thirdSectionInfoEnabled = thirdSectionInfoEnabled;
_dialogsWidthRatio = dialogsWidthRatio; _dialogsWithChatWidthRatio = dialogsWithChatWidthRatio;
_dialogsNoChatWidthRatio = (dialogsWithChatWidthRatio > 0)
? dialogsWithChatWidthRatio
: dialogsNoChatWidthRatio;
_thirdColumnWidth = thirdColumnWidth; _thirdColumnWidth = thirdColumnWidth;
_thirdSectionExtendedBy = thirdSectionExtendedBy; _thirdSectionExtendedBy = thirdSectionExtendedBy;
if (_thirdSectionInfoEnabled) { if (_thirdSectionInfoEnabled) {
@ -1025,16 +1044,46 @@ void Settings::setTabbedReplacedWithInfo(bool enabled) {
} }
} }
void Settings::setDialogsWidthRatio(float64 ratio) { void Settings::updateDialogsWidthRatio(float64 ratio, bool nochat) {
_dialogsWidthRatio = ratio; const auto changeWithChat = !nochat
|| (dialogsWithChatWidthRatio() > 0)
|| _dialogsWidthSetToZeroWithoutChat;
const auto changedWithChat = changeWithChat
&& (dialogsWithChatWidthRatio() != ratio);
const auto changeNoChat = nochat
|| (dialogsWithChatWidthRatio() != ratio);
const auto changedNoChat = changeNoChat
&& (dialogsNoChatWidthRatio() != ratio);
if (changedWithChat) {
_dialogsWidthSetToZeroWithoutChat = nochat && !(ratio > 0);
_dialogsWithChatWidthRatio = ratio;
}
if (changedNoChat) {
_dialogsNoChatWidthRatio = ratio;
}
} }
float64 Settings::dialogsWidthRatio() const { float64 Settings::dialogsWidthRatio(bool nochat) const {
return _dialogsWidthRatio.current(); const auto withchat = dialogsWithChatWidthRatio();
return (!nochat || withchat > 0) ? withchat : dialogsNoChatWidthRatio();
} }
rpl::producer<float64> Settings::dialogsWidthRatioChanges() const { float64 Settings::dialogsWithChatWidthRatio() const {
return _dialogsWidthRatio.changes(); return _dialogsWithChatWidthRatio.current();
}
rpl::producer<float64> Settings::dialogsWithChatWidthRatioChanges() const {
return _dialogsWithChatWidthRatio.changes();
}
float64 Settings::dialogsNoChatWidthRatio() const {
return _dialogsNoChatWidthRatio.current();
}
rpl::producer<float64> Settings::dialogsNoChatWidthRatioChanges() const {
return _dialogsNoChatWidthRatio.changes();
} }
void Settings::setThirdColumnWidth(int width) { void Settings::setThirdColumnWidth(int width) {
@ -1326,7 +1375,8 @@ void Settings::resetOnLastLogout() {
_floatPlayerCorner = RectPart::TopRight; // per-window _floatPlayerCorner = RectPart::TopRight; // per-window
_thirdSectionInfoEnabled = true; // per-window _thirdSectionInfoEnabled = true; // per-window
_thirdSectionExtendedBy = -1; // per-window _thirdSectionExtendedBy = -1; // per-window
_dialogsWidthRatio = DefaultDialogsWidthRatio(); // per-window _dialogsWithChatWidthRatio = DefaultDialogsWidthRatio(); // per-window
_dialogsNoChatWidthRatio = DefaultDialogsWidthRatio(); // per-window
_thirdColumnWidth = kDefaultThirdColumnWidth; // p-w _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
_notifyFromAll = true; _notifyFromAll = true;
_tabbedReplacedWithInfo = false; // per-window _tabbedReplacedWithInfo = false; // per-window

View file

@ -614,9 +614,15 @@ public:
[[nodiscard]] RectPart floatPlayerCorner() const { [[nodiscard]] RectPart floatPlayerCorner() const {
return _floatPlayerCorner; return _floatPlayerCorner;
} }
void setDialogsWidthRatio(float64 ratio);
[[nodiscard]] float64 dialogsWidthRatio() const; void updateDialogsWidthRatio(float64 ratio, bool nochat);
[[nodiscard]] rpl::producer<float64> dialogsWidthRatioChanges() const; [[nodiscard]] float64 dialogsWidthRatio(bool nochat) const;
[[nodiscard]] float64 dialogsWithChatWidthRatio() const;
[[nodiscard]] rpl::producer<float64> dialogsWithChatWidthRatioChanges() const;
[[nodiscard]] float64 dialogsNoChatWidthRatio() const;
[[nodiscard]] rpl::producer<float64> dialogsNoChatWidthRatioChanges() const;
void setThirdColumnWidth(int width); void setThirdColumnWidth(int width);
[[nodiscard]] int thirdColumnWidth() const; [[nodiscard]] int thirdColumnWidth() const;
[[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const; [[nodiscard]] rpl::producer<int> thirdColumnWidthChanges() const;
@ -969,7 +975,8 @@ private:
bool _thirdSectionInfoEnabled = true; // per-window bool _thirdSectionInfoEnabled = true; // per-window
rpl::event_stream<bool> _thirdSectionInfoEnabledValue; // per-window rpl::event_stream<bool> _thirdSectionInfoEnabledValue; // per-window
int _thirdSectionExtendedBy = -1; // per-window int _thirdSectionExtendedBy = -1; // per-window
rpl::variable<float64> _dialogsWidthRatio; // per-window rpl::variable<float64> _dialogsWithChatWidthRatio; // per-window
rpl::variable<float64> _dialogsNoChatWidthRatio; // per-window
rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w rpl::variable<int> _thirdColumnWidth = kDefaultThirdColumnWidth; // p-w
bool _notifyFromAll = true; bool _notifyFromAll = true;
rpl::variable<bool> _nativeWindowFrame = false; rpl::variable<bool> _nativeWindowFrame = false;
@ -1015,6 +1022,7 @@ private:
float64 _rememberedSongVolume = kDefaultVolume; float64 _rememberedSongVolume = kDefaultVolume;
bool _rememberedSoundNotifyFromTray = false; bool _rememberedSoundNotifyFromTray = false;
bool _rememberedFlashBounceNotifyFromTray = false; bool _rememberedFlashBounceNotifyFromTray = false;
bool _dialogsWidthSetToZeroWithoutChat = false;
QByteArray _photoEditorBrush; QByteArray _photoEditorBrush;

View file

@ -2667,8 +2667,9 @@ void Widget::updateForceDisplayWide() {
void Widget::showForum( void Widget::showForum(
not_null<Data::Forum*> forum, not_null<Data::Forum*> forum,
const Window::SectionShow &params) { const Window::SectionShow &params) {
const auto nochat = !controller()->mainSectionShown();
if (!params.childColumn if (!params.childColumn
|| !Core::App().settings().dialogsWidthRatio() || !Core::App().settings().dialogsWidthRatio(nochat)
|| (_layout != Layout::Main) || (_layout != Layout::Main)
|| OptionForumHideChatsList.value()) { || OptionForumHideChatsList.value()) {
changeOpenedForum(forum, params.animated); changeOpenedForum(forum, params.animated);

View file

@ -128,7 +128,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
base::flat_set<PeerId> groupEmojiSectionHidden; base::flat_set<PeerId> groupEmojiSectionHidden;
qint32 appThirdSectionInfoEnabled = 0; qint32 appThirdSectionInfoEnabled = 0;
qint32 legacySmallDialogsList = 0; qint32 legacySmallDialogsList = 0;
float64 appDialogsWidthRatio = app.dialogsWidthRatio(); float64 appDialogsWidthRatio = app.dialogsWidthRatio(false);
int appThirdColumnWidth = app.thirdColumnWidth(); int appThirdColumnWidth = app.thirdColumnWidth();
int appThirdSectionExtendedBy = app.thirdSectionExtendedBy(); int appThirdSectionExtendedBy = app.thirdSectionExtendedBy();
qint32 appSendFilesWay = app.sendFilesWay().serialize(); qint32 appSendFilesWay = app.sendFilesWay().serialize();
@ -535,7 +535,7 @@ void SessionSettings::addFromSerialized(const QByteArray &serialized) {
case RectPart::BottomRight: app.setFloatPlayerCorner(uncheckedCorner); break; case RectPart::BottomRight: app.setFloatPlayerCorner(uncheckedCorner); break;
} }
app.setThirdSectionInfoEnabled(appThirdSectionInfoEnabled); app.setThirdSectionInfoEnabled(appThirdSectionInfoEnabled);
app.setDialogsWidthRatio(appDialogsWidthRatio); app.updateDialogsWidthRatio(appDialogsWidthRatio, false);
app.setThirdColumnWidth(appThirdColumnWidth); app.setThirdColumnWidth(appThirdColumnWidth);
app.setThirdSectionExtendedBy(appThirdSectionExtendedBy); app.setThirdSectionExtendedBy(appThirdSectionExtendedBy);
} }

View file

@ -303,8 +303,16 @@ MainWidget::MainWidget(
}); });
}, lifetime()); }, lifetime());
const auto filter = [=](bool mainSectionShown) {
return rpl::filter([=] {
return (_controller->mainSectionShown() == mainSectionShown);
});
};
rpl::merge( rpl::merge(
Core::App().settings().dialogsWidthRatioChanges() | rpl::to_empty, Core::App().settings().dialogsWithChatWidthRatioChanges(
) | filter(true) | rpl::to_empty,
Core::App().settings().dialogsNoChatWidthRatioChanges(
) | filter(false) | rpl::to_empty,
Core::App().settings().thirdColumnWidthChanges() | rpl::to_empty Core::App().settings().thirdColumnWidthChanges() | rpl::to_empty
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
updateControlsGeometry(); updateControlsGeometry();
@ -1408,6 +1416,7 @@ void MainWidget::showHistory(
auto onlyDialogs = noPeer && isOneColumn(); auto onlyDialogs = noPeer && isOneColumn();
_mainSection.destroy(); _mainSection.destroy();
updateMainSectionShown();
updateControlsGeometry(); updateControlsGeometry();
if (noPeer) { if (noPeer) {
@ -1781,6 +1790,7 @@ void MainWidget::showNewSection(
if (const auto entry = _mainSection->activeChat(); entry.key) { if (const auto entry = _mainSection->activeChat(); entry.key) {
_controller->setActiveChatEntry(entry); _controller->setActiveChatEntry(entry);
} }
updateMainSectionShown();
// Depends on SessionController::activeChatEntry // Depends on SessionController::activeChatEntry
// for tabbed selector showing in the third column. // for tabbed selector showing in the third column.
@ -1815,22 +1825,16 @@ void MainWidget::checkMainSectionToLayer() {
} }
Ui::FocusPersister persister(this); Ui::FocusPersister persister(this);
if (auto layer = _mainSection->moveContentToLayer(rect())) { if (auto layer = _mainSection->moveContentToLayer(rect())) {
dropMainSection(_mainSection); _mainSection.destroy();
_controller->showBackFromStack(
SectionShow(
anim::type::instant,
anim::activation::background));
_controller->showSpecialLayer( _controller->showSpecialLayer(
std::move(layer), std::move(layer),
anim::type::instant); anim::type::instant);
} }
} updateMainSectionShown();
void MainWidget::dropMainSection(Window::SectionWidget *widget) {
if (_mainSection != widget) {
return;
}
_mainSection.destroy();
_controller->showBackFromStack(
SectionShow(
anim::type::instant,
anim::activation::background));
} }
PeerData *MainWidget::singlePeer() const { PeerData *MainWidget::singlePeer() const {
@ -2236,13 +2240,18 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
updateControlsGeometry(); updateControlsGeometry();
} }
void MainWidget::updateMainSectionShown() {
_controller->setMainSectionShown(_mainSection || _history->peer());
}
void MainWidget::updateControlsGeometry() { void MainWidget::updateControlsGeometry() {
if (!width()) { if (!width()) {
return; return;
} }
updateWindowAdaptiveLayout(); updateWindowAdaptiveLayout();
if (_dialogs) { if (_dialogs) {
if (Core::App().settings().dialogsWidthRatio() > 0) { const auto nochat = !_controller->mainSectionShown();
if (Core::App().settings().dialogsWidthRatio(nochat) > 0) {
_a_dialogsWidth.stop(); _a_dialogsWidth.stop();
} }
if (!_a_dialogsWidth.animating()) { if (!_a_dialogsWidth.animating()) {
@ -2444,19 +2453,22 @@ void MainWidget::ensureFirstColumnResizeAreaCreated() {
return; return;
} }
auto moveLeftCallback = [=](int globalLeft) { auto moveLeftCallback = [=](int globalLeft) {
auto newWidth = globalLeft - mapToGlobal(QPoint(0, 0)).x(); const auto newWidth = globalLeft - mapToGlobal(QPoint(0, 0)).x();
auto newRatio = (newWidth < st::columnMinimalWidthLeft / 2) const auto newRatio = (newWidth < st::columnMinimalWidthLeft / 2)
? 0. ? 0.
: float64(newWidth) / width(); : float64(newWidth) / width();
Core::App().settings().setDialogsWidthRatio(newRatio); const auto nochat = !_controller->mainSectionShown();
Core::App().settings().updateDialogsWidthRatio(newRatio, nochat);
}; };
auto moveFinishedCallback = [=] { auto moveFinishedCallback = [=] {
if (isOneColumn()) { if (isOneColumn()) {
return; return;
} }
if (Core::App().settings().dialogsWidthRatio() > 0) { const auto nochat = !_controller->mainSectionShown();
Core::App().settings().setDialogsWidthRatio( if (Core::App().settings().dialogsWidthRatio(nochat) > 0) {
float64(_dialogsWidth) / width()); Core::App().settings().updateDialogsWidthRatio(
float64(_dialogsWidth) / width(),
nochat);
} }
Core::App().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
}; };
@ -2491,12 +2503,13 @@ void MainWidget::ensureThirdColumnResizeAreaCreated() {
} }
void MainWidget::updateDialogsWidthAnimated() { void MainWidget::updateDialogsWidthAnimated() {
if (!_dialogs || Core::App().settings().dialogsWidthRatio() > 0) { const auto nochat = !_controller->mainSectionShown();
if (!_dialogs || Core::App().settings().dialogsWidthRatio(nochat) > 0) {
return; return;
} }
auto dialogsWidth = _dialogsWidth; auto dialogsWidth = _dialogsWidth;
updateWindowAdaptiveLayout(); updateWindowAdaptiveLayout();
if (!Core::App().settings().dialogsWidthRatio() if (!Core::App().settings().dialogsWidthRatio(nochat)
&& (_dialogsWidth != dialogsWidth && (_dialogsWidth != dialogsWidth
|| _a_dialogsWidth.animating())) { || _a_dialogsWidth.animating())) {
_dialogs->startWidthAnimation(); _dialogs->startWidthAnimation();
@ -2709,8 +2722,10 @@ void MainWidget::handleHistoryBack() {
} }
void MainWidget::updateWindowAdaptiveLayout() { void MainWidget::updateWindowAdaptiveLayout() {
const auto nochat = !_controller->mainSectionShown();
auto layout = _controller->computeColumnLayout(); auto layout = _controller->computeColumnLayout();
auto dialogsWidthRatio = Core::App().settings().dialogsWidthRatio(); auto dialogsWidthRatio = Core::App().settings().dialogsWidthRatio(nochat);
// 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.
@ -2753,7 +2768,7 @@ void MainWidget::updateWindowAdaptiveLayout() {
//} //}
} }
Core::App().settings().setDialogsWidthRatio(dialogsWidthRatio); Core::App().settings().updateDialogsWidthRatio(dialogsWidthRatio, nochat);
auto useSmallColumnWidth = !isOneColumn() auto useSmallColumnWidth = !isOneColumn()
&& !dialogsWidthRatio && !dialogsWidthRatio

View file

@ -250,6 +250,7 @@ private:
void handleAudioUpdate(const Media::Player::TrackState &state); void handleAudioUpdate(const Media::Player::TrackState &state);
void updateMediaPlaylistPosition(int x); void updateMediaPlaylistPosition(int x);
void updateControlsGeometry(); void updateControlsGeometry();
void updateMainSectionShown();
void updateDialogsWidthAnimated(); void updateDialogsWidthAnimated();
void updateThirdColumnToCurrentChat( void updateThirdColumnToCurrentChat(
Dialogs::Key key, Dialogs::Key key,
@ -278,7 +279,6 @@ private:
void showNewSection( void showNewSection(
std::shared_ptr<Window::SectionMemento> memento, std::shared_ptr<Window::SectionMemento> memento,
const SectionShow &params); const SectionShow &params);
void dropMainSection(Window::SectionWidget *widget);
Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section); Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section);

View file

@ -400,7 +400,7 @@ bool ReadSetting(
stream >> v; stream >> v;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Core::App().settings().setDialogsWidthRatio(v / 1000000.); Core::App().settings().updateDialogsWidthRatio(v / 1000000., false);
context.legacyRead = true; context.legacyRead = true;
} break; } break;

View file

@ -1946,7 +1946,10 @@ int SessionController::countDialogsWidthFromRatio(int bodyWidth) const {
if (!_isPrimary) { if (!_isPrimary) {
return 0; return 0;
} }
auto result = qRound(bodyWidth * Core::App().settings().dialogsWidthRatio()); const auto nochat = !mainSectionShown();
const auto width = bodyWidth
* Core::App().settings().dialogsWidthRatio(nochat);
auto result = qRound(width);
accumulate_max(result, st::columnMinimalWidthLeft); accumulate_max(result, st::columnMinimalWidthLeft);
// accumulate_min(result, st::columnMaximalWidthLeft); // accumulate_min(result, st::columnMaximalWidthLeft);
return result; return result;
@ -2035,10 +2038,12 @@ void SessionController::resizeForThirdSection() {
if (extendBy != settings.thirdColumnWidth()) { if (extendBy != settings.thirdColumnWidth()) {
settings.setThirdColumnWidth(extendBy); settings.setThirdColumnWidth(extendBy);
} }
const auto nochat = !mainSectionShown();
auto newBodyWidth = layout.bodyWidth + extendedBy; auto newBodyWidth = layout.bodyWidth + extendedBy;
auto currentRatio = settings.dialogsWidthRatio(); auto currentRatio = settings.dialogsWidthRatio(nochat);
settings.setDialogsWidthRatio( settings.updateDialogsWidthRatio(
(currentRatio * layout.bodyWidth) / newBodyWidth); (currentRatio * layout.bodyWidth) / newBodyWidth,
nochat);
} }
auto savedValue = (extendedBy == extendBy) ? -1 : extendedBy; auto savedValue = (extendedBy == extendBy) ? -1 : extendedBy;
settings.setThirdSectionExtendedBy(savedValue); settings.setThirdSectionExtendedBy(savedValue);
@ -2054,6 +2059,7 @@ void SessionController::closeThirdSection() {
auto newWindowSize = widget()->size(); auto newWindowSize = widget()->size();
auto layout = computeColumnLayout(); auto layout = computeColumnLayout();
if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) { if (layout.windowLayout == Adaptive::WindowLayout::ThreeColumn) {
const auto nochat = !mainSectionShown();
auto noResize = widget()->isFullScreen() auto noResize = widget()->isFullScreen()
|| widget()->isMaximized(); || widget()->isMaximized();
auto savedValue = settings.thirdSectionExtendedBy(); auto savedValue = settings.thirdSectionExtendedBy();
@ -2063,9 +2069,10 @@ void SessionController::closeThirdSection() {
auto newBodyWidth = noResize auto newBodyWidth = noResize
? layout.bodyWidth ? layout.bodyWidth
: (layout.bodyWidth - extendedBy); : (layout.bodyWidth - extendedBy);
auto currentRatio = settings.dialogsWidthRatio(); auto currentRatio = settings.dialogsWidthRatio(nochat);
settings.setDialogsWidthRatio( settings.updateDialogsWidthRatio(
(currentRatio * layout.bodyWidth) / newBodyWidth); (currentRatio * layout.bodyWidth) / newBodyWidth,
nochat);
newWindowSize = QSize( newWindowSize = QSize(
widget()->width() + (newBodyWidth - layout.bodyWidth), widget()->width() + (newBodyWidth - layout.bodyWidth),
widget()->height()); widget()->height());

View file

@ -515,6 +515,16 @@ public:
std::optional<bool> show = std::nullopt) const; std::optional<bool> show = std::nullopt) const;
void finishChatThemeEdit(not_null<PeerData*> peer); void finishChatThemeEdit(not_null<PeerData*> peer);
[[nodiscard]] bool mainSectionShown() const {
return _mainSectionShown.current();
}
[[nodiscard]] rpl::producer<bool> mainSectionShownChanges() const {
return _mainSectionShown.changes();
}
void setMainSectionShown(bool value) {
_mainSectionShown = value;
}
[[nodiscard]] bool chatsForceDisplayWide() const { [[nodiscard]] bool chatsForceDisplayWide() const {
return _chatsForceDisplayWide.current(); return _chatsForceDisplayWide.current();
} }
@ -678,6 +688,7 @@ private:
rpl::variable<Dialogs::Key> _searchInChat; rpl::variable<Dialogs::Key> _searchInChat;
rpl::variable<Dialogs::RowDescriptor> _activeChatEntry; rpl::variable<Dialogs::RowDescriptor> _activeChatEntry;
rpl::lifetime _activeHistoryLifetime; rpl::lifetime _activeHistoryLifetime;
rpl::variable<bool> _mainSectionShown = false;
rpl::variable<bool> _chatsForceDisplayWide = false; rpl::variable<bool> _chatsForceDisplayWide = false;
std::deque<Dialogs::RowDescriptor> _chatEntryHistory; std::deque<Dialogs::RowDescriptor> _chatEntryHistory;
int _chatEntryHistoryPosition = -1; int _chatEntryHistoryPosition = -1;