forked from qt-creator/qt-creator
QmlDesigner: Add enter and leave event support to 3D view
Fixes: QDS-10917 Change-Id: Iefcf92bd4a747d35f44e47c438548338fccfc4a2 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -10,10 +10,16 @@ namespace QmlDesigner {
|
||||
|
||||
InputEventCommand::InputEventCommand() = default;
|
||||
|
||||
InputEventCommand::InputEventCommand(QInputEvent *e)
|
||||
: m_type(e->type()),
|
||||
m_modifiers(e->modifiers())
|
||||
InputEventCommand::InputEventCommand(QEvent *e)
|
||||
: m_type(e->type())
|
||||
{
|
||||
// Leave events are not actual input events
|
||||
if (m_type == QEvent::Leave)
|
||||
return;
|
||||
|
||||
auto ie = static_cast<QInputEvent *>(e);
|
||||
m_modifiers = ie->modifiers();
|
||||
|
||||
if (m_type == QEvent::Wheel) {
|
||||
auto we = static_cast<QWheelEvent *>(e);
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(5, 15, 0)
|
||||
@@ -28,6 +34,11 @@ InputEventCommand::InputEventCommand(QInputEvent *e)
|
||||
m_key = ke->key();
|
||||
m_count = ke->count();
|
||||
m_autoRepeat = ke->isAutoRepeat();
|
||||
} else if (m_type == QEvent::Enter) {
|
||||
auto spe = static_cast<QSinglePointEvent *>(e);
|
||||
m_pos = spe->position().toPoint();
|
||||
m_button = spe->button();
|
||||
m_buttons = spe->buttons();
|
||||
} else {
|
||||
auto me = static_cast<QMouseEvent *>(e);
|
||||
m_pos = me->pos();
|
||||
|
||||
@@ -18,7 +18,7 @@ class InputEventCommand
|
||||
|
||||
public:
|
||||
InputEventCommand();
|
||||
explicit InputEventCommand(QInputEvent *e);
|
||||
explicit InputEventCommand(QEvent *e);
|
||||
|
||||
QEvent::Type type() const { return m_type; }
|
||||
QPoint pos() const { return m_pos; }
|
||||
|
||||
@@ -155,6 +155,18 @@ void Edit3DCanvas::focusInEvent(QFocusEvent *focusEvent)
|
||||
QWidget::focusInEvent(focusEvent);
|
||||
}
|
||||
|
||||
void Edit3DCanvas::enterEvent(QEnterEvent *e)
|
||||
{
|
||||
m_parent->view()->sendInputEvent(e);
|
||||
QWidget::enterEvent(e);
|
||||
}
|
||||
|
||||
void Edit3DCanvas::leaveEvent(QEvent *e)
|
||||
{
|
||||
m_parent->view()->sendInputEvent(e);
|
||||
QWidget::leaveEvent(e);
|
||||
}
|
||||
|
||||
void Edit3DCanvas::positionBusyInidicator()
|
||||
{
|
||||
m_busyIndicator->move(width() / 2 - 32, height() / 2 - 32);
|
||||
|
||||
@@ -38,6 +38,8 @@ protected:
|
||||
void resizeEvent(QResizeEvent *e) override;
|
||||
void focusOutEvent(QFocusEvent *focusEvent) override;
|
||||
void focusInEvent(QFocusEvent *focusEvent) override;
|
||||
void enterEvent(QEnterEvent *e) override;
|
||||
void leaveEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void positionBusyInidicator();
|
||||
|
||||
@@ -431,7 +431,7 @@ void Edit3DView::nodeRemoved(const ModelNode &,
|
||||
updateAlignActionStates();
|
||||
}
|
||||
|
||||
void Edit3DView::sendInputEvent(QInputEvent *e) const
|
||||
void Edit3DView::sendInputEvent(QEvent *e) const
|
||||
{
|
||||
if (nodeInstanceView())
|
||||
nodeInstanceView()->sendInputEvent(e);
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty,
|
||||
PropertyChangeFlags propertyChange) override;
|
||||
|
||||
void sendInputEvent(QInputEvent *e) const;
|
||||
void sendInputEvent(QEvent *e) const;
|
||||
void edit3DViewResized(const QSize &size) const;
|
||||
|
||||
QSize canvasSize() const;
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
const QList<ModelNode> &lastSelectedNodeList) override;
|
||||
|
||||
void sendInputEvent(QInputEvent *e) const;
|
||||
void sendInputEvent(QEvent *e) const;
|
||||
void view3DAction(View3DActionType type, const QVariant &value) override;
|
||||
void requestModelNodePreviewImage(const ModelNode &node, const ModelNode &renderNode) const;
|
||||
void edit3DViewResized(const QSize &size) const;
|
||||
|
||||
@@ -1764,7 +1764,7 @@ void NodeInstanceView::selectedNodesChanged(const QList<ModelNode> &selectedNode
|
||||
m_rotBlockTimer.start();
|
||||
}
|
||||
|
||||
void NodeInstanceView::sendInputEvent(QInputEvent *e) const
|
||||
void NodeInstanceView::sendInputEvent(QEvent *e) const
|
||||
{
|
||||
m_nodeInstanceServer->inputEvent(InputEventCommand(e));
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ void Qt5InformationNodeInstanceServer::handleInputEvents()
|
||||
// Peek at next command. If that is also a wheel with same button/modifiers
|
||||
// state, skip this event and add the angle delta to the next one.
|
||||
auto nextCommand = m_pendingInputEventCommands[i + 1];
|
||||
if (nextCommand.type() == QEvent::MouseMove
|
||||
if (nextCommand.type() == QEvent::Wheel
|
||||
&& nextCommand.button() == command.button()
|
||||
&& nextCommand.buttons() == command.buttons()
|
||||
&& nextCommand.modifiers() == command.modifiers()) {
|
||||
@@ -232,6 +232,12 @@ void Qt5InformationNodeInstanceServer::handleInputEvents()
|
||||
QKeyEvent *ke = new QKeyEvent(command.type(), command.key(), command.modifiers(),
|
||||
QString(), command.autoRepeat(), command.count());
|
||||
QGuiApplication::sendEvent(m_editView3DData.window, ke);
|
||||
} else if (command.type() == QEvent::Enter) {
|
||||
QEnterEvent *ee = new QEnterEvent(command.pos(), {}, {});
|
||||
QGuiApplication::sendEvent(m_editView3DData.window, ee);
|
||||
} else if (command.type() == QEvent::Leave) {
|
||||
QEvent *e = new QEvent(command.type());
|
||||
QGuiApplication::sendEvent(m_editView3DData.window, e);
|
||||
} else {
|
||||
if (command.type() == QEvent::MouseMove && i < m_pendingInputEventCommands.size() - 1) {
|
||||
// Peek at next command. If that is also a move with only difference being
|
||||
|
||||
Reference in New Issue
Block a user