mirror of https://github.com/procxx/kepka.git
Fix applying background after theme edit.
This commit is contained in:
parent
dfd63e66ff
commit
ca45fb617e
|
@ -1202,7 +1202,8 @@ void KeepFromEditor(
|
|||
const ParsedTheme &originalParsed,
|
||||
const Data::CloudTheme &cloud,
|
||||
const QByteArray &themeContent,
|
||||
const ParsedTheme &themeParsed) {
|
||||
const ParsedTheme &themeParsed,
|
||||
const QImage &background) {
|
||||
ClearApplying();
|
||||
const auto content = themeContent.isEmpty()
|
||||
? originalContent
|
||||
|
@ -1223,6 +1224,11 @@ void KeepFromEditor(
|
|||
cloud.documentId);
|
||||
Local::writeTheme(saved);
|
||||
Background()->keepApplied(saved.object, true);
|
||||
Background()->setThemeData(
|
||||
base::duplicate(background),
|
||||
themeParsed.tiled);
|
||||
Background()->set(Data::ThemeWallPaper());
|
||||
Background()->writeNewBackgroundSettings();
|
||||
}
|
||||
|
||||
void Revert() {
|
||||
|
|
|
@ -69,7 +69,8 @@ void KeepFromEditor(
|
|||
const ParsedTheme &originalParsed,
|
||||
const Data::CloudTheme &cloud,
|
||||
const QByteArray &themeContent,
|
||||
const ParsedTheme &themeParsed);
|
||||
const ParsedTheme &themeParsed,
|
||||
const QImage &background);
|
||||
QString NightThemePath();
|
||||
[[nodiscard]] bool IsNightMode();
|
||||
void SetNightModeValue(bool nightMode);
|
||||
|
@ -210,7 +211,8 @@ private:
|
|||
const ParsedTheme &originalParsed,
|
||||
const Data::CloudTheme &cloud,
|
||||
const QByteArray &themeContent,
|
||||
const ParsedTheme &themeParsed);
|
||||
const ParsedTheme &themeParsed,
|
||||
const QImage &background);
|
||||
friend bool IsNonDefaultBackground();
|
||||
|
||||
Main::Session *_session = nullptr;
|
||||
|
|
|
@ -330,7 +330,9 @@ QByteArray ReplaceValueInPaletteContent(
|
|||
if (end - lastValidValueEnd > 0) result.append(lastValidValueEnd, end - lastValidValueEnd);
|
||||
return result;
|
||||
}
|
||||
return QByteArray();
|
||||
auto newline = (content.indexOf("\r\n") >= 0 ? "\r\n" : "\n");
|
||||
auto addedline = (content.endsWith('\n') ? "" : newline);
|
||||
return content + addedline + name + ": " + value + ";" + newline;
|
||||
}
|
||||
|
||||
[[nodiscard]] QByteArray WriteCloudToText(const Data::CloudTheme &cloud) {
|
||||
|
@ -608,11 +610,6 @@ void Editor::Inner::applyEditing(const QString &name, const QString ©Of, QCo
|
|||
error();
|
||||
return;
|
||||
}
|
||||
if (newContent.isEmpty()) {
|
||||
auto newline = (_paletteContent.indexOf("\r\n") >= 0 ? "\r\n" : "\n");
|
||||
auto addedline = (_paletteContent.endsWith('\n') ? "" : newline);
|
||||
newContent = _paletteContent + addedline + plainName + ": " + plainValue + ";" + newline;
|
||||
}
|
||||
applyNewPalette(newContent);
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
const ParsedTheme &parsed);
|
||||
|
||||
[[nodiscard]] ParsedTheme result() const;
|
||||
[[nodiscard]] QImage image() const;
|
||||
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
|
||||
|
@ -213,6 +214,10 @@ ParsedTheme BackgroundSelector::result() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
QImage BackgroundSelector::image() const {
|
||||
return _background;
|
||||
}
|
||||
|
||||
bool PaletteChanged(
|
||||
const QByteArray &editorPalette,
|
||||
const QByteArray &originalPalette,
|
||||
|
@ -273,6 +278,12 @@ void ImportFromFile(
|
|||
data,
|
||||
name,
|
||||
ColorHexString(color->c));
|
||||
if (data == "error") {
|
||||
LOG(("Theme Error: could not adjust '%1: %2' in content"
|
||||
).arg(QString::fromLatin1(name)
|
||||
).arg(QString::fromLatin1(ColorHexString(color->c))));
|
||||
return QByteArray();
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@ -459,6 +470,7 @@ SendMediaReady PrepareThemeMedia(
|
|||
Fn<void()> SavePreparedTheme(
|
||||
not_null<Window::Controller*> window,
|
||||
const ParsedTheme &parsed,
|
||||
const QImage &background,
|
||||
const QByteArray &originalContent,
|
||||
const ParsedTheme &originalParsed,
|
||||
const Data::CloudTheme &fields,
|
||||
|
@ -510,7 +522,8 @@ Fn<void()> SavePreparedTheme(
|
|||
originalParsed,
|
||||
cloud,
|
||||
state->themeContent,
|
||||
parsed);
|
||||
parsed,
|
||||
background);
|
||||
};
|
||||
|
||||
const auto createTheme = [=](const MTPDocument &data) {
|
||||
|
@ -918,6 +931,7 @@ void SaveThemeBox(
|
|||
*cancel = SavePreparedTheme(
|
||||
window,
|
||||
back->result(),
|
||||
back->image(),
|
||||
collected.originalContent,
|
||||
collected.originalParsed,
|
||||
fields,
|
||||
|
|
Loading…
Reference in New Issue