Skip to content

Commit

Permalink
Property Editor widget: disallowed navigation using the (Shift+)Tab k…
Browse files Browse the repository at this point in the history
…ey(s) (closes #1354).
  • Loading branch information
agarny committed Jul 2, 2017
2 parents 878068a + 79ac18f commit af20ed0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 70 deletions.
1 change: 1 addition & 0 deletions doc/downloads/index.js
Expand Up @@ -38,6 +38,7 @@ var jsonData = { "versions": [
],
"changes": [
{ "change": "<strong>General:</strong> provide an error message when a plugin is considered to be invalid (see issue <a href=\"https://github.com/opencor/opencor/issues/1347\">#1347</a>)." },
{ "change": "<strong>Property Editor widget:</strong> disallow navigation using the (Shift+)Tab key(s) (see issue <a href=\"https://github.com/opencor/opencor/issues/1354\">#1354</a>)." },
{ "change": "<strong>Third-party libraries:</strong> upgraded <a href=\"https://libgit2.github.com/\">libgit2</a> to version 0.26 (see issue <a href=\"https://github.com/opencor/opencor/issues/1340\">#1340</a>). Added <a href=\"http://code.qt.io/cgit/qt/qtcharts.git/tree/\">Qt Charts</a> as a package (see issue <a href=\"https://github.com/opencor/opencor/issues/1342\">#1342</a>). Upgraded <a href=\"http://www.llvm.org/\">LLVM</a>+<a href=\"http://clang.llvm.org/\">Clang</a> to version 4.0.1 (see issue <a href=\"https://github.com/opencor/opencor/issues/1352\">#1352</a>)." }
]
},
Expand Down
72 changes: 10 additions & 62 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.cpp
Expand Up @@ -71,25 +71,15 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *pEvent)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier);

if (noModifiers && (pEvent->key() == Qt::Key_Escape)) {
// The user wants to go cancel the editing

emit cancelEditingRequested();

// Accept the event

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Up)
|| (pEvent->key() == Qt::Key_Backtab))) {
if (noModifiers && (pEvent->key() == Qt::Key_Up)) {
// The user wants to go to the previous property

emit goToPreviousPropertyRequested();

// Accept the event

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Down)
|| (pEvent->key() == Qt::Key_Tab))) {
} else if (noModifiers && (pEvent->key() == Qt::Key_Down)) {
// The user wants to go to the next property

emit goToNextPropertyRequested();
Expand Down Expand Up @@ -146,25 +136,15 @@ void ListEditorWidget::keyPressEvent(QKeyEvent *pEvent)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier);

if (noModifiers && (pEvent->key() == Qt::Key_Escape)) {
// The user wants to go cancel the editing

emit cancelEditingRequested();

// Accept the event

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Up)
|| (pEvent->key() == Qt::Key_Backtab))) {
if (noModifiers && (pEvent->key() == Qt::Key_Up)) {
// The user wants to go to the previous property

emit goToPreviousPropertyRequested();

// Accept the event

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Down)
|| (pEvent->key() == Qt::Key_Tab))) {
} else if (noModifiers && (pEvent->key() == Qt::Key_Down)) {
// The user wants to go to the next property

emit goToNextPropertyRequested();
Expand Down Expand Up @@ -360,9 +340,6 @@ QWidget * PropertyItemDelegate::createEditor(QWidget *pParent,

// Propagate a few signals

connect(editor, SIGNAL(cancelEditingRequested()),
this, SIGNAL(cancelEditingRequested()));

connect(editor, SIGNAL(goToPreviousPropertyRequested()),
this, SIGNAL(goToPreviousPropertyRequested()));
connect(editor, SIGNAL(goToNextPropertyRequested()),
Expand Down Expand Up @@ -1076,7 +1053,6 @@ PropertyEditorWidget::PropertyEditorWidget(const bool &pShowUnits,
// Customise ourselves

setRootIsDecorated(false);
setTabKeyNavigation(true);

// Create and set our data model

Expand All @@ -1100,9 +1076,6 @@ PropertyEditorWidget::PropertyEditorWidget(const bool &pShowUnits,
connect(propertyItemDelegate, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)),
this, SLOT(editorClosed()));

connect(propertyItemDelegate, SIGNAL(cancelEditingRequested()),
this, SLOT(cancelEditing()));

connect(propertyItemDelegate, SIGNAL(goToPreviousPropertyRequested()),
this, SLOT(goToPreviousProperty()));
connect(propertyItemDelegate, SIGNAL(goToNextPropertyRequested()),
Expand Down Expand Up @@ -1508,42 +1481,31 @@ void PropertyEditorWidget::keyPressEvent(QKeyEvent *pEvent)
|| (pEvent->key() == Qt::Key_Enter))) {
// The user wants to start/stop editing the property

if (mPropertyEditor) {
// We are currently editing a property, so stop editing it

if (mPropertyEditor)
editProperty(0);
} else {
// We are not currently editing a property, so start editing the
// current one
// Note: we could use mProperty, but if it was to be empty then we
// would have to use currentIndex().row(), so we might as well
// use the latter all the time...

else
editProperty(currentProperty());
}

// Accept the event

pEvent->accept();
} else if (noModifiers && (pEvent->key() == Qt::Key_Escape)) {
// The user wants to cancel the editing

cancelEditing();
finishEditing(false);

// Accept the event

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Up)
|| (pEvent->key() == Qt::Key_Backtab))) {
} else if (noModifiers && (pEvent->key() == Qt::Key_Up)) {
// The user wants to go the previous property

goToPreviousProperty();

// Accept the event

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Down)
|| (pEvent->key() == Qt::Key_Tab))) {
} else if (noModifiers && (pEvent->key() == Qt::Key_Down)) {
// The user wants to go to the next property

goToNextProperty();
Expand Down Expand Up @@ -1606,7 +1568,7 @@ void PropertyEditorWidget::mousePressEvent(QMouseEvent *pEvent)
mRightClicking = pEvent->button() == Qt::RightButton;

if (mRightClicking)
cancelEditing();
finishEditing(false);
else if (newProperty && (newProperty != oldProperty))
editProperty(newProperty);
}
Expand Down Expand Up @@ -1908,20 +1870,6 @@ void PropertyEditorWidget::finishEditing(const bool &pCommitData)

//==============================================================================

void PropertyEditorWidget::cancelEditing()
{
// The user wants to cancel the editing, i.e. finish the editing without
// committing the editor's data
// Note: we temporarily disable tab key navigation since otherwise it will
// get us to the next property, which we don't want...

setTabKeyNavigation(false);
finishEditing(false);
setTabKeyNavigation(true);
}

//==============================================================================

void PropertyEditorWidget::removeAllProperties()
{
// Remove all the properties we currently hold
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.h
Expand Up @@ -61,8 +61,6 @@ class TextEditorWidget : public QLineEdit
virtual void keyPressEvent(QKeyEvent *pEvent);

signals:
void cancelEditingRequested();

void goToPreviousPropertyRequested();
void goToNextPropertyRequested();
};
Expand Down Expand Up @@ -102,8 +100,6 @@ class ListEditorWidget : public QComboBox
virtual void mousePressEvent(QMouseEvent *pEvent);

signals:
void cancelEditingRequested();

void goToPreviousPropertyRequested();
void goToNextPropertyRequested();
};
Expand Down Expand Up @@ -147,8 +143,6 @@ class PropertyItemDelegate : public QStyledItemDelegate
signals:
void openEditor(QWidget *pEditor) const;

void cancelEditingRequested();

void goToPreviousPropertyRequested();
void goToNextPropertyRequested();

Expand Down Expand Up @@ -398,8 +392,6 @@ private slots:
void editorOpened(QWidget *pEditor);
void editorClosed();

void cancelEditing();

void goToPreviousProperty();
void goToNextProperty();

Expand Down

0 comments on commit af20ed0

Please sign in to comment.