Beautifier: Move a few strings closer to their use

Change-Id: I11c49976eca820b7083d143dbce6603085f9aa9d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-07 08:19:22 +02:00
parent dcca810fdc
commit afe8b19996
8 changed files with 17 additions and 67 deletions

View File

@@ -4,18 +4,15 @@ add_qtc_plugin(Beautifier
SOURCES
abstractsettings.cpp abstractsettings.h
artisticstyle/artisticstyle.cpp artisticstyle/artisticstyle.h
artisticstyle/artisticstyleconstants.h
beautifier.qrc
beautifierabstracttool.h
beautifierconstants.h
beautifierplugin.cpp beautifierplugin.h
beautifiertr.h
clangformat/clangformat.cpp clangformat/clangformat.h
clangformat/clangformatconstants.h
configurationdialog.cpp configurationdialog.h
configurationeditor.cpp configurationeditor.h
configurationpanel.cpp configurationpanel.h
generalsettings.cpp generalsettings.h
uncrustify/uncrustify.cpp uncrustify/uncrustify.h
uncrustify/uncrustifyconstants.h
)

View File

@@ -5,7 +5,6 @@
#include "artisticstyle.h"
#include "artisticstyleconstants.h"
#include "../abstractsettings.h"
#include "../beautifierconstants.h"
#include "../beautifierplugin.h"
@@ -52,6 +51,8 @@ namespace Beautifier::Internal {
// Settings
static QString displayName() { return Tr::tr("Artistic Style"); }
const char SETTINGS_NAME[] = "artisticstyle";
class ArtisticStyleSettings : public AbstractSettings
@@ -63,8 +64,7 @@ public:
setVersionRegExp(QRegularExpression("([2-9]{1})\\.([0-9]{1,2})(\\.[1-9]{1})?$"));
command.setLabelText(Tr::tr("Artistic Style command:"));
command.setDefaultValue("astyle");
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
Tr::tr(Constants::ARTISTICSTYLE_DISPLAY_NAME)));
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(displayName()));
useOtherFiles.setSettingsKey("useOtherFiles");
useOtherFiles.setLabelText(Tr::tr("Use file *.astylerc defined in project files"));
@@ -239,7 +239,7 @@ public:
ArtisticStyleOptionsPage()
{
setId("ArtisticStyle");
setDisplayName(Tr::tr("Artistic Style"));
setDisplayName(displayName());
setCategory(Constants::OPTION_CATEGORY);
setWidgetCreator([] { return new ArtisticStyleOptionsPageWidget; });
}
@@ -267,7 +267,7 @@ ArtisticStyle::ArtisticStyle()
QString ArtisticStyle::id() const
{
return QLatin1String(Constants::ARTISTICSTYLE_DISPLAY_NAME);
return "Artistic Style";
}
void ArtisticStyle::updateActions(Core::IEditor *editor)
@@ -278,12 +278,10 @@ void ArtisticStyle::updateActions(Core::IEditor *editor)
void ArtisticStyle::formatFile()
{
const QString cfgFileName = configurationFile();
if (cfgFileName.isEmpty()) {
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
Tr::tr(Constants::ARTISTICSTYLE_DISPLAY_NAME)));
} else {
if (cfgFileName.isEmpty())
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(displayName()));
else
formatCurrentFile(command(cfgFileName));
}
}
QString ArtisticStyle::configurationFile() const

View File

@@ -1,12 +0,0 @@
// Copyright (C) 2016 Lorenz Haas
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QtGlobal>
namespace Beautifier::Constants {
const char ARTISTICSTYLE_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("QtC::Beautifier", "Artistic Style");
} // Beautifier::Constants

View File

@@ -35,7 +35,6 @@ QtcPlugin {
files: [
"artisticstyle.cpp",
"artisticstyle.h",
"artisticstyleconstants.h",
]
}
@@ -45,7 +44,6 @@ QtcPlugin {
files: [
"clangformat.cpp",
"clangformat.h",
"clangformatconstants.h",
]
}
@@ -55,7 +53,6 @@ QtcPlugin {
files: [
"uncrustify.cpp",
"uncrustify.h",
"uncrustifyconstants.h",
]
}
}

View File

@@ -5,8 +5,6 @@
#include "clangformat.h"
#include "clangformatconstants.h"
#include "../abstractsettings.h"
#include "../beautifierconstants.h"
#include "../beautifierplugin.h"
@@ -367,7 +365,7 @@ ClangFormat::ClangFormat()
QString ClangFormat::id() const
{
return QLatin1String(Constants::CLANGFORMAT_DISPLAY_NAME);
return "ClangFormat";
}
void ClangFormat::updateActions(Core::IEditor *editor)

View File

@@ -1,12 +0,0 @@
// Copyright (C) 2016 Lorenz Haas
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QtGlobal>
namespace Beautifier::Constants {
const char CLANGFORMAT_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("QtC::Beautifier", "ClangFormat");
} // Beautifier::Constants

View File

@@ -5,8 +5,6 @@
#include "uncrustify.h"
#include "uncrustifyconstants.h"
#include "../abstractsettings.h"
#include "../beautifierconstants.h"
#include "../beautifierplugin.h"
@@ -54,6 +52,8 @@ namespace Beautifier::Internal {
const char SETTINGS_NAME[] = "uncrustify";
static QString displayName() { return Tr::tr("Uncrustify"); }
class UncrustifySettings : public AbstractSettings
{
public:
@@ -64,8 +64,7 @@ public:
command.setDefaultValue("uncrustify");
command.setLabelText(Tr::tr("Uncrustify command:"));
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(
Tr::tr(Constants::UNCRUSTIFY_DISPLAY_NAME)));
command.setPromptDialogTitle(BeautifierPlugin::msgCommandPromptDialogTitle(displayName()));
useOtherFiles.setSettingsKey("useOtherFiles");
useOtherFiles.setDefaultValue(true);
@@ -270,7 +269,7 @@ Uncrustify::Uncrustify()
QString Uncrustify::id() const
{
return QLatin1String(Constants::UNCRUSTIFY_DISPLAY_NAME);
return "Uncrustify";
}
void Uncrustify::updateActions(Core::IEditor *editor)
@@ -283,20 +282,17 @@ void Uncrustify::updateActions(Core::IEditor *editor)
void Uncrustify::formatFile()
{
const FilePath cfgFileName = configurationFile();
if (cfgFileName.isEmpty()) {
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
Tr::tr(Constants::UNCRUSTIFY_DISPLAY_NAME)));
} else {
if (cfgFileName.isEmpty())
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(displayName()));
else
formatCurrentFile(command(cfgFileName));
}
}
void Uncrustify::formatSelectedText()
{
const FilePath cfgFileName = configurationFile();
if (cfgFileName.isEmpty()) {
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(
Tr::tr(Constants::UNCRUSTIFY_DISPLAY_NAME)));
BeautifierPlugin::showError(BeautifierPlugin::msgCannotGetConfigurationFile(displayName()));
return;
}

View File

@@ -1,12 +0,0 @@
// Copyright (C) 2016 Lorenz Haas
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <QtGlobal>
namespace Beautifier::Constants {
const char UNCRUSTIFY_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("QtC::Beautifier", "Uncrustify");
} // Beautifier::Constants