forked from qt-creator/qt-creator
TextEditor: add action to paste without autoFormat
Fixes: QTCREATORBUG-20887 Change-Id: Iedc6b584c9c1cc48804025653d0749e054a406f8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -764,6 +764,7 @@ public:
|
|||||||
bool m_animateAutoComplete = true;
|
bool m_animateAutoComplete = true;
|
||||||
bool m_highlightAutoComplete = true;
|
bool m_highlightAutoComplete = true;
|
||||||
bool m_skipAutoCompletedText = true;
|
bool m_skipAutoCompletedText = true;
|
||||||
|
bool m_skipFormatOnPaste = false;
|
||||||
bool m_removeAutoCompletedText = true;
|
bool m_removeAutoCompletedText = true;
|
||||||
bool m_keepAutoCompletionHighlight = false;
|
bool m_keepAutoCompletionHighlight = false;
|
||||||
QList<QTextCursor> m_autoCompleteHighlightPos;
|
QList<QTextCursor> m_autoCompleteHighlightPos;
|
||||||
@@ -7613,6 +7614,13 @@ void TextEditorWidget::circularPaste()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditorWidget::pasteWithoutFormat()
|
||||||
|
{
|
||||||
|
d->m_skipFormatOnPaste = true;
|
||||||
|
paste();
|
||||||
|
d->m_skipFormatOnPaste = false;
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditorWidget::switchUtf8bom()
|
void TextEditorWidget::switchUtf8bom()
|
||||||
{
|
{
|
||||||
textDocument()->switchUtf8Bom();
|
textDocument()->switchUtf8Bom();
|
||||||
@@ -7790,9 +7798,10 @@ void TextEditorWidget::insertFromMimeData(const QMimeData *source)
|
|||||||
|
|
||||||
int reindentBlockEnd = cursor.blockNumber() - (hasFinalNewline?1:0);
|
int reindentBlockEnd = cursor.blockNumber() - (hasFinalNewline?1:0);
|
||||||
|
|
||||||
if (reindentBlockStart < reindentBlockEnd
|
if (!d->m_skipFormatOnPaste
|
||||||
|| (reindentBlockStart == reindentBlockEnd
|
&& (reindentBlockStart < reindentBlockEnd
|
||||||
&& (!insertAtBeginningOfLine || hasFinalNewline))) {
|
|| (reindentBlockStart == reindentBlockEnd
|
||||||
|
&& (!insertAtBeginningOfLine || hasFinalNewline)))) {
|
||||||
if (insertAtBeginningOfLine && !hasFinalNewline) {
|
if (insertAtBeginningOfLine && !hasFinalNewline) {
|
||||||
QTextCursor unnecessaryWhitespace = cursor;
|
QTextCursor unnecessaryWhitespace = cursor;
|
||||||
unnecessaryWhitespace.setPosition(cursorPosition);
|
unnecessaryWhitespace.setPosition(cursorPosition);
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ public:
|
|||||||
void setExtraEncodingSettings(const TextEditor::ExtraEncodingSettings &);
|
void setExtraEncodingSettings(const TextEditor::ExtraEncodingSettings &);
|
||||||
|
|
||||||
void circularPaste();
|
void circularPaste();
|
||||||
|
void pasteWithoutFormat();
|
||||||
void switchUtf8bom();
|
void switchUtf8bom();
|
||||||
|
|
||||||
void zoomF(float delta);
|
void zoomF(float delta);
|
||||||
|
|||||||
@@ -317,8 +317,11 @@ void TextEditorActionHandlerPrivate::createActions()
|
|||||||
[] (TextEditorWidget *w) { w->selectEncoding(); }, false, tr("Select Encoding..."),
|
[] (TextEditorWidget *w) { w->selectEncoding(); }, false, tr("Select Encoding..."),
|
||||||
QKeySequence(), G_EDIT_OTHER, editMenu);
|
QKeySequence(), G_EDIT_OTHER, editMenu);
|
||||||
m_circularPasteAction = registerAction(CIRCULAR_PASTE,
|
m_circularPasteAction = registerAction(CIRCULAR_PASTE,
|
||||||
[] (TextEditorWidget *w) { w->circularPaste(); }, false, tr("Paste from Clipboard History"),
|
[] (TextEditorWidget *w) { w->circularPaste(); }, false, tr("Paste from Clipboard History"),
|
||||||
QKeySequence(tr("Ctrl+Shift+V")), G_EDIT_COPYPASTE, editMenu);
|
QKeySequence(tr("Ctrl+Shift+V")), G_EDIT_COPYPASTE, editMenu);
|
||||||
|
m_circularPasteAction = registerAction(NO_FORMAT_PASTE,
|
||||||
|
[] (TextEditorWidget *w) { w->pasteWithoutFormat(); }, false, tr("Paste without Formatting"),
|
||||||
|
QKeySequence(Core::useMacShortcuts ? tr("Cmd+Opt+Shift+V") : QString()), G_EDIT_COPYPASTE, editMenu);
|
||||||
|
|
||||||
// register "Edit -> Advanced" Menu Actions
|
// register "Edit -> Advanced" Menu Actions
|
||||||
Core::ActionContainer *advancedEditMenu = Core::ActionManager::actionContainer(M_EDIT_ADVANCED);
|
Core::ActionContainer *advancedEditMenu = Core::ActionManager::actionContainer(M_EDIT_ADVANCED);
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ const char INFO_MISSING_SYNTAX_DEFINITION[] = "TextEditor.InfoSyntaxDefinition";
|
|||||||
const char INFO_MULTIPLE_SYNTAX_DEFINITIONS[] = "TextEditor.InfoMultipleSyntaxDefinitions";
|
const char INFO_MULTIPLE_SYNTAX_DEFINITIONS[] = "TextEditor.InfoMultipleSyntaxDefinitions";
|
||||||
const char TASK_OPEN_FILE[] = "TextEditor.Task.OpenFile";
|
const char TASK_OPEN_FILE[] = "TextEditor.Task.OpenFile";
|
||||||
const char CIRCULAR_PASTE[] = "TextEditor.CircularPaste";
|
const char CIRCULAR_PASTE[] = "TextEditor.CircularPaste";
|
||||||
|
const char NO_FORMAT_PASTE[] = "TextEditor.NoFormatPaste";
|
||||||
const char SWITCH_UTF8BOM[] = "TextEditor.SwitchUtf8bom";
|
const char SWITCH_UTF8BOM[] = "TextEditor.SwitchUtf8bom";
|
||||||
const char INDENT[] = "TextEditor.Indent";
|
const char INDENT[] = "TextEditor.Indent";
|
||||||
const char UNINDENT[] = "TextEditor.Unindent";
|
const char UNINDENT[] = "TextEditor.Unindent";
|
||||||
|
|||||||
Reference in New Issue
Block a user