Removed redundant hasSubmenu property from menu item base.
This commit is contained in:
		
							parent
							
								
									43f09755e5
								
							
						
					
					
						commit
						0ce0766b5e
					
				
					 4 changed files with 6 additions and 14 deletions
				
			
		| 
						 | 
					@ -65,7 +65,6 @@ Action::Action(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	initResizeHook(parent->sizeValue());
 | 
						initResizeHook(parent->sizeValue());
 | 
				
			||||||
	processAction();
 | 
						processAction();
 | 
				
			||||||
	setHasSubmenu(action->menu() != nullptr);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	paintRequest(
 | 
						paintRequest(
 | 
				
			||||||
	) | rpl::start_with_next([=] {
 | 
						) | rpl::start_with_next([=] {
 | 
				
			||||||
| 
						 | 
					@ -78,6 +77,10 @@ Action::Action(
 | 
				
			||||||
	connect(_action, &QAction::changed, [=] { processAction(); });
 | 
						connect(_action, &QAction::changed, [=] { processAction(); });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool Action::hasSubmenu() const {
 | 
				
			||||||
 | 
						return _action->menu() != nullptr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Action::paint(Painter &p) {
 | 
					void Action::paint(Painter &p) {
 | 
				
			||||||
	const auto enabled = _action->isEnabled();
 | 
						const auto enabled = _action->isEnabled();
 | 
				
			||||||
	const auto selected = isSelected();
 | 
						const auto selected = isSelected();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,8 @@ private:
 | 
				
			||||||
	void processAction();
 | 
						void processAction();
 | 
				
			||||||
	void paint(Painter &p);
 | 
						void paint(Painter &p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool hasSubmenu() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Text::String _text;
 | 
						Text::String _text;
 | 
				
			||||||
	QString _shortcut;
 | 
						QString _shortcut;
 | 
				
			||||||
	const not_null<QAction*> _action;
 | 
						const not_null<QAction*> _action;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,14 +77,6 @@ int ItemBase::minWidth() const {
 | 
				
			||||||
	return _minWidth.current();
 | 
						return _minWidth.current();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool ItemBase::hasSubmenu() const {
 | 
					 | 
				
			||||||
	return _hasSubmenu;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ItemBase::setHasSubmenu(bool value) {
 | 
					 | 
				
			||||||
	_hasSubmenu = value;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ItemBase::init() {
 | 
					void ItemBase::init() {
 | 
				
			||||||
	events(
 | 
						events(
 | 
				
			||||||
	) | rpl::filter([=](not_null<QEvent*> e) {
 | 
						) | rpl::filter([=](not_null<QEvent*> e) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,9 +36,6 @@ public:
 | 
				
			||||||
	int minWidth() const;
 | 
						int minWidth() const;
 | 
				
			||||||
	void setMinWidth(int w);
 | 
						void setMinWidth(int w);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool hasSubmenu() const;
 | 
					 | 
				
			||||||
	void setHasSubmenu(bool value);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	virtual void handleKeyPress(not_null<QKeyEvent*> e) {
 | 
						virtual void handleKeyPress(not_null<QKeyEvent*> e) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,8 +55,6 @@ protected:
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	int _index = -1;
 | 
						int _index = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool _hasSubmenu = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	rpl::variable<bool> _selected = false;
 | 
						rpl::variable<bool> _selected = false;
 | 
				
			||||||
	rpl::event_stream<> _clicks;
 | 
						rpl::event_stream<> _clicks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue