diff options
author | David Schulz <david.schulz@qt.io> | 2020-06-15 10:14:35 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2020-06-17 07:50:00 +0000 |
commit | bdc8411af5d73187955e7d612b4795bab8049647 (patch) | |
tree | ba21f9d42638b906f02da486f911013bdcb13a94 /src/plugins/texteditor/texteditoractionhandler.cpp | |
parent | 699d89290e6a3d9665c67090de5b3a87b70bd3cd (diff) |
Editor: add update optional actions function to action handler
Change-Id: I342fc53aaa845c6fa2933ea19a0a36a6dc8e6338
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/texteditor/texteditoractionhandler.cpp')
-rw-r--r-- | src/plugins/texteditor/texteditoractionhandler.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 1077417859..b04e89af32 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -114,6 +114,7 @@ public: void createActions(); void updateActions(); + void updateOptionalActions(); void updateRedoAction(bool on); void updateUndoAction(bool on); void updateCopyAction(bool on); @@ -517,13 +518,7 @@ void TextEditorActionHandlerPrivate::createActions() m_modifyingActions << m_upperCaseSelectionAction; m_modifyingActions << m_sortSelectedLinesAction; - // set enabled state of optional actions - m_followSymbolAction->setEnabled(m_optionalActions & TextEditorActionHandler::FollowSymbolUnderCursor); - m_followSymbolInNextSplitAction->setEnabled(m_optionalActions & TextEditorActionHandler::FollowSymbolUnderCursor); - m_jumpToFileAction->setEnabled(m_optionalActions & TextEditorActionHandler::JumpToFileUnderCursor); - m_jumpToFileInNextSplitAction->setEnabled(m_optionalActions & TextEditorActionHandler::JumpToFileUnderCursor); - m_unfoldAllAction->setEnabled(m_optionalActions & TextEditorActionHandler::UnCollapseAll); - m_renameSymbolAction->setEnabled(m_optionalActions & TextEditorActionHandler::RenameSymbol); + updateOptionalActions(); } void TextEditorActionHandlerPrivate::updateActions() @@ -531,8 +526,6 @@ void TextEditorActionHandlerPrivate::updateActions() bool isWritable = m_currentEditorWidget && !m_currentEditorWidget->isReadOnly(); foreach (QAction *a, m_modifyingActions) a->setEnabled(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); @@ -545,6 +538,28 @@ void TextEditorActionHandlerPrivate::updateActions() updateRedoAction(m_currentEditorWidget && m_currentEditorWidget->document()->isRedoAvailable()); updateUndoAction(m_currentEditorWidget && m_currentEditorWidget->document()->isUndoAvailable()); updateCopyAction(m_currentEditorWidget && m_currentEditorWidget->textCursor().hasSelection()); + updateOptionalActions(); +} + +void TextEditorActionHandlerPrivate::updateOptionalActions() +{ + m_followSymbolAction->setEnabled( + m_optionalActions & TextEditorActionHandler::FollowSymbolUnderCursor); + m_followSymbolInNextSplitAction->setEnabled( + m_optionalActions & TextEditorActionHandler::FollowSymbolUnderCursor); + m_jumpToFileAction->setEnabled( + m_optionalActions & TextEditorActionHandler::JumpToFileUnderCursor); + m_jumpToFileInNextSplitAction->setEnabled( + m_optionalActions & TextEditorActionHandler::JumpToFileUnderCursor); + m_unfoldAllAction->setEnabled( + m_optionalActions & TextEditorActionHandler::UnCollapseAll); + m_renameSymbolAction->setEnabled( + m_optionalActions & TextEditorActionHandler::RenameSymbol); + + bool formatEnabled = (m_optionalActions & TextEditorActionHandler::Format) + && m_currentEditorWidget && !m_currentEditorWidget->isReadOnly(); + m_autoIndentAction->setEnabled(formatEnabled); + m_autoFormatAction->setEnabled(formatEnabled); } void TextEditorActionHandlerPrivate::updateRedoAction(bool on) |