mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
feat: import peer ID view from Kotato
fix: really update string views in AyuGram Preferences
This commit is contained in:
parent
e21ccd6024
commit
09e24083ff
11 changed files with 237 additions and 51 deletions
|
@ -120,6 +120,8 @@ PRIVATE
|
||||||
ayu/database/entities.h
|
ayu/database/entities.h
|
||||||
ayu/database/ayu_database.cpp
|
ayu/database/ayu_database.cpp
|
||||||
ayu/database/ayu_database.h
|
ayu/database/ayu_database.h
|
||||||
|
ayu/utils/ayu_profile_values.cpp
|
||||||
|
ayu/utils/ayu_profile_values.h
|
||||||
|
|
||||||
api/api_attached_stickers.cpp
|
api/api_attached_stickers.cpp
|
||||||
api/api_attached_stickers.h
|
api/api_attached_stickers.h
|
||||||
|
|
|
@ -3875,4 +3875,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"ayu_EditsHistoryMenuText" = "History";
|
"ayu_EditsHistoryMenuText" = "History";
|
||||||
"ayu_ReadUntilMenuText" = "Read until";
|
"ayu_ReadUntilMenuText" = "Read until";
|
||||||
"ayu_LikelyOfflineStatus" = "offline ?";
|
"ayu_LikelyOfflineStatus" = "offline ?";
|
||||||
|
"ayu_GhostModeShortcut" = "Enter with Ghost";
|
||||||
"ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs";
|
"ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs";
|
||||||
|
"ayu_SettingsShowID" = "Show peer ID";
|
||||||
|
"ayu_SettingsShowID_Hide" = "Hide";
|
||||||
|
"ayu_ContextCopyID" = "Copy ID";
|
||||||
|
"ayu_IDCopiedToast" = "ID copied to clipboard.";
|
||||||
|
"ayu_DrawerGhostModeToggle" = "Ghost Mode";
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "ayu_settings.h"
|
#include "ayu_settings.h"
|
||||||
#include "rpl/lifetime.h"
|
#include "rpl/lifetime.h"
|
||||||
|
#include "rpl/producer.h"
|
||||||
|
#include "rpl/variable.h"
|
||||||
|
|
||||||
namespace AyuSettings {
|
namespace AyuSettings {
|
||||||
const QString filename = "tdata/ayu_settings.json";
|
const QString filename = "tdata/ayu_settings.json";
|
||||||
|
@ -14,6 +16,8 @@ namespace AyuSettings {
|
||||||
rpl::variable<bool> keepMessagesHistoryReactive;
|
rpl::variable<bool> keepMessagesHistoryReactive;
|
||||||
rpl::variable<QString> deletedMarkReactive;
|
rpl::variable<QString> deletedMarkReactive;
|
||||||
rpl::variable<QString> editedMarkReactive;
|
rpl::variable<QString> editedMarkReactive;
|
||||||
|
rpl::variable<int> showPeerIdReactive;
|
||||||
|
|
||||||
rpl::variable<bool> ghostModeEnabled;
|
rpl::variable<bool> ghostModeEnabled;
|
||||||
|
|
||||||
rpl::lifetime lifetime = rpl::lifetime();
|
rpl::lifetime lifetime = rpl::lifetime();
|
||||||
|
@ -47,6 +51,8 @@ namespace AyuSettings {
|
||||||
keepMessagesHistoryReactive = settings->keepMessagesHistory;
|
keepMessagesHistoryReactive = settings->keepMessagesHistory;
|
||||||
deletedMarkReactive = settings->deletedMark;
|
deletedMarkReactive = settings->deletedMark;
|
||||||
editedMarkReactive = settings->editedMark;
|
editedMarkReactive = settings->editedMark;
|
||||||
|
showPeerIdReactive = settings->showPeerId;
|
||||||
|
|
||||||
ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets;
|
ghostModeEnabled = !settings->sendReadPackets && !settings->sendOnlinePackets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,43 +133,52 @@ namespace AyuSettings {
|
||||||
editedMarkReactive = editedMark;
|
editedMarkReactive = editedMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_sendReadPacketsReactive() {
|
void AyuGramSettings::set_showPeerId(int val) {
|
||||||
return sendReadPacketsReactive;
|
showPeerId = val;
|
||||||
|
showPeerIdReactive = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_sendOnlinePacketsReactive() {
|
rpl::producer<bool> get_sendReadPacketsReactive() {
|
||||||
return sendOnlinePacketsReactive;
|
return sendReadPacketsReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_sendOfflinePacketAfterOnlineReactive() {
|
rpl::producer<bool> get_sendOnlinePacketsReactive() {
|
||||||
return sendOfflinePacketAfterOnlineReactive;
|
return sendOnlinePacketsReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_sendUploadProgressReactive() {
|
rpl::producer<bool> get_sendOfflinePacketAfterOnlineReactive() {
|
||||||
return sendUploadProgressReactive;
|
return sendOfflinePacketAfterOnlineReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_useScheduledMessagesReactive() {
|
rpl::producer<bool> get_sendUploadProgressReactive() {
|
||||||
return useScheduledMessagesReactive;
|
return sendUploadProgressReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_keepDeletedMessagesReactive() {
|
rpl::producer<bool> get_useScheduledMessagesReactive() {
|
||||||
return keepDeletedMessagesReactive;
|
return useScheduledMessagesReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_keepMessagesHistoryReactive() {
|
rpl::producer<bool> get_keepDeletedMessagesReactive() {
|
||||||
return keepMessagesHistoryReactive;
|
return keepDeletedMessagesReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<QString> get_deletedMarkReactive() {
|
rpl::producer<bool> get_keepMessagesHistoryReactive() {
|
||||||
return deletedMarkReactive;
|
return keepMessagesHistoryReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<QString> get_editedMarkReactive() {
|
rpl::producer<QString> get_deletedMarkReactive() {
|
||||||
return editedMarkReactive;
|
return deletedMarkReactive.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::variable<bool> get_ghostModeEnabled() {
|
rpl::producer<QString> get_editedMarkReactive() {
|
||||||
return ghostModeEnabled;
|
return editedMarkReactive.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<int> get_showPeerId() {
|
||||||
|
return showPeerIdReactive.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<bool> get_ghostModeEnabled() {
|
||||||
|
return ghostModeEnabled.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,13 @@ namespace AyuSettings {
|
||||||
keepMessagesHistory = false;
|
keepMessagesHistory = false;
|
||||||
deletedMark = "🧹";
|
deletedMark = "🧹";
|
||||||
editedMark = tr::lng_edited(tr::now);
|
editedMark = tr::lng_edited(tr::now);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* showPeerId = 0 means no ID shown
|
||||||
|
* showPeerId = 1 means ID shown as for Telegram API devs
|
||||||
|
* showPeerId = 2 means ID shown as for Bot API devs (-100)
|
||||||
|
*/
|
||||||
|
showPeerId = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
QS_SERIALIZABLE
|
QS_SERIALIZABLE
|
||||||
|
@ -44,6 +51,8 @@ namespace AyuSettings {
|
||||||
|
|
||||||
QS_FIELD(QString, editedMark)
|
QS_FIELD(QString, editedMark)
|
||||||
|
|
||||||
|
QS_FIELD(int, showPeerId)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_sendReadPackets(bool val);
|
void set_sendReadPackets(bool val);
|
||||||
void set_sendOnlinePackets(bool val);
|
void set_sendOnlinePackets(bool val);
|
||||||
|
@ -54,6 +63,7 @@ namespace AyuSettings {
|
||||||
void set_keepMessagesHistory(bool val);
|
void set_keepMessagesHistory(bool val);
|
||||||
void set_deletedMark(QString val);
|
void set_deletedMark(QString val);
|
||||||
void set_editedMark(QString val);
|
void set_editedMark(QString val);
|
||||||
|
void set_showPeerId(int val);
|
||||||
};
|
};
|
||||||
|
|
||||||
AyuGramSettings &getInstance();
|
AyuGramSettings &getInstance();
|
||||||
|
@ -62,16 +72,17 @@ namespace AyuSettings {
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
rpl::variable<bool> get_sendReadPacketsReactive();
|
rpl::producer<bool> get_sendReadPacketsReactive();
|
||||||
rpl::variable<bool> get_sendOnlinePacketsReactive();
|
rpl::producer<bool> get_sendOnlinePacketsReactive();
|
||||||
rpl::variable<bool> get_sendOfflinePacketAfterOnlineReactive();
|
rpl::producer<bool> get_sendOfflinePacketAfterOnlineReactive();
|
||||||
rpl::variable<bool> get_sendUploadProgressReactive();
|
rpl::producer<bool> get_sendUploadProgressReactive();
|
||||||
rpl::variable<bool> get_useScheduledMessagesReactive();
|
rpl::producer<bool> get_useScheduledMessagesReactive();
|
||||||
rpl::variable<bool> get_keepDeletedMessagesReactive();
|
rpl::producer<bool> get_keepDeletedMessagesReactive();
|
||||||
rpl::variable<bool> get_keepMessagesHistoryReactive();
|
rpl::producer<bool> get_keepMessagesHistoryReactive();
|
||||||
rpl::variable<QString> get_deletedMarkReactive();
|
rpl::producer<QString> get_deletedMarkReactive();
|
||||||
rpl::variable<QString> get_editedMarkReactive();
|
rpl::producer<QString> get_editedMarkReactive();
|
||||||
|
rpl::producer<int> get_showPeerId();
|
||||||
|
|
||||||
// computed fields
|
// computed fields
|
||||||
rpl::variable<bool> get_ghostModeEnabled();
|
rpl::producer<bool> get_ghostModeEnabled();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <ui/boxes/single_choice_box.h>
|
||||||
#include "ayu/boxes/edit_edited_mark.h"
|
#include "ayu/boxes/edit_edited_mark.h"
|
||||||
#include "ayu/boxes/edit_deleted_mark.h"
|
#include "ayu/boxes/edit_deleted_mark.h"
|
||||||
#include "ayu/ayu_settings.h"
|
#include "ayu/ayu_settings.h"
|
||||||
|
@ -35,10 +36,9 @@ namespace Settings {
|
||||||
setupContent(controller);
|
setupContent(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container) {
|
void Ayu::SetupGhostEssentials(not_null<Ui::VerticalLayout *> container) {
|
||||||
auto settings = &AyuSettings::getInstance();
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSkip(container);
|
|
||||||
AddSubsectionTitle(container, tr::ayu_GhostEssentialsHeader());
|
AddSubsectionTitle(container, tr::ayu_GhostEssentialsHeader());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -52,7 +52,7 @@ namespace Settings {
|
||||||
return (enabled != settings->sendReadPackets);
|
return (enabled != settings->sendReadPackets);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_sendReadPackets(enabled);
|
settings->set_sendReadPackets(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -66,7 +66,7 @@ namespace Settings {
|
||||||
return (enabled != settings->sendOnlinePackets);
|
return (enabled != settings->sendOnlinePackets);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_sendOnlinePackets(enabled);
|
settings->set_sendOnlinePackets(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -80,7 +80,7 @@ namespace Settings {
|
||||||
return (enabled != settings->sendUploadProgress);
|
return (enabled != settings->sendUploadProgress);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_sendUploadProgress(enabled);
|
settings->set_sendUploadProgress(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -94,7 +94,7 @@ namespace Settings {
|
||||||
return (enabled != settings->sendOfflinePacketAfterOnline);
|
return (enabled != settings->sendOfflinePacketAfterOnline);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_sendOfflinePacketAfterOnline(enabled);
|
settings->set_sendOfflinePacketAfterOnline(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -108,11 +108,12 @@ namespace Settings {
|
||||||
return (enabled != settings->useScheduledMessages);
|
return (enabled != settings->useScheduledMessages);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_useScheduledMessages(enabled);
|
settings->set_useScheduledMessages(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
AddDivider(container);
|
void Ayu::SetupSpyEssentials(not_null<Ui::VerticalLayout *> container) {
|
||||||
AddSkip(container);
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::ayu_SpyEssentialsHeader());
|
AddSubsectionTitle(container, tr::ayu_SpyEssentialsHeader());
|
||||||
|
|
||||||
|
@ -127,7 +128,7 @@ namespace Settings {
|
||||||
return (enabled != settings->keepDeletedMessages);
|
return (enabled != settings->keepDeletedMessages);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_keepDeletedMessages(enabled);
|
settings->set_keepDeletedMessages(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
|
||||||
AddButton(
|
AddButton(
|
||||||
|
@ -141,18 +142,17 @@ namespace Settings {
|
||||||
return (enabled != settings->keepMessagesHistory);
|
return (enabled != settings->keepMessagesHistory);
|
||||||
}) | rpl::start_with_next([=](bool enabled) {
|
}) | rpl::start_with_next([=](bool enabled) {
|
||||||
settings->set_keepMessagesHistory(enabled);
|
settings->set_keepMessagesHistory(enabled);
|
||||||
Local::writeSettings();
|
AyuSettings::save();
|
||||||
}, container->lifetime());
|
}, container->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
AddDivider(container);
|
void Ayu::SetupCustomization(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
||||||
AddSkip(container);
|
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
|
AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
|
||||||
|
|
||||||
auto btn = AddButtonWithLabel(
|
auto btn = AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
tr::ayu_DeletedMarkText(),
|
tr::ayu_DeletedMarkText(),
|
||||||
AyuSettings::get_deletedMarkReactive().value(),
|
AyuSettings::get_deletedMarkReactive(),
|
||||||
st::settingsButtonNoIcon
|
st::settingsButtonNoIcon
|
||||||
);
|
);
|
||||||
btn->addClickHandler([=]() {
|
btn->addClickHandler([=]() {
|
||||||
|
@ -163,7 +163,7 @@ namespace Settings {
|
||||||
auto btn2 = AddButtonWithLabel(
|
auto btn2 = AddButtonWithLabel(
|
||||||
container,
|
container,
|
||||||
rpl::single(QString("Edited mark")),
|
rpl::single(QString("Edited mark")),
|
||||||
AyuSettings::get_editedMarkReactive().value(),
|
AyuSettings::get_editedMarkReactive(),
|
||||||
st::settingsButtonNoIcon
|
st::settingsButtonNoIcon
|
||||||
);
|
);
|
||||||
btn2->addClickHandler([=]() {
|
btn2->addClickHandler([=]() {
|
||||||
|
@ -171,13 +171,64 @@ namespace Settings {
|
||||||
Ui::show(std::move(box));
|
Ui::show(std::move(box));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SetupShowPeerId(container, controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ayu::SetupShowPeerId(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
|
const auto options = std::vector{
|
||||||
|
QString(tr::ayu_SettingsShowID_Hide(tr::now)),
|
||||||
|
QString("Telegram API"),
|
||||||
|
QString("Bot API")
|
||||||
|
};
|
||||||
|
|
||||||
|
auto currentVal = AyuSettings::get_showPeerId() | rpl::map([=] (int val) {
|
||||||
|
return options[val];
|
||||||
|
});
|
||||||
|
|
||||||
|
const auto button = AddButtonWithLabel(
|
||||||
|
container,
|
||||||
|
tr::ayu_SettingsShowID(),
|
||||||
|
currentVal,
|
||||||
|
st::settingsButtonNoIcon);
|
||||||
|
button->addClickHandler([=] {
|
||||||
|
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||||
|
const auto save = [=](int index) {
|
||||||
|
settings->set_showPeerId(index);
|
||||||
|
AyuSettings::save();
|
||||||
|
};
|
||||||
|
SingleChoiceBox(box, {
|
||||||
|
.title = tr::ayu_SettingsShowID(),
|
||||||
|
.options = options,
|
||||||
|
.initialSelection = settings->showPeerId,
|
||||||
|
.callback = save,
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
||||||
|
AddSkip(container);
|
||||||
|
SetupGhostEssentials(container);
|
||||||
|
|
||||||
|
AddDivider(container);
|
||||||
|
|
||||||
|
AddSkip(container);
|
||||||
|
SetupSpyEssentials(container);
|
||||||
|
|
||||||
|
AddDivider(container);
|
||||||
|
|
||||||
|
AddSkip(container);
|
||||||
|
SetupCustomization(container, controller);
|
||||||
|
|
||||||
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);
|
SetupAyuGramSettings(content, controller);
|
||||||
|
|
||||||
Ui::ResizeFitChild(this, content);
|
Ui::ResizeFitChild(this, content);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,12 @@ namespace Settings {
|
||||||
[[nodiscard]] rpl::producer<QString> title() override;
|
[[nodiscard]] rpl::producer<QString> title() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container);
|
void SetupGhostEssentials(not_null<Ui::VerticalLayout *> container);
|
||||||
|
void SetupSpyEssentials(not_null<Ui::VerticalLayout *> container);
|
||||||
|
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 SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> null);
|
||||||
void setupContent(not_null<Window::SessionController *> controller);
|
void setupContent(not_null<Window::SessionController *> controller);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
33
Telegram/SourceFiles/ayu/utils/ayu_profile_values.cpp
Normal file
33
Telegram/SourceFiles/ayu/utils/ayu_profile_values.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
|
#include "ayu_profile_values.h"
|
||||||
|
#include "data/data_peer.h"
|
||||||
|
|
||||||
|
|
||||||
|
constexpr auto kMaxChannelId = -1000000000000;
|
||||||
|
|
||||||
|
|
||||||
|
QString IDString(not_null<PeerData*> peer) {
|
||||||
|
auto resultId = QString::number(peerIsUser(peer->id)
|
||||||
|
? peerToUser(peer->id).bare
|
||||||
|
: peerIsChat(peer->id)
|
||||||
|
? peerToChat(peer->id).bare
|
||||||
|
: peerIsChannel(peer->id)
|
||||||
|
? peerToChannel(peer->id).bare
|
||||||
|
: peer->id.value);
|
||||||
|
|
||||||
|
auto const settings = &AyuSettings::getInstance();
|
||||||
|
if (settings->showPeerId == 2) {
|
||||||
|
if (peer->isChannel()) {
|
||||||
|
resultId = QString::number(peerToChannel(peer->id).bare - kMaxChannelId).prepend("-");
|
||||||
|
} else if (peer->isChat()) {
|
||||||
|
resultId = resultId.prepend("-");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer) {
|
||||||
|
return rpl::single(IDString(peer)) | Ui::Text::ToWithEntities();
|
||||||
|
}
|
5
Telegram/SourceFiles/ayu/utils/ayu_profile_values.h
Normal file
5
Telegram/SourceFiles/ayu/utils/ayu_profile_values.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
QString IDString(not_null<PeerData*> peer);
|
||||||
|
rpl::producer<TextWithEntities> IDValue(not_null<PeerData*> peer);
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/profile/info_profile_actions.h"
|
#include "info/profile/info_profile_actions.h"
|
||||||
|
|
||||||
|
#include "ayu/ayu_settings.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
@ -15,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/notify/data_notify_settings.h"
|
#include "data/notify/data_notify_settings.h"
|
||||||
|
#include "ui/text/text_entity.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
@ -67,6 +69,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
|
|
||||||
|
#include "ayu/utils/ayu_profile_values.h"
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -283,6 +287,8 @@ bool SetClickContext(
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
|
auto settings = &AyuSettings::getInstance();
|
||||||
|
|
||||||
auto result = object_ptr<Ui::VerticalLayout>(_wrap);
|
auto result = object_ptr<Ui::VerticalLayout>(_wrap);
|
||||||
auto tracker = Ui::MultiSlideTracker();
|
auto tracker = Ui::MultiSlideTracker();
|
||||||
|
|
||||||
|
@ -475,6 +481,29 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings->showPeerId != 0) {
|
||||||
|
auto idDrawableText = IDValue(
|
||||||
|
user
|
||||||
|
) | rpl::map([](TextWithEntities &&text) {
|
||||||
|
return Ui::Text::Code(text.text);
|
||||||
|
});
|
||||||
|
auto idInfo = addInfoOneLine(
|
||||||
|
rpl::single(QString("ID")),
|
||||||
|
std::move(idDrawableText),
|
||||||
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
|
);
|
||||||
|
|
||||||
|
idInfo.text->setClickHandlerFilter([=](auto &&...) {
|
||||||
|
const auto idText = IDString(user);
|
||||||
|
if (!idText.isEmpty()) {
|
||||||
|
QGuiApplication::clipboard()->setText(idText);
|
||||||
|
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
||||||
|
controller->showToast(msg);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
AddMainButton(
|
AddMainButton(
|
||||||
result,
|
result,
|
||||||
tr::lng_info_add_as_contact(),
|
tr::lng_info_add_as_contact(),
|
||||||
|
@ -535,6 +564,29 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
if (!_topic) {
|
if (!_topic) {
|
||||||
addTranslateToMenu(about.text, AboutValue(_peer));
|
addTranslateToMenu(about.text, AboutValue(_peer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings->showPeerId != 0) {
|
||||||
|
auto idDrawableText = IDValue(
|
||||||
|
_peer
|
||||||
|
) | rpl::map([](TextWithEntities &&text) {
|
||||||
|
return Ui::Text::Code(text.text);
|
||||||
|
});
|
||||||
|
auto idInfo = addInfoOneLine(
|
||||||
|
rpl::single(QString("ID")),
|
||||||
|
std::move(idDrawableText),
|
||||||
|
tr::ayu_ContextCopyID(tr::now)
|
||||||
|
);
|
||||||
|
|
||||||
|
idInfo.text->setClickHandlerFilter([=, peer = _peer](auto &&...) {
|
||||||
|
const auto idText = IDString(peer);
|
||||||
|
if (!idText.isEmpty()) {
|
||||||
|
QGuiApplication::clipboard()->setText(idText);
|
||||||
|
const auto msg = tr::ayu_IDCopiedToast(tr::now);
|
||||||
|
controller->showToast(msg);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!_peer->isSelf()) {
|
if (!_peer->isSelf()) {
|
||||||
// No notifications toggle for Self => no separator.
|
// No notifications toggle for Self => no separator.
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "window/window_main_menu.h"
|
#include "window/window_main_menu.h"
|
||||||
|
|
||||||
|
#include "lang_auto.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -845,9 +846,9 @@ void MainMenu::setupMenu() {
|
||||||
|
|
||||||
const auto settings = &AyuSettings::getInstance();
|
const auto settings = &AyuSettings::getInstance();
|
||||||
_ghostModeToggle = addAction(
|
_ghostModeToggle = addAction(
|
||||||
rpl::single(QString("Ghost Mode")),
|
tr::ayu_DrawerGhostModeToggle(),
|
||||||
{ &st::menuIconFake, kIconPurple }
|
{ &st::menuIconFake, kIconPurple }
|
||||||
)->toggleOn(AyuSettings::get_ghostModeEnabled().value());
|
)->toggleOn(AyuSettings::get_ghostModeEnabled());
|
||||||
|
|
||||||
_ghostModeToggle->toggledChanges(
|
_ghostModeToggle->toggledChanges(
|
||||||
) | rpl::start_with_next([=](bool ghostMode) {
|
) | rpl::start_with_next([=](bool ghostMode) {
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
{
|
{
|
||||||
"SettingsWatermark": "AyuGram developed and maintained by Radolyn Labs"
|
"SettingsWatermark": "AyuGram developed and maintained by Radolyn Labs",
|
||||||
|
"SettingsShowID": "Show peer ID",
|
||||||
|
"SettingsShowID_Hide": "Hide",
|
||||||
|
"ContextCopyID": "Copy ID",
|
||||||
|
"IDCopiedToast": "ID copied to clipboard.",
|
||||||
|
"DrawerGhostModeToggle": "Ghost Mode"
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue