mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
feat: copy username
as @username
This commit is contained in:
parent
67df965f92
commit
c0898e1662
5 changed files with 49 additions and 10 deletions
|
@ -230,6 +230,11 @@ namespace AyuSettings
|
|||
voiceConfirmation = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_copyUsernameAsLink(bool val)
|
||||
{
|
||||
copyUsernameAsLink = val;
|
||||
}
|
||||
|
||||
bool get_ghostModeEnabled()
|
||||
{
|
||||
return ghostModeEnabled.current();
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace AyuSettings
|
|||
|
||||
// ~ QoL toggles
|
||||
enableAds = false;
|
||||
copyUsernameAsLink = true;
|
||||
|
||||
// ~ Customization
|
||||
deletedMark = "🧹";
|
||||
|
@ -75,6 +76,7 @@ namespace AyuSettings
|
|||
bool stickerConfirmation;
|
||||
bool GIFConfirmation;
|
||||
bool voiceConfirmation;
|
||||
bool copyUsernameAsLink;
|
||||
|
||||
public:
|
||||
void set_sendReadPackets(bool val);
|
||||
|
@ -112,6 +114,8 @@ namespace AyuSettings
|
|||
void set_GIFConfirmation(bool val);
|
||||
|
||||
void set_voiceConfirmation(bool val);
|
||||
|
||||
void set_copyUsernameAsLink(bool val);
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(
|
||||
|
@ -133,7 +137,8 @@ namespace AyuSettings
|
|||
showMessageSeconds,
|
||||
stickerConfirmation,
|
||||
GIFConfirmation,
|
||||
voiceConfirmation
|
||||
voiceConfirmation,
|
||||
copyUsernameAsLink
|
||||
);
|
||||
|
||||
AyuGramSettings& getInstance();
|
||||
|
@ -152,4 +157,4 @@ namespace AyuSettings
|
|||
bool get_ghostModeEnabled();
|
||||
|
||||
rpl::producer<bool> get_ghostModeEnabledReactive();
|
||||
}
|
||||
}
|
|
@ -23,7 +23,9 @@
|
|||
#include "platform/platform_specific.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "styles/style_basic.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_widgets.h"
|
||||
#include "ui/boxes/single_choice_box.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
|
@ -209,6 +211,22 @@ namespace Settings
|
|||
settings->set_enableAds(enabled);
|
||||
AyuSettings::save();
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
rpl::single(QString("Copy username as link")),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(settings->copyUsernameAsLink)
|
||||
)->toggledValue(
|
||||
) | rpl::filter([=](bool enabled)
|
||||
{
|
||||
return (enabled != settings->copyUsernameAsLink);
|
||||
}) | start_with_next([=](bool enabled)
|
||||
{
|
||||
settings->set_copyUsernameAsLink(enabled);
|
||||
AyuSettings::save();
|
||||
}, container->lifetime());
|
||||
}
|
||||
|
||||
void Ayu::SetupCustomization(not_null<Ui::VerticalLayout*> container,
|
||||
|
@ -381,7 +399,7 @@ namespace Settings
|
|||
});
|
||||
}
|
||||
|
||||
void Ayu::SetupBetaFunctions(not_null<Ui::VerticalLayout*> container)
|
||||
void Ayu::SetupSendConfirmations(not_null<Ui::VerticalLayout*> container)
|
||||
{
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
|
@ -463,8 +481,8 @@ namespace Settings
|
|||
AddDivider(container);
|
||||
|
||||
AddSkip(container);
|
||||
SetupBetaFunctions(container);
|
||||
|
||||
SetupSendConfirmations(container);
|
||||
|
||||
AddDividerText(container, tr::ayu_SettingsWatermark());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Settings
|
|||
|
||||
void SetupAyuSync(not_null<Ui::VerticalLayout*> container);
|
||||
|
||||
void SetupBetaFunctions(not_null<Ui::VerticalLayout*> container);
|
||||
void SetupSendConfirmations(not_null<Ui::VerticalLayout*> container);
|
||||
|
||||
void SetupAyuGramSettings(not_null<Ui::VerticalLayout*> container, not_null<Window::SessionController*> null);
|
||||
|
||||
|
|
|
@ -110,11 +110,22 @@ namespace {
|
|||
std::shared_ptr<Ui::Show> show,
|
||||
const QString &addToLink) {
|
||||
return [=](QString link) {
|
||||
if (!link.startsWith(u"https://"_q)) {
|
||||
link = peer->session().createInternalLinkFull(peer->userName())
|
||||
+ addToLink;
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (!settings->copyUsernameAsLink)
|
||||
{
|
||||
link = '@' + peer->userName();
|
||||
}
|
||||
if (!link.isEmpty()) {
|
||||
else
|
||||
{
|
||||
if (!link.startsWith(u"https://"_q))
|
||||
{
|
||||
link = peer->session().createInternalLinkFull(peer->userName())
|
||||
+ addToLink;
|
||||
}
|
||||
}
|
||||
|
||||
if (!link.isEmpty())
|
||||
{
|
||||
QGuiApplication::clipboard()->setText(link);
|
||||
show->showToast(tr::lng_username_copied(tr::now));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue