From fae151b2454e360e2268f4301631d698d34c8a84 Mon Sep 17 00:00:00 2001 From: Mikel Johnson Date: Sat, 7 Nov 2020 13:12:55 +0300 Subject: [PATCH] Use QStringLiteral and QLatin1String where it makes sense --- applets/kicker/plugin/contactentry.cpp | 2 +- applets/kicker/plugin/rootmodel.cpp | 14 ++++---- kcms/kfontinst/kcmfontinst/KCmFontInst.cpp | 6 ++-- kcms/krdb/krdb.cpp | 4 +-- kcms/lookandfeel/autotests/kcmtest.cpp | 32 +++++++++---------- libtaskmanager/autotests/tasktoolstest.cpp | 8 ++--- libtaskmanager/tasktools.cpp | 2 +- .../bookmarks/tests/testchromebookmarks.cpp | 2 +- shell/scripting/scriptengine.cpp | 2 +- .../autotests/testfindpreferredimage.cpp | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/applets/kicker/plugin/contactentry.cpp b/applets/kicker/plugin/contactentry.cpp index 1694ba193..59642ccdb 100644 --- a/applets/kicker/plugin/contactentry.cpp +++ b/applets/kicker/plugin/contactentry.cpp @@ -114,7 +114,7 @@ QVariantList ContactEntry::actions() const { QVariantList actionList; - actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QString("identity"), QStringLiteral("showContactInfo")); + actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QStringLiteral("identity"), QStringLiteral("showContactInfo")); return actionList; } diff --git a/applets/kicker/plugin/rootmodel.cpp b/applets/kicker/plugin/rootmodel.cpp index ee36fbdf9..03143ab83 100644 --- a/applets/kicker/plugin/rootmodel.cpp +++ b/applets/kicker/plugin/rootmodel.cpp @@ -411,7 +411,7 @@ void RootModel::refresh() int separatorPosition = 0; if (allModel) { - m_entryList.prepend(new GroupEntry(this, i18n("All Applications"), QString("applications-all"), allModel)); + m_entryList.prepend(new GroupEntry(this, i18n("All Applications"), QStringLiteral("applications-all"), allModel)); ++separatorPosition; } @@ -432,7 +432,7 @@ void RootModel::refresh() if (m_showRecentContacts) { m_recentContactsModel = new RecentContactsModel(this); - m_entryList.prepend(new GroupEntry(this, i18n("Recent Contacts"), QString("view-history"), m_recentContactsModel)); + m_entryList.prepend(new GroupEntry(this, i18n("Recent Contacts"), QStringLiteral("view-history"), m_recentContactsModel)); ++separatorPosition; } @@ -443,8 +443,8 @@ void RootModel::refresh() ? i18n("Recent Files") : i18n("Often Used Files"), m_recentOrdering == RecentUsageModel::Recent - ? QString("view-history") - : QString("office-chart-pie"), + ? QStringLiteral("view-history") + : QStringLiteral("office-chart-pie"), m_recentDocsModel)); ++separatorPosition; } @@ -456,8 +456,8 @@ void RootModel::refresh() ? i18n("Recent Applications") : i18n("Often Used Applications"), m_recentOrdering == RecentUsageModel::Recent - ? QString("view-history") - : QString("office-chart-pie"), + ? QStringLiteral("view-history") + : QStringLiteral("office-chart-pie"), m_recentAppsModel)); ++separatorPosition; } @@ -470,7 +470,7 @@ void RootModel::refresh() m_systemModel = new SystemModel(this); if (m_showPowerSession) { - m_entryList << new GroupEntry(this, i18n("Power / Session"), QString("system-log-out"), m_systemModel); + m_entryList << new GroupEntry(this, i18n("Power / Session"), QStringLiteral("system-log-out"), m_systemModel); } endResetModel(); diff --git a/kcms/kfontinst/kcmfontinst/KCmFontInst.cpp b/kcms/kfontinst/kcmfontinst/KCmFontInst.cpp index 51a7a9a32..1740e76eb 100644 --- a/kcms/kfontinst/kcmfontinst/KCmFontInst.cpp +++ b/kcms/kfontinst/kcmfontinst/KCmFontInst.cpp @@ -964,10 +964,10 @@ void CKCmFontInst::setStatusBar() if(disabled||partial) { - text+=QString(" (%2").arg(KIconLoader::global()->iconPath("dialog-ok", -KIconLoader::SizeSmall)).arg(enabled) - +QString(" %2").arg(KIconLoader::global()->iconPath("dialog-cancel", -KIconLoader::SizeSmall)).arg(disabled); + text+=QLatin1String(" (%2").arg(KIconLoader::global()->iconPath("dialog-ok", -KIconLoader::SizeSmall)).arg(enabled) + +QLatin1String(" %2").arg(KIconLoader::global()->iconPath("dialog-cancel", -KIconLoader::SizeSmall)).arg(disabled); if(partial) - text+=QString(" %2").arg(partialIcon()).arg(partial); + text+=QLatin1String(" %2").arg(partialIcon()).arg(partial); text+=QLatin1Char(')'); itsStatusLabel->setToolTip(partial ? i18n("" diff --git a/kcms/krdb/krdb.cpp b/kcms/krdb/krdb.cpp index 369a654b8..046670e36 100644 --- a/kcms/krdb/krdb.cpp +++ b/kcms/krdb/krdb.cpp @@ -416,8 +416,8 @@ void runRdb( uint flags ) // Export the Xcursor theme & size settings KConfigGroup mousecfg(KSharedConfig::openConfig( QStringLiteral("kcminputrc") ), "Mouse" ); - QString theme = mousecfg.readEntry("cursorTheme", QString("breeze_cursors")); - QString size = mousecfg.readEntry("cursorSize", QString("24")); + QString theme = mousecfg.readEntry("cursorTheme", QStringLiteral("breeze_cursors")); + QString size = mousecfg.readEntry("cursorSize", QStringLiteral("24")); QString contents; if (!theme.isNull()) diff --git a/kcms/lookandfeel/autotests/kcmtest.cpp b/kcms/lookandfeel/autotests/kcmtest.cpp index 13e8be235..42caaff77 100644 --- a/kcms/lookandfeel/autotests/kcmtest.cpp +++ b/kcms/lookandfeel/autotests/kcmtest.cpp @@ -100,7 +100,7 @@ void KcmTest::testWidgetStyle() KConfigGroup cg(&config, "KDE"); // We have to use an actual theme name here because setWidgetStyle checks // if the theme can actually be used before it changes the config - QCOMPARE(cg.readEntry("widgetStyle", QString()), QString("Fusion")); + QCOMPARE(cg.readEntry("widgetStyle", QString()), QStringLiteral("Fusion")); } void KcmTest::testColors() @@ -110,7 +110,7 @@ void KcmTest::testColors() KConfig config(QStringLiteral("kdeglobals")); KConfigGroup cg(&config, "General"); - QCOMPARE(cg.readEntry("ColorScheme", QString()), QString("customTestValue")); + QCOMPARE(cg.readEntry("ColorScheme", QString()), QStringLiteral("customTestValue")); } void KcmTest::testIcons() @@ -119,7 +119,7 @@ void KcmTest::testIcons() KConfig config(QStringLiteral("kdeglobals")); KConfigGroup cg(&config, "Icons"); - QCOMPARE(cg.readEntry("Theme", QString()), QString("customTestValue")); + QCOMPARE(cg.readEntry("Theme", QString()), QStringLiteral("customTestValue")); } void KcmTest::testPlasmaTheme() @@ -128,7 +128,7 @@ void KcmTest::testPlasmaTheme() KConfig config(QStringLiteral("plasmarc")); KConfigGroup cg(&config, "Theme"); - QCOMPARE(cg.readEntry("name", QString()), QString("customTestValue")); + QCOMPARE(cg.readEntry("name", QString()), QStringLiteral("customTestValue")); } void KcmTest::testCursorTheme() @@ -137,7 +137,7 @@ void KcmTest::testCursorTheme() KConfig config(QStringLiteral("kcminputrc")); KConfigGroup cg(&config, "Mouse"); - QCOMPARE(cg.readEntry("cursorTheme", QString()), QString("customTestValue")); + QCOMPARE(cg.readEntry("cursorTheme", QString()), QStringLiteral("customTestValue")); } void KcmTest::testSplashScreen() @@ -146,8 +146,8 @@ void KcmTest::testSplashScreen() KConfig config(QStringLiteral("ksplashrc")); KConfigGroup cg(&config, "KSplash"); - QCOMPARE(cg.readEntry("Theme", QString()), QString("customTestValue")); - QCOMPARE(cg.readEntry("Engine", QString()), QString("KSplashQML")); + QCOMPARE(cg.readEntry("Theme", QString()), QStringLiteral("customTestValue")); + QCOMPARE(cg.readEntry("Engine", QString()), QStringLiteral("KSplashQML")); } void KcmTest::testLockScreen() @@ -156,7 +156,7 @@ void KcmTest::testLockScreen() KConfig config(QStringLiteral("kscreenlockerrc")); KConfigGroup cg(&config, "Greeter"); - QCOMPARE(cg.readEntry("Theme", QString()), QString("customTestValue")); + QCOMPARE(cg.readEntry("Theme", QString()), QStringLiteral("customTestValue")); } void KcmTest::testWindowSwitcher() @@ -185,31 +185,31 @@ void KcmTest::testKCMSave() KConfig config(QStringLiteral("kdeglobals")); KConfigGroup cg(&config, "KDE"); // See comment in testWidgetStyle - QCOMPARE(cg.readEntry("widgetStyle", QString()), QString("Fusion")); + QCOMPARE(cg.readEntry("widgetStyle", QString()), QStringLiteral("Fusion")); cg = KConfigGroup(&config, "General"); //save() capitalizes the ColorScheme - QCOMPARE(cg.readEntry("ColorScheme", QString()), QString("TestValue")); + QCOMPARE(cg.readEntry("ColorScheme", QString()), QStringLiteral("TestValue")); cg = KConfigGroup(&config, "Icons"); - QCOMPARE(cg.readEntry("Theme", QString()), QString("testValue")); + QCOMPARE(cg.readEntry("Theme", QString()), QStringLiteral("testValue")); KConfig plasmaConfig(QStringLiteral("plasmarc")); cg = KConfigGroup(&plasmaConfig, "Theme"); - QCOMPARE(cg.readEntry("name", QString()), QString("testValue")); + QCOMPARE(cg.readEntry("name", QString()), QStringLiteral("testValue")); KConfig inputConfig(QStringLiteral("kcminputrc")); cg = KConfigGroup(&inputConfig, "Mouse"); - QCOMPARE(cg.readEntry("cursorTheme", QString()), QString("testValue")); + QCOMPARE(cg.readEntry("cursorTheme", QString()), QStringLiteral("testValue")); KConfig splashConfig(QStringLiteral("ksplashrc")); cg = KConfigGroup(&splashConfig, "KSplash"); - QCOMPARE(cg.readEntry("Theme", QString()), QString("customTestValue")); - QCOMPARE(cg.readEntry("Engine", QString()), QString("KSplashQML")); + QCOMPARE(cg.readEntry("Theme", QString()), QStringLiteral("customTestValue")); + QCOMPARE(cg.readEntry("Engine", QString()), QStringLiteral("KSplashQML")); KConfig lockerConfig(QStringLiteral("kscreenlockerrc")); cg = KConfigGroup(&lockerConfig, "Greeter"); - QCOMPARE(cg.readEntry("Theme", QString()), QString("org.kde.test")); + QCOMPARE(cg.readEntry("Theme", QString()), QStringLiteral("org.kde.test")); KConfig kwinConfig(QStringLiteral("kwinrc")); cg = KConfigGroup(&kwinConfig, "TabBox"); diff --git a/libtaskmanager/autotests/tasktoolstest.cpp b/libtaskmanager/autotests/tasktoolstest.cpp index 30f1719fb..727bfb5c1 100644 --- a/libtaskmanager/autotests/tasktoolstest.cpp +++ b/libtaskmanager/autotests/tasktoolstest.cpp @@ -159,11 +159,11 @@ void TaskToolsTest::createAppLink() { KDesktopFile file(appLinkPath()); KConfigGroup group = file.desktopGroup(); - group.writeEntry(QLatin1String("Type"), QString("Application")); + group.writeEntry(QLatin1String("Type"), QStringLiteral("Application")); group.writeEntry(QLatin1String("Name"), m_referenceAppData.name); group.writeEntry(QLatin1String("GenericName"), m_referenceAppData.genericName); - group.writeEntry(QLatin1String("Icon"), QString("konversation")); - group.writeEntry(QLatin1String("Exec"), QString("konversation")); + group.writeEntry(QLatin1String("Icon"), QStringLiteral("konversation")); + group.writeEntry(QLatin1String("Exec"), QStringLiteral("konversation")); file.sync(); QVERIFY(file.hasApplicationType()); @@ -192,7 +192,7 @@ void TaskToolsTest::createIcon() KConfig config(themeFile); KConfigGroup group(config.group(QLatin1String("Icon Theme"))); group.writeEntry(QLatin1String("Name"), KIconTheme::defaultThemeName()); - group.writeEntry(QLatin1String("Inherits"), QString("hicolor")); + group.writeEntry(QLatin1String("Inherits"), QStringLiteral("hicolor")); config.sync(); QVERIFY(QFile::exists(themeFile)); diff --git a/libtaskmanager/tasktools.cpp b/libtaskmanager/tasktools.cpp index 72ab9dcc6..dfe04b1f5 100644 --- a/libtaskmanager/tasktools.cpp +++ b/libtaskmanager/tasktools.cpp @@ -700,7 +700,7 @@ QString defaultApplication(const QUrl &url) } } - return QString(""); + return QLatin1String(""); } bool launcherUrlsMatch(const QUrl &a, const QUrl &b, UrlComparisonMode mode) diff --git a/runners/bookmarks/tests/testchromebookmarks.cpp b/runners/bookmarks/tests/testchromebookmarks.cpp index 92c576e10..aabe30a60 100644 --- a/runners/bookmarks/tests/testchromebookmarks.cpp +++ b/runners/bookmarks/tests/testchromebookmarks.cpp @@ -35,7 +35,7 @@ void TestChromeBookmarks::initTestCase() void TestChromeBookmarks::bookmarkFinderShouldFindEachProfileDirectory() { FindChromeProfile findChrome("chromium", "./chrome-config-home"); - QString profileTemplate = QString("./chrome-config-home/.config/%1/%2/Bookmarks"); + QString profileTemplate = QStringLiteral("./chrome-config-home/.config/%1/%2/Bookmarks"); QList profiles = findChrome.find(); QCOMPARE(profiles.size(), 2); diff --git a/shell/scripting/scriptengine.cpp b/shell/scripting/scriptengine.cpp index 45d81d495..ef69d85a3 100644 --- a/shell/scripting/scriptengine.cpp +++ b/shell/scripting/scriptengine.cpp @@ -97,7 +97,7 @@ int ScriptEngine::defaultPanelScreen() const QJSValue ScriptEngine::newError(const QString &message) { - return evaluate(QString("new Error('%1');").arg(message)); + return evaluate(QStringLiteral("new Error('%1');").arg(message)); } QString ScriptEngine::onlyExec(const QString &commandLine) diff --git a/wallpapers/image/autotests/testfindpreferredimage.cpp b/wallpapers/image/autotests/testfindpreferredimage.cpp index ac9b5c6ad..17c6a0428 100644 --- a/wallpapers/image/autotests/testfindpreferredimage.cpp +++ b/wallpapers/image/autotests/testfindpreferredimage.cpp @@ -26,7 +26,7 @@ QString formatResolution(const QString &str) { QSize size = resSize(str); float aspectRatio = (size.height() > 0 ) ? size.width() / (float)size.height() : 0; - return QString("%1 (%2)").arg(str, 9).arg(aspectRatio, 7); + return QStringLiteral("%1 (%2)").arg(str, 9).arg(aspectRatio, 7); } class TestResolutions: public QObject