mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Save embedded themes accent colors.
This commit is contained in:
@@ -336,6 +336,10 @@ bool Application::eventFilter(QObject *object, QEvent *e) {
|
||||
return QObject::eventFilter(object, e);
|
||||
}
|
||||
|
||||
void Application::saveSettingsDelayed(crl::time delay) {
|
||||
_saveSettingsTimer.callOnce(delay);
|
||||
}
|
||||
|
||||
void Application::setCurrentProxy(
|
||||
const ProxyData &proxy,
|
||||
ProxyData::Settings settings) {
|
||||
@@ -381,6 +385,7 @@ void Application::startLocalStorage() {
|
||||
}
|
||||
}
|
||||
});
|
||||
_saveSettingsTimer.setCallback([=] { Local::writeSettings(); });
|
||||
}
|
||||
|
||||
void Application::forceLogOut(const TextWithEntities &explanation) {
|
||||
|
@@ -7,8 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/observer.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "mtproto/auth_key.h"
|
||||
#include "base/observer.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class MainWindow;
|
||||
@@ -94,9 +95,6 @@ public:
|
||||
bool closeActiveWindow();
|
||||
bool minimizeActiveWindow();
|
||||
QWidget *getFileDialogParent();
|
||||
QWidget *getGlobalShortcutParent() {
|
||||
return &_globalShortcutParent;
|
||||
}
|
||||
|
||||
// Media view interface.
|
||||
void checkMediaViewActivation();
|
||||
@@ -115,7 +113,13 @@ public:
|
||||
return _logoNoMargin;
|
||||
}
|
||||
|
||||
// MTProto components.
|
||||
[[nodiscard]] Settings &settings() {
|
||||
return _settings;
|
||||
}
|
||||
void moveSettingsFrom(Settings &&other);
|
||||
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
||||
|
||||
// Dc options and proxy.
|
||||
MTP::DcOptions *dcOptions() {
|
||||
return _dcOptions.get();
|
||||
}
|
||||
@@ -221,6 +225,8 @@ protected:
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
private:
|
||||
static constexpr auto kDefaultSaveDelay = crl::time(1000);
|
||||
|
||||
friend bool IsAppLaunched();
|
||||
friend Application &App();
|
||||
|
||||
@@ -251,8 +257,7 @@ private:
|
||||
// Some fields are just moved from the declaration.
|
||||
struct Private;
|
||||
const std::unique_ptr<Private> _private;
|
||||
|
||||
QWidget _globalShortcutParent;
|
||||
Settings _settings;
|
||||
|
||||
const std::unique_ptr<Storage::Databases> _databases;
|
||||
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
||||
@@ -276,6 +281,7 @@ private:
|
||||
std::unique_ptr<Window::TermsLock> _termsLock;
|
||||
|
||||
base::DelayedCallTimer _callDelayedTimer;
|
||||
base::Timer _saveSettingsTimer;
|
||||
|
||||
struct LeaveSubscription {
|
||||
LeaveSubscription(
|
||||
|
51
Telegram/SourceFiles/core/core_settings.cpp
Normal file
51
Telegram/SourceFiles/core/core_settings.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "core/core_settings.h"
|
||||
|
||||
#include "storage/serialize_common.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
Settings::Variables::Variables() {
|
||||
}
|
||||
|
||||
QByteArray Settings::serialize() const {
|
||||
const auto themesAccentColors = _variables.themesAccentColors.serialize();
|
||||
auto size = Serialize::bytearraySize(themesAccentColors);
|
||||
|
||||
auto result = QByteArray();
|
||||
result.reserve(size);
|
||||
{
|
||||
QDataStream stream(&result, QIODevice::WriteOnly);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
stream << themesAccentColors;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Settings::constructFromSerialized(const QByteArray &serialized) {
|
||||
if (serialized.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDataStream stream(serialized);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
QByteArray themesAccentColors;
|
||||
|
||||
stream >> themesAccentColors;
|
||||
if (stream.status() != QDataStream::Ok) {
|
||||
LOG(("App Error: "
|
||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||
return;
|
||||
}
|
||||
if (!_variables.themesAccentColors.setFromSerialized(themesAccentColors)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Core
|
40
Telegram/SourceFiles/core/core_settings.h
Normal file
40
Telegram/SourceFiles/core/core_settings.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "window/themes/window_themes_embedded.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Settings final {
|
||||
public:
|
||||
void moveFrom(Settings &&other) {
|
||||
_variables = std::move(other._variables);
|
||||
}
|
||||
[[nodiscard]] QByteArray serialize() const;
|
||||
void constructFromSerialized(const QByteArray &serialized);
|
||||
|
||||
void setThemesAccentColors(Window::Theme::AccentColors &&colors) {
|
||||
_variables.themesAccentColors = std::move(colors);
|
||||
}
|
||||
[[nodiscard]] Window::Theme::AccentColors &themesAccentColors() {
|
||||
return _variables.themesAccentColors;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Variables {
|
||||
Variables();
|
||||
|
||||
Window::Theme::AccentColors themesAccentColors;
|
||||
};
|
||||
|
||||
Variables _variables;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Core
|
@@ -1587,7 +1587,7 @@ void UpdateApplication() {
|
||||
Window::SectionShow());
|
||||
} else {
|
||||
window->showSpecialLayer(
|
||||
Box<Settings::LayerWidget>(),
|
||||
Box<::Settings::LayerWidget>(),
|
||||
anim::type::normal);
|
||||
}
|
||||
window->showFromTray();
|
||||
|
Reference in New Issue
Block a user