mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
feat: settings overhaul
fix: use more translations
This commit is contained in:
parent
954b367d4f
commit
e21ccd6024
19 changed files with 237 additions and 140 deletions
|
@ -18,25 +18,34 @@ CustomLangPack *CustomLangPack::currentInstance() {
|
|||
return instance;
|
||||
}
|
||||
|
||||
void CustomLangPack::fetchCustomLangPack(const QString& langPackId, const QString& langPackBaseId) {
|
||||
void CustomLangPack::fetchCustomLangPack(const QString &langPackId, const QString &langPackBaseId) {
|
||||
LOG(("Current Language pack ID: %1, Base ID: %2").arg(langPackId, langPackBaseId));
|
||||
|
||||
const auto proxy = Core::App().settings().proxy().isEnabled() ? Core::App().settings().proxy().selected() : MTP::ProxyData();
|
||||
auto finalLangPackId = langPackId;
|
||||
if (finalLangPackId == qsl("pt-br")) { // meh
|
||||
finalLangPackId = qsl("pt");
|
||||
}
|
||||
|
||||
const auto proxy = Core::App().settings().proxy().isEnabled() ? Core::App().settings().proxy().selected()
|
||||
: MTP::ProxyData();
|
||||
if (proxy.type == MTP::ProxyData::Type::Socks5 || proxy.type == MTP::ProxyData::Type::Http) {
|
||||
QNetworkProxy LocaleProxy = MTP::ToNetworkProxy(MTP::ToDirectIpProxy(proxy));
|
||||
networkManager.setProxy(LocaleProxy);
|
||||
}
|
||||
|
||||
QUrl url;
|
||||
if (!langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) {
|
||||
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/localization/translations/desktop/%1.json").arg(langPackId));
|
||||
if (!finalLangPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) {
|
||||
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/localization/translations/desktop/%1.json").arg(
|
||||
finalLangPackId));
|
||||
} else {
|
||||
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/localization/translations/desktop/%1.json").arg(needFallback ? langPackBaseId : langPackId));
|
||||
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/localization/translations/desktop/%1.json").arg(
|
||||
needFallback ? langPackBaseId : finalLangPackId));
|
||||
}
|
||||
_chkReply = networkManager.get(QNetworkRequest(url));
|
||||
connect(_chkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(fetchError(QNetworkReply::NetworkError)));
|
||||
connect(_chkReply, SIGNAL(finished()), this, SLOT(fetchFinished()));
|
||||
LOG(("Fetching %1 lang pack...").arg(needFallback ? (langPackBaseId.isEmpty() ? langPackId : langPackBaseId) : langPackId));
|
||||
LOG(("Fetching %1 lang pack...").arg(
|
||||
needFallback ? (langPackBaseId.isEmpty() ? finalLangPackId : langPackBaseId) : finalLangPackId));
|
||||
}
|
||||
|
||||
void CustomLangPack::fetchFinished() {
|
||||
|
@ -51,8 +60,7 @@ void CustomLangPack::fetchFinished() {
|
|||
needFallback = true;
|
||||
_chkReply->disconnect();
|
||||
fetchCustomLangPack("", langPackBaseId);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
QByteArray result = _chkReply->readAll().trimmed();
|
||||
QJsonParseError error{};
|
||||
QJsonDocument str = QJsonDocument::fromJson(result, &error);
|
||||
|
@ -92,7 +100,7 @@ void CustomLangPack::loadDefaultLangFile() {
|
|||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QJsonDocument str = QJsonDocument::fromJson(file.readAll());
|
||||
QJsonObject json = str.object();
|
||||
for (const QString& key : json.keys()) {
|
||||
for (const QString &key: json.keys()) {
|
||||
Lang::GetInstance().applyValue(key.toUtf8(), json.value(key).toString().toUtf8());
|
||||
}
|
||||
Lang::GetInstance().updatePluralRules();
|
||||
|
@ -102,9 +110,9 @@ void CustomLangPack::loadDefaultLangFile() {
|
|||
|
||||
void CustomLangPack::parseLangFile(QJsonDocument str) {
|
||||
QJsonObject json = str.object();
|
||||
for (const QString& brokenKey : json.keys()) {
|
||||
for (const QString &brokenKey: json.keys()) {
|
||||
auto key = qsl("ayu_") + brokenKey;
|
||||
auto val = json.value(brokenKey).toString().toUtf8();
|
||||
auto val = json.value(brokenKey).toString().replace(qsl("&"), qsl("&")).toUtf8();
|
||||
|
||||
Lang::GetInstance().resetValue(key.toUtf8());
|
||||
Lang::GetInstance().applyValue(key.toUtf8(), val);
|
||||
|
|
|
@ -5,23 +5,31 @@
|
|||
|
||||
class CustomLangPack : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_DISABLE_COPY(CustomLangPack)
|
||||
|
||||
public:
|
||||
static CustomLangPack *currentInstance();
|
||||
|
||||
static void initInstance();
|
||||
|
||||
static CustomLangPack *instance;
|
||||
|
||||
void fetchCustomLangPack(const QString& langPackId, const QString& langPackBaseId);
|
||||
void fetchCustomLangPack(const QString &langPackId, const QString &langPackBaseId);
|
||||
|
||||
void loadDefaultLangFile();
|
||||
|
||||
void parseLangFile(QJsonDocument str);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void fetchFinished();
|
||||
|
||||
void fetchError(QNetworkReply::NetworkError e);
|
||||
|
||||
private:
|
||||
CustomLangPack();
|
||||
|
||||
~CustomLangPack() = default;
|
||||
|
||||
QNetworkAccessManager networkManager;
|
||||
|
|
|
@ -1,14 +1,57 @@
|
|||
#include "ayu_settings.h"
|
||||
#include "rpl/lifetime.h"
|
||||
|
||||
namespace AyuSettings {
|
||||
const QString filename = "tdata/ayu_settings.json";
|
||||
const int latestMigration = 1;
|
||||
std::optional<AyuGramSettings> settings = std::nullopt;
|
||||
|
||||
AyuGramSettings &getInstance() {
|
||||
if (!settings.has_value()) {
|
||||
settings = std::optional(AyuGramSettings());
|
||||
rpl::variable<bool> sendReadPacketsReactive;
|
||||
rpl::variable<bool> sendOnlinePacketsReactive;
|
||||
rpl::variable<bool> sendOfflinePacketAfterOnlineReactive;
|
||||
rpl::variable<bool> sendUploadProgressReactive;
|
||||
rpl::variable<bool> useScheduledMessagesReactive;
|
||||
rpl::variable<bool> keepDeletedMessagesReactive;
|
||||
rpl::variable<bool> keepMessagesHistoryReactive;
|
||||
rpl::variable<QString> deletedMarkReactive;
|
||||
rpl::variable<QString> editedMarkReactive;
|
||||
rpl::variable<bool> ghostModeEnabled;
|
||||
|
||||
rpl::lifetime lifetime = rpl::lifetime();
|
||||
|
||||
void initialize() {
|
||||
if (settings.has_value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
settings = std::optional(AyuGramSettings());
|
||||
|
||||
sendReadPacketsReactive.value() | rpl::filter([=](bool val) {
|
||||
return (val != settings->sendReadPackets);
|
||||
}) | rpl::start_with_next([=](bool val) {
|
||||
ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets;
|
||||
}, lifetime);
|
||||
sendOnlinePacketsReactive.value() | rpl::filter([=](bool val) {
|
||||
return (val != settings->sendOnlinePackets);
|
||||
}) | rpl::start_with_next([=](bool val) {
|
||||
ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets;
|
||||
}, lifetime);
|
||||
}
|
||||
|
||||
void postinitialize() {
|
||||
sendReadPacketsReactive = settings->sendReadPackets;
|
||||
sendOnlinePacketsReactive = settings->sendOnlinePackets;
|
||||
sendOfflinePacketAfterOnlineReactive = settings->sendOfflinePacketAfterOnline;
|
||||
sendUploadProgressReactive = settings->sendUploadProgress;
|
||||
useScheduledMessagesReactive = settings->useScheduledMessages;
|
||||
keepDeletedMessagesReactive = settings->keepDeletedMessages;
|
||||
keepMessagesHistoryReactive = settings->keepMessagesHistory;
|
||||
deletedMarkReactive = settings->deletedMark;
|
||||
editedMarkReactive = settings->editedMark;
|
||||
ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets;
|
||||
}
|
||||
|
||||
AyuGramSettings &getInstance() {
|
||||
initialize();
|
||||
return settings.value();
|
||||
}
|
||||
|
||||
|
@ -21,23 +64,106 @@ namespace AyuSettings {
|
|||
QByteArray json = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (!settings.has_value()) {
|
||||
settings = std::optional(AyuGramSettings());
|
||||
}
|
||||
initialize();
|
||||
settings->fromJson(json);
|
||||
postinitialize();
|
||||
}
|
||||
|
||||
void save() {
|
||||
if (!settings.has_value()) {
|
||||
settings = std::optional(AyuGramSettings());
|
||||
}
|
||||
initialize();
|
||||
|
||||
settings->migrationVersion = latestMigration;
|
||||
QByteArray json = settings->toRawJson();
|
||||
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(json);
|
||||
file.close();
|
||||
|
||||
postinitialize();
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_sendReadPackets(bool val) {
|
||||
sendReadPackets = val;
|
||||
sendReadPacketsReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_sendOnlinePackets(bool val) {
|
||||
sendOnlinePackets = val;
|
||||
sendOnlinePacketsReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_sendOfflinePacketAfterOnline(bool val) {
|
||||
sendOfflinePacketAfterOnline = val;
|
||||
sendOfflinePacketAfterOnlineReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_sendUploadProgress(bool val) {
|
||||
sendUploadProgress = val;
|
||||
sendUploadProgressReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_useScheduledMessages(bool val) {
|
||||
useScheduledMessages = val;
|
||||
useScheduledMessagesReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_keepDeletedMessages(bool val) {
|
||||
keepDeletedMessages = val;
|
||||
keepDeletedMessagesReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_keepMessagesHistory(bool val) {
|
||||
keepMessagesHistory = val;
|
||||
keepMessagesHistoryReactive = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_deletedMark(QString val) {
|
||||
deletedMark = std::move(val);
|
||||
deletedMarkReactive = deletedMark;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_editedMark(QString val) {
|
||||
editedMark = std::move(val);
|
||||
editedMarkReactive = editedMark;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_sendReadPacketsReactive() {
|
||||
return sendReadPacketsReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_sendOnlinePacketsReactive() {
|
||||
return sendOnlinePacketsReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_sendOfflinePacketAfterOnlineReactive() {
|
||||
return sendOfflinePacketAfterOnlineReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_sendUploadProgressReactive() {
|
||||
return sendUploadProgressReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_useScheduledMessagesReactive() {
|
||||
return useScheduledMessagesReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_keepDeletedMessagesReactive() {
|
||||
return keepDeletedMessagesReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_keepMessagesHistoryReactive() {
|
||||
return keepMessagesHistoryReactive;
|
||||
}
|
||||
|
||||
rpl::variable<QString> get_deletedMarkReactive() {
|
||||
return deletedMarkReactive;
|
||||
}
|
||||
|
||||
rpl::variable<QString> get_editedMarkReactive() {
|
||||
return editedMarkReactive;
|
||||
}
|
||||
|
||||
rpl::variable<bool> get_ghostModeEnabled() {
|
||||
return ghostModeEnabled;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "rpl/producer.h"
|
||||
|
||||
#define QS_HAS_JSON
|
||||
|
||||
#include <lang_auto.h>
|
||||
#include "lang_auto.h"
|
||||
#include "qserializer.h"
|
||||
|
||||
namespace AyuSettings {
|
||||
|
@ -11,8 +13,6 @@ namespace AyuSettings {
|
|||
|
||||
public:
|
||||
AyuGramSettings() {
|
||||
migrationVersion = 0;
|
||||
|
||||
sendReadPackets = true;
|
||||
sendOnlinePackets = true;
|
||||
sendOfflinePacketAfterOnline = false;
|
||||
|
@ -22,13 +22,10 @@ namespace AyuSettings {
|
|||
keepMessagesHistory = false;
|
||||
deletedMark = "🧹";
|
||||
editedMark = tr::lng_edited(tr::now);
|
||||
ghostMode = true;
|
||||
}
|
||||
|
||||
QS_SERIALIZABLE
|
||||
|
||||
QS_FIELD(int, migrationVersion)
|
||||
|
||||
QS_FIELD(bool, sendReadPackets)
|
||||
|
||||
QS_FIELD(bool, sendOnlinePackets)
|
||||
|
@ -47,52 +44,16 @@ namespace AyuSettings {
|
|||
|
||||
QS_FIELD(QString, editedMark)
|
||||
|
||||
QS_FIELD(bool, ghostMode)
|
||||
|
||||
public:
|
||||
void set_migrationVersion(int val) {
|
||||
migrationVersion = val;
|
||||
}
|
||||
|
||||
void set_sendReadPackets(bool val) {
|
||||
sendReadPackets = val;
|
||||
}
|
||||
|
||||
void set_sendOnlinePackets(bool val) {
|
||||
sendOnlinePackets = val;
|
||||
}
|
||||
|
||||
void set_sendOfflinePacketAfterOnline(bool val) {
|
||||
sendOfflinePacketAfterOnline = val;
|
||||
}
|
||||
|
||||
void set_sendUploadProgress(bool val) {
|
||||
sendUploadProgress = val;
|
||||
}
|
||||
|
||||
void set_useScheduledMessages(bool val) {
|
||||
useScheduledMessages = val;
|
||||
}
|
||||
|
||||
void set_keepDeletedMessages(bool val) {
|
||||
keepDeletedMessages = val;
|
||||
}
|
||||
|
||||
void set_keepMessagesHistory(bool val) {
|
||||
keepMessagesHistory = val;
|
||||
}
|
||||
|
||||
void set_deletedMark(QString val) {
|
||||
deletedMark = val;
|
||||
}
|
||||
|
||||
void set_editedMark(QString val) {
|
||||
editedMark = val;
|
||||
}
|
||||
|
||||
void set_ghostMode(bool val) {
|
||||
ghostMode = val;
|
||||
}
|
||||
void set_sendReadPackets(bool val);
|
||||
void set_sendOnlinePackets(bool val);
|
||||
void set_sendOfflinePacketAfterOnline(bool val);
|
||||
void set_sendUploadProgress(bool val);
|
||||
void set_useScheduledMessages(bool val);
|
||||
void set_keepDeletedMessages(bool val);
|
||||
void set_keepMessagesHistory(bool val);
|
||||
void set_deletedMark(QString val);
|
||||
void set_editedMark(QString val);
|
||||
};
|
||||
|
||||
AyuGramSettings &getInstance();
|
||||
|
@ -100,4 +61,17 @@ namespace AyuSettings {
|
|||
void load();
|
||||
|
||||
void save();
|
||||
|
||||
rpl::variable<bool> get_sendReadPacketsReactive();
|
||||
rpl::variable<bool> get_sendOnlinePacketsReactive();
|
||||
rpl::variable<bool> get_sendOfflinePacketAfterOnlineReactive();
|
||||
rpl::variable<bool> get_sendUploadProgressReactive();
|
||||
rpl::variable<bool> get_useScheduledMessagesReactive();
|
||||
rpl::variable<bool> get_keepDeletedMessagesReactive();
|
||||
rpl::variable<bool> get_keepMessagesHistoryReactive();
|
||||
rpl::variable<QString> get_deletedMarkReactive();
|
||||
rpl::variable<QString> get_editedMarkReactive();
|
||||
|
||||
// computed fields
|
||||
rpl::variable<bool> get_ghostModeEnabled();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace AyuState {
|
|||
|
||||
AyuStateVariable allowSendReadPacket;
|
||||
|
||||
bool processVariable(AyuStateVariable& variable) {
|
||||
bool processVariable(AyuStateVariable &variable) {
|
||||
if (variable.resetAfter == -1) {
|
||||
return variable.val;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace AyuUi {
|
||||
ConfirmationBox::ConfirmationBox(
|
||||
QWidget*,
|
||||
QWidget *,
|
||||
not_null<Window::SessionController *> controller) : _controller(controller) {
|
||||
//
|
||||
}
|
||||
|
|
|
@ -4,11 +4,14 @@
|
|||
namespace AyuUi {
|
||||
class ConfirmationBox : public Ui::BoxContent {
|
||||
public:
|
||||
ConfirmationBox(QWidget*, not_null<Window::SessionController *> controller);
|
||||
ConfirmationBox(QWidget *, not_null<Window::SessionController *> controller);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
private:
|
||||
void ReadAllPeers();
|
||||
not_null<Window::SessionController*> _controller;
|
||||
|
||||
not_null<Window::SessionController *> _controller;
|
||||
};
|
||||
}
|
|
@ -75,8 +75,8 @@ void EditDeletedMarkBox::resizeEvent(QResizeEvent *e) {
|
|||
|
||||
void EditDeletedMarkBox::save() {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
settings->deletedMark = _text->getLastText();
|
||||
Local::writeSettings();
|
||||
settings->set_deletedMark(_text->getLastText());
|
||||
AyuSettings::save();
|
||||
|
||||
closeBox();
|
||||
}
|
||||
|
|
|
@ -6,16 +6,18 @@
|
|||
|
||||
class EditDeletedMarkBox : public Ui::BoxContent {
|
||||
public:
|
||||
EditDeletedMarkBox(QWidget*);
|
||||
EditDeletedMarkBox(QWidget *);
|
||||
|
||||
protected:
|
||||
void setInnerFocus() override;
|
||||
|
||||
void prepare() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
void submit();
|
||||
|
||||
void save();
|
||||
|
||||
object_ptr<Ui::InputField> _text;
|
||||
|
|
|
@ -31,7 +31,6 @@ EditEditedMarkBox::EditEditedMarkBox(QWidget *) :
|
|||
}
|
||||
|
||||
|
||||
|
||||
void EditEditedMarkBox::prepare() {
|
||||
const auto defaultEditedMark = tr::lng_edited(tr::now);
|
||||
auto newHeight = st::contactPadding.top() + _text->height();
|
||||
|
@ -78,8 +77,8 @@ void EditEditedMarkBox::resizeEvent(QResizeEvent *e) {
|
|||
|
||||
void EditEditedMarkBox::save() {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
settings->editedMark = _text->getLastText();
|
||||
Local::writeSettings();
|
||||
settings->set_editedMark(_text->getLastText());
|
||||
AyuSettings::save();
|
||||
|
||||
closeBox();
|
||||
}
|
|
@ -6,16 +6,18 @@
|
|||
|
||||
class EditEditedMarkBox : public Ui::BoxContent {
|
||||
public:
|
||||
EditEditedMarkBox(QWidget*);
|
||||
EditEditedMarkBox(QWidget *);
|
||||
|
||||
protected:
|
||||
void setInnerFocus() override;
|
||||
|
||||
void prepare() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
void submit();
|
||||
|
||||
void save();
|
||||
|
||||
object_ptr<Ui::InputField> _text;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace AyuUi {
|
|||
|
||||
void AyuPopupMenu::addHistoryAction(HistoryItem *item) {
|
||||
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) {
|
||||
_ayuSubMenu->addAction(QString("History"), [=] {
|
||||
_ayuSubMenu->addAction(tr::ayu_EditsHistoryMenuText(tr::now), [=] {
|
||||
auto box = Box<MessageHistoryBox>(item);
|
||||
Ui::show(std::move(box));
|
||||
}, &st::menuIconInfo);
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace AyuUi {
|
|||
}
|
||||
|
||||
void MessageHistoryBox::prepare() {
|
||||
setTitle(rpl::single(QString("Message history")));
|
||||
setTitle(tr::ayu_EditsHistoryTitle());
|
||||
|
||||
// setDimensionsToContent(st::boxWideWidth, _content);
|
||||
setDimensions(st::boxWideWidth, 900);
|
||||
|
@ -53,7 +53,7 @@ namespace AyuUi {
|
|||
return;
|
||||
}
|
||||
|
||||
for (const auto& message : messages) {
|
||||
for (const auto &message: messages) {
|
||||
AddSkip(_content);
|
||||
AddDividerText(_content, rpl::single(QString::fromStdString(message.text)));
|
||||
AddSkip(_content);
|
||||
|
|
|
@ -6,12 +6,16 @@
|
|||
namespace AyuUi {
|
||||
class MessageHistoryBox : public Ui::BoxContent {
|
||||
public:
|
||||
MessageHistoryBox(QWidget*, HistoryItem *item);
|
||||
MessageHistoryBox(QWidget *, HistoryItem *item);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
void setupControls();
|
||||
|
||||
void addEditedMessagesToLayout(HistoryItem *item);
|
||||
|
||||
object_ptr<Ui::VerticalLayout> _content;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace AyuDatabase {
|
|||
c(&EditedMessage::userId) == userId and
|
||||
c(&EditedMessage::dialogId) == dialogId and
|
||||
c(&EditedMessage::messageId) == messageId)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
std::vector<EditedMessage> getEditedMessages(HistoryItem *item) {
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace AyuDatabase {
|
|||
long userId,
|
||||
long dialogId,
|
||||
long messageId,
|
||||
const QString& text,
|
||||
const QString &text,
|
||||
bool isDocument,
|
||||
QString path,
|
||||
long date);
|
||||
|
|
|
@ -35,8 +35,7 @@ namespace Settings {
|
|||
setupContent(controller);
|
||||
}
|
||||
|
||||
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container,
|
||||
not_null<Window::SessionController *> controller) {
|
||||
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
AddSkip(container);
|
||||
|
@ -150,41 +149,27 @@ namespace Settings {
|
|||
|
||||
AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
|
||||
|
||||
auto currentDeletedMark = lifetime().make_state<rpl::variable<QString>>();
|
||||
|
||||
auto btn = AddButtonWithLabel(
|
||||
container,
|
||||
tr::ayu_DeletedMarkText(),
|
||||
currentDeletedMark->changes(),
|
||||
AyuSettings::get_deletedMarkReactive().value(),
|
||||
st::settingsButtonNoIcon
|
||||
);
|
||||
btn->addClickHandler([=]() {
|
||||
auto box = Box<EditDeletedMarkBox>();
|
||||
box->boxClosing() | rpl::start_with_next([=]() {
|
||||
*currentDeletedMark = settings->deletedMark;
|
||||
}, container->lifetime());
|
||||
|
||||
Ui::show(std::move(box));
|
||||
});
|
||||
*currentDeletedMark = settings->deletedMark;
|
||||
|
||||
auto currentEditedMark = lifetime().make_state<rpl::variable<QString>>();
|
||||
|
||||
auto btn2 = AddButtonWithLabel(
|
||||
container,
|
||||
rpl::single(QString("Edited mark")),
|
||||
currentEditedMark->changes(),
|
||||
AyuSettings::get_editedMarkReactive().value(),
|
||||
st::settingsButtonNoIcon
|
||||
);
|
||||
btn2->addClickHandler([=]() {
|
||||
auto box = Box<EditEditedMarkBox>();
|
||||
box->boxClosing() | rpl::start_with_next([=]() {
|
||||
*currentEditedMark = settings->editedMark;
|
||||
}, container->lifetime());
|
||||
|
||||
Ui::show(std::move(box));
|
||||
});
|
||||
*currentEditedMark = settings->editedMark;
|
||||
|
||||
AddDividerText(container, tr::ayu_SettingsWatermark());
|
||||
}
|
||||
|
@ -192,7 +177,7 @@ namespace Settings {
|
|||
void Ayu::setupContent(not_null<Window::SessionController *> controller) {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
SetupAyuGramSettings(content, controller);
|
||||
SetupAyuGramSettings(content);
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
/*
|
||||
This file is part of 64Gram Desktop,
|
||||
the unofficial app based on Telegram Desktop.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/TDesktop-x64/tdesktop/blob/dev/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "settings/settings_common.h"
|
||||
|
@ -12,21 +5,21 @@ https://github.com/TDesktop-x64/tdesktop/blob/dev/LEGAL
|
|||
class BoxContent;
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
class SessionController;
|
||||
class Controller;
|
||||
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Settings {
|
||||
class Ayu : public Section<Ayu> {
|
||||
public:
|
||||
Ayu(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController *> controller);
|
||||
class Ayu : public Section<Ayu> {
|
||||
public:
|
||||
Ayu(QWidget *parent, not_null<Window::SessionController *> controller);
|
||||
|
||||
[[nodiscard]] rpl::producer<QString> title() override;
|
||||
|
||||
private:
|
||||
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> null);
|
||||
void setupContent(not_null<Window::SessionController *> controller);
|
||||
};
|
||||
private:
|
||||
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container);
|
||||
void setupContent(not_null<Window::SessionController *> controller);
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -843,28 +843,21 @@ void MainMenu::setupMenu() {
|
|||
toggle);
|
||||
}, _nightThemeToggle->lifetime());
|
||||
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
_ghostModeToggle = addAction(
|
||||
rpl::single(QString("Ghost Mode")),
|
||||
{ &st::menuIconFake, kIconPurple }
|
||||
)->toggleOn(rpl::single((&AyuSettings::getInstance())->ghostMode));
|
||||
)->toggleOn(AyuSettings::get_ghostModeEnabled().value());
|
||||
|
||||
_ghostModeToggle->toggledChanges(
|
||||
) | rpl::filter([=](bool ghostMode) {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
return (ghostMode != settings->ghostMode);
|
||||
}) | rpl::start_with_next([=](bool ghostMode) {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
settings->set_ghostMode(ghostMode);
|
||||
|
||||
) | rpl::start_with_next([=](bool ghostMode) {
|
||||
settings->set_sendReadPackets(!ghostMode);
|
||||
settings->set_sendOnlinePackets(!ghostMode);
|
||||
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
||||
settings->set_sendUploadProgress(!ghostMode);
|
||||
settings->set_keepDeletedMessages(ghostMode);
|
||||
settings->set_keepMessagesHistory(ghostMode);
|
||||
|
||||
settings->set_sendOfflinePacketAfterOnline(ghostMode);
|
||||
|
||||
AyuSettings::save();
|
||||
|
||||
}, _ghostModeToggle->lifetime());
|
||||
|
||||
Core::App().settings().systemDarkModeValue(
|
||||
|
|
Loading…
Add table
Reference in a new issue