| 2885 | } |
| 2886 | |
| 2887 | void MainWidget::updateWindowAdaptiveLayout() { |
| 2888 | const auto nochat = !_controller->mainSectionShown(); |
| 2889 | |
| 2890 | auto layout = _controller->computeColumnLayout(); |
| 2891 | auto dialogsWidthRatio = Core::App().settings().dialogsWidthRatio(nochat); |
| 2892 | |
| 2893 | // Check if we are in a single-column layout in a wide enough window |
| 2894 | // for the normal layout. If so, switch to the normal layout. |
| 2895 | if (layout.windowLayout == Window::Adaptive::WindowLayout::OneColumn) { |
| 2896 | auto chatWidth = layout.chatWidth; |
| 2897 | //if (session().settings().tabbedSelectorSectionEnabled() |
| 2898 | // && chatWidth >= _history->minimalWidthForTabbedSelectorSection()) { |
| 2899 | // chatWidth -= _history->tabbedSelectorSectionWidth(); |
| 2900 | //} |
| 2901 | auto minimalNormalWidth = st::columnMinimalWidthLeft |
| 2902 | + st::columnMinimalWidthMain; |
| 2903 | if (chatWidth >= minimalNormalWidth) { |
| 2904 | // Switch layout back to normal in a wide enough window. |
| 2905 | layout.windowLayout = Window::Adaptive::WindowLayout::Normal; |
| 2906 | layout.dialogsWidth = st::columnMinimalWidthLeft; |
| 2907 | layout.chatWidth = layout.bodyWidth - layout.dialogsWidth; |
| 2908 | dialogsWidthRatio = float64(layout.dialogsWidth) / layout.bodyWidth; |
| 2909 | } |
| 2910 | } |
| 2911 | |
| 2912 | // Check if we are going to create the third column and shrink the |
| 2913 | // dialogs widget to provide a wide enough chat history column. |
| 2914 | // Don't shrink the column on the first call, when window is inited. |
| 2915 | if (layout.windowLayout == Window::Adaptive::WindowLayout::ThreeColumn |
| 2916 | && _controller->widget()->positionInited()) { |
| 2917 | //auto chatWidth = layout.chatWidth; |
| 2918 | //if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) { |
| 2919 | // auto thirdColumnWidth = _history->tabbedSelectorSectionWidth(); |
| 2920 | // auto twoColumnsWidth = (layout.bodyWidth - thirdColumnWidth); |
| 2921 | // auto sameRatioChatWidth = twoColumnsWidth - qRound(dialogsWidthRatio * twoColumnsWidth); |
| 2922 | // auto desiredChatWidth = qMax(sameRatioChatWidth, HistoryView::WideChatWidth()); |
| 2923 | // chatWidth -= thirdColumnWidth; |
| 2924 | // auto extendChatBy = desiredChatWidth - chatWidth; |
| 2925 | // accumulate_min(extendChatBy, layout.dialogsWidth - st::columnMinimalWidthLeft); |
| 2926 | // if (extendChatBy > 0) { |
| 2927 | // layout.dialogsWidth -= extendChatBy; |
| 2928 | // layout.chatWidth += extendChatBy; |
| 2929 | // dialogsWidthRatio = float64(layout.dialogsWidth) / layout.bodyWidth; |
| 2930 | // } |
| 2931 | //} |
| 2932 | } |
| 2933 | |
| 2934 | Core::App().settings().updateDialogsWidthRatio(dialogsWidthRatio, nochat); |
| 2935 | |
| 2936 | auto useSmallColumnWidth = !isOneColumn() |
| 2937 | && !dialogsWidthRatio |
| 2938 | && !_controller->chatsForceDisplayWide(); |
| 2939 | _dialogsWidth = !_dialogs |
| 2940 | ? 0 |
| 2941 | : useSmallColumnWidth |
| 2942 | ? _controller->dialogsSmallColumnWidth() |
| 2943 | : layout.dialogsWidth; |
| 2944 | _thirdColumnWidth = layout.thirdWidth; |
nothing calls this directly
no test coverage detected