diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2022-10-06 14:05:43 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-10-06 12:32:58 +0000 |
commit | 928a7d2087406abef2b076705ba4aa51b8ef3c92 (patch) | |
tree | dcceff7a811fde4771966d874b14764e611ba7a0 /src/plugins/git | |
parent | b8efc2f14de4859409fef57f58e2b813e72bc510 (diff) |
Git: Convert to Tr::tr
Change-Id: I7fb1753109a9263c70c01713f5f4895db6b73662
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/git')
47 files changed, 660 insertions, 758 deletions
diff --git a/src/plugins/git/branchadddialog.cpp b/src/plugins/git/branchadddialog.cpp index 8c988b42a6..2ba6b37131 100644 --- a/src/plugins/git/branchadddialog.cpp +++ b/src/plugins/git/branchadddialog.cpp @@ -5,6 +5,7 @@ #include "branchmodel.h" #include "gitplugin.h" +#include "gittr.h" #include <utils/fancylineedit.h> #include <utils/hostosinfo.h> @@ -19,8 +20,7 @@ #include <QRegularExpression> #include <QValidator> -namespace Git { -namespace Internal { +namespace Git::Internal { /*! * \brief The BranchNameValidator class validates the corresponding string as @@ -94,12 +94,12 @@ BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QW { resize(590, 138); - auto branchNameLabel = new QLabel(tr("Branch Name:")); + auto branchNameLabel = new QLabel(Tr::tr("Branch Name:")); m_branchNameEdit = new QLineEdit(this); m_branchNameEdit->setValidator(new BranchNameValidator(localBranches, this)); - m_checkoutCheckBox = new QCheckBox(tr("Checkout new branch")); + m_checkoutCheckBox = new QCheckBox(Tr::tr("Checkout new branch")); m_trackingCheckBox = new QCheckBox(this); m_trackingCheckBox->setVisible(false); @@ -110,18 +110,18 @@ BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QW switch (type) { case BranchAddDialog::AddBranch: - setWindowTitle(tr("Add Branch")); + setWindowTitle(Tr::tr("Add Branch")); break; case BranchAddDialog::RenameBranch: - setWindowTitle(tr("Rename Branch")); + setWindowTitle(Tr::tr("Rename Branch")); break; case BranchAddDialog::AddTag: - setWindowTitle(tr("Add Tag")); - branchNameLabel->setText(tr("Tag name:")); + setWindowTitle(Tr::tr("Add Tag")); + branchNameLabel->setText(Tr::tr("Tag name:")); break; case BranchAddDialog::RenameTag: - setWindowTitle(tr("Rename Tag")); - branchNameLabel->setText(tr("Tag name:")); + setWindowTitle(Tr::tr("Rename Tag")); + branchNameLabel->setText(Tr::tr("Tag name:")); break; } @@ -159,8 +159,8 @@ void BranchAddDialog::setTrackedBranchName(const QString &name, bool remote) m_trackingCheckBox->setVisible(false); m_trackingCheckBox->setChecked(false); } else { - m_trackingCheckBox->setText(remote ? tr("Track remote branch \"%1\"").arg(name) - : tr("Track local branch \"%1\"").arg(name)); + m_trackingCheckBox->setText(remote ? Tr::tr("Track remote branch \"%1\"").arg(name) + : Tr::tr("Track local branch \"%1\"").arg(name)); m_trackingCheckBox->setVisible(true); m_trackingCheckBox->setChecked(remote); } @@ -188,5 +188,4 @@ void BranchAddDialog::updateButtonStatus() m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_branchNameEdit->hasAcceptableInput()); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/branchadddialog.h b/src/plugins/git/branchadddialog.h index ec4a4b667d..bbcf52070c 100644 --- a/src/plugins/git/branchadddialog.h +++ b/src/plugins/git/branchadddialog.h @@ -10,10 +10,9 @@ QT_BEGIN_NAMESPACE class QCheckBox; class QDialogButtonBox; class QLineEdit; -QT_BEGIN_NAMESPACE +QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { class BranchModel; @@ -30,8 +29,6 @@ private: class BranchAddDialog : public QDialog { - Q_OBJECT - public: enum Type { AddBranch, @@ -62,5 +59,4 @@ private: QDialogButtonBox *m_buttonBox; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/branchcheckoutdialog.cpp b/src/plugins/git/branchcheckoutdialog.cpp index 67dcd30b42..a6819bb58b 100644 --- a/src/plugins/git/branchcheckoutdialog.cpp +++ b/src/plugins/git/branchcheckoutdialog.cpp @@ -3,16 +3,16 @@ #include "branchcheckoutdialog.h" +#include "gittr.h" + #include <utils/layoutbuilder.h> -#include <QApplication> #include <QCheckBox> #include <QDialogButtonBox> #include <QGroupBox> #include <QRadioButton> -namespace Git { -namespace Internal { +namespace Git::Internal { BranchCheckoutDialog::BranchCheckoutDialog(QWidget *parent, const QString ¤tBranch, @@ -22,24 +22,24 @@ BranchCheckoutDialog::BranchCheckoutDialog(QWidget *parent, setWindowModality(Qt::WindowModal); resize(394, 199); setModal(true); - setWindowTitle(tr("Checkout branch \"%1\"").arg(nextBranch)); + setWindowTitle(Tr::tr("Checkout branch \"%1\"").arg(nextBranch)); - m_localChangesGroupBox = new QGroupBox(tr("Local Changes Found. Choose Action:")); + m_localChangesGroupBox = new QGroupBox(Tr::tr("Local Changes Found. Choose Action:")); - m_moveChangesRadioButton = new QRadioButton(tr("Move Local Changes to \"%1\"").arg(nextBranch)); + m_moveChangesRadioButton = new QRadioButton(Tr::tr("Move Local Changes to \"%1\"").arg(nextBranch)); - m_discardChangesRadioButton = new QRadioButton(tr("Discard Local Changes")); + m_discardChangesRadioButton = new QRadioButton(Tr::tr("Discard Local Changes")); m_discardChangesRadioButton->setEnabled(true); - m_popStashCheckBox = new QCheckBox(tr("Pop Stash of \"%1\"").arg(nextBranch)); + m_popStashCheckBox = new QCheckBox(Tr::tr("Pop Stash of \"%1\"").arg(nextBranch)); m_popStashCheckBox->setEnabled(false); m_makeStashRadioButton = new QRadioButton; m_makeStashRadioButton->setChecked(true); if (!currentBranch.isEmpty()) { - m_makeStashRadioButton->setText(tr("Create Branch Stash for \"%1\"").arg(currentBranch)); + m_makeStashRadioButton->setText(Tr::tr("Create Branch Stash for \"%1\"").arg(currentBranch)); } else { - m_makeStashRadioButton->setText(tr("Create Branch Stash for Current Branch")); + m_makeStashRadioButton->setText(Tr::tr("Create Branch Stash for Current Branch")); foundNoLocalChanges(); } @@ -119,6 +119,4 @@ void BranchCheckoutDialog::updatePopStashCheckBox(bool moveChangesChecked) m_popStashCheckBox->setEnabled(!moveChangesChecked && m_foundStashForNextBranch); } -} // namespace Internal -} // namespace Git - +} // Git::Internal diff --git a/src/plugins/git/branchcheckoutdialog.h b/src/plugins/git/branchcheckoutdialog.h index 2b58e7a454..44be2f5669 100644 --- a/src/plugins/git/branchcheckoutdialog.h +++ b/src/plugins/git/branchcheckoutdialog.h @@ -11,13 +11,10 @@ class QGroupBox; class QRadioButton; QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { class BranchCheckoutDialog : public QDialog { - Q_OBJECT - public: explicit BranchCheckoutDialog(QWidget *parent, const QString ¤tBranch, const QString &nextBranch); @@ -47,5 +44,4 @@ private: QCheckBox *m_popStashCheckBox; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index b33b4ab277..c262f07c0b 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -2,8 +2,10 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "branchmodel.h" + #include "gitclient.h" #include "gitconstants.h" +#include "gittr.h" #include <vcsbase/vcscommand.h> #include <vcsbase/vcsoutputwindow.h> @@ -22,8 +24,7 @@ using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { enum RootNodes { LocalBranches = 0, @@ -254,8 +255,8 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) : QTC_CHECK(d->client); // Abuse the sha field for ref prefix - d->rootNode->append(new BranchNode(tr("Local Branches"), "refs/heads")); - d->rootNode->append(new BranchNode(tr("Remote Branches"), "refs/remotes")); + d->rootNode->append(new BranchNode(Tr::tr("Local Branches"), "refs/heads")); + d->rootNode->append(new BranchNode(Tr::tr("Remote Branches"), "refs/remotes")); connect(&d->fsWatcher, &Utils::FileSystemWatcher::fileChanged, this, [this] { QString errorMessage; refresh(d->workingDirectory, &errorMessage); @@ -440,7 +441,7 @@ bool BranchModel::refresh(const FilePath &workingDirectory, QString *errorMessag } if (!d->currentBranch) { BranchNode *local = d->rootNode->children.at(LocalBranches); - d->currentBranch = d->headNode = new BranchNode(tr("Detached HEAD"), "HEAD", QString(), + d->currentBranch = d->headNode = new BranchNode(Tr::tr("Detached HEAD"), "HEAD", QString(), d->currentDateTime); local->prepend(d->headNode); } @@ -796,7 +797,7 @@ void BranchModel::Private::parseOutputLine(const QString &line, bool force) oldEntriesRoot = root->append(new BranchNode(remoteName)); } else if (showTags && nameParts.first() == "tags") { if (!hasTags()) // Tags is missing, add it - rootNode->append(new BranchNode(tr("Tags"), "refs/tags")); + rootNode->append(new BranchNode(Tr::tr("Tags"), "refs/tags")); rootType = Tags; } else { return; @@ -925,6 +926,4 @@ QString BranchModel::toolTip(const QString &sha) const return output; } -} // namespace Internal -} // namespace Git - +} // Git::Internal diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h index 4fa8794a7b..122ed2480b 100644 --- a/src/plugins/git/branchmodel.h +++ b/src/plugins/git/branchmodel.h @@ -6,26 +6,18 @@ #include <utils/filepath.h> #include <QAbstractListModel> -#include <QVariant> #include <optional> namespace VcsBase { class VcsCommand; } -namespace Git { -namespace Internal { - -class GitClient; +namespace Git::Internal { class BranchNode; +class GitClient; -// -------------------------------------------------------------------------- -// BranchModel: -// -------------------------------------------------------------------------- - -class BranchModel : public QAbstractItemModel { - Q_OBJECT - +class BranchModel : public QAbstractItemModel +{ public: explicit BranchModel(GitClient *client, QObject *parent = nullptr); ~BranchModel() override; @@ -80,5 +72,4 @@ private: Private *d; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/branchview.cpp b/src/plugins/git/branchview.cpp index 58a137dacb..eb8d5ad86e 100644 --- a/src/plugins/git/branchview.cpp +++ b/src/plugins/git/branchview.cpp @@ -9,6 +9,7 @@ #include "gitclient.h" #include "gitconstants.h" #include "gitplugin.h" +#include "gittr.h" #include "gitutils.h" #include <coreplugin/actionmanager/command.h> @@ -24,7 +25,6 @@ #include <vcsbase/vcscommand.h> #include <vcsbase/vcsoutputwindow.h> -#include <QDir> #include <QLabel> #include <QKeySequence> #include <QMenu> @@ -39,13 +39,13 @@ using namespace Core; using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { class BranchFilterModel : public QSortFilterProxyModel { public: BranchFilterModel(QObject *parent) : QSortFilterProxyModel(parent) {} + protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override { @@ -70,8 +70,8 @@ struct SetInContext }; BranchView::BranchView() - : m_includeOldEntriesAction(new QAction(tr("Include Old Entries"), this)) - , m_includeTagsAction(new QAction(tr("Include Tags"), this)) + : m_includeOldEntriesAction(new QAction(Tr::tr("Include Old Entries"), this)) + , m_includeTagsAction(new QAction(Tr::tr("Include Tags"), this)) , m_addAction(new QAction(this)) , m_refreshAction(new QAction(this)) , m_repositoryLabel(new ElidingLabel(this)) @@ -83,7 +83,7 @@ BranchView::BranchView() connect(m_addAction, &QAction::triggered, this, &BranchView::add); m_refreshAction->setIcon(Utils::Icons::RELOAD_TOOLBAR.icon()); - m_refreshAction->setToolTip(tr("Refresh")); + m_refreshAction->setToolTip(Tr::tr("Refresh")); connect(m_refreshAction, &QAction::triggered, this, &BranchView::refreshCurrentRepository); m_branchView->setHeaderHidden(true); @@ -108,7 +108,7 @@ BranchView::BranchView() m_includeOldEntriesAction->setCheckable(true); m_includeOldEntriesAction->setToolTip( - tr("Include branches and tags that have not been active for %n days.", nullptr, + Tr::tr("Include branches and tags that have not been active for %n days.", nullptr, Constants::OBSOLETE_COMMIT_AGE_IN_DAYS)); connect(m_includeOldEntriesAction, &QAction::toggled, this, &BranchView::setIncludeOldEntries); @@ -146,13 +146,13 @@ void BranchView::refresh(const FilePath &repository, bool force) m_repository = repository; if (m_repository.isEmpty()) { - m_repositoryLabel->setText(tr("<No repository>")); - m_addAction->setToolTip(tr("Create Git Repository...")); + m_repositoryLabel->setText(Tr::tr("<No repository>")); + m_addAction->setToolTip(Tr::tr("Create Git Repository...")); m_branchView->setEnabled(false); } else { m_repositoryLabel->setText(m_repository.toUserOutput()); m_repositoryLabel->setToolTip(GitPlugin::msgRepositoryLabel(m_repository)); - m_addAction->setToolTip(tr("Add Branch...")); + m_addAction->setToolTip(Tr::tr("Add Branch...")); m_branchView->setEnabled(true); } @@ -179,7 +179,7 @@ QList<QToolButton *> BranchView::createToolButtons() { auto filter = new QToolButton; filter->setIcon(Utils::Icons::FILTER.icon()); - filter->setToolTip(tr("Filter")); + filter->setToolTip(Tr::tr("Filter")); filter->setPopupMode(QToolButton::InstantPopup); filter->setProperty("noArrow", true); @@ -227,75 +227,75 @@ void BranchView::slotCustomContextMenu(const QPoint &point) const bool currentLocal = m_model->isLocal(currentBranch); QMenu contextMenu; - contextMenu.addAction(tr("&Add..."), this, &BranchView::add); + contextMenu.addAction(Tr::tr("&Add..."), this, &BranchView::add); const std::optional<QString> remote = m_model->remoteName(index); if (remote.has_value()) { - contextMenu.addAction(tr("&Fetch"), this, [this, &remote]() { + contextMenu.addAction(Tr::tr("&Fetch"), this, [this, &remote]() { GitClient::instance()->fetch(m_repository, *remote); }); contextMenu.addSeparator(); if (!remote->isEmpty()) { - contextMenu.addAction(tr("Remove &Stale Branches"), this, [this, &remote]() { + contextMenu.addAction(Tr::tr("Remove &Stale Branches"), this, [this, &remote]() { GitClient::instance()->removeStaleRemoteBranches(m_repository, *remote); }); contextMenu.addSeparator(); } - contextMenu.addAction(tr("Manage &Remotes..."), this, [] { + contextMenu.addAction(Tr::tr("Manage &Remotes..."), this, [] { GitPlugin::manageRemotes(); }); } if (hasActions) { if (!currentSelected && (isLocal || isTag)) - contextMenu.addAction(tr("Rem&ove..."), this, &BranchView::remove); + contextMenu.addAction(Tr::tr("Rem&ove..."), this, &BranchView::remove); if (isLocal || isTag) - contextMenu.addAction(tr("Re&name..."), this, &BranchView::rename); + contextMenu.addAction(Tr::tr("Re&name..."), this, &BranchView::rename); if (!currentSelected) - contextMenu.addAction(tr("&Checkout"), this, &BranchView::checkout); + contextMenu.addAction(Tr::tr("&Checkout"), this, &BranchView::checkout); contextMenu.addSeparator(); - contextMenu.addAction(tr("&Diff"), this, [this] { + contextMenu.addAction(Tr::tr("&Diff"), this, [this] { const QString fullName = m_model->fullName(selectedIndex(), true); if (!fullName.isEmpty()) { SetInContext block(m_blockRefresh); GitClient::instance()->diffBranch(m_repository, fullName); } }); - contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); }); - contextMenu.addAction(tr("Reflo&g"), this, [this] { reflog(selectedIndex()); }); + contextMenu.addAction(Tr::tr("&Log"), this, [this] { log(selectedIndex()); }); + contextMenu.addAction(Tr::tr("Reflo&g"), this, [this] { reflog(selectedIndex()); }); contextMenu.addSeparator(); if (!currentSelected) { - auto resetMenu = new QMenu(tr("Re&set"), &contextMenu); - resetMenu->addAction(tr("&Hard"), this, [this] { reset("hard"); }); - resetMenu->addAction(tr("&Mixed"), this, [this] { reset("mixed"); }); - resetMenu->addAction(tr("&Soft"), this, [this] { reset("soft"); }); + auto resetMenu = new QMenu(Tr::tr("Re&set"), &contextMenu); + resetMenu->addAction(Tr::tr("&Hard"), this, [this] { reset("hard"); }); + resetMenu->addAction(Tr::tr("&Mixed"), this, [this] { reset("mixed"); }); + resetMenu->addAction(Tr::tr("&Soft"), this, [this] { reset("soft"); }); contextMenu.addMenu(resetMenu); QString mergeTitle; if (isFastForwardMerge()) { - contextMenu.addAction(tr("&Merge \"%1\" into \"%2\" (Fast-Forward)") + contextMenu.addAction(Tr::tr("&Merge \"%1\" into \"%2\" (Fast-Forward)") .arg(indexName, currentName), this, [this] { merge(true); }); - mergeTitle = tr("Merge \"%1\" into \"%2\" (No &Fast-Forward)") + mergeTitle = Tr::tr("Merge \"%1\" into \"%2\" (No &Fast-Forward)") .arg(indexName, currentName); } else { - mergeTitle = tr("&Merge \"%1\" into \"%2\"") + mergeTitle = Tr::tr("&Merge \"%1\" into \"%2\"") .arg(indexName, currentName); } contextMenu.addAction(mergeTitle, this, [this] { merge(false); }); - contextMenu.addAction(tr("&Rebase \"%1\" on \"%2\"") + contextMenu.addAction(Tr::tr("&Rebase \"%1\" on \"%2\"") .arg(currentName, indexName), this, &BranchView::rebase); contextMenu.addSeparator(); - contextMenu.addAction(tr("Cherry &Pick"), this, &BranchView::cherryPick); + contextMenu.addAction(Tr::tr("Cherry &Pick"), this, &BranchView::cherryPick); } if (!currentSelected && !isTag) { if (currentLocal) { - contextMenu.addAction(tr("&Track"), this, [this] { + contextMenu.addAction(Tr::tr("&Track"), this, [this] { m_model->setRemoteTracking(selectedIndex()); }); } if (!isLocal) { contextMenu.addSeparator(); - contextMenu.addAction(tr("&Push"), this, &BranchView::push); + contextMenu.addAction(Tr::tr("&Push"), this, &BranchView::push); } } } @@ -459,13 +459,13 @@ bool BranchView::remove() const bool wasMerged = isTag ? true : m_model->branchIsMerged(selected); QString message; if (isTag) - message = tr("Would you like to delete the tag \"%1\"?").arg(branchName); + message = Tr::tr("Would you like to delete the tag \"%1\"?").arg(branchName); else if (wasMerged) - message = tr("Would you like to delete the branch \"%1\"?").arg(branchName); + message = Tr::tr("Would you like to delete the branch \"%1\"?").arg(branchName); else - message = tr("Would you like to delete the <b>unmerged</b> branch \"%1\"?").arg(branchName); + message = Tr::tr("Would you like to delete the <b>unmerged</b> branch \"%1\"?").arg(branchName); - if (QMessageBox::question(this, isTag ? tr("Delete Tag") : tr("Delete Branch"), + if (QMessageBox::question(this, isTag ? Tr::tr("Delete Tag") : Tr::tr("Delete Branch"), message, QMessageBox::Yes | QMessageBox::No, wasMerged ? QMessageBox::Yes : QMessageBox::No) == QMessageBox::Yes) { if (isTag) @@ -517,7 +517,7 @@ bool BranchView::reset(const QByteArray &resetType) if (currentName.isEmpty() || branchName.isEmpty()) return false; - if (QMessageBox::question(this, tr("Git Reset"), tr("Reset branch \"%1\" to \"%2\"?") + if (QMessageBox::question(this, Tr::tr("Git Reset"), Tr::tr("Reset branch \"%1\" to \"%2\"?") .arg(currentName, branchName), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { GitClient::instance()->reset(m_repository, QLatin1String("--" + resetType), branchName); @@ -610,7 +610,7 @@ void BranchView::push() BranchViewFactory::BranchViewFactory() { - setDisplayName(tr("Git Branches")); + setDisplayName(Tr::tr("Git Branches")); setPriority(500); setId(Constants::GIT_BRANCH_VIEW_ID); } @@ -626,5 +626,4 @@ BranchView *BranchViewFactory::view() const return m_view; } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/branchview.h b/src/plugins/git/branchview.h index 3fb79d9a9c..5ff8df715f 100644 --- a/src/plugins/git/branchview.h +++ b/src/plugins/git/branchview.h @@ -20,18 +20,15 @@ QT_END_NAMESPACE; namespace Utils { class ElidingLabel; class NavigationTreeView; -} +} // Utils -namespace Git { -namespace Internal { +namespace Git::Internal { class BranchModel; class BranchFilterModel; class BranchView : public QWidget { - Q_OBJECT - public: explicit BranchView(); @@ -80,8 +77,6 @@ private: class BranchViewFactory : public Core::INavigationWidgetFactory { - Q_OBJECT - public: BranchViewFactory(); @@ -93,5 +88,4 @@ private: QPointer<BranchView> m_view; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index d4e9587a85..1ef50c08fd 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -5,6 +5,7 @@ #include "logchangedialog.h" #include "gitclient.h" +#include "gittr.h" #include <coreplugin/vcsmanager.h> @@ -14,9 +15,7 @@ #include <utils/qtcprocess.h> #include <utils/theme/theme.h> -#include <QApplication> #include <QCompleter> -#include <QDir> #include <QFileDialog> #include <QFormLayout> #include <QLabel> @@ -30,8 +29,7 @@ using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { ChangeSelectionDialog::ChangeSelectionDialog(const FilePath &workingDirectory, Id id, QWidget *parent) : @@ -41,14 +39,14 @@ ChangeSelectionDialog::ChangeSelectionDialog(const FilePath &workingDirectory, I m_gitEnvironment = GitClient::instance()->processEnvironment(); resize(550, 350); - setWindowTitle(tr("Select a Git Commit")); + setWindowTitle(Tr::tr("Select a Git Commit")); setObjectName("Git.ChangeSelectionDialog"); m_workingDirectoryChooser = new PathChooser(this); m_changeNumberEdit = new CompletingLineEdit(this); m_changeNumberEdit->setObjectName("changeNumberEdit"); - m_changeNumberEdit->setText(tr("HEAD")); + m_changeNumberEdit->setText(Tr::tr("HEAD")); m_changeNumberEdit->setFocus(); m_changeNumberEdit->selectAll(); @@ -58,25 +56,25 @@ ChangeSelectionDialog::ChangeSelectionDialog(const FilePath &workingDirectory, I m_detailsText->setLineWrapMode(QPlainTextEdit::NoWrap); m_detailsText->setReadOnly(true); - auto selectFromHistoryButton = new QPushButton(tr("Browse &History...")); - auto closeButton = new QPushButton(tr("&Close")); - auto archiveButton = new QPushButton(tr("&Archive...")); + auto selectFromHistoryButton = new QPushButton(Tr::tr("Browse &History...")); + auto closeButton = new QPushButton(Tr::tr("&Close")); + auto archiveButton = new QPushButton(Tr::tr("&Archive...")); - m_checkoutButton = new QPushButton(tr("Check&out")); - m_revertButton = new QPushButton(tr("&Revert")); - m_cherryPickButton = new QPushButton(tr("Cherry &Pick")); - m_showButton = new QPushButton(tr("&Show")); + m_checkoutButton = new QPushButton(Tr::tr("Check&out")); + m_revertButton = new QPushButton(Tr::tr("&Revert")); + m_cherryPickButton = new QPushButton(Tr::tr("Cherry &Pick")); + m_showButton = new QPushButton(Tr::tr("&Show")); m_showButton->setObjectName("showButton"); m_workingDirectoryChooser->setExpectedKind(PathChooser::ExistingDirectory); - m_workingDirectoryChooser->setPromptDialogTitle(tr("Select Git Directory")); + m_workingDirectoryChooser->setPromptDialogTitle(Tr::tr("Select Git Directory")); m_workingDirectoryChooser->setFilePath(workingDirectory); using namespace Layouting; Column { Grid { - tr("Working directory:"), m_workingDirectoryChooser, br, - tr("Change:"), m_changeNumberEdit, selectFromHistoryButton, + Tr::tr("Working directory:"), m_workingDirectoryChooser, br, + Tr::tr("Change:"), m_changeNumberEdit, selectFromHistoryButton, }, m_detailsText, Row { @@ -143,7 +141,7 @@ void ChangeSelectionDialog::selectCommitFromRecentHistory() if (tilde != -1) commit.truncate(tilde); LogChangeDialog dialog(false, this); - dialog.setWindowTitle(tr("Select Commit")); + dialog.setWindowTitle(Tr::tr("Select Commit")); dialog.runDialog(workingDir, commit, LogChangeWidget::IncludeRemotes); @@ -184,9 +182,9 @@ void ChangeSelectionDialog::setDetails() palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal)); m_changeNumberEdit->setPalette(palette); } else if (m_process->result() == ProcessResult::StartFailed) { - m_detailsText->setPlainText(tr("Error: Could not start Git.")); + m_detailsText->setPlainText(Tr::tr("Error: Could not start Git.")); } else { - m_detailsText->setPlainText(tr("Error: Unknown reference")); + m_detailsText->setPlainText(Tr::tr("Error: Unknown reference")); palette.setColor(QPalette::Text, theme->color(Theme::TextColorError)); m_changeNumberEdit->setPalette(palette); enableButtons(false); @@ -231,7 +229,7 @@ void ChangeSelectionDialog::recalculateDetails() const FilePath workingDir = workingDirectory(); if (workingDir.isEmpty()) { - m_detailsText->setPlainText(tr("Error: Bad working directory.")); + m_detailsText->setPlainText(Tr::tr("Error: Bad working directory.")); return; } @@ -247,7 +245,7 @@ void ChangeSelectionDialog::recalculateDetails() m_process->setEnvironment(m_gitEnvironment); m_process->setCommand({m_gitExecutable, {"show", "--decorate", "--stat=80", ref}}); m_process->start(); - m_detailsText->setPlainText(tr("Fetching commit data...")); + m_detailsText->setPlainText(Tr::tr("Fetching commit data...")); } void ChangeSelectionDialog::changeTextChanged(const QString &text) @@ -261,5 +259,4 @@ void ChangeSelectionDialog::changeTextChanged(const QString &text) recalculateDetails(); } -} // Internal -} // Git +} // Git::Internal diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h index 9c43a2cfcb..c75239213e 100644 --- a/src/plugins/git/changeselectiondialog.h +++ b/src/plugins/git/changeselectiondialog.h @@ -21,8 +21,7 @@ class PathChooser; class QtcProcess; } // Utils -namespace Git { -namespace Internal { +namespace Git::Internal { enum ChangeCommand { NoCommand, @@ -35,7 +34,6 @@ enum ChangeCommand { class ChangeSelectionDialog : public QDialog { - Q_OBJECT public: ChangeSelectionDialog(const Utils::FilePath &workingDirectory, Utils::Id id, QWidget *parent); ~ChangeSelectionDialog() override; @@ -71,5 +69,4 @@ private: QPushButton *m_showButton; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/commitdata.cpp b/src/plugins/git/commitdata.cpp index 9c6b948ac1..78e70a5ee4 100644 --- a/src/plugins/git/commitdata.cpp +++ b/src/plugins/git/commitdata.cpp @@ -3,13 +3,12 @@ #include "commitdata.h" +#include "gittr.h" + #include <utils/algorithm.h> #include <utils/qtcassert.h> -#include <QCoreApplication> - -namespace Git { -namespace Internal { +namespace Git::Internal { void GitSubmitEditorPanelInfo::clear() { @@ -175,32 +174,31 @@ QString CommitData::stateDisplayName(const FileStates &state) { QString resultState; if (state == UntrackedFile) - return tr("untracked"); + return Tr::tr("untracked"); if (state & StagedFile) - resultState = tr("staged + "); + resultState = Tr::tr("staged + "); if (state & ModifiedFile) - resultState.append(tr("modified")); + resultState.append(Tr::tr("modified")); else if (state & AddedFile) - resultState.append(tr("added")); + resultState.append(Tr::tr("added")); else if (state & DeletedFile) - resultState.append(tr("deleted")); + resultState.append(Tr::tr("deleted")); else if (state & RenamedFile) - resultState.append(tr("renamed")); + resultState.append(Tr::tr("renamed")); else if (state & CopiedFile) - resultState.append(tr("copied")); + resultState.append(Tr::tr("copied")); else if (state & TypeChangedFile) - resultState.append(tr("typechange")); + resultState.append(Tr::tr("typechange")); if (state & UnmergedUs) { if (state & UnmergedThem) - resultState.append(tr(" by both")); + resultState.append(Tr::tr(" by both")); else - resultState.append(tr(" by us")); + resultState.append(Tr::tr(" by us")); } else if (state & UnmergedThem) { - resultState.append(tr(" by them")); + resultState.append(Tr::tr(" by them")); } return resultState; } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/commitdata.h b/src/plugins/git/commitdata.h index c425016b67..8d6c14ca91 100644 --- a/src/plugins/git/commitdata.h +++ b/src/plugins/git/commitdata.h @@ -7,7 +7,6 @@ #include <utils/filepath.h> -#include <QCoreApplication> #include <QStringList> #include <QPair> @@ -15,8 +14,7 @@ QT_BEGIN_NAMESPACE class QTextCodec; QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { // Read-only class GitSubmitEditorPanelInfo @@ -69,8 +67,6 @@ Q_DECLARE_FLAGS(FileStates, FileState) class CommitData { - Q_DECLARE_TR_FUNCTIONS(Git::Internal::CommitData) - public: CommitData(CommitType type = SimpleCommit); // A pair of state string/file name ('modified', 'file.cpp'). @@ -101,17 +97,14 @@ private: bool checkLine(const QString &stateInfo, const QString &file); }; -} // namespace Internal -} // namespace Git +} // Git::Internal Q_DECLARE_OPERATORS_FOR_FLAGS(Git::Internal::FileStates) -namespace Git { -namespace Internal { +namespace Git::Internal { // Must appear after Q_DECLARE_OPERATORS_FOR_FLAGS bool operator<(const CommitData::StateFilePair &a, const CommitData::StateFilePair &b); -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gerrit/authenticationdialog.cpp b/src/plugins/git/gerrit/authenticationdialog.cpp index a12c62f2b0..3dacd0d271 100644 --- a/src/plugins/git/gerrit/authenticationdialog.cpp +++ b/src/plugins/git/gerrit/authenticationdialog.cpp @@ -5,6 +5,8 @@ #include "gerritserver.h" +#include "../gittr.h" + #include <utils/fileutils.h> #include <utils/hostosinfo.h> #include <utils/layoutbuilder.h> @@ -52,11 +54,11 @@ static bool replaceEntry(QString &line, const QString &type, const QString &valu AuthenticationDialog::AuthenticationDialog(GerritServer *server) : m_server(server) { - setWindowTitle(tr("Authentication")); + setWindowTitle(Git::Tr::tr("Authentication")); resize(400, 334); // FIXME: Take html out of this translatable string. - const QString desc = tr( + const QString desc = Git::Tr::tr( "<html><head/><body><p>Gerrit server with HTTP was detected, but you need " "to set up credentials for it.</p><p>To get your password, " "<a href=\"LINK_PLACEHOLDER\"><span style=\" text-decoration: " @@ -90,16 +92,16 @@ AuthenticationDialog::AuthenticationDialog(GerritServer *server) Column { descriptionLabel, Form { - tr("Server:"), serverLineEdit, br, - tr("&User:"), m_userLineEdit, br, - tr("&Password:"), m_passwordLineEdit, br, + Git::Tr::tr("Server:"), serverLineEdit, br, + Git::Tr::tr("&User:"), m_userLineEdit, br, + Git::Tr::tr("&Password:"), m_passwordLineEdit, br, }, m_buttonBox, }.attachTo(this); readExistingConf(); - QPushButton *anonymous = m_buttonBox->addButton(tr("Anonymous"), QDialogButtonBox::AcceptRole); + QPushButton *anonymous = m_buttonBox->addButton(Git::Tr::tr("Anonymous"), QDialogButtonBox::AcceptRole); connect(m_buttonBox, &QDialogButtonBox::clicked, this, [this, anonymous](QAbstractButton *button) { if (button == anonymous) diff --git a/src/plugins/git/gerrit/gerritdialog.cpp b/src/plugins/git/gerrit/gerritdialog.cpp index 2abf25249f..e6f8307013 100644 --- a/src/plugins/git/gerrit/gerritdialog.cpp +++ b/src/plugins/git/gerrit/gerritdialog.cpp @@ -8,6 +8,7 @@ #include "gerritremotechooser.h" #include "../gitplugin.h" +#include "../gittr.h" #include <coreplugin/icore.h> @@ -54,7 +55,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, , m_model(new GerritModel(p, this)) , m_queryModel(new QStringListModel(this)) { - setWindowTitle(tr("Gerrit")); + setWindowTitle(Git::Tr::tr("Gerrit")); resize(950, 706); m_repositoryLabel = new QLabel(this); @@ -64,12 +65,12 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, m_remoteComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); m_remoteComboBox->setMinimumSize(QSize(40, 0)); - auto changesGroup = new QGroupBox(tr("Changes")); + auto changesGroup = new QGroupBox(Git::Tr::tr("Changes")); changesGroup->setMinimumSize(QSize(0, 350)); m_queryLineEdit = new FancyLineEdit(changesGroup); m_queryLineEdit->setMinimumSize(QSize(400, 0)); - m_queryLineEdit->setPlaceholderText(tr("Change #, SHA-1, tr:id, owner:email or reviewer:email")); + m_queryLineEdit->setPlaceholderText(Git::Tr::tr("Change #, SHA-1, tr:id, owner:email or reviewer:email")); m_queryLineEdit->setSpecialCompleter(new QCompleter(m_queryModel, this)); m_queryLineEdit->setValidationFunction( [this](FancyLineEdit *, QString *) { return m_model->state() != GerritModel::Error; }); @@ -84,7 +85,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, m_treeView->setUniformRowHeights(true); m_treeView->setSortingEnabled(true); - auto detailsGroup = new QGroupBox(tr("Details")); + auto detailsGroup = new QGroupBox(Git::Tr::tr("Details")); detailsGroup->setMinimumSize(QSize(0, 175)); m_detailsBrowser = new QTextBrowser(detailsGroup); @@ -92,7 +93,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - auto queryLabel = new QLabel(tr("&Query:"), changesGroup); + auto queryLabel = new QLabel(Git::Tr::tr("&Query:"), changesGroup); queryLabel->setBuddy(m_queryLineEdit); m_remoteComboBox->setParameters(m_parameters); @@ -113,10 +114,10 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, m_progressIndicator->attachToWidget(m_treeView->viewport()); m_progressIndicator->hide(); - m_displayButton = addActionButton(tr("&Show"), [this]() { slotFetchDisplay(); }); - m_cherryPickButton = addActionButton(tr("Cherry &Pick"), [this]() { slotFetchCherryPick(); }); - m_checkoutButton = addActionButton(tr("C&heckout"), [this]() { slotFetchCheckout(); }); - m_refreshButton = addActionButton(tr("&Refresh"), [this]() { refresh(); }); + m_displayButton = addActionButton(Git::Tr::tr("&Show"), [this]() { slotFetchDisplay(); }); + m_cherryPickButton = addActionButton(Git::Tr::tr("Cherry &Pick"), [this]() { slotFetchCherryPick(); }); + m_checkoutButton = addActionButton(Git::Tr::tr("C&heckout"), [this]() { slotFetchCheckout(); }); + m_refreshButton = addActionButton(Git::Tr::tr("&Refresh"), [this]() { refresh(); }); m_refreshButton->setDefault(true); using namespace Layouting; @@ -142,7 +143,7 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p, splitter->addWidget(detailsGroup); Column { - Row { m_repositoryLabel, st, tr("Remote:"), m_remoteComboBox }, + Row { m_repositoryLabel, st, Git::Tr::tr("Remote:"), m_remoteComboBox }, splitter, m_buttonBox }.attachTo(this); @@ -340,7 +341,7 @@ void GerritDialog::fetchStarted(const QSharedPointer<GerritChange> &change) // Disable buttons to prevent parallel gerrit operations which can cause mix-ups. m_fetchRunning = true; updateButtons(); - const QString toolTip = tr("Fetching \"%1\"...").arg(change->title); + const QString toolTip = Git::Tr::tr("Fetching \"%1\"...").arg(change->title); m_displayButton->setToolTip(toolTip); m_cherryPickButton->setToolTip(toolTip); m_checkoutButton->setToolTip(toolTip); diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp index 1f453f10e0..9691a8266a 100644 --- a/src/plugins/git/gerrit/gerritmodel.cpp +++ b/src/plugins/git/gerrit/gerritmodel.cpp @@ -3,6 +3,7 @@ #include "gerritmodel.h" #include "../gitclient.h" +#include "../gittr.h" #include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/futureprogress.h> @@ -195,7 +196,7 @@ QString GerritChange::fullTitle() const { QString res = title; if (status == "DRAFT") - res += GerritModel::tr(" (Draft)"); + res += Git::Tr::tr(" (Draft)"); return res; } @@ -293,7 +294,7 @@ QueryContext::~QueryContext() void QueryContext::start() { - Core::FutureProgress *fp = Core::ProgressManager::addTask(m_progress.future(), tr("Querying Gerrit"), + Core::FutureProgress *fp = Core::ProgressManager::addTask(m_progress.future(), Git::Tr::tr("Querying Gerrit"), "gerrit-query"); fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish); m_progress.reportStarted(); @@ -326,11 +327,11 @@ void QueryContext::processDone() emit errorText(m_error); if (m_process.exitStatus() == QProcess::CrashExit) - errorTermination(tr("%1 crashed.").arg(m_binary.toUserOutput())); + errorTermination(Git::Tr::tr("%1 crashed.").arg(m_binary.toUserOutput())); else if (m_process.exitCode()) - errorTermination(tr("%1 returned %2.").arg(m_binary.toUserOutput()).arg(m_process.exitCode())); + errorTermination(Git::Tr::tr("%1 returned %2.").arg(m_binary.toUserOutput()).arg(m_process.exitCode())); else if (m_process.result() != ProcessResult::FinishedWithSuccess) - errorTermination(tr("Error running %1: %2").arg(m_binary.toUserOutput(), m_process.errorString())); + errorTermination(Git::Tr::tr("Error running %1: %2").arg(m_binary.toUserOutput(), m_process.errorString())); else emit resultRetrieved(m_output); @@ -346,13 +347,13 @@ void QueryContext::timeout() QWidget *parent = QApplication::activeModalWidget(); if (!parent) parent = QApplication::activeWindow(); - QMessageBox box(QMessageBox::Question, tr("Timeout"), - tr("The gerrit process has not responded within %1 s.\n" + QMessageBox box(QMessageBox::Question, Git::Tr::tr("Timeout"), + Git::Tr::tr("The gerrit process has not responded within %1 s.\n" "Most likely this is caused by problems with SSH authentication.\n" "Would you like to terminate it?"). arg(timeOutMS / 1000), QMessageBox::NoButton, parent); - QPushButton *terminateButton = box.addButton(tr("Terminate"), QMessageBox::YesRole); - box.addButton(tr("Keep Running"), QMessageBox::NoRole); + QPushButton *terminateButton = box.addButton(Git::Tr::tr("Terminate"), QMessageBox::YesRole); + box.addButton(Git::Tr::tr("Keep Running"), QMessageBox::NoRole); connect(&m_process, &QtcProcess::done, &box, &QDialog::reject); box.exec(); if (m_process.state() != QProcess::Running) @@ -368,9 +369,9 @@ GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *par , m_parameters(p) { QStringList headers; // Keep in sync with GerritChange::toHtml() - headers << "#" << tr("Subject") << tr("Owner") - << tr("Updated") << tr("Project") - << tr("Approvals") << tr("Status"); + headers << "#" << Git::Tr::tr("Subject") << Git::Tr::tr("Owner") + << Git::Tr::tr("Updated") << Git::Tr::tr("Project") + << Git::Tr::tr("Approvals") << Git::Tr::tr("Status"); setHorizontalHeaderLabels(headers); } @@ -413,15 +414,15 @@ QString GerritModel::dependencyHtml(const QString &header, const int changeNumbe QString GerritModel::toHtml(const QModelIndex& index) const { - static const QString subjectHeader = GerritModel::tr("Subject"); - static const QString numberHeader = GerritModel::tr("Number"); - static const QString ownerHeader = GerritModel::tr("Owner"); - static const QString projectHeader = GerritModel::tr("Project"); - static const QString statusHeader = GerritModel::tr("Status"); - static const QString patchSetHeader = GerritModel::tr("Patch set"); - static const QString urlHeader = GerritModel::tr("URL"); - static const QString dependsOnHeader = GerritModel::tr("Depends on"); - static const QString neededByHeader = GerritModel::tr("Needed by"); + static const QString subjectHeader = Git::Tr::tr("Subject"); + static const QString numberHeader = Git::Tr::tr("Number"); + static const QString ownerHeader = Git::Tr::tr("Owner"); + static const QString projectHeader = Git::Tr::tr("Project"); + static const QString statusHeader = Git::Tr::tr("Status"); + static const QString patchSetHeader = Git::Tr::tr("Patch set"); + static const QString urlHeader = Git::Tr::tr("URL"); + static const QString dependsOnHeader = Git::Tr::tr("Depends on"); + static const QString neededByHeader = Git::Tr::tr("Needed by"); if (!index.isValid()) return QString(); @@ -781,7 +782,7 @@ static bool parseOutput(const QSharedPointer<GerritParameters> ¶meters, QJsonParseError error; const QJsonDocument doc = QJsonDocument::fromJson(adaptedOutput, &error); if (doc.isNull()) { - QString errorMessage = GerritModel::tr("Parse error: \"%1\" -> %2") + QString errorMessage = Git::Tr::tr("Parse error: \"%1\" -> %2") .arg(QString::fromUtf8(output)) .arg(error.errorString()); qWarning() << errorMessage; @@ -806,7 +807,7 @@ static bool parseOutput(const QSharedPointer<GerritParameters> ¶meters, } else { const QByteArray jsonObject = QJsonDocument(object).toJson(); qWarning("%s: Parse error: '%s'.", Q_FUNC_INFO, jsonObject.constData()); - VcsOutputWindow::appendError(GerritModel::tr("Parse error: \"%1\"") + VcsOutputWindow::appendError(Git::Tr::tr("Parse error: \"%1\"") .arg(QString::fromUtf8(jsonObject))); res = false; } diff --git a/src/plugins/git/gerrit/gerritoptionspage.cpp b/src/plugins/git/gerrit/gerritoptionspage.cpp index 2a9ba514dc..af7774f905 100644 --- a/src/plugins/git/gerrit/gerritoptionspage.cpp +++ b/src/plugins/git/gerrit/gerritoptionspage.cpp @@ -4,6 +4,7 @@ #include "gerritoptionspage.h" #include "gerritparameters.h" #include "gerritserver.h" +#include "gittr.h" #include <coreplugin/icore.h> #include <utils/pathchooser.h> @@ -24,7 +25,7 @@ GerritOptionsPage::GerritOptionsPage(const QSharedPointer<GerritParameters> &p, , m_parameters(p) { setId("Gerrit"); - setDisplayName(tr("Gerrit")); + setDisplayName(Git::Tr::tr("Gerrit")); setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); } @@ -70,24 +71,24 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent) , m_sshChooser(new Utils::PathChooser) , m_curlChooser(new Utils::PathChooser) , m_portSpinBox(new QSpinBox(this)) - , m_httpsCheckBox(new QCheckBox(tr("HTTPS"))) + , m_httpsCheckBox(new QCheckBox(Git::Tr::tr("HTTPS"))) { auto formLayout = new QFormLayout(this); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - formLayout->addRow(tr("&Host:"), m_hostLineEdit); - formLayout->addRow(tr("&User:"), m_userLineEdit); + formLayout->addRow(Git::Tr::tr("&Host:"), m_hostLineEdit); + formLayout->addRow(Git::Tr::tr("&User:"), m_userLineEdit); m_sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_sshChooser->setCommandVersionArguments({"-V"}); m_sshChooser->setHistoryCompleter("Git.SshCommand.History"); - formLayout->addRow(tr("&ssh:"), m_sshChooser); + formLayout->addRow(Git::Tr::tr("&ssh:"), m_sshChooser); m_curlChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_curlChooser->setCommandVersionArguments({"-V"}); - formLayout->addRow(tr("cur&l:"), m_curlChooser); + formLayout->addRow(Git::Tr::tr("cur&l:"), m_curlChooser); m_portSpinBox->setMinimum(1); m_portSpinBox->setMaximum(65535); - formLayout->addRow(tr("SSH &Port:"), m_portSpinBox); - formLayout->addRow(tr("P&rotocol:"), m_httpsCheckBox); - m_httpsCheckBox->setToolTip(tr( + formLayout->addRow(Git::Tr::tr("SSH &Port:"), m_portSpinBox); + formLayout->addRow(Git::Tr::tr("P&rotocol:"), m_httpsCheckBox); + m_httpsCheckBox->setToolTip(Git::Tr::tr( "Determines the protocol used to form a URL in case\n" "\"canonicalWebUrl\" is not configured in the file\n" "\"gerrit.config\".")); diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 6d1431aac6..31e515636d 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -8,8 +8,10 @@ #include "gerritoptionspage.h" #include "gerritpushdialog.h" -#include "../gitplugin.h" #include "../gitclient.h" +#include "../gitplugin.h" +#include "../gittr.h" + #include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseeditor.h> @@ -139,7 +141,7 @@ FetchContext::~FetchContext() void FetchContext::start() { m_progress.setProgressRange(0, 2); - FutureProgress *fp = ProgressManager::addTask(m_progress.future(), tr("Fetching from Gerrit"), + FutureProgress *fp = ProgressManager::addTask(m_progress.future(), Git::Tr::tr("Fetching from Gerrit"), "gerrit-fetch"); fp->setKeepOnFinish(FutureProgress::HideOnFinish); m_progress.reportStarted(); @@ -237,14 +239,14 @@ void GerritPlugin::initialize(ActionContainer *ac) { m_parameters->fromSettings(ICore::settings()); - QAction *openViewAction = new QAction(tr("Gerrit..."), this); + QAction *openViewAction = new QAction(Git::Tr::tr("Gerrit..."), this); m_gerritCommand = ActionManager::registerAction(openViewAction, Constants::GERRIT_OPEN_VIEW); connect(openViewAction, &QAction::triggered, this, &GerritPlugin::openView); ac->addAction(m_gerritCommand); - QAction *pushAction = new QAction(tr("Push to Gerrit..."), this); + QAction *pushAction = new QAction(Git::Tr::tr("Push to Gerrit..."), this); m_pushToGerritCommand = ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH); @@ -281,7 +283,7 @@ void GerritPlugin::push(const FilePath &topLevel) const QString initErrorMessage = dialog.initErrorMessage(); if (!initErrorMessage.isEmpty()) { - QMessageBox::warning(ICore::dialogParent(), tr("Initialization Failed"), initErrorMessage); + QMessageBox::warning(ICore::dialogParent(), Git::Tr::tr("Initialization Failed"), initErrorMessage); return; } @@ -303,8 +305,8 @@ void GerritPlugin::openView() { if (m_dialog.isNull()) { while (!m_parameters->isValid()) { - QMessageBox::warning(Core::ICore::dialogParent(), tr("Error"), - tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory.")); + QMessageBox::warning(Core::ICore::dialogParent(), Git::Tr::tr("Error"), + Git::Tr::tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory.")); if (!ICore::showOptionsDialog("Gerrit")) return; } @@ -352,7 +354,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) // Locate git. const Utils::FilePath git = GitClient::instance()->vcsBinary(); if (git.isEmpty()) { - VcsBase::VcsOutputWindow::appendError(tr("Git is not available.")); + VcsBase::VcsOutputWindow::appendError(Git::Tr::tr("Git is not available.")); return; } @@ -392,8 +394,8 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) if (!verifiedRepository) { QMessageBox::StandardButton answer = QMessageBox::question( - ICore::dialogParent(), tr("Remote Not Verified"), - tr("Change host %1\nand project %2\n\nwere not verified among remotes" + ICore::dialogParent(), Git::Tr::tr("Remote Not Verified"), + Git::Tr::tr("Change host %1\nand project %2\n\nwere not verified among remotes" " in %3. Select different folder?") .arg(m_server->host, change->project, @@ -416,7 +418,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) if (!verifiedRepository) { // Ask the user for a repository to retrieve the change. const QString title = - tr("Enter Local Repository for \"%1\" (%2)").arg(change->project, change->branch); + Git::Tr::tr("Enter Local Repository for \"%1\" (%2)").arg(change->project, change->branch); const FilePath suggestedRespository = findLocalRepository(change->project, change->branch); repository = FileUtils::getExistingDirectory(m_dialog.data(), title, suggestedRespository); } diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index 00fd6836ff..cbb2935531 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -7,6 +7,7 @@ #include "../gitclient.h" #include "../gitconstants.h" +#include "../gittr.h" #include <utils/icon.h> #include <utils/stringutils.h> @@ -120,7 +121,7 @@ GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir, const QStr initRemoteBranches(); if (m_ui->remoteComboBox->isEmpty()) { - m_initErrorMessage = tr("Cannot find a Gerrit remote. Add one and try again."); + m_initErrorMessage = Git::Tr::tr("Cannot find a Gerrit remote. Add one and try again."); return; } @@ -190,14 +191,14 @@ void GerritPushDialog::setChangeRange() } m_ui->infoLabel->show(); const QString remote = selectedRemoteName() + '/' + remoteBranchName; - QString labelText = tr("Number of commits between %1 and %2: %3").arg(branch, remote, range); + QString labelText = Git::Tr::tr("Number of commits between %1 and %2: %3").arg(branch, remote, range); const int currentRange = range.toInt(); QPalette palette = QApplication::palette(); if (currentRange > ReasonableDistance) { const QColor errorColor = Utils::creatorTheme()->color(Utils::Theme::TextColorError); palette.setColor(QPalette::WindowText, errorColor); palette.setColor(QPalette::ButtonText, errorColor); - labelText.append("\n" + tr("Are you sure you selected the right target branch?")); + labelText.append("\n" + Git::Tr::tr("Are you sure you selected the right target branch?")); } m_ui->infoLabel->setPalette(palette); m_ui->targetBranchComboBox->setPalette(palette); @@ -226,21 +227,21 @@ void GerritPushDialog::onRemoteChanged(bool force) m_currentSupportsWip = supportsWip; m_ui->wipCheckBox->setEnabled(supportsWip); if (supportsWip) { - m_ui->wipCheckBox->setToolTip(tr("Checked - Mark change as WIP.\n" + m_ui->wipCheckBox->setToolTip(Git::Tr::tr("Checked - Mark change as WIP.\n" "Unchecked - Mark change as ready for review.\n" "Partially checked - Do not change current state.")); m_ui->draftCheckBox->setTristate(true); if (m_ui->draftCheckBox->checkState() != Qt::Checked) m_ui->draftCheckBox->setCheckState(Qt::PartiallyChecked); - m_ui->draftCheckBox->setToolTip(tr("Checked - Mark change as private.\n" + m_ui->draftCheckBox->setToolTip(Git::Tr::tr("Checked - Mark change as private.\n" "Unchecked - Remove mark.\n" "Partially checked - Do not change current state.")); } else { - m_ui->wipCheckBox->setToolTip(tr("Supported on Gerrit 2.15 and later.")); + m_ui->wipCheckBox->setToolTip(Git::Tr::tr("Supported on Gerrit 2.15 and later.")); m_ui->draftCheckBox->setTristate(false); if (m_ui->draftCheckBox->checkState() != Qt::Checked) m_ui->draftCheckBox->setCheckState(Qt::Unchecked); - m_ui->draftCheckBox->setToolTip(tr("Checked - The change is a draft.\n" + m_ui->draftCheckBox->setToolTip(Git::Tr::tr("Checked - The change is a draft.\n" "Unchecked - The change is not a draft.")); } } @@ -309,9 +310,9 @@ void GerritPushDialog::setRemoteBranches(bool includeOld) if (remoteBranches.isEmpty()) { m_ui->targetBranchComboBox->setEditable(true); m_ui->targetBranchComboBox->setToolTip( - tr("No remote branches found. This is probably the initial commit.")); + Git::Tr::tr("No remote branches found. This is probably the initial commit.")); if (QLineEdit *lineEdit = m_ui->targetBranchComboBox->lineEdit()) - lineEdit->setPlaceholderText(tr("Branch name")); + lineEdit->setPlaceholderText(Git::Tr::tr("Branch name")); } } @@ -331,7 +332,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld) } } if (excluded) - m_ui->targetBranchComboBox->addItem(tr("... Include older branches ..."), 1); + m_ui->targetBranchComboBox->addItem(Git::Tr::tr("... Include older branches ..."), 1); setChangeRange(); } validate(); diff --git a/src/plugins/git/gerrit/gerritremotechooser.cpp b/src/plugins/git/gerrit/gerritremotechooser.cpp index 4ccd0ae28d..df628194ba 100644 --- a/src/plugins/git/gerrit/gerritremotechooser.cpp +++ b/src/plugins/git/gerrit/gerritremotechooser.cpp @@ -5,6 +5,7 @@ #include "gerritparameters.h" #include "gerritserver.h" #include "../gitclient.h" +#include "../gittr.h" #include <utils/filepath.h> #include <utils/qtcassert.h> @@ -34,7 +35,7 @@ GerritRemoteChooser::GerritRemoteChooser(QWidget *parent) : horizontalLayout->setContentsMargins(0, 0, 0, 0); m_resetRemoteButton = new QToolButton(this); - m_resetRemoteButton->setToolTip(tr("Refresh Remote Servers")); + m_resetRemoteButton->setToolTip(Git::Tr::tr("Refresh Remote Servers")); horizontalLayout->addWidget(m_resetRemoteButton); @@ -92,7 +93,7 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload) addRemote(server, mapIt.key()); } if (m_enableFallback) - addRemote(m_parameters->server, tr("Fallback")); + addRemote(m_parameters->server, Git::Tr::tr("Fallback")); m_remoteComboBox->setEnabled(m_remoteComboBox->count() > 1); m_updatingRemotes = false; handleRemoteChanged(); diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 7b7f121580..386549993f 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -2,14 +2,15 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "gitclient.h" -#include "gitutils.h" +#include "branchadddialog.h" #include "commitdata.h" #include "gitconstants.h" #include "giteditor.h" #include "gitplugin.h" +#include "gittr.h" +#include "gitutils.h" #include "mergetool.h" -#include "branchadddialog.h" #include <coreplugin/coreconstants.h> #include <coreplugin/editormanager/editormanager.h> @@ -84,8 +85,7 @@ using namespace DiffEditor; using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { static GitClient *m_instance = nullptr; @@ -117,7 +117,7 @@ static QString branchesDisplay(const QString &prefix, QStringList *branches, boo //: Displayed after the untranslated message "Branches: branch1, branch2 'and %n more'" // in git show. if (more > 0) - output += ' ' + GitClient::tr("and %n more", nullptr, more); + output += ' ' + Tr::tr("and %n more", nullptr, more); return output; } @@ -347,7 +347,7 @@ void GitBaseDiffEditorController::updateBranchList() } if (branches.isEmpty()) { if (previousRemote == localPrefix) - output += tr("<None>"); + output += Tr::tr("<None>"); } else { output += branchesDisplay(previousRemote, &branches, &first); } @@ -483,7 +483,7 @@ void ShowController::processDescription(const QString &output) int lastHeaderLine = modText.indexOf("\n\n") + 1; m_header = output.left(lastHeaderLine) + Constants::EXPAND_BRANCHES + '\n'; m_body = output.mid(lastHeaderLine + 1); - m_precedes = tr("<resolving>"); + m_precedes = Tr::tr("<resolving>"); m_follows.push_back(m_precedes); updateDescription(); const QString commit = modText.mid(7, 8); @@ -560,11 +560,11 @@ public: VcsBaseEditorConfig(toolBar) { m_patienceButton - = addToggleButton("--patience", tr("Patience"), - tr("Use the patience algorithm for calculating the differences.")); + = addToggleButton("--patience", Tr::tr("Patience"), + Tr::tr("Use the patience algorithm for calculating the differences.")); mapSetting(m_patienceButton, &settings.diffPatience); - m_ignoreWSButton = addToggleButton("--ignore-space-change", tr("Ignore Whitespace"), - tr("Ignore whitespace only changes.")); + m_ignoreWSButton = addToggleButton("--ignore-space-change", Tr::tr("Ignore Whitespace"), + Tr::tr("Ignore whitespace only changes.")); mapSetting(m_ignoreWSButton, &settings.ignoreSpaceChangesInDiff); } @@ -581,20 +581,20 @@ public: GitBlameArgumentsWidget(GitSettings &settings, QToolBar *toolBar) : VcsBaseEditorConfig(toolBar) { - mapSetting(addToggleButton(QString(), tr("Omit Date"), - tr("Hide the date of a change from the output.")), + mapSetting(addToggleButton(QString(), Tr::tr("Omit Date"), + Tr::tr("Hide the date of a change from the output.")), &settings.omitAnnotationDate); - mapSetting(addToggleButton("-w", tr("Ignore Whitespace"), - tr("Ignore whitespace only changes.")), + mapSetting(addToggleButton("-w", Tr::tr("Ignore Whitespace"), + Tr::tr("Ignore whitespace only changes.")), &settings.ignoreSpaceChangesInBlame); const QList<ChoiceItem> logChoices = { - ChoiceItem(tr("No Move Detection"), ""), - ChoiceItem(tr("Detect Moves Within File"), "-M"), - ChoiceItem(tr("Detect Moves Between Files"), "-M -C"), - ChoiceItem(tr("Detect Moves and Copies Between Files"), "-M -C -C") + ChoiceItem(Tr::tr("No Move Detection"), ""), + ChoiceItem(Tr::tr("Detect Moves Within File"), "-M"), + ChoiceItem(Tr::tr("Detect Moves Between Files"), "-M -C"), + ChoiceItem(Tr::tr("Detect Moves and Copies Between Files"), "-M -C -C") }; - mapSetting(addChoices(tr("Move detection"), {}, logChoices), + mapSetting(addChoices(Tr::tr("Move detection"), {}, logChoices), &settings.blameMoveDetection); addReloadButton(); @@ -610,15 +610,15 @@ public: BaseGitDiffArgumentsWidget(settings, editor->toolBar()) { QToolBar *toolBar = editor->toolBar(); - QAction *diffButton = addToggleButton(patchOption, tr("Diff"), - tr("Show difference.")); + QAction *diffButton = addToggleButton(patchOption, Tr::tr("Diff"), + Tr::tr("Show difference.")); mapSetting(diffButton, &settings.logDiff); connect(diffButton, &QAction::toggled, m_patienceButton, &QAction::setVisible); connect(diffButton, &QAction::toggled, m_ignoreWSButton, &QAction::setVisible); m_patienceButton->setVisible(diffButton->isChecked()); m_ignoreWSButton->setVisible(diffButton->isChecked()); - auto filterAction = new QAction(tr("Filter"), toolBar); - filterAction->setToolTip(tr("Filter commits by message or content.")); + auto filterAction = new QAction(Tr::tr("Filter"), toolBar); + filterAction->setToolTip(Tr::tr("Filter commits by message or content.")); filterAction->setCheckable(true); connect(filterAction, &QAction::toggled, editor, &GitEditorWidget::toggleFilters); toolBar->addAction(filterAction); @@ -652,21 +652,21 @@ public: { QAction *firstParentButton = addToggleButton({"-m", "--first-parent"}, - tr("First Parent"), - tr("Follow only the first parent on merge commits.")); + Tr::tr("First Parent"), + Tr::tr("Follow only the first parent on merge commits.")); mapSetting(firstParentButton, &settings.firstParent); - QAction *graphButton = addToggleButton(graphArguments(), tr("Graph"), - tr("Show textual graph log.")); + QAction *graphButton = addToggleButton(graphArguments(), Tr::tr("Graph"), + Tr::tr("Show textual graph log.")); mapSetting(graphButton, &settings.graphLog); QAction *colorButton = addToggleButton(QStringList{colorOption}, - tr("Color"), tr("Use colors in log.")); + Tr::tr("Color"), Tr::tr("Use colors in log.")); mapSetting(colorButton, &settings.colorLog); if (fileRelated) { QAction *followButton = addToggleButton( - "--follow", tr("Follow"), - tr("Show log also for previous names of the file.")); + "--follow", Tr::tr("Follow"), + Tr::tr("Show log also for previous names of the file.")); mapSetting(followButton, &settings.followRenames); } @@ -711,8 +711,8 @@ public: { QAction *showDateButton = addToggleButton("--date=iso", - tr("Show Date"), - tr("Show date instead of sequence.")); + Tr::tr("Show Date"), + Tr::tr("Show date instead of sequence.")); mapSetting(showDateButton, &settings.refLogShowDate); addReloadButton(); @@ -815,17 +815,17 @@ private: static inline QString msgRepositoryNotFound(const FilePath &dir) { - return GitClient::tr("Cannot determine the repository for \"%1\".").arg(dir.toUserOutput()); + return Tr::tr("Cannot determine the repository for \"%1\".").arg(dir.toUserOutput()); } static inline QString msgParseFilesFailed() { - return GitClient::tr("Cannot parse the file output."); + return Tr::tr("Cannot parse the file output."); } static QString msgCannotLaunch(const FilePath &binary) { - return GitClient::tr("Cannot launch \"%1\".").arg(binary.toUserOutput()); + return Tr::tr("Cannot launch \"%1\".").arg(binary.toUserOutput()); } static inline void msgCannotRun(const QString &message, QString *errorMessage) @@ -839,7 +839,7 @@ static inline void msgCannotRun(const QString &message, QString *errorMessage) static inline void msgCannotRun(const QStringList &args, const FilePath &workingDirectory, const QString &error, QString *errorMessage) { - const QString message = GitClient::tr("Cannot run \"%1\" in \"%2\": %3") + const QString message = Tr::tr("Cannot run \"%1\" in \"%2\": %3") .arg("git " + args.join(' '), workingDirectory.toUserOutput(), error); @@ -963,25 +963,25 @@ void GitClient::chunkActionsRequested(DiffEditor::DiffEditorController *controll }; menu->addSeparator(); - QAction *stageChunkAction = menu->addAction(tr("Stage Chunk")); + QAction *stageChunkAction = menu->addAction(Tr::tr("Stage Chunk")); connect(stageChunkAction, &QAction::triggered, this, [stageChunk, diffController, fileIndex, chunkIndex] { stageChunk(diffController, fileIndex, chunkIndex, DiffEditorController::NoOption, DiffEditor::ChunkSelection()); }); - QAction *stageLinesAction = menu->addAction(tr("Stage Selection (%n Lines)", "", selection.selectedRowsCount())); + QAction *stageLinesAction = menu->addAction(Tr::tr("Stage Selection (%n Lines)", "", selection.selectedRowsCount())); connect(stageLinesAction, &QAction::triggered, this, [stageChunk, diffController, fileIndex, chunkIndex, selection] { stageChunk(diffController, fileIndex, chunkIndex, DiffEditorController::NoOption, selection); }); - QAction *unstageChunkAction = menu->addAction(tr("Unstage Chunk")); + QAction *unstageChunkAction = menu->addAction(Tr::tr("Unstage Chunk")); connect(unstageChunkAction, &QAction::triggered, this, [stageChunk, diffController, fileIndex, chunkIndex] { stageChunk(diffController, fileIndex, chunkIndex, DiffEditorController::Revert, DiffEditor::ChunkSelection()); }); - QAction *unstageLinesAction = menu->addAction(tr("Unstage Selection (%n Lines)", "", selection.selectedRowsCount())); + QAction *unstageLinesAction = menu->addAction(Tr::tr("Unstage Selection (%n Lines)", "", selection.selectedRowsCount())); connect(unstageLinesAction, &QAction::triggered, this, [stageChunk, diffController, fileIndex, chunkIndex, selection] { stageChunk(diffController, fileIndex, chunkIndex, @@ -1022,9 +1022,9 @@ void GitClient::stage(DiffEditor::DiffEditorController *diffController, &errorMessage, args)) { if (errorMessage.isEmpty()) { if (revert) - VcsOutputWindow::appendSilently(tr("Chunk successfully unstaged")); + VcsOutputWindow::appendSilently(Tr::tr("Chunk successfully unstaged")); else - VcsOutputWindow::appendSilently(tr("Chunk successfully staged")); + VcsOutputWindow::appendSilently(Tr::tr("Chunk successfully staged")); } else { VcsOutputWindow::appendError(errorMessage); } @@ -1069,7 +1069,7 @@ void GitClient::diffFiles(const FilePath &workingDirectory, const QString documentId = QLatin1String(Constants::GIT_PLUGIN) + QLatin1String(".DiffFiles.") + workingDirectory.toString(); requestReload(documentId, - workingDirectory.toString(), tr("Git Diff Files"), workingDirectory, + workingDirectory.toString(), Tr::tr("Git Diff Files"), workingDirectory, [stagedFileNames, unstagedFileNames](IDocument *doc) { return new FileListDiffController(doc, stagedFileNames, unstagedFileNames); }); @@ -1080,7 +1080,7 @@ void GitClient::diffProject(const FilePath &workingDirectory, const QString &pro const QString documentId = QLatin1String(Constants::GIT_PLUGIN) + QLatin1String(".DiffProject.") + workingDirectory.toString(); requestReload(documentId, - workingDirectory.toString(), tr("Git Diff Project"), workingDirectory, + workingDirectory.toString(), Tr::tr("Git Diff Project"), workingDirectory, [projectDirectory](IDocument *doc){ return new GitDiffEditorController(doc, {}, {}, {"--", projectDirectory}); }); @@ -1092,7 +1092,7 @@ void GitClient::diffRepository(const FilePath &workingDirectory, { const QString documentId = QLatin1String(Constants::GIT_PLUGIN) + QLatin1String(".DiffRepository.") + workingDirectory.toString(); - requestReload(documentId, workingDirectory.toString(), tr("Git Diff Repository"), workingDirectory, + requestReload(documentId, workingDirectory.toString(), Tr::tr("Git Diff Repository"), workingDirectory, [&leftCommit, &rightCommit](IDocument *doc) { return new GitDiffEditorController(doc, leftCommit, rightCommit, {}); }); @@ -1100,7 +1100,7 @@ void GitClient::diffRepository(const FilePath &workingDirectory, void GitClient::diffFile(const FilePath &workingDirectory, const QString &fileName) const { - const QString title = tr("Git Diff \"%1\"").arg(fileName); + const QString title = Tr::tr("Git Diff \"%1\"").arg(fileName); const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName); const QString documentId = QLatin1String(Constants::GIT_PLUGIN) + QLatin1String(".DifFile.") + sourceFile; @@ -1112,7 +1112,7 @@ void GitClient::diffFile(const FilePath &workingDirectory, const QString &fileNa void GitClient::diffBranch(const FilePath &workingDirectory, const QString &branchName) const { - const QString title = tr("Git Diff Branch \"%1\"").arg(branchName); + const QString title = Tr::tr("Git Diff Branch \"%1\"").arg(branchName); const QString documentId = QLatin1String(Constants::GIT_PLUGIN) + QLatin1String(".DiffBranch.") + branchName; requestReload(documentId, workingDirectory.toString(), title, workingDirectory, @@ -1169,7 +1169,7 @@ void GitClient::log(const FilePath &workingDirectory, const QString &fileName, msgArg = workingDirectory.toString(); // Creating document might change the referenced workingDirectory. Store a copy and use it. const FilePath workingDir = workingDirectory; - const QString title = tr("Git Log \"%1\"").arg(msgArg); + const QString title = Tr::tr("Git Log \"%1\"").arg(msgArg); const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID; const QString sourceFile = VcsBaseEditor::getSource(workingDir, fileName); GitEditorWidget *editor = static_cast<GitEditorWidget *>( @@ -1224,7 +1224,7 @@ void GitClient::log(const FilePath &workingDirectory, const QString &fileName, void GitClient::reflog(const FilePath &workingDirectory, const QString &ref) { - const QString title = tr("Git Reflog \"%1\"").arg(workingDirectory.toUserOutput()); + const QString title = Tr::tr("Git Reflog \"%1\"").arg(workingDirectory.toUserOutput()); const Id editorId = Git::Constants::GIT_REFLOG_EDITOR_ID; // Creating document might change the referenced workingDirectory. Store a copy and use it. const FilePath workingDir = workingDirectory; @@ -1259,7 +1259,7 @@ static inline bool canShow(const QString &sha) static inline QString msgCannotShow(const QString &sha) { - return GitClient::tr("Cannot describe \"%1\".").arg(sha); + return Tr::tr("Cannot describe \"%1\".").arg(sha); } void GitClient::show(const QString &source, const QString &id, const QString &name) @@ -1269,7 +1269,7 @@ void GitClient::show(const QString &source, const QString &id, const QString &na return; } - const QString title = tr("Git Show \"%1\"").arg(name.isEmpty() ? id : name); + const QString title = Tr::tr("Git Show \"%1\"").arg(name.isEmpty() ? id : name); const QFileInfo sourceFi(source); FilePath workingDirectory = FilePath::fromString( sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath()); @@ -1309,7 +1309,7 @@ void GitClient::archive(const FilePath &workingDirectory, QString commit) FilePath archiveName = FileUtils::getSaveFilePath( nullptr, - tr("Generate %1 archive").arg(repoName), + Tr::tr("Generate %1 archive").arg(repoName), repoDirectory.pathAppended(QString("../%1-%2").arg(repoName).arg(commit.left(8))), filters.keys().join(";;"), &selectedFilter); @@ -1322,8 +1322,8 @@ void GitClient::archive(const FilePath &workingDirectory, QString commit) } if (archive.exists()) { - if (QMessageBox::warning(ICore::dialogParent(), tr("Overwrite?"), - tr("An item named \"%1\" already exists at this location. " + if (QMessageBox::warning(ICore::dialogParent(), Tr::tr("Overwrite?"), + Tr::tr("An item named \"%1\" already exists at this location. " "Do you want to overwrite it?").arg(QDir::toNativeSeparators(archive.absoluteFilePath())), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { return; @@ -1339,7 +1339,7 @@ VcsBaseEditorWidget *GitClient::annotate( { const Id editorId = Git::Constants::GIT_BLAME_EDITOR_ID; const QString id = VcsBaseEditor::getTitleId(workingDir, {file}, revision); - const QString title = tr("Git Blame \"%1\"").arg(id); + const QString title = Tr::tr("Git Blame \"%1\"").arg(id); const QString sourceFile = VcsBaseEditor::getSource(workingDir, file); VcsBaseEditorWidget *editor @@ -1397,8 +1397,8 @@ QStringList GitClient::setupCheckoutArguments(const FilePath &workingDirectory, if (Utils::CheckableMessageBox::doNotAskAgainQuestion( ICore::dialogParent() /*parent*/, - tr("Create Local Branch") /*title*/, - tr("Would you like to create a local branch?") /*message*/, + Tr::tr("Create Local Branch") /*title*/, + Tr::tr("Would you like to create a local branch?") /*message*/, ICore::settings(), "Git.CreateLocalBranchOnCheckout" /*setting*/, QDialogButtonBox::Yes | QDialogButtonBox::No /*buttons*/, QDialogButtonBox::No /*default button*/, @@ -1468,8 +1468,8 @@ void GitClient::reset(const FilePath &workingDirectory, const QString &argument, if (argument == "--hard") { if (gitStatus(workingDirectory, StatusMode(NoUntracked | NoSubmodules)) != StatusUnchanged) { if (QMessageBox::question( - Core::ICore::dialogParent(), tr("Reset"), - tr("All changes in working directory will be discarded. Are you sure?"), + Core::ICore::dialogParent(), Tr::tr("Reset"), + Tr::tr("All changes in working directory will be discarded. Are you sure?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) { return; @@ -1500,12 +1500,12 @@ void GitClient::recoverDeletedFiles(const FilePath &workingDirectory) if (result.result() == ProcessResult::FinishedWithSuccess) { const QString stdOut = result.cleanedStdOut().trimmed(); if (stdOut.isEmpty()) { - VcsOutputWindow::appendError(tr("Nothing to recover")); + VcsOutputWindow::appendError(Tr::tr("Nothing to recover")); return; } const QStringList files = stdOut.split('\n'); synchronousCheckoutFiles(workingDirectory, files, QString(), nullptr, false); - VcsOutputWindow::append(tr("Files recovered"), VcsOutputWindow::Message); + VcsOutputWindow::append(Tr::tr("Files recovered"), VcsOutputWindow::Message); } } @@ -1527,7 +1527,7 @@ bool GitClient::synchronousLog(const FilePath &workingDirectory, const QStringLi *output = result.cleanedStdOut(); return true; } - msgCannotRun(tr("Cannot obtain log of \"%1\": %2") + msgCannotRun(Tr::tr("Cannot obtain log of \"%1\": %2") .arg(workingDirectory.toUserOutput(), result.cleanedStdErr()), errorMessageIn); return false; } @@ -1583,7 +1583,7 @@ bool GitClient::synchronousReset(const FilePath &workingDirectory, if (files.isEmpty()) { msgCannotRun(arguments, workingDirectory, result.cleanedStdErr(), errorMessage); } else { - msgCannotRun(tr("Cannot reset %n files in \"%1\": %2", nullptr, files.size()) + msgCannotRun(Tr::tr("Cannot reset %n files in \"%1\": %2", nullptr, files.size()) .arg(workingDirectory.toUserOutput(), result.cleanedStdErr()), errorMessage); } @@ -1629,24 +1629,24 @@ bool GitClient::synchronousCheckoutFiles(const FilePath &workingDirectory, QStri const QString fileArg = files.join(", "); //: Meaning of the arguments: %1: revision, %2: files, %3: repository, //: %4: Error message - msgCannotRun(tr("Cannot checkout \"%1\" of %2 in \"%3\": %4") + msgCannotRun(Tr::tr("Cannot checkout \"%1\" of %2 in \"%3\": %4") .arg(revision, fileArg, workingDirectory.toUserOutput(), result.cleanedStdErr()), errorMessage); return false; } -static inline QString msgParentRevisionFailed(const FilePath &workingDirectory, +static QString msgParentRevisionFailed(const FilePath &workingDirectory, const QString &revision, const QString &why) { //: Failed to find parent revisions of a SHA1 for "annotate previous" - return GitClient::tr("Cannot find parent revisions of \"%1\" in \"%2\": %3") + return Tr::tr("Cannot find parent revisions of \"%1\" in \"%2\": %3") .arg(revision, workingDirectory.toUserOutput(), why); } -static inline QString msgInvalidRevision() +static QString msgInvalidRevision() { - return GitClient::tr("Invalid revision"); + return Tr::tr("Invalid revision"); } // Split a line of "<commit> <parent1> ..." to obtain parents from "rev-list" or "log". @@ -1816,7 +1816,7 @@ QString GitClient::synchronousTopic(const FilePath &workingDirectory) const if (!stdOut.isEmpty()) return stdOut; } - return tr("Detached HEAD"); + return Tr::tr("Detached HEAD"); } bool GitClient::synchronousRevParseCmd(const FilePath &workingDirectory, const QString &ref, @@ -1869,7 +1869,7 @@ QString GitClient::synchronousShortDescription(const FilePath &workingDirectory, "--max-count=1", revision}; const CommandResult result = vcsSynchronousExec(workingDirectory, arguments, RunFlags::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess) { - VcsOutputWindow::appendSilently(tr("Cannot describe revision \"%1\" in \"%2\": %3") + VcsOutputWindow::appendSilently(Tr::tr("Cannot describe revision \"%1\" in \"%2\": %3") .arg(revision, workingDirectory.toUserOutput(), result.cleanedStdErr())); return revision; } @@ -1907,7 +1907,7 @@ QString GitClient::synchronousStash(const FilePath &workingDirectory, const QStr do { if ((flags & StashPromptDescription)) { if (!inputText(ICore::dialogParent(), - tr("Stash Description"), tr("Description:"), &message)) + Tr::tr("Stash Description"), Tr::tr("Description:"), &message)) break; } if (!executeSynchronousStash(workingDirectory, message)) @@ -1975,7 +1975,7 @@ bool GitClient::stashNameFromMessage(const FilePath &workingDirectory, } } //: Look-up of a stash via its descriptive message failed. - msgCannotRun(tr("Cannot resolve stash message \"%1\" in \"%2\".") + msgCannotRun(Tr::tr("Cannot resolve stash message \"%1\" in \"%2\".") .arg(message, workingDirectory.toUserOutput()), errorMessage); return false; } @@ -2066,7 +2066,7 @@ QStringList GitClient::synchronousSubmoduleStatus(const FilePath &workingDirecto RunFlags::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess) { - msgCannotRun(tr("Cannot retrieve submodule status of \"%1\": %2") + msgCannotRun(Tr::tr("Cannot retrieve submodule status of \"%1\": %2") .arg(workingDirectory.toUserOutput(), result.cleanedStdErr()), errorMessage); return {}; } @@ -2208,12 +2208,12 @@ bool GitClient::synchronousApplyPatch(const FilePath &workingDirectory, const QString stdErr = result.cleanedStdErr(); if (result.result() == ProcessResult::FinishedWithSuccess) { if (!stdErr.isEmpty()) - *errorMessage = tr("There were warnings while applying \"%1\" to \"%2\":\n%3") + *errorMessage = Tr::tr("There were warnings while applying \"%1\" to \"%2\":\n%3") .arg(file, workingDirectory.toUserOutput(), stdErr); return true; } - *errorMessage = tr("Cannot apply patch \"%1\" to \"%2\": %3") + *errorMessage = Tr::tr("Cannot apply patch \"%1\" to \"%2\": %3") .arg(QDir::toNativeSeparators(file), workingDirectory.toUserOutput(), stdErr); return false; } @@ -2289,8 +2289,8 @@ void GitClient::updateSubmodulesIfNeeded(const FilePath &workingDirectory, bool if (!updateNeeded) return; - if (prompt && QMessageBox::question(ICore::dialogParent(), tr("Submodules Found"), - tr("Would you like to update submodules?"), + if (prompt && QMessageBox::question(ICore::dialogParent(), Tr::tr("Submodules Found"), + Tr::tr("Would you like to update submodules?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { return; } @@ -2350,7 +2350,7 @@ GitClient::StatusResult GitClient::gitStatus(const FilePath &workingDirectory, S // Is it something really fatal? if (!statusRc && !branchKnown) { if (errorMessage) { - *errorMessage = tr("Cannot obtain status: %1").arg(result.cleanedStdErr()); + *errorMessage = Tr::tr("Cannot obtain status: %1").arg(result.cleanedStdErr()); } return StatusFailed; } @@ -2368,13 +2368,13 @@ QString GitClient::commandInProgressDescription(const FilePath &workingDirectory break; case Rebase: case RebaseMerge: - return tr("REBASING"); + return Tr::tr("REBASING"); case Revert: - return tr("REVERTING"); + return Tr::tr("REVERTING"); case CherryPick: - return tr("CHERRY-PICKING"); + return Tr::tr("CHERRY-PICKING"); case Merge: - return tr("MERGING"); + return Tr::tr("MERGING"); } return QString(); } @@ -2409,24 +2409,24 @@ void GitClient::continueCommandIfNeeded(const FilePath &workingDirectory, bool a switch (command) { case Rebase: case RebaseMerge: - continuePreviousGitCommand(workingDirectory, tr("Continue Rebase"), - tr("Rebase is in progress. What do you want to do?"), - tr("Continue"), "rebase", continueMode); + continuePreviousGitCommand(workingDirectory, Tr::tr("Continue Rebase"), + Tr::tr("Rebase is in progress. What do you want to do?"), + Tr::tr("Continue"), "rebase", continueMode); break; case Merge: - continuePreviousGitCommand(workingDirectory, tr("Continue Merge"), - tr("You need to commit changes to finish merge.\nCommit now?"), - tr("Commit"), "merge", continueMode); + continuePreviousGitCommand(workingDirectory, Tr::tr("Continue Merge"), + Tr::tr("You need to commit changes to finish merge.\nCommit now?"), + Tr::tr("Commit"), "merge", continueMode); break; case Revert: - continuePreviousGitCommand(workingDirectory, tr("Continue Revert"), - tr("You need to commit changes to finish revert.\nCommit now?"), - tr("Commit"), "revert", continueMode); + continuePreviousGitCommand(workingDirectory, Tr::tr("Continue Revert"), + Tr::tr("You need to commit changes to finish revert.\nCommit now?"), + Tr::tr("Commit"), "revert", continueMode); break; case CherryPick: - continuePreviousGitCommand(workingDirectory, tr("Continue Cherry-Picking"), - tr("You need to commit changes to finish cherry-picking.\nCommit now?"), - tr("Commit"), "cherry-pick", continueMode); + continuePreviousGitCommand(workingDirectory, Tr::tr("Continue Cherry-Picking"), + Tr::tr("You need to commit changes to finish cherry-picking.\nCommit now?"), + Tr::tr("Commit"), "cherry-pick", continueMode); break; default: break; @@ -2448,7 +2448,7 @@ void GitClient::continuePreviousGitCommand(const FilePath &workingDirectory, hasChanges = gitStatus(workingDirectory, StatusMode(NoUntracked | NoSubmodules)) == GitClient::StatusChanged; if (!hasChanges) - msgBoxText.prepend(tr("No changes found.") + ' '); + msgBoxText.prepend(Tr::tr("No changes found.") + ' '); break; case SkipOnly: hasChanges = false; @@ -2458,7 +2458,7 @@ void GitClient::continuePreviousGitCommand(const FilePath &workingDirectory, QMessageBox msgBox(QMessageBox::Question, msgBoxTitle, msgBoxText, QMessageBox::NoButton, ICore::dialogParent()); if (hasChanges || isRebase) - msgBox.addButton(hasChanges ? buttonName : tr("Skip"), QMessageBox::AcceptRole); + msgBox.addButton(hasChanges ? buttonName : Tr::tr("Skip"), QMessageBox::AcceptRole); msgBox.addButton(QMessageBox::Abort); msgBox.addButton(QMessageBox::Ignore); switch (msgBox.exec()) { @@ -2485,7 +2485,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR {"ls-remote", repositoryURL, HEAD, "refs/heads/*"}, RunFlags::SuppressStdErr | RunFlags::SuppressFailMessage); QStringList branches; - branches << tr("<Detached HEAD>"); + branches << Tr::tr("<Detached HEAD>"); QString headSha; // split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master" bool headFound = false; @@ -2712,7 +2712,7 @@ bool GitClient::readDataFromCommit(const FilePath &repoDirectory, const QString if (result.result() != ProcessResult::FinishedWithSuccess) { if (errorMessage) { - *errorMessage = tr("Cannot retrieve last commit data of repository \"%1\".") + *errorMessage = Tr::tr("Cannot retrieve last commit data of repository \"%1\".") .arg(repoDirectory.toUserOutput()); } return false; @@ -2748,7 +2748,7 @@ bool GitClient::getCommitData(const FilePath &workingDirectory, QString gitDir = findGitDirForRepository(repoDirectory); if (gitDir.isEmpty()) { - *errorMessage = tr("The repository \"%1\" is not initialized.").arg(repoDirectory.toString()); + *errorMessage = Tr::tr("The repository \"%1\" is not initialized.").arg(repoDirectory.toString()); return false; } @@ -2880,10 +2880,10 @@ bool GitClient::getCommitData(const FilePath &workingDirectory, static inline QString msgCommitted(const QString &amendSHA1, int fileCount) { if (amendSHA1.isEmpty()) - return GitClient::tr("Committed %n files.", nullptr, fileCount); + return Tr::tr("Committed %n files.", nullptr, fileCount); if (fileCount) - return GitClient::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendSHA1); - return GitClient::tr("Amended \"%1\".").arg(amendSHA1); + return Tr::tr("Amended \"%1\" (%n files).", nullptr, fileCount).arg(amendSHA1); + return Tr::tr("Amended \"%1\".").arg(amendSHA1); } bool GitClient::addAndCommit(const FilePath &repositoryDirectory, @@ -2973,7 +2973,7 @@ bool GitClient::addAndCommit(const FilePath &repositoryDirectory, GitPlugin::updateCurrentBranch(); return true; } - VcsOutputWindow::appendError(tr("Cannot commit %n files\n", nullptr, commitCount)); + VcsOutputWindow::appendError(Tr::tr("Cannot commit %n files\n", nullptr, commitCount)); return false; } @@ -3047,8 +3047,8 @@ GitClient::RevertResult GitClient::revertI(QStringList files, // Ask to revert (to do: Handle lists with a selection dialog) const QMessageBox::StandardButton answer = QMessageBox::question(ICore::dialogParent(), - tr("Revert"), - tr("The file has been changed. Do you want to revert it?"), + Tr::tr("Revert"), + Tr::tr("The file has been changed. Do you want to revert it?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (answer == QMessageBox::No) @@ -3077,7 +3077,7 @@ void GitClient::revertFiles(const QStringList &files, bool revertStaging) case RevertCanceled: break; case RevertUnchanged: { - const QString msg = (isDirectory || files.size() > 1) ? msgNoChangedFiles() : tr("The file is not modified."); + const QString msg = (isDirectory || files.size() > 1) ? msgNoChangedFiles() : Tr::tr("The file is not modified."); VcsOutputWindow::appendWarning(msg); } break; @@ -3174,7 +3174,7 @@ void GitClient::handleMergeConflicts(const FilePath &workingDir, const QString & { QString message; if (!commit.isEmpty()) { - message = tr("Conflicts detected with commit %1.").arg(commit); + message = Tr::tr("Conflicts detected with commit %1.").arg(commit); } else if (!files.isEmpty()) { QString fileList; QStringList partialFiles = files; @@ -3183,23 +3183,23 @@ void GitClient::handleMergeConflicts(const FilePath &workingDir, const QString & fileList = partialFiles.join('\n'); if (partialFiles.count() != files.count()) fileList += "\n..."; - message = tr("Conflicts detected with files:\n%1").arg(fileList); + message = Tr::tr("Conflicts detected with files:\n%1").arg(fileList); } else { - message = tr("Conflicts detected."); + message = Tr::tr("Conflicts detected."); } - QMessageBox mergeOrAbort(QMessageBox::Question, tr("Conflicts Detected"), message, + QMessageBox mergeOrAbort(QMessageBox::Question, Tr::tr("Conflicts Detected"), message, QMessageBox::NoButton, ICore::dialogParent()); - QPushButton *mergeToolButton = mergeOrAbort.addButton(tr("Run &Merge Tool"), + QPushButton *mergeToolButton = mergeOrAbort.addButton(Tr::tr("Run &Merge Tool"), QMessageBox::AcceptRole); const QString mergeTool = readConfigValue(workingDir, "merge.tool"); if (mergeTool.isEmpty() || mergeTool.startsWith("vimdiff")) { mergeToolButton->setEnabled(false); - mergeToolButton->setToolTip(tr("Only graphical merge tools are supported. " + mergeToolButton->setToolTip(Tr::tr("Only graphical merge tools are supported. " "Please configure merge.tool.")); } mergeOrAbort.addButton(QMessageBox::Ignore); if (abortCommand == "rebase") - mergeOrAbort.addButton(tr("&Skip"), QMessageBox::RejectRole); + mergeOrAbort.addButton(Tr::tr("&Skip"), QMessageBox::RejectRole); if (!abortCommand.isEmpty()) mergeOrAbort.addButton(QMessageBox::Abort); switch (mergeOrAbort.exec()) { @@ -3236,7 +3236,7 @@ void GitClient::subversionLog(const FilePath &workingDirectory) const arguments << ("--limit=" + QString::number(logCount)); // Create a command editor, no highlighting or interaction. - const QString title = tr("Git SVN Log"); + const QString title = Tr::tr("Git SVN Log"); const Id editorId = Git::Constants::GIT_SVN_LOG_EDITOR_ID; const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, QStringList()); VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, sourceFile, codecFor(CodecNone), @@ -3274,8 +3274,8 @@ public: if (pushFailure == NonFastForward) { const QColor warnColor = Utils::creatorTheme()->color(Theme::TextColorError); if (QMessageBox::question( - Core::ICore::dialogParent(), tr("Force Push"), - tr("Push failed. Would you like to force-push <span style=\"color:#%1\">" + Core::ICore::dialogParent(), Tr::tr("Force Push"), + Tr::tr("Push failed. Would you like to force-push <span style=\"color:#%1\">" "(rewrites remote history)</span>?") .arg(QString::number(warnColor.rgba(), 16)), QMessageBox::Yes | QMessageBox::No, @@ -3293,8 +3293,8 @@ public: } // NoRemoteBranch case if (QMessageBox::question( - Core::ICore::dialogParent(), tr("No Upstream Branch"), - tr("Push failed because the local branch \"%1\" " + Core::ICore::dialogParent(), Tr::tr("No Upstream Branch"), + Tr::tr("Push failed because the local branch \"%1\" " "does not have an upstream branch on the remote.\n\n" "Would you like to create the branch \"%1\" on the " "remote and set it as upstream?") @@ -3364,7 +3364,7 @@ bool GitClient::canRebase(const FilePath &workingDirectory) const if (QFileInfo::exists(gitDir + "/rebase-apply") || QFileInfo::exists(gitDir + "/rebase-merge")) { VcsOutputWindow::appendError( - tr("Rebase, merge or am is in progress. Finish " + Tr::tr("Rebase, merge or am is in progress. Finish " "or abort it and then try again.")); return false; } @@ -3450,12 +3450,12 @@ void GitClient::interactiveRebase(const FilePath &workingDirectory, const QStrin QString GitClient::msgNoChangedFiles() { - return tr("There are no modified files."); + return Tr::tr("There are no modified files."); } QString GitClient::msgNoCommits(bool includeRemote) { - return includeRemote ? tr("No commits were found") : tr("No local commits were found"); + return includeRemote ? Tr::tr("No commits were found") : Tr::tr("No local commits were found"); } void GitClient::stashPop(const FilePath &workingDirectory, const QString &stash) @@ -3641,31 +3641,31 @@ bool GitClient::StashInfo::init(const FilePath &workingDirectory, const QString void GitClient::StashInfo::stashPrompt(const QString &command, const QString &statusOutput, QString *errorMessage) { - QMessageBox msgBox(QMessageBox::Question, tr("Uncommitted Changes Found"), - tr("What would you like to do with local changes in:") + "\n\n\"" + QMessageBox msgBox(QMessageBox::Question, Tr::tr("Uncommitted Changes Found"), + Tr::tr("What would you like to do with local changes in:") + "\n\n\"" + m_workingDir.toUserOutput() + '\"', QMessageBox::NoButton, ICore::dialogParent()); msgBox.setDetailedText(statusOutput); - QPushButton *stashAndPopButton = msgBox.addButton(tr("Stash && &Pop"), QMessageBox::AcceptRole); - stashAndPopButton->setToolTip(tr("Stash local changes and pop when %1 finishes.").arg(command)); + QPushButton *stashAndPopButton = msgBox.addButton(Tr::tr("Stash && &Pop"), QMessageBox::AcceptRole); + stashAndPopButton->setToolTip(Tr::tr("Stash local changes and pop when %1 finishes.").arg(command)); - QPushButton *stashButton = msgBox.addButton(tr("&Stash"), QMessageBox::AcceptRole); - stashButton->setToolTip(tr("Stash local changes and execute %1.").arg(command)); + QPushButton *stashButton = msgBox.addButton(Tr::tr("&Stash"), QMessageBox::AcceptRole); + stashButton->setToolTip(Tr::tr("Stash local changes and execute %1.").arg(command)); - QPushButton *discardButton = msgBox.addButton(tr("&Discard"), QMessageBox::AcceptRole); - discardButton->setToolTip(tr("Discard (reset) local changes and execute %1.").arg(command)); + QPushButton *discardButton = msgBox.addButton(Tr::tr("&Discard"), QMessageBox::AcceptRole); + discardButton->setToolTip(Tr::tr("Discard (reset) local changes and execute %1.").arg(command)); QPushButton *ignoreButton = nullptr; if (m_flags & AllowUnstashed) { ignoreButton = msgBox.addButton(QMessageBox::Ignore); - ignoreButton->setToolTip(tr("Execute %1 with local changes in working directory.") + ignoreButton->setToolTip(Tr::tr("Execute %1 with local changes in working directory.") .arg(command)); } QPushButton *cancelButton = msgBox.addButton(QMessageBox::Cancel); - cancelButton->setToolTip(tr("Cancel %1.").arg(command)); + cancelButton->setToolTip(Tr::tr("Cancel %1.").arg(command)); msgBox.exec(); @@ -3760,22 +3760,22 @@ void GitClient::addChangeActions(QMenu *menu, const QString &source, const QStri QTC_ASSERT(!change.isEmpty(), return); const FilePath &workingDir = fileWorkingDirectory(source); const bool isRange = change.contains(".."); - menu->addAction(tr("Cherr&y-Pick %1").arg(change), [workingDir, change] { + menu->addAction(Tr::tr("Cherr&y-Pick %1").arg(change), [workingDir, change] { m_instance->synchronousCherryPick(workingDir, change); }); - menu->addAction(tr("Re&vert %1").arg(change), [workingDir, change] { + menu->addAction(Tr::tr("Re&vert %1").arg(change), [workingDir, change] { m_instance->synchronousRevert(workingDir, change); }); if (!isRange) { - menu->addAction(tr("C&heckout %1").arg(change), [workingDir, change] { + menu->addAction(Tr::tr("C&heckout %1").arg(change), [workingDir, change] { m_instance->checkout(workingDir, change); }); - connect(menu->addAction(tr("&Interactive Rebase from %1...").arg(change)), + connect(menu->addAction(Tr::tr("&Interactive Rebase from %1...").arg(change)), &QAction::triggered, [workingDir, change] { GitPlugin::startRebaseFromCommit(workingDir, change); }); } - QAction *logAction = menu->addAction(tr("&Log for %1").arg(change), [workingDir, change] { + QAction *logAction = menu->addAction(Tr::tr("&Log for %1").arg(change), [workingDir, change] { m_instance->log(workingDir, QString(), false, {change}); }); if (isRange) { @@ -3783,12 +3783,12 @@ void GitClient::addChangeActions(QMenu *menu, const QString &source, const QStri } else { const FilePath filePath = FilePath::fromString(source); if (!filePath.isDir()) { - menu->addAction(tr("Sh&ow file \"%1\" on revision %2").arg(filePath.fileName()).arg(change), + menu->addAction(Tr::tr("Sh&ow file \"%1\" on revision %2").arg(filePath.fileName()).arg(change), [workingDir, change, source] { m_instance->openShowEditor(workingDir, change, source); }); } - menu->addAction(tr("Add &Tag for %1...").arg(change), [workingDir, change] { + menu->addAction(Tr::tr("Add &Tag for %1...").arg(change), [workingDir, change] { QString output; QString errorMessage; m_instance->synchronousTagCmd(workingDir, QStringList(), &output, &errorMessage); @@ -3809,26 +3809,26 @@ void GitClient::addChangeActions(QMenu *menu, const QString &source, const QStri auto resetChange = [workingDir, change](const QByteArray &resetType) { m_instance->reset(workingDir, QLatin1String("--" + resetType), change); }; - auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu); - resetMenu->addAction(tr("&Hard"), std::bind(resetChange, "hard")); - resetMenu->addAction(tr("&Mixed"), std::bind(resetChange, "mixed")); - resetMenu->addAction(tr("&Soft"), std::bind(resetChange, "soft")); + auto resetMenu = new QMenu(Tr::tr("&Reset to Change %1").arg(change), menu); + resetMenu->addAction(Tr::tr("&Hard"), std::bind(resetChange, "hard")); + resetMenu->addAction(Tr::tr("&Mixed"), std::bind(resetChange, "mixed")); + resetMenu->addAction(Tr::tr("&Soft"), std::bind(resetChange, "soft")); menu->addMenu(resetMenu); } - menu->addAction((isRange ? tr("Di&ff %1") : tr("Di&ff Against %1")).arg(change), + menu->addAction((isRange ? Tr::tr("Di&ff %1") : Tr::tr("Di&ff Against %1")).arg(change), [workingDir, change] { m_instance->diffRepository(workingDir, change, {}); }); if (!isRange) { if (!m_instance->m_diffCommit.isEmpty()) { - menu->addAction(tr("Diff &Against Saved %1").arg(m_instance->m_diffCommit), + menu->addAction(Tr::tr("Diff &Against Saved %1").arg(m_instance->m_diffCommit), [workingDir, change] { m_instance->diffRepository(workingDir, m_instance->m_diffCommit, change); m_instance->m_diffCommit.clear(); }); } - menu->addAction(tr("&Save for Diff"), [change] { + menu->addAction(Tr::tr("&Save for Diff"), [change] { m_instance->m_diffCommit = change; }); } @@ -3868,7 +3868,7 @@ IEditor *GitClient::openShowEditor(const FilePath &workingDirectory, const QStri const QString documentId = QLatin1String(Git::Constants::GIT_PLUGIN) + QLatin1String(".GitShow.") + topLevelString + QLatin1String(".") + relativePath; - QString title = tr("Git Show %1:%2").arg(ref).arg(relativePath); + QString title = Tr::tr("Git Show %1:%2").arg(ref).arg(relativePath); IEditor *editor = EditorManager::openEditorWithContents(Id(), &title, content, documentId, EditorManager::DoNotSwitchToDesignMode); editor->document()->setTemporary(true); @@ -3876,7 +3876,6 @@ IEditor *GitClient::openShowEditor(const FilePath &workingDirectory, const QStri return editor; } -} // namespace Internal -} // namespace Git +} // Git::Internal #include "gitclient.moc" diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index dae7d19194..6ff835d0b9 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -37,8 +37,7 @@ class VcsBaseEditorWidget; class VcsCommand; } -namespace Git { -namespace Internal { +namespace Git::Internal { class CommitData; class GitBaseDiffEditorController; @@ -80,8 +79,6 @@ public: class GITSHARED_EXPORT GitClient : public VcsBase::VcsBaseClientImpl { - Q_OBJECT - public: enum CommandInProgress { NoCommand, Revert, CherryPick, Rebase, Merge, RebaseMerge }; @@ -406,5 +403,4 @@ public: GitRemote(const QString &location); }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index 305d4f1198..415d162298 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -5,9 +5,10 @@ #include "annotationhighlighter.h" #include "gitclient.h" -#include "gitsettings.h" #include "gitconstants.h" #include "githighlighters.h" +#include "gitsettings.h" +#include "gittr.h" #include <coreplugin/icore.h> #include <texteditor/textdocument.h> @@ -34,40 +35,37 @@ using namespace Core; using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { class GitLogFilterWidget : public QToolBar { - Q_DECLARE_TR_FUNCTIONS(Git::Internal::GitLogFilterWidget); - public: GitLogFilterWidget(GitEditorWidget *editor) { auto addLineEdit = [](const QString &placeholder, const QString &tooltip, GitEditorWidget *editor) { - auto lineEdit = new Utils::FancyLineEdit; + auto lineEdit = new FancyLineEdit; lineEdit->setFiltering(true); lineEdit->setToolTip(tooltip); lineEdit->setPlaceholderText(placeholder); lineEdit->setMaximumWidth(200); connect(lineEdit, &QLineEdit::returnPressed, editor, &GitEditorWidget::refresh); - connect(lineEdit, &Utils::FancyLineEdit::rightButtonClicked, + connect(lineEdit, &FancyLineEdit::rightButtonClicked, editor, &GitEditorWidget::refresh); return lineEdit; }; - grepLineEdit = addLineEdit(tr("Filter by message"), - tr("Filter log entries by text in the commit message."), + grepLineEdit = addLineEdit(Tr::tr("Filter by message"), + Tr::tr("Filter log entries by text in the commit message."), editor); - pickaxeLineEdit = addLineEdit(tr("Filter by content"), - tr("Filter log entries by added or removed string."), + pickaxeLineEdit = addLineEdit(Tr::tr("Filter by content"), + Tr::tr("Filter log entries by added or removed string."), editor); - authorLineEdit = addLineEdit(tr("Filter by author"), - tr("Filter log entries by author."), + authorLineEdit = addLineEdit(Tr::tr("Filter by author"), + Tr::tr("Filter log entries by author."), editor); - addWidget(new QLabel(tr("Filter:"))); + addWidget(new QLabel(Tr::tr("Filter:"))); addSeparator(); addWidget(grepLineEdit); addSeparator(); @@ -75,7 +73,7 @@ public: addSeparator(); addWidget(authorLineEdit); addSeparator(); - caseAction = new QAction(tr("Case Sensitive"), this); + caseAction = new QAction(Tr::tr("Case Sensitive"), this); caseAction->setCheckable(true); caseAction->setChecked(true); connect(caseAction, &QAction::toggled, editor, &GitEditorWidget::refresh); @@ -84,9 +82,9 @@ public: connect(editor, &GitEditorWidget::toggleFilters, this, &QWidget::setVisible); } - Utils::FancyLineEdit *grepLineEdit; - Utils::FancyLineEdit *pickaxeLineEdit; - Utils::FancyLineEdit *authorLineEdit; + FancyLineEdit *grepLineEdit; + FancyLineEdit *pickaxeLineEdit; + FancyLineEdit *authorLineEdit; QAction *caseAction; }; @@ -102,8 +100,8 @@ GitEditorWidget::GitEditorWidget() : */ setDiffFilePattern("^(?:diff --git a/|index |[+-]{3} (?:/dev/null|[ab]/(.+$)))"); setLogEntryPattern("^commit ([0-9a-f]{8})[0-9a-f]{32}"); - setAnnotateRevisionTextFormat(tr("&Blame %1")); - setAnnotatePreviousRevisionTextFormat(tr("Blame &Parent Revision %1")); + setAnnotateRevisionTextFormat(Tr::tr("&Blame %1")); + setAnnotatePreviousRevisionTextFormat(Tr::tr("Blame &Parent Revision %1")); setAnnotationEntryPattern("^(" CHANGE_PATTERN ") "); } @@ -189,9 +187,8 @@ void GitEditorWidget::setPlainText(const QString &text) switch (contentType()) { case LogOutput: { - Utils::AnsiEscapeCodeHandler handler; - const QList<Utils::FormattedText> formattedTextList - = handler.parseText(Utils::FormattedText(text)); + AnsiEscapeCodeHandler handler; + const QList<FormattedText> formattedTextList = handler.parseText(FormattedText(text)); clear(); QTextCursor cursor = textCursor(); @@ -215,7 +212,7 @@ void GitEditorWidget::setPlainText(const QString &text) void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, PatchAction patchAction) { - Utils::TemporaryFile patchFile("git-apply-chunk"); + TemporaryFile patchFile("git-apply-chunk"); if (!patchFile.open()) return; @@ -230,7 +227,7 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, PatchAction patchAc QString errorMessage; if (GitClient::instance()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) { if (errorMessage.isEmpty()) - VcsOutputWindow::append(tr("Chunk successfully staged")); + VcsOutputWindow::append(Tr::tr("Chunk successfully staged")); else VcsOutputWindow::append(errorMessage); if (patchAction == PatchAction::Revert) @@ -243,7 +240,7 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, PatchAction patchAc void GitEditorWidget::init() { VcsBaseEditorWidget::init(); - Utils::Id editorId = textDocument()->id(); + Id editorId = textDocument()->id(); const bool isCommitEditor = editorId == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID; const bool isRebaseEditor = editorId == Git::Constants::GIT_REBASE_EDITOR_ID; if (!isCommitEditor && !isRebaseEditor) @@ -259,22 +256,21 @@ void GitEditorWidget::addDiffActions(QMenu *menu, const DiffChunk &chunk) { menu->addSeparator(); - QAction *stageAction = menu->addAction(tr("Stage Chunk...")); + QAction *stageAction = menu->addAction(Tr::tr("Stage Chunk...")); connect(stageAction, &QAction::triggered, this, [this, chunk] { applyDiffChunk(chunk, PatchAction::Apply); }); - QAction *unstageAction = menu->addAction(tr("Unstage Chunk...")); + QAction *unstageAction = menu->addAction(Tr::tr("Unstage Chunk...")); connect(unstageAction, &QAction::triggered, this, [this, chunk] { applyDiffChunk(chunk, PatchAction::Revert); }); } -void GitEditorWidget::aboutToOpen(const Utils::FilePath &filePath, - const Utils::FilePath &realFilePath) +void GitEditorWidget::aboutToOpen(const FilePath &filePath, const FilePath &realFilePath) { Q_UNUSED(realFilePath) - Utils::Id editorId = textDocument()->id(); + Id editorId = textDocument()->id(); if (editorId == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID || editorId == Git::Constants::GIT_REBASE_EDITOR_ID) { const FilePath gitPath = filePath.absolutePath(); @@ -392,5 +388,4 @@ bool GitEditorWidget::caseSensitive() const return m_logFilterWidget && m_logFilterWidget->caseAction->isChecked(); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/giteditor.h b/src/plugins/git/giteditor.h index 8c92a6da65..79ec42299c 100644 --- a/src/plugins/git/giteditor.h +++ b/src/plugins/git/giteditor.h @@ -12,8 +12,7 @@ class FancyLineEdit; class FilePath; } // Utils -namespace Git { -namespace Internal { +namespace Git::Internal { class GitLogFilterWidget; @@ -57,5 +56,4 @@ private: GitLogFilterWidget *m_logFilterWidget = nullptr; }; -} // namespace Git -} // namespace Internal +} // Git::Internal diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp index abcea246bf..1e0fc3f131 100644 --- a/src/plugins/git/gitgrep.cpp +++ b/src/plugins/git/gitgrep.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "gitgrep.h" + #include "gitclient.h" +#include "gittr.h" #include <coreplugin/vcsmanager.h> @@ -25,8 +27,13 @@ #include <QSettings> #include <QTextStream> -namespace Git { -namespace Internal { +using namespace Core; +using namespace Utils; +using namespace VcsBase; + +namespace Git::Internal { + +const char GitGrepRef[] = "GitGrepRef"; class GitGrepParameters { @@ -36,14 +43,6 @@ public: QString id() const { return recurseSubmodules ? ref + ".Rec" : ref; } }; -using namespace Core; -using namespace Utils; -using namespace VcsBase; - -namespace { - -const char GitGrepRef[] = "GitGrepRef"; - class GitGrepRunner { using FutureInterfaceType = QFutureInterface<FileSearchResultList>; @@ -192,8 +191,6 @@ private: Environment m_environment; }; -} // namespace - static bool isGitDirectory(const FilePath &path) { static IVersionControl *gitVc = VcsManager::versionControl(VcsBase::Constants::VCS_ID_GIT); @@ -208,8 +205,8 @@ GitGrep::GitGrep(GitClient *client) auto layout = new QHBoxLayout(m_widget); layout->setContentsMargins(0, 0, 0, 0); m_treeLineEdit = new FancyLineEdit; - m_treeLineEdit->setPlaceholderText(tr("Tree (optional)")); - m_treeLineEdit->setToolTip(tr("Can be HEAD, tag, local or remote branch, or a commit hash.\n" + m_treeLineEdit->setPlaceholderText(Tr::tr("Tree (optional)")); + m_treeLineEdit->setToolTip(Tr::tr("Can be HEAD, tag, local or remote branch, or a commit hash.\n" "Leave empty to search through the file system.")); const QRegularExpression refExpression("[\\S]*"); m_treeLineEdit->setValidator(new QRegularExpressionValidator(refExpression, this)); @@ -219,7 +216,7 @@ GitGrep::GitGrep(GitClient *client) this, [this, pLayout = QPointer<QHBoxLayout>(layout)](unsigned version) { if (version >= 0x021300 && pLayout) { - m_recurseSubmodules = new QCheckBox(tr("Recurse submodules")); + m_recurseSubmodules = new QCheckBox(Tr::tr("Recurse submodules")); pLayout->addWidget(m_recurseSubmodules); } }); @@ -240,14 +237,14 @@ GitGrep::~GitGrep() QString GitGrep::title() const { - return tr("Git Grep"); + return Tr::tr("Git Grep"); } QString GitGrep::toolTip() const { const QString ref = m_treeLineEdit->text(); if (!ref.isEmpty()) - return tr("Ref: %1\n%2").arg(ref); + return Tr::tr("Ref: %1\n%2").arg(ref); return QLatin1String("%1"); } @@ -296,7 +293,6 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item, return editor; } -} // Internal -} // Git +} // Git::Internal Q_DECLARE_METATYPE(Git::Internal::GitGrepParameters) diff --git a/src/plugins/git/gitgrep.h b/src/plugins/git/gitgrep.h index 41310c8b65..405f1bc50f 100644 --- a/src/plugins/git/gitgrep.h +++ b/src/plugins/git/gitgrep.h @@ -5,24 +5,20 @@ #include <texteditor/basefilefind.h> -#include <QCoreApplication> - QT_FORWARD_DECLARE_CLASS(QCheckBox); namespace Utils { class FancyLineEdit; } -namespace Git { -namespace Internal { +namespace Git::Internal { class GitClient; class GitGrep : public TextEditor::SearchEngine { - Q_DECLARE_TR_FUNCTIONS(GitGrep) - public: explicit GitGrep(GitClient *client); ~GitGrep() override; + QString title() const override; QString toolTip() const override; QWidget *widget() const override; @@ -42,5 +38,4 @@ private: QCheckBox *m_recurseSubmodules = nullptr; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/githighlighters.cpp b/src/plugins/git/githighlighters.cpp index 3b98221741..a3b7547f08 100644 --- a/src/plugins/git/githighlighters.cpp +++ b/src/plugins/git/githighlighters.cpp @@ -8,10 +8,9 @@ #include "gitconstants.h" #include "githighlighters.h" -namespace Git { -namespace Internal { +namespace Git::Internal { -static const char CHANGE_PATTERN[] = "\\b[a-f0-9]{7,40}\\b"; +const char CHANGE_PATTERN[] = "\\b[a-f0-9]{7,40}\\b"; GitSubmitHighlighter::GitSubmitHighlighter(QChar commentChar, QTextEdit * parent) : TextEditor::SyntaxHighlighter(parent), @@ -159,5 +158,4 @@ void GitRebaseHighlighter::highlightBlock(const QString &text) formatSpaces(text); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/githighlighters.h b/src/plugins/git/githighlighters.h index 3feb11373b..81fb8327d8 100644 --- a/src/plugins/git/githighlighters.h +++ b/src/plugins/git/githighlighters.h @@ -7,8 +7,7 @@ #include <QRegularExpression> -namespace Git { -namespace Internal { +namespace Git::Internal { enum Format { Format_Comment, @@ -35,6 +34,7 @@ class GitSubmitHighlighter : public TextEditor::SyntaxHighlighter { public: explicit GitSubmitHighlighter(QChar commentChar = QChar(), QTextEdit *parent = nullptr); + void highlightBlock(const QString &text) override; QChar commentChar() const; void setCommentChar(QChar commentChar); @@ -66,5 +66,4 @@ private: QList<RebaseAction> m_actions; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 83446e1f04..4a19145300 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -9,12 +9,13 @@ #include "gitclient.h" #include "gitconstants.h" #include "giteditor.h" +#include "gitgrep.h" #include "gitsubmiteditor.h" +#include "gittr.h" +#include "gitutils.h" +#include "logchangedialog.h" #include "remotedialog.h" #include "stashdialog.h" -#include "logchangedialog.h" -#include "gitutils.h" -#include "gitgrep.h" #include "gerrit/gerritplugin.h" @@ -80,8 +81,7 @@ using namespace Utils; using namespace VcsBase; using namespace std::placeholders; -namespace Git { -namespace Internal { +namespace Git::Internal { using GitClientMemberFunc = void (GitClient::*)(const FilePath &) const; @@ -242,9 +242,9 @@ public: const FilePath &workingDirectory, const QString &reference) final { - menu->addAction(tr("&Copy \"%1\"").arg(reference), + menu->addAction(Tr::tr("&Copy \"%1\"").arg(reference), [reference] { setClipboardAndSelection(reference); }); - QAction *action = menu->addAction(tr("&Describe Change %1").arg(reference), + QAction *action = menu->addAction(Tr::tr("&Describe Change %1").arg(reference), [=] { vcsDescribe(workingDirectory, reference); }); menu->setDefaultAction(action); GitClient::addChangeActions(menu, workingDirectory.toString(), reference); @@ -457,7 +457,7 @@ void GitPluginPrivate::onApplySettings() m_settings.gitExecutable(&gitFoundOk, &errorMessage); if (!gitFoundOk) { QTimer::singleShot(0, this, [errorMessage] { - AsynchronousMessageBox::warning(tr("Git Settings"), errorMessage); + AsynchronousMessageBox::warning(Tr::tr("Git Settings"), errorMessage); }); } } @@ -498,8 +498,8 @@ const VcsBasePluginState &GitPlugin::currentState() QString GitPlugin::msgRepositoryLabel(const FilePath &repository) { return repository.isEmpty() ? - tr("<No repository>") : - tr("Repository: %1").arg(repository.toUserOutput()); + Tr::tr("<No repository>") : + Tr::tr("Repository: %1").arg(repository.toUserOutput()); } // Returns a regular expression pattern with characters not allowed @@ -644,79 +644,79 @@ GitPluginPrivate::GitPluginPrivate() const QString prefix = "git"; m_commandLocator = new CommandLocator("Git", prefix, prefix, this); - m_commandLocator->setDescription(tr("Triggers a Git version control operation.")); + m_commandLocator->setDescription(Tr::tr("Triggers a Git version control operation.")); //register actions ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *gitContainer = ActionManager::createMenu("Git"); - gitContainer->menu()->setTitle(tr("&Git")); + gitContainer->menu()->setTitle(Tr::tr("&Git")); toolsContainer->addMenu(gitContainer); m_menuAction = gitContainer->menu()->menuAction(); /* "Current File" menu */ ActionContainer *currentFileMenu = ActionManager::createMenu("Git.CurrentFileMenu"); - currentFileMenu->menu()->setTitle(tr("Current &File")); + currentFileMenu->menu()->setTitle(Tr::tr("Current &File")); gitContainer->addMenu(currentFileMenu); - createFileAction(currentFileMenu, tr("Diff Current File", "Avoid translating \"Diff\""), - tr("Diff of \"%1\"", "Avoid translating \"Diff\""), + createFileAction(currentFileMenu, Tr::tr("Diff Current File", "Avoid translating \"Diff\""), + Tr::tr("Diff of \"%1\"", "Avoid translating \"Diff\""), "Git.Diff", context, true, std::bind(&GitPluginPrivate::diffCurrentFile, this), - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+D") : tr("Alt+G,Alt+D"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+D") : Tr::tr("Alt+G,Alt+D"))); - createFileAction(currentFileMenu, tr("Log Current File", "Avoid translating \"Log\""), - tr("Log of \"%1\"", "Avoid translating \"Log\""), + createFileAction(currentFileMenu, Tr::tr("Log Current File", "Avoid translating \"Log\""), + Tr::tr("Log of \"%1\"", "Avoid translating \"Log\""), "Git.Log", context, true, std::bind(&GitPluginPrivate::logFile, this), - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+L") : tr("Alt+G,Alt+L"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+L") : Tr::tr("Alt+G,Alt+L"))); - createFileAction(currentFileMenu, tr("Blame Current File", "Avoid translating \"Blame\""), - tr("Blame for \"%1\"", "Avoid translating \"Blame\""), + createFileAction(currentFileMenu, Tr::tr("Blame Current File", "Avoid translating \"Blame\""), + Tr::tr("Blame for \"%1\"", "Avoid translating \"Blame\""), "Git.Blame", context, true, std::bind(&GitPluginPrivate::blameFile, this), - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+B") : tr("Alt+G,Alt+B"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+B") : Tr::tr("Alt+G,Alt+B"))); currentFileMenu->addSeparator(context); - createFileAction(currentFileMenu, tr("Stage File for Commit"), tr("Stage \"%1\" for Commit"), + createFileAction(currentFileMenu, Tr::tr("Stage File for Commit"), Tr::tr("Stage \"%1\" for Commit"), "Git.Stage", context, true, std::bind(&GitPluginPrivate::stageFile, this), - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+A") : tr("Alt+G,Alt+A"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+A") : Tr::tr("Alt+G,Alt+A"))); - createFileAction(currentFileMenu, tr("Unstage File from Commit"), tr("Unstage \"%1\" from Commit"), + createFileAction(currentFileMenu, Tr::tr("Unstage File from Commit"), Tr::tr("Unstage \"%1\" from Commit"), "Git.Unstage", context, true, std::bind(&GitPluginPrivate::unstageFile, this)); - createFileAction(currentFileMenu, tr("Undo Unstaged Changes"), tr("Undo Unstaged Changes for \"%1\""), + createFileAction(currentFileMenu, Tr::tr("Undo Unstaged Changes"), Tr::tr("Undo Unstaged Changes for \"%1\""), "Git.UndoUnstaged", context, true, std::bind(&GitPluginPrivate::undoFileChanges, this, false)); - createFileAction(currentFileMenu, tr("Undo Uncommitted Changes"), tr("Undo Uncommitted Changes for \"%1\""), + createFileAction(currentFileMenu, Tr::tr("Undo Uncommitted Changes"), Tr::tr("Undo Uncommitted Changes for \"%1\""), "Git.Undo", context, true, std::bind(&GitPluginPrivate::undoFileChanges, this, true), - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+U") : tr("Alt+G,Alt+U"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+U") : Tr::tr("Alt+G,Alt+U"))); /* "Current Project" menu */ ActionContainer *currentProjectMenu = ActionManager::createMenu("Git.CurrentProjectMenu"); - currentProjectMenu->menu()->setTitle(tr("Current &Project")); + currentProjectMenu->menu()->setTitle(Tr::tr("Current &Project")); gitContainer->addMenu(currentProjectMenu); - createProjectAction(currentProjectMenu, tr("Diff Current Project", "Avoid translating \"Diff\""), - tr("Diff Project \"%1\"", "Avoid translating \"Diff\""), + createProjectAction(currentProjectMenu, Tr::tr("Diff Current Project", "Avoid translating \"Diff\""), + Tr::tr("Diff Project \"%1\"", "Avoid translating \"Diff\""), "Git.DiffProject", context, true, &GitPluginPrivate::diffCurrentProject, - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+Shift+D") : tr("Alt+G,Alt+Shift+D"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+Shift+D") : Tr::tr("Alt+G,Alt+Shift+D"))); - createProjectAction(currentProjectMenu, tr("Log Project", "Avoid translating \"Log\""), - tr("Log Project \"%1\"", "Avoid translating \"Log\""), + createProjectAction(currentProjectMenu, Tr::tr("Log Project", "Avoid translating \"Log\""), + Tr::tr("Log Project \"%1\"", "Avoid translating \"Log\""), "Git.LogProject", context, true, &GitPluginPrivate::logProject, - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+K") : tr("Alt+G,Alt+K"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+K") : Tr::tr("Alt+G,Alt+K"))); - createProjectAction(currentProjectMenu, tr("Clean Project...", "Avoid translating \"Clean\""), - tr("Clean Project \"%1\"...", "Avoid translating \"Clean\""), + createProjectAction(currentProjectMenu, Tr::tr("Clean Project...", "Avoid translating \"Clean\""), + Tr::tr("Clean Project \"%1\"...", "Avoid translating \"Clean\""), "Git.CleanProject", context, true, &GitPluginPrivate::cleanProject); /* "Local Repository" menu */ ActionContainer *localRepositoryMenu = ActionManager::createMenu("Git.LocalRepositoryMenu"); - localRepositoryMenu->menu()->setTitle(tr("&Local Repository")); + localRepositoryMenu->menu()->setTitle(Tr::tr("&Local Repository")); gitContainer->addMenu(localRepositoryMenu); createRepositoryAction(localRepositoryMenu, "Diff", "Git.DiffRepository", @@ -739,16 +739,16 @@ GitPluginPrivate::GitPluginPrivate() createRepositoryAction(localRepositoryMenu, "Commit...", "Git.Commit", context, true, std::bind(&GitPluginPrivate::startCommit, this, SimpleCommit), - QKeySequence(useMacShortcuts ? tr("Meta+G,Meta+C") : tr("Alt+G,Alt+C"))); + QKeySequence(useMacShortcuts ? Tr::tr("Meta+G,Meta+C") : Tr::tr("Alt+G,Alt+C"))); createRepositoryAction(localRepositoryMenu, - tr("Amend Last Commit...", "Avoid translating \"Commit\""), + Tr::tr("Amend Last Commit...", "Avoid translating \"Commit\""), "Git.AmendCommit", context, true, std::bind(&GitPluginPrivate::startCommit, this, AmendCommit)); m_fixupCommitAction = createRepositoryAction(localRepositoryMenu, - tr("Fixup Previous Commit...", "Avoid translating \"Commit\""), + Tr::tr("Fixup Previous Commit...", "Avoid translating \"Commit\""), "Git.FixupCommit", context, true, std::bind(&GitPluginPrivate::startCommit, this, FixupCommit)); @@ -758,18 +758,18 @@ GitPluginPrivate::GitPluginPrivate() createRepositoryAction(localRepositoryMenu, "Reset...", "Git.Reset", context, true, std::bind(&GitPluginPrivate::resetRepository, this)); - createRepositoryAction(localRepositoryMenu, tr("Recover Deleted Files"), "Git.RecoverDeleted", + createRepositoryAction(localRepositoryMenu, Tr::tr("Recover Deleted Files"), "Git.RecoverDeleted", context, true, std::bind(&GitPluginPrivate::recoverDeletedFiles, this)); m_interactiveRebaseAction = createRepositoryAction(localRepositoryMenu, - tr("Interactive Rebase...", "Avoid translating \"Rebase\""), + Tr::tr("Interactive Rebase...", "Avoid translating \"Rebase\""), "Git.InteractiveRebase", context, true, std::bind(&GitPluginPrivate::startRebase, this)); m_submoduleUpdateAction = createRepositoryAction(localRepositoryMenu, - tr("Update Submodules"), "Git.SubmoduleUpdate", + Tr::tr("Update Submodules"), "Git.SubmoduleUpdate", context, true, std::bind(&GitPluginPrivate::updateSubmodules, this)); auto createAction = [=](const QString &text, Id id, @@ -787,34 +787,34 @@ GitPluginPrivate::GitPluginPrivate() return createRepositoryAction(localRepositoryMenu, text, id, context, true, actionHandler); }; - m_abortMergeAction = createAction(tr("Abort Merge", "Avoid translating \"Merge\""), "Git.MergeAbort", + m_abortMergeAction = createAction(Tr::tr("Abort Merge", "Avoid translating \"Merge\""), "Git.MergeAbort", std::bind(&GitClient::synchronousMerge, &m_gitClient, _1, QString("--abort"), true)); - m_abortRebaseAction = createAction(tr("Abort Rebase", "Avoid translating \"Rebase\""), "Git.RebaseAbort", + m_abortRebaseAction = createAction(Tr::tr("Abort Rebase", "Avoid translating \"Rebase\""), "Git.RebaseAbort", std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--abort"))); - m_continueRebaseAction = createAction(tr("Continue Rebase"), "Git.RebaseContinue", + m_continueRebaseAction = createAction(Tr::tr("Continue Rebase"), "Git.RebaseContinue", std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--continue"))); - m_skipRebaseAction = createAction(tr("Skip Rebase"), "Git.RebaseSkip", + m_skipRebaseAction = createAction(Tr::tr("Skip Rebase"), "Git.RebaseSkip", std::bind(&GitClient::rebase, &m_gitClient, _1, QString("--skip"))); - m_abortCherryPickAction = createAction(tr("Abort Cherry Pick", "Avoid translating \"Cherry Pick\""), "Git.CherryPickAbort", + m_abortCherryPickAction = createAction(Tr::tr("Abort Cherry Pick", "Avoid translating \"Cherry Pick\""), "Git.CherryPickAbort", std::bind(&GitClient::synchronousCherryPick, &m_gitClient, _1, QString("--abort"))); - m_continueCherryPickAction = createAction(tr("Continue Cherry Pick"), "Git.CherryPickContinue", + m_continueCherryPickAction = createAction(Tr::tr("Continue Cherry Pick"), "Git.CherryPickContinue", std::bind(&GitClient::cherryPick, &m_gitClient, _1, QString("--continue"))); - m_abortRevertAction = createAction(tr("Abort Revert", "Avoid translating \"Revert\""), "Git.RevertAbort", + m_abortRevertAction = createAction(Tr::tr("Abort Revert", "Avoid translating \"Revert\""), "Git.RevertAbort", std::bind(&GitClient::synchronousRevert, &m_gitClient, _1, QString("--abort"))); - m_continueRevertAction = createAction(tr("Continue Revert"), "Git.RevertContinue", + m_continueRevertAction = createAction(Tr::tr("Continue Revert"), "Git.RevertContinue", std::bind(&GitClient::revert, &m_gitClient, _1, QString("--continue"))); // -------------- localRepositoryMenu->addSeparator(context); - createRepositoryAction(localRepositoryMenu, tr("Branches..."), "Git.BranchList", + createRepositoryAction(localRepositoryMenu, Tr::tr("Branches..."), "Git.BranchList", context, true, std::bind(&GitPluginPrivate::branchList, this)); // -------------- @@ -822,21 +822,21 @@ GitPluginPrivate::GitPluginPrivate() // "Patch" menu ActionContainer *patchMenu = ActionManager::createMenu("Git.PatchMenu"); - patchMenu->menu()->setTitle(tr("&Patch")); + patchMenu->menu()->setTitle(Tr::tr("&Patch")); localRepositoryMenu->addMenu(patchMenu); // Apply current file as patch is handled specially. m_applyCurrentFilePatchAction = createParameterAction(patchMenu, - tr("Apply from Editor"), tr("Apply \"%1\""), + Tr::tr("Apply from Editor"), Tr::tr("Apply \"%1\""), "Git.ApplyCurrentFilePatch", context, true, std::bind(&GitPluginPrivate::applyCurrentFilePatch, this)); - createRepositoryAction(patchMenu, tr("Apply from File..."), "Git.ApplyPatch", + createRepositoryAction(patchMenu, Tr::tr("Apply from File..."), "Git.ApplyPatch", context, true, std::bind(&GitPluginPrivate::promptApplyPatch, this)); // "Stash" menu ActionContainer *stashMenu = ActionManager::createMenu("Git.StashMenu"); - stashMenu->menu()->setTitle(tr("&Stash")); + stashMenu->menu()->setTitle(Tr::tr("&Stash")); localRepositoryMenu->addMenu(stashMenu); createRepositoryAction(stashMenu, "Stashes...", "Git.StashList", @@ -846,24 +846,24 @@ GitPluginPrivate::GitPluginPrivate() QAction *action = createRepositoryAction(stashMenu, "Stash", "Git.Stash", context, true, std::bind(&GitPluginPrivate::stash, this, false)); - action->setToolTip(tr("Saves the current state of your work and resets the repository.")); + action->setToolTip(Tr::tr("Saves the current state of your work and resets the repository.")); - action = createRepositoryAction(stashMenu, tr("Stash Unstaged Files", "Avoid translating \"Stash\""), + action = createRepositoryAction(stashMenu, Tr::tr("Stash Unstaged Files", "Avoid translating \"Stash\""), "Git.StashUnstaged", context, true, std::bind(&GitPluginPrivate::stashUnstaged, this)); - action->setToolTip(tr("Saves the current state of your unstaged files and resets the repository " + action->setToolTip(Tr::tr("Saves the current state of your unstaged files and resets the repository " "to its staged state.")); - action = createRepositoryAction(stashMenu, tr("Take Snapshot..."), "Git.StashSnapshot", + action = createRepositoryAction(stashMenu, Tr::tr("Take Snapshot..."), "Git.StashSnapshot", context, true, std::bind(&GitPluginPrivate::stashSnapshot, this)); - action->setToolTip(tr("Saves the current state of your work.")); + action->setToolTip(Tr::tr("Saves the current state of your work.")); stashMenu->addSeparator(context); - action = createRepositoryAction(stashMenu, tr("Stash Pop", "Avoid translating \"Stash\""), + action = createRepositoryAction(stashMenu, Tr::tr("Stash Pop", "Avoid translating \"Stash\""), "Git.StashPop", context, true, std::bind(&GitPluginPrivate::stashPop, this)); - action->setToolTip(tr("Restores changes saved to the stash list using \"Stash\".")); + action->setToolTip(Tr::tr("Restores changes saved to the stash list using \"Stash\".")); /* \"Local Repository" menu */ @@ -872,7 +872,7 @@ GitPluginPrivate::GitPluginPrivate() /* "Remote Repository" menu */ ActionContainer *remoteRepositoryMenu = ActionManager::createMenu("Git.RemoteRepositoryMenu"); - remoteRepositoryMenu->menu()->setTitle(tr("&Remote Repository")); + remoteRepositoryMenu->menu()->setTitle(Tr::tr("&Remote Repository")); gitContainer->addMenu(remoteRepositoryMenu); createRepositoryAction(remoteRepositoryMenu, "Fetch", "Git.Fetch", @@ -889,7 +889,7 @@ GitPluginPrivate::GitPluginPrivate() // "Subversion" menu ActionContainer *subversionMenu = ActionManager::createMenu("Git.Subversion"); - subversionMenu->menu()->setTitle(tr("&Subversion")); + subversionMenu->menu()->setTitle(Tr::tr("&Subversion")); remoteRepositoryMenu->addMenu(subversionMenu); createRepositoryAction(subversionMenu, "Log", "Git.Subversion.Log", @@ -898,13 +898,13 @@ GitPluginPrivate::GitPluginPrivate() createRepositoryAction(subversionMenu, "Fetch", "Git.Subversion.Fetch", context, false, &GitClient::synchronousSubversionFetch); - createRepositoryAction(subversionMenu, tr("DCommit"), "Git.Subversion.DCommit", + createRepositoryAction(subversionMenu, Tr::tr("DCommit"), "Git.Subversion.DCommit", context, false, &GitClient::subversionDeltaCommit); // -------------- remoteRepositoryMenu->addSeparator(context); - createRepositoryAction(remoteRepositoryMenu, tr("Manage Remotes..."), "Git.RemoteList", + createRepositoryAction(remoteRepositoryMenu, Tr::tr("Manage Remotes..."), "Git.RemoteList", context, false, std::bind(&GitPluginPrivate::manageRemotes, this)); /* \"Remote Repository" menu */ @@ -916,7 +916,7 @@ GitPluginPrivate::GitPluginPrivate() createChangeRelatedRepositoryAction("Revert...", "Git.Revert", context); createChangeRelatedRepositoryAction("Cherry Pick...", "Git.CherryPick", context); createChangeRelatedRepositoryAction("Checkout...", "Git.Checkout", context); - createChangeRelatedRepositoryAction(tr("Archive..."), "Git.Archive", context); + createChangeRelatedRepositoryAction(Tr::tr("Archive..."), "Git.Archive", context); createRepositoryAction(nullptr, "Rebase...", "Git.Rebase", context, true, std::bind(&GitPluginPrivate::branchList, this)); @@ -928,22 +928,22 @@ GitPluginPrivate::GitPluginPrivate() /* "Git Tools" menu */ ActionContainer *gitToolsMenu = ActionManager::createMenu("Git.GitToolsMenu"); - gitToolsMenu->menu()->setTitle(tr("Git &Tools")); + gitToolsMenu->menu()->setTitle(Tr::tr("Git &Tools")); gitContainer->addMenu(gitToolsMenu); - createRepositoryAction(gitToolsMenu, tr("Gitk"), "Git.LaunchGitK", + createRepositoryAction(gitToolsMenu, Tr::tr("Gitk"), "Git.LaunchGitK", context, true, &GitClient::launchGitK); - createFileAction(gitToolsMenu, tr("Gitk Current File"), tr("Gitk of \"%1\""), + createFileAction(gitToolsMenu, Tr::tr("Gitk Current File"), Tr::tr("Gitk of \"%1\""), "Git.GitkFile", context, true, std::bind(&GitPluginPrivate::gitkForCurrentFile, this)); - createFileAction(gitToolsMenu, tr("Gitk for folder of Current File"), tr("Gitk for folder of \"%1\""), + createFileAction(gitToolsMenu, Tr::tr("Gitk for folder of Current File"), Tr::tr("Gitk for folder of \"%1\""), "Git.GitkFolder", context, true, std::bind(&GitPluginPrivate::gitkForCurrentFolder, this)); // -------------- gitToolsMenu->addSeparator(context); - createRepositoryAction(gitToolsMenu, tr("Git Gui"), "Git.GitGui", + createRepositoryAction(gitToolsMenu, Tr::tr("Git Gui"), "Git.GitGui", context, true, std::bind(&GitPluginPrivate::gitGui, this)); // -------------- @@ -951,18 +951,18 @@ GitPluginPrivate::GitPluginPrivate() m_repositoryBrowserAction = createRepositoryAction(gitToolsMenu, - tr("Repository Browser"), "Git.LaunchRepositoryBrowser", + Tr::tr("Repository Browser"), "Git.LaunchRepositoryBrowser", context, true, &GitClient::launchRepositoryBrowser); m_mergeToolAction - = createRepositoryAction(gitToolsMenu, tr("Merge Tool"), "Git.MergeTool", + = createRepositoryAction(gitToolsMenu, Tr::tr("Merge Tool"), "Git.MergeTool", context, true, std::bind(&GitPluginPrivate::startMergeTool, this)); // -------------- if (HostOsInfo::isWindowsHost()) { gitToolsMenu->addSeparator(context); - createRepositoryAction(gitToolsMenu, tr("Git Bash"), "Git.GitBash", + createRepositoryAction(gitToolsMenu, Tr::tr("Git Bash"), "Git.GitBash", context, true, std::bind(&GitPluginPrivate::gitBash, this)); } @@ -971,14 +971,14 @@ GitPluginPrivate::GitPluginPrivate() // -------------- gitContainer->addSeparator(context); - QAction *actionsOnCommitsAction = new QAction(tr("Actions on Commits..."), this); + QAction *actionsOnCommitsAction = new QAction(Tr::tr("Actions on Commits..."), this); Command *actionsOnCommitsCommand = ActionManager::registerAction( actionsOnCommitsAction, "Git.ChangeActions"); connect(actionsOnCommitsAction, &QAction::triggered, this, [this] { startChangeRelatedAction("Git.ChangeActions"); }); gitContainer->addAction(actionsOnCommitsCommand); - QAction *createRepositoryAction = new QAction(tr("Create Repository..."), this); + QAction *createRepositoryAction = new QAction(Tr::tr("Create Repository..."), this); Command *createRepositoryCommand = ActionManager::registerAction( createRepositoryAction, "Git.CreateRepository"); connect(createRepositoryAction, &QAction::triggered, this, &GitPluginPrivate::createRepository); @@ -1131,7 +1131,7 @@ void GitPluginPrivate::resetRepository() LogChangeDialog dialog(true, ICore::dialogParent()); ResetItemDelegate delegate(dialog.widget()); - dialog.setWindowTitle(tr("Undo Changes to %1").arg(topLevel.toUserOutput())); + dialog.setWindowTitle(Tr::tr("Undo Changes to %1").arg(topLevel.toUserOutput())); if (dialog.runDialog(topLevel, {}, LogChangeWidget::IncludeRemotes)) m_gitClient.reset(topLevel, dialog.resetFlag(), dialog.commit()); } @@ -1164,7 +1164,7 @@ void GitPluginPrivate::startRebaseFromCommit(const FilePath &workingDirectory, Q if (commit.isEmpty()) { LogChangeDialog dialog(false, ICore::dialogParent()); RebaseItemDelegate delegate(dialog.widget()); - dialog.setWindowTitle(tr("Interactive Rebase")); + dialog.setWindowTitle(Tr::tr("Interactive Rebase")); if (!dialog.runDialog(workingDirectory)) return; commit = dialog.commit(); @@ -1299,7 +1299,7 @@ void GitPluginPrivate::startCommit(CommitType commitType) if (raiseSubmitEditor()) return; if (isCommitEditorOpen()) { - VcsOutputWindow::appendWarning(tr("Another submit is currently being executed.")); + VcsOutputWindow::appendWarning(Tr::tr("Another submit is currently being executed.")); return; } @@ -1344,7 +1344,7 @@ void GitPluginPrivate::updateVersionWarning() return; infoBar->addInfo( InfoBarEntry(gitVersionWarning, - tr("Unsupported version of Git found. Git %1 or later required.") + Tr::tr("Unsupported version of Git found. Git %1 or later required.") .arg(versionString(minimumRequiredVersion)), InfoBarEntry::GlobalSuppression::Enabled)); }); @@ -1362,13 +1362,13 @@ IEditor *GitPluginPrivate::openSubmitEditor(const QString &fileName, const Commi QString title; switch (cd.commitType) { case AmendCommit: - title = tr("Amend %1").arg(cd.amendSHA1); + title = Tr::tr("Amend %1").arg(cd.amendSHA1); break; case FixupCommit: - title = tr("Git Fixup Commit"); + title = Tr::tr("Git Fixup Commit"); break; default: - title = tr("Git Commit"); + title = Tr::tr("Git Commit"); } IDocument *document = submitEditor->document(); document->setPreferredDisplayName(title); @@ -1518,12 +1518,12 @@ void GitPluginPrivate::cleanRepository(const FilePath &directory) QApplication::restoreOverrideCursor(); if (!gotFiles) { - AsynchronousMessageBox::warning(tr("Unable to Retrieve File List"), errorMessage); + AsynchronousMessageBox::warning(Tr::tr("Unable to Retrieve File List"), errorMessage); return; } if (files.isEmpty() && ignoredFiles.isEmpty()) { - AsynchronousMessageBox::information(tr("Repository Clean"), - tr("The repository is clean.")); + AsynchronousMessageBox::information(Tr::tr("Repository Clean"), + Tr::tr("The repository is clean.")); return; } @@ -1571,8 +1571,8 @@ void GitPluginPrivate::applyPatch(const FilePath &workingDirectory, QString file return; // Prompt for file if (file.isEmpty()) { - const QString filter = tr("Patches (*.patch *.diff)"); - file = QFileDialog::getOpenFileName(ICore::dialogParent(), tr("Choose Patch"), {}, filter); + const QString filter = Tr::tr("Patches (*.patch *.diff)"); + file = QFileDialog::getOpenFileName(ICore::dialogParent(), Tr::tr("Choose Patch"), {}, filter); if (file.isEmpty()) { m_gitClient.endStashScope(workingDirectory); return; @@ -1582,7 +1582,7 @@ void GitPluginPrivate::applyPatch(const FilePath &workingDirectory, QString file QString errorMessage; if (m_gitClient.synchronousApplyPatch(workingDirectory, file, &errorMessage)) { if (errorMessage.isEmpty()) - VcsOutputWindow::appendMessage(tr("Patch %1 successfully applied to %2") + VcsOutputWindow::appendMessage(Tr::tr("Patch %1 successfully applied to %2") .arg(file, workingDirectory.toUserOutput())); else VcsOutputWindow::appendError(errorMessage); @@ -2099,13 +2099,11 @@ public: bool m_isValid = true; }; -} // namespace Internal -} // namespace Git +} // Git::Internal Q_DECLARE_METATYPE(Git::Internal::RemoteTest) -namespace Git { -namespace Internal { +namespace Git::Internal { void GitPlugin::testGitRemote_data() { @@ -2189,7 +2187,6 @@ void GitPlugin::testGitRemote() #endif -} // namespace Internal -} // namespace Git +} // Git::Internal #include "gitplugin.moc" diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index c6b7edec0f..b7a3aadf92 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -16,8 +16,7 @@ namespace VcsBase { class VcsBasePluginState; } -namespace Git { -namespace Internal { +namespace Git::Internal { class GitClient; @@ -67,5 +66,4 @@ private slots: }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index b1f3103a7e..4e2432941a 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -3,6 +3,8 @@ #include "gitsettings.h" +#include "gittr.h" + #include <utils/environment.h> #include <utils/layoutbuilder.h> @@ -13,22 +15,21 @@ using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { GitSettings::GitSettings() { setSettingsGroup("Git"); path.setDisplayStyle(StringAspect::LineEditDisplay); - path.setLabelText(tr("Prepend to PATH:")); + path.setLabelText(Tr::tr("Prepend to PATH:")); registerAspect(&binaryPath); binaryPath.setDefaultValue("git"); registerAspect(&pullRebase); pullRebase.setSettingsKey("PullRebase"); - pullRebase.setLabelText(tr("Pull with rebase")); + pullRebase.setLabelText(Tr::tr("Pull with rebase")); registerAspect(&showTags); showTags.setSettingsKey("ShowTags"); @@ -55,16 +56,16 @@ GitSettings::GitSettings() registerAspect(&winSetHomeEnvironment); winSetHomeEnvironment.setSettingsKey("WinSetHomeEnvironment"); winSetHomeEnvironment.setDefaultValue(true); - winSetHomeEnvironment.setLabelText(tr("Set \"HOME\" environment variable")); + winSetHomeEnvironment.setLabelText(Tr::tr("Set \"HOME\" environment variable")); if (HostOsInfo::isWindowsHost()) { const QString currentHome = qtcEnvironmentVariable("HOME"); const QString toolTip - = tr("Set the environment variable HOME to \"%1\"\n(%2).\n" + = Tr::tr("Set the environment variable HOME to \"%1\"\n(%2).\n" "This causes Git to look for the SSH-keys in that location\n" "instead of its installation directory when run outside git bash.") .arg(QDir::homePath(), - currentHome.isEmpty() ? tr("not currently set") - : tr("currently set to \"%1\"").arg(currentHome)); + currentHome.isEmpty() ? Tr::tr("not currently set") + : Tr::tr("currently set to \"%1\"").arg(currentHome)); winSetHomeEnvironment.setToolTip(toolTip); } else { winSetHomeEnvironment.setVisible(false); @@ -73,19 +74,19 @@ GitSettings::GitSettings() registerAspect(&gitkOptions); gitkOptions.setDisplayStyle(StringAspect::LineEditDisplay); gitkOptions.setSettingsKey("GitKOptions"); - gitkOptions.setLabelText(tr("Arguments:")); + gitkOptions.setLabelText(Tr::tr("Arguments:")); registerAspect(&logDiff); logDiff.setSettingsKey("LogDiff"); - logDiff.setToolTip(tr("Note that huge amount of commits might take some time.")); + logDiff.setToolTip(Tr::tr("Note that huge amount of commits might take some time.")); registerAspect(&repositoryBrowserCmd); repositoryBrowserCmd.setDisplayStyle(StringAspect::PathChooserDisplay); repositoryBrowserCmd.setSettingsKey("RepositoryBrowserCmd"); repositoryBrowserCmd.setExpectedKind(PathChooser::ExistingCommand); repositoryBrowserCmd.setHistoryCompleter("Git.RepoCommand.History"); - repositoryBrowserCmd.setDisplayName(tr("Git Repository Browser Command")); - repositoryBrowserCmd.setLabelText(tr("Command:")); + repositoryBrowserCmd.setDisplayName(Tr::tr("Git Repository Browser Command")); + repositoryBrowserCmd.setLabelText(Tr::tr("Command:")); registerAspect(&graphLog); graphLog.setSettingsKey("GraphLog"); @@ -126,7 +127,7 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const if (ok) *ok = false; if (errorMessage) - *errorMessage = tr("The binary \"%1\" could not be located in the path \"%2\"") + *errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"") .arg(binaryPath.value(), path.value()); } return binPath; @@ -137,7 +138,7 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const GitSettingsPage::GitSettingsPage(GitSettings *settings) { setId(VcsBase::Constants::VCS_ID_GIT); - setDisplayName(GitSettings::tr("Git")); + setDisplayName(Tr::tr("Git")); setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY); setSettings(settings); @@ -147,7 +148,7 @@ GitSettingsPage::GitSettingsPage(GitSettings *settings) Column { Group { - title(GitSettings::tr("Configuration")), + title(Tr::tr("Configuration")), Column { Row { s.path }, s.winSetHomeEnvironment, @@ -155,7 +156,7 @@ GitSettingsPage::GitSettingsPage(GitSettings *settings) }, Group { - title(GitSettings::tr("Miscellaneous")), + title(Tr::tr("Miscellaneous")), Column { Row { s.logCount, s.timeout, st }, s.pullRebase @@ -163,12 +164,12 @@ GitSettingsPage::GitSettingsPage(GitSettings *settings) }, Group { - title(GitSettings::tr("Gitk")), + title(Tr::tr("Gitk")), Row { s.gitkOptions } }, Group { - title(GitSettings::tr("Repository Browser")), + title(Tr::tr("Repository Browser")), Row { s.repositoryBrowserCmd } }, @@ -177,5 +178,4 @@ GitSettingsPage::GitSettingsPage(GitSettings *settings) }); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h index 6ac00afe88..0bf4e68fa5 100644 --- a/src/plugins/git/gitsettings.h +++ b/src/plugins/git/gitsettings.h @@ -6,8 +6,7 @@ #include <coreplugin/dialogs/ioptionspage.h> #include <vcsbase/vcsbaseclientsettings.h> -namespace Git { -namespace Internal { +namespace Git::Internal { enum CommitType { @@ -19,8 +18,6 @@ enum CommitType // Todo: Add user name and password? class GitSettings : public VcsBase::VcsBaseSettings { - Q_DECLARE_TR_FUNCTIONS(Git::Internal::GitSettings) - public: GitSettings(); @@ -51,5 +48,4 @@ public: explicit GitSettingsPage(GitSettings *settings); }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp index 09ce7214b3..4614f7293d 100644 --- a/src/plugins/git/gitsubmiteditor.cpp +++ b/src/plugins/git/gitsubmiteditor.cpp @@ -2,9 +2,11 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "gitsubmiteditor.h" + #include "gitclient.h" #include "gitplugin.h" #include "gitsubmiteditorwidget.h" +#include "gittr.h" #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/iversioncontrol.h> @@ -19,13 +21,12 @@ #include <QTextCodec> #include <QTimer> -static const char TASK_UPDATE_COMMIT[] = "Git.UpdateCommit"; - using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { + +const char TASK_UPDATE_COMMIT[] = "Git.UpdateCommit"; class GitSubmitFileModel : public SubmitFileModel { @@ -206,7 +207,7 @@ void GitSubmitEditor::updateFileModel() w->setUpdateInProgress(true); m_fetchWatcher.setFuture(Utils::runAsync(&CommitDataFetchResult::fetch, m_commitType, m_workingDirectory)); - Core::ProgressManager::addTask(m_fetchWatcher.future(), tr("Refreshing Commit Data"), + Core::ProgressManager::addTask(m_fetchWatcher.future(), Tr::tr("Refreshing Commit Data"), TASK_UPDATE_COMMIT); GitClient::instance()->addFuture(QFuture<void>(m_fetchWatcher.future())); @@ -262,5 +263,4 @@ QByteArray GitSubmitEditor::fileContents() const return text.toUtf8(); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitsubmiteditor.h b/src/plugins/git/gitsubmiteditor.h index 8798072465..3b82870d8d 100644 --- a/src/plugins/git/gitsubmiteditor.h +++ b/src/plugins/git/gitsubmiteditor.h @@ -14,8 +14,7 @@ namespace VcsBase { class SubmitFileModel; } -namespace Git { -namespace Internal { +namespace Git::Internal { class GitSubmitEditorWidget; class GitSubmitEditorPanelData; @@ -65,5 +64,4 @@ private: QFutureWatcher<CommitDataFetchResult> m_fetchWatcher; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp index 57d5528079..f81e22d169 100644 --- a/src/plugins/git/gitsubmiteditorwidget.cpp +++ b/src/plugins/git/gitsubmiteditorwidget.cpp @@ -6,6 +6,7 @@ #include "commitdata.h" #include "gitconstants.h" #include "githighlighters.h" +#include "gittr.h" #include "logchangedialog.h" #include <coreplugin/coreconstants.h> @@ -18,8 +19,6 @@ #include <QApplication> #include <QCheckBox> -#include <QDir> -#include <QGroupBox> #include <QGroupBox> #include <QLabel> #include <QLineEdit> @@ -30,8 +29,7 @@ using namespace Utils; -namespace Git { -namespace Internal { +namespace Git::Internal { class GitSubmitPanel : public QWidget { @@ -40,9 +38,9 @@ public: { resize(364, 269); - repositoryLabel = new QLabel(tr("repository")); - branchLabel = new QLabel(tr("branch")); // FIXME: Isn't this overwritten soon? - showHeadLabel = new QLabel(tr("<a href=\"head\">Show HEAD</a>")); // FIXME: Simplify string in tr() + repositoryLabel = new QLabel(Tr::tr("repository")); + branchLabel = new QLabel(Tr::tr("branch")); // FIXME: Isn't this overwritten soon? + showHeadLabel = new QLabel(Tr::tr("<a href=\"head\">Show HEAD</a>")); // FIXME: Simplify string in tr() authorLineEdit = new QLineEdit; authorLineEdit->setMinimumSize(QSize(200, 0)); @@ -56,25 +54,25 @@ public: invalidEmailLabel = new QLabel; invalidEmailLabel->setMinimumSize(QSize(20, 20)); - bypassHooksCheckBox = new QCheckBox(tr("By&pass hooks")); + bypassHooksCheckBox = new QCheckBox(Tr::tr("By&pass hooks")); - signOffCheckBox = new QCheckBox(tr("Sign off")); + signOffCheckBox = new QCheckBox(Tr::tr("Sign off")); using namespace Layouting; - editGroup = new QGroupBox(tr("Commit Information")); + editGroup = new QGroupBox(Tr::tr("Commit Information")); Grid { - tr("Author:"), authorLineEdit, invalidAuthorLabel, st, br, - tr("Email:"), emailLineEdit, invalidEmailLabel, br, + Tr::tr("Author:"), authorLineEdit, invalidAuthorLabel, st, br, + Tr::tr("Email:"), emailLineEdit, invalidEmailLabel, br, empty, Row { bypassHooksCheckBox, signOffCheckBox, st } }.attachTo(editGroup); Column { Group { - title(tr("General Information")), + title(Tr::tr("General Information")), Form { - tr("Repository:"), repositoryLabel, br, - tr("Branch:"), branchLabel, br, + Tr::tr("Repository:"), repositoryLabel, br, + Tr::tr("Branch:"), branchLabel, br, Span(2, showHeadLabel) } }, @@ -103,7 +101,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() : m_emailValidator = new QRegularExpressionValidator(QRegularExpression("[^@ ]+@[^@ ]+\\.[a-zA-Z]+"), this); const QPixmap error = Utils::Icons::CRITICAL.pixmap(); m_gitSubmitPanel->invalidAuthorLabel->setPixmap(error); - m_gitSubmitPanel->invalidEmailLabel->setToolTip(tr("Provide a valid email to commit.")); + m_gitSubmitPanel->invalidEmailLabel->setToolTip(Tr::tr("Provide a valid email to commit.")); m_gitSubmitPanel->invalidEmailLabel->setPixmap(error); connect(m_gitSubmitPanel->authorLineEdit, &QLineEdit::textChanged, @@ -121,7 +119,7 @@ void GitSubmitEditorWidget::setPanelInfo(const GitSubmitEditorPanelInfo &info) const QString errorColor = Utils::creatorTheme()->color(Utils::Theme::TextColorError).name(); m_gitSubmitPanel->branchLabel->setText(QString::fromLatin1("<span style=\"color:%1\">%2</span>") - .arg(errorColor, tr("Detached HEAD"))); + .arg(errorColor, Tr::tr("Detached HEAD"))); } else { m_gitSubmitPanel->branchLabel->setText(info.branch); } @@ -145,7 +143,7 @@ void GitSubmitEditorWidget::initialize(const FilePath &repository, const CommitD if (data.commitType != AmendCommit) m_gitSubmitPanel->showHeadLabel->hide(); if (data.commitType == FixupCommit) { - auto logChangeGroupBox = new QGroupBox(tr("Select Change")); + auto logChangeGroupBox = new QGroupBox(Tr::tr("Select Change")); auto logChangeLayout = new QVBoxLayout; logChangeGroupBox->setLayout(logChangeLayout); m_logChangeWidget = new LogChangeWidget; @@ -166,11 +164,11 @@ void GitSubmitEditorWidget::initialize(const FilePath &repository, const CommitD if (data.enablePush) { auto menu = new QMenu(this); - connect(menu->addAction(tr("&Commit only")), &QAction::triggered, + connect(menu->addAction(Tr::tr("&Commit only")), &QAction::triggered, this, &GitSubmitEditorWidget::commitOnlySlot); - connect(menu->addAction(tr("Commit and &Push")), &QAction::triggered, + connect(menu->addAction(Tr::tr("Commit and &Push")), &QAction::triggered, this, &GitSubmitEditorWidget::commitAndPushSlot); - connect(menu->addAction(tr("Commit and Push to &Gerrit")), &QAction::triggered, + connect(menu->addAction(Tr::tr("Commit and Push to &Gerrit")), &QAction::triggered, this, &GitSubmitEditorWidget::commitAndPushToGerritSlot); addSubmitButtonMenu(menu); } @@ -212,17 +210,17 @@ bool GitSubmitEditorWidget::canSubmit(QString *whyNot) const { if (m_gitSubmitPanel->invalidAuthorLabel->isVisible()) { if (whyNot) - *whyNot = tr("Invalid author"); + *whyNot = Tr::tr("Invalid author"); return false; } if (m_gitSubmitPanel->invalidEmailLabel->isVisible()) { if (whyNot) - *whyNot = tr("Invalid email"); + *whyNot = Tr::tr("Invalid email"); return false; } if (m_hasUnmerged) { if (whyNot) - *whyNot = tr("Unresolved merge conflicts"); + *whyNot = Tr::tr("Unresolved merge conflicts"); return false; } return SubmitEditorWidget::canSubmit(whyNot); @@ -250,11 +248,11 @@ QString GitSubmitEditorWidget::cleanupDescription(const QString &input) const QString GitSubmitEditorWidget::commitName() const { if (m_pushAction == NormalPush) - return tr("&Commit and Push"); + return Tr::tr("&Commit and Push"); else if (m_pushAction == PushToGerrit) - return tr("&Commit and Push to Gerrit"); + return Tr::tr("&Commit and Push to Gerrit"); - return tr("&Commit"); + return Tr::tr("&Commit"); } void GitSubmitEditorWidget::authorInformationChanged() @@ -295,5 +293,4 @@ bool GitSubmitEditorWidget::emailIsValid() const return m_emailValidator->validate(text, pos) == QValidator::Acceptable; } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitsubmiteditorwidget.h b/src/plugins/git/gitsubmiteditorwidget.h index ba5542c663..a6d27beaf7 100644 --- a/src/plugins/git/gitsubmiteditorwidget.h +++ b/src/plugins/git/gitsubmiteditorwidget.h @@ -3,7 +3,6 @@ #pragma once -#include "gitsettings.h" #include "commitdata.h" #include <texteditor/syntaxhighlighter.h> @@ -16,8 +15,7 @@ QT_BEGIN_NAMESPACE class QValidator; QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { class GitSubmitPanel; class GitSubmitEditorPanelInfo; @@ -75,5 +73,4 @@ private: bool m_isInitialized = false; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitutils.cpp b/src/plugins/git/gitutils.cpp index 5ca8abbd9b..6b9a288a65 100644 --- a/src/plugins/git/gitutils.cpp +++ b/src/plugins/git/gitutils.cpp @@ -6,8 +6,7 @@ #include <QInputDialog> #include <QLineEdit> -namespace Git { -namespace Internal { +namespace Git::Internal { void Stash::clear() { @@ -72,5 +71,4 @@ QString versionString(unsigned ver) .arg(versionPart(ver)); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/gitutils.h b/src/plugins/git/gitutils.h index b24812fad1..c8d0900314 100644 --- a/src/plugins/git/gitutils.h +++ b/src/plugins/git/gitutils.h @@ -9,10 +9,10 @@ QT_BEGIN_NAMESPACE class QWidget; QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { -class Stash { +class Stash +{ public: void clear(); bool parseStashLine(const QString &l); @@ -33,5 +33,4 @@ inline unsigned version(unsigned major, unsigned minor, unsigned patch) QString versionString(unsigned ver); -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp index ac8c9feb45..41c620ab6f 100644 --- a/src/plugins/git/logchangedialog.cpp +++ b/src/plugins/git/logchangedialog.cpp @@ -2,7 +2,9 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "logchangedialog.h" + #include "gitclient.h" +#include "gittr.h" #include <vcsbase/vcscommand.h> #include <vcsbase/vcsoutputwindow.h> @@ -23,8 +25,7 @@ using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { enum Columns { @@ -65,7 +66,7 @@ LogChangeWidget::LogChangeWidget(QWidget *parent) , m_hasCustomDelegate(false) { QStringList headers; - headers << tr("Sha1")<< tr("Subject"); + headers << Tr::tr("Sha1")<< Tr::tr("Subject"); m_model->setHorizontalHeaderLabels(headers); setModel(m_model); setMinimumWidth(300); @@ -214,15 +215,15 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) : , m_dialogButtonBox(new QDialogButtonBox(this)) { auto layout = new QVBoxLayout(this); - layout->addWidget(new QLabel(isReset ? tr("Reset to:") : tr("Select change:"), this)); + layout->addWidget(new QLabel(isReset ? Tr::tr("Reset to:") : Tr::tr("Select change:"), this)); layout->addWidget(m_widget); auto popUpLayout = new QHBoxLayout; if (isReset) { - popUpLayout->addWidget(new QLabel(tr("Reset type:"), this)); + popUpLayout->addWidget(new QLabel(Tr::tr("Reset type:"), this)); m_resetTypeComboBox = new QComboBox(this); - m_resetTypeComboBox->addItem(tr("Hard"), "--hard"); - m_resetTypeComboBox->addItem(tr("Mixed"), "--mixed"); - m_resetTypeComboBox->addItem(tr("Soft"), "--soft"); + m_resetTypeComboBox->addItem(Tr::tr("Hard"), "--hard"); + m_resetTypeComboBox->addItem(Tr::tr("Mixed"), "--mixed"); + m_resetTypeComboBox->addItem(Tr::tr("Soft"), "--soft"); m_resetTypeComboBox->setCurrentIndex(GitClient::settings().lastResetIndex.value()); popUpLayout->addWidget(m_resetTypeComboBox); popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); @@ -306,5 +307,4 @@ void IconItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti QStyledItemDelegate::paint(painter, o, index); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/logchangedialog.h b/src/plugins/git/logchangedialog.h index 09fce4dfa1..483968271f 100644 --- a/src/plugins/git/logchangedialog.h +++ b/src/plugins/git/logchangedialog.h @@ -18,8 +18,7 @@ class QStandardItemModel; class QStandardItem; QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { class LogChangeModel; @@ -65,8 +64,6 @@ private: class LogChangeDialog : public QDialog { - Q_OBJECT - public: LogChangeDialog(bool isReset, QWidget *parent); @@ -109,5 +106,4 @@ private: QIcon m_icon; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp index 19077d4d45..88bed0dd25 100644 --- a/src/plugins/git/mergetool.cpp +++ b/src/plugins/git/mergetool.cpp @@ -2,8 +2,10 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "mergetool.h" + #include "gitclient.h" #include "gitplugin.h" +#include "gittr.h" #include <coreplugin/documentmanager.h> #include <coreplugin/icore.h> @@ -17,8 +19,7 @@ using namespace Utils; using namespace VcsBase; -namespace Git { -namespace Internal { +namespace Git::Internal { MergeTool::MergeTool(QObject *parent) : QObject(parent) { @@ -88,10 +89,10 @@ static MergeTool::MergeType mergeType(const QString &type) QString MergeTool::mergeTypeName() { switch (m_mergeType) { - case NormalMerge: return tr("Normal"); - case SubmoduleMerge: return tr("Submodule"); - case DeletedMerge: return tr("Deleted"); - case SymbolicLinkMerge: return tr("Symbolic link"); + case NormalMerge: return Tr::tr("Normal"); + case SubmoduleMerge: return Tr::tr("Submodule"); + case DeletedMerge: return Tr::tr("Deleted"); + case SymbolicLinkMerge: return Tr::tr("Symbolic link"); } return QString(); } @@ -99,11 +100,11 @@ QString MergeTool::mergeTypeName() QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInfo) { switch (state) { - case ModifiedState: return tr("Modified"); - case CreatedState: return tr("Created"); - case DeletedState: return tr("Deleted"); - case SubmoduleState: return tr("Submodule commit %1").arg(extraInfo); - case SymbolicLinkState: return tr("Symbolic link -> %1").arg(extraInfo); + case ModifiedState: return Tr::tr("Modified"); + case CreatedState: return Tr::tr("Created"); + case DeletedState: return Tr::tr("Deleted"); + case SubmoduleState: return Tr::tr("Submodule commit %1").arg(extraInfo); + case SymbolicLinkState: return Tr::tr("Symbolic link -> %1").arg(extraInfo); default: break; } return QString(); @@ -114,25 +115,25 @@ void MergeTool::chooseAction() if (m_mergeType == NormalMerge) return; QMessageBox msgBox; - msgBox.setWindowTitle(tr("Merge Conflict")); + msgBox.setWindowTitle(Tr::tr("Merge Conflict")); msgBox.setIcon(QMessageBox::Question); msgBox.setStandardButtons(QMessageBox::Abort); - msgBox.setText(tr("%1 merge conflict for \"%2\"\nLocal: %3\nRemote: %4") + msgBox.setText(Tr::tr("%1 merge conflict for \"%2\"\nLocal: %3\nRemote: %4") .arg(mergeTypeName(), m_fileName, stateName(m_localState, m_localInfo), stateName(m_remoteState, m_remoteInfo))); switch (m_mergeType) { case SubmoduleMerge: case SymbolicLinkMerge: - addButton(&msgBox, tr("&Local"), 'l'); - addButton(&msgBox, tr("&Remote"), 'r'); + addButton(&msgBox, Tr::tr("&Local"), 'l'); + addButton(&msgBox, Tr::tr("&Remote"), 'r'); break; case DeletedMerge: if (m_localState == CreatedState || m_remoteState == CreatedState) - addButton(&msgBox, tr("&Created"), 'c'); + addButton(&msgBox, Tr::tr("&Created"), 'c'); else - addButton(&msgBox, tr("&Modified"), 'm'); - addButton(&msgBox, tr("&Deleted"), 'd'); + addButton(&msgBox, Tr::tr("&Modified"), 'm'); + addButton(&msgBox, Tr::tr("&Deleted"), 'd'); break; default: break; @@ -182,15 +183,15 @@ void MergeTool::readData() data = data.mid(index + 1); } if (data.startsWith("Was the merge successful")) { - prompt(tr("Unchanged File"), tr("Was the merge successful?")); + prompt(Tr::tr("Unchanged File"), Tr::tr("Was the merge successful?")); } else if (data.startsWith("Continue merging")) { - prompt(tr("Continue Merging"), tr("Continue merging other unresolved paths?")); + prompt(Tr::tr("Continue Merging"), Tr::tr("Continue merging other unresolved paths?")); } else if (data.startsWith("Hit return")) { QMessageBox::warning( - Core::ICore::dialogParent(), tr("Merge Tool"), + Core::ICore::dialogParent(), Tr::tr("Merge Tool"), QString("<html><body><p>%1</p>\n<p>%2</p></body></html>").arg( - tr("Merge tool is not configured."), - tr("Run git config --global merge.tool <tool> " + Tr::tr("Merge tool is not configured."), + Tr::tr("Run git config --global merge.tool <tool> " "to configure it, then try again."))); m_process.stop(); } else { @@ -234,5 +235,4 @@ void MergeTool::write(const QString &str) VcsOutputWindow::append(str); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/mergetool.h b/src/plugins/git/mergetool.h index 71e1eb646a..76adc00f5d 100644 --- a/src/plugins/git/mergetool.h +++ b/src/plugins/git/mergetool.h @@ -12,13 +12,10 @@ QT_BEGIN_NAMESPACE class QMessageBox; QT_END_NAMESPACE -namespace Git { -namespace Internal { +namespace Git::Internal { class MergeTool : public QObject { - Q_OBJECT - enum FileState { UnknownState, ModifiedState, @@ -62,5 +59,4 @@ private: QString m_unfinishedLine; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/remotedialog.cpp b/src/plugins/git/remotedialog.cpp index b06083a61b..3c3cdb6640 100644 --- a/src/plugins/git/remotedialog.cpp +++ b/src/plugins/git/remotedialog.cpp @@ -5,6 +5,7 @@ #include "gitclient.h" #include "gitplugin.h" +#include "gittr.h" #include "remotemodel.h" #include <utils/fancylineedit.h> @@ -27,8 +28,7 @@ using namespace Utils; -namespace Git { -namespace Internal { +namespace Git::Internal { // -------------------------------------------------------------------------- // RemoteAdditionDialog: @@ -65,7 +65,7 @@ public: if (m_remoteNames.contains(input)) { if (errorMessage) - *errorMessage = RemoteDialog::tr("A remote with the name \"%1\" already exists.").arg(input); + *errorMessage = Tr::tr("A remote with the name \"%1\" already exists.").arg(input); return false; } @@ -81,7 +81,7 @@ public: const GitRemote r(edit->text()); if (!r.isValid && errorMessage) - *errorMessage = RemoteDialog::tr("The URL may not be valid."); + *errorMessage = Tr::tr("The URL may not be valid."); return r.isValid; }); @@ -91,8 +91,8 @@ public: using namespace Layouting; Grid { - tr("Name:"), m_nameEdit, br, - tr("URL:"), m_urlEdit, br, + Tr::tr("Name:"), m_nameEdit, br, + Tr::tr("URL:"), m_urlEdit, br, Span(2, buttonBox) }.attachTo(this); @@ -134,11 +134,11 @@ RemoteDialog::RemoteDialog(QWidget *parent) : { setModal(false); setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily - setWindowTitle(tr("Remotes")); + setWindowTitle(Tr::tr("Remotes")); m_repositoryLabel = new QLabel; - auto refreshButton = new QPushButton(tr("Re&fresh")); + auto refreshButton = new QPushButton(Tr::tr("Re&fresh")); refreshButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); m_remoteView = new QTreeView; @@ -151,14 +151,14 @@ RemoteDialog::RemoteDialog(QWidget *parent) : m_remoteView->setModel(m_remoteModel); new HeaderViewStretcher(m_remoteView->header(), 1); - m_addButton = new QPushButton(tr("&Add...")); + m_addButton = new QPushButton(Tr::tr("&Add...")); m_addButton->setAutoDefault(false); - m_fetchButton = new QPushButton(tr("F&etch")); + m_fetchButton = new QPushButton(Tr::tr("F&etch")); - m_pushButton = new QPushButton(tr("&Push")); + m_pushButton = new QPushButton(Tr::tr("&Push")); - m_removeButton = new QPushButton(tr("&Remove")); + m_removeButton = new QPushButton(Tr::tr("&Remove")); m_removeButton->setAutoDefault(false); auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); @@ -169,7 +169,7 @@ RemoteDialog::RemoteDialog(QWidget *parent) : Row { m_repositoryLabel, refreshButton } }, Group { - title(tr("Remotes")), + title(Tr::tr("Remotes")), Column { m_remoteView, Row { st, m_addButton, m_fetchButton, m_pushButton, m_removeButton } @@ -233,8 +233,8 @@ void RemoteDialog::removeRemote() int row = indexList.at(0).row(); const QString remoteName = m_remoteModel->remoteName(row); - if (QMessageBox::question(this, tr("Delete Remote"), - tr("Would you like to delete the remote \"%1\"?").arg(remoteName), + if (QMessageBox::question(this, Tr::tr("Delete Remote"), + Tr::tr("Would you like to delete the remote \"%1\"?").arg(remoteName), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) { m_remoteModel->removeRemote(row); @@ -274,5 +274,4 @@ void RemoteDialog::updateButtonState() m_removeButton->setEnabled(haveSelection); } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/remotedialog.h b/src/plugins/git/remotedialog.h index 9475405c7b..20365f9b25 100644 --- a/src/plugins/git/remotedialog.h +++ b/src/plugins/git/remotedialog.h @@ -12,15 +12,12 @@ QT_END_NAMESPACE namespace Utils { class FilePath; } -namespace Git { -namespace Internal { +namespace Git::Internal { class RemoteModel; class RemoteDialog : public QDialog { - Q_OBJECT - public: explicit RemoteDialog(QWidget *parent = nullptr); ~RemoteDialog() override; @@ -46,5 +43,4 @@ private: QPushButton *m_removeButton; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/remotemodel.cpp b/src/plugins/git/remotemodel.cpp index 1ba984ec5d..8129c8893f 100644 --- a/src/plugins/git/remotemodel.cpp +++ b/src/plugins/git/remotemodel.cpp @@ -2,16 +2,16 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0 #include "remotemodel.h" + #include "gitclient.h" +#include "gittr.h" #include <utils/algorithm.h> using namespace Utils; -namespace Git { -namespace Internal { +namespace Git::Internal { -// ------ RemoteModel RemoteModel::RemoteModel(QObject *parent) : QAbstractTableModel(parent) { } @@ -120,7 +120,7 @@ QVariant RemoteModel::headerData(int section, Qt::Orientation orientation, int r if (role != Qt::DisplayRole || orientation != Qt::Horizontal) return QVariant(); - return (section == 0) ? tr("Name") : tr("URL"); + return (section == 0) ? Tr::tr("Name") : Tr::tr("URL"); } bool RemoteModel::setData(const QModelIndex &index, const QVariant &value, int role) @@ -190,6 +190,5 @@ int RemoteModel::findRemoteByName(const QString &name) const return -1; } -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/remotemodel.h b/src/plugins/git/remotemodel.h index 35d1d386e9..6142884945 100644 --- a/src/plugins/git/remotemodel.h +++ b/src/plugins/git/remotemodel.h @@ -9,12 +9,12 @@ #include <QList> #include <QVariant> -namespace Git { -namespace Internal { +namespace Git::Internal { class RemoteModel : public QAbstractTableModel { Q_OBJECT + public: explicit RemoteModel(QObject *parent = nullptr); @@ -62,5 +62,4 @@ private: RemoteList m_remotes; }; -} // namespace Internal -} // namespace Git +} // Git::Internal diff --git a/src/plugins/git/stashdialog.cpp b/src/plugins/git/stashdialog.cpp index 835e3f3598..12692b01b0 100644 --- a/src/plugins/git/stashdialog.cpp +++ b/src/plugins/git/stashdialog.cpp @@ -5,6 +5,7 @@ #include "gitclient.h" #include "gitplugin.h" +#include "gittr.h" #include "gitutils.h" #include <utils/algorithm.h> @@ -63,9 +64,7 @@ private: StashModel::StashModel(QObject *parent) : QStandardItemModel(0, ColumnCount, parent) { - QStringList headers; - headers << StashDialog::tr("Name") << StashDialog::tr("Branch") << StashDialog::tr("Message"); - setHorizontalHeaderLabels(headers); + setHorizontalHeaderLabels({Tr::tr("Name"), Tr::tr("Branch"), Tr::tr("Message")}); } void StashModel::setStashes(const QList<Stash> &stashes) @@ -81,16 +80,16 @@ void StashModel::setStashes(const QList<Stash> &stashes) StashDialog::StashDialog(QWidget *parent) : QDialog(parent), m_model(new StashModel), m_proxyModel(new QSortFilterProxyModel), - m_deleteAllButton(new QPushButton(tr("Delete &All..."))), - m_deleteSelectionButton(new QPushButton(tr("&Delete..."))), - m_showCurrentButton(new QPushButton(tr("&Show"))), - m_restoreCurrentButton(new QPushButton(tr("R&estore..."))), + m_deleteAllButton(new QPushButton(Tr::tr("Delete &All..."))), + m_deleteSelectionButton(new QPushButton(Tr::tr("&Delete..."))), + m_showCurrentButton(new QPushButton(Tr::tr("&Show"))), + m_restoreCurrentButton(new QPushButton(Tr::tr("R&estore..."))), //: Restore a git stash to new branch to be created - m_restoreCurrentInBranchButton(new QPushButton(tr("Restore to &Branch..."))), - m_refreshButton(new QPushButton(tr("Re&fresh"))) + m_restoreCurrentInBranchButton(new QPushButton(Tr::tr("Restore to &Branch..."))), + m_refreshButton(new QPushButton(Tr::tr("Re&fresh"))) { setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily - setWindowTitle(tr("Stashes")); + setWindowTitle(Tr::tr("Stashes")); resize(599, 485); @@ -184,8 +183,8 @@ void StashDialog::refresh(const FilePath &repository, bool force) void StashDialog::deleteAll() { - const QString title = tr("Delete Stashes"); - if (!ask(title, tr("Do you want to delete all stashes?"))) + const QString title = Tr::tr("Delete Stashes"); + if (!ask(title, Tr::tr("Do you want to delete all stashes?"))) return; QString errorMessage; if (GitClient::instance()->synchronousStashRemove(m_repository, QString(), &errorMessage)) @@ -198,8 +197,8 @@ void StashDialog::deleteSelection() { const QList<int> rows = selectedRows(); QTC_ASSERT(!rows.isEmpty(), return); - const QString title = tr("Delete Stashes"); - if (!ask(title, tr("Do you want to delete %n stash(es)?", nullptr, rows.size()))) + const QString title = Tr::tr("Delete Stashes"); + if (!ask(title, Tr::tr("Do you want to delete %n stash(es)?", nullptr, rows.size()))) return; QString errorMessage; QStringList errors; @@ -252,12 +251,12 @@ static inline QString nextStash(const QString &stash) StashDialog::ModifiedRepositoryAction StashDialog::promptModifiedRepository(const QString &stash) { QMessageBox box(QMessageBox::Question, - tr("Repository Modified"), - tr("%1 cannot be restored since the repository is modified.\n" + Tr::tr("Repository Modified"), + Tr::tr("%1 cannot be restored since the repository is modified.\n" "You can choose between stashing the changes or discarding them.").arg(stash), QMessageBox::Cancel, this); - QPushButton *stashButton = box.addButton(tr("Stash"), QMessageBox::AcceptRole); - QPushButton *discardButton = box.addButton(tr("Discard"), QMessageBox::AcceptRole); + QPushButton *stashButton = box.addButton(Tr::tr("Stash"), QMessageBox::AcceptRole); + QPushButton *discardButton = box.addButton(Tr::tr("Discard"), QMessageBox::AcceptRole); box.exec(); const QAbstractButton *clickedButton = box.clickedButton(); if (clickedButton == stashButton) @@ -307,19 +306,19 @@ bool StashDialog::promptForRestore(QString *stash, // Prompt for branch or just ask. if (branch) { *branch = stashRestoreDefaultBranch(*stash); - if (!inputText(this, tr("Restore Stash to Branch"), tr("Branch:"), branch) + if (!inputText(this, Tr::tr("Restore Stash to Branch"), Tr::tr("Branch:"), branch) || branch->isEmpty()) return false; } else { - if (!modifiedPromptShown && !ask(tr("Stash Restore"), tr("Would you like to restore %1?").arg(stashIn))) + if (!modifiedPromptShown && !ask(Tr::tr("Stash Restore"), Tr::tr("Would you like to restore %1?").arg(stashIn))) return false; } return true; } -static inline QString msgRestoreFailedTitle(const QString &stash) +static QString msgRestoreFailedTitle(const QString &stash) { - return StashDialog::tr("Error restoring %1").arg(stash); + return Tr::tr("Error restoring %1").arg(stash); } void StashDialog::restoreCurrent() diff --git a/src/plugins/git/stashdialog.h b/src/plugins/git/stashdialog.h index b21249798c..49c2833b1b 100644 --- a/src/plugins/git/stashdialog.h +++ b/src/plugins/git/stashdialog.h @@ -15,8 +15,7 @@ QT_END_NAMESPACE namespace Utils { class TreeView; } -namespace Git { -namespace Internal { +namespace Git::Internal { class StashModel; @@ -27,8 +26,6 @@ class StashModel; class StashDialog : public QDialog { - Q_OBJECT - public: explicit StashDialog(QWidget *parent = nullptr); ~StashDialog() override; @@ -72,5 +69,4 @@ private: Utils::TreeView *m_stashView; }; -} // namespace Internal -} // namespace Git +} // Git::Internal |