Editor: remove html from default mime data

This is known to be expensive and a lot of users actually prefer plain
text in the copied mime data to avoid unwanted coloring in 3rd party
tools. Add a separate action (Edit > Advanced > Copy With Highlighting)
that preserves the original functionality.

Change-Id: I0f3c529146ab94d0cd9ce9e3b997c8501a577f03
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
David Schulz
2022-08-30 15:34:20 +02:00
parent 77b5613cd9
commit 8fab2011ba
4 changed files with 23 additions and 1 deletions

View File

@@ -104,6 +104,7 @@ public:
QAction *m_undoAction = nullptr;
QAction *m_redoAction = nullptr;
QAction *m_copyAction = nullptr;
QAction *m_copyHtmlAction = nullptr;
QAction *m_cutAction = nullptr;
QAction *m_autoIndentAction = nullptr;
QAction *m_autoFormatAction = nullptr;
@@ -307,6 +308,10 @@ void TextEditorActionHandlerPrivate::createActions()
[] (TextEditorWidget *w) { w->copyLine(); }, false, tr("Copy &Line"),
QKeySequence(tr("Ctrl+Ins")),
G_EDIT_TEXT, advancedEditMenu);
m_copyHtmlAction = registerAction(COPY_WITH_HTML,
[] (TextEditorWidget *w) { w->copyWithHtml(); }, true, tr("Copy With Highlighting"),
QKeySequence(), G_EDIT_TEXT, advancedEditMenu);
registerAction(ADD_CURSORS_TO_LINE_ENDS,
[] (TextEditorWidget *w) { w->addCursorsToLineEnds(); }, false, tr("Create Cursors at Selected Line Ends"),
QKeySequence(tr("Alt+Shift+I")),
@@ -496,6 +501,8 @@ void TextEditorActionHandlerPrivate::updateCopyAction(bool hasCopyableText)
&& !m_currentEditorWidget->isReadOnly());
if (m_copyAction)
m_copyAction->setEnabled(hasCopyableText);
if (m_copyHtmlAction)
m_copyHtmlAction->setEnabled(hasCopyableText);
}
void TextEditorActionHandlerPrivate::updateCurrentEditor(Core::IEditor *editor)