feature/add_shortcuts_paste_to_md (#2277)

* feature/add_shortcuts_paste_to_md

* feature/add_shortcuts_paste_to_md

* submodule update

* adj
This commit is contained in:
chendapao 2022-10-12 22:54:09 +08:00 committed by GitHub
parent 0f635fba7d
commit e47b813b69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 6 deletions

View File

@ -65,6 +65,7 @@ namespace vnotex
WordCount, WordCount,
Attachment, Attachment,
AlternateViewMode, AlternateViewMode,
ParseToMarkdownAndPaste,
MaxShortcut MaxShortcut
}; };
Q_ENUM(Shortcut) Q_ENUM(Shortcut)

View File

@ -223,7 +223,8 @@
"WordCount" : "", "WordCount" : "",
"Debug" : "F12", "Debug" : "F12",
"Print" : "", "Print" : "",
"ClearHighlights" : "Ctrl+G, Space" "ClearHighlights" : "Ctrl+G, Space",
"ParseToMarkdownAndPaste" : "Ctrl+G, Ctrl+P"
}, },
"spell_check_auto_detect_language" : false, "spell_check_auto_detect_language" : false,
"spell_check_default_dictionary" : "en_US", "spell_check_default_dictionary" : "en_US",

View File

@ -1021,6 +1021,8 @@ void MarkdownEditor::handleContextMenuEvent(QContextMenuEvent *p_event, bool *p_
if (mimeData->hasHtml()) { if (mimeData->hasHtml()) {
// Parse to Markdown and Paste. // Parse to Markdown and Paste.
auto parsePasteAct = new QAction(tr("Parse to Markdown and Paste"), menu); auto parsePasteAct = new QAction(tr("Parse to Markdown and Paste"), menu);
WidgetUtils::addActionShortcutText(parsePasteAct,
editorConfig.getShortcut(EditorConfig::Shortcut::ParseToMarkdownAndPaste));
connect(parsePasteAct, &QAction::triggered, connect(parsePasteAct, &QAction::triggered,
this, &MarkdownEditor::parseToMarkdownAndPaste); this, &MarkdownEditor::parseToMarkdownAndPaste);
WidgetUtils::insertActionAfter(menu, altPasteAct, parsePasteAct); WidgetUtils::insertActionAfter(menu, altPasteAct, parsePasteAct);
@ -1069,11 +1071,24 @@ void MarkdownEditor::setupShortcuts()
{ {
const auto &editorConfig = ConfigMgr::getInst().getEditorConfig(); const auto &editorConfig = ConfigMgr::getInst().getEditorConfig();
auto shortcut = WidgetUtils::createShortcut(editorConfig.getShortcut(EditorConfig::Shortcut::AltPaste), // Alt paste.
this); {
if (shortcut) { auto shortcut = WidgetUtils::createShortcut(editorConfig.getShortcut(EditorConfig::Shortcut::AltPaste),
connect(shortcut, &QShortcut::activated, this);
this, &MarkdownEditor::altPaste); if (shortcut) {
connect(shortcut, &QShortcut::activated,
this, &MarkdownEditor::altPaste);
}
}
// Parse to Markdown and Paste.
{
auto shortcut = WidgetUtils::createShortcut(editorConfig.getShortcut(EditorConfig::Shortcut::ParseToMarkdownAndPaste),
this);
if (shortcut) {
connect(shortcut, &QShortcut::activated,
this, &MarkdownEditor::parseToMarkdownAndPaste);
}
} }
} }