diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-06-20 10:27:44 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-07-07 08:49:36 +0000 |
commit | b2a1066e108678aa66d7e6f22cadf9c01d646ec9 (patch) | |
tree | 484ed5d83a98563a42f399b1c8e7cce1b1d1a651 | |
parent | 6bbf06477f6508b84b4fdf2a885ac880013f1892 (diff) | |
download | qttools-b2a1066e108678aa66d7e6f22cadf9c01d646ec9.tar.gz |
Qt Designer: Suppress QEvent::LayoutRequest when changing layout span
QTabWidget activates its parent layout when resizing, which prevents
it from smoothly resizing when changing item spans. Suppress
the QEvent::LayoutRequest when the widget handle is in a span-changing
mode.
Task-number: QTBUG-61439
Change-Id: I87b2c9d5e3e6796983b730907cf3bfe8c7ed2292
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
3 files changed, 32 insertions, 0 deletions
diff --git a/src/designer/src/components/formeditor/formwindow.h b/src/designer/src/components/formeditor/formwindow.h index d2502f4a7..86027a625 100644 --- a/src/designer/src/components/formeditor/formwindow.h +++ b/src/designer/src/components/formeditor/formwindow.h @@ -70,6 +70,13 @@ class QT_FORMEDITOR_EXPORT FormWindow: public FormWindowBase Q_OBJECT public: + enum HandleOperation + { + NoHandleOperation, + ResizeHandleOperation, + ChangeLayoutSpanHandleOperation + }; + explicit FormWindow(FormEditor *core, QWidget *parent = 0, Qt::WindowFlags flags = 0); virtual ~FormWindow(); @@ -199,6 +206,9 @@ public: bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; + HandleOperation handleOperation() const { return m_handleOperation; } + void setHandleOperation(HandleOperation o) { m_handleOperation = o; } + signals: void contextMenuRequested(QMenu *menu, QWidget *widget); @@ -354,6 +364,7 @@ private: QStringList m_includeHints; QPoint m_contextMenuPosition; + HandleOperation m_handleOperation = NoHandleOperation; private: friend class WidgetEditorTool; diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index 498160f8a..1650e1450 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -209,6 +209,14 @@ bool FormWindowManager::eventFilter(QObject *o, QEvent *e) return true; } switch (eventType) { + case QEvent::LayoutRequest: + // QTBUG-61439: Suppress layout request while changing the QGridLayout + // span of a QTabWidget, which sends LayoutRequest in resizeEvent(). + if (fw->handleOperation() == FormWindow::ChangeLayoutSpanHandleOperation) { + e->ignore(); + return true; + } + break; case QEvent::WindowActivate: { if (fw->parentWidget()->isWindow() && fw->isMainContainer(managedWidget) && activeFormWindow() != fw) { diff --git a/src/designer/src/components/formeditor/widgetselection.cpp b/src/designer/src/components/formeditor/widgetselection.cpp index eda77e213..fcb54de92 100644 --- a/src/designer/src/components/formeditor/widgetselection.cpp +++ b/src/designer/src/components/formeditor/widgetselection.cpp @@ -178,6 +178,17 @@ void WidgetHandle::mousePressEvent(QMouseEvent *e) m_origPressPos = container->mapFromGlobal(e->globalPos()); m_geom = m_origGeom = m_widget->geometry(); + + switch (WidgetSelection::widgetState(m_formWindow->core(), m_widget)) { + case WidgetSelection::UnlaidOut: + case WidgetSelection::LaidOut: + m_formWindow->setHandleOperation(FormWindow::ResizeHandleOperation); + break; + case WidgetSelection::ManagedGridLayout: + case WidgetSelection::ManagedFormLayout: + m_formWindow->setHandleOperation(FormWindow::ChangeLayoutSpanHandleOperation); + break; + } } void WidgetHandle::mouseMoveEvent(QMouseEvent *e) @@ -326,6 +337,8 @@ void WidgetHandle::mouseMoveEvent(QMouseEvent *e) void WidgetHandle::mouseReleaseEvent(QMouseEvent *e) { + m_formWindow->setHandleOperation(FormWindow::NoHandleOperation); + if (e->button() != Qt::LeftButton || !m_active) return; |