Commit f96deb39 authored by Laurent Montel's avatar Laurent Montel

GIT_SILENT: minor qstring optimization

parent 569305e0
......@@ -141,7 +141,7 @@ void Application::populateCommandLineParser(QCommandLineParser *parser)
QStringList Application::getCustomCommand(QStringList &args)
{
int i = args.indexOf(QStringLiteral("-e"));
int i = args.indexOf(QLatin1String("-e"));
QStringList customCommand;
if ((0 < i) && (i < (args.size() - 1))) {
// -e was specified with at least one extra argument
......@@ -310,8 +310,8 @@ bool Application::processTabsFromFileArgs(MainWindow *window)
lineTokens[key] = value;
}
// should contain at least one of 'command' and 'profile'
if (lineTokens.contains(QStringLiteral("command"))
|| lineTokens.contains(QStringLiteral("profile"))) {
if (lineTokens.contains(QLatin1String("command"))
|| lineTokens.contains(QLatin1String("profile"))) {
createTabFromArgs(window, lineTokens);
sessions++;
} else {
......
......@@ -203,7 +203,7 @@ void ColorSchemeEditor::selectWallpaper()
for (const QByteArray &mime : mimeTypes) {
fileFormats += QStringLiteral("*.%1 ").arg(QLatin1String(mime));
}
fileFormats += QLatin1String(")");
fileFormats += QLatin1Char(')');
const QString fileName = QFileDialog::getOpenFileName(this,
i18nc("@title:window",
......
......@@ -221,7 +221,7 @@ const ColorScheme *ColorSchemeManager::findColorScheme(const QString &name)
QString ColorSchemeManager::findColorSchemePath(const QString &name) const
{
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".colorscheme"));
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("konsole/") + name + QLatin1String(".colorscheme"));
if (!path.isEmpty()) {
return path;
......@@ -247,7 +247,7 @@ bool ColorSchemeManager::isColorSchemeDeletable(const QString &name)
bool ColorSchemeManager::canResetColorScheme(const QString &name)
{
const QStringList paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".colorscheme"));
const QStringList paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("konsole/") + name + QLatin1String(".colorscheme"));
// if the colorscheme exists in both a writable location under the
// user's home dir and a system-wide location, then it's possible
......
......@@ -507,7 +507,7 @@ void EditProfileDialog::showEnvironmentEditor()
QString text = QInputDialog::getMultiLineText(this,
i18n("Edit Environment"),
i18n("One environment variable per line"),
currentEnvironment.join(QStringLiteral("\n")),
currentEnvironment.join(QLatin1Char('\n')),
&ok);
QStringList newEnvironment;
......
......@@ -85,7 +85,7 @@ bool KeyboardTranslatorManager::isTranslatorDeletable(const QString &name) const
bool KeyboardTranslatorManager::isTranslatorResettable(const QString &name) const
{
const QStringList &paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".keytab"));
const QStringList &paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("konsole/") + name + QLatin1String(".keytab"));
return (paths.count() > 1);
}
......
......@@ -141,7 +141,7 @@ QSet<QString> ProcessInfo::commonDirNames()
QString ProcessInfo::formatShortDir(const QString &input) const
{
if(input == QStringLiteral("/")) {
if(input == QLatin1String("/")) {
return QStringLiteral("/");
}
......@@ -1151,7 +1151,7 @@ QString SSHProcessInfo::format(const QString &input) const
// Depending on whether -l was passed to ssh (which is mostly not the
// case due to ~/.ssh/config).
if (_user.isEmpty()) {
output.replace(QLatin1String("%U"), QString());
output.remove(QLatin1String("%U"));
} else {
output.replace(QLatin1String("%U"), _user + QLatin1Char('@'));
}
......
......@@ -100,7 +100,7 @@ ProfileManager::ProfileManager()
_defaultProfile = _fallbackProfile;
if (!defaultProfileFileName.isEmpty()) {
// load the default profile
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + defaultProfileFileName);
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("konsole/") + defaultProfileFileName);
if (!path.isEmpty()) {
Profile::Ptr profile = loadProfile(path);
......@@ -146,7 +146,7 @@ Profile::Ptr ProfileManager::loadProfile(const QString& shortPath)
if (fileInfo.suffix() != QLatin1String("profile")) {
path.append(QLatin1String(".profile"));
}
if (fileInfo.path().isEmpty() || fileInfo.path() == QLatin1String(".")) {
if (fileInfo.path().isEmpty() || fileInfo.path() == QLatin1Char('.')) {
path.prepend(QLatin1String("konsole") + QDir::separator());
}
......@@ -379,7 +379,7 @@ void ProfileManager::changeProfile(Profile::Ptr profile,
QString newName;
QString newTranslatedName;
do {
newName = QStringLiteral("Profile ") + QString::number(nameSuffix);
newName = QLatin1String("Profile ") + QString::number(nameSuffix);
newTranslatedName = i18nc("The default name of a profile", "Profile #%1", nameSuffix);
// TODO: remove the # above and below - too many issues
newTranslatedName.remove(QLatin1Char('#'));
......@@ -562,7 +562,7 @@ void ProfileManager::loadShortcuts()
// if the file is not an absolute path, look it up
QFileInfo fileInfo(profilePath);
if (!fileInfo.isAbsolute()) {
profilePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + profilePath);
profilePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("konsole/") + profilePath);
}
data.profilePath = profilePath;
......
......@@ -493,7 +493,7 @@ void Session::run()
int result = _shellProcess->start(exec, arguments, _environment);
if (result < 0) {
terminalWarning(i18n("Could not start program '%1' with arguments '%2'.", exec, arguments.join(QLatin1String(" "))));
terminalWarning(i18n("Could not start program '%1' with arguments '%2'.", exec, arguments.join(QLatin1Char(' '))));
terminalWarning(_shellProcess->errorString());
return;
}
......
......@@ -1546,7 +1546,7 @@ void SessionController::updateSessionIcon()
{
// If the default profile icon is being used, don't put it on the tab
// Only show the icon if the user specifically chose one
if (_session->iconName() == QStringLiteral("utilities-terminal")) {
if (_session->iconName() == QLatin1String("utilities-terminal")) {
_sessionIconName = QString();
} else {
_sessionIconName = _session->iconName();
......
......@@ -98,7 +98,7 @@ TabbedViewContainer::TabbedViewContainer(ViewManager *connectedViewManager, QWid
connect(_contextPopupMenu, &QMenu::aboutToHide, this, [this]() {
// Remove the read-only action when the popup closes
for (auto &action : _contextPopupMenu->actions()) {
if (action->objectName() == QStringLiteral("view-readonly")) {
if (action->objectName() == QLatin1String("view-readonly")) {
_contextPopupMenu->removeAction(action);
break;
}
......@@ -470,7 +470,7 @@ void TabbedViewContainer::openTabContextMenu(const QPoint &point)
//TODO: add a countChanged signal so we can remove this for.
// Detaching in mac causes crashes.
for(auto action : _contextPopupMenu->actions()) {
if (action->objectName() == QStringLiteral("tab-detach")) {
if (action->objectName() == QLatin1String("tab-detach")) {
action->setEnabled(count() > 1);
}
}
......@@ -493,7 +493,7 @@ void TabbedViewContainer::openTabContextMenu(const QPoint &point)
// Disable tab rename
for (auto &action : _contextPopupMenu->actions()) {
if (action->objectName() == QStringLiteral("edit-rename")) {
if (action->objectName() == QLatin1String("edit-rename")) {
action->setEnabled(!sessionController->isReadOnly());
break;
}
......
......@@ -903,7 +903,7 @@ namespace {
ViewSplitter *restoreSessionsSplitterRecurse(const QJsonObject& jsonSplitter, ViewManager *manager)
{
auto splitterWidgets = jsonSplitter[QStringLiteral("Widgets")].toArray();
auto orientation = (jsonSplitter[QStringLiteral("Orientation")].toString() == QStringLiteral("Horizontal"))
auto orientation = (jsonSplitter[QStringLiteral("Orientation")].toString() == QLatin1String("Horizontal"))
? Qt::Horizontal : Qt::Vertical;
auto *currentSplitter = new ViewSplitter();
......
......@@ -51,7 +51,7 @@ void PartTest::initTestCase()
auto buildPath = libraryPaths.last();
QCoreApplication::removeLibraryPath(buildPath);
// konsolepart.so is in ../autotests/
if (buildPath.endsWith(QStringLiteral("/autotests"))) {
if (buildPath.endsWith(QLatin1String("/autotests"))) {
buildPath.chop(10);
}
QCoreApplication::addLibraryPath(buildPath);
......
......@@ -54,7 +54,7 @@ void ShellCommandTest::testConstructorWithTwoArguments()
ShellCommand shellCommand(command, arguments);
QCOMPARE(shellCommand.command(), command);
QCOMPARE(shellCommand.arguments(), arguments);
QCOMPARE(shellCommand.fullCommand(), arguments.join(QLatin1String(" ")));
QCOMPARE(shellCommand.fullCommand(), arguments.join(QLatin1Char(' ')));
}
void ShellCommandTest::testExpandEnvironmentVariable()
......
......@@ -57,7 +57,7 @@ void TerminalInterfaceTest::initTestCase()
auto buildPath = libraryPaths.last();
QCoreApplication::removeLibraryPath(buildPath);
// konsolepart.so is in ../autotests/
if (buildPath.endsWith(QStringLiteral("/autotests"))) {
if (buildPath.endsWith(QLatin1String("/autotests"))) {
buildPath.chop(10);
}
QCoreApplication::addLibraryPath(buildPath);
......
......@@ -279,13 +279,13 @@ bool shouldUseNewProcess(int argc, char *argv[])
// if users have explictly requested starting a new process
// Support --nofork to retain argument compatibility with older
// versions.
if (arguments.contains(QStringLiteral("--separate"))
|| arguments.contains(QStringLiteral("--nofork"))) {
if (arguments.contains(QLatin1String("--separate"))
|| arguments.contains(QLatin1String("--nofork"))) {
return true;
}
// the only way to create new tab is to reuse existing Konsole process.
if (arguments.contains(QStringLiteral("--new-tab"))) {
if (arguments.contains(QLatin1String("--new-tab"))) {
return false;
}
......
......@@ -124,7 +124,7 @@ static inline void warn(const Template::Element &element, const QString &msg) {
void Template::executeCommand(Element &element, const Template::Element &childStub, const QStringList &argv) {
// Insert content N times
if(argv[0] == QStringLiteral("repeat")) {
if(argv[0] == QLatin1String("repeat")) {
bool ok;
unsigned count = argv.value(1).toInt(&ok);
if(!ok || count < 1) {
......@@ -148,7 +148,7 @@ void Template::executeCommand(Element &element, const Template::Element &childSt
}
// Set printf-like format (with leading %) applied for strings and numbers
// inside the group
} else if(argv[0] == QStringLiteral("fmt")) {
} else if(argv[0] == QLatin1String("fmt")) {
static const QRegularExpression FMT_RE(QStringLiteral(R":(^%[-0 +#]?(?:[1-9][0-9]*)?\.?[0-9]*[diouxXs]$):"),
QRegularExpression::OptimizeOnFirstUsageOption);
const auto match = FMT_RE.match(argv.value(1));
......
......@@ -119,7 +119,7 @@ protected:
continue;
}
if(!match.captured(QStringLiteral("udRangeInd")).isNull()) {
if(match.captured(QStringLiteral("udRangeInd")) == QStringLiteral("First")) {
if(match.captured(QStringLiteral("udRangeInd")) == QLatin1String("First")) {
// Fetch next valid line, as it pairs with the current one to form a range
QRegularExpressionMatch nlMatch;
int firstLineNo = _lineNo;
......@@ -914,20 +914,20 @@ int main(int argc, char *argv[]) {
{EmojiOpt, EmojiProperty::EmojiPresentation},
};
if(emojiStr == QStringLiteral("presentation"))
if(emojiStr == QLatin1String("presentation"))
convertOpts[EmojiOpt] = EmojiProperty::EmojiPresentation;
else if(emojiStr == QStringLiteral("all"))
else if(emojiStr == QLatin1String("all"))
convertOpts[EmojiOpt] = EmojiProperty::Emoji;
else {
convertOpts[EmojiOpt] = EmojiProperty::EmojiPresentation;
qWarning() << QStringLiteral("invalid emoji option value: %1. Assuming \"presentation\".").arg(emojiStr);
}
if(ambiguousWidthStr == QStringLiteral("separate"))
if(ambiguousWidthStr == QLatin1String("separate"))
convertOpts[AmbiguousWidthOpt] = CharacterWidth::Ambiguous;
else if(ambiguousWidthStr == QStringLiteral("1"))
else if(ambiguousWidthStr == QLatin1Char('1'))
convertOpts[AmbiguousWidthOpt] = 1;
else if(ambiguousWidthStr == QStringLiteral("2"))
else if(ambiguousWidthStr == QLatin1Char('2'))
convertOpts[AmbiguousWidthOpt] = 2;
else {
convertOpts[AmbiguousWidthOpt] = CharacterWidth::Ambiguous;
......@@ -940,7 +940,7 @@ int main(int argc, char *argv[]) {
if(!GENERATOR_FUNCS_MAP.contains(generatorName)) {
int status = 0;
if(generatorName != QStringLiteral("-")) {
if(generatorName != QLatin1String("-")) {
status = 1;
eout << QStringLiteral("Invalid output generator. Available generators:") << endl;
}
......
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