ToDo: Convert to Tr::tr

Change-Id: I2bd081fd484f851234c7e54114a15488271e0df1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2022-07-12 12:52:55 +02:00
parent 3651c385b7
commit ab90298fde
19 changed files with 101 additions and 306 deletions

View File

@@ -49,14 +49,9 @@ enum OutputColumnIndex {
OUTPUT_COLUMN_COUNT
};
const char OUTPUT_COLUMN_TEXT_TITLE[] = QT_TRANSLATE_NOOP("Todo::Internal::TodoItemsModel", "Description");
const char OUTPUT_COLUMN_FILE_TITLE[] = QT_TRANSLATE_NOOP("Todo::Internal::TodoItemsModel", "File");
const char OUTPUT_COLUMN_LINE_TITLE[] = QT_TRANSLATE_NOOP("Todo::Internal::TodoItemsModel", "Line");
const int OUTPUT_TOOLBAR_SPACER_WIDTH = 25;
const int OUTPUT_PANE_UPDATE_INTERVAL = 2000;
const char OUTPUT_PANE_TITLE[] = QT_TRANSLATE_NOOP("Todo::Internal::TodoOutputPane", "To-Do Entries");
const char FILTER_KEYWORD_NAME[] = "filterKeywordName";

View File

@@ -28,6 +28,7 @@
#include "keyword.h"
#include "lineparser.h"
#include "todotr.h"
#include <utils/layoutbuilder.h>
#include <utils/qtcolorbutton.h>
@@ -46,7 +47,7 @@ KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alread
QDialog(parent),
m_alreadyUsedKeywordNames(alreadyUsedKeywordNames)
{
setWindowTitle(tr("Keyword"));
setWindowTitle(Tr::tr("Keyword"));
m_listWidget = new QListWidget(this);
@@ -60,7 +61,7 @@ KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alread
m_keywordNameEdit = new QLineEdit(keyword.name);
m_errorLabel = new QLabel(tr("errorLabel"), this);
m_errorLabel = new QLabel(Tr::tr("errorLabel"), this);
m_errorLabel->setStyleSheet(QString::fromUtf8("color: red;"));
m_errorLabel->hide();
@@ -71,15 +72,15 @@ KeywordDialog::KeywordDialog(const Keyword &keyword, const QSet<QString> &alread
using namespace Utils::Layouting;
Column {
new QLabel(tr("Icon")),
new QLabel(Tr::tr("Icon")),
m_listWidget,
Row {
Group {
Title(tr("Color")),
Title(Tr::tr("Color")),
Row { m_colorEdit, m_colorButton }
},
Group {
Title(tr("Keyword")),
Title(Tr::tr("Keyword")),
m_keywordNameEdit
}
},
@@ -162,12 +163,12 @@ void KeywordDialog::setupColorWidgets(const QColor &color)
bool KeywordDialog::canAccept()
{
if (!isKeywordNameCorrect()) {
showError(tr("Keyword cannot be empty, contain spaces, colons, slashes or asterisks."));
showError(Tr::tr("Keyword cannot be empty, contain spaces, colons, slashes or asterisks."));
return false;
}
if (isKeywordNameAlreadyUsed()) {
showError(tr("There is already a keyword with this name."));
showError(Tr::tr("There is already a keyword with this name."));
return false;
}

View File

@@ -29,10 +29,10 @@
#include "keyworddialog.h"
#include "keyword.h"
#include "settings.h"
#include "todotr.h"
#include <utils/layoutbuilder.h>
#include <QCoreApplication>
#include <QGroupBox>
#include <QListWidget>
#include <QPushButton>
@@ -42,8 +42,6 @@ namespace Todo::Internal {
class OptionsDialog final : public Core::IOptionsPageWidget
{
Q_DECLARE_TR_FUNCTIONS(Todo::Internal::TodoOptionsPage)
public:
OptionsDialog(Settings *settings, const std::function<void ()> &onApply);
@@ -83,24 +81,24 @@ OptionsDialog::OptionsDialog(Settings *settings, const std::function<void ()> &o
m_keywordsList->setSelectionBehavior(QAbstractItemView::SelectRows);
m_keywordsList->setSortingEnabled(false);
auto addKeywordButton = new QPushButton(tr("Add"));
m_editKeywordButton = new QPushButton(tr("Edit"));
m_removeKeywordButton = new QPushButton(tr("Remove"));
resetKeywordsButton = new QPushButton(tr("Reset"));
auto addKeywordButton = new QPushButton(Tr::tr("Add"));
m_editKeywordButton = new QPushButton(Tr::tr("Edit"));
m_removeKeywordButton = new QPushButton(Tr::tr("Remove"));
resetKeywordsButton = new QPushButton(Tr::tr("Reset"));
m_scanInProjectRadioButton = new QRadioButton(tr("Scan the whole active project"));
m_scanInProjectRadioButton = new QRadioButton(Tr::tr("Scan the whole active project"));
m_scanInProjectRadioButton->setEnabled(true);
m_scanInCurrentFileRadioButton = new QRadioButton(tr("Scan only the currently edited document"));
m_scanInCurrentFileRadioButton = new QRadioButton(Tr::tr("Scan only the currently edited document"));
m_scanInCurrentFileRadioButton->setChecked(true);
m_scanInSubprojectRadioButton = new QRadioButton(tr("Scan the current subproject"));
m_scanInSubprojectRadioButton = new QRadioButton(Tr::tr("Scan the current subproject"));
using namespace Utils::Layouting;
Column {
Group {
Title(tr("Keywords")),
Title(Tr::tr("Keywords")),
Row {
m_keywordsList,
Column {
@@ -113,7 +111,7 @@ OptionsDialog::OptionsDialog(Settings *settings, const std::function<void ()> &o
}
},
Group {
Title(tr("Scanning scope")),
Title(Tr::tr("Scanning scope")),
Column {
m_scanInProjectRadioButton,
m_scanInCurrentFileRadioButton,
@@ -270,9 +268,9 @@ void OptionsDialog::apply()
TodoOptionsPage::TodoOptionsPage(Settings *settings, const std::function<void ()> &onApply)
{
setId("TodoSettings");
setDisplayName(OptionsDialog::tr("To-Do"));
setDisplayName(Tr::tr("To-Do"));
setCategory("To-Do");
setDisplayCategory(OptionsDialog::tr("To-Do"));
setDisplayCategory(Tr::tr("To-Do"));
setCategoryIconPath(":/todoplugin/images/settingscategory_todo.png");
setWidgetCreator([settings, onApply] { return new OptionsDialog(settings, onApply); });
}

View File

@@ -25,10 +25,11 @@
****************************************************************************/
#include "todoitemsmodel.h"
#include "constants.h"
#include "todotr.h"
#include <utils/algorithm.h>
#include <utils/theme/theme.h>
#include <QIcon>
@@ -116,14 +117,11 @@ QVariant TodoItemsModel::headerData(int section, Qt::Orientation orientation, in
switch (section) {
case Constants::OUTPUT_COLUMN_TEXT:
return tr(Constants::OUTPUT_COLUMN_TEXT_TITLE);
return Tr::tr("Description");
case Constants::OUTPUT_COLUMN_FILE:
return tr(Constants::OUTPUT_COLUMN_FILE_TITLE);
return Tr::tr("File");
case Constants::OUTPUT_COLUMN_LINE:
return tr(Constants::OUTPUT_COLUMN_LINE_TITLE);
return Tr::tr("Line");
default:
return QVariant();
}

View File

@@ -25,9 +25,11 @@
****************************************************************************/
#include "todooutputpane.h"
#include "constants.h"
#include "todoitemsmodel.h"
#include "todooutputtreeview.h"
#include "todotr.h"
#include <aggregation/aggregate.h>
#include <coreplugin/find/itemviewfind.h>
@@ -81,7 +83,7 @@ QList<QWidget*> TodoOutputPane::toolBarWidgets() const
QString TodoOutputPane::displayName() const
{
return tr(Constants::OUTPUT_PANE_TITLE);
return Tr::tr("To-Do Entries");
}
int TodoOutputPane::priorityInStatusBar() const
@@ -249,18 +251,18 @@ void TodoOutputPane::createScopeButtons()
{
m_currentFileButton = new QToolButton();
m_currentFileButton->setCheckable(true);
m_currentFileButton->setText(tr("Current Document"));
m_currentFileButton->setToolTip(tr("Scan only the currently edited document."));
m_currentFileButton->setText(Tr::tr("Current Document"));
m_currentFileButton->setToolTip(Tr::tr("Scan only the currently edited document."));
m_wholeProjectButton = new QToolButton();
m_wholeProjectButton->setCheckable(true);
m_wholeProjectButton->setText(tr("Active Project"));
m_wholeProjectButton->setToolTip(tr("Scan the whole active project."));
m_wholeProjectButton->setText(Tr::tr("Active Project"));
m_wholeProjectButton->setToolTip(Tr::tr("Scan the whole active project."));
m_subProjectButton = new QToolButton();
m_subProjectButton->setCheckable(true);
m_subProjectButton->setText(tr("Subproject"));
m_subProjectButton->setToolTip(tr("Scan the current subproject."));
m_subProjectButton->setText(Tr::tr("Subproject"));
m_subProjectButton->setToolTip(Tr::tr("Scan the current subproject."));
m_scopeButtons = new QButtonGroup();
m_scopeButtons->addButton(m_wholeProjectButton);
@@ -272,7 +274,7 @@ void TodoOutputPane::createScopeButtons()
m_spacer = new QWidget;
m_spacer->setMinimumWidth(Constants::OUTPUT_TOOLBAR_SPACER_WIDTH);
QString tooltip = tr("Show \"%1\" entries");
QString tooltip = Tr::tr("Show \"%1\" entries");
for (const Keyword &keyword: m_settings->keywords) {
QToolButton *button = createCheckableToolButton(keyword.name, tooltip.arg(keyword.name), toolBarIcon(keyword.iconType));
button->setProperty(Constants::FILTER_KEYWORD_NAME, keyword.name);

View File

@@ -25,12 +25,12 @@
****************************************************************************/
#include "todoplugin.h"
#include "constants.h"
#include "optionsdialog.h"
#include "keyword.h"
#include "todooutputpane.h"
#include "todoitemsprovider.h"
#include "todoprojectsettingswidget.h"
#include "todotr.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -39,7 +39,6 @@
#include <projectexplorer/projectpanelfactory.h>
#include <utils/link.h>
#include <QFileInfo>
#include <QSettings>
namespace Todo {
@@ -47,8 +46,6 @@ namespace Internal {
class TodoPluginPrivate : public QObject
{
Q_DECLARE_TR_FUNCTIONS(Todo::Internal::TodoPlugin)
public:
TodoPluginPrivate();
@@ -73,7 +70,7 @@ TodoPluginPrivate::TodoPluginPrivate()
auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
panelFactory->setPriority(100);
panelFactory->setDisplayName(TodoProjectSettingsWidget::tr("To-Do"));
panelFactory->setDisplayName(Tr::tr("To-Do"));
panelFactory->setCreateWidgetFunction([this](ProjectExplorer::Project *project) {
auto widget = new TodoProjectSettingsWidget(project);
connect(widget, &TodoProjectSettingsWidget::projectSettingsChanged,

View File

@@ -26,6 +26,7 @@
#include "todoprojectsettingswidget.h"
#include "constants.h"
#include "todotr.h"
#include <projectexplorer/project.h>
@@ -39,7 +40,7 @@ namespace Internal {
static QString excludePlaceholder()
{
return Todo::Internal::TodoProjectSettingsWidget::tr("<Enter regular expression to exclude>");
return Tr::tr("<Enter regular expression to exclude>");
}
TodoProjectSettingsWidget::TodoProjectSettingsWidget(ProjectExplorer::Project *project)
@@ -47,17 +48,17 @@ TodoProjectSettingsWidget::TodoProjectSettingsWidget(ProjectExplorer::Project *p
{
m_excludedPatternsList = new QListWidget;
m_excludedPatternsList->setSortingEnabled(true);
m_excludedPatternsList->setToolTip(tr("Regular expressions for file paths to be excluded from scanning."));
m_excludedPatternsList->setToolTip(Tr::tr("Regular expressions for file paths to be excluded from scanning."));
m_removeExcludedPatternButton = new QPushButton(tr("Remove"));
m_removeExcludedPatternButton = new QPushButton(Tr::tr("Remove"));
auto addExcludedPatternButton = new QPushButton(tr("Add"));
auto addExcludedPatternButton = new QPushButton(Tr::tr("Add"));
using namespace Utils::Layouting;
Column {
Group {
Title(tr("Excluded Files")),
Title(Tr::tr("Excluded Files")),
Row {
m_excludedPatternsList,
Column {

View File

@@ -27,8 +27,6 @@
#include <projectexplorer/projectsettingswidget.h>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QListWidget;
class QListWidgetItem;