Moved JSON settings

This commit is contained in:
Eric Kotato 2020-04-21 06:20:14 +03:00
parent fea7148e9b
commit 29610ddda2
10 changed files with 43 additions and 39 deletions

View file

@ -309,8 +309,8 @@ PRIVATE
core/crash_reports.h
core/file_utilities.cpp
core/file_utilities.h
core/kotato_settings.cpp
core/kotato_settings.h
kotato/json_settings.cpp
kotato/json_settings.h
core/launcher.cpp
core/launcher.h
core/local_url_handlers.cpp

View file

@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat_filters.h"
#include "data/data_peer.h"
#include "data/data_session.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "settings/settings_common.h"
#include "base/event_filter.h"
#include "lang/lang_keys.h"
@ -696,7 +696,7 @@ void EditExistingFilter(
if ((isCurrentDefault && !result.isDefault())
|| (!isCurrentDefault && result.isDefault())) {
cSetDefaultFilterId(result.isDefault() ? result.id() : 0);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}
};
window->window().show(Box(

View file

@ -13,7 +13,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "boxes/confirm_box.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "lang/lang_keys.h"
#include "app.h"
@ -116,7 +116,7 @@ void FontsBox::save() {
cSetSemiboldFont(semiboldFont);
cSetSemiboldFontIsBold(semiboldIsBold);
cSetMonospaceFont(monospacedFont);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
App::restart();
};
@ -142,7 +142,7 @@ void FontsBox::resetToDefault() {
cSetUseSystemFont(false);
#endif
cSetUseOriginalMetrics(false);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
App::restart();
};

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "boxes/confirm_box.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "app.h"
NetBoostBox::NetBoostBox(QWidget* parent)
@ -74,7 +74,7 @@ QString NetBoostBox::BoostLabel(int boost) {
void NetBoostBox::save() {
const auto changeBoost = [=] {
SetNetworkBoost(_boostGroup->value());
KotatoSettings::Write();
Kotato::JsonSettings::Write();
App::restart();
};

View file

@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/sandbox.h"
#include "core/local_url_handlers.h"
#include "core/launcher.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "core/ui_integration.h"
#include "chat_helpers/emoji_keywords.h"
#include "storage/localstorage.h"
@ -177,12 +177,12 @@ Application::~Application() {
Global::finish();
ThirdParty::finish();
KotatoSettings::Finish();
Kotato::JsonSettings::Finish();
Instance = nullptr;
}
void Application::run() {
KotatoSettings::Start();
Kotato::JsonSettings::Start();
if (!cMainFont().isEmpty()) {
style::internal::CustomMainFont = cMainFont();
}

View file

@ -5,7 +5,7 @@ the unofficial app based on Telegram Desktop.
For license and copyright information please follow this link:
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
*/
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "mainwindow.h"
#include "mainwidget.h"
@ -21,7 +21,8 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include <QtCore/QJsonValue>
#include <QtCore/QTimer>
namespace KotatoSettings {
namespace Kotato {
namespace JsonSettings {
namespace {
constexpr auto kWriteJsonTimeout = crl::time(5000);
@ -541,4 +542,5 @@ void Finish() {
Data->write(true);
}
} // namespace KotatoSettings
} // namespace JsonSettings
} // namespace Kotato

View file

@ -9,7 +9,8 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include <QtCore/QTimer>
namespace KotatoSettings {
namespace Kotato {
namespace JsonSettings {
class Manager : public QObject {
Q_OBJECT
@ -36,4 +37,5 @@ void Start();
void Write();
void Finish();
} // namespace KotatoSettings
} // namespace JsonSettings
} // namespace Kotato

View file

@ -24,7 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h"
#include "ui/painter.h"
#include "ui/filter_icons.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "settings/settings_common.h"
#include "lang/lang_keys.h"
#include "apiwrap.h"
@ -593,7 +593,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
controller->setActiveChatsFilter(0);
}
if (currentDefaultId != cDefaultFilterId()) {
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}
};
}

View file

@ -25,7 +25,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "window/window_session_controller.h"
#include "lang/lang_keys.h"
#include "core/update_checker.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "core/application.h"
#include "storage/localstorage.h"
#include "data/data_session.h"
@ -64,7 +64,7 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
const auto updateRecentStickersLimitHeight = [=](int value) {
updateRecentStickersLimitLabel(value);
SetRecentStickersLimit(value);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
};
recentStickersLimitSlider->resize(st::settingsAudioVolumeSlider.seekSize);
recentStickersLimitSlider->setPseudoDiscrete(
@ -85,7 +85,7 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
return (enabled != cProfileTopBarNotifications());
}) | rpl::start_with_next([](bool enabled) {
cSetProfileTopBarNotifications(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -99,7 +99,7 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
return (enabled != cDisableUpEdit());
}) | rpl::start_with_next([](bool enabled) {
cSetDisableUpEdit(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -113,7 +113,7 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
return (enabled != (DialogListLines() == 1));
}) | rpl::start_with_next([](bool enabled) {
SetDialogListLines(enabled ? 1 : 2);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -128,7 +128,7 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
}) | rpl::start_with_next([](bool enabled) {
cSetAlwaysShowScheduled(enabled);
Notify::showScheduledButtonChanged();
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -165,7 +165,7 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
const auto updateStickerHeight = [=](int value) {
updateStickerHeightLabel(value);
SetStickerHeight(value);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
};
stickerHeightSlider->resize(st::settingsAudioVolumeSlider.seekSize);
stickerHeightSlider->setPseudoDiscrete(
@ -186,7 +186,7 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
return (enabled != AdaptiveBubbles());
}) | rpl::start_with_next([](bool enabled) {
SetAdaptiveBubbles(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -200,7 +200,7 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
return (enabled != BigEmojiOutline());
}) | rpl::start_with_next([](bool enabled) {
SetBigEmojiOutline(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddSkip(container);
@ -241,7 +241,7 @@ void SetupKotatoFolders(
return (enabled != cUnmutedFilterCounterOnly());
}) | rpl::start_with_next([=](bool enabled) {
cSetUnmutedFilterCounterOnly(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
controller->reloadFiltersMenu();
App::wnd()->fixOrder();
}, container->lifetime());
@ -257,7 +257,7 @@ void SetupKotatoFolders(
return (enabled != cHideFilterAllChats());
}) | rpl::start_with_next([=](bool enabled) {
cSetHideFilterAllChats(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
controller->reloadFiltersMenu();
App::wnd()->fixOrder();
}, container->lifetime());
@ -273,7 +273,7 @@ void SetupKotatoFolders(
return (enabled != cHideFilterEditButton());
}) | rpl::start_with_next([=](bool enabled) {
cSetHideFilterEditButton(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
controller->reloadFiltersMenu();
App::wnd()->fixOrder();
}, container->lifetime());
@ -289,7 +289,7 @@ void SetupKotatoFolders(
return (enabled != cHideFilterNames());
}) | rpl::start_with_next([=](bool enabled) {
cSetHideFilterNames(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
controller->reloadFiltersMenu();
App::wnd()->fixOrder();
}, container->lifetime());
@ -313,7 +313,7 @@ void SetupKotatoSystem(not_null<Ui::VerticalLayout*> container) {
return (enabled != cNoTaskbarFlashing());
}) | rpl::start_with_next([](bool enabled) {
cSetNoTaskbarFlashing(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddSkip(container);
@ -335,7 +335,7 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
return (enabled != cShowPhoneInDrawer());
}) | rpl::start_with_next([](bool enabled) {
cSetShowPhoneInDrawer(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -349,7 +349,7 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
return (enabled != cShowChatId());
}) | rpl::start_with_next([](bool enabled) {
cSetShowChatId(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
@ -363,7 +363,7 @@ void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
return (enabled != cConfirmBeforeCall());
}) | rpl::start_with_next([](bool enabled) {
cSetConfirmBeforeCall(enabled);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}, container->lifetime());
AddSkip(container);

View file

@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h"
#include "boxes/confirm_box.h"
#include "boxes/filters/edit_filter_box.h"
#include "core/kotato_settings.h"
#include "kotato/json_settings.h"
#include "settings/settings_common.h"
#include "api/api_chat_filters.h"
#include "apiwrap.h"
@ -351,7 +351,7 @@ void FiltersMenu::showAllMenu(QPoint position) {
void FiltersMenu::setDefaultFilter(FilterId id) {
if (cDefaultFilterId() != id) {
cSetDefaultFilterId(id);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
}
}
@ -379,7 +379,7 @@ void FiltersMenu::remove(FilterId id) {
)).send();
if (id == cDefaultFilterId()) {
cSetDefaultFilterId(0);
KotatoSettings::Write();
Kotato::JsonSettings::Write();
if (id == _session->activeChatsFilterCurrent()) {
_session->setActiveChatsFilter(0);
}