Skip to content

Commit

Permalink
ticket:4314 Close windows by ESC key.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Mar 15, 2017
1 parent 44b8b42 commit 027b95b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -939,6 +939,11 @@ InformationDialog::InformationDialog(QString windowTitle, QString informationTex
}
}

/*!
* \brief InformationDialog::closeEvent
* Saves the widgets geometry.
* \param event
*/
void InformationDialog::closeEvent(QCloseEvent *event)
{
/* save the window geometry. */
Expand All @@ -949,6 +954,20 @@ void InformationDialog::closeEvent(QCloseEvent *event)
event->accept();
}

/*!
* \brief InformationDialog::keyPressEvent
* Closes the widget when Esc key is pressed.
* \param event
*/
void InformationDialog::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
close();
return;
}
QWidget::keyPressEvent(event);
}

/*!
* \class GraphicsViewProperties
* \brief Creates a dialog that shows the icon/diagram GraphicsView properties.
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.h
Expand Up @@ -194,6 +194,8 @@ class InformationDialog : public QWidget
public:
InformationDialog(QString windowTitle, QString informationText, bool modelicaTextHighlighter = false, QWidget *pParent = 0);
void closeEvent(QCloseEvent *event);
protected:
virtual void keyPressEvent(QKeyEvent *event);
};

class GraphicsView;
Expand Down
14 changes: 14 additions & 0 deletions OMEdit/OMEditGUI/Simulation/SimulationOutputWidget.cpp
Expand Up @@ -655,3 +655,17 @@ void SimulationOutputWidget::openTransformationBrowser(QUrl url)
.arg(tr("Url is <b>%1</b>").arg(url.toString())), Helper::ok);
}
}

/*!
* \brief SimulationOutputWidget::keyPressEvent
* Closes the widget when Esc key is pressed.
* \param event
*/
void SimulationOutputWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Escape) {
close();
return;
}
QWidget::keyPressEvent(event);
}
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Simulation/SimulationOutputWidget.h
Expand Up @@ -120,6 +120,8 @@ public slots:
void simulationProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void cancelCompilationOrSimulation();
void openTransformationBrowser(QUrl url);
protected:
virtual void keyPressEvent(QKeyEvent *event);
};

#endif // SIMULATIONOUTPUTWIDGET_H

0 comments on commit 027b95b

Please sign in to comment.