mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
feat: confirmation while attempting to send sticker (changeable in settings)
This commit is contained in:
parent
7450d3fc4d
commit
a1aac455db
6 changed files with 77 additions and 7 deletions
|
@ -366,6 +366,7 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) {
|
|||
const auto itemId = item->id;
|
||||
const auto topicRootId = item->topicRootId();
|
||||
const auto history = item->history();
|
||||
|
||||
controller->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_bot_share_phone(),
|
||||
.confirmed = [=] {
|
||||
|
|
|
@ -145,6 +145,14 @@ namespace AyuSettings {
|
|||
showMessageSeconds = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_stickerConfirmation(bool val) {
|
||||
stickerConfirmation = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_GIFConfirmation(bool val) {
|
||||
GIFConfirmation = val;
|
||||
}
|
||||
|
||||
rpl::producer<QString> get_deletedMarkReactive() {
|
||||
return deletedMarkReactive.value();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ namespace AyuSettings {
|
|||
recentStickersCount = 20;
|
||||
showGhostToggleInDrawer = true;
|
||||
|
||||
// ~ Beta functionality
|
||||
stickerConfirmation = false;
|
||||
GIFConfirmation = false;
|
||||
|
||||
/*
|
||||
* showPeerId = 0 means no ID shown
|
||||
* showPeerId = 1 means ID shown as for Telegram API devs
|
||||
|
@ -78,6 +82,10 @@ namespace AyuSettings {
|
|||
|
||||
QS_FIELD(bool, showMessageSeconds)
|
||||
|
||||
QS_FIELD(bool, stickerConfirmation)
|
||||
|
||||
QS_FIELD(bool, GIFConfirmation)
|
||||
|
||||
public:
|
||||
void set_sendReadPackets(bool val);
|
||||
void set_sendOnlinePackets(bool val);
|
||||
|
@ -99,6 +107,9 @@ namespace AyuSettings {
|
|||
void set_showGhostToggleInDrawer(bool val);
|
||||
void set_showPeerId(int val);
|
||||
void set_showMessageSeconds(bool val);
|
||||
|
||||
void set_stickerConfirmation(bool val);
|
||||
void set_GIFConfirmation(bool val);
|
||||
};
|
||||
|
||||
AyuGramSettings &getInstance();
|
||||
|
|
|
@ -242,6 +242,8 @@ namespace Settings {
|
|||
AddDividerText(container, tr::ayu_SettingsCustomizationHint());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Ayu::SetupShowPeerId(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
|
@ -316,6 +318,26 @@ namespace Settings {
|
|||
});
|
||||
}
|
||||
|
||||
void Ayu::SetupBetaFunctions(not_null<Ui::VerticalLayout *> container) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
AddSubsectionTitle(container, rpl::single(QString("Beta functions")));
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
rpl::single(QString("Send sticker confirmation")),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(settings->stickerConfirmation)
|
||||
)->toggledValue(
|
||||
) | rpl::filter([=] (bool enabled) {
|
||||
return (enabled != settings->stickerConfirmation);
|
||||
}) | rpl::start_with_next([=] (bool enabled) {
|
||||
settings->set_stickerConfirmation(enabled);
|
||||
AyuSettings::save();
|
||||
}, container->lifetime());
|
||||
}
|
||||
|
||||
void Ayu::SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller) {
|
||||
AddSkip(container);
|
||||
SetupGhostEssentials(container);
|
||||
|
@ -335,6 +357,9 @@ namespace Settings {
|
|||
AddSkip(container);
|
||||
SetupCustomization(container, controller);
|
||||
|
||||
AddSkip(container);
|
||||
SetupBetaFunctions(container);
|
||||
|
||||
AddDividerText(container, tr::ayu_SettingsWatermark());
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace Settings {
|
|||
void SetupShowPeerId(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> controller);
|
||||
void SetupRecentStickersLimitSlider(not_null<Ui::VerticalLayout *> container);
|
||||
|
||||
void SetupBetaFunctions(not_null<Ui::VerticalLayout *> container);
|
||||
|
||||
void SetupAyuGramSettings(not_null<Ui::VerticalLayout *> container, not_null<Window::SessionController *> null);
|
||||
void setupContent(not_null<Window::SessionController *> controller);
|
||||
};
|
||||
|
|
|
@ -1710,13 +1710,36 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
if (e->modifiers() & Qt::ControlModifier) {
|
||||
showStickerSetBox(document);
|
||||
} else {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
.messageSendingFrom = messageSentAnimationInfo(
|
||||
sticker->section,
|
||||
sticker->index,
|
||||
document),
|
||||
});
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
if (settings->stickerConfirmation) {
|
||||
// it is necessary to store it here, because section & index can be changed by cursor position (guess)
|
||||
int currentSection = sticker->section;
|
||||
int currentIndex = sticker->index;
|
||||
auto sendStickerCallback = [=, this] {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
.messageSendingFrom = messageSentAnimationInfo(
|
||||
currentSection,
|
||||
currentIndex,
|
||||
document),
|
||||
});
|
||||
};
|
||||
|
||||
Ui::show(Ui::MakeConfirmBox({
|
||||
.text = rpl::single(QString("Do you want to send sticker?")),
|
||||
.confirmed = sendStickerCallback,
|
||||
.confirmText = rpl::single(QString("Send")),
|
||||
}));
|
||||
}
|
||||
else {
|
||||
_chosen.fire({
|
||||
.document = document,
|
||||
.messageSendingFrom = messageSentAnimationInfo(
|
||||
sticker->section,
|
||||
sticker->index,
|
||||
document),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (auto set = std::get_if<OverSet>(&pressed)) {
|
||||
Assert(set->section >= 0 && set->section < sets.size());
|
||||
|
|
Loading…
Add table
Reference in a new issue