Pass Qt::Edges to updateCursor and startResize
This commit is contained in:
		
							parent
							
								
									212944d89c
								
							
						
					
					
						commit
						d8cc7a9b50
					
				
					 2 changed files with 8 additions and 9 deletions
				
			
		| 
						 | 
					@ -105,15 +105,16 @@ bool TitleWidgetQt::eventFilter(QObject *obj, QEvent *e) {
 | 
				
			||||||
		|| e->type() == QEvent::MouseButtonPress) {
 | 
							|| e->type() == QEvent::MouseButtonPress) {
 | 
				
			||||||
		if(window()->isAncestorOf(static_cast<QWidget*>(obj))) {
 | 
							if(window()->isAncestorOf(static_cast<QWidget*>(obj))) {
 | 
				
			||||||
			const auto mouseEvent = static_cast<QMouseEvent*>(e);
 | 
								const auto mouseEvent = static_cast<QMouseEvent*>(e);
 | 
				
			||||||
 | 
								const auto edges = edgesFromPos(mouseEvent->windowPos().toPoint());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (e->type() == QEvent::MouseMove) {
 | 
								if (e->type() == QEvent::MouseMove) {
 | 
				
			||||||
				updateCursor(mouseEvent->windowPos().toPoint());
 | 
									updateCursor(edges);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if(e->type() == QEvent::MouseButtonPress
 | 
								if(e->type() == QEvent::MouseButtonPress
 | 
				
			||||||
				&& mouseEvent->button() == Qt::LeftButton
 | 
									&& mouseEvent->button() == Qt::LeftButton
 | 
				
			||||||
				&& window()->windowState() != Qt::WindowMaximized) {
 | 
									&& window()->windowState() != Qt::WindowMaximized) {
 | 
				
			||||||
				return startResize(mouseEvent->windowPos().toPoint());
 | 
									return startResize(edges);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else if (e->type() == QEvent::Leave) {
 | 
						} else if (e->type() == QEvent::Leave) {
 | 
				
			||||||
| 
						 | 
					@ -195,9 +196,7 @@ Qt::Edges TitleWidgetQt::edgesFromPos(const QPoint &pos) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void TitleWidgetQt::updateCursor(const QPoint &pos) {
 | 
					void TitleWidgetQt::updateCursor(Qt::Edges edges) {
 | 
				
			||||||
	const auto edges = edgesFromPos(pos);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!edges || window()->windowState() == Qt::WindowMaximized) {
 | 
						if (!edges || window()->windowState() == Qt::WindowMaximized) {
 | 
				
			||||||
		while (QGuiApplication::overrideCursor()) {
 | 
							while (QGuiApplication::overrideCursor()) {
 | 
				
			||||||
			QGuiApplication::restoreOverrideCursor();
 | 
								QGuiApplication::restoreOverrideCursor();
 | 
				
			||||||
| 
						 | 
					@ -221,9 +220,9 @@ void TitleWidgetQt::updateCursor(const QPoint &pos) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool TitleWidgetQt::startResize(const QPoint &pos) {
 | 
					bool TitleWidgetQt::startResize(Qt::Edges edges) {
 | 
				
			||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
 | 
					#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) || defined DESKTOP_APP_QT_PATCHED
 | 
				
			||||||
	if (const auto edges = edgesFromPos(pos)) {
 | 
						if (edges) {
 | 
				
			||||||
		return window()->windowHandle()->startSystemResize(edges);
 | 
							return window()->windowHandle()->startSystemResize(edges);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
 | 
					#endif // Qt >= 5.15 || DESKTOP_APP_QT_PATCHED
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,8 +41,8 @@ private:
 | 
				
			||||||
	void updateControlsPosition();
 | 
						void updateControlsPosition();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Qt::Edges edgesFromPos(const QPoint &pos);
 | 
						Qt::Edges edgesFromPos(const QPoint &pos);
 | 
				
			||||||
	void updateCursor(const QPoint &pos);
 | 
						void updateCursor(Qt::Edges edges);
 | 
				
			||||||
	bool startResize(const QPoint &pos);
 | 
						bool startResize(Qt::Edges edges);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const style::WindowTitle &_st;
 | 
						const style::WindowTitle &_st;
 | 
				
			||||||
	object_ptr<Ui::IconButton> _minimize;
 | 
						object_ptr<Ui::IconButton> _minimize;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue