Returned context menu to RTMP labels with custom style.
This commit is contained in:
		
							parent
							
								
									d1bb87ccec
								
							
						
					
					
						commit
						13aa2196f4
					
				
					 4 changed files with 18 additions and 25 deletions
				
			
		| 
						 | 
					@ -8,7 +8,6 @@ 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"
 | 
				
			||||||
| 
						 | 
					@ -51,14 +50,14 @@ 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),
 | 
				
			||||||
		&st::boxLabel,
 | 
							&st::boxLabel,
 | 
				
			||||||
		&st::groupCallRtmpShowButton,
 | 
							&st::groupCallRtmpShowButton,
 | 
				
			||||||
		&st::settingsSubsectionTitle,
 | 
							&st::settingsSubsectionTitle,
 | 
				
			||||||
		&st::attentionBoxButton);
 | 
							&st::attentionBoxButton,
 | 
				
			||||||
 | 
							&st::defaultPopupMenu);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	box->setTitle(tr::lng_group_call_rtmp_title());
 | 
						box->setTitle(tr::lng_group_call_rtmp_title());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -200,14 +199,14 @@ 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<RtmpInfo> &&data,
 | 
							rpl::producer<RtmpInfo> &&data,
 | 
				
			||||||
		const style::FlatLabel *labelStyle,
 | 
							const style::FlatLabel *labelStyle,
 | 
				
			||||||
		const style::IconButton *showButtonStyle,
 | 
							const style::IconButton *showButtonStyle,
 | 
				
			||||||
		const style::FlatLabel *subsectionTitleStyle,
 | 
							const style::FlatLabel *subsectionTitleStyle,
 | 
				
			||||||
		const style::RoundButton *attentionButtonStyle) {
 | 
							const style::RoundButton *attentionButtonStyle,
 | 
				
			||||||
 | 
							const style::PopupMenu *popupMenuStyle) {
 | 
				
			||||||
	struct State {
 | 
						struct State {
 | 
				
			||||||
		rpl::variable<bool> hidden = true;
 | 
							rpl::variable<bool> hidden = true;
 | 
				
			||||||
		rpl::variable<QString> key;
 | 
							rpl::variable<QString> key;
 | 
				
			||||||
| 
						 | 
					@ -253,21 +252,16 @@ void StartRtmpProcess::FillRtmpRows(
 | 
				
			||||||
		return weak;
 | 
							return weak;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const auto addLabel = [&](
 | 
						const auto addLabel = [&](rpl::producer<QString> &&text) {
 | 
				
			||||||
			rpl::producer<QString> &&text,
 | 
					 | 
				
			||||||
			const style::FlatLabel &st) {
 | 
					 | 
				
			||||||
		const auto label = container->add(
 | 
							const auto label = container->add(
 | 
				
			||||||
			object_ptr<Ui::FlatLabel>(container, std::move(text), st),
 | 
								object_ptr<Ui::FlatLabel>(
 | 
				
			||||||
 | 
									container,
 | 
				
			||||||
 | 
									std::move(text),
 | 
				
			||||||
 | 
									*labelStyle,
 | 
				
			||||||
 | 
									*popupMenuStyle),
 | 
				
			||||||
			st::boxRowPadding + QMargins(0, 0, showButtonStyle->width, 0));
 | 
								st::boxRowPadding + QMargins(0, 0, showButtonStyle->width, 0));
 | 
				
			||||||
		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;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,7 +273,7 @@ void StartRtmpProcess::FillRtmpRows(
 | 
				
			||||||
		subsectionTitleStyle);
 | 
							subsectionTitleStyle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto urlLabelContent = state->url.value();
 | 
						auto urlLabelContent = state->url.value();
 | 
				
			||||||
	addLabel(std::move(urlLabelContent), *labelStyle);
 | 
						addLabel(std::move(urlLabelContent));
 | 
				
			||||||
	container->add(object_ptr<Ui::FixedHeightWidget>(
 | 
						container->add(object_ptr<Ui::FixedHeightWidget>(
 | 
				
			||||||
		container,
 | 
							container,
 | 
				
			||||||
		st::groupCallRtmpUrlSkip));
 | 
							st::groupCallRtmpUrlSkip));
 | 
				
			||||||
| 
						 | 
					@ -313,9 +307,7 @@ void StartRtmpProcess::FillRtmpRows(
 | 
				
			||||||
	}) | rpl::after_next([=] {
 | 
						}) | rpl::after_next([=] {
 | 
				
			||||||
		container->resizeToWidth(container->widthNoMargins());
 | 
							container->resizeToWidth(container->widthNoMargins());
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	const auto streamKeyLabel = addLabel(
 | 
						const auto streamKeyLabel = addLabel(std::move(keyLabelContent));
 | 
				
			||||||
		std::move(keyLabelContent),
 | 
					 | 
				
			||||||
		*labelStyle);
 | 
					 | 
				
			||||||
	streamKeyLabel->setSelectable(false);
 | 
						streamKeyLabel->setSelectable(false);
 | 
				
			||||||
	const auto streamKeyButton = Ui::CreateChild<Ui::IconButton>(
 | 
						const auto streamKeyButton = Ui::CreateChild<Ui::IconButton>(
 | 
				
			||||||
		container.get(),
 | 
							container.get(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ namespace style {
 | 
				
			||||||
struct FlatLabel;
 | 
					struct FlatLabel;
 | 
				
			||||||
struct RoundButton;
 | 
					struct RoundButton;
 | 
				
			||||||
struct IconButton;
 | 
					struct IconButton;
 | 
				
			||||||
 | 
					struct PopupMenu;
 | 
				
			||||||
} // namespace style
 | 
					} // namespace style
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Calls::Group {
 | 
					namespace Calls::Group {
 | 
				
			||||||
| 
						 | 
					@ -42,14 +43,14 @@ 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<RtmpInfo> &&data,
 | 
							rpl::producer<RtmpInfo> &&data,
 | 
				
			||||||
		const style::FlatLabel *labelStyle,
 | 
							const style::FlatLabel *labelStyle,
 | 
				
			||||||
		const style::IconButton *showButtonStyle,
 | 
							const style::IconButton *showButtonStyle,
 | 
				
			||||||
		const style::FlatLabel *subsectionTitleStyle,
 | 
							const style::FlatLabel *subsectionTitleStyle,
 | 
				
			||||||
		const style::RoundButton *attentionButtonStyle);
 | 
							const style::RoundButton *attentionButtonStyle,
 | 
				
			||||||
 | 
							const style::PopupMenu *popupMenuStyle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void requestUrl(bool revoke);
 | 
						void requestUrl(bool revoke);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -696,7 +696,6 @@ 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));
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
| 
						 | 
					@ -709,7 +708,8 @@ void SettingsBox(
 | 
				
			||||||
			&st::groupCallBoxLabel,
 | 
								&st::groupCallBoxLabel,
 | 
				
			||||||
			&st::groupCallSettingsRtmpShowButton,
 | 
								&st::groupCallSettingsRtmpShowButton,
 | 
				
			||||||
			&st::groupCallSubsectionTitle,
 | 
								&st::groupCallSubsectionTitle,
 | 
				
			||||||
			&st::groupCallAttentionBoxButton);
 | 
								&st::groupCallAttentionBoxButton,
 | 
				
			||||||
 | 
								&st::groupCallPopupMenu);
 | 
				
			||||||
		state->data.fire(call->rtmpInfo());
 | 
							state->data.fire(call->rtmpInfo());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1 +1 @@
 | 
				
			||||||
Subproject commit 5f3e04a3199c96385e80025cb8db6c5ee5260345
 | 
					Subproject commit 1ba9270234db8cbe8badbe6f6fbaea0a5869e28d
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue