mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Editor: support Ctrl+Shift+V to paste as plain text
This commit is contained in:
parent
6d1830ad86
commit
43fcdd502a
@ -429,6 +429,8 @@ OpenViaDefaultProgram=F12
|
||||
FullScreen=F11
|
||||
; Universal Entry
|
||||
UniversalEntry=Ctrl+G
|
||||
; Paste as plain text
|
||||
PastePlainText=Ctrl+Shift+V
|
||||
|
||||
[captain_mode_shortcuts]
|
||||
; Define shortcuts in Captain mode here.
|
||||
|
@ -105,6 +105,15 @@ void VEditor::init()
|
||||
|
||||
m_config.init(QFontMetrics(m_editor->font()), false);
|
||||
updateEditConfig();
|
||||
|
||||
// Init shortcuts.
|
||||
QKeySequence keySeq(g_config->getShortcutKeySequence("PastePlainText"));
|
||||
QShortcut *pastePlainTextShortcut = new QShortcut(keySeq, m_editor);
|
||||
pastePlainTextShortcut->setContext(Qt::WidgetShortcut);
|
||||
QObject::connect(pastePlainTextShortcut, &QShortcut::activated,
|
||||
m_object, [this]() {
|
||||
pastePlainText();
|
||||
});
|
||||
}
|
||||
|
||||
void VEditor::labelTimerTimeout()
|
||||
@ -1681,3 +1690,18 @@ void VEditor::nextMatch(bool p_forward)
|
||||
m_findInfo.m_end);
|
||||
}
|
||||
}
|
||||
|
||||
void VEditor::pastePlainText()
|
||||
{
|
||||
if (!m_file || !m_file->isModifiable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
QString text(clipboard->text());
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_editOps->insertText(text);
|
||||
}
|
||||
|
@ -270,6 +270,9 @@ protected:
|
||||
|
||||
void addTempFile(const QString &p_file);
|
||||
|
||||
// Paste plain text.
|
||||
void pastePlainText();
|
||||
|
||||
QWidget *m_editor;
|
||||
|
||||
VEditorObject *m_object;
|
||||
|
@ -367,6 +367,14 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
||||
if (mimeData->hasHtml()) {
|
||||
initPasteAfterParseMenu(pasteAct, menu.data());
|
||||
}
|
||||
|
||||
QAction *pptAct = new QAction(tr("Paste As Plain Text"), menu.data());
|
||||
VUtils::fixTextWithShortcut(pptAct, "PastePlainText");
|
||||
connect(pptAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
pastePlainText();
|
||||
});
|
||||
insertActionAfter(pasteAct, pptAct, menu.data());
|
||||
}
|
||||
|
||||
if (!textCursor().hasSelection()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user