-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added code compatibility for Qt6; - Replaced deprecated calls (Qt6 only): - MouseEvent::globalPos -> MouseEvent::globalPosition::toPoint; - MouseEvent::globalX -> MouseEvent::globalPosition::toPoint::x; - MouseEvent::globalY -> MouseEvent::globalPosition::toPoint::y. - Applied code macro when necessary. - Updated code samples.
- Loading branch information
1 parent
ab4e3a8
commit 64d4cb4
Showing
14 changed files
with
103 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -30,16 +30,31 @@ | |
#include <QEvent> | ||
#include <QLabel> | ||
#include <QPoint> | ||
#include <QPointF> | ||
#include <QPixmap> | ||
#include <QWidget> | ||
#include <QPainter> | ||
#include <QtGlobal> | ||
#include <QMainWindow> | ||
#include <QHBoxLayout> | ||
#include <QMouseEvent> | ||
#include <QPaintEvent> | ||
#include <QPushButton> | ||
#include <QStyleOption> | ||
|
||
#ifndef EV_GLOBAL_MACRO | ||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
#define EV_GLOBAL_X(event) event->globalX() | ||
#define EV_GLOBAL_Y(event) event->globalY() | ||
#define EV_GLOBAL_POS(event) event->globalPos() | ||
#else | ||
#define EV_GLOBAL_X(event) event->globalPosition().toPoint().x() | ||
#define EV_GLOBAL_Y(event) event->globalPosition().toPoint().y() | ||
#define EV_GLOBAL_POS(event) event->globalPosition().toPoint() | ||
#endif | ||
#define EV_GLOBAL_MACRO | ||
#endif | ||
|
||
namespace QCustomAttrs { | ||
enum WindowButton { | ||
Minimize = 0x01, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 4 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -30,13 +30,15 @@ | |
#include <QTimer> | ||
#include <QPoint> | ||
#include <QStyle> | ||
#include <QPointF> | ||
#include <QObject> | ||
#include <QWidget> | ||
#include <QCursor> | ||
#include <QWindow> | ||
#include <QMenuBar> | ||
#include <QPainter> | ||
#include <QToolBar> | ||
#include <QtGlobal> | ||
#include <QStatusBar> | ||
#include <QSizePolicy> | ||
#include <QMetaMethod> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -118,12 +118,12 @@ void QCustomTitleBar::setWindowButtonEnabled(QCustomAttrs::WindowButton btn, boo | |
} | ||
|
||
void QCustomTitleBar::mouseMoveEvent(QMouseEvent *event){ | ||
if (event->buttons() & Qt::LeftButton) emit changeWindowPositionRequest(event->globalPos()); | ||
if (event->buttons() & Qt::LeftButton) emit changeWindowPositionRequest(EV_GLOBAL_POS(event)); | ||
QWidget::mouseMoveEvent(event); | ||
} | ||
|
||
void QCustomTitleBar::mousePressEvent(QMouseEvent *event){ | ||
if (event->button() & Qt::LeftButton) emit startWindowMoveRequest(event->globalPos()); | ||
if (event->button() & Qt::LeftButton) emit startWindowMoveRequest(EV_GLOBAL_POS(event)); | ||
QWidget::mousePressEvent(event); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -22,16 +22,31 @@ | |
#include <QEvent> | ||
#include <QLabel> | ||
#include <QPoint> | ||
#include <QPointF> | ||
#include <QPixmap> | ||
#include <QWidget> | ||
#include <QPainter> | ||
#include <QtGlobal> | ||
#include <QMainWindow> | ||
#include <QHBoxLayout> | ||
#include <QMouseEvent> | ||
#include <QPaintEvent> | ||
#include <QPushButton> | ||
#include <QStyleOption> | ||
|
||
#ifndef EV_GLOBAL_MACRO | ||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
#define EV_GLOBAL_X(event) event->globalX() | ||
#define EV_GLOBAL_Y(event) event->globalY() | ||
#define EV_GLOBAL_POS(event) event->globalPos() | ||
#else | ||
#define EV_GLOBAL_X(event) event->globalPosition().toPoint().x() | ||
#define EV_GLOBAL_Y(event) event->globalPosition().toPoint().y() | ||
#define EV_GLOBAL_POS(event) event->globalPosition().toPoint() | ||
#endif | ||
#define EV_GLOBAL_MACRO | ||
#endif | ||
|
||
namespace QCustomAttrs { | ||
enum WindowButton { | ||
Minimize = 0x01, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -118,20 +118,20 @@ bool QCustomWindow::eventFilter(QObject *, QEvent *event){ | |
case QEvent::MouseMove: | ||
if (this->cOpStatus & OperationType::CUSTOM_RESIZE) | ||
customMouseMoveEvent(static_cast<QMouseEvent*>(event)); | ||
else if (!this->isMoving()) redefineCursor(static_cast<QMouseEvent*>(event)->globalPos()); | ||
else if (!this->isMoving()) redefineCursor(EV_GLOBAL_POS(static_cast<QMouseEvent*>(event))); | ||
break; | ||
default: break; | ||
} | ||
return false; | ||
} | ||
|
||
void QCustomWindow::mousePressEvent(QMouseEvent *event){ | ||
this->redefineCursor(event->globalPos()); | ||
this->redefineCursor(EV_GLOBAL_POS(event)); | ||
if (event->button() & Qt::LeftButton && this->mLock){ | ||
if (!this->forceCustomResize && this->windowHandle()->startSystemResize(this->mLock)) | ||
this->cOpStatus = OperationType::SYSTEM_RESIZE; | ||
else { | ||
QPoint posCursor = event->globalPos(); | ||
QPoint posCursor = EV_GLOBAL_POS(event); | ||
if (this->mLock & Qt::TopEdge) posCursor.ry() -= this->y(); | ||
if (this->mLock & Qt::LeftEdge) posCursor.rx() -= this->x(); | ||
if (this->mLock & Qt::RightEdge) posCursor.rx() -= (this->x() + this->width()); | ||
|
@@ -144,12 +144,12 @@ void QCustomWindow::mousePressEvent(QMouseEvent *event){ | |
|
||
void QCustomWindow::mouseReleaseEvent(QMouseEvent *event){ | ||
this->cOpStatus = OperationType::NONE; | ||
this->redefineCursor(event->globalPos()); | ||
this->redefineCursor(EV_GLOBAL_POS(event)); | ||
QWidget::mouseReleaseEvent(event); | ||
} | ||
|
||
void QCustomWindow::customMouseMoveEvent(QMouseEvent *event){ | ||
int gX = event->globalX(), gY = event->globalY(); | ||
int gX = EV_GLOBAL_X(event), gY = EV_GLOBAL_Y(event); | ||
QPoint tL = this->geometry().topLeft(), bR = this->geometry().bottomRight(); | ||
|
||
bool cRH = bR.x() - tL.x() > this->minimumWidth(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 30 of August of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -22,13 +22,15 @@ | |
#include <QTimer> | ||
#include <QPoint> | ||
#include <QStyle> | ||
#include <QPointF> | ||
#include <QObject> | ||
#include <QWidget> | ||
#include <QCursor> | ||
#include <QWindow> | ||
#include <QMenuBar> | ||
#include <QPainter> | ||
#include <QToolBar> | ||
#include <QtGlobal> | ||
#include <QStatusBar> | ||
#include <QSizePolicy> | ||
#include <QMetaMethod> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -118,12 +118,12 @@ void QCustomTitleBar::setWindowButtonEnabled(QCustomAttrs::WindowButton btn, boo | |
} | ||
|
||
void QCustomTitleBar::mouseMoveEvent(QMouseEvent *event){ | ||
if (event->buttons() & Qt::LeftButton) emit changeWindowPositionRequest(event->globalPos()); | ||
if (event->buttons() & Qt::LeftButton) emit changeWindowPositionRequest(EV_GLOBAL_POS(event)); | ||
QWidget::mouseMoveEvent(event); | ||
} | ||
|
||
void QCustomTitleBar::mousePressEvent(QMouseEvent *event){ | ||
if (event->button() & Qt::LeftButton) emit startWindowMoveRequest(event->globalPos()); | ||
if (event->button() & Qt::LeftButton) emit startWindowMoveRequest(EV_GLOBAL_POS(event)); | ||
QWidget::mousePressEvent(event); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -30,16 +30,31 @@ | |
#include <QEvent> | ||
#include <QLabel> | ||
#include <QPoint> | ||
#include <QPointF> | ||
#include <QPixmap> | ||
#include <QWidget> | ||
#include <QPainter> | ||
#include <QtGlobal> | ||
#include <QMainWindow> | ||
#include <QHBoxLayout> | ||
#include <QMouseEvent> | ||
#include <QPaintEvent> | ||
#include <QPushButton> | ||
#include <QStyleOption> | ||
|
||
#ifndef EV_GLOBAL_MACRO | ||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
#define EV_GLOBAL_X(event) event->globalX() | ||
#define EV_GLOBAL_Y(event) event->globalY() | ||
#define EV_GLOBAL_POS(event) event->globalPos() | ||
#else | ||
#define EV_GLOBAL_X(event) event->globalPosition().toPoint().x() | ||
#define EV_GLOBAL_Y(event) event->globalPosition().toPoint().y() | ||
#define EV_GLOBAL_POS(event) event->globalPosition().toPoint() | ||
#endif | ||
#define EV_GLOBAL_MACRO | ||
#endif | ||
|
||
namespace QCustomAttrs { | ||
enum WindowButton { | ||
Minimize = 0x01, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -118,20 +118,20 @@ bool QCustomWindow::eventFilter(QObject *, QEvent *event){ | |
case QEvent::MouseMove: | ||
if (this->cOpStatus & OperationType::CUSTOM_RESIZE) | ||
customMouseMoveEvent(static_cast<QMouseEvent*>(event)); | ||
else if (!this->isMoving()) redefineCursor(static_cast<QMouseEvent*>(event)->globalPos()); | ||
else if (!this->isMoving()) redefineCursor(EV_GLOBAL_POS(static_cast<QMouseEvent*>(event))); | ||
break; | ||
default: break; | ||
} | ||
return false; | ||
} | ||
|
||
void QCustomWindow::mousePressEvent(QMouseEvent *event){ | ||
this->redefineCursor(event->globalPos()); | ||
this->redefineCursor(EV_GLOBAL_POS(event)); | ||
if (event->button() & Qt::LeftButton && this->mLock){ | ||
if (!this->forceCustomResize && this->windowHandle()->startSystemResize(this->mLock)) | ||
this->cOpStatus = OperationType::SYSTEM_RESIZE; | ||
else { | ||
QPoint posCursor = event->globalPos(); | ||
QPoint posCursor = EV_GLOBAL_POS(event); | ||
if (this->mLock & Qt::TopEdge) posCursor.ry() -= this->y(); | ||
if (this->mLock & Qt::LeftEdge) posCursor.rx() -= this->x(); | ||
if (this->mLock & Qt::RightEdge) posCursor.rx() -= (this->x() + this->width()); | ||
|
@@ -144,12 +144,12 @@ void QCustomWindow::mousePressEvent(QMouseEvent *event){ | |
|
||
void QCustomWindow::mouseReleaseEvent(QMouseEvent *event){ | ||
this->cOpStatus = OperationType::NONE; | ||
this->redefineCursor(event->globalPos()); | ||
this->redefineCursor(EV_GLOBAL_POS(event)); | ||
QWidget::mouseReleaseEvent(event); | ||
} | ||
|
||
void QCustomWindow::customMouseMoveEvent(QMouseEvent *event){ | ||
int gX = event->globalX(), gY = event->globalY(); | ||
int gX = EV_GLOBAL_X(event), gY = EV_GLOBAL_Y(event); | ||
QPoint tL = this->geometry().topLeft(), bR = this->geometry().bottomRight(); | ||
|
||
bool cRH = bR.x() - tL.x() > this->minimumWidth(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 4 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -30,13 +30,15 @@ | |
#include <QTimer> | ||
#include <QPoint> | ||
#include <QStyle> | ||
#include <QPointF> | ||
#include <QObject> | ||
#include <QWidget> | ||
#include <QCursor> | ||
#include <QWindow> | ||
#include <QMenuBar> | ||
#include <QPainter> | ||
#include <QToolBar> | ||
#include <QtGlobal> | ||
#include <QStatusBar> | ||
#include <QSizePolicy> | ||
#include <QMetaMethod> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
# Developer: Mauro Mascarenhas de Araújo | ||
# Contact: [email protected] | ||
# Licence: Mozilla Public Licence 2.0 | ||
# Date: 5 of September of 2021 | ||
# Date: 31 of October of 2021 | ||
# | ||
# Licence notice | ||
# | ||
|
@@ -118,12 +118,12 @@ void QCustomTitleBar::setWindowButtonEnabled(QCustomAttrs::WindowButton btn, boo | |
} | ||
|
||
void QCustomTitleBar::mouseMoveEvent(QMouseEvent *event){ | ||
if (event->buttons() & Qt::LeftButton) emit changeWindowPositionRequest(event->globalPos()); | ||
if (event->buttons() & Qt::LeftButton) emit changeWindowPositionRequest(EV_GLOBAL_POS(event)); | ||
QWidget::mouseMoveEvent(event); | ||
} | ||
|
||
void QCustomTitleBar::mousePressEvent(QMouseEvent *event){ | ||
if (event->button() & Qt::LeftButton) emit startWindowMoveRequest(event->globalPos()); | ||
if (event->button() & Qt::LeftButton) emit startWindowMoveRequest(EV_GLOBAL_POS(event)); | ||
QWidget::mousePressEvent(event); | ||
} | ||
|
||
|
Oops, something went wrong.