From 0e5fed0855633025612533944c89591a6a7a68d6 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Mon, 13 Dec 2021 17:19:23 +0800 Subject: [PATCH] fix form resize exception under windows --- DSView/main.cpp | 7 ++++--- DSView/pv/mainframe.cpp | 22 +++++++++++----------- DSView/pv/sigsession.cpp | 17 ++++++++++------- DSView/pv/sigsession.h | 2 +- qtpro/DSView.pro.user | 4 ++-- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/DSView/main.cpp b/DSView/main.cpp index d0cb7161..6b45764b 100755 --- a/DSView/main.cpp +++ b/DSView/main.cpp @@ -165,12 +165,13 @@ int main(int argc, char *argv[]) } try - { - control->Start(); - + { + control->Start(); + // Initialise the main frame pv::MainFrame w; w.show(); + w.readSettings(); //to show the dailog for open help document diff --git a/DSView/pv/mainframe.cpp b/DSView/pv/mainframe.cpp index 5f7c3be0..adab48f6 100644 --- a/DSView/pv/mainframe.cpp +++ b/DSView/pv/mainframe.cpp @@ -228,15 +228,7 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event) if (isMaximized() || _titleBar->IsMoving()){ return QFrame::eventFilter(object, event); } - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - int x0 = (int)mouse_event->globalPosition().x(); - int y0 = (int)mouse_event->globalPosition().y(); -#else - int x0 = mouse_event->globalX(); - int y0 = mouse_event->globalY(); -#endif - + if (!_bDraging && type == QEvent::MouseMove && (!(mouse_event->buttons() | Qt::NoButton))){ if (object == _top_left) { _hit_border = TopLeft; @@ -271,6 +263,15 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event) } if (type == QEvent::MouseMove) { + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + int x0 = (int)mouse_event->globalPosition().x(); + int y0 = (int)mouse_event->globalPosition().y(); +#else + int x0 = mouse_event->globalX(); + int y0 = mouse_event->globalY(); +#endif + if(mouse_event->buttons().testFlag(Qt::LeftButton)) { if (!_freezing) { switch (_hit_border) { @@ -362,8 +363,7 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event) _dragStartGeometry = geometry(); } else if (type == QEvent::MouseButtonRelease) { - if (mouse_event->button() == Qt::LeftButton) { - + if (mouse_event->button() == Qt::LeftButton) { _bDraging = false; _timer.stop(); } diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index d3d9a848..1eff15f9 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -61,8 +61,7 @@ #include "data/decode/decoderstatus.h" #include "dsvdef.h" - - + namespace pv { // TODO: This should not be necessary @@ -1259,13 +1258,17 @@ void SigSession::register_hotplug_callback() { int ret; - ret = libusb_hotplug_register_callback(NULL, (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | - LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), - (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE, 0x2A0E, LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, hotplug_callback, NULL, + ret = libusb_hotplug_register_callback(NULL, + (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), + (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE, + 0x2A0E, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + hotplug_callback, + NULL, &_hotplug_handle); if (LIBUSB_SUCCESS != ret){ - qDebug() << "Error creating a hotplug callback\n"; + qDebug() << "Error creating a hotplug callback,code:"< - + EnvironmentId @@ -93,7 +93,7 @@ QtProjectManager.QMakeBuildStep true - true + false false false