mirror of https://github.com/procxx/kepka.git
Apply themes in settings without preview.
This commit is contained in:
parent
aa10934e85
commit
6d29dc3b36
|
@ -131,9 +131,7 @@ void CloudThemes::applyUpdate(const MTPTheme &theme) {
|
|||
|| !cloud.documentId) {
|
||||
return;
|
||||
}
|
||||
updateFromDocument(
|
||||
cloud,
|
||||
_session->data().document(cloud.documentId));
|
||||
applyFromDocument(cloud);
|
||||
}, [&](const MTPDthemeDocumentNotModified &data) {
|
||||
});
|
||||
scheduleReload();
|
||||
|
@ -167,7 +165,7 @@ void CloudThemes::showPreview(const MTPTheme &data) {
|
|||
|
||||
void CloudThemes::showPreview(const CloudTheme &cloud) {
|
||||
if (const auto documentId = cloud.documentId) {
|
||||
previewFromDocument(cloud, _session->data().document(documentId));
|
||||
previewFromDocument(cloud);
|
||||
} else if (cloud.createdBy == _session->userId()) {
|
||||
Ui::show(Box(
|
||||
Window::Theme::CreateForExistingBox,
|
||||
|
@ -179,9 +177,8 @@ void CloudThemes::showPreview(const CloudTheme &cloud) {
|
|||
}
|
||||
}
|
||||
|
||||
void CloudThemes::updateFromDocument(
|
||||
const CloudTheme &cloud,
|
||||
not_null<DocumentData*> document) {
|
||||
void CloudThemes::applyFromDocument(const CloudTheme &cloud) {
|
||||
const auto document = _session->data().document(cloud.documentId);
|
||||
loadDocumentAndInvoke(_updatingFrom, cloud, document, [=] {
|
||||
auto preview = Window::Theme::PreviewFromFile(
|
||||
document->data(),
|
||||
|
@ -194,9 +191,8 @@ void CloudThemes::updateFromDocument(
|
|||
});
|
||||
}
|
||||
|
||||
void CloudThemes::previewFromDocument(
|
||||
const CloudTheme &cloud,
|
||||
not_null<DocumentData*> document) {
|
||||
void CloudThemes::previewFromDocument(const CloudTheme &cloud) {
|
||||
const auto document = _session->data().document(cloud.documentId);
|
||||
loadDocumentAndInvoke(_previewFrom, cloud, document, [=] {
|
||||
Core::App().showTheme(document, cloud);
|
||||
});
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
void resolve(const QString &slug, const FullMsgId &clickFromMessageId);
|
||||
void showPreview(const MTPTheme &data);
|
||||
void showPreview(const CloudTheme &cloud);
|
||||
void applyFromDocument(const CloudTheme &cloud);
|
||||
|
||||
private:
|
||||
struct LoadingDocument {
|
||||
|
@ -64,12 +65,7 @@ private:
|
|||
[[nodiscard]] bool needReload() const;
|
||||
void scheduleReload();
|
||||
void reloadCurrent();
|
||||
void updateFromDocument(
|
||||
const CloudTheme &cloud,
|
||||
not_null<DocumentData*> document);
|
||||
void previewFromDocument(
|
||||
const CloudTheme &cloud,
|
||||
not_null<DocumentData*> document);
|
||||
void previewFromDocument(const CloudTheme &cloud);
|
||||
void loadDocumentAndInvoke(
|
||||
LoadingDocument &value,
|
||||
const CloudTheme &cloud,
|
||||
|
|
|
@ -489,10 +489,13 @@ void CloudList::insert(int index, const Data::CloudTheme &theme) {
|
|||
|| i->waiting) {
|
||||
return;
|
||||
}
|
||||
const auto &cloud = i->theme;
|
||||
if (button == Qt::RightButton) {
|
||||
showMenu(*i);
|
||||
} else if (cloud.documentId) {
|
||||
_window->session().data().cloudThemes().applyFromDocument(cloud);
|
||||
} else {
|
||||
_window->session().data().cloudThemes().showPreview(i->theme);
|
||||
_window->session().data().cloudThemes().showPreview(cloud);
|
||||
}
|
||||
});
|
||||
auto &element = *_elements.insert(
|
||||
|
|
Loading…
Reference in New Issue