| 370 | } |
| 371 | |
| 372 | void TextEditorPrivate::showContextMenu() |
| 373 | { |
| 374 | QMenu menu; |
| 375 | menu.addAction(tr("Refactor")); |
| 376 | menu.addSeparator(); |
| 377 | |
| 378 | QAction *action { nullptr }; |
| 379 | if (!q->isReadOnly()) { |
| 380 | action = menu.addAction(tr("Undo"), q, &TextEditor::undo); |
| 381 | action->setEnabled(q->isUndoAvailable()); |
| 382 | |
| 383 | action = menu.addAction(tr("Redo"), q, &TextEditor::redo); |
| 384 | action->setEnabled(q->isRedoAvailable()); |
| 385 | |
| 386 | menu.addSeparator(); |
| 387 | |
| 388 | action = menu.addAction(tr("Cut"), q, &TextEditor::cut); |
| 389 | action->setEnabled(q->hasSelectedText()); |
| 390 | } |
| 391 | |
| 392 | action = menu.addAction(tr("Copy"), q, &TextEditor::copy); |
| 393 | action->setEnabled(q->hasSelectedText()); |
| 394 | |
| 395 | if (!q->isReadOnly()) { |
| 396 | action = menu.addAction(tr("Paste"), q, &TextEditor::paste); |
| 397 | action->setEnabled(q->SendScintilla(TextEditor::SCI_CANPASTE)); |
| 398 | |
| 399 | action = menu.addAction(tr("Delete"), q, [this] { q->SendScintilla(TextEditor::SCI_CLEAR); }); |
| 400 | action->setEnabled(q->hasSelectedText()); |
| 401 | } |
| 402 | |
| 403 | menu.addSeparator(); |
| 404 | action = menu.addAction(tr("Select All"), q, [this] { q->selectAll(true); }); |
| 405 | action->setEnabled(q->length() != 0); |
| 406 | |
| 407 | // notify other plugin to add action. |
| 408 | editor.contextMenu(QVariant::fromValue(&menu)); |
| 409 | emit q->contextMenuRequested(&menu); |
| 410 | menu.exec(QCursor::pos()); |
| 411 | } |
| 412 | |
| 413 | void TextEditorPrivate::showMarginMenu() |
| 414 | { |
no test coverage detected