mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-06 07:07:00 +00:00
Improve single chat export progress display.
This commit is contained in:
parent
1686eb394d
commit
368eeaf754
@ -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*> 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;
|
||||
|
@ -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*> settings,
|
||||
const ProcessingState &state);
|
||||
[[nodiscard]] Content ContentFromState(const FinishedState &state);
|
||||
|
||||
inline auto ContentFromState(rpl::producer<State> state) {
|
||||
[[nodiscard]] inline auto ContentFromState(
|
||||
not_null<Settings*> settings,
|
||||
rpl::producer<State> state) {
|
||||
return std::move(
|
||||
state
|
||||
) | rpl::filter([](const State &state) {
|
||||
return state.is<ProcessingState>() || state.is<FinishedState>();
|
||||
}) | rpl::map([](const State &state) {
|
||||
}) | rpl::map([=](const State &state) {
|
||||
if (const auto process = base::get_if<ProcessingState>(&state)) {
|
||||
return ContentFromState(*process);
|
||||
return ContentFromState(settings, *process);
|
||||
} else if (const auto done = base::get_if<FinishedState>(&state)) {
|
||||
return ContentFromState(*done);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ void PanelController::showProgress() {
|
||||
auto progress = base::make_unique_q<ProgressWidget>(
|
||||
_panel.get(),
|
||||
rpl::single(
|
||||
ContentFromState(ProcessingState())
|
||||
ContentFromState(_settings.get(), ProcessingState())
|
||||
) | rpl::then(progressState()));
|
||||
|
||||
progress->cancelClicks(
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
}
|
||||
|
||||
auto progressState() const {
|
||||
return ContentFromState(_process->state());
|
||||
return ContentFromState(_settings.get(), _process->state());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -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<Row>(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() {
|
||||
|
Loading…
Reference in New Issue
Block a user