Commit a6711015 authored by Friedemann Kleint's avatar Friedemann Kleint

Reduce message duplication in Beautifier plugin.

Change-Id: I5216dd2e62e32ed889a71ebcad3f89baf0e0ff1b
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent c7e37947
......@@ -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()
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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));
......
......@@ -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);
}
......
......@@ -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()
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment