2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 06:55:58 +00:00

Add language and scale settings.

This commit is contained in:
John Preston
2018-09-06 00:01:50 +03:00
parent a7725f03bb
commit 3f543347b8
10 changed files with 226 additions and 20 deletions

View File

@@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "messenger.h"
#include "lang/lang_instance.h"
#include "lang/lang_cloud_manager.h"
#include "styles/style_boxes.h"
@@ -150,3 +151,27 @@ void LanguageBox::refreshLanguages() {
}
_inner->setSelected(currentIndex);
}
base::binary_guard LanguageBox::Show() {
auto result = base::binary_guard();
const auto manager = Messenger::Instance().langCloudManager();
if (manager->languageList().isEmpty()) {
auto guard = std::make_shared<base::binary_guard>();
std::tie(result, *guard) = base::make_binary_guard();
auto alive = std::make_shared<std::unique_ptr<base::Subscription>>(
std::make_unique<base::Subscription>());
**alive = manager->languageListChanged().add_subscription([=] {
const auto show = guard->alive();
*alive = nullptr;
if (show) {
Ui::show(Box<LanguageBox>());
}
});
} else {
Ui::show(Box<LanguageBox>());
}
manager->requestLanguageList();
return result;
}