mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
feat: copy username for channels too
fix: purge useless
This commit is contained in:
parent
f54c82bcb3
commit
cc16922673
6 changed files with 35 additions and 48 deletions
|
@ -207,7 +207,6 @@ AyuGramSettings::AyuGramSettings() {
|
|||
|
||||
disableNotificationsDelay = false;
|
||||
localPremium = false;
|
||||
copyUsernameAsLink = true;
|
||||
|
||||
// ~ Customization
|
||||
appIcon = AyuAssets::DEFAULT_ICON;
|
||||
|
@ -341,10 +340,6 @@ void AyuGramSettings::set_localPremium(bool val) {
|
|||
localPremium = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_copyUsernameAsLink(bool val) {
|
||||
copyUsernameAsLink = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_appIcon(QString val) {
|
||||
appIcon = std::move(val);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ public:
|
|||
|
||||
bool disableNotificationsDelay;
|
||||
bool localPremium;
|
||||
bool copyUsernameAsLink;
|
||||
|
||||
QString appIcon;
|
||||
bool simpleQuotesAndReplies;
|
||||
|
@ -98,7 +97,6 @@ public:
|
|||
|
||||
void set_disableNotificationsDelay(bool val);
|
||||
void set_localPremium(bool val);
|
||||
void set_copyUsernameAsLink(bool val);
|
||||
|
||||
void set_appIcon(QString val);
|
||||
void set_simpleQuotesAndReplies(bool val);
|
||||
|
@ -153,7 +151,6 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
|||
hideSimilarChannels,
|
||||
disableNotificationsDelay,
|
||||
localPremium,
|
||||
copyUsernameAsLink,
|
||||
appIcon,
|
||||
simpleQuotesAndReplies,
|
||||
deletedMark,
|
||||
|
|
|
@ -729,25 +729,6 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
|
|||
AyuSettings::save();
|
||||
},
|
||||
container->lifetime());
|
||||
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_CopyUsernameAsLink(),
|
||||
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 SetupAppIcon(not_null<Ui::VerticalLayout*> container) {
|
||||
|
|
|
@ -132,8 +132,6 @@ base::options::toggle ShowPeerIdBelowAbout({
|
|||
const QString &addToLink) {
|
||||
const auto weak = base::make_weak(controller);
|
||||
return [=](QString link) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
if (link.startsWith(u"internal:"_q)) {
|
||||
Core::App().openInternalUrl(link,
|
||||
QVariant::fromValue(ClickHandlerContext{
|
||||
|
@ -1218,6 +1216,37 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
linkLine.text->overrideLinkClickHandler(linkCallback);
|
||||
linkLine.subtext->overrideLinkClickHandler(linkCallback);
|
||||
|
||||
const auto hook = [=](Ui::FlatLabel::ContextMenuRequest request)
|
||||
{
|
||||
if (!request.link) {
|
||||
return;
|
||||
}
|
||||
const auto text = request.link->copyToClipboardContextItemText();
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
const auto link = request.link->copyToClipboardText();
|
||||
request.menu->addAction(
|
||||
text,
|
||||
[=] { QGuiApplication::clipboard()->setText(link); });
|
||||
const auto last = link.lastIndexOf('/');
|
||||
if (last < 0) {
|
||||
return;
|
||||
}
|
||||
const auto mention = '@' + link.mid(last + 1);
|
||||
if (mention.size() < 2) {
|
||||
return;
|
||||
}
|
||||
request.menu->addAction(
|
||||
tr::lng_context_copy_mention(tr::now),
|
||||
[=] { QGuiApplication::clipboard()->setText(mention); });
|
||||
};
|
||||
|
||||
if (!_topic) {
|
||||
linkLine.text->setContextMenuHook(hook);
|
||||
linkLine.subtext->setContextMenuHook(hook);
|
||||
}
|
||||
|
||||
if (const auto channel = _topic ? nullptr : _peer->asChannel()) {
|
||||
auto locationText = LocationValue(
|
||||
channel
|
||||
|
|
|
@ -26,10 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtCore/QRegularExpression>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
|
@ -192,22 +188,11 @@ void CollectibleInfoBox(
|
|||
Ui::Text::Link(formatted),
|
||||
Ui::Text::WithEntities);
|
||||
const auto copyCallback = [box, type, formatted, text = info.copyText] {
|
||||
auto toCopy = text.isEmpty() ? formatted : text;
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
if (type == CollectibleType::Username) {
|
||||
if (settings->copyUsernameAsLink && !text.startsWith("https://")) {
|
||||
toCopy = "https://t.me/" + toCopy.replace("@", "");
|
||||
} else if (!settings->copyUsernameAsLink && !text.startsWith("@")) {
|
||||
toCopy = "@" + toCopy.replace("https://t.me/", "");
|
||||
}
|
||||
}
|
||||
|
||||
QGuiApplication::clipboard()->setText(toCopy);
|
||||
QGuiApplication::clipboard()->setText(
|
||||
text.isEmpty() ? formatted : text);
|
||||
box->uiShow()->showToast((type == CollectibleType::Phone)
|
||||
? tr::lng_text_copied(tr::now)
|
||||
: settings->copyUsernameAsLink
|
||||
? tr::lng_username_copied(tr::now) // "Link copied to clipboard."
|
||||
: tr::lng_text_copied(tr::now)); // "Text copied to clipboard."
|
||||
: tr::lng_username_copied(tr::now));
|
||||
};
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 365acef6ddd58f7a19d82588ea986e23517861b7
|
||||
Subproject commit 07cda692d99a9acdea6406516fead0a1517ab032
|
Loading…
Add table
Reference in a new issue