forked from qt-creator/qt-creator
Reduce message duplication in Beautifier plugin.
Change-Id: I5216dd2e62e32ed889a71ebcad3f89baf0e0ff1b Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -71,7 +71,7 @@ bool ArtisticStyle::initialize()
|
|||||||
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ArtisticStyle::MENU_ID);
|
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ArtisticStyle::MENU_ID);
|
||||||
menu->menu()->setTitle(QLatin1String("Artistic Style"));
|
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::Command *cmd
|
||||||
= Core::ActionManager::registerAction(m_formatFile,
|
= Core::ActionManager::registerAction(m_formatFile,
|
||||||
Constants::ArtisticStyle::ACTION_FORMATFILE,
|
Constants::ArtisticStyle::ACTION_FORMATFILE,
|
||||||
@@ -131,7 +131,8 @@ void ArtisticStyle::formatFile()
|
|||||||
cfgFileName = m_settings->styleFileName(m_settings->customStyle());
|
cfgFileName = m_settings->styleFileName(m_settings->customStyle());
|
||||||
|
|
||||||
if (cfgFileName.isEmpty()) {
|
if (cfgFileName.isEmpty()) {
|
||||||
BeautifierPlugin::showError(tr("Cannot get configuration file for Artistic Style."));
|
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
|
||||||
|
QLatin1String("Artistic Style")));
|
||||||
} else {
|
} else {
|
||||||
BeautifierPlugin::formatCurrentFile(QStringList()
|
BeautifierPlugin::formatCurrentFile(QStringList()
|
||||||
<< m_settings->command()
|
<< m_settings->command()
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "artisticstylesettings.h"
|
#include "artisticstylesettings.h"
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
#include "../beautifierconstants.h"
|
||||||
|
#include "../beautifierplugin.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -51,7 +52,8 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
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)));
|
connect(ui->command, SIGNAL(validChanged(bool)), ui->options, SLOT(setEnabled(bool)));
|
||||||
ui->configurations->setSettings(m_settings);
|
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()));
|
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 Internal
|
||||||
} // namespace Beautifier
|
} // namespace Beautifier
|
||||||
|
|
||||||
|
@@ -56,6 +56,11 @@ public:
|
|||||||
static void formatCurrentFile(QStringList command);
|
static void formatCurrentFile(QStringList command);
|
||||||
static void showError(const QString &error);
|
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:
|
private slots:
|
||||||
void updateActions(Core::IEditor *editor = 0);
|
void updateActions(Core::IEditor *editor = 0);
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ bool ClangFormat::initialize()
|
|||||||
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID);
|
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::ClangFormat::MENU_ID);
|
||||||
menu->menu()->setTitle(QLatin1String("ClangFormat"));
|
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::Command *cmd
|
||||||
= Core::ActionManager::registerAction(m_formatFile,
|
= Core::ActionManager::registerAction(m_formatFile,
|
||||||
Constants::ClangFormat::ACTION_FORMATFILE,
|
Constants::ClangFormat::ACTION_FORMATFILE,
|
||||||
@@ -77,7 +77,7 @@ bool ClangFormat::initialize()
|
|||||||
menu->addAction(cmd);
|
menu->addAction(cmd);
|
||||||
connect(m_formatFile, SIGNAL(triggered()), this, SLOT(formatFile()));
|
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,
|
cmd = Core::ActionManager::registerAction(m_formatRange,
|
||||||
Constants::ClangFormat::ACTION_FORMATSELECTED,
|
Constants::ClangFormat::ACTION_FORMATSELECTED,
|
||||||
Core::Context(Core::Constants::C_GLOBAL));
|
Core::Context(Core::Constants::C_GLOBAL));
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "clangformatsettings.h"
|
#include "clangformatsettings.h"
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
#include "../beautifierconstants.h"
|
||||||
|
#include "../beautifierplugin.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -53,7 +54,8 @@ ClangFormatOptionsPageWidget::ClangFormatOptionsPageWidget(ClangFormatSettings *
|
|||||||
ui->options->setEnabled(false);
|
ui->options->setEnabled(false);
|
||||||
ui->predefinedStyle->addItems(m_settings->predefinedStyles());
|
ui->predefinedStyle->addItems(m_settings->predefinedStyles());
|
||||||
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
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)));
|
connect(ui->command, SIGNAL(validChanged(bool)), ui->options, SLOT(setEnabled(bool)));
|
||||||
ui->configurations->setSettings(m_settings);
|
ui->configurations->setSettings(m_settings);
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@ bool Uncrustify::initialize()
|
|||||||
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::Uncrustify::MENU_ID);
|
Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::Uncrustify::MENU_ID);
|
||||||
menu->menu()->setTitle(QLatin1String("Uncrustify"));
|
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::Command *cmd
|
||||||
= Core::ActionManager::registerAction(m_formatFile,
|
= Core::ActionManager::registerAction(m_formatFile,
|
||||||
Constants::Uncrustify::ACTION_FORMATFILE,
|
Constants::Uncrustify::ACTION_FORMATFILE,
|
||||||
@@ -126,7 +126,8 @@ void Uncrustify::formatFile()
|
|||||||
cfgFileName = m_settings->styleFileName(m_settings->customStyle());
|
cfgFileName = m_settings->styleFileName(m_settings->customStyle());
|
||||||
|
|
||||||
if (cfgFileName.isEmpty()) {
|
if (cfgFileName.isEmpty()) {
|
||||||
BeautifierPlugin::showError(tr("Cannot get configuration file for uncrustify."));
|
BeautifierPlugin::showError(
|
||||||
|
BeautifierPlugin::msgCannotGetConfigurationFile(QLatin1String("uncrustify")));
|
||||||
} else {
|
} else {
|
||||||
BeautifierPlugin::formatCurrentFile(QStringList()
|
BeautifierPlugin::formatCurrentFile(QStringList()
|
||||||
<< m_settings->command()
|
<< m_settings->command()
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include "uncrustifysettings.h"
|
#include "uncrustifysettings.h"
|
||||||
|
|
||||||
#include "../beautifierconstants.h"
|
#include "../beautifierconstants.h"
|
||||||
|
#include "../beautifierplugin.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -51,7 +52,8 @@ UncrustifyOptionsPageWidget::UncrustifyOptionsPageWidget(UncrustifySettings *set
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->command->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
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)));
|
connect(ui->command, SIGNAL(validChanged(bool)), ui->options, SLOT(setEnabled(bool)));
|
||||||
ui->configurations->setSettings(m_settings);
|
ui->configurations->setSettings(m_settings);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user