Skip to content

Commit

Permalink
Merge a7259b2 into 081c89c
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Jan 10, 2019
2 parents 081c89c + a7259b2 commit 7dedb22
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 124 deletions.
7 changes: 2 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,8 @@ void MainWindow::keyPressEvent(QKeyEvent *pEvent)
// with Cmd+M to minimise OpenCOR on macOS, but then we wouldn't be
// able to close the find/replace widget of a text editor...

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
if ( (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
if (isFullScreen())
showNormal();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,8 @@ bool CellmlTextViewWidgetEditingWidget::handleEditorKeyPressEvent(QKeyEvent *pEv
{
// Some key combinations from our editor

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& (pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() == Qt::Key_Slash)) {
if ( (pEvent->modifiers() == Qt::ControlModifier)
&& (pEvent->key() == Qt::Key_Slash)) {
// We want to (un)comment the selected text, if any, or the current
// line, so start by retrieving the position of our cursor within our
// editor
Expand Down
50 changes: 21 additions & 29 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,15 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Check some key combinations

bool noModifiers = !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier);

if (noModifiers && (pEvent->key() == Qt::Key_Up)) {
if ( (pEvent->modifiers() == Qt::KeypadModifier)
&& (pEvent->key() == Qt::Key_Up)) {
// The user wants to go to the previous property

emit goToPreviousPropertyRequested();

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

emit goToNextPropertyRequested();
Expand Down Expand Up @@ -178,18 +175,15 @@ void ListEditorWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Check some key combinations

bool noModifiers = !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier);

if (noModifiers && (pEvent->key() == Qt::Key_Up)) {
if ( (pEvent->modifiers() == Qt::KeypadModifier)
&& (pEvent->key() == Qt::Key_Up)) {
// The user wants to go to the previous property

emit goToPreviousPropertyRequested();

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

emit goToNextPropertyRequested();
Expand Down Expand Up @@ -1806,22 +1800,16 @@ void PropertyEditorWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Check some key combinations

bool noModifiers = !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier);

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& (pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() == Qt::Key_A)) {
if ( (pEvent->modifiers() == Qt::ControlModifier)
&& (pEvent->key() == Qt::Key_A)) {
// The user wants to select everything, which we don't want to allow,
// so just accept the event...

pEvent->accept();
} else if (noModifiers && ( (pEvent->key() == Qt::Key_Return)
|| (pEvent->key() == Qt::Key_Enter))) {
} else if ( ( (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Return))
|| ( (pEvent->modifiers() == Qt::KeypadModifier)
&& (pEvent->key() == Qt::Key_Enter))) {
// The user wants to start/stop editing the property

if (mPropertyEditor)
Expand All @@ -1830,19 +1818,23 @@ void PropertyEditorWidget::keyPressEvent(QKeyEvent *pEvent)
editProperty(currentProperty());

pEvent->accept();
} else if (isEditing() && noModifiers && (pEvent->key() == Qt::Key_Escape)) {
} else if ( isEditing()
&& (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
// The user is editing and wants to cancel it

finishEditing(false);

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

goToPreviousProperty();

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

goToNextProperty();
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/miscellaneous/Core/src/treeviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ void TreeViewWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Check some key combinations

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)) {
if (pEvent->modifiers() == Qt::KeypadModifier) {
// None of the modifiers is selected

if (pEvent->key() == Qt::Key_Left) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,7 @@ void PmrWorkspacesWindowSynchronizeDialog::keyPressEvent(QKeyEvent *pEvent)
{
// Check whether we are trying to quick synchronise

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& (pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
if ( (pEvent->modifiers() == Qt::ControlModifier)
&& (pEvent->key() == Qt::Key_Return)) {
// Pretend that we clicked on the Ok button, if possible

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,10 +603,8 @@ void QScintillaWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Increase/decrease/reset the font size, if needed

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& (pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)) {
if ( (pEvent->modifiers() == Qt::ControlModifier)
|| (pEvent->modifiers() == Qt::ControlModifier+Qt::KeypadModifier)) {
if (pEvent->key() == Qt::Key_0) {
zoomTo(0);

Expand Down
60 changes: 19 additions & 41 deletions src/plugins/widget/EditorWidget/src/editorwidgeteditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,9 @@ void EditorWidgetEditorWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Hide our corresponding find/replace widget, if needed

if ( mFindReplace->isVisible()
&& !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
if ( mFindReplace->isVisible()
&& (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
mOwner->setFindReplaceVisible(false);

pEvent->accept();
Expand All @@ -116,9 +113,10 @@ void EditorWidgetEditorWidget::keyPressEvent(QKeyEvent *pEvent)

// Update our highlighting all if our find/replace widget is visible and
// has some find text and we didn't press one of the navigation keys,
// clear our highlighting if we pressed any key and our find/replace
// widget is not visible, forward the pressing of the Esc key but only
// on macOS (so we can exit full-screen mode, if needed)
// clear our highlighting if we pressed any key (except any of our
// modifiers) and our find/replace widget is not visible, forward the
// pressing of the Esc key but only on macOS (so we can exit full-screen
// mode, if needed)
// Note #1: regarding highlighting all, we need to do that in case we
// have some highlighting and then add some text, in which case
// the new text might indeed need highlighting and our vertical
Expand All @@ -127,44 +125,24 @@ void EditorWidgetEditorWidget::keyPressEvent(QKeyEvent *pEvent)
// text, but that we press one of the navigation keys then we
// don't need and shouldn't do highlighting all since it will
// lose any selection that we might have...

if ( mFindReplace->isVisible() && !mFindReplace->findText().isEmpty()
&& !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() != Qt::Key_Tab) && (pEvent->key() != Qt::Key_Backtab)
&& (pEvent->key() != Qt::Key_Up) && (pEvent->key() != Qt::Key_Down)
&& (pEvent->key() != Qt::Key_Left) && (pEvent->key() != Qt::Key_Right)
&& (pEvent->key() != Qt::Key_Home) && (pEvent->key() != Qt::Key_End)
&& (pEvent->key() != Qt::Key_PageUp) && (pEvent->key() != Qt::Key_PageDown)) {
// Note #3: regarding navigation keys, we don't need to test for the
// arrow keys since in that case pEvent->modifiers() will be
// equal to Qt::KeypadModifier and, here, we are testing for
// Qt::NoModifier...

if ( mFindReplace->isVisible() && !mFindReplace->findText().isEmpty()
&& (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() != Qt::Key_Home) && (pEvent->key() != Qt::Key_End)
&& (pEvent->key() != Qt::Key_PageUp) && (pEvent->key() != Qt::Key_PageDown)) {
highlightAll();

pEvent->accept();
#ifdef Q_OS_MAC
} else if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
} else if ( (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
QCoreApplication::sendEvent(Core::mainWindow(), pEvent);
#endif
} else if ( ( (pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier))
|| ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& (pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier))
|| ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& (pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier))
|| ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& (pEvent->modifiers() & Qt::MetaModifier))) {
} else if (pEvent->modifiers() != Qt::NoModifier) {
pEvent->accept();
} else if (!mFindReplace->isVisible()) {
clearHighlighting();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,21 +392,16 @@ void EditorWidgetFindReplaceWidget::keyPressEvent(QKeyEvent *pEvent)
{
// Some key combinations from our find/replace widget

if ( mOwner->isFindReplaceVisible()
&& !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
if ( mOwner->isFindReplaceVisible()
&& (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Escape)) {
mOwner->setFindReplaceVisible(false);

pEvent->accept();
} else if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& ( (pEvent->key() == Qt::Key_Return)
|| (pEvent->key() == Qt::Key_Enter))) {
} else if ( ( (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->key() == Qt::Key_Return))
|| ( (pEvent->modifiers() == Qt::KeypadModifier)
&& (pEvent->key() == Qt::Key_Enter))) {
if (mGui->findEdit->hasFocus()) {
mOwner->findNext();

Expand Down
28 changes: 8 additions & 20 deletions src/plugins/widget/GraphPanelWidget/src/graphpanelplotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3314,40 +3314,31 @@ void GraphPanelPlotWidget::mousePressEvent(QMouseEvent *pEvent)

// Check which action to can carry out

bool noModifiers = !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier);

if (noModifiers && (pEvent->button() == Qt::LeftButton)) {
if ( (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->button() == Qt::LeftButton)) {
// We want to pan, but only do this if we are not completely zoomed out

if (mCanZoomOutX || mCanZoomOutY) {
mAction = Pan;

mPoint = pEvent->pos();
}
} else if ( (pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
} else if ( (pEvent->modifiers() == Qt::ShiftModifier)
&& (pEvent->button() == Qt::LeftButton)) {
// We want to show the coordinates

mAction = ShowCoordinates;

mOverlayWidget->setPoint(pEvent->pos());
} else if (noModifiers && (pEvent->button() == Qt::RightButton)) {
} else if ( (pEvent->modifiers() == Qt::NoModifier)
&& (pEvent->button() == Qt::RightButton)) {
// We want to zoom in/out

mAction = Zoom;

mOriginPoint = pEvent->pos();
mPoint = pEvent->pos();
} else if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& (pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
} else if ( (pEvent->modifiers() == Qt::ControlModifier)
&& (pEvent->button() == Qt::RightButton)) {
// We want to zoom a region, but only allow it if we are not already
// fully zoomed in
Expand Down Expand Up @@ -3458,11 +3449,8 @@ void GraphPanelPlotWidget::wheelEvent(QWheelEvent *pEvent)
{
// Handle the wheel mouse button for zooming in/out

if ( !(pEvent->modifiers() & Qt::ShiftModifier)
&& !(pEvent->modifiers() & Qt::ControlModifier)
&& !(pEvent->modifiers() & Qt::AltModifier)
&& !(pEvent->modifiers() & Qt::MetaModifier)
&& canvas()->rect().contains(pEvent->pos()-canvas()->pos())) {
if ( (pEvent->modifiers() == Qt::NoModifier)
&& canvas()->rect().contains(pEvent->pos()-canvas()->pos())) {
// Make sure that we are not already carrying out an action

if (mAction == None) {
Expand Down

0 comments on commit 7dedb22

Please sign in to comment.