diff options
author | David Schulz <david.schulz@qt.io> | 2019-11-18 10:38:35 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2020-01-22 06:00:11 +0000 |
commit | 4070d6a289ef27bb1629024782c71c7cbcd68db9 (patch) | |
tree | dad0b3c49f18a90d9b4c71f1650f5e18feca7206 /src/plugins/texteditor/texteditoractionhandler.cpp | |
parent | cadb00cdf3bdcf7bc6744c72b90db1e56650f903 (diff) |
Editor: add formatter support
Change-Id: I65590273b2541e08a39970cd9bb4739a5634b2f7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/texteditor/texteditoractionhandler.cpp')
-rw-r--r-- | src/plugins/texteditor/texteditoractionhandler.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 3508d089c5..46e6801f4d 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -133,7 +133,8 @@ public: QAction *m_selectAllAction = nullptr; QAction *m_gotoAction = nullptr; QAction *m_printAction = nullptr; - QAction *m_formatAction = nullptr; + QAction *m_autoIndentAction = nullptr; + QAction *m_autoFormatAction = nullptr; QAction *m_rewrapParagraphAction = nullptr; QAction *m_visualizeWhitespaceAction = nullptr; QAction *m_cleanWhitespaceAction = nullptr; @@ -323,10 +324,14 @@ void TextEditorActionHandlerPrivate::createActions() // register "Edit -> Advanced" Menu Actions Core::ActionContainer *advancedEditMenu = Core::ActionManager::actionContainer(M_EDIT_ADVANCED); - m_formatAction = registerAction(AUTO_INDENT_SELECTION, + m_autoIndentAction = registerAction(AUTO_INDENT_SELECTION, [] (TextEditorWidget *w) { w->autoIndent(); }, true, tr("Auto-&indent Selection"), QKeySequence(tr("Ctrl+I")), G_EDIT_FORMAT, advancedEditMenu); + m_autoFormatAction = registerAction(AUTO_FORMAT_SELECTION, + [] (TextEditorWidget *w) { w->autoFormat(); }, true, tr("Auto-&format Selection"), + QKeySequence(tr("Ctrl+;")), + G_EDIT_FORMAT, advancedEditMenu); m_rewrapParagraphAction = registerAction(REWRAP_PARAGRAPH, [] (TextEditorWidget *w) { w->rewrapParagraph(); }, true, tr("&Rewrap Paragraph"), QKeySequence(Core::useMacShortcuts ? tr("Meta+E, R") : tr("Ctrl+E, R")), @@ -499,7 +504,8 @@ void TextEditorActionHandlerPrivate::createActions() m_modifyingActions << m_deleteStartOfWordCamelCaseAction; m_modifyingActions << m_duplicateSelectionAction; m_modifyingActions << m_duplicateSelectionAndCommentAction; - m_modifyingActions << m_formatAction; + m_modifyingActions << m_autoIndentAction; + m_modifyingActions << m_autoFormatAction; m_modifyingActions << m_indentAction; m_modifyingActions << m_insertLineAboveAction; m_modifyingActions << m_insertLineBelowAction; @@ -528,7 +534,8 @@ void TextEditorActionHandlerPrivate::updateActions() bool isWritable = m_currentEditorWidget && !m_currentEditorWidget->isReadOnly(); foreach (QAction *a, m_modifyingActions) a->setEnabled(isWritable); - m_formatAction->setEnabled((m_optionalActions & TextEditorActionHandler::Format) && isWritable); + m_autoIndentAction->setEnabled((m_optionalActions & TextEditorActionHandler::Format) && isWritable); + m_autoFormatAction->setEnabled((m_optionalActions & TextEditorActionHandler::Format) && isWritable); m_unCommentSelectionAction->setEnabled((m_optionalActions & TextEditorActionHandler::UnCommentSelection) && isWritable); m_visualizeWhitespaceAction->setEnabled(m_currentEditorWidget); m_textWrappingAction->setEnabled(m_currentEditorWidget); |