diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-03-05 14:02:01 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-03-05 14:54:42 +0100 |
commit | a6711015c1254acb9debb0d9183b18b3ead61f05 (patch) | |
tree | b94d698470016ac49636b13094f68627ab5fe59e /src/plugins/beautifier | |
parent | c7e379475995ef70b90b37df7946d699ce8733ac (diff) | |
download | qt-creator-a6711015c1254acb9debb0d9183b18b3ead61f05.tar.gz |
Reduce message duplication in Beautifier plugin.
Change-Id: I5216dd2e62e32ed889a71ebcad3f89baf0e0ff1b
Reviewed-by: David Schulz <david.schulz@digia.com>
Diffstat (limited to 'src/plugins/beautifier')
8 files changed, 45 insertions, 9 deletions
diff --git a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp index 69ad3a4aec..30a39d0d7f 100644 --- a/src/plugins/beautifier/artisticstyle/artisticstyle.cpp +++ b/src/plugins/beautifier/artisticstyle/artisticstyle.cpp @@ -71,7 +71,7 @@ bool ArtisticStyle::initialize() Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ArtisticStyle::MENU_ID); menu->menu()->setTitle(QLatin1String("Artistic Style")); - m_formatFile = new QAction(tr("Format Current File"), this); + m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); Core::Command *cmd = Core::ActionManager::registerAction(m_formatFile, Constants::ArtisticStyle::ACTION_FORMATFILE, @@ -131,7 +131,8 @@ void ArtisticStyle::formatFile() cfgFileName = m_settings->styleFileName(m_settings->customStyle()); if (cfgFileName.isEmpty()) { - BeautifierPlugin::showError(tr("Cannot get configuration file for Artistic Style.")); + BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile( + QLatin1String("Artistic Style"))); } else { BeautifierPlugin::formatCurrentFile(QStringList() << m_settings->command() diff --git a/src/plugins/beautifier/artisticstyle/artisticstyleoptionspage.cpp b/src/plugins/beautifier/artisticstyle/artisticstyleoptionspage.cpp index 457a9e4b8a..2f0c82f240 100644 --- a/src/plugins/beautifier/artisticstyle/artisticstyleoptionspage.cpp +++ b/src/plugins/beautifier/artisticstyle/artisticstyleoptionspage.cpp @@ -34,6 +34,7 @@ #include "artisticstylesettings.h" #include "../beautifierconstants.h" +#include "../beautifierplugin.h" #include <coreplugin/icore.h> @@ -51,7 +52,8 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett { ui->setupUi(this); ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand); - ui->command->setPromptDialogTitle(tr("Artistic Style Command")); + ui->command->setPromptDialogTitle( + BeautifierPlugin::msgCommandPromptDialogTitle(QLatin1String("Artistic Style"))); connect(ui->command, SIGNAL(validChanged(bool)), ui->options, SLOT(setEnabled(bool))); ui->configurations->setSettings(m_settings); } diff --git a/src/plugins/beautifier/beautifierplugin.cpp b/src/plugins/beautifier/beautifierplugin.cpp index 023b950bd5..c3c8bcd34a 100644 --- a/src/plugins/beautifier/beautifierplugin.cpp +++ b/src/plugins/beautifier/beautifierplugin.cpp @@ -291,6 +291,29 @@ void BeautifierPlugin::showError(const QString &error) Core::MessageManager::write(tr("ERROR in Beautifier: %1").arg(error.trimmed())); } +QString BeautifierPlugin::msgCannotGetConfigurationFile(const QString &command) +{ + return tr("Cannot get configuration file for %1.").arg(command); +} + +QString BeautifierPlugin::msgFormatCurrentFile() +{ + //: Menu entry + return tr("Format Current File"); +} + +QString BeautifierPlugin::msgFormatSelectedText() +{ + //: Menu entry + return tr("Format Selected Text"); +} + +QString BeautifierPlugin::msgCommandPromptDialogTitle(const QString &command) +{ + //: File dialog title for path chooser when choosing binary + return tr("%1 Command").arg(command); +} + } // namespace Internal } // namespace Beautifier diff --git a/src/plugins/beautifier/beautifierplugin.h b/src/plugins/beautifier/beautifierplugin.h index 2e4910e042..e1b0da5e27 100644 --- a/src/plugins/beautifier/beautifierplugin.h +++ b/src/plugins/beautifier/beautifierplugin.h @@ -56,6 +56,11 @@ public: static void formatCurrentFile(QStringList command); static void showError(const QString &error); + static QString msgCannotGetConfigurationFile(const QString &command); + static QString msgFormatCurrentFile(); + static QString msgFormatSelectedText(); + static QString msgCommandPromptDialogTitle(const QString &command); + private slots: void updateActions(Core::IEditor *editor = 0); diff --git a/src/plugins/beautifier/clangformat/clangformat.cpp b/src/plugins/beautifier/clangformat/clangformat.cpp index 5c6f929cbb..8de29e5ab8 100644 --- a/src/plugins/beautifier/clangformat/clangformat.cpp +++ b/src/plugins/beautifier/clangformat/clangformat.cpp @@ -69,7 +69,7 @@ bool ClangFormat::initialize() Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID); menu->menu()->setTitle(QLatin1String("ClangFormat")); - m_formatFile = new QAction(tr("Format Current File"), this); + m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); Core::Command *cmd = Core::ActionManager::registerAction(m_formatFile, Constants::ClangFormat::ACTION_FORMATFILE, @@ -77,7 +77,7 @@ bool ClangFormat::initialize() menu->addAction(cmd); connect(m_formatFile, SIGNAL(triggered()), this, SLOT(formatFile())); - m_formatRange = new QAction(tr("Format Selected Text"), this); + m_formatRange = new QAction(BeautifierPlugin::msgFormatSelectedText(), this); cmd = Core::ActionManager::registerAction(m_formatRange, Constants::ClangFormat::ACTION_FORMATSELECTED, Core::Context(Core::Constants::C_GLOBAL)); diff --git a/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp b/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp index 5ef69a62f4..6dbc167435 100644 --- a/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp +++ b/src/plugins/beautifier/clangformat/clangformatoptionspage.cpp @@ -34,6 +34,7 @@ #include "clangformatsettings.h" #include "../beautifierconstants.h" +#include "../beautifierplugin.h" #include <coreplugin/icore.h> @@ -53,7 +54,8 @@ ClangFormatOptionsPageWidget::ClangFormatOptionsPageWidget(ClangFormatSettings * ui->options->setEnabled(false); ui->predefinedStyle->addItems(m_settings->predefinedStyles()); ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand); - ui->command->setPromptDialogTitle(tr("Clang Format Command")); + ui->command->setPromptDialogTitle( + BeautifierPlugin::msgCommandPromptDialogTitle(QLatin1String("Clang Format"))); connect(ui->command, SIGNAL(validChanged(bool)), ui->options, SLOT(setEnabled(bool))); ui->configurations->setSettings(m_settings); } diff --git a/src/plugins/beautifier/uncrustify/uncrustify.cpp b/src/plugins/beautifier/uncrustify/uncrustify.cpp index dfcaf3fa44..f069257174 100644 --- a/src/plugins/beautifier/uncrustify/uncrustify.cpp +++ b/src/plugins/beautifier/uncrustify/uncrustify.cpp @@ -71,7 +71,7 @@ bool Uncrustify::initialize() Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::Uncrustify::MENU_ID); menu->menu()->setTitle(QLatin1String("Uncrustify")); - m_formatFile = new QAction(tr("Format Current File"), this); + m_formatFile = new QAction(BeautifierPlugin::msgFormatCurrentFile(), this); Core::Command *cmd = Core::ActionManager::registerAction(m_formatFile, Constants::Uncrustify::ACTION_FORMATFILE, @@ -126,7 +126,8 @@ void Uncrustify::formatFile() cfgFileName = m_settings->styleFileName(m_settings->customStyle()); if (cfgFileName.isEmpty()) { - BeautifierPlugin::showError(tr("Cannot get configuration file for uncrustify.")); + BeautifierPlugin::showError( + BeautifierPlugin::msgCannotGetConfigurationFile(QLatin1String("uncrustify"))); } else { BeautifierPlugin::formatCurrentFile(QStringList() << m_settings->command() diff --git a/src/plugins/beautifier/uncrustify/uncrustifyoptionspage.cpp b/src/plugins/beautifier/uncrustify/uncrustifyoptionspage.cpp index 77e2590298..9c04e16448 100644 --- a/src/plugins/beautifier/uncrustify/uncrustifyoptionspage.cpp +++ b/src/plugins/beautifier/uncrustify/uncrustifyoptionspage.cpp @@ -34,6 +34,7 @@ #include "uncrustifysettings.h" #include "../beautifierconstants.h" +#include "../beautifierplugin.h" #include <coreplugin/icore.h> @@ -51,7 +52,8 @@ UncrustifyOptionsPageWidget::UncrustifyOptionsPageWidget(UncrustifySettings *set { ui->setupUi(this); ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand); - ui->command->setPromptDialogTitle(tr("Uncrustify Command")); + ui->command->setPromptDialogTitle( + BeautifierPlugin::msgCommandPromptDialogTitle(QLatin1String("Uncrustify"))); connect(ui->command, SIGNAL(validChanged(bool)), ui->options, SLOT(setEnabled(bool))); ui->configurations->setSettings(m_settings); } |