diff options
Diffstat (limited to 'src/designer/src/components/formeditor/tool_widgeteditor.cpp')
-rw-r--r-- | src/designer/src/components/formeditor/tool_widgeteditor.cpp | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/src/designer/src/components/formeditor/tool_widgeteditor.cpp b/src/designer/src/components/formeditor/tool_widgeteditor.cpp index 8b27d54aa..fd019b75c 100644 --- a/src/designer/src/components/formeditor/tool_widgeteditor.cpp +++ b/src/designer/src/components/formeditor/tool_widgeteditor.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "tool_widgeteditor.h" #include "formwindow.h" @@ -48,7 +23,7 @@ QT_BEGIN_NAMESPACE -using namespace qdesigner_internal; +namespace qdesigner_internal { WidgetEditorTool::WidgetEditorTool(FormWindow *formWindow) : QDesignerFormWindowToolInterface(formWindow), @@ -75,6 +50,7 @@ QDesignerFormWindowInterface *WidgetEditorTool::formWindow() const return m_formWindow; } +// separators in QMainWindow are no longer widgets bool WidgetEditorTool::mainWindowSeparatorEvent(QWidget *widget, QEvent *event) { QMainWindow *mw = qobject_cast<QMainWindow*>(widget); @@ -109,11 +85,14 @@ bool WidgetEditorTool::mainWindowSeparatorEvent(QWidget *widget, QEvent *event) return false; } +bool WidgetEditorTool::isPassiveInteractor(QWidget *widget, QEvent *event) +{ + auto *widgetFactory = core()->widgetFactory(); + return widgetFactory->isPassiveInteractor(widget) || mainWindowSeparatorEvent(widget, event); +} + bool WidgetEditorTool::handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event) { - const bool passive = core()->widgetFactory()->isPassiveInteractor(widget) != 0 - || mainWindowSeparatorEvent(widget, event); // separators in QMainWindow - // are no longer widgets switch (event->type()) { case QEvent::Resize: case QEvent::Move: @@ -122,40 +101,48 @@ bool WidgetEditorTool::handleEvent(QWidget *widget, QWidget *managedWidget, QEve case QEvent::FocusOut: case QEvent::FocusIn: // Popup cancelled over a form widget: Reset its focus frame - return !(passive || widget == m_formWindow || widget == m_formWindow->mainContainer()); + return widget != m_formWindow && widget != m_formWindow->mainContainer() + && !isPassiveInteractor(widget, event); case QEvent::Wheel: // Prevent spinboxes and combos from reacting if (widget == m_formWindow->formContainer() || widget == m_formWindow || widget == m_formWindow->mainContainer()) { // Allow scrolling the form with wheel. return false; } - return !passive; + return !isPassiveInteractor(widget, event); case QEvent::KeyPress: - return !passive && handleKeyPressEvent(widget, managedWidget, static_cast<QKeyEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleKeyPressEvent(widget, managedWidget, static_cast<QKeyEvent*>(event)); case QEvent::KeyRelease: - return !passive && handleKeyReleaseEvent(widget, managedWidget, static_cast<QKeyEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleKeyReleaseEvent(widget, managedWidget, static_cast<QKeyEvent*>(event)); case QEvent::MouseMove: - return !passive && handleMouseMoveEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleMouseMoveEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); case QEvent::MouseButtonPress: - return !passive && handleMousePressEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleMousePressEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); case QEvent::MouseButtonRelease: - return !passive && handleMouseReleaseEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleMouseReleaseEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); case QEvent::MouseButtonDblClick: - return !passive && handleMouseButtonDblClickEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleMouseButtonDblClickEvent(widget, managedWidget, static_cast<QMouseEvent*>(event)); case QEvent::ContextMenu: - return !passive && handleContextMenu(widget, managedWidget, static_cast<QContextMenuEvent*>(event)); + return !isPassiveInteractor(widget, event) + && handleContextMenu(widget, managedWidget, static_cast<QContextMenuEvent*>(event)); case QEvent::DragEnter: return handleDragEnterMoveEvent(widget, managedWidget, static_cast<QDragEnterEvent *>(event), true); case QEvent::DragMove: - return handleDragEnterMoveEvent(widget, managedWidget, static_cast<QDragEnterEvent *>(event), false); + return handleDragEnterMoveEvent(widget, managedWidget, static_cast<QDragMoveEvent *>(event), false); case QEvent::DragLeave: return handleDragLeaveEvent(widget, managedWidget, static_cast<QDragLeaveEvent *>(event)); case QEvent::Drop: @@ -351,4 +338,6 @@ void WidgetEditorTool::deactivated() m_formWindow->clearSelection(); } +} // namespace qdesigner_internal + QT_END_NAMESPACE |