Moved menu item with check to td_ui.
This commit is contained in:
		
							parent
							
								
									2846aa2f77
								
							
						
					
					
						commit
						51cb234b37
					
				
					 5 changed files with 75 additions and 40 deletions
				
			
		|  | @ -21,12 +21,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "ui/widgets/buttons.h" | ||||
| #include "ui/widgets/scroll_area.h" | ||||
| #include "ui/widgets/input_fields.h" | ||||
| #include "ui/widgets/menu/menu_action.h" | ||||
| #include "ui/widgets/popup_menu.h" | ||||
| #include "ui/wrap/slide_wrap.h" | ||||
| #include "ui/text/text_options.h" | ||||
| #include "ui/text/text_utilities.h" | ||||
| #include "chat_helpers/message_field.h" | ||||
| #include "menu/menu_check_item.h" | ||||
| #include "menu/menu_send.h" | ||||
| #include "history/history.h" | ||||
| #include "history/history_message.h" | ||||
|  | @ -49,47 +49,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "styles/style_boxes.h" | ||||
| #include "styles/style_chat.h" | ||||
| #include "styles/style_menu_icons.h" | ||||
| #include "styles/style_media_player.h" | ||||
| 
 | ||||
| #include <QtGui/QGuiApplication> | ||||
| #include <QtGui/QClipboard> | ||||
| 
 | ||||
| namespace { | ||||
| 
 | ||||
| class ForwardOptionItem final : public Ui::Menu::Action { | ||||
| public: | ||||
| 	using Ui::Menu::Action::Action; | ||||
| 
 | ||||
| 	void init(bool checked) { | ||||
| 		enableMouseSelecting(); | ||||
| 
 | ||||
| 		AbstractButton::setDisabled(true); | ||||
| 
 | ||||
| 		_checkView = std::make_unique<Ui::CheckView>(st::defaultCheck, false); | ||||
| 		_checkView->checkedChanges( | ||||
| 		) | rpl::start_with_next([=](bool checked) { | ||||
| 			setIcon(checked ? &st::mediaPlayerMenuCheck : nullptr); | ||||
| 		}, lifetime()); | ||||
| 
 | ||||
| 		_checkView->setChecked(checked, anim::type::normal); | ||||
| 		AbstractButton::clicks( | ||||
| 		) | rpl::start_with_next([=] { | ||||
| 			_checkView->setChecked( | ||||
| 				!_checkView->checked(), | ||||
| 				anim::type::normal); | ||||
| 		}, lifetime()); | ||||
| 	} | ||||
| 
 | ||||
| 	not_null<Ui::CheckView*> checkView() const { | ||||
| 		return _checkView.get(); | ||||
| 	} | ||||
| 
 | ||||
| private: | ||||
| 	std::unique_ptr<Ui::CheckView> _checkView; | ||||
| }; | ||||
| 
 | ||||
| } // namespace
 | ||||
| 
 | ||||
| class ShareBox::Inner final : public Ui::RpWidget { | ||||
| public: | ||||
| 	Inner(QWidget *parent, const Descriptor &descriptor); | ||||
|  | @ -503,7 +466,7 @@ void ShareBox::showMenu(not_null<Ui::RpWidget*> parent) { | |||
| 
 | ||||
| 	if (_descriptor.forwardOptions.show) { | ||||
| 		auto createView = [&](rpl::producer<QString> &&text, bool checked) { | ||||
| 			auto item = base::make_unique_q<ForwardOptionItem>( | ||||
| 			auto item = base::make_unique_q<Menu::ItemWithCheck>( | ||||
| 				_menu->menu(), | ||||
| 				st::popupMenuWithIcons.menu, | ||||
| 				new QAction(QString(), _menu->menu()), | ||||
|  |  | |||
							
								
								
									
										39
									
								
								Telegram/SourceFiles/menu/menu_check_item.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								Telegram/SourceFiles/menu/menu_check_item.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| /*
 | ||||
| This file is part of Telegram Desktop, | ||||
| the official desktop application for the Telegram messaging service. | ||||
| 
 | ||||
| For license and copyright information please follow this link: | ||||
| https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | ||||
| */ | ||||
| #include "menu/menu_check_item.h" | ||||
| 
 | ||||
| #include "ui/widgets/checkbox.h" | ||||
| #include "styles/style_media_player.h" | ||||
| 
 | ||||
| namespace Menu { | ||||
| 
 | ||||
| void ItemWithCheck::init(bool checked) { | ||||
| 	enableMouseSelecting(); | ||||
| 
 | ||||
| 	AbstractButton::setDisabled(true); | ||||
| 
 | ||||
| 	_checkView = std::make_unique<Ui::CheckView>(st::defaultCheck, false); | ||||
| 	_checkView->checkedChanges( | ||||
| 	) | rpl::start_with_next([=](bool checked) { | ||||
| 		setIcon(checked ? &st::mediaPlayerMenuCheck : nullptr); | ||||
| 	}, lifetime()); | ||||
| 
 | ||||
| 	_checkView->setChecked(checked, anim::type::normal); | ||||
| 	AbstractButton::clicks( | ||||
| 	) | rpl::start_with_next([=] { | ||||
| 		_checkView->setChecked( | ||||
| 			!_checkView->checked(), | ||||
| 			anim::type::normal); | ||||
| 	}, lifetime()); | ||||
| } | ||||
| 
 | ||||
| not_null<Ui::CheckView*> ItemWithCheck::checkView() const { | ||||
| 	return _checkView.get(); | ||||
| } | ||||
| 
 | ||||
| } // namespace Menu
 | ||||
							
								
								
									
										30
									
								
								Telegram/SourceFiles/menu/menu_check_item.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								Telegram/SourceFiles/menu/menu_check_item.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,30 @@ | |||
| /*
 | ||||
| This file is part of Telegram Desktop, | ||||
| the official desktop application for the Telegram messaging service. | ||||
| 
 | ||||
| For license and copyright information please follow this link: | ||||
| https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | ||||
| */ | ||||
| #pragma once | ||||
| 
 | ||||
| #include "ui/widgets/menu/menu_action.h" | ||||
| 
 | ||||
| namespace Ui { | ||||
| class CheckView; | ||||
| } // namespace Ui
 | ||||
| 
 | ||||
| namespace Menu { | ||||
| 
 | ||||
| class ItemWithCheck final : public Ui::Menu::Action { | ||||
| public: | ||||
| 	using Ui::Menu::Action::Action; | ||||
| 
 | ||||
| 	void init(bool checked); | ||||
| 
 | ||||
| 	not_null<Ui::CheckView*> checkView() const; | ||||
| 
 | ||||
| private: | ||||
| 	std::unique_ptr<Ui::CheckView> _checkView; | ||||
| }; | ||||
| 
 | ||||
| } // namespace Menu
 | ||||
|  | @ -102,6 +102,9 @@ PRIVATE | |||
|     media/player/media_player_dropdown.cpp | ||||
|     media/player/media_player_dropdown.h | ||||
| 
 | ||||
|     menu/menu_check_item.cpp | ||||
|     menu/menu_check_item.h | ||||
| 
 | ||||
|     passport/ui/passport_details_row.cpp | ||||
|     passport/ui/passport_details_row.h | ||||
|     passport/ui/passport_form_row.cpp | ||||
|  |  | |||
|  | @ -1 +1 @@ | |||
| Subproject commit a0b04da1d95a67d1ba431b7652026bd72d86962e | ||||
| Subproject commit 62002f034bbfd3e5f78a71317f37c685a8846b1f | ||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 23rd
						23rd