MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / contextMenuEvent

Method contextMenuEvent

ElaWidgetTools/ElaPlainTextEdit.cpp:83–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81#endif
82 if (!isReadOnly())
83 {
84 action = menu->addElaIconAction(ElaIconType::DeleteLeft, "删除");
85 action->setEnabled(!isReadOnly() && !toPlainText().isEmpty() && !textCursor().selectedText().isEmpty());
86 connect(action, &QAction::triggered, this, [=](bool checked) {
87 if (!textCursor().selectedText().isEmpty())
88 {
89 textCursor().deleteChar();
90 }
91 });
92 }
93 if (!menu->isEmpty())
94 {
95 menu->addSeparator();
96 }
97 action = menu->addAction("全选");
98 action->setShortcut(QKeySequence::SelectAll);
99 action->setEnabled(!toPlainText().isEmpty() && !(textCursor().selectedText() == toPlainText()));
100 connect(action, &QAction::triggered, this, &ElaPlainTextEdit::selectAll);
101 menu->popup(event->globalPos());
102 this->setFocus();
103}
104
105void ElaPlainTextEdit::paintEvent(QPaintEvent* event)
106{
107 Q_D(ElaPlainTextEdit);
108 if (palette().color(QPalette::Active, QPalette::Text) != ElaThemeColor(d->_themeMode, BasicText))
109 {
110 d->onThemeChanged(d->_themeMode);
111 }
112 QPlainTextEdit::paintEvent(event);
113}

Callers

nothing calls this directly

Calls 2

setMenuItemHeightMethod · 0.80
addElaIconActionMethod · 0.45

Tested by

no test coverage detected