| 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 | |
| 105 | void 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 | } |
nothing calls this directly
no test coverage detected