2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Don't expand minimum window size for folders

Turn them into horizontal automatically instead
This commit is contained in:
Ilya Fedin
2024-11-17 07:38:48 +04:00
committed by John Preston
parent 702aa944dd
commit 6c64c22f83
6 changed files with 29 additions and 9 deletions

View File

@@ -566,11 +566,6 @@ void MainWindow::updatePalette() {
int MainWindow::computeMinWidth() const {
auto result = st::windowMinWidth;
if (const auto session = _controller->sessionController()) {
if (const auto add = session->filtersWidth()) {
result += add;
}
}
if (_rightColumn) {
result += _rightColumn->width();
}

View File

@@ -230,6 +230,7 @@ void Controller::setupSideBar() {
}, _sessionController->lifetime());
if (_sessionController->session().settings().dialogsFiltersEnabled()
&& _sessionController->enoughSpaceForFilters()
&& !Core::App().settings().chatFiltersHorizontal()) {
_sessionController->toggleFiltersMenu(true);
} else {

View File

@@ -1315,6 +1315,7 @@ SessionController::SessionController(
}, lifetime());
rpl::merge(
enoughSpaceForFiltersValue() | rpl::skip(1) | rpl::to_empty,
Core::App().settings().chatFiltersHorizontalChanges() | rpl::to_empty,
session->data().chatsFilters().changed()
) | rpl::start_with_next([=] {
@@ -1322,7 +1323,8 @@ SessionController::SessionController(
crl::on_main(this, [this] {
if (SessionNavigation::session().data().chatsFilters().has()) {
const auto isHorizontal
= Core::App().settings().chatFiltersHorizontal();
= Core::App().settings().chatFiltersHorizontal()
|| !enoughSpaceForFilters();
content()->toggleFiltersMenu(isHorizontal);
toggleFiltersMenu(!isHorizontal);
} else {
@@ -2588,6 +2590,16 @@ int SessionController::filtersWidth() const {
return _filters ? st::windowFiltersWidth : 0;
}
bool SessionController::enoughSpaceForFilters() const {
return widget()->width() >= widget()->minimumWidth() + st::windowFiltersWidth;
}
rpl::producer<bool> SessionController::enoughSpaceForFiltersValue() const {
return widget()->widthValue() | rpl::map([=] {
return enoughSpaceForFilters();
}) | rpl::distinct_until_changed();
}
rpl::producer<FilterId> SessionController::activeChatsFilter() const {
return _activeChatsFilter.value();
}

View File

@@ -546,6 +546,8 @@ public:
}
[[nodiscard]] int filtersWidth() const;
[[nodiscard]] bool enoughSpaceForFilters() const;
[[nodiscard]] rpl::producer<bool> enoughSpaceForFiltersValue() const;
[[nodiscard]] rpl::producer<FilterId> activeChatsFilter() const;
[[nodiscard]] FilterId activeChatsFilterCurrent() const;
void setActiveChatsFilter(