aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/texteditorplugin.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-01-17 18:02:43 +0100
committerhjk <hjk@qt.io>2023-01-18 07:02:12 +0000
commit17b20e06224f1fdee61fe5477b0789d09d602652 (patch)
tree9b9f1dac81fc4774a1ee1719b9215c0454354aee /src/plugins/texteditor/texteditorplugin.cpp
parent87e5ac74385ffcb8713510c9e243e2455cb17516 (diff)
TextEditor: Tr::tr
Change-Id: I28aa68e25c53c3a4d1c370074d7b3318944dc45a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/texteditor/texteditorplugin.cpp')
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index a60ad61aad..254389c957 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -8,14 +8,16 @@
#include "findinopenfiles.h"
#include "fontsettings.h"
#include "highlighter.h"
+#include "icodestylepreferences.h"
#include "linenumberfilter.h"
#include "outlinefactory.h"
#include "plaintexteditorfactory.h"
#include "snippets/snippetprovider.h"
+#include "tabsettings.h"
#include "textdocument.h"
#include "texteditor.h"
-#include "texteditoractionhandler.h"
#include "texteditorsettings.h"
+#include "texteditortr.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
@@ -24,31 +26,26 @@
#include <coreplugin/externaltoolmanager.h>
#include <coreplugin/foldernavigationwidget.h>
#include <coreplugin/icore.h>
-#include <extensionsystem/pluginmanager.h>
-#include <texteditor/icodestylepreferences.h>
-#include <texteditor/tabsettings.h>
+#include <extensionsystem/pluginmanager.h>
#include <utils/fancylineedit.h>
#include <utils/qtcassert.h>
#include <utils/macroexpander.h>
-#include <QAction>
-#include <QDir>
-
using namespace Core;
using namespace Utils;
namespace TextEditor {
namespace Internal {
-static const char kCurrentDocumentSelection[] = "CurrentDocument:Selection";
-static const char kCurrentDocumentRow[] = "CurrentDocument:Row";
-static const char kCurrentDocumentColumn[] = "CurrentDocument:Column";
-static const char kCurrentDocumentRowCount[] = "CurrentDocument:RowCount";
-static const char kCurrentDocumentColumnCount[] = "CurrentDocument:ColumnCount";
-static const char kCurrentDocumentFontSize[] = "CurrentDocument:FontSize";
-static const char kCurrentDocumentWordUnderCursor[] = "CurrentDocument:WordUnderCursor";
+const char kCurrentDocumentSelection[] = "CurrentDocument:Selection";
+const char kCurrentDocumentRow[] = "CurrentDocument:Row";
+const char kCurrentDocumentColumn[] = "CurrentDocument:Column";
+const char kCurrentDocumentRowCount[] = "CurrentDocument:RowCount";
+const char kCurrentDocumentColumnCount[] = "CurrentDocument:ColumnCount";
+const char kCurrentDocumentFontSize[] = "CurrentDocument:FontSize";
+const char kCurrentDocumentWordUnderCursor[] = "CurrentDocument:WordUnderCursor";
class TextEditorPluginPrivate : public QObject
{
@@ -101,9 +98,9 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
Context context(TextEditor::Constants::C_TEXTEDITOR);
// Add shortcut for invoking automatic completion
- QAction *completionAction = new QAction(tr("Trigger Completion"), this);
+ QAction *completionAction = new QAction(Tr::tr("Trigger Completion"), this);
Command *command = ActionManager::registerAction(completionAction, Constants::COMPLETE_THIS, context);
- command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space")));
+ command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+Space") : Tr::tr("Ctrl+Space")));
connect(completionAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->invokeAssist(Completion);
@@ -114,25 +111,25 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
Utils::FancyLineEdit::setCompletionShortcut(command->keySequence());
// Add shortcut for invoking function hint completion
- QAction *functionHintAction = new QAction(tr("Display Function Hint"), this);
+ QAction *functionHintAction = new QAction(Tr::tr("Display Function Hint"), this);
command = ActionManager::registerAction(functionHintAction, Constants::FUNCTION_HINT, context);
- command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+D")
- : tr("Ctrl+Shift+D")));
+ command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? Tr::tr("Meta+Shift+D")
+ : Tr::tr("Ctrl+Shift+D")));
connect(functionHintAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->invokeAssist(FunctionHint);
});
// Add shortcut for invoking quick fix options
- QAction *quickFixAction = new QAction(tr("Trigger Refactoring Action"), this);
+ QAction *quickFixAction = new QAction(Tr::tr("Trigger Refactoring Action"), this);
Command *quickFixCommand = ActionManager::registerAction(quickFixAction, Constants::QUICKFIX_THIS, context);
- quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return")));
+ quickFixCommand->setDefaultKeySequence(QKeySequence(Tr::tr("Alt+Return")));
connect(quickFixAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->invokeAssist(QuickFix);
});
- QAction *showContextMenuAction = new QAction(tr("Show Context Menu"), this);
+ QAction *showContextMenuAction = new QAction(Tr::tr("Show Context Menu"), this);
ActionManager::registerAction(showContextMenuAction,
Constants::SHOWCONTEXTMENU,
context);
@@ -143,7 +140,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
// Add text snippet provider.
SnippetProvider::registerGroup(Constants::TEXT_SNIPPET_GROUP_ID,
- tr("Text", "SnippetProvider"));
+ Tr::tr("Text", "SnippetProvider"));
d->createStandardContextMenu();
@@ -184,7 +181,7 @@ void TextEditorPlugin::extensionsInitialized()
Utils::MacroExpander *expander = Utils::globalMacroExpander();
expander->registerVariable(kCurrentDocumentSelection,
- tr("Selected text within the current document."),
+ Tr::tr("Selected text within the current document."),
[]() -> QString {
QString value;
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) {
@@ -195,42 +192,42 @@ void TextEditorPlugin::extensionsInitialized()
});
expander->registerIntVariable(kCurrentDocumentRow,
- tr("Line number of the text cursor position in current document (starts with 1)."),
+ Tr::tr("Line number of the text cursor position in current document (starts with 1)."),
[]() -> int {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
return editor ? editor->currentLine() : 0;
});
expander->registerIntVariable(kCurrentDocumentColumn,
- tr("Column number of the text cursor position in current document (starts with 0)."),
+ Tr::tr("Column number of the text cursor position in current document (starts with 0)."),
[]() -> int {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
return editor ? editor->currentColumn() : 0;
});
expander->registerIntVariable(kCurrentDocumentRowCount,
- tr("Number of lines visible in current document."),
+ Tr::tr("Number of lines visible in current document."),
[]() -> int {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
return editor ? editor->rowCount() : 0;
});
expander->registerIntVariable(kCurrentDocumentColumnCount,
- tr("Number of columns visible in current document."),
+ Tr::tr("Number of columns visible in current document."),
[]() -> int {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
return editor ? editor->columnCount() : 0;
});
expander->registerIntVariable(kCurrentDocumentFontSize,
- tr("Current document's font size in points."),
+ Tr::tr("Current document's font size in points."),
[]() -> int {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
return editor ? editor->widget()->font().pointSize() : 0;
});
expander->registerVariable(kCurrentDocumentWordUnderCursor,
- tr("Word under the current document's text cursor."), [] {
+ Tr::tr("Word under the current document's text cursor."), [] {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
if (!editor)
return QString();