2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Move dialogsWidthRatio to AuthSessionData.

This commit is contained in:
John Preston
2017-11-05 17:57:51 +04:00
parent 4771ea7cd4
commit 9a56b2d20f
11 changed files with 64 additions and 82 deletions

View File

@@ -108,13 +108,13 @@ Controller::ColumnLayout Controller::computeColumnLayout() const {
dialogsWidth = chatWidth = bodyWidth;
} else if (useNormalLayout()) {
layout = Adaptive::WindowLayout::Normal;
dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
dialogsWidth = qRound(bodyWidth * Auth().data().dialogsWidthRatio());
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
accumulate_min(dialogsWidth, bodyWidth - st::columnMinimalWidthMain);
chatWidth = bodyWidth - dialogsWidth;
} else {
layout = Adaptive::WindowLayout::ThreeColumn;
dialogsWidth = qRound(bodyWidth * dialogsWidthRatio().value());
dialogsWidth = qRound(bodyWidth * Auth().data().dialogsWidthRatio());
accumulate_max(dialogsWidth, st::columnMinimalWidthLeft);
thirdWidth = st::columnMinimalWidthThird;
accumulate_min(
@@ -161,9 +161,8 @@ void Controller::resizeForThirdSection() {
minimalThreeColumnWidth() - layout.bodyWidth,
st::columnMinimalWidthThird);
auto newBodyWidth = layout.bodyWidth + extendBy;
dialogsWidthRatio().set(
(dialogsWidthRatio().value() * layout.bodyWidth) / newBodyWidth,
true);
auto currentRatio = Auth().data().dialogsWidthRatio();
Auth().data().setDialogsWidthRatio((currentRatio * layout.bodyWidth) / newBodyWidth);
window()->tryToExtendWidthBy(extendBy);
Auth().data().setTabbedSelectorSectionEnabled(
@@ -181,9 +180,8 @@ void Controller::closeThirdSection() {
auto newBodyWidth = noResize
? layout.bodyWidth
: (layout.bodyWidth - layout.thirdWidth);
dialogsWidthRatio().set(
(dialogsWidthRatio().value() * layout.bodyWidth) / newBodyWidth,
true);
auto currentRatio = Auth().data().dialogsWidthRatio();
Auth().data().setDialogsWidthRatio((currentRatio * layout.bodyWidth) / newBodyWidth);
newWindowSize = QSize(
window()->width() + (newBodyWidth - layout.bodyWidth),
window()->height());