diff --git a/Telegram/SourceFiles/export/view/export_view_content.cpp b/Telegram/SourceFiles/export/view/export_view_content.cpp index d76d51126..713f67e3a 100644 --- a/Telegram/SourceFiles/export/view/export_view_content.cpp +++ b/Telegram/SourceFiles/export/view/export_view_content.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "export/view/export_view_content.h" +#include "export/export_settings.h" #include "lang/lang_keys.h" #include "layout.h" @@ -15,7 +16,9 @@ namespace View { const QString Content::kDoneId = "done"; -Content ContentFromState(const ProcessingState &state) { +Content ContentFromState( + not_null settings, + const ProcessingState &state) { using Step = ProcessingState::Step; auto result = Content(); @@ -89,7 +92,9 @@ Content ContentFromState(const ProcessingState &state) { pushMain(tr::lng_export_option_other(tr::now)); break; case Step::Dialogs: - pushMain(tr::lng_export_state_chats(tr::now)); + if (state.entityCount > 1) { + pushMain(tr::lng_export_state_chats(tr::now)); + } push( "chat" + QString::number(state.entityIndex), (state.entityName.isEmpty() @@ -114,7 +119,8 @@ Content ContentFromState(const ProcessingState &state) { break; default: Unexpected("Step in ContentFromState."); } - while (result.rows.size() < 3) { + const auto requiredRows = settings->onlySinglePeer() ? 2 : 3; + while (result.rows.size() < requiredRows) { result.rows.emplace_back(); } return result; diff --git a/Telegram/SourceFiles/export/view/export_view_content.h b/Telegram/SourceFiles/export/view/export_view_content.h index b31e64a7b..18500b7a4 100644 --- a/Telegram/SourceFiles/export/view/export_view_content.h +++ b/Telegram/SourceFiles/export/view/export_view_content.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "export/export_controller.h" +namespace Export { +struct Settings; +} // namespace Export + namespace Export { namespace View { @@ -26,17 +30,21 @@ struct Content { }; -Content ContentFromState(const ProcessingState &state); -Content ContentFromState(const FinishedState &state); +[[nodiscard]] Content ContentFromState( + not_null settings, + const ProcessingState &state); +[[nodiscard]] Content ContentFromState(const FinishedState &state); -inline auto ContentFromState(rpl::producer state) { +[[nodiscard]] inline auto ContentFromState( + not_null settings, + rpl::producer state) { return std::move( state ) | rpl::filter([](const State &state) { return state.is() || state.is(); - }) | rpl::map([](const State &state) { + }) | rpl::map([=](const State &state) { if (const auto process = base::get_if(&state)) { - return ContentFromState(*process); + return ContentFromState(settings, *process); } else if (const auto done = base::get_if(&state)) { return ContentFromState(*done); } diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp index dec220ed0..2bfa55ff4 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.cpp @@ -280,7 +280,7 @@ void PanelController::showProgress() { auto progress = base::make_unique_q( _panel.get(), rpl::single( - ContentFromState(ProcessingState()) + ContentFromState(_settings.get(), ProcessingState()) ) | rpl::then(progressState())); progress->cancelClicks( diff --git a/Telegram/SourceFiles/export/view/export_view_panel_controller.h b/Telegram/SourceFiles/export/view/export_view_panel_controller.h index 3bcebb513..ad3ad1db8 100644 --- a/Telegram/SourceFiles/export/view/export_view_panel_controller.h +++ b/Telegram/SourceFiles/export/view/export_view_panel_controller.h @@ -46,7 +46,7 @@ public: } auto progressState() const { - return ContentFromState(_process->state()); + return ContentFromState(_settings.get(), _process->state()); } private: diff --git a/Telegram/SourceFiles/export/view/export_view_progress.cpp b/Telegram/SourceFiles/export/view/export_view_progress.cpp index 785b3b48b..16553a36c 100644 --- a/Telegram/SourceFiles/export/view/export_view_progress.cpp +++ b/Telegram/SourceFiles/export/view/export_view_progress.cpp @@ -288,6 +288,7 @@ void ProgressWidget::updateState(Content &&content) { showDone(); } + const auto wasCount = _rows.size(); auto index = 0; for (auto &row : content.rows) { if (index < _rows.size()) { @@ -297,12 +298,16 @@ void ProgressWidget::updateState(Content &&content) { index, object_ptr(this, std::move(row)), st::exportProgressRowPadding)); + _rows.back()->show(); } ++index; } for (const auto count = _rows.size(); index != count; ++index) { _rows[index]->updateData(Content::Row()); } + if (_rows.size() != wasCount) { + _body->resizeToWidth(width()); + } } void ProgressWidget::showDone() {