From 3559af69db03529422443ff0cf35884a2d7e2511 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 6 May 2020 07:30:33 +0200 Subject: TextEditor: move rename symbol action to text editor Task-number: QTCREATORBUG-21578 Change-Id: I9a873dcd38bacb2287c45973b6be0091c3eb9480 Reviewed-by: Christian Stenger --- src/plugins/texteditor/texteditor.cpp | 5 +++++ src/plugins/texteditor/texteditor.h | 2 ++ src/plugins/texteditor/texteditoractionhandler.cpp | 5 +++++ src/plugins/texteditor/texteditoractionhandler.h | 3 ++- src/plugins/texteditor/texteditorconstants.h | 2 ++ 5 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/plugins/texteditor') diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 0c8551ec46..2c32af5b28 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -1965,6 +1965,11 @@ void TextEditorWidget::findUsages() emit requestUsages(textCursor()); } +void TextEditorWidget::renameSymbolUnderCursor() +{ + emit requestRename(textCursor()); +} + void TextEditorWidget::abortAssist() { d->m_codeAssistant.destroyContext(); diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index f7b69b4822..ad95abe3cd 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -453,6 +453,7 @@ public: void openLinkUnderCursorInNextSplit(); virtual void findUsages(); + virtual void renameSymbolUnderCursor(); /// Abort code assistant if it is running. void abortAssist(); @@ -490,6 +491,7 @@ signals: void requestLinkAt(const QTextCursor &cursor, Utils::ProcessLinkCallback &callback, bool resolveTarget, bool inNextSplit); void requestUsages(const QTextCursor &cursor); + void requestRename(const QTextCursor &cursor); protected: QTextBlock blockForVisibleRow(int row) const; diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 67d5898509..1077417859 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -182,6 +182,7 @@ public: QAction *m_followSymbolAction = nullptr; QAction *m_followSymbolInNextSplitAction = nullptr; QAction *m_findUsageAction = nullptr; + QAction *m_renameSymbolAction = nullptr; QAction *m_jumpToFileAction = nullptr; QAction *m_jumpToFileInNextSplitAction = nullptr; QList m_modifyingActions; @@ -285,6 +286,9 @@ void TextEditorActionHandlerPrivate::createActions() m_findUsageAction = registerAction(FIND_USAGES, [] (TextEditorWidget *w) { w->findUsages(); }, true, tr("Find References to Symbol Under Cursor"), QKeySequence(tr("Ctrl+Shift+U"))); + m_renameSymbolAction = registerAction(RENAME_SYMBOL, + [] (TextEditorWidget *w) { w->renameSymbolUnderCursor(); }, true, tr("Rename Symbol Under Cursor"), + QKeySequence(tr("Ctrl+Shift+R"))); m_jumpToFileAction = registerAction(JUMP_TO_FILE_UNDER_CURSOR, [] (TextEditorWidget *w) { w->openLinkUnderCursor(); }, true, tr("Jump to File Under Cursor"), QKeySequence(Qt::Key_F2)); @@ -519,6 +523,7 @@ void TextEditorActionHandlerPrivate::createActions() 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); } void TextEditorActionHandlerPrivate::updateActions() diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index f91ad7a806..cfa684a13d 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -55,7 +55,8 @@ public: UnCommentSelection = 2, UnCollapseAll = 4, FollowSymbolUnderCursor = 8, - JumpToFileUnderCursor = 16 + JumpToFileUnderCursor = 16, + RenameSymbol = 32, }; using TextEditorWidgetResolver = std::function; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 3435a713af..c74bbfcde8 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -201,6 +201,8 @@ const char UNINDENT[] = "TextEditor.Unindent"; const char FOLLOW_SYMBOL_UNDER_CURSOR[] = "TextEditor.FollowSymbolUnderCursor"; const char FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT[] = "TextEditor.FollowSymbolUnderCursorInNextSplit"; const char FIND_USAGES[] = "TextEditor.FindUsages"; +// moved from CppEditor to TextEditor avoid breaking the setting by using the old key +const char RENAME_SYMBOL[] = "CppEditor.RenameSymbolUnderCursor"; const char JUMP_TO_FILE_UNDER_CURSOR[] = "TextEditor.JumpToFileUnderCursor"; const char JUMP_TO_FILE_UNDER_CURSOR_IN_NEXT_SPLIT[] = "TextEditor.JumpToFileUnderCursorInNextSplit"; -- cgit v1.2.3