| 194 | } |
| 195 | |
| 196 | void pqPythonTabWidget::mousePressEvent(QMouseEvent* mouseEvent) |
| 197 | { |
| 198 | if (mouseEvent->button() == Qt::RightButton) |
| 199 | { |
| 200 | const QPoint& mousePosition = mouseEvent->pos(); |
| 201 | const int tabIndex = this->tabBar()->tabAt(mousePosition); |
| 202 | |
| 203 | if (tabIndex >= 0 && tabIndex < this->count()) |
| 204 | { |
| 205 | QMenu contextMenu; |
| 206 | |
| 207 | QAction closeTabAction; |
| 208 | closeTabAction.setText(tr("Close")); |
| 209 | this->connect(&closeTabAction, &QAction::triggered, |
| 210 | [this, tabIndex]() { this->tabCloseRequested(tabIndex); }); |
| 211 | contextMenu.addAction(&closeTabAction); |
| 212 | |
| 213 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) |
| 214 | contextMenu.exec(mouseEvent->globalPos()); |
| 215 | #else |
| 216 | contextMenu.exec(mouseEvent->globalPosition().toPoint()); |
| 217 | #endif |
| 218 | } |
| 219 | |
| 220 | mouseEvent->accept(); |
| 221 | } |
| 222 | |
| 223 | mouseEvent->ignore(); |
| 224 | } |
| 225 | |
| 226 | //----------------------------------------------------------------------------- |
| 227 | void pqPythonTabWidget::updateTab(QWidget* widget) |