From 2c2469f99145c203e98d4bc78b2df33e8e72b1c3 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 22 Aug 2021 15:15:16 +0200 Subject: [PATCH] Fix clazy warning: Use QString() multi-arg No need to use arg(QString::number(int )), when arg() already has a int overload. Also replace "endl" with "Qt::endl". GIT_SILENT --- src/debug_console.cpp | 2 +- src/decorations/decorationbridge.cpp | 2 +- src/geometrytip.cpp | 8 ++++---- .../kwindecoration/kwin-applywindowdecoration.cpp | 8 +++++--- .../platforms/x11/windowed/x11windowed_backend.cpp | 6 +++--- src/scripting/genericscriptedconfig.cpp | 4 ++-- src/sm.cpp | 2 +- src/tabbox/tabboxhandler.cpp | 9 +++++---- src/useractions.cpp | 3 +-- src/workspace.cpp | 11 +++++------ 10 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/debug_console.cpp b/src/debug_console.cpp index 5fc3c93e14..76d5f2b076 100644 --- a/src/debug_console.cpp +++ b/src/debug_console.cpp @@ -137,7 +137,7 @@ static QString deviceRow(LibInput::Device *device) if (!device) { return tableRow(i18n("Input Device"), i18nc("The input device of the event is not known", "Unknown")); } - return tableRow(i18n("Input Device"), QStringLiteral("%1 (%2)").arg(device->name()).arg(device->sysName())); + return tableRow(i18n("Input Device"), QStringLiteral("%1 (%2)").arg(device->name(), device->sysName())); } static QString buttonsToString(Qt::MouseButtons buttons) diff --git a/src/decorations/decorationbridge.cpp b/src/decorations/decorationbridge.cpp index 3e54528f6c..7eecdc106d 100644 --- a/src/decorations/decorationbridge.cpp +++ b/src/decorations/decorationbridge.cpp @@ -310,7 +310,7 @@ QString DecorationBridge::supportInformation() const if (QLatin1String(property.name()) == QLatin1String("objectName")) { continue; } - b.append(QStringLiteral("%1: %2\n").arg(property.name()).arg(settingsProperty(m_settings->property(property.name())))); + b.append(QStringLiteral("%1: %2\n").arg(property.name(), settingsProperty(m_settings->property(property.name())))); } } return b; diff --git a/src/geometrytip.cpp b/src/geometrytip.cpp index 9545ea62fe..af4eb24dea 100644 --- a/src/geometrytip.cpp +++ b/src/geometrytip.cpp @@ -50,10 +50,10 @@ void GeometryTip::setGeometry(const QRect& geom) h = qMax(h, 0); // in case of isShade() and PBaseSize const QString pos = QStringLiteral("%1,%2
(%3 x %4)") - .arg(numberWithSign(geom.x())) - .arg(numberWithSign(geom.y())) - .arg(w) - .arg(h); + .arg(numberWithSign(geom.x()), // + numberWithSign(geom.y()), + QString::number(w), + QString::number(h)); setText(pos); adjustSize(); move(geom.x() + ((geom.width() - width()) / 2), diff --git a/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp b/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp index 987eace05c..f6c79a5e14 100644 --- a/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp +++ b/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp @@ -62,7 +62,9 @@ int main(int argc, char **argv) if (!path.isEmpty() && path == QStringLiteral("%1/metadata.desktop").arg(requestedTheme)) { requestedTheme = QString("__aurorae__svg__").append(splitTheme.last()); themeResolved = true; - ts << i18n("Resolved %1 to the KWin Aurorae theme \"%2\", and will attempt to set that as your current theme.").arg(parser->positionalArguments().first()).arg(requestedTheme) << endl; + ts << i18n("Resolved %1 to the KWin Aurorae theme \"%2\", and will attempt to set that as your current theme.") + .arg(parser->positionalArguments().first(), requestedTheme) + << Qt::endl; } } } else { @@ -111,9 +113,9 @@ int main(int argc, char **argv) const QString displayName = model->data(model->index(i), Qt::DisplayRole).toString(); const QString themeName = model->data(model->index(i), KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString(); if (settings->theme() == themeName) { - ts << QStringLiteral(" * %1 (theme name: %2 - current theme for this Plasma session)").arg(displayName).arg(themeName) << endl; + ts << QStringLiteral(" * %1 (theme name: %2 - current theme for this Plasma session)").arg(displayName, themeName) << Qt::endl; } else { - ts << QStringLiteral(" * %1 (theme name: %2)").arg(displayName).arg(themeName) << endl; + ts << QStringLiteral(" * %1 (theme name: %2)").arg(displayName, themeName) << Qt::endl; } } } else { diff --git a/src/plugins/platforms/x11/windowed/x11windowed_backend.cpp b/src/plugins/platforms/x11/windowed/x11windowed_backend.cpp index ff897290f4..f71ab54a4b 100644 --- a/src/plugins/platforms/x11/windowed/x11windowed_backend.cpp +++ b/src/plugins/platforms/x11/windowed/x11windowed_backend.cpp @@ -357,9 +357,9 @@ void X11WindowedBackend::grabKeyboard(xcb_timestamp_t time) void X11WindowedBackend::updateWindowTitle() { const QString grab = m_keyboardGrabbed ? i18n("Press right control to ungrab input") : i18n("Press right control key to grab input"); - const QString title = QStringLiteral("%1 (%2) - %3").arg(i18n("KDE Wayland Compositor")) - .arg(waylandServer()->socketName()) - .arg(grab); + const QString title = QStringLiteral("%1 (%2) - %3").arg(i18n("KDE Wayland Compositor"), + waylandServer()->socketName(), + grab); for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { (*it)->setWindowTitle(title); } diff --git a/src/scripting/genericscriptedconfig.cpp b/src/scripting/genericscriptedconfig.cpp index 9474c21cb6..2fdc480d6e 100644 --- a/src/scripting/genericscriptedconfig.cpp +++ b/src/scripting/genericscriptedconfig.cpp @@ -78,8 +78,8 @@ void GenericScriptedConfig::createUi() loader->setLanguageChangeEnabled(true); QFile uiFile(uiPath); // try getting a translation domain - const QString metaDataPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral(KWIN_NAME"/%1/%2/metadata.desktop").arg(typeName()).arg(m_packageName)); + const QString metaDataPath = + QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME "/%1/%2/metadata.desktop").arg(typeName(), m_packageName)); if (!metaDataPath.isNull()) { KDesktopFile metaData(metaDataPath); m_translator->setTranslationDomain(metaData.desktopGroup().readEntry("X-KWin-Config-TranslationDomain", QString())); diff --git a/src/sm.cpp b/src/sm.cpp index a42f26817a..ce9eeac7de 100644 --- a/src/sm.cpp +++ b/src/sm.cpp @@ -40,7 +40,7 @@ static KConfig *sessionConfig(QString id, QString key) lastId = id; lastKey = key; if (!config) { - config = new KConfig(pattern.arg(id).arg(key), KConfig::SimpleConfig); + config = new KConfig(pattern.arg(id, key), KConfig::SimpleConfig); } return config; } diff --git a/src/tabbox/tabboxhandler.cpp b/src/tabbox/tabboxhandler.cpp index 6082446887..af05f0b5b8 100644 --- a/src/tabbox/tabboxhandler.cpp +++ b/src/tabbox/tabboxhandler.cpp @@ -216,10 +216,11 @@ void TabBoxHandlerPrivate::endHighlightWindows(bool abort) QObject *TabBoxHandlerPrivate::createSwitcherItem(bool desktopMode) { // first try look'n'feel package - QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("plasma/look-and-feel/%1/contents/%2") - .arg(config.layoutName()) - .arg(desktopMode ? QStringLiteral("desktopswitcher/DesktopSwitcher.qml") : QStringLiteral("windowswitcher/WindowSwitcher.qml"))); + QString file = QStandardPaths::locate( + QStandardPaths::GenericDataLocation, + QStringLiteral("plasma/look-and-feel/%1/contents/%2") + .arg(config.layoutName(), + desktopMode ? QStringLiteral("desktopswitcher/DesktopSwitcher.qml") : QStringLiteral("windowswitcher/WindowSwitcher.qml"))); if (file.isNull()) { const QString folderName = QLatin1String(KWIN_NAME) + (desktopMode ? QLatin1String("/desktoptabbox/") : QLatin1String("/tabbox/")); auto findSwitcher = [this, desktopMode, folderName] { diff --git a/src/useractions.cpp b/src/useractions.cpp index ed4cc25f24..d012e16534 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -159,8 +159,7 @@ void UserActionsMenu::helperDialog(const QString& message, AbstractClient* clien QAction* action = Workspace::self()->findChild(name); Q_ASSERT(action != nullptr); const auto shortcuts = KGlobalAccel::self()->shortcut(action); - return QStringLiteral("%1 (%2)").arg(action->text()) - .arg(shortcuts.isEmpty() ? QString() : shortcuts.first().toString(QKeySequence::NativeText)); + return QStringLiteral("%1 (%2)").arg(action->text(), shortcuts.isEmpty() ? QString() : shortcuts.first().toString(QKeySequence::NativeText)); }; if (message == QStringLiteral("noborderaltf3")) { args << QStringLiteral("--msgbox") << i18n( diff --git a/src/workspace.cpp b/src/workspace.cpp index 67ee32912a..18c7c5bbad 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -1539,9 +1539,8 @@ QString Workspace::supportInformation() const support.append(QStringLiteral("Protocol Version/Revision: %1/%2\n").arg(x11setup->protocol_major_version).arg(x11setup->protocol_minor_version)); const auto extensions = Xcb::Extensions::self()->extensions(); for (const auto &e : extensions) { - support.append(QStringLiteral("%1: %2; Version: 0x%3\n").arg(QString::fromUtf8(e.name)) - .arg(e.present ? yes.trimmed() : no.trimmed()) - .arg(QString::number(e.version, 16))); + support.append(QStringLiteral("%1: %2; Version: 0x%3\n") + .arg(QString::fromUtf8(e.name), e.present ? yes.trimmed() : no.trimmed(), QString::number(e.version, 16))); } support.append(QStringLiteral("\n")); } @@ -1570,7 +1569,7 @@ QString Workspace::supportInformation() const auto printProperty = [] (const QVariant &variant) { if (variant.type() == QVariant::Size) { const QSize &s = variant.toSize(); - return QStringLiteral("%1x%2").arg(QString::number(s.width())).arg(QString::number(s.height())); + return QStringLiteral("%1x%2").arg(s.width()).arg(s.height()); } if (QLatin1String(variant.typeName()) == QLatin1String("KWin::OpenGLPlatformInterface") || QLatin1String(variant.typeName()) == QLatin1String("KWin::Options::WindowOperation")) { @@ -1583,7 +1582,7 @@ QString Workspace::supportInformation() const if (QLatin1String(property.name()) == QLatin1String("objectName")) { continue; } - support.append(QStringLiteral("%1: %2\n").arg(property.name()).arg(printProperty(options->property(property.name())))); + support.append(QStringLiteral("%1: %2\n").arg(property.name(), printProperty(options->property(property.name())))); } support.append(QStringLiteral("\nScreen Edges\n")); support.append(QStringLiteral( "============\n")); @@ -1593,7 +1592,7 @@ QString Workspace::supportInformation() const if (QLatin1String(property.name()) == QLatin1String("objectName")) { continue; } - support.append(QStringLiteral("%1: %2\n").arg(property.name()).arg(printProperty(ScreenEdges::self()->property(property.name())))); + support.append(QStringLiteral("%1: %2\n").arg(property.name(), printProperty(ScreenEdges::self()->property(property.name())))); } support.append(QStringLiteral("\nScreens\n")); support.append(QStringLiteral( "=======\n"));