mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
disableNotificationsDelay = false;
|
||||||
localPremium = false;
|
localPremium = false;
|
||||||
copyUsernameAsLink = true;
|
|
||||||
|
|
||||||
// ~ Customization
|
// ~ Customization
|
||||||
appIcon = AyuAssets::DEFAULT_ICON;
|
appIcon = AyuAssets::DEFAULT_ICON;
|
||||||
|
@ -341,10 +340,6 @@ void AyuGramSettings::set_localPremium(bool val) {
|
||||||
localPremium = val;
|
localPremium = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AyuGramSettings::set_copyUsernameAsLink(bool val) {
|
|
||||||
copyUsernameAsLink = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AyuGramSettings::set_appIcon(QString val) {
|
void AyuGramSettings::set_appIcon(QString val) {
|
||||||
appIcon = std::move(val);
|
appIcon = std::move(val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ public:
|
||||||
|
|
||||||
bool disableNotificationsDelay;
|
bool disableNotificationsDelay;
|
||||||
bool localPremium;
|
bool localPremium;
|
||||||
bool copyUsernameAsLink;
|
|
||||||
|
|
||||||
QString appIcon;
|
QString appIcon;
|
||||||
bool simpleQuotesAndReplies;
|
bool simpleQuotesAndReplies;
|
||||||
|
@ -98,7 +97,6 @@ public:
|
||||||
|
|
||||||
void set_disableNotificationsDelay(bool val);
|
void set_disableNotificationsDelay(bool val);
|
||||||
void set_localPremium(bool val);
|
void set_localPremium(bool val);
|
||||||
void set_copyUsernameAsLink(bool val);
|
|
||||||
|
|
||||||
void set_appIcon(QString val);
|
void set_appIcon(QString val);
|
||||||
void set_simpleQuotesAndReplies(bool val);
|
void set_simpleQuotesAndReplies(bool val);
|
||||||
|
@ -153,7 +151,6 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
||||||
hideSimilarChannels,
|
hideSimilarChannels,
|
||||||
disableNotificationsDelay,
|
disableNotificationsDelay,
|
||||||
localPremium,
|
localPremium,
|
||||||
copyUsernameAsLink,
|
|
||||||
appIcon,
|
appIcon,
|
||||||
simpleQuotesAndReplies,
|
simpleQuotesAndReplies,
|
||||||
deletedMark,
|
deletedMark,
|
||||||
|
|
|
@ -729,25 +729,6 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
|
||||||
AyuSettings::save();
|
AyuSettings::save();
|
||||||
},
|
},
|
||||||
container->lifetime());
|
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) {
|
void SetupAppIcon(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
|
@ -132,8 +132,6 @@ base::options::toggle ShowPeerIdBelowAbout({
|
||||||
const QString &addToLink) {
|
const QString &addToLink) {
|
||||||
const auto weak = base::make_weak(controller);
|
const auto weak = base::make_weak(controller);
|
||||||
return [=](QString link) {
|
return [=](QString link) {
|
||||||
auto settings = &AyuSettings::getInstance();
|
|
||||||
|
|
||||||
if (link.startsWith(u"internal:"_q)) {
|
if (link.startsWith(u"internal:"_q)) {
|
||||||
Core::App().openInternalUrl(link,
|
Core::App().openInternalUrl(link,
|
||||||
QVariant::fromValue(ClickHandlerContext{
|
QVariant::fromValue(ClickHandlerContext{
|
||||||
|
@ -1218,6 +1216,37 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
linkLine.text->overrideLinkClickHandler(linkCallback);
|
linkLine.text->overrideLinkClickHandler(linkCallback);
|
||||||
linkLine.subtext->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()) {
|
if (const auto channel = _topic ? nullptr : _peer->asChannel()) {
|
||||||
auto locationText = LocationValue(
|
auto locationText = LocationValue(
|
||||||
channel
|
channel
|
||||||
|
|
|
@ -26,10 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtCore/QRegularExpression>
|
#include <QtCore/QRegularExpression>
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
|
|
||||||
// AyuGram includes
|
|
||||||
#include "ayu/ayu_settings.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -192,22 +188,11 @@ void CollectibleInfoBox(
|
||||||
Ui::Text::Link(formatted),
|
Ui::Text::Link(formatted),
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
const auto copyCallback = [box, type, formatted, text = info.copyText] {
|
const auto copyCallback = [box, type, formatted, text = info.copyText] {
|
||||||
auto toCopy = text.isEmpty() ? formatted : text;
|
QGuiApplication::clipboard()->setText(
|
||||||
const auto settings = &AyuSettings::getInstance();
|
text.isEmpty() ? formatted : text);
|
||||||
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);
|
|
||||||
box->uiShow()->showToast((type == CollectibleType::Phone)
|
box->uiShow()->showToast((type == CollectibleType::Phone)
|
||||||
? tr::lng_text_copied(tr::now)
|
? tr::lng_text_copied(tr::now)
|
||||||
: settings->copyUsernameAsLink
|
: tr::lng_username_copied(tr::now));
|
||||||
? tr::lng_username_copied(tr::now) // "Link copied to clipboard."
|
|
||||||
: tr::lng_text_copied(tr::now)); // "Text copied to clipboard."
|
|
||||||
};
|
};
|
||||||
box->addRow(
|
box->addRow(
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 365acef6ddd58f7a19d82588ea986e23517861b7
|
Subproject commit 07cda692d99a9acdea6406516fead0a1517ab032
|
Loading…
Add table
Reference in a new issue