Remove implicit string casting

Summary: Follow the KF5 guidelines

Test Plan: Plasma shell starts

Reviewers: #plasma, #frameworks, sebas

Reviewed By: #plasma, sebas

Subscribers: plasma-devel

Tags: #plasma, #frameworks

Differential Revision: https://phabricator.kde.org/D9108
This commit is contained in:
Aleix Pol 2017-12-02 15:12:40 +01:00
parent cfcf8a61d5
commit b8b8a69fd1
49 changed files with 129 additions and 129 deletions

View File

@ -139,8 +139,6 @@ add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
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)
#########################################################################

View File

@ -2,6 +2,7 @@ find_package(Qt5Test ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
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)

View File

@ -39,7 +39,7 @@ static QObject *event_plugins_manager_provider(QQmlEngine *engine, QJSEngine *sc
void CalendarPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.calendar"));
Q_ASSERT(uri == QByteArray("org.kde.plasma.calendar"));
qmlRegisterType<CalendarData>(uri, 2, 0, "CalendarData");
qmlRegisterType<Calendar>(uri, 2, 0, "Calendar");
qmlRegisterType<QAbstractItemModel>();

View File

@ -87,9 +87,9 @@ public:
{
// 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;

View File

@ -70,10 +70,10 @@ void CoreBindingsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
void CoreBindingsPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.core"));
Q_ASSERT(uri == QByteArray("org.kde.plasma.core"));
qmlRegisterUncreatableType<Plasma::Types>(uri, 2, 0, "Types", "");
qmlRegisterUncreatableType<Units>(uri, 2, 0, "Units", "");
qmlRegisterUncreatableType<Plasma::Types>(uri, 2, 0, "Types", {});
qmlRegisterUncreatableType<Units>(uri, 2, 0, "Units", {});
qmlRegisterType<Plasma::Svg>(uri, 2, 0, "Svg");
qmlRegisterType<Plasma::FrameSvg>(uri, 2, 0, "FrameSvg");

View File

@ -55,7 +55,7 @@ void SortFilterModel::syncRoleNames()
const QHash<int, QByteArray> 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 @@ QVariantMap SortFilterModel::get(int row) const
const QHash<int, QByteArray> 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 @@ void DataModel::removeSource(const QString &sourceName)
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<QVariantMap>().value("DataEngineSource") == sourceName) {
if (m_items.value(QString())[i].value<QVariantMap>().value(QStringLiteral("DataEngineSource")) == sourceName) {
beginRemoveRows(QModelIndex(), i, i);
m_items[QString()].remove(i);
endRemoveRows();
@ -498,7 +498,7 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
if (!m_keyRoleFilter.isEmpty() && m_roleNames.value(role) == "DataEngineSource") {
return source;
} else {
return m_items.value(source).value(actualRow).value<QVariantMap>().value(m_roleNames.value(role));
return m_items.value(source).value(actualRow).value<QVariantMap>().value(QString::fromUtf8(m_roleNames.value(role)));
}
}
@ -554,7 +554,7 @@ QVariantMap DataModel::get(int row) const
const QHash<int, QByteArray> 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;

View File

@ -243,6 +243,7 @@ private:
QRegExp m_keyRoleFilterRE;
QString m_sourceFilter;
QRegExp m_sourceFilterRE;
#warning QByteArray key?
QMap<QString, QVector<QVariant> > m_items;
QHash<int, QByteArray> m_roleNames;
QHash<QString, int> m_roleIds;

View File

@ -174,7 +174,7 @@ void DataSource::dataUpdated(const QString &sourceName, const Plasma::DataEngine
{
//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) {

View File

@ -175,7 +175,7 @@ void IconItem::setSource(const QVariant &source)
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);
}

View File

@ -52,7 +52,7 @@ ToolTip::ToolTip(QQuickItem *parent)
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()));

View File

@ -57,8 +57,8 @@ QQuickItem *ToolTipDialog::loadDefaultItem()
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;
}
}

View File

@ -81,16 +81,16 @@ void PlasmaComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *ur
void PlasmaComponentsPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.components"));
Q_ASSERT(uri == QByteArray("org.kde.plasma.components"));
qmlRegisterType<QMenuProxy>(uri, 2, 0, "Menu");
qmlRegisterType<QMenuItem>(uri, 2, 0, "MenuItem");
qmlRegisterType<Plasma::QRangeModel>(uri, 2, 0, "RangeModel");
qmlRegisterUncreatableType<DialogStatus>(uri, 2, 0, "DialogStatus", "");
qmlRegisterUncreatableType<PageOrientation>(uri, 2, 0, "PageOrientation", "");
qmlRegisterUncreatableType<PageStatus>(uri, 2, 0, "PageStatus", "");
qmlRegisterUncreatableType<DialogStatus>(uri, 2, 0, "DialogStatus", {});
qmlRegisterUncreatableType<PageOrientation>(uri, 2, 0, "PageOrientation", {});
qmlRegisterUncreatableType<PageStatus>(uri, 2, 0, "PageStatus", {});
}
#include "moc_plasmacomponentsplugin.cpp"

View File

@ -448,7 +448,7 @@ void QMenuProxy::openInternal(QPoint pos)
//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();

View File

@ -41,6 +41,6 @@ QImage AppBackgroundProvider::requestImage(const QString &id, QSize *size, const
{
Q_UNUSED(size)
Q_UNUSED(requestedSize)
return QImage(m_theme->backgroundPath(id % ".png"));
return QImage(m_theme->backgroundPath(id % QStringLiteral(".png")));
}

View File

@ -75,7 +75,7 @@ QString FallbackComponent::filePath(const QString &key)
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));

View File

@ -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<FallbackComponent>(uri, 2, 0, "FallbackComponent");
}

View File

@ -109,7 +109,7 @@ Applet::Applet(QObject *parentObject, const QVariantList &args)
}
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);
}

View File

@ -423,8 +423,8 @@ void Containment::addApplet(Applet *applet)
//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));

View File

@ -125,7 +125,7 @@ QString ContainmentActions::eventToString(QEvent *event)
QMouseEvent *e = static_cast<QMouseEvent *>(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;
}
@ -134,14 +134,14 @@ QString ContainmentActions::eventToString(QEvent *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 @@ QString ContainmentActions::eventToString(QEvent *event)
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;
}

View File

@ -246,7 +246,7 @@ KSharedConfigPtr Corona::config() const
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 @@ CoronaPrivate::CoronaPrivate(Corona *corona)
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 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
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);

View File

@ -433,7 +433,7 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info, con
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);

View File

@ -132,7 +132,7 @@ void FrameSvg::setElementPrefix(const QString &prefix)
} else {
d->prefix = prefix;
if (!d->prefix.isEmpty()) {
d->prefix += '-';
d->prefix += QLatin1Char('-');
}
}
d->requestedPrefix = prefix;

View File

@ -116,7 +116,7 @@ void PackageStructurePrivate::installPathChanged(const QString &path)
} 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 @@ void PackageStructurePrivate::installPathChanged(const QString &path)
//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 @@ void PackageStructurePrivate::installPathChanged(const QString &path)
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::install(Package *package, const QString &archivePath, co
KJob *PackageStructure::uninstall(Package *package, const QString &packageRoot)
{
if (d->internalStructure && !qobject_cast<PackageStructureWrapper *>(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) {

View File

@ -56,7 +56,7 @@ void ChangeableMainScriptPackage::pathChanged(KPackage::Package *package)
}
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 @@ void GenericPackage::initPackage(KPackage::Package *package)
QMutableStringListIterator it(platform);
while (it.hasNext()) {
it.next();
it.setValue("platformcontents/" + it.value());
it.setValue(QStringLiteral("platformcontents/") + it.value());
}
platform.append(QStringLiteral("contents"));

View File

@ -182,7 +182,7 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
//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 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s
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 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS
//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 @@ KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
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 @@ KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parent
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));

View File

@ -174,8 +174,8 @@ void AppletPrivate::init(const QString &_packagePath, const QVariantList &args)
//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 {

View File

@ -65,7 +65,7 @@ void ComponentInstaller::installMissingComponent(const QString &type,
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)) {

View File

@ -192,7 +192,7 @@ Applet *ContainmentPrivate::createApplet(const QString &name, const QVariantList
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

View File

@ -162,7 +162,7 @@ void DataEngineManager::unloadEngine(const QString &name)
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 @@ void DataEngineManager::timerEvent(QTimerEvent *)
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;
}

View File

@ -81,14 +81,14 @@ void StorageThread::initializeDb(StorageJob *caller)
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,12 +122,12 @@ void StorageThread::save(QWeakPointer<StorageJob> wcaller, const QVariantMap &pa
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()) {
@ -136,7 +136,7 @@ void StorageThread::save(QWeakPointer<StorageJob> wcaller, const QVariantMap &pa
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 @@ void StorageThread::retrieve(QWeakPointer<StorageJob> wcaller, const QVariantMap
//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 @@ void StorageThread::deleteEntry(QWeakPointer<StorageJob> wcaller, const QVariant
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 @@ void StorageThread::expire(QWeakPointer<StorageJob> wcaller, const QVariantMap &
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());

View File

@ -58,8 +58,8 @@ ThemePrivate::ThemePrivate(QObject *parent)
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 @@ KConfigGroup &ThemePrivate::config()
#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 @@ bool ThemePrivate::useCache()
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 @@ bool ThemePrivate::useCache()
// 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 @@ bool ThemePrivate::useCache()
}
}
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 @@ const QString ThemePrivate::processStyleSheet(const QString &css, Plasma::Svg::S
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<QString, QString>::const_iterator it = elements.constBegin();
@ -845,7 +845,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
apiMinor = 0;
apiRevision = 0;
if (!apiVersion.isEmpty()) {
QVector<QStringRef> parts = apiVersion.splitRef('.');
QVector<QStringRef> parts = apiVersion.splitRef(QLatin1Char('.'));
if (!parts.isEmpty()) {
apiMajor = parts.value(0).toInt();
}

View File

@ -51,7 +51,7 @@ public:
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,7 +96,7 @@ TimeTracker::TimeTracker(QObject* o)
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);
@ -104,7 +104,7 @@ void TimeTracker::init()
QObject* o = parent();
for (int i = 0, pc = o->metaObject()->propertyCount(); i<pc; ++i) {
QMetaProperty prop = o->metaObject()->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 @@ void TimeTracker::propertyChanged()
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())});
}
}
}

View File

@ -198,7 +198,7 @@ void Service::registerOperationsScheme()
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

View File

@ -309,7 +309,7 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
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 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
}
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 @@ void SvgPrivate::createRenderer()
//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<QString, SharedSvgRenderer::Ptr>::const_iterator it = s_renderers.constFind(styleCrc + path);

View File

@ -202,9 +202,7 @@ QString Theme::styleSheet(const QString &css) const
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 @@ bool Theme::findInRectsCache(const QString &image, const QString &element, QRect
//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;
}

View File

@ -77,7 +77,7 @@ int main(int argc, char **argv)
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()));
}

View File

@ -186,7 +186,7 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item)
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 @@ void AppletQuickItem::init()
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 {

View File

@ -236,7 +236,7 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
{
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));

View File

@ -97,9 +97,9 @@ void ConfigViewPrivate::init()
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();

View File

@ -208,7 +208,7 @@ ContainmentView::ContainmentView(Plasma::Corona *corona, QWindow *parent)
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";
}

View File

@ -96,7 +96,7 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
{
//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;
@ -105,9 +105,10 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept
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 {

View File

@ -91,7 +91,7 @@ void QmlWallpaperPackage::initPackage(Plasma::Package *package)
QMutableStringListIterator it(platform);
while (it.hasNext()) {
it.next();
it.setValue("platformcontents/" + it.value());
it.setValue(QStringLiteral("platformcontents/") + it.value());
}
platform.append(QStringLiteral("contents"));

View File

@ -196,7 +196,7 @@ View::View(Plasma::Corona *corona, QWindow *parent)
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";

View File

@ -643,10 +643,10 @@ QString AppletInterface::downloadPath(const QString &file)
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);
}
@ -655,7 +655,7 @@ QString AppletInterface::downloadPath() const
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);
}
@ -664,9 +664,10 @@ 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));
}

View File

@ -102,13 +102,13 @@ void ContainmentInterface::init()
}
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<PlasmaQuick::PackageUrlInterceptor *>(qmlObject()->engine()->urlInterceptor());
@ -121,7 +121,7 @@ void ContainmentInterface::init()
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 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
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 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
} 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 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
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 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
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 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
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 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event)
//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 {

View File

@ -197,13 +197,13 @@ QList<QAction *> WallpaperInterface::contextualActions() const
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 @@ QAction *WallpaperInterface::action(QString name) const
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);
}
}

View File

@ -33,7 +33,7 @@ int main(int argc, char **argv)
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();

View File

@ -30,7 +30,7 @@ int main(int argc, char **argv)
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();

View File

@ -127,7 +127,7 @@ void TestEngine::init()
// 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