Switch layout to Normal in a wide enough window.

A lot of people didn't know how to bring the dialogs column back
after it was gone in a wide single column MainWindow.

Now we switch to a two column layout if the window allows it,
preserving the emoji / stickers / GIFs section in case it is shown.
This commit is contained in:
John Preston 2017-05-13 15:02:07 +03:00
parent 565b56fb5f
commit 8d02d81a9a
5 changed files with 27 additions and 3 deletions

View File

@ -3735,8 +3735,12 @@ void HistoryWidget::updateTabbedSelectorSectionShown() {
orderWidgets();
}
int HistoryWidget::tabbedSelectorSectionWidth() const {
return st::emojiPanWidth;
}
int HistoryWidget::minimalWidthForTabbedSelectorSection() const {
return st::windowMinWidth + st::emojiPanWidth;
return st::windowMinWidth + tabbedSelectorSectionWidth();
}
void HistoryWidget::toggleTabbedSelectorMode() {

View File

@ -200,6 +200,8 @@ public:
void unreadCountChanged(History *history);
QRect historyRect() const;
int tabbedSelectorSectionWidth() const;
int minimalWidthForTabbedSelectorSection() const;
void updateSendAction(History *history, SendAction::Type type, int32 progress = 0);
void cancelSendAction(History *history, SendAction::Type type);
@ -480,7 +482,6 @@ private:
void toggleTabbedSelectorMode();
void updateTabbedSelectorSectionShown();
void recountChatWidth();
int minimalWidthForTabbedSelectorSection() const;
void setReportSpamStatus(DBIPeerReportSpamStatus status);
void animationCallback();

View File

@ -3160,6 +3160,7 @@ bool MainWidget::eventFilter(QObject *o, QEvent *e) {
Local::writeUserSettings();
} else if (e->type() == QEvent::MouseMove && _resizingSide) {
auto newWidth = mouseLeft() - _resizingSideShift;
accumulate_max(newWidth, _controller->dialogsSmallColumnWidth());
_controller->dialogsWidthRatio().set(float64(newWidth) / width(), true);
}
} else if (e->type() == QEvent::FocusIn) {
@ -3191,6 +3192,19 @@ void MainWidget::handleAdaptiveLayoutUpdate() {
void MainWidget::updateWindowAdaptiveLayout() {
auto layout = _controller->computeColumnLayout();
if (layout.windowLayout == Adaptive::WindowLayout::OneColumn) {
auto chatWidth = layout.dialogsWidth;
if (AuthSession::Current().data().tabbedSelectorSectionEnabled()
&& chatWidth >= _history->minimalWidthForTabbedSelectorSection()) {
chatWidth -= _history->tabbedSelectorSectionWidth();
}
if (chatWidth >= st::dialogsWidthMin + st::windowMinWidth) {
// Switch layout back to normal in a wide enough window.
layout.windowLayout = Adaptive::WindowLayout::Normal;
layout.dialogsWidth = st::dialogsWidthMin;
_controller->dialogsWidthRatio().set(float64(layout.dialogsWidth) / layout.bodyWidth, true);
}
}
_dialogsWidth = layout.dialogsWidth;
if (layout.windowLayout != Global::AdaptiveWindowLayout()) {
Global::SetAdaptiveWindowLayout(layout.windowLayout);

View File

@ -53,6 +53,10 @@ bool Controller::isGifPausedAtLeastFor(GifPauseReason reason) const {
return (static_cast<int>(_gifPauseReasons) >= 2 * static_cast<int>(reason)) || !window()->isActive();
}
int Controller::dialogsSmallColumnWidth() const {
return st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
}
Controller::ColumnLayout Controller::computeColumnLayout() {
auto layout = Adaptive::WindowLayout::OneColumn;
@ -94,7 +98,7 @@ Controller::ColumnLayout Controller::computeColumnLayout() {
if (forceWideDialogs()) {
dialogsWidth = st::dialogsWidthMin;
} else {
dialogsWidth = st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x();
dialogsWidth = dialogsSmallColumnWidth();
}
} else {
layout = Adaptive::WindowLayout::Normal;

View File

@ -72,6 +72,7 @@ public:
Adaptive::WindowLayout windowLayout;
};
ColumnLayout computeColumnLayout();
int dialogsSmallColumnWidth() const;
bool provideChatWidth(int requestedWidth);
base::Variable<float64> &dialogsWidthRatio() {