2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Save themes, apply and close editor on save.

This commit is contained in:
John Preston
2019-09-06 14:33:51 +03:00
parent 910f16312c
commit 9c86f0e0a5
9 changed files with 122 additions and 53 deletions

View File

@@ -906,23 +906,25 @@ void Generator::restoreTextPalette() {
_p->restoreTextPalette();
}
[[nodiscard]] QString CachedThemePath(uint64 documentId) {
return QString::fromLatin1("special://cached-%1").arg(documentId);
}
} // namespace
std::unique_ptr<Preview> PreviewFromFile(
const QByteArray &bytes,
const QString &filepath,
const Data::CloudTheme &cloud) {
Expects(!filepath.isEmpty()); // Use
auto result = std::make_unique<Preview>();
auto &object = result->object;
object.cloud = cloud;
object.pathRelative = filepath.isEmpty()
? QString()
: QDir().relativeFilePath(filepath);
object.pathAbsolute = filepath.isEmpty()
? QString()
? CachedThemePath(cloud.documentId)
: QFileInfo(filepath).absoluteFilePath();
object.pathRelative = filepath.isEmpty()
? object.pathAbsolute
: QDir().relativeFilePath(filepath);
if (bytes.isEmpty()) {
if (!LoadFromFile(filepath, &result->instance, &object.content)) {
return nullptr;