mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-20 15:17:41 +00:00
Moved producer of state description to CloudBlob.
This commit is contained in:
parent
8ca0b614d7
commit
efdf5f1767
@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/effects/radial_animation.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "base/zlib_help.h"
|
||||
#include "layout.h"
|
||||
#include "core/application.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_session.h"
|
||||
@ -110,26 +109,9 @@ DictState ComputeState(int id) {
|
||||
}
|
||||
|
||||
QString StateDescription(const DictState &state) {
|
||||
return state.match([](const Available &data) {
|
||||
return tr::lng_emoji_set_download(tr::now, lt_size, formatSizeText(data.size));
|
||||
}, [](const Ready &data) -> QString {
|
||||
return tr::lng_emoji_set_ready(tr::now);
|
||||
}, [](const Active &data) -> QString {
|
||||
return tr::lng_settings_manage_enabled_dictionary(tr::now);
|
||||
// return tr::lng_emoji_set_active(tr::now);
|
||||
}, [](const Loading &data) {
|
||||
const auto percent = (data.size > 0)
|
||||
? snap((data.already * 100) / float64(data.size), 0., 100.)
|
||||
: 0.;
|
||||
return tr::lng_emoji_set_loading(
|
||||
tr::now,
|
||||
lt_percent,
|
||||
QString::number(int(std::round(percent))) + '%',
|
||||
lt_progress,
|
||||
formatDownloadText(data.already, data.size));
|
||||
}, [](const Failed &data) {
|
||||
return tr::lng_attach_failed(tr::now);
|
||||
});
|
||||
return StateDescription(
|
||||
state,
|
||||
tr::lng_settings_manage_enabled_dictionary);
|
||||
}
|
||||
|
||||
Loader::Loader(
|
||||
|
@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/emoji_config.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "base/zlib_help.h"
|
||||
#include "layout.h"
|
||||
#include "core/application.h"
|
||||
#include "main/main_account.h"
|
||||
#include "mainwidget.h"
|
||||
@ -149,25 +148,9 @@ SetState ComputeState(int id) {
|
||||
}
|
||||
|
||||
QString StateDescription(const SetState &state) {
|
||||
return state.match([](const Available &data) {
|
||||
return tr::lng_emoji_set_download(tr::now, lt_size, formatSizeText(data.size));
|
||||
}, [](const Ready &data) -> QString {
|
||||
return tr::lng_emoji_set_ready(tr::now);
|
||||
}, [](const Active &data) -> QString {
|
||||
return tr::lng_emoji_set_active(tr::now);
|
||||
}, [](const Loading &data) {
|
||||
const auto percent = (data.size > 0)
|
||||
? snap((data.already * 100) / float64(data.size), 0., 100.)
|
||||
: 0.;
|
||||
return tr::lng_emoji_set_loading(
|
||||
tr::now,
|
||||
lt_percent,
|
||||
QString::number(int(std::round(percent))) + '%',
|
||||
lt_progress,
|
||||
formatDownloadText(data.already, data.size));
|
||||
}, [](const Failed &data) {
|
||||
return tr::lng_attach_failed(tr::now);
|
||||
});
|
||||
return StateDescription(
|
||||
state,
|
||||
tr::lng_emoji_set_active);
|
||||
}
|
||||
|
||||
bool GoodSetPartName(const QString &name) {
|
||||
|
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "base/zlib_help.h"
|
||||
#include "core/application.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "layout.h"
|
||||
#include "main/main_account.h"
|
||||
|
||||
namespace Storage::CloudBlob {
|
||||
@ -66,6 +68,31 @@ bool UnpackBlob(
|
||||
return true;
|
||||
}
|
||||
|
||||
QString StateDescription(const BlobState &state, tr::phrase<> activeText) {
|
||||
return state.match([](const Available &data) {
|
||||
return tr::lng_emoji_set_download(
|
||||
tr::now,
|
||||
lt_size,
|
||||
formatSizeText(data.size));
|
||||
}, [](const Ready &data) -> QString {
|
||||
return tr::lng_emoji_set_ready(tr::now);
|
||||
}, [&](const Active &data) -> QString {
|
||||
return activeText(tr::now);
|
||||
}, [](const Loading &data) {
|
||||
const auto percent = (data.size > 0)
|
||||
? snap((data.already * 100) / float64(data.size), 0., 100.)
|
||||
: 0.;
|
||||
return tr::lng_emoji_set_loading(
|
||||
tr::now,
|
||||
lt_percent,
|
||||
QString::number(int(std::round(percent))) + '%',
|
||||
lt_progress,
|
||||
formatDownloadText(data.already, data.size));
|
||||
}, [](const Failed &data) {
|
||||
return tr::lng_attach_failed(tr::now);
|
||||
});
|
||||
}
|
||||
|
||||
BlobLoader::BlobLoader(
|
||||
QObject *parent,
|
||||
int id,
|
||||
|
@ -9,6 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "mtproto/dedicated_file_loader.h"
|
||||
|
||||
namespace tr {
|
||||
template <typename ...>
|
||||
struct phrase;
|
||||
} // namespace tr
|
||||
|
||||
namespace Storage::CloudBlob {
|
||||
|
||||
constexpr auto kCloudLocationUsername = "tdhbcfiles"_cs;
|
||||
@ -68,6 +73,8 @@ bool UnpackBlob(
|
||||
const QString &folder,
|
||||
Fn<bool(const QString &)> checkNameCallback);
|
||||
|
||||
QString StateDescription(const BlobState &state, tr::phrase<> activeText);
|
||||
|
||||
class BlobLoader : public QObject {
|
||||
public:
|
||||
BlobLoader(
|
||||
|
Loading…
Reference in New Issue
Block a user