From 5f4deea7c995d48952c4ecc876c4a270180e2946 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 16 Feb 2019 21:53:23 +0100 Subject: [PATCH] fixes 0003794: Shortcut-Key is executed in edit field of a constraint (Combo View) --- src/Gui/QuantitySpinBox.cpp | 6 ++---- src/Gui/TaskView/TaskView.cpp | 25 +++++++++++++++++++++++ src/Gui/TaskView/TaskView.h | 4 +++- src/Gui/propertyeditor/PropertyEditor.cpp | 25 +++++++++++++++++++++++ src/Gui/propertyeditor/PropertyEditor.h | 1 + 5 files changed, 56 insertions(+), 5 deletions(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index cbd5d5a599..06ac949878 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -737,11 +737,9 @@ bool QuantitySpinBox::event(QEvent * event) event->accept(); return true; } - else - return QAbstractSpinBox::event(event); } - else - return QAbstractSpinBox::event(event); + + return QAbstractSpinBox::event(event); } void QuantitySpinBox::focusInEvent(QFocusEvent * event) diff --git a/src/Gui/TaskView/TaskView.cpp b/src/Gui/TaskView/TaskView.cpp index 72bc808c4e..92c39e7057 100644 --- a/src/Gui/TaskView/TaskView.cpp +++ b/src/Gui/TaskView/TaskView.cpp @@ -416,6 +416,31 @@ TaskView::~TaskView() Gui::Selection().Detach(this); } +bool TaskView::event(QEvent* event) +{ + if (event->type() == QEvent::ShortcutOverride) { + QKeyEvent * kevent = static_cast(event); + Qt::KeyboardModifiers ShiftKeypadModifier = Qt::ShiftModifier | Qt::KeypadModifier; + if (kevent->modifiers() == Qt::NoModifier || + kevent->modifiers() == Qt::ShiftModifier || + kevent->modifiers() == Qt::KeypadModifier || + kevent->modifiers() == ShiftKeypadModifier) { + switch (kevent->key()) { + case Qt::Key_Delete: + case Qt::Key_Home: + case Qt::Key_End: + case Qt::Key_Backspace: + case Qt::Key_Left: + case Qt::Key_Right: + kevent->accept(); + default: + break; + } + } + } + return QScrollArea::event(event); +} + void TaskView::keyPressEvent(QKeyEvent* ke) { if (ActiveCtrl && ActiveDialog) { diff --git a/src/Gui/TaskView/TaskView.h b/src/Gui/TaskView/TaskView.h index 5a368c8e3c..e1678c90f7 100644 --- a/src/Gui/TaskView/TaskView.h +++ b/src/Gui/TaskView/TaskView.h @@ -196,7 +196,9 @@ protected Q_SLOTS: void clicked (QAbstractButton * button); protected: - void keyPressEvent(QKeyEvent*); + virtual void keyPressEvent(QKeyEvent*); + virtual bool event(QEvent*); + void addTaskWatcher(void); void removeTaskWatcher(void); /// update the visibility of the TaskWatcher accordant to the selection diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index b0204d0d5a..d90de436a5 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -99,6 +99,31 @@ QStyleOptionViewItem PropertyEditor::viewOptions() const return option; } +bool PropertyEditor::event(QEvent* event) +{ + if (event->type() == QEvent::ShortcutOverride) { + QKeyEvent * kevent = static_cast(event); + Qt::KeyboardModifiers ShiftKeypadModifier = Qt::ShiftModifier | Qt::KeypadModifier; + if (kevent->modifiers() == Qt::NoModifier || + kevent->modifiers() == Qt::ShiftModifier || + kevent->modifiers() == Qt::KeypadModifier || + kevent->modifiers() == ShiftKeypadModifier) { + switch (kevent->key()) { + case Qt::Key_Delete: + case Qt::Key_Home: + case Qt::Key_End: + case Qt::Key_Backspace: + case Qt::Key_Left: + case Qt::Key_Right: + kevent->accept(); + default: + break; + } + } + } + return QTreeView::event(event); +} + void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEditHint hint) { if (autoupdate) { diff --git a/src/Gui/propertyeditor/PropertyEditor.h b/src/Gui/propertyeditor/PropertyEditor.h index 36eecd0850..e78a30f291 100644 --- a/src/Gui/propertyeditor/PropertyEditor.h +++ b/src/Gui/propertyeditor/PropertyEditor.h @@ -92,6 +92,7 @@ protected: virtual void rowsInserted (const QModelIndex & parent, int start, int end); virtual void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const; virtual QStyleOptionViewItem viewOptions() const; + virtual bool event(QEvent*); private: void setEditorMode(const QModelIndex & parent, int start, int end);