diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,8 +139,6 @@ add_definitions(-DQT_USE_QSTRINGBUILDER) add_definitions(-DQT_NO_URL_CAST_FROM_STRING) -remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS) - include(KF5PlasmaMacros.cmake) ######################################################################### diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -2,6 +2,7 @@ set_package_properties(Qt5Test PROPERTIES PURPOSE "Required for tests") set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) +remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_STRICT_ITERATORS -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_KEYWORDS) include(ECMMarkAsTest) include(ECMAddTests) diff --git a/src/declarativeimports/calendar/calendarplugin.cpp b/src/declarativeimports/calendar/calendarplugin.cpp --- a/src/declarativeimports/calendar/calendarplugin.cpp +++ b/src/declarativeimports/calendar/calendarplugin.cpp @@ -39,7 +39,7 @@ void CalendarPlugin::registerTypes(const char *uri) { - Q_ASSERT(uri == QLatin1String("org.kde.plasma.calendar")); + Q_ASSERT(uri == QByteArray("org.kde.plasma.calendar")); qmlRegisterType(uri, 2, 0, "CalendarData"); qmlRegisterType(uri, 2, 0, "Calendar"); qmlRegisterType(); diff --git a/src/declarativeimports/calendar/eventpluginsmanager.cpp b/src/declarativeimports/calendar/eventpluginsmanager.cpp --- a/src/declarativeimports/calendar/eventpluginsmanager.cpp +++ b/src/declarativeimports/calendar/eventpluginsmanager.cpp @@ -87,9 +87,9 @@ { // The currentPlugin path contains the full path including // the plugin filename, so it needs to be cut off from the last '/' - const QStringRef pathRef = currentPlugin.leftRef(currentPlugin.lastIndexOf('/')); + const QStringRef pathRef = currentPlugin.leftRef(currentPlugin.lastIndexOf(QLatin1Char('/'))); const QString qmlFilePath = metadata.configUi; - return QString(pathRef % '/' % qmlFilePath); + return QString(pathRef % QLatin1Char('/') % qmlFilePath); } case Qt::UserRole + 1: return currentPlugin; diff --git a/src/declarativeimports/core/corebindingsplugin.cpp b/src/declarativeimports/core/corebindingsplugin.cpp --- a/src/declarativeimports/core/corebindingsplugin.cpp +++ b/src/declarativeimports/core/corebindingsplugin.cpp @@ -70,10 +70,10 @@ void CoreBindingsPlugin::registerTypes(const char *uri) { - Q_ASSERT(uri == QLatin1String("org.kde.plasma.core")); + Q_ASSERT(uri == QByteArray("org.kde.plasma.core")); - qmlRegisterUncreatableType(uri, 2, 0, "Types", ""); - qmlRegisterUncreatableType(uri, 2, 0, "Units", ""); + qmlRegisterUncreatableType(uri, 2, 0, "Types", {}); + qmlRegisterUncreatableType(uri, 2, 0, "Units", {}); qmlRegisterType(uri, 2, 0, "Svg"); qmlRegisterType(uri, 2, 0, "FrameSvg"); diff --git a/src/declarativeimports/core/datamodel.h b/src/declarativeimports/core/datamodel.h --- a/src/declarativeimports/core/datamodel.h +++ b/src/declarativeimports/core/datamodel.h @@ -243,6 +243,7 @@ QRegExp m_keyRoleFilterRE; QString m_sourceFilter; QRegExp m_sourceFilterRE; +#warning QByteArray key? QMap > m_items; QHash m_roleNames; QHash m_roleIds; diff --git a/src/declarativeimports/core/datamodel.cpp b/src/declarativeimports/core/datamodel.cpp --- a/src/declarativeimports/core/datamodel.cpp +++ b/src/declarativeimports/core/datamodel.cpp @@ -55,7 +55,7 @@ const QHash rNames = roleNames(); m_roleIds.reserve(rNames.count()); for (auto i = rNames.constBegin(); i != rNames.constEnd(); ++i) { - m_roleIds[i.value()] = i.key(); + m_roleIds[QString::fromUtf8(i.value())] = i.key(); } setRoleNames(sourceModel()->roleNames()); @@ -193,7 +193,7 @@ const QHash rNames = roleNames(); for (auto i = rNames.begin(); i != rNames.end(); ++i) { - hash[i.value()] = data(idx, i.key()); + hash[QString::fromUtf8(i.value())] = data(idx, i.key()); } return hash; @@ -439,7 +439,7 @@ if (m_keyRoleFilter.isEmpty()) { //source name in the map, linear scan for (int i = 0; i < m_items.value(QString()).count(); ++i) { - if (m_items.value(QString())[i].value().value("DataEngineSource") == sourceName) { + if (m_items.value(QString())[i].value().value(QStringLiteral("DataEngineSource")) == sourceName) { beginRemoveRows(QModelIndex(), i, i); m_items[QString()].remove(i); endRemoveRows(); @@ -498,7 +498,7 @@ if (!m_keyRoleFilter.isEmpty() && m_roleNames.value(role) == "DataEngineSource") { return source; } else { - return m_items.value(source).value(actualRow).value().value(m_roleNames.value(role)); + return m_items.value(source).value(actualRow).value().value(QString::fromUtf8(m_roleNames.value(role))); } } @@ -554,7 +554,7 @@ const QHash rNames = roleNames(); for (auto i = rNames.constBegin(); i != rNames.constEnd(); ++i) { - map[i.value()] = data(idx, i.key()); + map[QString::fromUtf8(i.value())] = data(idx, i.key()); } return map; diff --git a/src/declarativeimports/core/datasource.cpp b/src/declarativeimports/core/datasource.cpp --- a/src/declarativeimports/core/datasource.cpp +++ b/src/declarativeimports/core/datasource.cpp @@ -174,7 +174,7 @@ { //it can arrive also data we don't explicitly connected a source if (m_connectedSources.contains(sourceName)) { - m_data->insert(sourceName.toLatin1(), data); + m_data->insert(sourceName, data); emit dataChanged(); emit newData(sourceName, data); } else if (m_dataEngine) { diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -175,7 +175,7 @@ if (m_usesPlasmaTheme) { //try as a svg icon from plasma theme - m_svgIcon->setImagePath(QLatin1String("icons/") + sourceString.section('-', 0, 0)); + m_svgIcon->setImagePath(QLatin1String("icons/") + sourceString.section(QLatin1Char('-'), 0, 0)); m_svgIcon->setContainsMultipleImages(true); } diff --git a/src/declarativeimports/core/tooltip.cpp b/src/declarativeimports/core/tooltip.cpp --- a/src/declarativeimports/core/tooltip.cpp +++ b/src/declarativeimports/core/tooltip.cpp @@ -52,7 +52,7 @@ loadSettings(); - const QString configFile = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + "plasmarc"; + const QString configFile = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/plasmarc"); KDirWatch::self()->addFile(configFile); QObject::connect(KDirWatch::self(), SIGNAL(created(QString)), this, SLOT(settingsChanged())); QObject::connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(settingsChanged())); diff --git a/src/declarativeimports/core/tooltipdialog.cpp b/src/declarativeimports/core/tooltipdialog.cpp --- a/src/declarativeimports/core/tooltipdialog.cpp +++ b/src/declarativeimports/core/tooltipdialog.cpp @@ -57,8 +57,8 @@ if (!m_qmlObject->rootObject()) { //HACK: search our own import foreach (const QString &path, m_qmlObject->engine()->importPathList()) { - if (QFile::exists(path + "/org/kde/plasma/core")) { - m_qmlObject->setSource(QUrl::fromLocalFile(path + "/org/kde/plasma/core/private/DefaultToolTip.qml")); + if (QFile::exists(path + QStringLiteral("/org/kde/plasma/core"))) { + m_qmlObject->setSource(QUrl::fromLocalFile(path + QStringLiteral("/org/kde/plasma/core/private/DefaultToolTip.qml"))); break; } } diff --git a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp --- a/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp +++ b/src/declarativeimports/plasmacomponents/plasmacomponentsplugin.cpp @@ -81,16 +81,16 @@ void PlasmaComponentsPlugin::registerTypes(const char *uri) { - Q_ASSERT(uri == QLatin1String("org.kde.plasma.components")); + Q_ASSERT(uri == QByteArray("org.kde.plasma.components")); qmlRegisterType(uri, 2, 0, "Menu"); qmlRegisterType(uri, 2, 0, "MenuItem"); qmlRegisterType(uri, 2, 0, "RangeModel"); - qmlRegisterUncreatableType(uri, 2, 0, "DialogStatus", ""); - qmlRegisterUncreatableType(uri, 2, 0, "PageOrientation", ""); - qmlRegisterUncreatableType(uri, 2, 0, "PageStatus", ""); + qmlRegisterUncreatableType(uri, 2, 0, "DialogStatus", {}); + qmlRegisterUncreatableType(uri, 2, 0, "PageOrientation", {}); + qmlRegisterUncreatableType(uri, 2, 0, "PageStatus", {}); } #include "moc_plasmacomponentsplugin.cpp" diff --git a/src/declarativeimports/plasmacomponents/qmenu.cpp b/src/declarativeimports/plasmacomponents/qmenu.cpp --- a/src/declarativeimports/plasmacomponents/qmenu.cpp +++ b/src/declarativeimports/plasmacomponents/qmenu.cpp @@ -448,7 +448,7 @@ //pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" //post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() - if (QVersionNumber::fromString(qVersion()) > QVersionNumber(5, 8, 0)) { + if (QVersionNumber::fromString(QString::fromLatin1(qVersion())) > QVersionNumber(5, 8, 0)) { QTimer::singleShot(0, this, ungrabMouseHack); } else { ungrabMouseHack(); diff --git a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp --- a/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp +++ b/src/declarativeimports/plasmaextracomponents/appbackgroundprovider.cpp @@ -41,6 +41,6 @@ { Q_UNUSED(size) Q_UNUSED(requestedSize) - return QImage(m_theme->backgroundPath(id % ".png")); + return QImage(m_theme->backgroundPath(id % QStringLiteral(".png"))); } diff --git a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp --- a/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp +++ b/src/declarativeimports/plasmaextracomponents/fallbackcomponent.cpp @@ -75,7 +75,7 @@ resolved = m_basePath + path + key; } else { - resolved = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_basePath + '/' + path + key); + resolved = QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_basePath + QLatin1Char('/') + path + key); } m_possiblePaths.insert(path + key, new QString(resolved)); diff --git a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp --- a/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp +++ b/src/declarativeimports/plasmaextracomponents/plasmaextracomponentsplugin.cpp @@ -30,13 +30,13 @@ void PlasmaExtraComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) { - Q_ASSERT(uri == QLatin1String("org.kde.plasma.extras")); + Q_ASSERT(uri == QByteArray("org.kde.plasma.extras")); engine->addImageProvider(QStringLiteral("appbackgrounds"), new AppBackgroundProvider); } void PlasmaExtraComponentsPlugin::registerTypes(const char *uri) { - Q_ASSERT(uri == QLatin1String("org.kde.plasma.extras")); + Q_ASSERT(uri == QByteArray("org.kde.plasma.extras")); qmlRegisterType(uri, 2, 0, "FallbackComponent"); } diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -109,7 +109,7 @@ } d->icon = d->appletDescription.iconName(); - if (args.contains("org.kde.plasma:force-create")) { + if (args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) { setProperty("org.kde.plasma:force-create", true); } diff --git a/src/plasma/containment.cpp b/src/plasma/containment.cpp --- a/src/plasma/containment.cpp +++ b/src/plasma/containment.cpp @@ -423,8 +423,8 @@ //change the group to its configloader, if any //FIXME: this is very, very brutal if (applet->configScheme()) { - const QString oldGroupPrefix = QString("Containments" + QString::number(currentContainment->id()) + "Applets"); - const QString newGroupPrefix = QString("Containments" + QString::number(id()) + "Applets"); + const QString oldGroupPrefix = QStringLiteral("Containments") + QString::number(currentContainment->id()) + QStringLiteral("Applets"); + const QString newGroupPrefix = QStringLiteral("Containments") + QString::number(id()) + QStringLiteral("Applets"); applet->configScheme()->setCurrentGroup(applet->configScheme()->currentGroup().replace(0, oldGroupPrefix.length(), newGroupPrefix)); diff --git a/src/plasma/containmentactions.cpp b/src/plasma/containmentactions.cpp --- a/src/plasma/containmentactions.cpp +++ b/src/plasma/containmentactions.cpp @@ -125,23 +125,23 @@ QMouseEvent *e = static_cast(event); int m = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m); - trigger += mouse.valueToKey(e->button()); + trigger += QString::fromLatin1(mouse.valueToKey(e->button())); modifiers = e->modifiers(); break; } case QEvent::Wheel: { QWheelEvent *e = static_cast(event); int o = QObject::staticQtMetaObject.indexOfEnumerator("Orientations"); QMetaEnum orient = QObject::staticQtMetaObject.enumerator(o); trigger = QStringLiteral("wheel:"); - trigger += orient.valueToKey(e->orientation()); + trigger += QString::fromLatin1(orient.valueToKey(e->orientation())); modifiers = e->modifiers(); break; } case QEvent::ContextMenu: { int m = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons"); QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m); - trigger = mouse.valueToKey(Qt::RightButton); + trigger = QString::fromLatin1(mouse.valueToKey(Qt::RightButton)); modifiers = Qt::NoModifier; break; } @@ -151,8 +151,7 @@ int k = QObject::staticQtMetaObject.indexOfEnumerator("KeyboardModifiers"); QMetaEnum kbd = QObject::staticQtMetaObject.enumerator(k); - trigger += ';'; - trigger += kbd.valueToKeys(modifiers); + trigger += QLatin1Char(';') + QString::fromLatin1(kbd.valueToKeys(modifiers)); return trigger; } diff --git a/src/plasma/corona.cpp b/src/plasma/corona.cpp --- a/src/plasma/corona.cpp +++ b/src/plasma/corona.cpp @@ -246,7 +246,7 @@ Containment *Corona::createContainment(const QString &name, const QVariantList &args) { - if (d->immutability == Types::Mutable || args.contains("org.kde.plasma:force-create")) { + if (d->immutability == Types::Mutable || args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) { return d->addContainment(name, args, 0); } @@ -364,7 +364,7 @@ KConfigGroup config(KSharedConfig::openConfig(), "General"); if (QCoreApplication::instance()) { - configName = QCoreApplication::instance()->applicationName() + "-appletsrc"; + configName = QCoreApplication::instance()->applicationName() + QStringLiteral("-appletsrc"); } else { configName = QStringLiteral("plasma-appletsrc"); } @@ -484,7 +484,7 @@ applet->init(); delete applet; } - applet = containment = new Containment(q, 0, id); + applet = containment = new Containment(q, {}, id); //if it's a dummy containment, just say its ui is ready, not blocking the corona applet->updateConstraints(Plasma::Types::UiReadyConstraint); diff --git a/src/plasma/dataengine.cpp b/src/plasma/dataengine.cpp --- a/src/plasma/dataengine.cpp +++ b/src/plasma/dataengine.cpp @@ -433,7 +433,7 @@ if (!api.isEmpty()) { const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/" + dataEngineDescription.pluginName() + '/', + QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/dataengines/") + dataEngineDescription.pluginName(), QStandardPaths::LocateDirectory); package = new Package(PluginLoader::self()->loadPackage(QStringLiteral("Plasma/DataEngine"), api)); package->setPath(path); diff --git a/src/plasma/framesvg.cpp b/src/plasma/framesvg.cpp --- a/src/plasma/framesvg.cpp +++ b/src/plasma/framesvg.cpp @@ -132,7 +132,7 @@ } else { d->prefix = prefix; if (!d->prefix.isEmpty()) { - d->prefix += '-'; + d->prefix += QLatin1Char('-'); } } d->requestedPrefix = prefix; diff --git a/src/plasma/packagestructure.cpp b/src/plasma/packagestructure.cpp --- a/src/plasma/packagestructure.cpp +++ b/src/plasma/packagestructure.cpp @@ -116,7 +116,7 @@ } else { if (!servicePrefix.isEmpty()) { // and now we register it as a service =) - QString metaPath = path + "/metadata.desktop"; + QString metaPath = path + QStringLiteral("/metadata.desktop"); KDesktopFile df(metaPath); KConfigGroup cg = df.desktopGroup(); const QString pluginName = cg.readEntry("X-KDE-PluginInfo-Name", QString()); @@ -132,7 +132,7 @@ //TODO: remove installation of the desktop file in kservices5 when possible - const QString serviceName = servicePrefix + pluginName + ".desktop"; + const QString serviceName = servicePrefix + pluginName + QStringLiteral(".desktop"); QString localServiceDirectory = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kservices5/"); if (!QDir().mkpath(localServiceDirectory)) { @@ -148,7 +148,7 @@ qCDebug(LOG_PLASMA) << "Copying metadata went ok."; // the icon in the installed file needs to point to the icon in the // installation dir! - QString iconPath = path + '/' + cg.readEntry("Icon"); + QString iconPath = path + QLatin1Char('/') + cg.readEntry("Icon"); QFile icon(iconPath); if (icon.exists()) { KDesktopFile df(service); @@ -217,11 +217,11 @@ KJob *PackageStructure::uninstall(Package *package, const QString &packageRoot) { if (d->internalStructure && !qobject_cast(d->internalStructure)) { - QString metaPath = package->path() + "/metadata.desktop"; + QString metaPath = package->path() + QStringLiteral("/metadata.desktop"); KDesktopFile df(metaPath); KConfigGroup cg = df.desktopGroup(); const QString pluginName = cg.readEntry("X-KDE-PluginInfo-Name", QString()); - const QString serviceName = package->servicePrefix() + pluginName + ".desktop"; + const QString serviceName = package->servicePrefix() + pluginName + QStringLiteral(".desktop"); KJob *job = d->internalStructure->uninstall(package->d->internalPackage, packageRoot); if (job) { diff --git a/src/plasma/packagestructure/packages.cpp b/src/plasma/packagestructure/packages.cpp --- a/src/plasma/packagestructure/packages.cpp +++ b/src/plasma/packagestructure/packages.cpp @@ -56,7 +56,7 @@ } KPluginMetaData md(package->metadata().metaDataFileName()); - QString mainScript = md.value("X-Plasma-MainScript"); + QString mainScript = md.value(QLatin1String("X-Plasma-MainScript")); if (!mainScript.isEmpty()) { package->addFileDefinition("mainscript", mainScript, i18n("Main Script File")); @@ -72,7 +72,7 @@ QMutableStringListIterator it(platform); while (it.hasNext()) { it.next(); - it.setValue("platformcontents/" + it.value()); + it.setValue(QStringLiteral("platformcontents/") + it.value()); } platform.append(QStringLiteral("contents")); diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -182,7 +182,7 @@ //if name wasn't a path, pluginName == name - const QString pluginName = name.split('/').last(); + const auto pluginName = name.splitRef(QLatin1Char('/')).last(); // Look for C++ plugins first auto filter = [&pluginName](const KPluginMetaData &md) -> bool @@ -452,7 +452,7 @@ return Package(); } - const QString hashkey = packageFormat + '%' + specialization; + const QString hashkey = packageFormat + QLatin1Char('%') + specialization; PackageStructure *structure = d->structures.value(hashkey).data(); if (structure) { @@ -528,7 +528,7 @@ //NOTE: it still produces kplugininfos from KServices because some user code expects //info.sevice() to be valid and would crash ohtherwise foreach (auto& md, plugins) { - auto pi = md.metaDataFileName().endsWith(".json") ? KPluginInfo(md) : KPluginInfo(KService::serviceByStorageId(md.metaDataFileName())); + auto pi = md.metaDataFileName().endsWith(QLatin1String(".json")) ? KPluginInfo(md) : KPluginInfo(KService::serviceByStorageId(md.metaDataFileName())); if (!pi.isValid()) { qCWarning(LOG_PLASMA) << "Could not load plugin info for plugin :" << md.pluginId() << "skipping plugin"; continue; @@ -716,7 +716,7 @@ if (parentApp.isEmpty()) { constraint = QStringLiteral("not exist [X-KDE-ParentApp]"); } else { - constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + '\''; + constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\''); } list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_dataEnginePluginDir, QStringLiteral("Plasma/DataEngine"), constraint)); @@ -735,7 +735,7 @@ if (parentApp.isEmpty()) { constraint = QStringLiteral("not exist [X-KDE-ParentApp]"); } else { - constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + '\''; + constraint = QLatin1String("[X-KDE-ParentApp] == '") + parentApp + QLatin1Char('\''); } list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_containmentActionsPluginDir, QStringLiteral("Plasma/ContainmentActions"), constraint)); diff --git a/src/plasma/private/applet_p.cpp b/src/plasma/private/applet_p.cpp --- a/src/plasma/private/applet_p.cpp +++ b/src/plasma/private/applet_p.cpp @@ -174,8 +174,8 @@ //It's valid, let's try to load the icon from within the package if (script) { //use the absolute path of the in-package icon as icon name - if (appletDescription.iconName().startsWith('/')) { - icon = package->filePath("", appletDescription.iconName().toUtf8()); + if (appletDescription.iconName().startsWith(QLatin1Char('/'))) { + icon = package->filePath({}, appletDescription.iconName()); } //package not valid, get rid of it } else { diff --git a/src/plasma/private/componentinstaller.cpp b/src/plasma/private/componentinstaller.cpp --- a/src/plasma/private/componentinstaller.cpp +++ b/src/plasma/private/componentinstaller.cpp @@ -65,7 +65,7 @@ QWidget *parent, bool force) { #ifdef PLASMA_ENABLE_PACKAGEKIT_SUPPORT - QString searchString = type + '-' + name; + QString searchString = type + QLatin1Char('-') + name; if (!force) { if (d->alreadyPrompted.contains(searchString)) { diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -192,7 +192,7 @@ return 0; } - if (q->immutability() != Types::Mutable && !args.contains("org.kde.plasma:force-create")) { + if (q->immutability() != Types::Mutable && !args.contains(QVariant::fromValue(QStringLiteral("org.kde.plasma:force-create")))) { #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "addApplet for" << name << "requested, but we're currently immutable!"; #endif diff --git a/src/plasma/private/dataenginemanager.cpp b/src/plasma/private/dataenginemanager.cpp --- a/src/plasma/private/dataenginemanager.cpp +++ b/src/plasma/private/dataenginemanager.cpp @@ -162,7 +162,7 @@ void DataEngineManager::timerEvent(QTimerEvent *) { #ifndef NDEBUG - QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "plasma_dataenginemanager_log"; + QString path = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QStringLiteral("/plasma_dataenginemanager_log"); QFile f(path); if (!f.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { // qCDebug(LOG_PLASMA) << "faild to open" << path; @@ -195,7 +195,7 @@ out << " Relays: " << dc->d->relays.count() << endl; QString times; foreach (SignalRelay *relay, dc->d->relays) { - times.append(' ').append(QString::number(relay->m_interval)); + times.append(QLatin1Char(' ') + QString::number(relay->m_interval)); } out << " Relay Timeouts: " << times << ' ' << endl; } diff --git a/src/plasma/private/storagethread.cpp b/src/plasma/private/storagethread.cpp --- a/src/plasma/private/storagethread.cpp +++ b/src/plasma/private/storagethread.cpp @@ -81,14 +81,14 @@ m_db = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), QStringLiteral("plasma-storage-%1").arg((quintptr)this)); const QString storageDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); QDir().mkpath(storageDir); - m_db.setDatabaseName(storageDir + QLatin1Char('/') + "plasma-storage2.db"); + m_db.setDatabaseName(storageDir + QLatin1Char('/') + QStringLiteral("plasma-storage2.db")); } if (!m_db.open()) { qCWarning(LOG_PLASMA) << "Unable to open the plasma storage cache database: " << m_db.lastError(); } else if (!m_db.tables().contains(caller->clientName())) { QSqlQuery query(m_db); - query.prepare(QStringLiteral("create table ") + caller->clientName() + " (valueGroup varchar(256), id varchar(256), txt TEXT, int INTEGER, float REAL, binary BLOB, creationTime datetime, accessTime datetime, primary key (valueGroup, id))"); + query.prepare(QStringLiteral("create table ") + caller->clientName() + QStringLiteral(" (valueGroup varchar(256), id varchar(256), txt TEXT, int INTEGER, float REAL, binary BLOB, creationTime datetime, accessTime datetime, primary key (valueGroup, id))")); if (!query.exec()) { qCWarning(LOG_PLASMA) << "Unable to create table for" << caller->clientName(); m_db.close(); @@ -122,21 +122,21 @@ QSqlField field(QStringLiteral(":id"), QVariant::String); field.setValue(it.key()); if (!ids.isEmpty()) { - ids.append(", "); + ids.append(QStringLiteral(", ")); } ids.append(m_db.driver()->formatValue(field)); } - query.prepare("delete from " + caller->clientName() + " where valueGroup = :valueGroup and id in (" + ids + ");"); + query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where valueGroup = :valueGroup and id in (") + ids + QStringLiteral(");")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); if (!query.exec()) { m_db.commit(); emit newResult(caller, false); return; } - query.prepare("insert into " + caller->clientName() + " values(:valueGroup, :id, :txt, :int, :float, :binary, date('now'), date('now'))"); + query.prepare(QStringLiteral("insert into ") + caller->clientName() + QStringLiteral(" values(:valueGroup, :id, :txt, :int, :float, :binary, date('now'), date('now'))")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.bindValue(QStringLiteral(":txt"), QVariant()); query.bindValue(QStringLiteral(":int"), QVariant()); @@ -218,20 +218,20 @@ //a bit redundant but should be the faster way with less string concatenation as possible if (params[QStringLiteral("key")].toString().isEmpty()) { //update modification time - query.prepare("update " + clientName + " set accessTime=date('now') where valueGroup=:valueGroup"); + query.prepare(QStringLiteral("update ") + clientName + QStringLiteral(" set accessTime=date('now') where valueGroup=:valueGroup")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.exec(); - query.prepare("select * from " + clientName + " where valueGroup=:valueGroup"); + query.prepare(QStringLiteral("select * from ") + clientName + QStringLiteral(" where valueGroup=:valueGroup")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); } else { //update modification time - query.prepare("update " + clientName + " set accessTime=date('now') where valueGroup=:valueGroup and id=:key"); + query.prepare(QStringLiteral("update ") + clientName + QStringLiteral(" set accessTime=date('now') where valueGroup=:valueGroup and id=:key")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.bindValue(QStringLiteral(":key"), params[QStringLiteral("key")].toString()); query.exec(); - query.prepare("select * from " + clientName + " where valueGroup=:valueGroup and id=:key"); + query.prepare(QStringLiteral("select * from ") + clientName + QStringLiteral(" where valueGroup=:valueGroup and id=:key")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.bindValue(QStringLiteral(":key"), params[QStringLiteral("key")].toString()); } @@ -288,10 +288,10 @@ QSqlQuery query(m_db); if (params[QStringLiteral("key")].toString().isEmpty()) { - query.prepare("delete from " + caller->clientName() + " where valueGroup=:valueGroup"); + query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where valueGroup=:valueGroup")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); } else { - query.prepare("delete from " + caller->clientName() + " where valueGroup=:valueGroup and id=:key"); + query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where valueGroup=:valueGroup and id=:key")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); query.bindValue(QStringLiteral(":key"), params[QStringLiteral("key")].toString()); } @@ -317,11 +317,11 @@ QSqlQuery query(m_db); if (valueGroup.isEmpty()) { - query.prepare("delete from " + caller->clientName() + " where accessTime < :date"); + query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where accessTime < :date")); QDateTime time(QDateTime::currentDateTime().addSecs(-params[QStringLiteral("age")].toUInt())); query.bindValue(QStringLiteral(":date"), time.toTime_t()); } else { - query.prepare("delete from " + caller->clientName() + " where valueGroup=:valueGroup and accessTime < :date"); + query.prepare(QStringLiteral("delete from ") + caller->clientName() + QStringLiteral(" where valueGroup=:valueGroup and accessTime < :date")); query.bindValue(QStringLiteral(":valueGroup"), valueGroup); QDateTime time(QDateTime::currentDateTime().addSecs(-params[QStringLiteral("age")].toUInt())); query.bindValue(QStringLiteral(":date"), time.toTime_t()); diff --git a/src/plasma/private/theme_p.cpp b/src/plasma/private/theme_p.cpp --- a/src/plasma/private/theme_p.cpp +++ b/src/plasma/private/theme_p.cpp @@ -58,8 +58,8 @@ buttonColorScheme(QPalette::Active, KColorScheme::Button, KSharedConfigPtr(0)), viewColorScheme(QPalette::Active, KColorScheme::View, KSharedConfigPtr(0)), complementaryColorScheme(QPalette::Active, KColorScheme::Complementary, KSharedConfigPtr(0)), - defaultWallpaperTheme(DEFAULT_WALLPAPER_THEME), - defaultWallpaperSuffix(DEFAULT_WALLPAPER_SUFFIX), + defaultWallpaperTheme(QStringLiteral(DEFAULT_WALLPAPER_THEME)), + defaultWallpaperSuffix(QStringLiteral(DEFAULT_WALLPAPER_SUFFIX)), defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH), defaultWallpaperHeight(DEFAULT_WALLPAPER_HEIGHT), pixmapCache(0), @@ -151,10 +151,10 @@ #ifndef NDEBUG // qCDebug(LOG_PLASMA) << "using theme for app" << app; #endif - groupName.append('-').append(app); + groupName.append(QLatin1Char('-')).append(app); } } - cfg = KConfigGroup(KSharedConfig::openConfig(themeRcFile), groupName); + cfg = KConfigGroup(KSharedConfig::openConfig(QFile::decodeName(themeRcFile)), groupName); } return cfg; @@ -179,10 +179,10 @@ KDirWatch::self()->removeFile(themeMetadataPath); } if (isRegularTheme) { - themeMetadataPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % themeName % QLatin1Literal("/metadata.desktop")); + themeMetadataPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % themeName % QStringLiteral("/metadata.desktop")); const auto *iconTheme = KIconLoader::global()->theme(); if (iconTheme) { - iconThemeMetadataPath = iconTheme->dir() + "index.theme"; + iconThemeMetadataPath = iconTheme->dir() + QStringLiteral("index.theme"); } Q_ASSERT(!themeMetadataPath.isEmpty() || themeName.isEmpty()); @@ -236,7 +236,7 @@ // the cache should be dropped; we need a way to detect system color change when the // application is not running. // check for expired cache - const QString cacheFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + '/' + cacheFile + QLatin1String(".kcache"); + const QString cacheFilePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + cacheFile + QLatin1String(".kcache"); if (!cacheFilePath.isEmpty()) { const QFileInfo cacheFileInfo(cacheFilePath); const QFileInfo metadataFileInfo(themeMetadataPath); @@ -272,7 +272,7 @@ } } - const QString svgElementsFile = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + '/' + svgElementsFileName; + const QString svgElementsFile = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1Char('/') + svgElementsFileName; svgElementsCache = KSharedConfig::openConfig(svgElementsFile, KConfig::SimpleConfig); QString currentIconThemePath; const auto *iconTheme = KIconLoader::global()->theme(); @@ -485,7 +485,7 @@ QFont font = QGuiApplication::font(); elements[QStringLiteral("%fontsize")] = QStringLiteral("%1pt").arg(font.pointSize()); - elements[QStringLiteral("%fontfamily")] = font.family().split('[').first(); + elements[QStringLiteral("%fontfamily")] = font.family().splitRef(QLatin1Char('[')).first().toString(); elements[QStringLiteral("%smallfontsize")] = QStringLiteral("%1pt").arg(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSize()); QHash::const_iterator it = elements.constBegin(); @@ -845,7 +845,7 @@ apiMinor = 0; apiRevision = 0; if (!apiVersion.isEmpty()) { - QVector parts = apiVersion.splitRef('.'); + QVector parts = apiVersion.splitRef(QLatin1Char('.')); if (!parts.isEmpty()) { apiMajor = parts.value(0).toInt(); } diff --git a/src/plasma/private/timetracker.cpp b/src/plasma/private/timetracker.cpp --- a/src/plasma/private/timetracker.cpp +++ b/src/plasma/private/timetracker.cpp @@ -51,7 +51,7 @@ QJsonDocument doc; doc.setArray(array); - QFile f(QStringLiteral("/tmp/debug-")+qgetenv("USER")+".json"); + QFile f(QStringLiteral("/tmp/debug-") + QString::fromUtf8(qgetenv("USER")) + QStringLiteral(".json")); bool b = f.open(QFile::WriteOnly); Q_ASSERT(b); f.write(doc.toJson()); @@ -96,15 +96,15 @@ void TimeTracker::init() { - m_history.events.append(TimeEvent { QDateTime::currentDateTime(), QStringLiteral("constructed %1 %2").arg(parent()->metaObject()->className(), parent()->objectName()) }); + m_history.events.append(TimeEvent { QDateTime::currentDateTime(), QStringLiteral("constructed %1 %2").arg(QString::fromUtf8(parent()->metaObject()->className()), parent()->objectName()) }); QMetaMethod propChange = metaObject()->method(metaObject()->indexOfSlot("propertyChanged()")); Q_ASSERT(propChange.isValid() && metaObject()->indexOfSlot("propertyChanged()")>=0); QObject* o = parent(); for (int i = 0, pc = o->metaObject()->propertyCount(); imetaObject()->property(i); - m_history.initial[prop.name()] = prop.read(o); + m_history.initial[QString::fromUtf8(prop.name())] = prop.read(o); if (prop.hasNotifySignal()) connect(o, prop.notifySignal(), this, propChange); @@ -133,7 +133,7 @@ QString val; QDebug d(&val); d << prop.read(parent()); - m_history.events.append(TimeEvent { QDateTime::currentDateTime(), QStringLiteral("property %1 changed to %2").arg(prop.name(), val.trimmed())}); + m_history.events.append(TimeEvent { QDateTime::currentDateTime(), QStringLiteral("property %1 changed to %2").arg(QString::fromUtf8(prop.name()), val.trimmed())}); } } } diff --git a/src/plasma/service.cpp b/src/plasma/service.cpp --- a/src/plasma/service.cpp +++ b/src/plasma/service.cpp @@ -198,7 +198,7 @@ return; } - const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, PLASMA_RELATIVE_DATA_INSTALL_DIR "/services/" + d->name + ".operations"); + const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(PLASMA_RELATIVE_DATA_INSTALL_DIR "/services/") + d->name + QStringLiteral(".operations")); if (path.isEmpty()) { #ifndef NDEBUG diff --git a/src/plasma/svg.cpp b/src/plasma/svg.cpp --- a/src/plasma/svg.cpp +++ b/src/plasma/svg.cpp @@ -309,7 +309,7 @@ if (elementsWithSizeHints.isEmpty()) { // Fetch all size hinted element ids from the theme's rect cache // and store them locally. - QRegExp sizeHintedKeyExpr(CACHE_ID_NATURAL_SIZE("(\\d+)-(\\d+)-(.+)", status, ratio)); + QRegExp sizeHintedKeyExpr(CACHE_ID_NATURAL_SIZE(QStringLiteral("(\\d+)-(\\d+)-(.+)"), status, ratio)); foreach (const QString &key, cacheAndColorsTheme()->listCachedRectKeys(path)) { if (sizeHintedKeyExpr.exactMatch(key)) { @@ -347,8 +347,8 @@ } if (bestFit.isValid()) { - actualElementId = QString::number(bestFit.width()) % '-' % - QString::number(bestFit.height()) % '-' % elementId; + actualElementId = QString::number(bestFit.width()) % QLatin1Char('-') % + QString::number(bestFit.height()) % QLatin1Char('-') % elementId; } } } @@ -456,7 +456,7 @@ //qCDebug(LOG_PLASMA) << path << "**"; QString styleSheet = cacheAndColorsTheme()->d->svgStyleSheet(colorGroup, status); - styleCrc = qChecksum(styleSheet.toUtf8(), styleSheet.size()); + styleCrc = qChecksum(styleSheet.toUtf8().constData(), styleSheet.size()); QHash::const_iterator it = s_renderers.constFind(styleCrc + path); diff --git a/src/plasma/theme.cpp b/src/plasma/theme.cpp --- a/src/plasma/theme.cpp +++ b/src/plasma/theme.cpp @@ -202,9 +202,7 @@ QString Theme::wallpaperPath(const QSize &size) const { QString fullPath; - QString image = d->defaultWallpaperTheme; - - image.append("/contents/images/%1x%2").append(d->defaultWallpaperSuffix); + QString image = d->defaultWallpaperTheme + QStringLiteral("/contents/images/%1x%2") + d->defaultWallpaperSuffix; QString defaultImage = image.arg(d->defaultWallpaperWidth).arg(d->defaultWallpaperHeight); if (size.isValid()) { @@ -356,7 +354,7 @@ //Name starting by _ means the element is empty and we're asked for the size of //the whole image, so the whole image is never invalid - if (element.indexOf('_') <= 0) { + if (element.indexOf(QLatin1Char('_')) <= 0) { return false; } diff --git a/src/plasmapkg/main.cpp b/src/plasmapkg/main.cpp --- a/src/plasmapkg/main.cpp +++ b/src/plasmapkg/main.cpp @@ -77,7 +77,7 @@ params[typeIndex + 1] = typeFromLegacy(params.value(typeIndex + 1)); } else { //user passed --type=typeName - typeIndex = params.indexOf(QRegularExpression("--type=.*")); + typeIndex = params.indexOf(QRegularExpression(QStringLiteral("--type=.*"))); if (typeIndex > -1) { params[typeIndex] = QStringLiteral("--type=") + typeFromLegacy(params.value(typeIndex).replace(QStringLiteral("--type="), QString())); } diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -186,7 +186,7 @@ void AppletQuickItemPrivate::propagateSizeHint(const QByteArray &layoutProperty) { if (ownLayout && representationLayout) { - ownLayout->setProperty(layoutProperty, representationLayout->property(layoutProperty)); + ownLayout->setProperty(layoutProperty.constData(), representationLayout->property(layoutProperty.constData())); } } @@ -524,7 +524,7 @@ reason = d->applet->launchErrorMessage(); } else if (d->applet->kPackage().isValid()) { foreach (QQmlError error, d->qmlObject->mainComponent()->errors()) { - reason += error.toString() + '\n'; + reason += error.toString() + QLatin1Char('\n'); } reason = i18n("Error loading QML file: %1", reason); } else { diff --git a/src/plasmaquick/configmodel.cpp b/src/plasmaquick/configmodel.cpp --- a/src/plasmaquick/configmodel.cpp +++ b/src/plasmaquick/configmodel.cpp @@ -236,7 +236,7 @@ { const QString source = d->categories.at(index.row())->source(); // Quick check if source is an absolute path or not - if (d->appletInterface && !source.isEmpty() && !(source.startsWith('/') && source.endsWith(QLatin1String("qml")))) { + if (d->appletInterface && !source.isEmpty() && !(source.startsWith(QLatin1Char('/')) && source.endsWith(QLatin1String("qml")))) { if(!d->appletInterface.data()->kPackage().isValid()) qWarning() << "wrong applet" << d->appletInterface.data()->pluginMetaData().name(); return QUrl::fromLocalFile(d->appletInterface.data()->kPackage().filePath("ui", source)); diff --git a/src/plasmaquick/configview.cpp b/src/plasmaquick/configview.cpp --- a/src/plasmaquick/configview.cpp +++ b/src/plasmaquick/configview.cpp @@ -97,9 +97,9 @@ kdeclarative.setDeclarativeEngine(q->engine()); const QString rootPath = applet.data()->pluginMetaData().value(QStringLiteral("X-Plasma-RootPath")); if (!rootPath.isEmpty()) { - kdeclarative.setTranslationDomain("plasma_applet_" + rootPath); + kdeclarative.setTranslationDomain(QStringLiteral("plasma_applet_") + rootPath); } else { - kdeclarative.setTranslationDomain("plasma_applet_" + applet.data()->pluginMetaData().pluginId()); + kdeclarative.setTranslationDomain(QStringLiteral("plasma_applet_") + applet.data()->pluginMetaData().pluginId()); } kdeclarative.setupBindings(); diff --git a/src/plasmaquick/containmentview.cpp b/src/plasmaquick/containmentview.cpp --- a/src/plasmaquick/containmentview.cpp +++ b/src/plasmaquick/containmentview.cpp @@ -208,7 +208,7 @@ if (corona->kPackage().isValid()) { const auto info = corona->kPackage().metadata(); if (info.isValid()) { - setTranslationDomain("plasma_shell_" + info.pluginId()); + setTranslationDomain(QStringLiteral("plasma_shell_") + info.pluginId()); } else { qWarning() << "Invalid corona package metadata"; } diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -96,18 +96,19 @@ { //qDebug() << "Intercepted URL:" << path << type; - if (d->forcePlasmaStyle && path.path().contains("Controls.2/org.kde.desktop/")) { + if (d->forcePlasmaStyle && path.path().contains(QLatin1String("Controls.2/org.kde.desktop/"))) { return QUrl::fromLocalFile(path.path().replace(QLatin1String("Controls.2/org.kde.desktop/"), QLatin1String("Controls.2/Plasma/"))); } QString pkgRoot; KPackage::Package package; if (d->package.isValid()) { package = d->package; } else { foreach (const QString &base, QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation)) { - pkgRoot = QFileInfo(base + "/plasma/plasmoids/").canonicalFilePath(); + pkgRoot = QFileInfo(base + QStringLiteral("/plasma/plasmoids/")).canonicalFilePath(); if (!pkgRoot.isEmpty() && path.path().startsWith(pkgRoot)) { - const QString pkgName = path.path().mid(pkgRoot.length() + 1).split('/').first(); + const QString pkgName = path.path().midRef(pkgRoot.length() + 1).split(QLatin1Char('/')).first().toString(); +#warning FIX double look-up if (PackageUrlInterceptorPrivate::s_packages.contains(pkgName)) { package = PackageUrlInterceptorPrivate::s_packages.value(pkgName); } else { diff --git a/src/plasmaquick/private/packages.cpp b/src/plasmaquick/private/packages.cpp --- a/src/plasmaquick/private/packages.cpp +++ b/src/plasmaquick/private/packages.cpp @@ -91,7 +91,7 @@ QMutableStringListIterator it(platform); while (it.hasNext()) { it.next(); - it.setValue("platformcontents/" + it.value()); + it.setValue(QStringLiteral("platformcontents/") + it.value()); } platform.append(QStringLiteral("contents")); diff --git a/src/plasmaquick/view.cpp b/src/plasmaquick/view.cpp --- a/src/plasmaquick/view.cpp +++ b/src/plasmaquick/view.cpp @@ -196,7 +196,7 @@ KDeclarative::KDeclarative kdeclarative; kdeclarative.setDeclarativeEngine(engine()); //binds things like kconfig and icons - kdeclarative.setTranslationDomain("plasma_shell_" + pkg.metadata().pluginId()); + kdeclarative.setTranslationDomain(QStringLiteral("plasma_shell_") + pkg.metadata().pluginId()); kdeclarative.setupBindings(); } else { qWarning() << "Invalid home screen package"; diff --git a/src/scriptengines/qml/plasmoid/appletinterface.cpp b/src/scriptengines/qml/plasmoid/appletinterface.cpp --- a/src/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/src/scriptengines/qml/plasmoid/appletinterface.cpp @@ -643,30 +643,31 @@ QString AppletInterface::downloadPath() const { - const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/Plasma/" + applet()->pluginMetaData().pluginId() + '/'; + const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/Plasma/") + applet()->pluginMetaData().pluginId() + QLatin1Char('/'); if (!QFile::exists(downloadDir)) { - QDir dir(QChar('/')); + QDir dir({ QLatin1Char('/') }); dir.mkpath(downloadDir); } return downloadDir; } QStringList AppletInterface::downloadedFiles() const { - const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/Plasma/" + applet()->pluginMetaData().pluginId() + '/'; + const QString downloadDir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/Plasma/") + applet()->pluginMetaData().pluginId() + QLatin1Char('/'); QDir dir(downloadDir); return dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable); } void AppletInterface::executeAction(const QString &name) { if (qmlObject()->rootObject()) { const QMetaObject *metaObj = qmlObject()->rootObject()->metaObject(); - QString actionMethodName = QString("action_" + name); - if (metaObj->indexOfMethod(QMetaObject::normalizedSignature((actionMethodName + "()").toLatin1())) != -1) { - QMetaObject::invokeMethod(qmlObject()->rootObject(), actionMethodName.toLatin1(), Qt::DirectConnection); + const QByteArray actionMethodName = "action_" + name.toUtf8(); + const QByteArray actionFunctionName = actionMethodName + QByteArray("()"); + if (metaObj->indexOfMethod(QMetaObject::normalizedSignature(actionFunctionName.constData()).constData()) != -1) { + QMetaObject::invokeMethod(qmlObject()->rootObject(), actionMethodName.constData(), Qt::DirectConnection); } else { QMetaObject::invokeMethod(qmlObject()->rootObject(), "actionTriggered", Qt::DirectConnection, Q_ARG(QVariant, name)); } diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -102,13 +102,13 @@ } if (defaults.isValid()) { - KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML"); - pkg.setDefaultPackageRoot("plasma/packages"); + KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("KPackage/GenericQML")); + pkg.setDefaultPackageRoot(QStringLiteral("plasma/packages")); if (defaults.isValid()) { pkg.setPath(defaults.readEntry("ToolBox", "org.kde.desktoptoolbox")); } else { - pkg.setPath("org.kde.desktoptoolbox"); + pkg.setPath(QStringLiteral("org.kde.desktoptoolbox")); } PlasmaQuick::PackageUrlInterceptor *interceptor = dynamic_cast(qmlObject()->engine()->urlInterceptor()); @@ -121,7 +121,7 @@ QObject *containmentGraphicObject = qmlObject()->rootObject(); QVariantHash toolboxProperties; - toolboxProperties["parent"] = QVariant::fromValue(this); + toolboxProperties[QStringLiteral("parent")] = QVariant::fromValue(this); QObject *toolBoxObject = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")), 0, toolboxProperties); if (toolBoxObject && containmentGraphicObject) { containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject)); @@ -447,8 +447,8 @@ qDebug() << "Arrived mimeData" << mimeData->urls() << mimeData->formats() << "at" << x << ", " << y; if (mimeData->hasFormat(QStringLiteral("text/x-plasmoidservicename"))) { - QString data = mimeData->data(QStringLiteral("text/x-plasmoidservicename")); - const QStringList appletNames = data.split('\n', QString::SkipEmptyParts); + QString data = QString::fromUtf8( mimeData->data(QStringLiteral("text/x-plasmoidservicename")) ); + const QStringList appletNames = data.split(QLatin1Char('\n'), QString::SkipEmptyParts); foreach (const QString &appletName, appletNames) { qDebug() << "adding" << appletName; @@ -519,7 +519,7 @@ } else if (seenPlugins.count() == 1) { selectedPlugin = seenPlugins.constBegin().key(); Plasma::Applet *applet = createApplet(selectedPlugin, QVariantList(), QRect(x, y, -1, -1)); - setAppletArgs(applet, pluginFormats[selectedPlugin], mimeData->data(pluginFormats[selectedPlugin])); + setAppletArgs(applet, pluginFormats[selectedPlugin], QString::fromUtf8(mimeData->data(pluginFormats[selectedPlugin]))); } else { QMenu *choices = nullptr; if (!dropJob) { @@ -545,7 +545,7 @@ connect(action, &QAction::triggered, this, [this, x, y, mimeData, action]() { const QString selectedPlugin = action->data().toString(); Plasma::Applet *applet = createApplet(selectedPlugin, QVariantList(), QRect(x, y, -1, -1)); - setAppletArgs(applet, selectedPlugin, mimeData->data(selectedPlugin)); + setAppletArgs(applet, selectedPlugin, QString::fromUtf8(mimeData->data(selectedPlugin))); }); actionsToPlugins.insert(action, info.pluginId()); @@ -657,7 +657,7 @@ dropJob->setApplicationActions(dropActions); } const QString &packagePath = tjob->url().toLocalFile(); - connect(installPlasmaPackageAction, &QAction::triggered, this, [this, tjob, posi, packagePath]() { + connect(installPlasmaPackageAction, &QAction::triggered, this, [this, posi, packagePath]() { using namespace KPackage; PackageStructure *structure = PackageLoader::self()->loadPackageStructure(QStringLiteral("Plasma/Applet")); Package package(structure); @@ -763,7 +763,7 @@ dropActions << action; actionsToWallpapers.insert(action, info.pluginId()); const QUrl url = tjob->url(); - connect(action, &QAction::triggered, this, [this, action, url]() { + connect(action, &QAction::triggered, this, [this, url]() { //set wallpapery stuff if (m_wallpaperInterface && url.isValid()) { m_wallpaperInterface->setUrl(url); @@ -1041,7 +1041,7 @@ //pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" //post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() - if (QVersionNumber::fromString(qVersion()) > QVersionNumber(5, 8, 0)) { + if (QVersionNumber::fromString(QLatin1String(qVersion())) > QVersionNumber(5, 8, 0)) { QTimer::singleShot(0, this, ungrabMouseHack); } else { diff --git a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp --- a/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp +++ b/src/scriptengines/qml/plasmoid/wallpaperinterface.cpp @@ -197,13 +197,13 @@ bool WallpaperInterface::supportsMimetype(const QString &mimetype) const { - return KPluginMetaData::readStringList(m_pkg.metadata().rawData(), "X-Plasma-DropMimeTypes").contains(mimetype); + return KPluginMetaData::readStringList(m_pkg.metadata().rawData(), QStringLiteral("X-Plasma-DropMimeTypes")).contains(mimetype); } void WallpaperInterface::setUrl(const QUrl &url) { if (m_qmlObject->rootObject()) { - QMetaObject::invokeMethod(m_qmlObject->rootObject(), QStringLiteral("setUrl").toLatin1(), Qt::DirectConnection, Q_ARG(QVariant, QVariant::fromValue(url))); + QMetaObject::invokeMethod(m_qmlObject->rootObject(), "setUrl", Qt::DirectConnection, Q_ARG(QVariant, QVariant::fromValue(url))); } } @@ -254,7 +254,8 @@ void WallpaperInterface::executeAction(const QString &name) { if (m_qmlObject->rootObject()) { - QMetaObject::invokeMethod(m_qmlObject->rootObject(), QString("action_" + name).toLatin1(), Qt::DirectConnection); + const QByteArray actionName("action_" + name.toUtf8()); + QMetaObject::invokeMethod(m_qmlObject->rootObject(), actionName.constData(), Qt::DirectConnection); } } diff --git a/tests/dpi/main.cpp b/tests/dpi/main.cpp --- a/tests/dpi/main.cpp +++ b/tests/dpi/main.cpp @@ -33,7 +33,7 @@ Plasma::DPITest app(argc, argv, parser); const QString description = i18n("DPI test app"); - const char version[] = "2.0"; + const QString version = QStringLiteral("2.0"); app.setApplicationVersion(version); parser->addVersionOption(); diff --git a/tests/kplugins/main.cpp b/tests/kplugins/main.cpp --- a/tests/kplugins/main.cpp +++ b/tests/kplugins/main.cpp @@ -30,7 +30,7 @@ Plasma::PluginTest app(argc, argv, parser); const QString description = i18n("Plugin test app"); - const char version[] = "2.0"; + const QString version = QStringLiteral("2.0"); app.setApplicationVersion(version); parser->addVersionOption(); diff --git a/tests/testengine/testengine.cpp b/tests/testengine/testengine.cpp --- a/tests/testengine/testengine.cpp +++ b/tests/testengine/testengine.cpp @@ -127,7 +127,7 @@ // QVariant::RectF setData(dsn, QStringLiteral("QRectF"), QVariant(QRectF(1.2, 3.4, 5.6, 7.8))); // QVariant::RegExp - setData(dsn, QStringLiteral("QRegExp"), QVariant(QRegExp("^KDE4$"))); + setData(dsn, QStringLiteral("QRegExp"), QVariant(QRegExp(QStringLiteral("^KDE4$")))); // QVariant::Region setData(dsn, QStringLiteral("QRegion"), QVariant(QRegion(10, 20, 30, 40))); // QVariant::Size