MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / showContextMenu

Method showContextMenu

src/plugins/codeeditor/gui/private/texteditor_p.cpp:372–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void 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
413void TextEditorPrivate::showMarginMenu()
414{

Callers 1

contextMenuEventMethod · 0.45

Calls 10

addSeparatorMethod · 0.80
isReadOnlyMethod · 0.80
isUndoAvailableMethod · 0.80
isRedoAvailableMethod · 0.80
selectAllMethod · 0.80
addActionMethod · 0.45
setEnabledMethod · 0.45
SendScintillaMethod · 0.45
lengthMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected