| 1340 | } |
| 1341 | |
| 1342 | void PythonConsole::contextMenuEvent(QContextMenuEvent* e) |
| 1343 | { |
| 1344 | QMenu menu(this); |
| 1345 | QAction* a; |
| 1346 | bool mayPasteHere = cursorBeyond(this->textCursor(), this->inputBegin()); |
| 1347 | |
| 1348 | a = menu.addAction(tr("&Copy"), this, &PythonConsole::copy); |
| 1349 | a->setShortcut(QKeySequence(QStringLiteral("CTRL+C"))); |
| 1350 | a->setEnabled(textCursor().hasSelection()); |
| 1351 | |
| 1352 | a = menu.addAction(tr("&Copy Command"), this, &PythonConsole::onCopyCommand); |
| 1353 | a->setEnabled(textCursor().hasSelection()); |
| 1354 | |
| 1355 | a = menu.addAction(tr("&Copy History"), this, &PythonConsole::onCopyHistory); |
| 1356 | a->setEnabled(!d->history.isEmpty()); |
| 1357 | |
| 1358 | a = menu.addAction(tr("Save History As…"), this, &PythonConsole::onSaveHistoryAs); |
| 1359 | a->setEnabled(!d->history.isEmpty()); |
| 1360 | |
| 1361 | QAction* saveh = menu.addAction(tr("Save History")); |
| 1362 | saveh->setToolTip(tr("Saves Python history across %1 sessions").arg(qApp->applicationName())); |
| 1363 | saveh->setCheckable(true); |
| 1364 | saveh->setChecked(d->hGrpSettings->GetBool("SavePythonHistory", false)); |
| 1365 | |
| 1366 | menu.addSeparator(); |
| 1367 | |
| 1368 | a = menu.addAction(tr("&Paste"), this, &PythonConsole::paste); |
| 1369 | a->setShortcut(QKeySequence(QStringLiteral("CTRL+V"))); |
| 1370 | const QMimeData* md = QApplication::clipboard()->mimeData(); |
| 1371 | a->setEnabled(mayPasteHere && md && canInsertFromMimeData(md)); |
| 1372 | |
| 1373 | a = menu.addAction(tr("Select All"), this, &PythonConsole::selectAll); |
| 1374 | a->setShortcut(QKeySequence(QStringLiteral("CTRL+A"))); |
| 1375 | a->setEnabled(!document()->isEmpty()); |
| 1376 | |
| 1377 | clearAction->setEnabled(!document()->isEmpty()); |
| 1378 | menu.addAction(clearAction); |
| 1379 | |
| 1380 | menu.addSeparator(); |
| 1381 | menu.addAction(tr("Insert File Name…"), this, &PythonConsole::onInsertFileName); |
| 1382 | menu.addSeparator(); |
| 1383 | |
| 1384 | QAction* wrap = menu.addAction(tr("Word Wrap")); |
| 1385 | wrap->setCheckable(true); |
| 1386 | |
| 1387 | wrap->setChecked(d->hGrpSettings->GetBool("PythonWordWrap", true)); |
| 1388 | QAction* exec = menu.exec(e->globalPos()); |
| 1389 | if (exec == wrap) { |
| 1390 | d->hGrpSettings->SetBool("PythonWordWrap", wrap->isChecked()); |
| 1391 | } |
| 1392 | else if (exec == saveh) { |
| 1393 | d->hGrpSettings->SetBool("SavePythonHistory", saveh->isChecked()); |
| 1394 | } |
| 1395 | } |
| 1396 | |
| 1397 | void PythonConsole::onClearConsole() |
| 1398 | { |
nothing calls this directly
no test coverage detected