mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
feat: reformat ayu files with resharper
This commit is contained in:
parent
85e8c75ad1
commit
32a2de1bef
35 changed files with 1866 additions and 1590 deletions
|
@ -8,43 +8,53 @@
|
||||||
#include "ayu_lang.h"
|
#include "ayu_lang.h"
|
||||||
|
|
||||||
#include "qjsondocument.h"
|
#include "qjsondocument.h"
|
||||||
#include "lang/lang_instance.h"
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
#include "lang/lang_instance.h"
|
||||||
|
|
||||||
CustomLangPack* CustomLangPack::instance = nullptr;
|
CustomLangPack* CustomLangPack::instance = nullptr;
|
||||||
|
|
||||||
CustomLangPack::CustomLangPack() = default;
|
CustomLangPack::CustomLangPack() = default;
|
||||||
|
|
||||||
void CustomLangPack::initInstance() {
|
void CustomLangPack::initInstance()
|
||||||
|
{
|
||||||
if (!instance)
|
if (!instance)
|
||||||
instance = new CustomLangPack;
|
instance = new CustomLangPack;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomLangPack *CustomLangPack::currentInstance() {
|
CustomLangPack* CustomLangPack::currentInstance()
|
||||||
|
{
|
||||||
return instance;
|
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));
|
LOG(("Current Language pack ID: %1, Base ID: %2").arg(langPackId, langPackBaseId));
|
||||||
|
|
||||||
auto finalLangPackId = langPackId;
|
auto finalLangPackId = langPackId;
|
||||||
if (finalLangPackId == qsl("pt-br")) { // meh
|
if (finalLangPackId == qsl("pt-br"))
|
||||||
|
{
|
||||||
|
// meh
|
||||||
finalLangPackId = qsl("pt");
|
finalLangPackId = qsl("pt");
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto proxy = Core::App().settings().proxy().isEnabled() ? Core::App().settings().proxy().selected()
|
const auto proxy = Core::App().settings().proxy().isEnabled()
|
||||||
|
? Core::App().settings().proxy().selected()
|
||||||
: MTP::ProxyData();
|
: MTP::ProxyData();
|
||||||
if (proxy.type == MTP::ProxyData::Type::Socks5 || proxy.type == MTP::ProxyData::Type::Http) {
|
if (proxy.type == MTP::ProxyData::Type::Socks5 || proxy.type == MTP::ProxyData::Type::Http)
|
||||||
QNetworkProxy LocaleProxy = MTP::ToNetworkProxy(MTP::ToDirectIpProxy(proxy));
|
{
|
||||||
|
QNetworkProxy LocaleProxy = ToNetworkProxy(ToDirectIpProxy(proxy));
|
||||||
networkManager.setProxy(LocaleProxy);
|
networkManager.setProxy(LocaleProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
if (!finalLangPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) {
|
if (!finalLangPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback)
|
||||||
|
{
|
||||||
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/Languages/l10n_main/values/langs/%1/Shared.json").arg(
|
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/Languages/l10n_main/values/langs/%1/Shared.json").arg(
|
||||||
finalLangPackId));
|
finalLangPackId));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/Languages/l10n_main/values/langs/%1/Shared.json").arg(
|
url.setUrl(qsl("https://raw.githubusercontent.com/AyuGram/Languages/l10n_main/values/langs/%1/Shared.json").arg(
|
||||||
needFallback ? langPackBaseId : finalLangPackId));
|
needFallback ? langPackBaseId : finalLangPackId));
|
||||||
}
|
}
|
||||||
|
@ -55,25 +65,32 @@ void CustomLangPack::fetchCustomLangPack(const QString &langPackId, const QStrin
|
||||||
needFallback ? (langPackBaseId.isEmpty() ? finalLangPackId : langPackBaseId) : finalLangPackId));
|
needFallback ? (langPackBaseId.isEmpty() ? finalLangPackId : langPackBaseId) : finalLangPackId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomLangPack::fetchFinished() {
|
void CustomLangPack::fetchFinished()
|
||||||
|
{
|
||||||
if (!_chkReply) return;
|
if (!_chkReply) return;
|
||||||
|
|
||||||
QString langPackBaseId = Lang::GetInstance().baseId();
|
QString langPackBaseId = Lang::GetInstance().baseId();
|
||||||
QString langPackId = Lang::GetInstance().id();
|
QString langPackId = Lang::GetInstance().id();
|
||||||
auto statusCode = _chkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
auto statusCode = _chkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|
||||||
if (statusCode == 404 && !langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) {
|
if (statusCode == 404 && !langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback)
|
||||||
|
{
|
||||||
LOG(("AyuGram Language pack not found! Fallback to main language: %1...").arg(langPackBaseId));
|
LOG(("AyuGram Language pack not found! Fallback to main language: %1...").arg(langPackBaseId));
|
||||||
needFallback = true;
|
needFallback = true;
|
||||||
_chkReply->disconnect();
|
_chkReply->disconnect();
|
||||||
fetchCustomLangPack("", langPackBaseId);
|
fetchCustomLangPack("", langPackBaseId);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
QByteArray result = _chkReply->readAll().trimmed();
|
QByteArray result = _chkReply->readAll().trimmed();
|
||||||
QJsonParseError error{};
|
QJsonParseError error{};
|
||||||
QJsonDocument str = QJsonDocument::fromJson(result, &error);
|
QJsonDocument str = QJsonDocument::fromJson(result, &error);
|
||||||
if (error.error == QJsonParseError::NoError) {
|
if (error.error == QJsonParseError::NoError)
|
||||||
|
{
|
||||||
parseLangFile(str);
|
parseLangFile(str);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG(("Incorrect JSON File. Fallback to default language: English..."));
|
LOG(("Incorrect JSON File. Fallback to default language: English..."));
|
||||||
loadDefaultLangFile();
|
loadDefaultLangFile();
|
||||||
}
|
}
|
||||||
|
@ -82,19 +99,24 @@ void CustomLangPack::fetchFinished() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomLangPack::fetchError(QNetworkReply::NetworkError e) {
|
void CustomLangPack::fetchError(QNetworkReply::NetworkError e)
|
||||||
|
{
|
||||||
LOG(("Network error: %1").arg(e));
|
LOG(("Network error: %1").arg(e));
|
||||||
|
|
||||||
if (e == QNetworkReply::NetworkError::ContentNotFoundError) {
|
if (e == QNetworkReply::NetworkError::ContentNotFoundError)
|
||||||
|
{
|
||||||
QString langPackBaseId = Lang::GetInstance().baseId();
|
QString langPackBaseId = Lang::GetInstance().baseId();
|
||||||
QString langPackId = Lang::GetInstance().id();
|
QString langPackId = Lang::GetInstance().id();
|
||||||
|
|
||||||
if (!langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback) {
|
if (!langPackId.isEmpty() && !langPackBaseId.isEmpty() && !needFallback)
|
||||||
|
{
|
||||||
LOG(("AyuGram Language pack not found! Fallback to main language: %1...").arg(langPackBaseId));
|
LOG(("AyuGram Language pack not found! Fallback to main language: %1...").arg(langPackBaseId));
|
||||||
needFallback = true;
|
needFallback = true;
|
||||||
_chkReply->disconnect();
|
_chkReply->disconnect();
|
||||||
fetchCustomLangPack("", langPackBaseId);
|
fetchCustomLangPack("", langPackBaseId);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG(("AyuGram Language pack not found! Fallback to default language: English..."));
|
LOG(("AyuGram Language pack not found! Fallback to default language: English..."));
|
||||||
loadDefaultLangFile();
|
loadDefaultLangFile();
|
||||||
_chkReply = nullptr;
|
_chkReply = nullptr;
|
||||||
|
@ -102,12 +124,15 @@ void CustomLangPack::fetchError(QNetworkReply::NetworkError e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomLangPack::loadDefaultLangFile() {
|
void CustomLangPack::loadDefaultLangFile()
|
||||||
|
{
|
||||||
QFile file(":/localization/en.json");
|
QFile file(":/localization/en.json");
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly))
|
||||||
|
{
|
||||||
QJsonDocument str = QJsonDocument::fromJson(file.readAll());
|
QJsonDocument str = QJsonDocument::fromJson(file.readAll());
|
||||||
QJsonObject json = str.object();
|
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().applyValue(key.toUtf8(), json.value(key).toString().toUtf8());
|
||||||
}
|
}
|
||||||
Lang::GetInstance().updatePluralRules();
|
Lang::GetInstance().updatePluralRules();
|
||||||
|
@ -115,15 +140,18 @@ void CustomLangPack::loadDefaultLangFile() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CustomLangPack::parseLangFile(QJsonDocument str) {
|
void CustomLangPack::parseLangFile(QJsonDocument str)
|
||||||
|
{
|
||||||
QJsonObject json = str.object();
|
QJsonObject json = str.object();
|
||||||
for (const QString &brokenKey: json.keys()) {
|
for (const QString& brokenKey : json.keys())
|
||||||
|
{
|
||||||
auto key = qsl("ayu_") + brokenKey;
|
auto key = qsl("ayu_") + brokenKey;
|
||||||
auto val = json.value(brokenKey).toString().replace(qsl("&"), qsl("&")).toUtf8();
|
auto val = json.value(brokenKey).toString().replace(qsl("&"), qsl("&")).toUtf8();
|
||||||
|
|
||||||
Lang::GetInstance().resetValue(key.toUtf8());
|
Lang::GetInstance().resetValue(key.toUtf8());
|
||||||
Lang::GetInstance().applyValue(key.toUtf8(), val);
|
Lang::GetInstance().applyValue(key.toUtf8(), val);
|
||||||
if (key.contains("#other")) {
|
if (key.contains("#other"))
|
||||||
|
{
|
||||||
Lang::GetInstance().resetValue(key.toUtf8().replace("#other", "#few"));
|
Lang::GetInstance().resetValue(key.toUtf8().replace("#other", "#few"));
|
||||||
Lang::GetInstance().resetValue(key.toUtf8().replace("#other", "#few"));
|
Lang::GetInstance().resetValue(key.toUtf8().replace("#other", "#few"));
|
||||||
Lang::GetInstance().applyValue(key.toUtf8().replace("#other", "#few"), val);
|
Lang::GetInstance().applyValue(key.toUtf8().replace("#other", "#few"), val);
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <QtXml/QDomDocument>
|
#include <QtXml/QDomDocument>
|
||||||
|
|
||||||
class CustomLangPack : public QObject {
|
class CustomLangPack : public QObject
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_DISABLE_COPY(CustomLangPack)
|
Q_DISABLE_COPY(CustomLangPack)
|
||||||
|
@ -29,7 +30,6 @@ public:
|
||||||
void parseLangFile(QJsonDocument str);
|
void parseLangFile(QJsonDocument str);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
||||||
void fetchFinished();
|
void fetchFinished();
|
||||||
|
|
||||||
void fetchError(QNetworkReply::NetworkError e);
|
void fetchError(QNetworkReply::NetworkError e);
|
||||||
|
@ -37,7 +37,7 @@ public Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
CustomLangPack();
|
CustomLangPack();
|
||||||
|
|
||||||
~CustomLangPack() = default;
|
~CustomLangPack() override = default;
|
||||||
|
|
||||||
QNetworkAccessManager networkManager;
|
QNetworkAccessManager networkManager;
|
||||||
QNetworkReply* _chkReply = nullptr;
|
QNetworkReply* _chkReply = nullptr;
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
namespace AyuSettings {
|
namespace AyuSettings
|
||||||
|
{
|
||||||
const QString filename = "tdata/ayu_settings.json";
|
const QString filename = "tdata/ayu_settings.json";
|
||||||
std::optional<AyuGramSettings> settings = std::nullopt;
|
std::optional<AyuGramSettings> settings = std::nullopt;
|
||||||
|
|
||||||
|
@ -29,43 +30,55 @@ namespace AyuSettings {
|
||||||
|
|
||||||
rpl::lifetime lifetime = rpl::lifetime();
|
rpl::lifetime lifetime = rpl::lifetime();
|
||||||
|
|
||||||
bool ghostModeEnabled_util(AyuGramSettings &settingsUtil) {
|
bool ghostModeEnabled_util(AyuGramSettings& settingsUtil)
|
||||||
|
{
|
||||||
return (!settingsUtil.sendReadPackets
|
return (!settingsUtil.sendReadPackets
|
||||||
&& !settingsUtil.sendOnlinePackets
|
&& !settingsUtil.sendOnlinePackets
|
||||||
&& !settingsUtil.sendUploadProgress
|
&& !settingsUtil.sendUploadProgress
|
||||||
&& settingsUtil.sendOfflinePacketAfterOnline);
|
&& settingsUtil.sendOfflinePacketAfterOnline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize() {
|
void initialize()
|
||||||
if (settings.has_value()) {
|
{
|
||||||
|
if (settings.has_value())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
settings = AyuGramSettings();
|
settings = AyuGramSettings();
|
||||||
|
|
||||||
sendReadPacketsReactive.value() | rpl::filter([=](bool val) {
|
sendReadPacketsReactive.value() | rpl::filter([=](bool val)
|
||||||
|
{
|
||||||
return (val != settings->sendReadPackets);
|
return (val != settings->sendReadPackets);
|
||||||
}) | rpl::start_with_next([=](bool val) {
|
}) | start_with_next([=](bool val)
|
||||||
|
{
|
||||||
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
sendOnlinePacketsReactive.value() | rpl::filter([=](bool val) {
|
sendOnlinePacketsReactive.value() | rpl::filter([=](bool val)
|
||||||
|
{
|
||||||
return (val != settings->sendOnlinePackets);
|
return (val != settings->sendOnlinePackets);
|
||||||
}) | rpl::start_with_next([=](bool val) {
|
}) | start_with_next([=](bool val)
|
||||||
|
{
|
||||||
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
sendUploadProgressReactive.value() | rpl::filter([=](bool val) {
|
sendUploadProgressReactive.value() | rpl::filter([=](bool val)
|
||||||
|
{
|
||||||
return (val != settings->sendUploadProgress);
|
return (val != settings->sendUploadProgress);
|
||||||
}) | rpl::start_with_next([=](bool val) {
|
}) | start_with_next([=](bool val)
|
||||||
|
{
|
||||||
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
sendOfflinePacketAfterOnlineReactive.value() | rpl::filter([=](bool val) {
|
sendOfflinePacketAfterOnlineReactive.value() | rpl::filter([=](bool val)
|
||||||
|
{
|
||||||
return (val != settings->sendOfflinePacketAfterOnline);
|
return (val != settings->sendOfflinePacketAfterOnline);
|
||||||
}) | rpl::start_with_next([=](bool val) {
|
}) | start_with_next([=](bool val)
|
||||||
|
{
|
||||||
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void postinitialize() {
|
void postinitialize()
|
||||||
|
{
|
||||||
sendReadPacketsReactive = settings->sendReadPackets;
|
sendReadPacketsReactive = settings->sendReadPackets;
|
||||||
sendOnlinePacketsReactive = settings->sendOnlinePackets;
|
sendOnlinePacketsReactive = settings->sendOnlinePackets;
|
||||||
|
|
||||||
|
@ -76,14 +89,17 @@ namespace AyuSettings {
|
||||||
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
ghostModeEnabled = ghostModeEnabled_util(settings.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
AyuGramSettings &getInstance() {
|
AyuGramSettings& getInstance()
|
||||||
|
{
|
||||||
initialize();
|
initialize();
|
||||||
return settings.value();
|
return settings.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void load() {
|
void load()
|
||||||
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.exists()) {
|
if (!file.exists())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
file.open(QIODevice::ReadOnly);
|
file.open(QIODevice::ReadOnly);
|
||||||
|
@ -92,11 +108,12 @@ namespace AyuSettings {
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
json p = json::parse(data);
|
json p = json::parse(data);
|
||||||
settings = p.template get<AyuGramSettings>();
|
settings = p.get<AyuGramSettings>();
|
||||||
postinitialize();
|
postinitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void save() {
|
void save()
|
||||||
|
{
|
||||||
initialize();
|
initialize();
|
||||||
|
|
||||||
json p = settings.value();
|
json p = settings.value();
|
||||||
|
@ -109,102 +126,125 @@ namespace AyuSettings {
|
||||||
postinitialize();
|
postinitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_sendReadPackets(bool val) {
|
void AyuGramSettings::set_sendReadPackets(bool val)
|
||||||
|
{
|
||||||
sendReadPackets = val;
|
sendReadPackets = val;
|
||||||
sendReadPacketsReactive = val;
|
sendReadPacketsReactive = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_sendOnlinePackets(bool val) {
|
void AyuGramSettings::set_sendOnlinePackets(bool val)
|
||||||
|
{
|
||||||
sendOnlinePackets = val;
|
sendOnlinePackets = val;
|
||||||
sendOnlinePacketsReactive = val;
|
sendOnlinePacketsReactive = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_sendUploadProgress(bool val) {
|
void AyuGramSettings::set_sendUploadProgress(bool val)
|
||||||
|
{
|
||||||
sendUploadProgress = val;
|
sendUploadProgress = val;
|
||||||
sendUploadProgressReactive = val;
|
sendUploadProgressReactive = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_sendOfflinePacketAfterOnline(bool val) {
|
void AyuGramSettings::set_sendOfflinePacketAfterOnline(bool val)
|
||||||
|
{
|
||||||
sendOfflinePacketAfterOnline = val;
|
sendOfflinePacketAfterOnline = val;
|
||||||
sendOfflinePacketAfterOnlineReactive = val;
|
sendOfflinePacketAfterOnlineReactive = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_markReadAfterSend(bool val) {
|
void AyuGramSettings::set_markReadAfterSend(bool val)
|
||||||
|
{
|
||||||
markReadAfterSend = val;
|
markReadAfterSend = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_useScheduledMessages(bool val) {
|
void AyuGramSettings::set_useScheduledMessages(bool val)
|
||||||
|
{
|
||||||
useScheduledMessages = val;
|
useScheduledMessages = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_keepDeletedMessages(bool val) {
|
void AyuGramSettings::set_keepDeletedMessages(bool val)
|
||||||
|
{
|
||||||
keepDeletedMessages = val;
|
keepDeletedMessages = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_keepMessagesHistory(bool val) {
|
void AyuGramSettings::set_keepMessagesHistory(bool val)
|
||||||
|
{
|
||||||
keepMessagesHistory = val;
|
keepMessagesHistory = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_enableAds(bool val) {
|
void AyuGramSettings::set_enableAds(bool val)
|
||||||
|
{
|
||||||
enableAds = val;
|
enableAds = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_deletedMark(QString val) {
|
void AyuGramSettings::set_deletedMark(QString val)
|
||||||
|
{
|
||||||
deletedMark = std::move(val);
|
deletedMark = std::move(val);
|
||||||
deletedMarkReactive = deletedMark;
|
deletedMarkReactive = deletedMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_editedMark(QString val) {
|
void AyuGramSettings::set_editedMark(QString val)
|
||||||
|
{
|
||||||
editedMark = std::move(val);
|
editedMark = std::move(val);
|
||||||
editedMarkReactive = editedMark;
|
editedMarkReactive = editedMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_recentStickersCount(int val) {
|
void AyuGramSettings::set_recentStickersCount(int val)
|
||||||
|
{
|
||||||
recentStickersCount = val;
|
recentStickersCount = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_showGhostToggleInDrawer(bool val) {
|
void AyuGramSettings::set_showGhostToggleInDrawer(bool val)
|
||||||
|
{
|
||||||
showGhostToggleInDrawer = val;
|
showGhostToggleInDrawer = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_showPeerId(int val) {
|
void AyuGramSettings::set_showPeerId(int val)
|
||||||
|
{
|
||||||
showPeerId = val;
|
showPeerId = val;
|
||||||
showPeerIdReactive = val;
|
showPeerIdReactive = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_showMessageSeconds(bool val) {
|
void AyuGramSettings::set_showMessageSeconds(bool val)
|
||||||
|
{
|
||||||
showMessageSeconds = val;
|
showMessageSeconds = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_stickerConfirmation(bool val) {
|
void AyuGramSettings::set_stickerConfirmation(bool val)
|
||||||
|
{
|
||||||
stickerConfirmation = val;
|
stickerConfirmation = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_GIFConfirmation(bool val) {
|
void AyuGramSettings::set_GIFConfirmation(bool val)
|
||||||
|
{
|
||||||
GIFConfirmation = val;
|
GIFConfirmation = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_voiceConfirmation(bool val) {
|
void AyuGramSettings::set_voiceConfirmation(bool val)
|
||||||
|
{
|
||||||
voiceConfirmation = val;
|
voiceConfirmation = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_ghostModeEnabled() {
|
bool get_ghostModeEnabled()
|
||||||
|
{
|
||||||
return ghostModeEnabled.current();
|
return ghostModeEnabled.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> get_deletedMarkReactive() {
|
rpl::producer<QString> get_deletedMarkReactive()
|
||||||
|
{
|
||||||
return deletedMarkReactive.value();
|
return deletedMarkReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> get_editedMarkReactive() {
|
rpl::producer<QString> get_editedMarkReactive()
|
||||||
|
{
|
||||||
return editedMarkReactive.value();
|
return editedMarkReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<int> get_showPeerIdReactive() {
|
rpl::producer<int> get_showPeerIdReactive()
|
||||||
|
{
|
||||||
return showPeerIdReactive.value();
|
return showPeerIdReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<bool> get_ghostModeEnabledReactive() {
|
rpl::producer<bool> get_ghostModeEnabledReactive()
|
||||||
|
{
|
||||||
return ghostModeEnabled.value();
|
return ghostModeEnabled.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,18 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "rpl/producer.h"
|
|
||||||
#include "lang_auto.h"
|
#include "lang_auto.h"
|
||||||
#include "ayu/libs/json.hpp"
|
#include "ayu/libs/json.hpp"
|
||||||
#include "ayu/libs/json_ext.hpp"
|
#include "ayu/libs/json_ext.hpp"
|
||||||
|
#include "rpl/producer.h"
|
||||||
|
|
||||||
namespace AyuSettings {
|
namespace AyuSettings
|
||||||
class AyuGramSettings {
|
{
|
||||||
|
class AyuGramSettings
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
AyuGramSettings() {
|
AyuGramSettings()
|
||||||
|
{
|
||||||
// ~ Ghost essentials
|
// ~ Ghost essentials
|
||||||
sendReadPackets = true;
|
sendReadPackets = true;
|
||||||
sendOnlinePackets = true;
|
sendOnlinePackets = true;
|
||||||
|
|
|
@ -7,13 +7,16 @@
|
||||||
|
|
||||||
#include "ayu_state.h"
|
#include "ayu_state.h"
|
||||||
|
|
||||||
namespace AyuState {
|
namespace AyuState
|
||||||
void setAllowSendReadPacket(bool val, int resetAfter) {
|
{
|
||||||
|
void setAllowSendReadPacket(bool val, int resetAfter)
|
||||||
|
{
|
||||||
allowSendReadPacket.val = val;
|
allowSendReadPacket.val = val;
|
||||||
allowSendReadPacket.resetAfter = resetAfter;
|
allowSendReadPacket.resetAfter = resetAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getAllowSendPacket() {
|
bool getAllowSendPacket()
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
return settings->sendReadPackets || processVariable(allowSendReadPacket);
|
return settings->sendReadPackets || processVariable(allowSendReadPacket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
|
|
||||||
#include "ayu_settings.h"
|
#include "ayu_settings.h"
|
||||||
|
|
||||||
namespace AyuState {
|
namespace AyuState
|
||||||
namespace {
|
{
|
||||||
class AyuStateVariable {
|
namespace
|
||||||
|
{
|
||||||
|
class AyuStateVariable
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
bool val;
|
bool val;
|
||||||
int resetAfter;
|
int resetAfter;
|
||||||
|
@ -19,15 +22,18 @@ namespace AyuState {
|
||||||
|
|
||||||
AyuStateVariable allowSendReadPacket;
|
AyuStateVariable allowSendReadPacket;
|
||||||
|
|
||||||
bool processVariable(AyuStateVariable &variable) {
|
bool processVariable(AyuStateVariable& variable)
|
||||||
if (variable.resetAfter == -1) {
|
{
|
||||||
|
if (variable.resetAfter == -1)
|
||||||
|
{
|
||||||
return variable.val;
|
return variable.val;
|
||||||
}
|
}
|
||||||
|
|
||||||
variable.resetAfter -= 1;
|
variable.resetAfter -= 1;
|
||||||
auto val = variable.val;
|
auto val = variable.val;
|
||||||
|
|
||||||
if (variable.resetAfter == 0) {
|
if (variable.resetAfter == 0)
|
||||||
|
{
|
||||||
variable.val = false;
|
variable.val = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ auto storage = make_storage("ayugram.db",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
namespace AyuDatabase {
|
namespace AyuDatabase
|
||||||
|
{
|
||||||
void addEditedMessage(
|
void addEditedMessage(
|
||||||
long userId,
|
long userId,
|
||||||
long dialogId,
|
long dialogId,
|
||||||
|
@ -35,8 +36,8 @@ namespace AyuDatabase {
|
||||||
const QString& text,
|
const QString& text,
|
||||||
bool isDocument,
|
bool isDocument,
|
||||||
QString path,
|
QString path,
|
||||||
long date) {
|
long date)
|
||||||
|
{
|
||||||
EditedMessage entity;
|
EditedMessage entity;
|
||||||
entity.userId = userId;
|
entity.userId = userId;
|
||||||
entity.dialogId = dialogId;
|
entity.dialogId = dialogId;
|
||||||
|
@ -57,8 +58,8 @@ namespace AyuDatabase {
|
||||||
long userId,
|
long userId,
|
||||||
long dialogId,
|
long dialogId,
|
||||||
long messageId
|
long messageId
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
return storage.get_all<EditedMessage>(
|
return storage.get_all<EditedMessage>(
|
||||||
where(
|
where(
|
||||||
c(&EditedMessage::userId) == userId and
|
c(&EditedMessage::userId) == userId and
|
||||||
|
@ -67,16 +68,18 @@ namespace AyuDatabase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<EditedMessage> getEditedMessages(HistoryItem *item) {
|
std::vector<EditedMessage> getEditedMessages(HistoryItem* item)
|
||||||
|
{
|
||||||
auto userId = item->displayFrom()->id.value;
|
auto userId = item->displayFrom()->id.value;
|
||||||
auto dialogId = item->history()->peer->id.value;
|
auto dialogId = item->history()->peer->id.value;
|
||||||
auto msgId = item->id.bare;
|
auto msgId = item->id.bare;
|
||||||
// auto some = &item->history()->session().account();
|
// auto some = &item->history()->session().account();
|
||||||
|
|
||||||
return getEditedMessages((long) userId, (long) dialogId, (long) msgId);
|
return getEditedMessages(static_cast<long>(userId), static_cast<long>(dialogId), static_cast<long>(msgId));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool editedMessagesTableExists() {
|
bool editedMessagesTableExists()
|
||||||
|
{
|
||||||
return storage.table_exists("editedmessage");
|
return storage.table_exists("editedmessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "entities.h"
|
#include "entities.h"
|
||||||
#include "history/history_item.h"
|
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
#include "history/history_item.h"
|
||||||
|
|
||||||
namespace AyuDatabase {
|
namespace AyuDatabase
|
||||||
|
{
|
||||||
void addEditedMessage(
|
void addEditedMessage(
|
||||||
long userId,
|
long userId,
|
||||||
long dialogId,
|
long dialogId,
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// https://github.com/AyuGram/AyuGram4A/blob/main/TMessagesProj/src/main/java/com/radolyn/ayugram/database/entities/EditedMessage.java
|
// https://github.com/AyuGram/AyuGram4A/blob/main/TMessagesProj/src/main/java/com/radolyn/ayugram/database/entities/EditedMessage.java
|
||||||
class EditedMessage {
|
class EditedMessage
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
long userId;
|
long userId;
|
||||||
long dialogId;
|
long dialogId;
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
|
|
||||||
inline void to_json(nlohmann::json &j, const QString &q) {
|
inline void to_json(nlohmann::json& j, const QString& q)
|
||||||
|
{
|
||||||
j = nlohmann::json(q.toStdString());
|
j = nlohmann::json(q.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void from_json(const nlohmann::json &j, QString &q) {
|
inline void from_json(const nlohmann::json& j, QString& q)
|
||||||
|
{
|
||||||
q = QString::fromStdString(j.get<std::string>());
|
q = QString::fromStdString(j.get<std::string>());
|
||||||
}
|
}
|
|
@ -7,46 +7,55 @@
|
||||||
|
|
||||||
#include "ayu_sync_controller.h"
|
#include "ayu_sync_controller.h"
|
||||||
#include "ayu/libs/process.hpp"
|
#include "ayu/libs/process.hpp"
|
||||||
#include "ayu/sync/utils/process_utils.hpp"
|
|
||||||
#include "ayu/sync/models.h"
|
#include "ayu/sync/models.h"
|
||||||
|
#include "ayu/sync/utils/process_utils.hpp"
|
||||||
|
#include "ayu/sync/utils/telegram_helpers.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "ayu/sync/utils/telegram_helpers.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace AyuSync {
|
namespace AyuSync
|
||||||
|
{
|
||||||
std::optional<ayu_sync_controller> controller = std::nullopt;
|
std::optional<ayu_sync_controller> controller = std::nullopt;
|
||||||
|
|
||||||
bool isAgentDownloaded() {
|
bool isAgentDownloaded()
|
||||||
|
{
|
||||||
return std::filesystem::exists(AgentPath);
|
return std::filesystem::exists(AgentPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAgentRunning() {
|
bool isAgentRunning()
|
||||||
|
{
|
||||||
return is_process_running(AgentFilename);
|
return is_process_running(AgentFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize() {
|
void initialize()
|
||||||
if (controller.has_value()) {
|
{
|
||||||
|
if (controller.has_value())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
controller = ayu_sync_controller();
|
controller = ayu_sync_controller();
|
||||||
}
|
}
|
||||||
|
|
||||||
ayu_sync_controller &getControllerInstance() {
|
ayu_sync_controller& getControllerInstance()
|
||||||
|
{
|
||||||
initialize();
|
initialize();
|
||||||
return controller.value();
|
return controller.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ayu_sync_controller::initializeAgent() {
|
void ayu_sync_controller::initializeAgent()
|
||||||
if (!isAgentDownloaded()) {
|
{
|
||||||
|
if (!isAgentDownloaded())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAgentRunning()) {
|
if (!isAgentRunning())
|
||||||
|
{
|
||||||
auto configPath = std::filesystem::absolute("./tdata/sync_preferences.json");
|
auto configPath = std::filesystem::absolute("./tdata/sync_preferences.json");
|
||||||
auto process = nes::process{AgentPath, {configPath.string(), ""}, nes::process_options::none};
|
auto process = nes::process{AgentPath, {configPath.string(), ""}, nes::process_options::none};
|
||||||
process.detach();
|
process.detach();
|
||||||
|
@ -56,12 +65,15 @@ namespace AyuSync {
|
||||||
receiverThread.detach();
|
receiverThread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ayu_sync_controller::receiver() {
|
void ayu_sync_controller::receiver()
|
||||||
|
{
|
||||||
pipe = std::make_unique<ayu_pipe_wrapper>();
|
pipe = std::make_unique<ayu_pipe_wrapper>();
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
auto p = pipe->receive();
|
auto p = pipe->receive();
|
||||||
if (p == std::nullopt) {
|
if (p == std::nullopt)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +84,8 @@ namespace AyuSync {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ayu_sync_controller::invokeHandler(json p) {
|
void ayu_sync_controller::invokeHandler(json p)
|
||||||
|
{
|
||||||
LOG(("Invoking handler on %1").arg(p.dump().c_str()));
|
LOG(("Invoking handler on %1").arg(p.dump().c_str()));
|
||||||
|
|
||||||
auto userId = p["userId"].get<long>();
|
auto userId = p["userId"].get<long>();
|
||||||
|
@ -82,34 +95,43 @@ namespace AyuSync {
|
||||||
|
|
||||||
// todo: check if account exists
|
// todo: check if account exists
|
||||||
|
|
||||||
if (type == "sync_force") {
|
if (type == "sync_force")
|
||||||
|
{
|
||||||
auto ev = p.template get<SyncForce>();
|
auto ev = p.template get<SyncForce>();
|
||||||
onSyncForce(ev);
|
onSyncForce(ev);
|
||||||
} else if (type == "sync_batch") {
|
}
|
||||||
|
else if (type == "sync_batch")
|
||||||
|
{
|
||||||
onSyncBatch(p);
|
onSyncBatch(p);
|
||||||
} else if (type == "sync_read") {
|
}
|
||||||
|
else if (type == "sync_read")
|
||||||
|
{
|
||||||
auto ev = p.template get<SyncRead>();
|
auto ev = p.template get<SyncRead>();
|
||||||
onSyncRead(ev);
|
onSyncRead(ev);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
LOG(("Unknown sync type: %1").arg(type.c_str()));
|
LOG(("Unknown sync type: %1").arg(type.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ayu_sync_controller::onSyncForce(SyncForce ev) {
|
void ayu_sync_controller::onSyncForce(SyncForce ev)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ayu_sync_controller::onSyncBatch(json ev) {
|
void ayu_sync_controller::onSyncBatch(json ev)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ayu_sync_controller::onSyncRead(SyncRead ev) {
|
void ayu_sync_controller::onSyncRead(SyncRead ev)
|
||||||
|
{
|
||||||
auto session = getSession(ev.userId);
|
auto session = getSession(ev.userId);
|
||||||
|
|
||||||
auto peer = PeerId(abs(ev.args.dialogId));
|
auto peer = PeerId(abs(ev.args.dialogId));
|
||||||
|
|
||||||
auto history = session->data().history(peer);
|
auto history = session->data().history(peer);
|
||||||
if (history) {
|
if (history)
|
||||||
|
{
|
||||||
history->inboxRead(ev.args.untilId, ev.args.unread);
|
history->inboxRead(ev.args.untilId, ev.args.unread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ayu/libs/json.hpp"
|
|
||||||
#include "models.h"
|
#include "models.h"
|
||||||
|
#include "ayu/libs/json.hpp"
|
||||||
#include "utils/ayu_pipe_wrapper.h"
|
#include "utils/ayu_pipe_wrapper.h"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
@ -22,8 +22,10 @@ const std::string AgentFilename =
|
||||||
|
|
||||||
const std::string AgentPath = "./AyuSync/" + AgentFilename;
|
const std::string AgentPath = "./AyuSync/" + AgentFilename;
|
||||||
|
|
||||||
namespace AyuSync {
|
namespace AyuSync
|
||||||
class ayu_sync_controller {
|
{
|
||||||
|
class ayu_sync_controller
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
void initializeAgent();
|
void initializeAgent();
|
||||||
|
|
||||||
|
@ -32,6 +34,7 @@ namespace AyuSync {
|
||||||
void onSyncRead(SyncRead ev);
|
void onSyncRead(SyncRead ev);
|
||||||
|
|
||||||
void invokeHandler(json p);
|
void invokeHandler(json p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void receiver();
|
void receiver();
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "ayu/libs/json.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class SyncEvent {
|
class SyncEvent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::string type = "sync_unspecified";
|
std::string type = "sync_unspecified";
|
||||||
long userId = 0;
|
long userId = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SyncBatch : public SyncEvent {
|
class SyncBatch : public SyncEvent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::string type = "sync_batch";
|
std::string type = "sync_batch";
|
||||||
long userId;
|
long userId;
|
||||||
|
|
||||||
class SyncBatchArgs {
|
class SyncBatchArgs
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::vector<SyncEvent> events;
|
std::vector<SyncEvent> events;
|
||||||
};
|
};
|
||||||
|
@ -22,12 +27,14 @@ public:
|
||||||
SyncBatchArgs args;
|
SyncBatchArgs args;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SyncRead : public SyncEvent {
|
class SyncRead : public SyncEvent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::string type = "sync_read";
|
std::string type = "sync_read";
|
||||||
long userId;
|
long userId;
|
||||||
|
|
||||||
class SyncReadArgs {
|
class SyncReadArgs
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
long dialogId;
|
long dialogId;
|
||||||
int untilId;
|
int untilId;
|
||||||
|
@ -37,12 +44,14 @@ public:
|
||||||
SyncReadArgs args;
|
SyncReadArgs args;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SyncForce : public SyncEvent {
|
class SyncForce : public SyncEvent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::string type = "sync_force";
|
std::string type = "sync_force";
|
||||||
long userId;
|
long userId;
|
||||||
|
|
||||||
class SyncForceArgs {
|
class SyncForceArgs
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
int fromDate;
|
int fromDate;
|
||||||
};
|
};
|
||||||
|
@ -50,12 +59,14 @@ public:
|
||||||
SyncForceArgs args;
|
SyncForceArgs args;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SyncForceFinish : public SyncEvent {
|
class SyncForceFinish : public SyncEvent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
std::string type = "sync_force_finish";
|
std::string type = "sync_force_finish";
|
||||||
long userId;
|
long userId;
|
||||||
|
|
||||||
class SyncForceFinishArgs {
|
class SyncForceFinishArgs
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
short dummy; // required to be JSON serializable
|
short dummy; // required to be JSON serializable
|
||||||
};
|
};
|
||||||
|
@ -73,4 +84,3 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForce::SyncForceArgs, fromDate)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForce, type, userId, args)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForce, type, userId, args)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForceFinish::SyncForceFinishArgs, dummy)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForceFinish::SyncForceFinishArgs, dummy)
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForceFinish, type, userId, args)
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SyncForceFinish, type, userId, args)
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
//
|
//
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include "ayu_pipe_wrapper.h"
|
#include "ayu_pipe_wrapper.h"
|
||||||
|
#include <sstream>
|
||||||
#include "ayu/libs/bit_converter.hpp"
|
#include "ayu/libs/bit_converter.hpp"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void ayu_pipe_wrapper::send(T obj) {
|
void ayu_pipe_wrapper::send(T obj)
|
||||||
|
{
|
||||||
// auto s = json(obj).dump();
|
// auto s = json(obj).dump();
|
||||||
// auto length = s.length();
|
// auto length = s.length();
|
||||||
// char lengthBuff[4];
|
// char lengthBuff[4];
|
||||||
|
@ -22,8 +23,10 @@ void ayu_pipe_wrapper::send(T obj) {
|
||||||
throw std::logic_error("not implemented");
|
throw std::logic_error("not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<json> ayu_pipe_wrapper::receive() {
|
std::optional<json> ayu_pipe_wrapper::receive()
|
||||||
if (!is.is_open()) {
|
{
|
||||||
|
if (!is.is_open())
|
||||||
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,15 +35,17 @@ std::optional<json> ayu_pipe_wrapper::receive() {
|
||||||
|
|
||||||
auto length = bit_converter::bytes_to_i32(lengthBuff, false);
|
auto length = bit_converter::bytes_to_i32(lengthBuff, false);
|
||||||
|
|
||||||
if (length <= 0) {
|
if (length <= 0)
|
||||||
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sb = std::stringbuf();
|
auto sb = std::stringbuf();
|
||||||
char buff[4096];
|
char buff[4096];
|
||||||
|
|
||||||
while (length > 0) {
|
while (length > 0)
|
||||||
auto readSize = std::min(length, (int) sizeof(buff));
|
{
|
||||||
|
auto readSize = std::min(length, static_cast<int>(sizeof(buff)));
|
||||||
is.read(buff, readSize);
|
is.read(buff, readSize);
|
||||||
sb.sputn(buff, readSize);
|
sb.sputn(buff, readSize);
|
||||||
length -= readSize;
|
length -= readSize;
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
class ayu_pipe_wrapper {
|
class ayu_pipe_wrapper
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
template <class T>
|
template <class T>
|
||||||
void send(T obj);
|
void send(T obj);
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
#include <algorithm>
|
||||||
|
#include <codecvt>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
|
||||||
#include <locale>
|
|
||||||
#include <codecvt>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -17,31 +17,37 @@
|
||||||
|
|
||||||
// A function to check if a process is running by its name
|
// A function to check if a process is running by its name
|
||||||
// Bing AI generated
|
// Bing AI generated
|
||||||
bool is_process_running(const std::string &name) {
|
bool is_process_running(const std::string& name)
|
||||||
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Create a snapshot of all processes
|
// Create a snapshot of all processes
|
||||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
if (snapshot == INVALID_HANDLE_VALUE) {
|
if (snapshot == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
std::cerr << "Failed to create snapshot\n";
|
std::cerr << "Failed to create snapshot\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Iterate over the processes and compare the names
|
// Iterate over the processes and compare the names
|
||||||
PROCESSENTRY32 entry;
|
PROCESSENTRY32 entry;
|
||||||
entry.dwSize = sizeof(entry);
|
entry.dwSize = sizeof(entry);
|
||||||
if (!Process32First(snapshot, &entry)) {
|
if (!Process32First(snapshot, &entry))
|
||||||
|
{
|
||||||
std::cerr << "Failed to get first process\n";
|
std::cerr << "Failed to get first process\n";
|
||||||
CloseHandle(snapshot);
|
CloseHandle(snapshot);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
std::string entry_name = converter.to_bytes(entry.szExeFile);
|
std::string entry_name = converter.to_bytes(entry.szExeFile);
|
||||||
if (name == entry_name) {
|
if (name == entry_name)
|
||||||
|
{
|
||||||
// Found a match
|
// Found a match
|
||||||
CloseHandle(snapshot);
|
CloseHandle(snapshot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} while (Process32Next(snapshot, &entry));
|
}
|
||||||
|
while (Process32Next(snapshot, &entry));
|
||||||
// No match found
|
// No match found
|
||||||
CloseHandle(snapshot);
|
CloseHandle(snapshot);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -8,10 +8,14 @@
|
||||||
#include "telegram_helpers.h"
|
#include "telegram_helpers.h"
|
||||||
#include "data/data_peer_id.h"
|
#include "data/data_peer_id.h"
|
||||||
|
|
||||||
Main::Session* getSession(long userId) {
|
Main::Session* getSession(long userId)
|
||||||
for (auto &[index, account] : Core::App().domain().accounts()) {
|
{
|
||||||
if (const auto session = account->maybeSession()) {
|
for (auto& [index, account] : Core::App().domain().accounts())
|
||||||
if (session->userId().bare == userId) {
|
{
|
||||||
|
if (const auto session = account->maybeSession())
|
||||||
|
{
|
||||||
|
if (session->userId().bare == userId)
|
||||||
|
{
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +24,8 @@ Main::Session* getSession(long userId) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerId dialogIdToPeerId(long dialogId) {
|
PeerId dialogIdToPeerId(long dialogId)
|
||||||
|
{
|
||||||
auto peerId = PeerId();
|
auto peerId = PeerId();
|
||||||
return peerId;
|
return peerId;
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_session.h"
|
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
|
||||||
Main::Session* getSession(long userId);
|
Main::Session* getSession(long userId);
|
||||||
|
|
|
@ -6,23 +6,26 @@
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include "confirmation_box.h"
|
#include "confirmation_box.h"
|
||||||
#include "ayu/ayu_settings.h"
|
|
||||||
#include "window/window_session_controller.h"
|
|
||||||
#include "main/main_session.h"
|
|
||||||
#include "data/data_session.h"
|
|
||||||
#include "window/window_peer_menu.h"
|
|
||||||
#include "styles/style_layers.h"
|
|
||||||
#include "lang_auto.h"
|
#include "lang_auto.h"
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "window/window_peer_menu.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
|
{
|
||||||
ConfirmationBox::ConfirmationBox(
|
ConfirmationBox::ConfirmationBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<Window::SessionController *> controller) : _controller(controller) {
|
not_null<Window::SessionController*> controller) : _controller(controller)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationBox::prepare() {
|
void ConfirmationBox::prepare()
|
||||||
|
{
|
||||||
// setTitle(rpl::single(QString("Confirmation for SRead")));
|
// setTitle(rpl::single(QString("Confirmation for SRead")));
|
||||||
auto details = TextWithEntities();
|
auto details = TextWithEntities();
|
||||||
details.text = QString("Do you want to read all messages?");
|
details.text = QString("Do you want to read all messages?");
|
||||||
|
@ -35,21 +38,24 @@ namespace AyuUi {
|
||||||
|
|
||||||
setDimensions(st::boxWidth, fullHeight);
|
setDimensions(st::boxWidth, fullHeight);
|
||||||
|
|
||||||
addButton(rpl::single(QString("Read")), [=, this] {
|
addButton(rpl::single(QString("Read")), [=, this]
|
||||||
|
{
|
||||||
ReadAllPeers();
|
ReadAllPeers();
|
||||||
closeBox();
|
closeBox();
|
||||||
});
|
});
|
||||||
addButton(tr::lng_cancel(), [=, this] { closeBox(); });
|
addButton(tr::lng_cancel(), [=, this] { closeBox(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationBox::resizeEvent(QResizeEvent *e) {
|
void ConfirmationBox::resizeEvent(QResizeEvent* e)
|
||||||
|
{
|
||||||
BoxContent::resizeEvent(e);
|
BoxContent::resizeEvent(e);
|
||||||
|
|
||||||
const auto& padding = st::boxPadding;
|
const auto& padding = st::boxPadding;
|
||||||
_text->moveToLeft(padding.left(), padding.top());
|
_text->moveToLeft(padding.left(), padding.top());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmationBox::ReadAllPeers() {
|
void ConfirmationBox::ReadAllPeers()
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
auto prev = settings->sendReadPackets;
|
auto prev = settings->sendReadPackets;
|
||||||
settings->set_sendReadPackets(true);
|
settings->set_sendReadPackets(true);
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
#include "ui/layers/box_content.h"
|
#include "ui/layers/box_content.h"
|
||||||
#include "window/window_main_menu.h"
|
#include "window/window_main_menu.h"
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
class ConfirmationBox : public Ui::BoxContent {
|
{
|
||||||
|
class ConfirmationBox : public Ui::BoxContent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
ConfirmationBox(QWidget*, not_null<Window::SessionController*> controller);
|
ConfirmationBox(QWidget*, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,21 @@
|
||||||
|
|
||||||
#include "edit_deleted_mark.h"
|
#include "edit_deleted_mark.h"
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/premium_limits_box.h"
|
#include "boxes/premium_limits_box.h"
|
||||||
|
#include "data/data_cloud_file.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/style_widgets.h"
|
||||||
|
#include "ui/ui_utility.h"
|
||||||
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/fields/special_fields.h"
|
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/widgets/fields/special_fields.h"
|
||||||
#include "ui/ui_utility.h"
|
|
||||||
#include "data/data_cloud_file.h"
|
|
||||||
#include "main/main_session.h"
|
|
||||||
#include "styles/style_layers.h"
|
|
||||||
#include "styles/style_boxes.h"
|
|
||||||
#include "styles/style_widgets.h"
|
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
@ -33,10 +33,12 @@ EditDeletedMarkBox::EditDeletedMarkBox(QWidget *) :
|
||||||
this,
|
this,
|
||||||
st::defaultInputField,
|
st::defaultInputField,
|
||||||
rpl::single(QString("Deleted Mark")),
|
rpl::single(QString("Deleted Mark")),
|
||||||
AyuSettings::getInstance().deletedMark) {
|
AyuSettings::getInstance().deletedMark)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditDeletedMarkBox::prepare() {
|
void EditDeletedMarkBox::prepare()
|
||||||
|
{
|
||||||
const auto defaultDeletedMark = "🧹";
|
const auto defaultDeletedMark = "🧹";
|
||||||
auto newHeight = st::contactPadding.top() + _text->height();
|
auto newHeight = st::contactPadding.top() + _text->height();
|
||||||
|
|
||||||
|
@ -53,20 +55,26 @@ void EditDeletedMarkBox::prepare() {
|
||||||
connect(_text, &Ui::InputField::submitted, [=] { submit(); });
|
connect(_text, &Ui::InputField::submitted, [=] { submit(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditDeletedMarkBox::setInnerFocus() {
|
void EditDeletedMarkBox::setInnerFocus()
|
||||||
|
{
|
||||||
_text->setFocusFast();
|
_text->setFocusFast();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditDeletedMarkBox::submit() {
|
void EditDeletedMarkBox::submit()
|
||||||
if (_text->getLastText().trimmed().isEmpty()) {
|
{
|
||||||
|
if (_text->getLastText().trimmed().isEmpty())
|
||||||
|
{
|
||||||
_text->setFocus();
|
_text->setFocus();
|
||||||
_text->showError();
|
_text->showError();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditDeletedMarkBox::resizeEvent(QResizeEvent *e) {
|
void EditDeletedMarkBox::resizeEvent(QResizeEvent* e)
|
||||||
|
{
|
||||||
BoxContent::resizeEvent(e);
|
BoxContent::resizeEvent(e);
|
||||||
|
|
||||||
_text->resize(
|
_text->resize(
|
||||||
|
@ -80,7 +88,8 @@ void EditDeletedMarkBox::resizeEvent(QResizeEvent *e) {
|
||||||
_text->moveToLeft(left, st::contactPadding.top());
|
_text->moveToLeft(left, st::contactPadding.top());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditDeletedMarkBox::save() {
|
void EditDeletedMarkBox::save()
|
||||||
|
{
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
settings->set_deletedMark(_text->getLastText());
|
settings->set_deletedMark(_text->getLastText());
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
#include "boxes/abstract_box.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
|
||||||
class EditDeletedMarkBox : public Ui::BoxContent {
|
class EditDeletedMarkBox : public Ui::BoxContent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
EditDeletedMarkBox(QWidget*);
|
EditDeletedMarkBox(QWidget*);
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,21 @@
|
||||||
|
|
||||||
#include "edit_edited_mark.h"
|
#include "edit_edited_mark.h"
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
|
||||||
#include "base/random.h"
|
#include "base/random.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/premium_limits_box.h"
|
#include "boxes/premium_limits_box.h"
|
||||||
|
#include "data/data_cloud_file.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "styles/style_boxes.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/style_widgets.h"
|
||||||
|
#include "ui/ui_utility.h"
|
||||||
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/fields/special_fields.h"
|
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/widgets/fields/special_fields.h"
|
||||||
#include "ui/ui_utility.h"
|
|
||||||
#include "data/data_cloud_file.h"
|
|
||||||
#include "main/main_session.h"
|
|
||||||
#include "styles/style_layers.h"
|
|
||||||
#include "styles/style_boxes.h"
|
|
||||||
#include "styles/style_widgets.h"
|
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
@ -33,12 +33,13 @@ EditEditedMarkBox::EditEditedMarkBox(QWidget *) :
|
||||||
this,
|
this,
|
||||||
st::defaultInputField,
|
st::defaultInputField,
|
||||||
rpl::single(QString("Edited mark")),
|
rpl::single(QString("Edited mark")),
|
||||||
AyuSettings::getInstance().editedMark) {
|
AyuSettings::getInstance().editedMark)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditEditedMarkBox::prepare() {
|
void EditEditedMarkBox::prepare()
|
||||||
|
{
|
||||||
const auto defaultEditedMark = tr::lng_edited(tr::now);
|
const auto defaultEditedMark = tr::lng_edited(tr::now);
|
||||||
auto newHeight = st::contactPadding.top() + _text->height();
|
auto newHeight = st::contactPadding.top() + _text->height();
|
||||||
|
|
||||||
|
@ -55,20 +56,26 @@ void EditEditedMarkBox::prepare() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditEditedMarkBox::setInnerFocus() {
|
void EditEditedMarkBox::setInnerFocus()
|
||||||
|
{
|
||||||
_text->setFocusFast();
|
_text->setFocusFast();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEditedMarkBox::submit() {
|
void EditEditedMarkBox::submit()
|
||||||
if (_text->getLastText().trimmed().isEmpty()) {
|
{
|
||||||
|
if (_text->getLastText().trimmed().isEmpty())
|
||||||
|
{
|
||||||
_text->setFocus();
|
_text->setFocus();
|
||||||
_text->showError();
|
_text->showError();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEditedMarkBox::resizeEvent(QResizeEvent *e) {
|
void EditEditedMarkBox::resizeEvent(QResizeEvent* e)
|
||||||
|
{
|
||||||
BoxContent::resizeEvent(e);
|
BoxContent::resizeEvent(e);
|
||||||
|
|
||||||
_text->resize(
|
_text->resize(
|
||||||
|
@ -82,7 +89,8 @@ void EditEditedMarkBox::resizeEvent(QResizeEvent *e) {
|
||||||
_text->moveToLeft(left, st::contactPadding.top());
|
_text->moveToLeft(left, st::contactPadding.top());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditEditedMarkBox::save() {
|
void EditEditedMarkBox::save()
|
||||||
|
{
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
settings->set_editedMark(_text->getLastText());
|
settings->set_editedMark(_text->getLastText());
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
#include "boxes/abstract_box.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
|
||||||
class EditEditedMarkBox : public Ui::BoxContent {
|
class EditEditedMarkBox : public Ui::BoxContent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
EditEditedMarkBox(QWidget*);
|
EditEditedMarkBox(QWidget*);
|
||||||
|
|
||||||
|
|
|
@ -6,41 +6,54 @@
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
|
||||||
#include "ui/widgets/buttons.h"
|
|
||||||
#include "styles/style_layers.h"
|
|
||||||
#include "voice_confirmation_box.h"
|
#include "voice_confirmation_box.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
#include "ui/widgets/buttons.h"
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
|
{
|
||||||
void VoiceConfirmBox(not_null<Ui::GenericBox *> box, Ui::ConfirmBoxArgs &&args) {
|
void VoiceConfirmBox(not_null<Ui::GenericBox*> box, Ui::ConfirmBoxArgs&& args)
|
||||||
const auto weak = Ui::MakeWeak(box);
|
{
|
||||||
|
const auto weak = MakeWeak(box);
|
||||||
const auto lifetime = box->lifetime().make_state<rpl::lifetime>();
|
const auto lifetime = box->lifetime().make_state<rpl::lifetime>();
|
||||||
|
|
||||||
v::match(args.text, [](v::null_t) {
|
v::match(args.text, [](v::null_t)
|
||||||
}, [&](auto &&) {
|
{
|
||||||
|
}, [&](auto&&)
|
||||||
|
{
|
||||||
const auto label = box->addRow(
|
const auto label = box->addRow(
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
box.get(),
|
box.get(),
|
||||||
v::text::take_marked(std::move(args.text)),
|
v::text::take_marked(std::move(args.text)),
|
||||||
args.labelStyle ? *args.labelStyle : st::boxLabel),
|
args.labelStyle ? *args.labelStyle : st::boxLabel),
|
||||||
st::boxPadding);
|
st::boxPadding);
|
||||||
if (args.labelFilter) {
|
if (args.labelFilter)
|
||||||
|
{
|
||||||
label->setClickHandlerFilter(std::move(args.labelFilter));
|
label->setClickHandlerFilter(std::move(args.labelFilter));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto prepareCallback = [&](Ui::ConfirmBoxArgs::Callback &callback) {
|
const auto prepareCallback = [&](Ui::ConfirmBoxArgs::Callback& callback)
|
||||||
return [=, confirmed = std::move(callback)]() {
|
{
|
||||||
if (const auto callbackPtr = std::get_if<1>(&confirmed)) {
|
return [=, confirmed = std::move(callback)]()
|
||||||
if (auto callback = (*callbackPtr)) {
|
{
|
||||||
|
if (const auto callbackPtr = std::get_if<1>(&confirmed))
|
||||||
|
{
|
||||||
|
if (auto callback = (*callbackPtr))
|
||||||
|
{
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
} else if (const auto callbackPtr = std::get_if<2>(&confirmed)) {
|
}
|
||||||
if (auto callback = (*callbackPtr)) {
|
else if (const auto callbackPtr = std::get_if<2>(&confirmed))
|
||||||
|
{
|
||||||
|
if (auto callback = (*callbackPtr))
|
||||||
|
{
|
||||||
callback(crl::guard(weak, [=] { weak->closeBox(); }));
|
callback(crl::guard(weak, [=] { weak->closeBox(); }));
|
||||||
}
|
}
|
||||||
} else if (weak) {
|
}
|
||||||
|
else if (weak)
|
||||||
|
{
|
||||||
weak->closeBox();
|
weak->closeBox();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -50,7 +63,8 @@ namespace AyuUi {
|
||||||
|
|
||||||
const auto confirmButton = box->addButton(
|
const auto confirmButton = box->addButton(
|
||||||
v::text::take_plain(std::move(args.confirmText), tr::lng_box_ok()),
|
v::text::take_plain(std::move(args.confirmText), tr::lng_box_ok()),
|
||||||
[=, c = prepareCallback(args.confirmed)]() {
|
[=, c = prepareCallback(args.confirmed)]()
|
||||||
|
{
|
||||||
lifetime->destroy();
|
lifetime->destroy();
|
||||||
c();
|
c();
|
||||||
|
|
||||||
|
@ -58,45 +72,53 @@ namespace AyuUi {
|
||||||
},
|
},
|
||||||
args.confirmStyle ? *args.confirmStyle : defaultButtonStyle);
|
args.confirmStyle ? *args.confirmStyle : defaultButtonStyle);
|
||||||
box->events(
|
box->events(
|
||||||
) | rpl::start_with_next([=](not_null<QEvent *> e) {
|
) | start_with_next([=](not_null<QEvent*> e)
|
||||||
if ((e->type() != QEvent::KeyPress) || !confirmButton) {
|
{
|
||||||
|
if ((e->type() != QEvent::KeyPress) || !confirmButton)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto k = static_cast<QKeyEvent*>(e.get());
|
const auto k = static_cast<QKeyEvent*>(e.get());
|
||||||
if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return) {
|
if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return)
|
||||||
|
{
|
||||||
confirmButton->clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
confirmButton->clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
||||||
}
|
}
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
|
||||||
if (!args.inform) {
|
if (!args.inform)
|
||||||
|
{
|
||||||
const auto cancelButton = box->addButton(
|
const auto cancelButton = box->addButton(
|
||||||
v::text::take_plain(std::move(args.cancelText), tr::lng_cancel()),
|
v::text::take_plain(std::move(args.cancelText), tr::lng_cancel()),
|
||||||
crl::guard(weak, [=, c = prepareCallback(args.cancelled)]() {
|
crl::guard(weak, [=, c = prepareCallback(args.cancelled)]()
|
||||||
|
{
|
||||||
lifetime->destroy();
|
lifetime->destroy();
|
||||||
c();
|
c();
|
||||||
}),
|
}),
|
||||||
args.cancelStyle ? *args.cancelStyle : defaultButtonStyle);
|
args.cancelStyle ? *args.cancelStyle : defaultButtonStyle);
|
||||||
|
|
||||||
box->boxClosing(
|
box->boxClosing(
|
||||||
) | rpl::start_with_next(crl::guard(cancelButton, [=] {
|
) | start_with_next(crl::guard(cancelButton, [=]
|
||||||
|
{
|
||||||
cancelButton->clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
cancelButton->clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
||||||
}), *lifetime);
|
}), *lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.strictCancel) {
|
if (args.strictCancel)
|
||||||
|
{
|
||||||
lifetime->destroy();
|
lifetime->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::GenericBox> MakeConfirmBox(Ui::ConfirmBoxArgs &&args) {
|
object_ptr<Ui::GenericBox> MakeConfirmBox(Ui::ConfirmBoxArgs&& args)
|
||||||
|
{
|
||||||
return Box(VoiceConfirmBox, std::move(args));
|
return Box(VoiceConfirmBox, std::move(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text) {
|
object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text)
|
||||||
|
{
|
||||||
return MakeConfirmBox({
|
return MakeConfirmBox({
|
||||||
.text = std::move(text),
|
.text = std::move(text),
|
||||||
.inform = true,
|
.inform = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace AyuUi
|
} // namespace AyuUi
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/text/text_variant.h"
|
#include "ui/text/text_variant.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
|
{
|
||||||
void VoiceConfirmBox(not_null<Ui::GenericBox*> box, Ui::ConfirmBoxArgs&& args);
|
void VoiceConfirmBox(not_null<Ui::GenericBox*> box, Ui::ConfirmBoxArgs&& args);
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::GenericBox> MakeConfirmBox(
|
[[nodiscard]] object_ptr<Ui::GenericBox> MakeConfirmBox(
|
||||||
Ui::ConfirmBoxArgs&& args);
|
Ui::ConfirmBoxArgs&& args);
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text);
|
[[nodiscard]] object_ptr<Ui::GenericBox> MakeInformBox(v::text::data text);
|
||||||
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
|
@ -6,34 +6,41 @@
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include "context_menu.h"
|
#include "context_menu.h"
|
||||||
#include "history/history_inner_widget.h"
|
|
||||||
#include "lang_auto.h"
|
#include "lang_auto.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
|
||||||
#include "base/unixtime.h"
|
|
||||||
#include "styles/style_chat.h"
|
|
||||||
#include "settings/settings_common.h"
|
|
||||||
#include "message_history_box.h"
|
#include "message_history_box.h"
|
||||||
#include "ayu/database/ayu_database.h"
|
|
||||||
#include "ayu/ayu_state.h"
|
#include "ayu/ayu_state.h"
|
||||||
|
#include "ayu/database/ayu_database.h"
|
||||||
|
#include "base/unixtime.h"
|
||||||
|
#include "history/history_inner_widget.h"
|
||||||
|
#include "settings/settings_common.h"
|
||||||
|
#include "styles/style_chat.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
AyuPopupMenu::AyuPopupMenu(HistoryInner *parent) {
|
{
|
||||||
|
AyuPopupMenu::AyuPopupMenu(HistoryInner* parent)
|
||||||
|
{
|
||||||
_ayuSubMenu = std::make_unique<Ui::PopupMenu>(parent, st::popupMenuWithIcons);
|
_ayuSubMenu = std::make_unique<Ui::PopupMenu>(parent, st::popupMenuWithIcons);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuPopupMenu::addHistoryAction(HistoryItem *item) {
|
void AyuPopupMenu::addHistoryAction(HistoryItem* item)
|
||||||
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty())) {
|
{
|
||||||
_ayuSubMenu->addAction(tr::ayu_EditsHistoryMenuText(tr::now), [=] {
|
if (AyuDatabase::editedMessagesTableExists() && !((AyuDatabase::getEditedMessages(item)).empty()))
|
||||||
|
{
|
||||||
|
_ayuSubMenu->addAction(tr::ayu_EditsHistoryMenuText(tr::now), [=]
|
||||||
|
{
|
||||||
auto box = Box<MessageHistoryBox>(item);
|
auto box = Box<MessageHistoryBox>(item);
|
||||||
Ui::show(std::move(box));
|
show(std::move(box));
|
||||||
}, &st::menuIconInfo);
|
}, &st::menuIconInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuPopupMenu::addHideMessageAction(HistoryItem *item) const {
|
void AyuPopupMenu::addHideMessageAction(HistoryItem* item) const
|
||||||
|
{
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
_ayuSubMenu->addAction(QString("Hide"), [=]() {
|
_ayuSubMenu->addAction(QString("Hide"), [=]()
|
||||||
|
{
|
||||||
const auto initKeepDeleted = settings->keepDeletedMessages;
|
const auto initKeepDeleted = settings->keepDeletedMessages;
|
||||||
|
|
||||||
settings->set_keepDeletedMessages(false);
|
settings->set_keepDeletedMessages(false);
|
||||||
|
@ -42,9 +49,11 @@ namespace AyuUi {
|
||||||
}, &st::menuIconClear);
|
}, &st::menuIconClear);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuPopupMenu::addReadUntilAction(HistoryItem *item) const {
|
void AyuPopupMenu::addReadUntilAction(HistoryItem* item) const
|
||||||
|
{
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
_ayuSubMenu->addAction(tr::ayu_ReadUntilMenuText(tr::now), [=]() {
|
_ayuSubMenu->addAction(tr::ayu_ReadUntilMenuText(tr::now), [=]()
|
||||||
|
{
|
||||||
AyuState::setAllowSendReadPacket(true);
|
AyuState::setAllowSendReadPacket(true);
|
||||||
history->session().data().histories().readInboxOnNewMessage(item);
|
history->session().data().histories().readInboxOnNewMessage(item);
|
||||||
}, &st::menuIconShowInChat);
|
}, &st::menuIconShowInChat);
|
||||||
|
|
|
@ -7,83 +7,84 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "history/history_inner_widget.h"
|
#include "mainwindow.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "base/call_delayed.h"
|
||||||
#include "ui/image/image.h"
|
#include "base/unixtime.h"
|
||||||
#include "ui/effects/path_shift_gradient.h"
|
|
||||||
#include "ui/effects/message_sending_animation_controller.h"
|
|
||||||
#include "ui/effects/reaction_fly_animation.h"
|
|
||||||
#include "ui/text/text_options.h"
|
|
||||||
#include "ui/text/text_entity.h"
|
|
||||||
#include "ui/boxes/report_box.h"
|
|
||||||
#include "ui/layers/generic_box.h"
|
|
||||||
#include "ui/controls/delete_message_context_action.h"
|
|
||||||
#include "ui/controls/who_reacted_context_action.h"
|
|
||||||
#include "ui/painter.h"
|
|
||||||
#include "ui/ui_utility.h"
|
|
||||||
#include "ui/cached_round_corners.h"
|
|
||||||
#include "ui/inactive_press.h"
|
|
||||||
#include "window/window_adaptive.h"
|
|
||||||
#include "window/window_session_controller.h"
|
|
||||||
#include "window/window_controller.h"
|
|
||||||
#include "window/window_peer_menu.h"
|
|
||||||
#include "window/window_controller.h"
|
|
||||||
#include "window/notifications_manager.h"
|
|
||||||
#include "boxes/about_sponsored_box.h"
|
|
||||||
#include "boxes/delete_messages_box.h"
|
|
||||||
#include "boxes/report_messages_box.h"
|
|
||||||
#include "boxes/sticker_set_box.h"
|
|
||||||
#include "boxes/premium_preview_box.h"
|
|
||||||
#include "boxes/translate_box.h"
|
|
||||||
#include "chat_helpers/message_field.h"
|
|
||||||
#include "chat_helpers/emoji_interactions.h"
|
|
||||||
#include "history/history_widget.h"
|
|
||||||
#include "history/view/history_view_translate_tracker.h"
|
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/qt/qt_common_adapters.h"
|
#include "base/qt/qt_common_adapters.h"
|
||||||
#include "base/qt/qt_key_modifiers.h"
|
#include "base/qt/qt_key_modifiers.h"
|
||||||
#include "base/unixtime.h"
|
#include "boxes/about_sponsored_box.h"
|
||||||
#include "base/call_delayed.h"
|
#include "boxes/delete_messages_box.h"
|
||||||
#include "mainwindow.h"
|
#include "boxes/premium_preview_box.h"
|
||||||
|
#include "boxes/report_messages_box.h"
|
||||||
|
#include "boxes/sticker_set_box.h"
|
||||||
|
#include "boxes/translate_box.h"
|
||||||
|
#include "chat_helpers/emoji_interactions.h"
|
||||||
|
#include "chat_helpers/message_field.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_document.h"
|
||||||
|
#include "data/data_file_click_handler.h"
|
||||||
|
#include "data/data_file_origin.h"
|
||||||
|
#include "data/data_forum_topic.h"
|
||||||
|
#include "data/data_histories.h"
|
||||||
|
#include "data/data_media_types.h"
|
||||||
|
#include "data/data_message_reactions.h"
|
||||||
|
#include "data/data_peer_values.h"
|
||||||
|
#include "data/data_photo.h"
|
||||||
|
#include "data/data_photo_media.h"
|
||||||
|
#include "data/data_poll.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_sponsored_messages.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
|
#include "data/stickers/data_stickers.h"
|
||||||
|
#include "dialogs/ui/dialogs_video_userpic.h"
|
||||||
|
#include "history/history_inner_widget.h"
|
||||||
|
#include "history/history_widget.h"
|
||||||
|
#include "history/view/history_view_translate_tracker.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
#include "layout/layout_selection.h"
|
#include "layout/layout_selection.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "main/session/send_as_peers.h"
|
#include "main/session/send_as_peers.h"
|
||||||
#include "menu/menu_item_download_files.h"
|
#include "menu/menu_item_download_files.h"
|
||||||
#include "core/application.h"
|
|
||||||
#include "lang/lang_keys.h"
|
|
||||||
#include "data/data_session.h"
|
|
||||||
#include "data/data_media_types.h"
|
|
||||||
#include "data/data_message_reactions.h"
|
|
||||||
#include "data/data_document.h"
|
|
||||||
#include "data/data_channel.h"
|
|
||||||
#include "data/data_forum_topic.h"
|
|
||||||
#include "data/data_poll.h"
|
|
||||||
#include "data/data_photo.h"
|
|
||||||
#include "data/data_photo_media.h"
|
|
||||||
#include "data/data_peer_values.h"
|
|
||||||
#include "data/data_chat.h"
|
|
||||||
#include "data/data_user.h"
|
|
||||||
#include "data/data_file_click_handler.h"
|
|
||||||
#include "data/data_file_origin.h"
|
|
||||||
#include "data/data_histories.h"
|
|
||||||
#include "data/data_changes.h"
|
|
||||||
#include "data/stickers/data_stickers.h"
|
|
||||||
#include "data/data_sponsored_messages.h"
|
|
||||||
#include "dialogs/ui/dialogs_video_userpic.h"
|
|
||||||
#include "settings/settings_premium.h"
|
#include "settings/settings_premium.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_window.h" // st::windowMinWidth
|
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
#include "styles/style_window.h" // st::windowMinWidth
|
||||||
|
#include "ui/cached_round_corners.h"
|
||||||
|
#include "ui/inactive_press.h"
|
||||||
|
#include "ui/painter.h"
|
||||||
|
#include "ui/ui_utility.h"
|
||||||
|
#include "ui/boxes/report_box.h"
|
||||||
|
#include "ui/controls/delete_message_context_action.h"
|
||||||
|
#include "ui/controls/who_reacted_context_action.h"
|
||||||
|
#include "ui/effects/message_sending_animation_controller.h"
|
||||||
|
#include "ui/effects/path_shift_gradient.h"
|
||||||
|
#include "ui/effects/reaction_fly_animation.h"
|
||||||
|
#include "ui/image/image.h"
|
||||||
|
#include "ui/layers/generic_box.h"
|
||||||
|
#include "ui/text/text_entity.h"
|
||||||
|
#include "ui/text/text_options.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "window/notifications_manager.h"
|
||||||
|
#include "window/window_adaptive.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
|
#include "window/window_peer_menu.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
#include "history/view/history_view_context_menu.h"
|
#include "history/view/history_view_context_menu.h"
|
||||||
|
|
||||||
#include <styles/style_info.h>
|
|
||||||
#include <ayu/ayu_settings.h>
|
#include <ayu/ayu_settings.h>
|
||||||
|
#include <styles/style_info.h>
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
class AyuPopupMenu {
|
{
|
||||||
|
class AyuPopupMenu
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
AyuPopupMenu(HistoryInner* parent);
|
AyuPopupMenu(HistoryInner* parent);
|
||||||
|
|
||||||
|
@ -95,5 +96,4 @@ namespace AyuUi {
|
||||||
|
|
||||||
std::unique_ptr<Ui::PopupMenu> _ayuSubMenu;
|
std::unique_ptr<Ui::PopupMenu> _ayuSubMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,62 +5,71 @@
|
||||||
//
|
//
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include <styles/style_layers.h>
|
|
||||||
#include <styles/style_boxes.h>
|
|
||||||
#include <ui/effects/scroll_content_shadow.h>
|
|
||||||
#include <styles/style_settings.h>
|
|
||||||
#include "message_history_box.h"
|
#include "message_history_box.h"
|
||||||
#include "settings/settings_common.h"
|
#include <styles/style_boxes.h>
|
||||||
|
#include <styles/style_layers.h>
|
||||||
|
#include <styles/style_settings.h>
|
||||||
|
#include <ui/effects/scroll_content_shadow.h>
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
#include "ayu/database/ayu_database.h"
|
#include "ayu/database/ayu_database.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
#include "settings/settings_common.h"
|
||||||
|
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
|
{
|
||||||
MessageHistoryBox::MessageHistoryBox(QWidget*, HistoryItem* item)
|
MessageHistoryBox::MessageHistoryBox(QWidget*, HistoryItem* item)
|
||||||
: _content(this), _scroll(base::make_unique_q<Ui::ScrollArea>(this, st::boxScroll)) {
|
: _content(this), _scroll(base::make_unique_q<Ui::ScrollArea>(this, st::boxScroll))
|
||||||
|
{
|
||||||
setupControls();
|
setupControls();
|
||||||
addEditedMessagesToLayout(item);
|
addEditedMessagesToLayout(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHistoryBox::setupControls() {
|
void MessageHistoryBox::setupControls()
|
||||||
|
{
|
||||||
_content.create(this);
|
_content.create(this);
|
||||||
|
|
||||||
_content->resizeToWidth(st::boxWideWidth);
|
_content->resizeToWidth(st::boxWideWidth);
|
||||||
_content->moveToLeft(0, 0);
|
_content->moveToLeft(0, 0);
|
||||||
|
|
||||||
_content->heightValue(
|
_content->heightValue(
|
||||||
) | rpl::start_to_stream(_contentHeight, _content->lifetime());
|
) | start_to_stream(_contentHeight, _content->lifetime());
|
||||||
|
|
||||||
_scroll->setOwnedWidget(
|
_scroll->setOwnedWidget(
|
||||||
object_ptr<Ui::RpWidget>::fromRaw(_content));
|
object_ptr<RpWidget>::fromRaw(_content));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHistoryBox::resizeEvent(QResizeEvent *e) {
|
void MessageHistoryBox::resizeEvent(QResizeEvent* e)
|
||||||
|
{
|
||||||
_scroll->resize(width(), height() - st::boxPhotoPadding.top() - st::boxPadding.bottom());
|
_scroll->resize(width(), height() - st::boxPhotoPadding.top() - st::boxPadding.bottom());
|
||||||
_scroll->move(0, st::boxPadding.top());
|
_scroll->move(0, st::boxPadding.top());
|
||||||
|
|
||||||
if (_content) {
|
if (_content)
|
||||||
|
{
|
||||||
_content->resize(_scroll->width(), _content->height());
|
_content->resize(_scroll->width(), _content->height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHistoryBox::prepare() {
|
void MessageHistoryBox::prepare()
|
||||||
|
{
|
||||||
setTitle(tr::ayu_EditsHistoryTitle());
|
setTitle(tr::ayu_EditsHistoryTitle());
|
||||||
|
|
||||||
// setDimensionsToContent(st::boxWideWidth, _content);
|
// setDimensionsToContent(st::boxWideWidth, _content);
|
||||||
setDimensions(st::boxWideWidth, 900);
|
setDimensions(st::boxWideWidth, 900);
|
||||||
Ui::SetupShadowsToScrollContent(this, _scroll, _contentHeight.events());
|
SetupShadowsToScrollContent(this, _scroll, _contentHeight.events());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHistoryBox::addEditedMessagesToLayout(HistoryItem *item) {
|
void MessageHistoryBox::addEditedMessagesToLayout(HistoryItem* item)
|
||||||
|
{
|
||||||
auto messages = AyuDatabase::getEditedMessages(item);
|
auto messages = AyuDatabase::getEditedMessages(item);
|
||||||
if (messages.empty()) {
|
if (messages.empty())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &message: messages) {
|
for (const auto& message : messages)
|
||||||
|
{
|
||||||
AddSkip(_content);
|
AddSkip(_content);
|
||||||
AddDividerText(_content, rpl::single(QString::fromStdString(message.text)));
|
AddDividerText(_content, rpl::single(QString::fromStdString(message.text)));
|
||||||
AddSkip(_content);
|
AddSkip(_content);
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include <ui/layers/box_content.h>
|
#include <ui/layers/box_content.h>
|
||||||
#include "ui/wrap/vertical_layout.h"
|
|
||||||
#include "ui/widgets/scroll_area.h"
|
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
#include "ui/widgets/scroll_area.h"
|
||||||
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
|
||||||
namespace AyuUi {
|
namespace AyuUi
|
||||||
class MessageHistoryBox : public Ui::BoxContent {
|
{
|
||||||
|
class MessageHistoryBox : public Ui::BoxContent
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
MessageHistoryBox(QWidget*, HistoryItem* item);
|
MessageHistoryBox(QWidget*, HistoryItem* item);
|
||||||
|
|
||||||
|
|
|
@ -5,46 +5,49 @@
|
||||||
//
|
//
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include "ayu/sync/ayu_sync_controller.h"
|
|
||||||
#include "ayu/ui/boxes/edit_edited_mark.h"
|
|
||||||
#include "ayu/ui/boxes/edit_deleted_mark.h"
|
|
||||||
#include "ayu/ayu_settings.h"
|
|
||||||
#include "settings_ayu.h"
|
#include "settings_ayu.h"
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu/sync/ayu_sync_controller.h"
|
||||||
|
#include "ayu/ui/boxes/edit_deleted_mark.h"
|
||||||
|
#include "ayu/ui/boxes/edit_edited_mark.h"
|
||||||
|
|
||||||
|
#include "apiwrap.h"
|
||||||
#include "lang_auto.h"
|
#include "lang_auto.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "api/api_blocked_peers.h"
|
||||||
|
#include "boxes/connection_box.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "data/data_session.h"
|
||||||
|
#include "lang/lang_instance.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "platform/platform_specific.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "storage/localstorage.h"
|
||||||
|
#include "styles/style_settings.h"
|
||||||
|
#include "ui/boxes/single_choice_box.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "boxes/connection_box.h"
|
|
||||||
#include "platform/platform_specific.h"
|
|
||||||
#include "window/window_session_controller.h"
|
|
||||||
#include "lang/lang_instance.h"
|
|
||||||
#include "core/application.h"
|
|
||||||
#include "storage/localstorage.h"
|
|
||||||
#include "data/data_session.h"
|
|
||||||
#include "main/main_session.h"
|
|
||||||
#include "styles/style_settings.h"
|
|
||||||
#include "apiwrap.h"
|
|
||||||
#include "api/api_blocked_peers.h"
|
|
||||||
#include "ui/widgets/continuous_sliders.h"
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
#include "ui/boxes/single_choice_box.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings
|
||||||
|
{
|
||||||
rpl::producer<QString> Ayu::title() {
|
rpl::producer<QString> Ayu::title()
|
||||||
|
{
|
||||||
return tr::ayu_AyuPreferences();
|
return tr::ayu_AyuPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ayu::Ayu(
|
Ayu::Ayu(
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
not_null<Window::SessionController*> controller)
|
not_null<Window::SessionController*> controller)
|
||||||
: Section(parent) {
|
: Section(parent)
|
||||||
|
{
|
||||||
setupContent(controller);
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupGhostEssentials(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupGhostEssentials(not_null<Ui::VerticalLayout*> container)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::ayu_GhostEssentialsHeader());
|
AddSubsectionTitle(container, tr::ayu_GhostEssentialsHeader());
|
||||||
|
@ -56,9 +59,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->sendReadPackets)
|
rpl::single(settings->sendReadPackets)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->sendReadPackets);
|
return (enabled != settings->sendReadPackets);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_sendReadPackets(enabled);
|
settings->set_sendReadPackets(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -70,9 +75,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->sendOnlinePackets)
|
rpl::single(settings->sendOnlinePackets)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->sendOnlinePackets);
|
return (enabled != settings->sendOnlinePackets);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_sendOnlinePackets(enabled);
|
settings->set_sendOnlinePackets(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -84,9 +91,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->sendUploadProgress)
|
rpl::single(settings->sendUploadProgress)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->sendUploadProgress);
|
return (enabled != settings->sendUploadProgress);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_sendUploadProgress(enabled);
|
settings->set_sendUploadProgress(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -98,9 +107,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->sendOfflinePacketAfterOnline)
|
rpl::single(settings->sendOfflinePacketAfterOnline)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->sendOfflinePacketAfterOnline);
|
return (enabled != settings->sendOfflinePacketAfterOnline);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_sendOfflinePacketAfterOnline(enabled);
|
settings->set_sendOfflinePacketAfterOnline(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -112,9 +123,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->markReadAfterSend)
|
rpl::single(settings->markReadAfterSend)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->markReadAfterSend);
|
return (enabled != settings->markReadAfterSend);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_markReadAfterSend(enabled);
|
settings->set_markReadAfterSend(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -126,15 +139,18 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->useScheduledMessages)
|
rpl::single(settings->useScheduledMessages)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->useScheduledMessages);
|
return (enabled != settings->useScheduledMessages);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_useScheduledMessages(enabled);
|
settings->set_useScheduledMessages(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupSpyEssentials(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupSpyEssentials(not_null<Ui::VerticalLayout*> container)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::ayu_SpyEssentialsHeader());
|
AddSubsectionTitle(container, tr::ayu_SpyEssentialsHeader());
|
||||||
|
@ -146,9 +162,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->keepDeletedMessages)
|
rpl::single(settings->keepDeletedMessages)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->keepDeletedMessages);
|
return (enabled != settings->keepDeletedMessages);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_keepDeletedMessages(enabled);
|
settings->set_keepDeletedMessages(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -160,15 +178,18 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->keepMessagesHistory)
|
rpl::single(settings->keepMessagesHistory)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->keepMessagesHistory);
|
return (enabled != settings->keepMessagesHistory);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_keepMessagesHistory(enabled);
|
settings->set_keepMessagesHistory(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupQoLToggles(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupQoLToggles(not_null<Ui::VerticalLayout*> container)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::ayu_QoLTogglesHeader());
|
AddSubsectionTitle(container, tr::ayu_QoLTogglesHeader());
|
||||||
|
@ -180,16 +201,19 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->enableAds)
|
rpl::single(settings->enableAds)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->enableAds);
|
return (enabled != settings->enableAds);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_enableAds(enabled);
|
settings->set_enableAds(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupCustomization(not_null<Ui::VerticalLayout*> container,
|
void Ayu::SetupCustomization(not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController *> controller) {
|
not_null<Window::SessionController*> controller)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
|
AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
|
||||||
|
@ -200,7 +224,8 @@ namespace Settings {
|
||||||
AyuSettings::get_deletedMarkReactive(),
|
AyuSettings::get_deletedMarkReactive(),
|
||||||
st::settingsButtonNoIcon
|
st::settingsButtonNoIcon
|
||||||
);
|
);
|
||||||
btn->addClickHandler([=]() {
|
btn->addClickHandler([=]()
|
||||||
|
{
|
||||||
auto box = Box<EditDeletedMarkBox>();
|
auto box = Box<EditDeletedMarkBox>();
|
||||||
Ui::show(std::move(box));
|
Ui::show(std::move(box));
|
||||||
});
|
});
|
||||||
|
@ -211,7 +236,8 @@ namespace Settings {
|
||||||
AyuSettings::get_editedMarkReactive(),
|
AyuSettings::get_editedMarkReactive(),
|
||||||
st::settingsButtonNoIcon
|
st::settingsButtonNoIcon
|
||||||
);
|
);
|
||||||
btn2->addClickHandler([=]() {
|
btn2->addClickHandler([=]()
|
||||||
|
{
|
||||||
auto box = Box<EditEditedMarkBox>();
|
auto box = Box<EditEditedMarkBox>();
|
||||||
Ui::show(std::move(box));
|
Ui::show(std::move(box));
|
||||||
});
|
});
|
||||||
|
@ -227,9 +253,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->showGhostToggleInDrawer)
|
rpl::single(settings->showGhostToggleInDrawer)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->showGhostToggleInDrawer);
|
return (enabled != settings->showGhostToggleInDrawer);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_showGhostToggleInDrawer(enabled);
|
settings->set_showGhostToggleInDrawer(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -241,9 +269,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->showMessageSeconds)
|
rpl::single(settings->showMessageSeconds)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->showMessageSeconds);
|
return (enabled != settings->showMessageSeconds);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_showMessageSeconds(enabled);
|
settings->set_showMessageSeconds(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -252,7 +282,8 @@ namespace Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupShowPeerId(not_null<Ui::VerticalLayout*> container,
|
void Ayu::SetupShowPeerId(not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController *> controller) {
|
not_null<Window::SessionController*> controller)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
const auto options = std::vector{
|
const auto options = std::vector{
|
||||||
|
@ -261,7 +292,8 @@ namespace Settings {
|
||||||
QString("Bot API")
|
QString("Bot API")
|
||||||
};
|
};
|
||||||
|
|
||||||
auto currentVal = AyuSettings::get_showPeerIdReactive() | rpl::map([=](int val) {
|
auto currentVal = AyuSettings::get_showPeerIdReactive() | rpl::map([=](int val)
|
||||||
|
{
|
||||||
return options[val];
|
return options[val];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -270,9 +302,12 @@ namespace Settings {
|
||||||
tr::ayu_SettingsShowID(),
|
tr::ayu_SettingsShowID(),
|
||||||
currentVal,
|
currentVal,
|
||||||
st::settingsButtonNoIcon);
|
st::settingsButtonNoIcon);
|
||||||
button->addClickHandler([=] {
|
button->addClickHandler([=]
|
||||||
controller->show(Box([=](not_null<Ui::GenericBox *> box) {
|
{
|
||||||
const auto save = [=](int index) {
|
controller->show(Box([=](not_null<Ui::GenericBox*> box)
|
||||||
|
{
|
||||||
|
const auto save = [=](int index)
|
||||||
|
{
|
||||||
settings->set_showPeerId(index);
|
settings->set_showPeerId(index);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
};
|
};
|
||||||
|
@ -286,7 +321,8 @@ namespace Settings {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout*> container)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
container->add(
|
container->add(
|
||||||
|
@ -308,7 +344,8 @@ namespace Settings {
|
||||||
const auto slider = recentStickersLimitSlider.slider;
|
const auto slider = recentStickersLimitSlider.slider;
|
||||||
const auto label = recentStickersLimitSlider.label;
|
const auto label = recentStickersLimitSlider.label;
|
||||||
|
|
||||||
const auto updateLabel = [=](int amount) {
|
const auto updateLabel = [=](int amount)
|
||||||
|
{
|
||||||
label->setText(QString::number(amount));
|
label->setText(QString::number(amount));
|
||||||
};
|
};
|
||||||
updateLabel(settings->recentStickersCount);
|
updateLabel(settings->recentStickersCount);
|
||||||
|
@ -318,7 +355,8 @@ namespace Settings {
|
||||||
[=](int amount) { return amount; },
|
[=](int amount) { return amount; },
|
||||||
settings->recentStickersCount,
|
settings->recentStickersCount,
|
||||||
[=](int amount) { updateLabel(amount); },
|
[=](int amount) { updateLabel(amount); },
|
||||||
[=](int amount) {
|
[=](int amount)
|
||||||
|
{
|
||||||
updateLabel(amount);
|
updateLabel(amount);
|
||||||
|
|
||||||
settings->set_recentStickersCount(amount);
|
settings->set_recentStickersCount(amount);
|
||||||
|
@ -326,24 +364,25 @@ namespace Settings {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupAyuSync(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupAyuSync(not_null<Ui::VerticalLayout*> container)
|
||||||
|
{
|
||||||
AddSubsectionTitle(container, rpl::single(QString("AyuSync")));
|
AddSubsectionTitle(container, rpl::single(QString("AyuSync")));
|
||||||
|
|
||||||
auto text = AyuSync::isAgentDownloaded() ?
|
auto text = AyuSync::isAgentDownloaded() ? QString("Open preferences") : QString("Download agent");
|
||||||
QString("Open preferences") :
|
|
||||||
QString("Download agent");
|
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
container,
|
container,
|
||||||
rpl::single(text),
|
rpl::single(text),
|
||||||
st::settingsButtonNoIcon
|
st::settingsButtonNoIcon
|
||||||
)->addClickHandler([=] {
|
)->addClickHandler([=]
|
||||||
|
{
|
||||||
auto controller = &AyuSync::getControllerInstance();
|
auto controller = &AyuSync::getControllerInstance();
|
||||||
controller->initializeAgent();
|
controller->initializeAgent();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupBetaFunctions(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupBetaFunctions(not_null<Ui::VerticalLayout*> container)
|
||||||
|
{
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSubsectionTitle(container, rpl::single(QString("Beta functions")));
|
AddSubsectionTitle(container, rpl::single(QString("Beta functions")));
|
||||||
|
@ -355,9 +394,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->stickerConfirmation)
|
rpl::single(settings->stickerConfirmation)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->stickerConfirmation);
|
return (enabled != settings->stickerConfirmation);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_stickerConfirmation(enabled);
|
settings->set_stickerConfirmation(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -369,9 +410,11 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->GIFConfirmation)
|
rpl::single(settings->GIFConfirmation)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->GIFConfirmation);
|
return (enabled != settings->GIFConfirmation);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_GIFConfirmation(enabled);
|
settings->set_GIFConfirmation(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
@ -383,16 +426,19 @@ namespace Settings {
|
||||||
)->toggleOn(
|
)->toggleOn(
|
||||||
rpl::single(settings->voiceConfirmation)
|
rpl::single(settings->voiceConfirmation)
|
||||||
)->toggledValue(
|
)->toggledValue(
|
||||||
) | rpl::filter([=](bool enabled) {
|
) | rpl::filter([=](bool enabled)
|
||||||
|
{
|
||||||
return (enabled != settings->voiceConfirmation);
|
return (enabled != settings->voiceConfirmation);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | start_with_next([=](bool enabled)
|
||||||
|
{
|
||||||
settings->set_voiceConfirmation(enabled);
|
settings->set_voiceConfirmation(enabled);
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout*> container,
|
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController *> controller) {
|
not_null<Window::SessionController*> controller)
|
||||||
|
{
|
||||||
AddSkip(container);
|
AddSkip(container);
|
||||||
SetupGhostEssentials(container);
|
SetupGhostEssentials(container);
|
||||||
|
|
||||||
|
@ -422,12 +468,12 @@ namespace Settings {
|
||||||
AddDividerText(container, tr::ayu_SettingsWatermark());
|
AddDividerText(container, tr::ayu_SettingsWatermark());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::setupContent(not_null<Window::SessionController *> controller) {
|
void Ayu::setupContent(not_null<Window::SessionController*> controller)
|
||||||
|
{
|
||||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||||
|
|
||||||
SetupAyuGramSettings(content, controller);
|
SetupAyuGramSettings(content, controller);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
ResizeFitChild(this, content);
|
||||||
}
|
}
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,17 @@
|
||||||
|
|
||||||
class BoxContent;
|
class BoxContent;
|
||||||
|
|
||||||
namespace Window {
|
namespace Window
|
||||||
|
{
|
||||||
class Controller;
|
class Controller;
|
||||||
|
|
||||||
class SessionController;
|
class SessionController;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
namespace Settings {
|
namespace Settings
|
||||||
class Ayu : public Section<Ayu> {
|
{
|
||||||
|
class Ayu : public Section<Ayu>
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Ayu(QWidget* parent, not_null<Window::SessionController*> controller);
|
Ayu(QWidget* parent, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
|
@ -31,7 +34,8 @@ namespace Settings {
|
||||||
|
|
||||||
void SetupQoLToggles(not_null<Ui::VerticalLayout*> container);
|
void SetupQoLToggles(not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
void SetupCustomization(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
|
void SetupCustomization(not_null<Ui::VerticalLayout*> container,
|
||||||
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
void SetupShowPeerId(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> controller);
|
void SetupShowPeerId(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
|
@ -45,5 +49,4 @@ namespace Settings {
|
||||||
|
|
||||||
void setupContent(not_null<Window::SessionController*> controller);
|
void setupContent(not_null<Window::SessionController*> controller);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Settings
|
} // namespace Settings
|
||||||
|
|
|
@ -5,16 +5,17 @@
|
||||||
//
|
//
|
||||||
// Copyright @Radolyn, 2023
|
// Copyright @Radolyn, 2023
|
||||||
|
|
||||||
#include "ui/text/text_utilities.h"
|
|
||||||
#include "ayu/ayu_settings.h"
|
|
||||||
#include "ayu_profile_values.h"
|
#include "ayu_profile_values.h"
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
|
||||||
|
|
||||||
constexpr auto kMaxChannelId = -1000000000000;
|
constexpr auto kMaxChannelId = -1000000000000;
|
||||||
|
|
||||||
|
|
||||||
QString IDString(not_null<PeerData *> peer) {
|
QString IDString(not_null<PeerData*> peer)
|
||||||
|
{
|
||||||
auto resultId = QString::number(peerIsUser(peer->id)
|
auto resultId = QString::number(peerIsUser(peer->id)
|
||||||
? peerToUser(peer->id).bare
|
? peerToUser(peer->id).bare
|
||||||
: peerIsChat(peer->id)
|
: peerIsChat(peer->id)
|
||||||
|
@ -23,11 +24,15 @@ QString IDString(not_null<PeerData *> peer) {
|
||||||
? peerToChannel(peer->id).bare
|
? peerToChannel(peer->id).bare
|
||||||
: peer->id.value);
|
: peer->id.value);
|
||||||
|
|
||||||
auto const settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
if (settings->showPeerId == 2) {
|
if (settings->showPeerId == 2)
|
||||||
if (peer->isChannel()) {
|
{
|
||||||
|
if (peer->isChannel())
|
||||||
|
{
|
||||||
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
|
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
|
||||||
} else if (peer->isChat()) {
|
}
|
||||||
|
else if (peer->isChat())
|
||||||
|
{
|
||||||
resultId = resultId.prepend("-");
|
resultId = resultId.prepend("-");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,17 +40,20 @@ QString IDString(not_null<PeerData *> peer) {
|
||||||
return resultId;
|
return resultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IDString(MsgId topic_root_id) {
|
QString IDString(MsgId topic_root_id)
|
||||||
|
{
|
||||||
auto resultId = QString::number(topic_root_id.bare);
|
auto resultId = QString::number(topic_root_id.bare);
|
||||||
|
|
||||||
return resultId;
|
return resultId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> IDValue(not_null<PeerData *> peer) {
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer)
|
||||||
|
{
|
||||||
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
|
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> IDValue(MsgId topic_root_id) {
|
rpl::producer<TextWithEntities> IDValue(MsgId topic_root_id)
|
||||||
|
{
|
||||||
return rpl::single(IDString(topic_root_id)) | Ui::Text::ToWithEntities();
|
return rpl::single(IDString(topic_root_id)) | Ui::Text::ToWithEntities();
|
||||||
}
|
}
|
|
@ -481,11 +481,12 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->showPeerId != 0) {
|
if (settings->showPeerId != 0)
|
||||||
|
{
|
||||||
auto idDrawableText = IDValue(
|
auto idDrawableText = IDValue(
|
||||||
user
|
user
|
||||||
) | rpl::map([](TextWithEntities &&text) {
|
) | rpl::map([](TextWithEntities&& text)
|
||||||
|
{
|
||||||
return Ui::Text::Code(text.text);
|
return Ui::Text::Code(text.text);
|
||||||
});
|
});
|
||||||
auto idInfo = addInfoOneLine(
|
auto idInfo = addInfoOneLine(
|
||||||
|
@ -494,9 +495,11 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
tr::ayu_ContextCopyID(tr::now)
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
);
|
);
|
||||||
|
|
||||||
idInfo.text->setClickHandlerFilter([=](auto &&...) {
|
idInfo.text->setClickHandlerFilter([=](auto&&...)
|
||||||
|
{
|
||||||
const auto idText = IDString(user);
|
const auto idText = IDString(user);
|
||||||
if (!idText.isEmpty()) {
|
if (!idText.isEmpty())
|
||||||
|
{
|
||||||
QGuiApplication::clipboard()->setText(idText);
|
QGuiApplication::clipboard()->setText(idText);
|
||||||
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
||||||
controller->showToast(msg);
|
controller->showToast(msg);
|
||||||
|
@ -566,10 +569,12 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
addTranslateToMenu(about.text, AboutValue(_peer));
|
addTranslateToMenu(about.text, AboutValue(_peer));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->showPeerId != 0 && !_topic) {
|
if (settings->showPeerId != 0 && !_topic)
|
||||||
|
{
|
||||||
auto idDrawableText = IDValue(
|
auto idDrawableText = IDValue(
|
||||||
_peer
|
_peer
|
||||||
) | rpl::map([](TextWithEntities &&text) {
|
) | rpl::map([](TextWithEntities&& text)
|
||||||
|
{
|
||||||
return Ui::Text::Code(text.text);
|
return Ui::Text::Code(text.text);
|
||||||
});
|
});
|
||||||
auto idInfo = addInfoOneLine(
|
auto idInfo = addInfoOneLine(
|
||||||
|
@ -578,9 +583,11 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
tr::ayu_ContextCopyID(tr::now)
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
);
|
);
|
||||||
|
|
||||||
idInfo.text->setClickHandlerFilter([=, peer = _peer](auto &&...) {
|
idInfo.text->setClickHandlerFilter([=, peer = _peer](auto&&...)
|
||||||
|
{
|
||||||
const auto idText = IDString(peer);
|
const auto idText = IDString(peer);
|
||||||
if (!idText.isEmpty()) {
|
if (!idText.isEmpty())
|
||||||
|
{
|
||||||
QGuiApplication::clipboard()->setText(idText);
|
QGuiApplication::clipboard()->setText(idText);
|
||||||
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
||||||
controller->showToast(msg);
|
controller->showToast(msg);
|
||||||
|
@ -589,11 +596,13 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->showPeerId != 0 && _topic) {
|
if (settings->showPeerId != 0 && _topic)
|
||||||
|
{
|
||||||
const auto topicRootId = _topic->rootId();
|
const auto topicRootId = _topic->rootId();
|
||||||
auto idDrawableText = IDValue(
|
auto idDrawableText = IDValue(
|
||||||
_peer->forumTopicFor(topicRootId)->topicRootId()
|
_peer->forumTopicFor(topicRootId)->topicRootId()
|
||||||
) | rpl::map([](TextWithEntities &&text) {
|
) | rpl::map([](TextWithEntities&& text)
|
||||||
|
{
|
||||||
return Ui::Text::Code(text.text);
|
return Ui::Text::Code(text.text);
|
||||||
});
|
});
|
||||||
auto idInfo = addInfoOneLine(
|
auto idInfo = addInfoOneLine(
|
||||||
|
@ -602,9 +611,11 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
tr::ayu_ContextCopyID(tr::now)
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
);
|
);
|
||||||
|
|
||||||
idInfo.text->setClickHandlerFilter([=, peer = _peer](auto &&...) {
|
idInfo.text->setClickHandlerFilter([=, peer = _peer](auto&&...)
|
||||||
|
{
|
||||||
const auto idText = IDString(peer);
|
const auto idText = IDString(peer);
|
||||||
if (!idText.isEmpty()) {
|
if (!idText.isEmpty())
|
||||||
|
{
|
||||||
QGuiApplication::clipboard()->setText(idText);
|
QGuiApplication::clipboard()->setText(idText);
|
||||||
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
||||||
controller->showToast(msg);
|
controller->showToast(msg);
|
||||||
|
|
Loading…
Add table
Reference in a new issue