Added ability to disable context menu for RTMP labels.

This commit is contained in:
23rd 2022-02-28 20:55:49 +03:00
parent 069a2814fc
commit 6d46590312
3 changed files with 12 additions and 0 deletions

View file

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "calls/group/calls_group_rtmp.h" #include "calls/group/calls_group_rtmp.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "base/event_filter.h"
#include "calls/group/calls_group_common.h" #include "calls/group/calls_group_common.h"
#include "data/data_peer.h" #include "data/data_peer.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
@ -50,6 +51,7 @@ void StartWithBox(
StartRtmpProcess::FillRtmpRows( StartRtmpProcess::FillRtmpRows(
box->verticalLayout(), box->verticalLayout(),
true, true,
false,
std::move(showBox), std::move(showBox),
std::move(showToast), std::move(showToast),
std::move(data), std::move(data),
@ -199,6 +201,7 @@ void StartRtmpProcess::createBox() {
void StartRtmpProcess::FillRtmpRows( void StartRtmpProcess::FillRtmpRows(
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
bool divider, bool divider,
bool disabledMenuForLabels,
Fn<void(object_ptr<Ui::BoxContent>)> showBox, Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast, Fn<void(QString)> showToast,
rpl::producer<StartRtmpProcess::Data> &&data, rpl::producer<StartRtmpProcess::Data> &&data,
@ -261,6 +264,13 @@ void StartRtmpProcess::FillRtmpRows(
st::boxRowPadding); st::boxRowPadding);
label->setSelectable(true); label->setSelectable(true);
label->setBreakEverywhere(true); label->setBreakEverywhere(true);
if (disabledMenuForLabels) {
base::install_event_filter(label, [=](not_null<QEvent*> e) {
return (e->type() == QEvent::ContextMenu)
? base::EventFilterResult::Cancel
: base::EventFilterResult::Continue;
});
}
return label; return label;
}; };

View file

@ -46,6 +46,7 @@ public:
static void FillRtmpRows( static void FillRtmpRows(
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
bool divider, bool divider,
bool disabledMenuForLabels,
Fn<void(object_ptr<Ui::BoxContent>)> showBox, Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast, Fn<void(QString)> showToast,
rpl::producer<StartRtmpProcess::Data> &&data, rpl::producer<StartRtmpProcess::Data> &&data,

View file

@ -702,6 +702,7 @@ void SettingsBox(
StartRtmpProcess::FillRtmpRows( StartRtmpProcess::FillRtmpRows(
box->verticalLayout(), box->verticalLayout(),
false, false,
true,
[=](object_ptr<Ui::BoxContent> &&object) { [=](object_ptr<Ui::BoxContent> &&object) {
box->getDelegate()->show(std::move(object)); box->getDelegate()->show(std::move(object));
}, },