mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Use getters in MTP classes.
This commit is contained in:
@@ -63,10 +63,10 @@ ConfirmSwitchBox::ConfirmSwitchBox(
|
||||
QWidget*,
|
||||
const MTPDlangPackLanguage &data,
|
||||
Fn<void()> apply)
|
||||
: _name(qs(data.vnative_name))
|
||||
, _percent(data.vtranslated_count.v * 100 / data.vstrings_count.v)
|
||||
: _name(qs(data.vnative_name()))
|
||||
, _percent(data.vtranslated_count().v * 100 / data.vstrings_count().v)
|
||||
, _official(data.is_official())
|
||||
, _editLink(qs(data.vtranslations_url))
|
||||
, _editLink(qs(data.vtranslations_url()))
|
||||
, _apply(std::move(apply)) {
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ void ConfirmSwitchBox::prepare() {
|
||||
NotReadyBox::NotReadyBox(
|
||||
QWidget*,
|
||||
const MTPDlangPackLanguage &data)
|
||||
: _name(qs(data.vnative_name))
|
||||
, _editLink(qs(data.vtranslations_url)) {
|
||||
: _name(qs(data.vnative_name()))
|
||||
, _editLink(qs(data.vtranslations_url())) {
|
||||
}
|
||||
|
||||
void NotReadyBox::prepare() {
|
||||
@@ -145,13 +145,11 @@ void NotReadyBox::prepare() {
|
||||
Language ParseLanguage(const MTPLangPackLanguage &data) {
|
||||
return data.match([](const MTPDlangPackLanguage &data) {
|
||||
return Language{
|
||||
qs(data.vlang_code),
|
||||
qs(data.vplural_code),
|
||||
(data.has_base_lang_code()
|
||||
? qs(data.vbase_lang_code)
|
||||
: QString()),
|
||||
qs(data.vname),
|
||||
qs(data.vnative_name)
|
||||
qs(data.vlang_code()),
|
||||
qs(data.vplural_code()),
|
||||
qs(data.vbase_lang_code().value_or_empty()),
|
||||
qs(data.vname()),
|
||||
qs(data.vnative_name())
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -268,7 +266,7 @@ void CloudManager::applyLangPackDifference(
|
||||
}
|
||||
|
||||
const auto &langpack = difference.c_langPackDifference();
|
||||
const auto langpackId = qs(langpack.vlang_code);
|
||||
const auto langpackId = qs(langpack.vlang_code());
|
||||
const auto pack = packTypeFromId(langpackId);
|
||||
if (pack != Pack::None) {
|
||||
applyLangPackData(pack, langpack);
|
||||
@@ -356,9 +354,9 @@ bool CloudManager::showOfferSwitchBox() {
|
||||
void CloudManager::applyLangPackData(
|
||||
Pack pack,
|
||||
const MTPDlangPackDifference &data) {
|
||||
if (_langpack.version(pack) < data.vfrom_version.v) {
|
||||
if (_langpack.version(pack) < data.vfrom_version().v) {
|
||||
requestLangPackDifference(pack);
|
||||
} else if (!data.vstrings.v.isEmpty()) {
|
||||
} else if (!data.vstrings().v.isEmpty()) {
|
||||
_langpack.applyDifference(pack, data);
|
||||
Local::writeLangPack();
|
||||
} else if (_restartAfterSwitch) {
|
||||
@@ -421,7 +419,7 @@ void CloudManager::requestLanguageAndSwitch(
|
||||
return;
|
||||
}
|
||||
result.match([=](const MTPDlangPackLanguage &data) {
|
||||
if (data.vstrings_count.v > 0) {
|
||||
if (data.vstrings_count().v > 0) {
|
||||
Ui::show(Box<ConfirmSwitchBox>(data, finalize));
|
||||
} else {
|
||||
Ui::show(Box<NotReadyBox>(data));
|
||||
|
@@ -611,27 +611,17 @@ void HandleString(
|
||||
SetCallback setCallback,
|
||||
ResetCallback resetCallback) {
|
||||
string.match([&](const MTPDlangPackString &data) {
|
||||
setCallback(qba(data.vkey), qba(data.vvalue));
|
||||
setCallback(qba(data.vkey()), qba(data.vvalue()));
|
||||
}, [&](const MTPDlangPackStringPluralized &data) {
|
||||
const auto key = qba(data.vkey);
|
||||
setCallback(
|
||||
key + "#zero",
|
||||
data.has_zero_value() ? qba(data.vzero_value) : QByteArray());
|
||||
setCallback(
|
||||
key + "#one",
|
||||
data.has_one_value() ? qba(data.vone_value) : QByteArray());
|
||||
setCallback(
|
||||
key + "#two",
|
||||
data.has_two_value() ? qba(data.vtwo_value) : QByteArray());
|
||||
setCallback(
|
||||
key + "#few",
|
||||
data.has_few_value() ? qba(data.vfew_value) : QByteArray());
|
||||
setCallback(
|
||||
key + "#many",
|
||||
data.has_many_value() ? qba(data.vmany_value) : QByteArray());
|
||||
setCallback(key + "#other", qba(data.vother_value));
|
||||
const auto key = qba(data.vkey());
|
||||
setCallback(key + "#zero", data.vzero_value().value_or_empty());
|
||||
setCallback(key + "#one", data.vone_value().value_or_empty());
|
||||
setCallback(key + "#two", data.vtwo_value().value_or_empty());
|
||||
setCallback(key + "#few", data.vfew_value().value_or_empty());
|
||||
setCallback(key + "#many", data.vmany_value().value_or_empty());
|
||||
setCallback(key + "#other", qba(data.vother_value()));
|
||||
}, [&](const MTPDlangPackStringDeleted &data) {
|
||||
auto key = qba(data.vkey);
|
||||
auto key = qba(data.vkey());
|
||||
resetCallback(key);
|
||||
const auto postfixes = {
|
||||
"#zero",
|
||||
@@ -665,11 +655,11 @@ void Instance::applyDifference(
|
||||
|
||||
void Instance::applyDifferenceToMe(
|
||||
const MTPDlangPackDifference &difference) {
|
||||
Expects(LanguageIdOrDefault(_id) == qs(difference.vlang_code));
|
||||
Expects(difference.vfrom_version.v <= _version);
|
||||
Expects(LanguageIdOrDefault(_id) == qs(difference.vlang_code()));
|
||||
Expects(difference.vfrom_version().v <= _version);
|
||||
|
||||
_version = difference.vversion.v;
|
||||
for (const auto &string : difference.vstrings.v) {
|
||||
_version = difference.vversion().v;
|
||||
for (const auto &string : difference.vstrings().v) {
|
||||
HandleString(string, [&](auto &&key, auto &&value) {
|
||||
applyValue(key, value);
|
||||
}, [&](auto &&key) {
|
||||
|
Reference in New Issue
Block a user