aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/resourceeditor/resourceeditorplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/resourceeditor/resourceeditorplugin.cpp')
-rw-r--r--src/plugins/resourceeditor/resourceeditorplugin.cpp60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp
index 182b11205a..3c1ef9f00c 100644
--- a/src/plugins/resourceeditor/resourceeditorplugin.cpp
+++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp
@@ -25,9 +25,10 @@
#include "resourceeditorplugin.h"
-#include "resourceeditorw.h"
#include "resourceeditorconstants.h"
#include "resourceeditorfactory.h"
+#include "resourceeditortr.h"
+#include "resourceeditorw.h"
#include "resourcenode.h"
#include <coreplugin/icore.h>
@@ -63,15 +64,13 @@
using namespace ProjectExplorer;
using namespace Utils;
-namespace ResourceEditor {
-namespace Internal {
+namespace ResourceEditor::Internal {
-static const char resourcePrefix[] = ":";
-static const char urlPrefix[] = "qrc:";
+const char resourcePrefix[] = ":";
+const char urlPrefix[] = "qrc:";
class PrefixLangDialog : public QDialog
{
- Q_OBJECT
public:
PrefixLangDialog(const QString &title, const QString &prefix, const QString &lang, QWidget *parent)
: QDialog(parent)
@@ -80,11 +79,11 @@ public:
auto layout = new QFormLayout(this);
m_prefixLineEdit = new QLineEdit(this);
m_prefixLineEdit->setText(prefix);
- layout->addRow(tr("Prefix:"), m_prefixLineEdit);
+ layout->addRow(Tr::tr("Prefix:"), m_prefixLineEdit);
m_langLineEdit = new QLineEdit(this);
m_langLineEdit->setText(lang);
- layout->addRow(tr("Language:"), m_langLineEdit);
+ layout->addRow(Tr::tr("Language:"), m_langLineEdit);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel,
@@ -114,8 +113,6 @@ private:
class ResourceEditorPluginPrivate : public QObject
{
- Q_DECLARE_TR_FUNCTIONS(ResourceEditor::Internal::ResourceEditorPlugin)
-
public:
explicit ResourceEditorPluginPrivate(ResourceEditorPlugin *q);
@@ -167,9 +164,9 @@ ResourceEditorPluginPrivate::ResourceEditorPluginPrivate(ResourceEditorPlugin *q
{
// Register undo and redo
const Core::Context context(Constants::C_RESOURCEEDITOR);
- m_undoAction = new QAction(tr("&Undo"), this);
- m_redoAction = new QAction(tr("&Redo"), this);
- m_refreshAction = new QAction(tr("Recheck Existence of Referenced Files"), this);
+ m_undoAction = new QAction(Tr::tr("&Undo"), this);
+ m_redoAction = new QAction(Tr::tr("&Redo"), this);
+ m_refreshAction = new QAction(Tr::tr("Recheck Existence of Referenced Files"), this);
Core::ActionManager::registerAction(m_undoAction, Core::Constants::UNDO, context);
Core::ActionManager::registerAction(m_redoAction, Core::Constants::REDO, context);
Core::ActionManager::registerAction(m_refreshAction, Constants::REFRESH, context);
@@ -184,53 +181,53 @@ ResourceEditorPluginPrivate::ResourceEditorPluginPrivate(ResourceEditorPlugin *q
Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT);
Core::Command *command = nullptr;
- m_addPrefix = new QAction(tr("Add Prefix..."), this);
+ m_addPrefix = new QAction(Tr::tr("Add Prefix..."), this);
command = Core::ActionManager::registerAction(m_addPrefix, Constants::C_ADD_PREFIX, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_addPrefix, &QAction::triggered, this, &ResourceEditorPluginPrivate::addPrefixContextMenu);
- m_renamePrefix = new QAction(tr("Change Prefix..."), this);
+ m_renamePrefix = new QAction(Tr::tr("Change Prefix..."), this);
command = Core::ActionManager::registerAction(m_renamePrefix, Constants::C_RENAME_PREFIX, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_renamePrefix, &QAction::triggered, this, &ResourceEditorPluginPrivate::renamePrefixContextMenu);
- m_removePrefix = new QAction(tr("Remove Prefix..."), this);
+ m_removePrefix = new QAction(Tr::tr("Remove Prefix..."), this);
command = Core::ActionManager::registerAction(m_removePrefix, Constants::C_REMOVE_PREFIX, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_removePrefix, &QAction::triggered, this, &ResourceEditorPluginPrivate::removePrefixContextMenu);
- m_removeNonExisting = new QAction(tr("Remove Missing Files"), this);
+ m_removeNonExisting = new QAction(Tr::tr("Remove Missing Files"), this);
command = Core::ActionManager::registerAction(m_removeNonExisting, Constants::C_REMOVE_NON_EXISTING, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_removeNonExisting, &QAction::triggered, this, &ResourceEditorPluginPrivate::removeNonExisting);
- m_renameResourceFile = new QAction(tr("Rename..."), this);
+ m_renameResourceFile = new QAction(Tr::tr("Rename..."), this);
command = Core::ActionManager::registerAction(m_renameResourceFile, Constants::C_RENAME_FILE, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_renameResourceFile, &QAction::triggered, this, &ResourceEditorPluginPrivate::renameFileContextMenu);
- m_removeResourceFile = new QAction(tr("Remove File..."), this);
+ m_removeResourceFile = new QAction(Tr::tr("Remove File..."), this);
command = Core::ActionManager::registerAction(m_removeResourceFile, Constants::C_REMOVE_FILE, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_removeResourceFile, &QAction::triggered, this, &ResourceEditorPluginPrivate::removeFileContextMenu);
- m_openInEditor = new QAction(tr("Open in Editor"), this);
+ m_openInEditor = new QAction(Tr::tr("Open in Editor"), this);
command = Core::ActionManager::registerAction(m_openInEditor, Constants::C_OPEN_EDITOR, projectTreeContext);
folderContextMenu->addAction(command, ProjectExplorer::Constants::G_FOLDER_FILES);
connect(m_openInEditor, &QAction::triggered, this, &ResourceEditorPluginPrivate::openEditorContextMenu);
- m_openWithMenu = new QMenu(tr("Open With"), folderContextMenu->menu());
+ m_openWithMenu = new QMenu(Tr::tr("Open With"), folderContextMenu->menu());
folderContextMenu->menu()->insertMenu(
folderContextMenu->insertLocation(ProjectExplorer::Constants::G_FOLDER_FILES),
m_openWithMenu);
- m_copyPath = new Utils::ParameterAction(tr("Copy Path"), tr("Copy Path \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
+ m_copyPath = new Utils::ParameterAction(Tr::tr("Copy Path"), Tr::tr("Copy Path \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
command = Core::ActionManager::registerAction(m_copyPath, Constants::C_COPY_PATH, projectTreeContext);
command->setAttribute(Core::Command::CA_UpdateText);
fileContextMenu->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER);
connect(m_copyPath, &QAction::triggered, this, &ResourceEditorPluginPrivate::copyPathContextMenu);
- m_copyUrl = new Utils::ParameterAction(tr("Copy URL"), tr("Copy URL \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
+ m_copyUrl = new Utils::ParameterAction(Tr::tr("Copy URL"), Tr::tr("Copy URL \"%1\""), Utils::ParameterAction::AlwaysEnabled, this);
command = Core::ActionManager::registerAction(m_copyUrl, Constants::C_COPY_URL, projectTreeContext);
command->setAttribute(Core::Command::CA_UpdateText);
fileContextMenu->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER);
@@ -301,7 +298,7 @@ void ResourceEditorPluginPrivate::addPrefixContextMenu()
{
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QTC_ASSERT(topLevel, return);
- PrefixLangDialog dialog(tr("Add Prefix"), QString(), QString(), Core::ICore::dialogParent());
+ PrefixLangDialog dialog(Tr::tr("Add Prefix"), QString(), QString(), Core::ICore::dialogParent());
if (dialog.exec() != QDialog::Accepted)
return;
QString prefix = dialog.prefix();
@@ -315,8 +312,8 @@ void ResourceEditorPluginPrivate::removePrefixContextMenu()
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
QTC_ASSERT(rfn, return);
if (QMessageBox::question(Core::ICore::dialogParent(),
- tr("Remove Prefix"),
- tr("Remove prefix %1 and all its files?").arg(rfn->displayName()))
+ Tr::tr("Remove Prefix"),
+ Tr::tr("Remove prefix %1 and all its files?").arg(rfn->displayName()))
== QMessageBox::Yes) {
ResourceTopLevelNode *rn = rfn->resourceNode();
rn->removePrefix(rfn->prefix(), rfn->lang());
@@ -344,8 +341,8 @@ void ResourceEditorPluginPrivate::removeFileContextMenu()
QTC_ASSERT(parent, return);
if (parent->removeFiles({path}) != RemovedFilesFromProject::Ok)
QMessageBox::warning(Core::ICore::dialogParent(),
- tr("File Removal Failed"),
- tr("Removing file %1 from the project failed.").arg(path.toUserOutput()));
+ Tr::tr("File Removal Failed"),
+ Tr::tr("Removing file %1 from the project failed.").arg(path.toUserOutput()));
}
void ResourceEditorPluginPrivate::openEditorContextMenu()
@@ -372,7 +369,7 @@ void ResourceEditorPluginPrivate::renamePrefixContextMenu()
auto node = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
QTC_ASSERT(node, return);
- PrefixLangDialog dialog(tr("Rename Prefix"),
+ PrefixLangDialog dialog(Tr::tr("Rename Prefix"),
node->prefix(),
node->lang(),
Core::ICore::dialogParent());
@@ -471,7 +468,4 @@ void ResourceEditorPlugin::onUndoStackChanged(ResourceEditorW const *editor,
}
}
-} // namespace Internal
-} // namespace ResourceEditor
-
-#include "resourceeditorplugin.moc"
+} // ResourceEditor::Internal