-----------------------------------------------------------------------------
| 88 | |
| 89 | //----------------------------------------------------------------------------- |
| 90 | bool pqPythonScriptEditor::eventFilter(QObject* watched, QEvent* event) |
| 91 | { |
| 92 | if (watched == this->parentWidget() && event->type() == QEvent::Close) |
| 93 | { |
| 94 | QCloseEvent* closeEvent = static_cast<QCloseEvent*>(event); |
| 95 | |
| 96 | // if the python editor is closed when the main window is closing, force it to show |
| 97 | if (!this->isVisible()) |
| 98 | { |
| 99 | this->show(); |
| 100 | } |
| 101 | |
| 102 | // prompt the user to save any open files if not already saved |
| 103 | if (this->TabWidget->saveOnClose()) |
| 104 | { |
| 105 | pqApplicationCore::instance()->settings()->saveState(*this, "PythonScriptEditor"); |
| 106 | closeEvent->accept(); |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | closeEvent->ignore(); |
| 111 | } |
| 112 | } |
| 113 | return QWidget::eventFilter(watched, event); |
| 114 | } |
| 115 | |
| 116 | //----------------------------------------------------------------------------- |
| 117 | void pqPythonScriptEditor::open(const QString& filename) |
nothing calls this directly
no test coverage detected