mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #20183 from xhawk18:3.4
* improve compatibility for qt 6. * cmake(highgui): rework Qt dependency support * cmake(highgui): workaround Qt5Config.cmake "components" bug Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
This commit is contained in:
@@ -64,6 +64,38 @@
|
||||
#endif
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
#define Qt_MiddleButton Qt::MiddleButton
|
||||
inline Qt::Orientation wheelEventOrientation(QWheelEvent *we) {
|
||||
if (std::abs(we->angleDelta().x()) < std::abs(we->angleDelta().y()))
|
||||
return Qt::Vertical;
|
||||
else
|
||||
return Qt::Horizontal;
|
||||
}
|
||||
inline int wheelEventDelta(QWheelEvent *we) {
|
||||
if(wheelEventOrientation(we) == Qt::Vertical)
|
||||
return we->angleDelta().y();
|
||||
else
|
||||
return we->angleDelta().x();
|
||||
}
|
||||
inline QPoint wheelEventPos(QWheelEvent *we) {
|
||||
return we->position().toPoint();
|
||||
}
|
||||
#else
|
||||
#define Qt_MiddleButton Qt::MidButton
|
||||
inline Qt::Orientation wheelEventOrientation(QWheelEvent *we) {
|
||||
return we->orientation();
|
||||
}
|
||||
inline int wheelEventDelta(QWheelEvent *we) {
|
||||
return we->delta();
|
||||
}
|
||||
inline QPoint wheelEventPos(QWheelEvent *we) {
|
||||
return we->pos();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//Static and global first
|
||||
static GuiReceiver *guiMainThread = NULL;
|
||||
static int parameterSystemC = 1;
|
||||
@@ -1579,7 +1611,9 @@ CvWinProperties::CvWinProperties(QString name_paraWindow, QObject* /*parent*/)
|
||||
myLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
||||
myLayout->setContentsMargins(0, 0, 0, 0);
|
||||
myLayout->setSpacing(0);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
myLayout->setMargin(0);
|
||||
#endif
|
||||
myLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
setLayout(myLayout);
|
||||
|
||||
@@ -1957,7 +1991,9 @@ void CvWindow::createBarLayout()
|
||||
myBarLayout->setObjectName(QString::fromUtf8("barLayout"));
|
||||
myBarLayout->setContentsMargins(0, 0, 0, 0);
|
||||
myBarLayout->setSpacing(0);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
myBarLayout->setMargin(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1967,7 +2003,9 @@ void CvWindow::createGlobalLayout()
|
||||
myGlobalLayout->setObjectName(QString::fromUtf8("boxLayout"));
|
||||
myGlobalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
myGlobalLayout->setSpacing(0);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
myGlobalLayout->setMargin(0);
|
||||
#endif
|
||||
setMinimumSize(1, 1);
|
||||
|
||||
if (param_flags == CV_WINDOW_AUTOSIZE)
|
||||
@@ -2205,7 +2243,7 @@ void CvWindow::icvLoadControlPanel()
|
||||
}
|
||||
if (t->type == type_CvButtonbar)
|
||||
{
|
||||
int subsize = settings.beginReadArray(QString("buttonbar")+i);
|
||||
int subsize = settings.beginReadArray(QString("buttonbar%1").arg(i));
|
||||
|
||||
if ( subsize == ((CvButtonbar*)t)->layout()->count() )
|
||||
icvLoadButtonbar((CvButtonbar*)t,&settings);
|
||||
@@ -2236,7 +2274,7 @@ void CvWindow::icvSaveControlPanel()
|
||||
}
|
||||
if (t->type == type_CvButtonbar)
|
||||
{
|
||||
settings.beginWriteArray(QString("buttonbar")+i);
|
||||
settings.beginWriteArray(QString("buttonbar%1").arg(i));
|
||||
icvSaveButtonbar((CvButtonbar*)t,&settings);
|
||||
settings.endArray();
|
||||
}
|
||||
@@ -2396,14 +2434,14 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
|
||||
flags |= CV_EVENT_FLAG_LBUTTON;
|
||||
if(buttons & Qt::RightButton)
|
||||
flags |= CV_EVENT_FLAG_RBUTTON;
|
||||
if(buttons & Qt::MidButton)
|
||||
if(buttons & Qt_MiddleButton)
|
||||
flags |= CV_EVENT_FLAG_MBUTTON;
|
||||
|
||||
if (cv_event == -1) {
|
||||
if (category == mouse_wheel) {
|
||||
QWheelEvent *we = (QWheelEvent *) evnt;
|
||||
cv_event = ((we->orientation() == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
|
||||
flags |= (we->delta() & 0xffff)<<16;
|
||||
cv_event = ((wheelEventOrientation(we) == Qt::Vertical) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
|
||||
flags |= (wheelEventDelta(we) & 0xffff)<<16;
|
||||
return;
|
||||
}
|
||||
switch(evnt->button())
|
||||
@@ -2416,7 +2454,7 @@ void OCVViewPort::icvmouseHandler(QMouseEvent* evnt, type_mouse_event category,
|
||||
cv_event = tableMouseButtons[category][1];
|
||||
flags |= CV_EVENT_FLAG_RBUTTON;
|
||||
break;
|
||||
case Qt::MidButton:
|
||||
case Qt_MiddleButton:
|
||||
cv_event = tableMouseButtons[category][2];
|
||||
flags |= CV_EVENT_FLAG_MBUTTON;
|
||||
break;
|
||||
@@ -2772,7 +2810,7 @@ void DefaultViewPort::wheelEvent(QWheelEvent* evnt)
|
||||
{
|
||||
icvmouseEvent((QMouseEvent *)evnt, mouse_wheel);
|
||||
|
||||
scaleView(evnt->delta() / 240.0, evnt->pos());
|
||||
scaleView(wheelEventDelta(evnt) / 240.0, wheelEventPos(evnt));
|
||||
viewport()->update();
|
||||
|
||||
QWidget::wheelEvent(evnt);
|
||||
|
||||
Reference in New Issue
Block a user