Commit 973bef83 authored by Frederik Gladhorn's avatar Frederik Gladhorn

Clean up string casts

Summary:
Compile without casting to/from ascii to avoid typical mistakes due to
implicit conversions. Fix a bunch of dubious places.

Test Plan: Things compile, tests run.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: zzag, anthonyfieroni, broulik, davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D14060
parent 967f21ac
......@@ -40,6 +40,15 @@ add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt
# library setup
add_definitions(
-DQT_USE_QSTRINGBUILDER
-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_STRICT_ITERATORS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
)
set(KF5_VERSION ${PROJECT_VERSION}) #When we are happy with the api, we can sync with frameworks
ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KSCREEN
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kscreen_version.h"
......
......@@ -101,7 +101,7 @@ void TestBackendLoader::testFallback()
{
qputenv("KSCREEN_BACKEND", "nonsense");
auto preferred = BackendManager::instance()->preferredBackend();
QVERIFY(preferred.fileName().startsWith("KSC_QScreen"));
QVERIFY(preferred.fileName().startsWith(QLatin1String("KSC_QScreen")));
}
QTEST_GUILESS_MAIN(TestBackendLoader)
......
......@@ -76,7 +76,7 @@ testWaylandBackend::testWaylandBackend(QObject *parent)
{
qputenv("KSCREEN_LOGGING", "false");
m_server = new WaylandTestServer(this);
m_server->setConfig(TEST_DATA + QStringLiteral("multipleoutput.json"));
m_server->setConfig(QLatin1String(TEST_DATA) + QLatin1String("multipleoutput.json"));
}
void testWaylandBackend::initTestCase()
......@@ -85,7 +85,7 @@ void testWaylandBackend::initTestCase()
KScreen::BackendManager::instance()->shutdownBackend();
// This is how KWayland will pick up the right socket,
// and thus connect to our internal test server.
setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit(), 1);
setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit().constData(), 1);
m_server->start();
GetConfigOperation *op = new GetConfigOperation();
......
......@@ -75,7 +75,7 @@ void TestKWaylandConfig::initTestCase()
// This is how KWayland will pick up the right socket,
// and thus connect to our internal test server.
setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit(), 1);
setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit().constData(), 1);
m_server = new WaylandTestServer(this);
m_server->start();
......@@ -105,7 +105,7 @@ void TestKWaylandConfig::changeConfig()
auto output = config->outputs().first();
QVERIFY(output->isEnabled() == false);
output->setEnabled(true);
output->setCurrentModeId("76");
output->setCurrentModeId(QStringLiteral("76"));
auto output2 = config->outputs()[2]; // is this id stable enough?
output2->setPos(QPoint(4000, 1080));
......
......@@ -64,7 +64,7 @@ TestDpmsClient::TestDpmsClient(QObject *parent)
: QObject(parent)
, m_server(nullptr)
{
setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit(), 1);
setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit().constData(), true);
m_server = new KScreen::WaylandTestServer(this);
m_server->start();
}
......
......@@ -49,7 +49,7 @@ private:
void TestLog::init()
{
QStandardPaths::setTestModeEnabled(true);
m_defaultLogFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kscreen/kscreen.log";
m_defaultLogFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kscreen/kscreen.log");
}
void TestLog::initTestCase()
......@@ -66,7 +66,7 @@ void TestLog::cleanupTestCase()
void TestLog::testContext()
{
auto log = Log::instance();
QString ctx("context text");
QString ctx = QStringLiteral("context text");
QVERIFY(log != nullptr);
log->setContext(ctx);
QCOMPARE(log->context(), ctx);
......@@ -108,7 +108,7 @@ void TestLog::testLog()
lf.remove();
QVERIFY(!lf.exists());
QString logmsg("This is a log message. ♥");
QString logmsg = QStringLiteral("This is a log message. ♥");
Log::log(logmsg);
QVERIFY(lf.exists());
......
......@@ -59,7 +59,7 @@ void testQScreenBackend::initTestCase()
qputenv("KSCREEN_BACKEND_INPROCESS", "1");
KScreen::BackendManager::instance()->shutdownBackend();
m_backend = qgetenv("KSCREEN_BACKEND").constData();
m_backend = QString::fromLocal8Bit(qgetenv("KSCREEN_BACKEND"));
QElapsedTimer t;
t.start();
......@@ -172,16 +172,15 @@ void testQScreenBackend::commonUsagePattern()
}
QVariantMap info;
info["id"] = output->id();
info["primary"] = output->isPrimary();
info["enabled"] = output->isEnabled();
info["rotation"] = output->rotation();
info[QStringLiteral("id")] = output->id();
info[QStringLiteral("primary")] = output->isPrimary();
info[QStringLiteral("enabled")] = output->isEnabled();
info[QStringLiteral("rotation")] = output->rotation();
QVariantMap pos;
pos["x"] = output->pos().x();
pos["y"] = output->pos().y();
info["pos"] = pos;
pos[QStringLiteral("x")] = output->pos().x();
pos[QStringLiteral("y")] = output->pos().y();
info[QStringLiteral("pos")] = pos;
if (output->isEnabled()) {
const KScreen::ModePtr mode = output->currentMode();
......@@ -191,14 +190,14 @@ void testQScreenBackend::commonUsagePattern()
}
QVariantMap modeInfo;
modeInfo["refresh"] = mode->refreshRate();
modeInfo[QStringLiteral("refresh")] = mode->refreshRate();
QVariantMap modeSize;
modeSize["width"] = mode->size().width();
modeSize["height"] = mode->size().height();
modeInfo["size"] = modeSize;
modeSize[QStringLiteral("width")] = mode->size().width();
modeSize[QStringLiteral("height")] = mode->size().height();
modeInfo[QStringLiteral("size")] = modeSize;
info["mode"] = modeInfo;
info[QStringLiteral("mode")] = modeInfo;
}
outputList.append(info);
......
......@@ -101,7 +101,7 @@ void testScreenConfig::singleOutput()
const OutputPtr output = config->outputs().take(1);
QVERIFY(!output.isNull());
QCOMPARE(output->name(), QString("LVDS1"));
QCOMPARE(output->name(), QLatin1String("LVDS1"));
QCOMPARE(output->type(), Output::Panel);
QCOMPARE(output->modes().count(), 3);
QCOMPARE(output->pos(), QPoint(0, 0));
......@@ -152,7 +152,7 @@ void testScreenConfig::multiOutput()
const OutputPtr output = config->outputs().take(2);
QVERIFY(!output.isNull());
QCOMPARE(output->name(), QString("HDMI1"));
QCOMPARE(output->name(), QStringLiteral("HDMI1"));
QCOMPARE(output->type(), Output::HDMI);
QCOMPARE(output->modes().count(), 4);
QCOMPARE(output->pos(), QPoint(1280, 0));
......@@ -216,9 +216,9 @@ void testScreenConfig::configCanBeApplied()
QVERIFY(!Config::canBeApplied(brokenConfig));
primaryBroken->setCurrentModeId(currentPrimary->currentModeId());
QVERIFY(!Config::canBeApplied(brokenConfig));
qDebug() << "brokenConfig.modes" << primaryBroken->mode("3");
qDebug() << "brokenConfig.modes" << primaryBroken->mode(QStringLiteral("3"));
primaryBroken->mode(QLatin1String("3"))->setSize(QSize(1280, 800));
qDebug() << "brokenConfig.modes" << primaryBroken->mode("3");
qDebug() << "brokenConfig.modes" << primaryBroken->mode(QStringLiteral("3"));
QVERIFY(Config::canBeApplied(brokenConfig));
......@@ -270,7 +270,7 @@ void testScreenConfig::supportedFeatures()
void testScreenConfig::testInvalidMode()
{
ModeList modes;
ModePtr invalidMode = modes.value("99");
ModePtr invalidMode = modes.value(QStringLiteral("99"));
QVERIFY(invalidMode.isNull());
auto output = new KScreen::Output();
......
......@@ -74,7 +74,7 @@ Fake::~Fake()
QString Fake::name() const
{
return QString("Fake");
return QStringLiteral("Fake");
}
QString Fake::serviceName() const
......@@ -112,14 +112,14 @@ QByteArray Fake::edid(int outputId) const
const QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll());
const QJsonObject json = jsonDoc.object();
const QJsonArray outputs = json["outputs"].toArray();
const QJsonArray outputs = json[QStringLiteral("outputs")].toArray();
Q_FOREACH(const QJsonValue &value, outputs) {
const QVariantMap output = value.toObject().toVariantMap();
if (output["id"].toInt() != outputId) {
if (output[QStringLiteral("id")].toInt() != outputId) {
continue;
}
return QByteArray::fromBase64(output["edid"].toByteArray());
return QByteArray::fromBase64(output[QStringLiteral("edid")].toByteArray());
}
return QByteArray();
}
......
......@@ -38,10 +38,10 @@ ConfigPtr Parser::fromJson(const QByteArray& data)
const QJsonObject json = QJsonDocument::fromJson(data).object();
ScreenPtr screen = Parser::screenFromJson(json["screen"].toObject().toVariantMap());
ScreenPtr screen = Parser::screenFromJson(json[QStringLiteral("screen")].toObject().toVariantMap());
config->setScreen(screen);
const QVariantList outputs = json["outputs"].toArray().toVariantList();
const QVariantList outputs = json[QStringLiteral("outputs")].toArray().toVariantList();
if (outputs.isEmpty()) {
return config;
}
......@@ -71,11 +71,11 @@ ConfigPtr Parser::fromJson(const QString& path)
ScreenPtr Parser::screenFromJson(const QVariantMap &data)
{
ScreenPtr screen(new Screen);
screen->setId(data["id"].toInt());
screen->setMinSize(Parser::sizeFromJson(data["minSize"].toMap()));
screen->setMaxSize(Parser::sizeFromJson(data["maxSize"].toMap()));
screen->setCurrentSize(Parser::sizeFromJson(data["currentSize"].toMap()));
screen->setMaxActiveOutputsCount(data["maxActiveOutputsCount"].toInt());
screen->setId(data[QStringLiteral("id")].toInt());
screen->setMinSize(Parser::sizeFromJson(data[QStringLiteral("minSize")].toMap()));
screen->setMaxSize(Parser::sizeFromJson(data[QStringLiteral("maxSize")].toMap()));
screen->setCurrentSize(Parser::sizeFromJson(data[QStringLiteral("currentSize")].toMap()));
screen->setMaxActiveOutputsCount(data[QStringLiteral("maxActiveOutputsCount")].toInt());
return screen;
}
......@@ -95,15 +95,15 @@ void Parser::qvariant2qobject(const QVariantMap &variant, QObject *object)
continue;
}
const QVariant property = object->property(iter.key().toLatin1());
const QVariant property = object->property(iter.key().toLatin1().constData());
Q_ASSERT(property.isValid());
if (property.isValid()) {
QVariant value = iter.value();
if (value.canConvert(property.type())) {
value.convert(property.type());
object->setProperty(iter.key().toLatin1(), value);
object->setProperty(iter.key().toLatin1().constData(), value);
} else if (QString(QLatin1String("QVariant")).compare(QLatin1String(property.typeName())) == 0) {
object->setProperty(iter.key().toLatin1(), value);
object->setProperty(iter.key().toLatin1().constData(), value);
}
}
}
......@@ -112,36 +112,36 @@ void Parser::qvariant2qobject(const QVariantMap &variant, QObject *object)
OutputPtr Parser::outputFromJson(QMap< QString, QVariant > map)
{
OutputPtr output(new Output);
output->setId(map["id"].toInt());
output->setId(map[QStringLiteral("id")].toInt());
QStringList preferredModes;
const QVariantList prefModes = map["preferredModes"].toList();
const QVariantList prefModes = map[QStringLiteral("preferredModes")].toList();
Q_FOREACH(const QVariant &mode, prefModes) {
preferredModes.append(mode.toString());
}
output->setPreferredModes(preferredModes);
map.remove(QLatin1Literal("preferredModes"));
map.remove(QStringLiteral("preferredModes"));
ModeList modelist;
const QVariantList modes = map["modes"].toList();
const QVariantList modes = map[QStringLiteral("modes")].toList();
Q_FOREACH(const QVariant &modeValue, modes) {
const ModePtr mode = Parser::modeFromJson(modeValue);
modelist.insert(mode->id(), mode);
}
output->setModes(modelist);
map.remove(QLatin1Literal("modes"));
map.remove(QStringLiteral("modes"));
if(map.contains("clones")) {
if(map.contains(QLatin1String("clones"))) {
QList<int> clones;
Q_FOREACH(const QVariant &id, map["clones"].toList()) {
Q_FOREACH(const QVariant &id, map[QStringLiteral("clones")].toList()) {
clones.append(id.toInt());
}
output->setClones(clones);
map.remove(QLatin1Literal("clones"));
map.remove(QStringLiteral("clones"));
}
const QString type = map["type"].toByteArray().toUpper();
const QByteArray type = map[QStringLiteral("type")].toByteArray().toUpper();
if (type.contains("LVDS") || type.contains("EDP") || type.contains("IDP") || type.contains("7")) {
output->setType(Output::Panel);
} else if (type.contains("VGA")) {
......@@ -177,26 +177,27 @@ OutputPtr Parser::outputFromJson(QMap< QString, QVariant > map)
} else {
qCWarning(KSCREEN_FAKE) << "Output Type not translated:" << type;
}
map.remove(QLatin1Literal("type"));
map.remove(QStringLiteral("type"));
if (map.contains("pos")) {
output->setPos(Parser::pointFromJson(map["pos"].toMap()));
map.remove(QLatin1Literal("pos"));
if (map.contains(QStringLiteral("pos"))) {
output->setPos(Parser::pointFromJson(map[QStringLiteral("pos")].toMap()));
map.remove(QStringLiteral("pos"));
}
if (map.contains("size")) {
output->setSize(Parser::sizeFromJson(map["size"].toMap()));
map.remove(QLatin1Literal("size"));
if (map.contains(QStringLiteral("size"))) {
output->setSize(Parser::sizeFromJson(map[QStringLiteral("size")].toMap()));
map.remove(QStringLiteral("size"));
}
if (map.contains("scale")) {
qDebug() << "Scale found:" << map["scale"].toReal();
output->setScale(map["scale"].toReal());
map.remove(QLatin1Literal("scale"));
auto scale = QStringLiteral("scale");
if (map.contains(scale)) {
qDebug() << "Scale found:" << map[scale].toReal();
output->setScale(map[scale].toReal());
map.remove(scale);
}
//Remove some extra properties that we do not want or need special treatment
map.remove(QLatin1Literal("edid"));
map.remove(QStringLiteral("edid"));
Parser::qvariant2qobject(map, output.data());
return output;
......@@ -208,7 +209,7 @@ ModePtr Parser::modeFromJson(const QVariant& data)
ModePtr mode(new Mode);
Parser::qvariant2qobject(map, mode.data());
mode->setSize(Parser::sizeFromJson(map["size"].toMap()));
mode->setSize(Parser::sizeFromJson(map[QStringLiteral("size")].toMap()));
return mode;
}
......@@ -218,8 +219,8 @@ QSize Parser::sizeFromJson(const QVariant& data)
const QVariantMap map = data.toMap();
QSize size;
size.setWidth(map["width"].toInt());
size.setHeight(map["height"].toInt());
size.setWidth(map[QStringLiteral("width")].toInt());
size.setHeight(map[QStringLiteral("height")].toInt());
return size;
}
......@@ -229,8 +230,8 @@ QPoint Parser::pointFromJson(const QVariant& data)
const QVariantMap map = data.toMap();
QPoint point;
point.setX(map["x"].toInt());
point.setY(map["y"].toInt());
point.setX(map[QStringLiteral("x")].toInt());
point.setY(map[QStringLiteral("y")].toInt());
return point;
}
......
......@@ -189,7 +189,7 @@ QString WaylandOutput::name() const
QDebug operator<<(QDebug dbg, const WaylandOutput *output)
{
dbg << "WaylandOutput(Id:" << output->id() <<", Name:" << \
QString(output->outputDevice()->manufacturer() + QStringLiteral(" ") + \
QString(output->outputDevice()->manufacturer() + QLatin1Char(' ') + \
output->outputDevice()->model()) << ")";
return dbg;
}
......@@ -45,12 +45,12 @@ QScreenBackend::~QScreenBackend()
QString QScreenBackend::name() const
{
return QString("QScreen");
return QStringLiteral("QScreen");
}
QString QScreenBackend::serviceName() const
{
return QLatin1Literal("org.kde.KScreen.Backend.QScreen");
return QStringLiteral("org.kde.KScreen.Backend.QScreen");
}
......
......@@ -101,8 +101,8 @@ void QScreenOutput::updateKScreenOutput(OutputPtr &output) const
mode->setRefreshRate(m_qscreen->refreshRate());
mode->setSize(m_qscreen->size());
const QString modename = QString::number(m_qscreen->size().width()) + QStringLiteral("x") + QString::number(m_qscreen->size().height()) \
+ QStringLiteral("@") + QString::number(m_qscreen->refreshRate());
const QString modename = QString::number(m_qscreen->size().width()) + QLatin1String("x") + QString::number(m_qscreen->size().height()) \
+ QLatin1String("@") + QString::number(m_qscreen->refreshRate());
mode->setName(modename);
ModeList modes;
......
......@@ -33,35 +33,35 @@ KScreen::Output::Type Utils::guessOutputType(const QString &type, const QString
}
}
if (type.contains("VGA")) {
if (type.contains(QLatin1String("VGA"))) {
return KScreen::Output::VGA;
} else if (type.contains("DVI")) {
} else if (type.contains(QLatin1String("DVI"))) {
return KScreen::Output::DVI;
} else if (type.contains("DVI-I")) {
} else if (type.contains(QLatin1String("DVI-I"))) {
return KScreen::Output::DVII;
} else if (type.contains("DVI-A")) {
} else if (type.contains(QLatin1String("DVI-A"))) {
return KScreen::Output::DVIA;
} else if (type.contains("DVI-D")) {
} else if (type.contains(QLatin1String("DVI-D"))) {
return KScreen::Output::DVID;
} else if (type.contains("HDMI")) {
} else if (type.contains(QLatin1String("HDMI"))) {
return KScreen::Output::HDMI;
} else if (type.contains("Panel")) {
} else if (type.contains(QLatin1String("Panel"))) {
return KScreen::Output::Panel;
} else if (type.contains("TV-Composite")) {
} else if (type.contains(QLatin1String("TV-Composite"))) {
return KScreen::Output::TVComposite;
} else if (type.contains("TV-SVideo")) {
} else if (type.contains(QLatin1String("TV-SVideo"))) {
return KScreen::Output::TVSVideo;
} else if (type.contains("TV-Component")) {
} else if (type.contains(QLatin1String("TV-Component"))) {
return KScreen::Output::TVComponent;
} else if (type.contains("TV-SCART")) {
} else if (type.contains(QLatin1String("TV-SCART"))) {
return KScreen::Output::TVSCART;
} else if (type.contains("TV-C4")) {
} else if (type.contains(QLatin1String("TV-C4"))) {
return KScreen::Output::TVC4;
} else if (type.contains("TV")) {
} else if (type.contains(QLatin1String("TV"))) {
return KScreen::Output::TV;
} else if (type.contains("DisplayPort") || type.startsWith("DP")) {
} else if (type.contains(QLatin1String("DisplayPort")) || type.startsWith(QLatin1String("DP"))) {
return KScreen::Output::DisplayPort;
} else if (type.contains("unknown")) {
} else if (type.contains(QLatin1String("unknown"))) {
return KScreen::Output::Unknown;
} else {
return KScreen::Output::Unknown;
......
......@@ -96,34 +96,34 @@ QString XCBEventListener::rotationToString(xcb_randr_rotation_t rotation)
{
switch (rotation) {
case XCB_RANDR_ROTATION_ROTATE_0:
return "Rotate_0";
return QStringLiteral("Rotate_0");
case XCB_RANDR_ROTATION_ROTATE_90:
return "Rotate_90";
return QStringLiteral("Rotate_90");
case XCB_RANDR_ROTATION_ROTATE_180:
return "Rotate_180";
return QStringLiteral("Rotate_180");
case XCB_RANDR_ROTATION_ROTATE_270:
return "Rotate_270";
return QStringLiteral("Rotate_270");
case XCB_RANDR_ROTATION_REFLECT_X:
return "Reflect_X";
return QStringLiteral("Reflect_X");
case XCB_RANDR_ROTATION_REFLECT_Y:
return "REflect_Y";
return QStringLiteral("REflect_Y");
}
return QString("invalid value (%1)").arg(rotation);
return QStringLiteral("invalid value (%1)").arg(rotation);
}
QString XCBEventListener::connectionToString(xcb_randr_connection_t connection)
{
switch (connection) {
case XCB_RANDR_CONNECTION_CONNECTED:
return "Connected";
return QStringLiteral("Connected");
case XCB_RANDR_CONNECTION_DISCONNECTED:
return "Disconnected";
return QStringLiteral("Disconnected");
case XCB_RANDR_CONNECTION_UNKNOWN:
return "UnknownConnection";
return QStringLiteral("UnknownConnection");
}
return QString("invalid value (%1)").arg(connection);
return QStringLiteral("invalid value (%1)").arg(connection);
}
bool XCBEventListener::nativeEventFilter(const QByteArray& eventType, void* message, long int* result)
......
......@@ -247,9 +247,9 @@ void XRandROutput::updateModes(const XCB::OutputInfo &outputInfo)
KScreen::Output::Type XRandROutput::fetchOutputType(xcb_randr_output_t outputId, const QString &name)
{
QByteArray type = typeFromProperty(outputId);
QString type = QString::fromUtf8(typeFromProperty(outputId));
if (type.isEmpty()) {
type = name.toLocal8Bit();
type = name;
}
return Utils::guessOutputType(type, name);
......
......@@ -171,7 +171,7 @@ void XRandR11::setConfig(const KScreen::ConfigPtr &config)
const XCB::ScreenInfo info(xcbScreen->root);
xcb_generic_error_t *err;
const int sizeId = mode->id().split("-").first().toInt();
const int sizeId = mode->id().split(QLatin1Char('-')).first().toInt();
auto cookie = xcb_randr_set_screen_config(XCB::connection(), xcbScreen->root,
XCB_CURRENT_TIME, info->config_timestamp, sizeId,
(short) output->rotation(), mode->refreshRate());
......
......@@ -145,7 +145,7 @@ QFileInfo BackendManager::preferredBackend(const QString &backend)
*
*/
QString backendFilter;
const auto env_kscreen_backend = qgetenv("KSCREEN_BACKEND");
const auto env_kscreen_backend = QString::fromUtf8(qgetenv("KSCREEN_BACKEND"));
if (!backend.isEmpty()) {
backendFilter = backend;
} else if (!env_kscreen_backend.isEmpty()) {
......@@ -234,10 +234,11 @@ KScreen::AbstractBackend *BackendManager::loadBackendInProcess(const QString &na
if (mLoader == nullptr) {
mLoader = new QPluginLoader(this);
}
auto test_data_equals = QStringLiteral("TEST_DATA=");
QVariantMap arguments;
auto beargs = QString::fromLocal8Bit(qgetenv("KSCREEN_BACKEND_ARGS"));
if (beargs.startsWith("TEST_DATA=")) {
arguments["TEST_DATA"] = beargs.remove("TEST_DATA=");
if (beargs.startsWith(test_data_equals)) {
arguments[QStringLiteral("TEST_DATA")] = beargs.remove(test_data_equals);
}
auto backend = BackendManager::loadBackendPlugin(mLoader, name, arguments);
//qCDebug(KSCREEN) << "Connecting ConfigMonitor to backend.";
......@@ -271,7 +272,7 @@ void BackendManager::requestBackend()
if (pos == -1) {
continue;
}
arguments.insert(arg.left(pos), arg.mid(pos + 1));
arguments.insert(QString::fromUtf8(arg.left(pos)), arg.mid(pos + 1));
}
}
......
......@@ -134,7 +134,7 @@ KScreen::AbstractBackend* ConfigOperationPrivate::loadBackend()
{
Q_ASSERT(BackendManager::instance()->method() == BackendManager::InProcess);
Q_Q(ConfigOperation);
const QString &name = qgetenv("KSCREEN_BACKEND").constData();
const QString &name = QString::fromUtf8(qgetenv("KSCREEN_BACKEND"));
auto backend = KScreen::BackendManager::instance()->loadBackendInProcess(name);
if (backend == nullptr) {
const QString &e = QStringLiteral("Plugin does not provide valid KScreen backend");
......
......@@ -79,10 +79,10 @@ Doctor::~Doctor()
void Doctor::start(QCommandLineParser *parser)
{
m_parser = parser;
if (m_parser->isSet("info")) {
if (m_parser->isSet(QStringLiteral("info"))) {
showBackends();
}
if (parser->isSet("json") || parser->isSet("outputs") || !m_positionalArgs.isEmpty()) {
if (parser->isSet(QStringLiteral("json")) || parser->isSet(QStringLiteral("outputs")) || !m_positionalArgs.isEmpty()) {
KScreen::GetConfigOperation *op = new KScreen::GetConfigOperation();
connect(op, &KScreen::GetConfigOperation::finished, this,
......@@ -91,7 +91,7 @@ void Doctor::start(QCommandLineParser *parser)
});
return;
}
if (m_parser->isSet("dpms")) {
if (m_parser->isSet(QStringLiteral("dpms"))) {
if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"))) {
cerr << "DPMS is only supported on Wayland." << endl;
// We need to kick the event loop, otherwise .quit() hangs
......@@ -111,7 +111,7 @@ void Doctor::start(QCommandLineParser *parser)
return;
}
if (m_parser->isSet("log")) {
if (m_parser->isSet(QStringLiteral("log"))) {
const QString logmsg = m_parser->value(QStringLiteral("log"));
if (!Log::instance()->enabled()) {
......@@ -156,14 +156,14 @@ void Doctor::showDpms()
void Doctor::showBackends() const
{
cout << "Environment: " << endl;
auto env_kscreen_backend = (qgetenv("KSCREEN_BACKEND").isEmpty()) ? QStringLiteral("[not set]") : qgetenv("KSCREEN_BACKEND");
auto env_kscreen_backend = (qgetenv("KSCREEN_BACKEND").isEmpty()) ? QStringLiteral("[not set]") : QString::fromUtf8(qgetenv("KSCREEN_BACKEND"));
cout << " * KSCREEN_BACKEND : " << env_kscreen_backend << endl;
auto env_kscreen_backend_inprocess = (qgetenv("KSCREEN_BACKEND_INPROCESS").isEmpty()) ? QStringLiteral("[not set]") : qgetenv("KSCREEN_BACKEND_INPROCESS");
auto env_kscreen_backend_inprocess = (qgetenv("KSCREEN_BACKEND_INPROCESS").isEmpty()) ? QStringLiteral("[not set]") : QString::fromUtf8(qgetenv("KSCREEN_BACKEND_INPROCESS"));
cout << " * KSCREEN_BACKEND_INPROCESS : " << env_kscreen_backend_inprocess << endl;
auto env_kscreen_logging = (qgetenv("KSCREEN_LOGGING").isEmpty()) ? QStringLiteral("[not set]") : qgetenv("KSCREEN_LOGGING");
auto env_kscreen_logging = (qgetenv("KSCREEN_LOGGING").isEmpty()) ? QStringLiteral("[not set]") : QString::fromUtf8(qgetenv("KSCREEN_LOGGING"));
cout << " * KSCREEN_LOGGING : " << env_kscreen_logging << endl;
cout << "Logging to : " << (Log::instance()->enabled() ? Log::instance()->logFile() : "[logging disabled]") << endl;
cout << "Logging to : " << (Log::instance()->enabled() ? Log::instance()->logFile() : QStringLiteral("[logging disabled]")) << endl;
auto backends = BackendManager::instance()->listBackends();
auto preferred = BackendManager::instance()->preferredBackend();
cout << "Preferred KScreen backend : " << green << preferred.fileName() << cr << endl;
......@@ -187,7 +187,7 @@ void Doctor::parsePositionalArgs()
{
//qCDebug(KSCREEN_DOCTOR) << "POSARGS" << m_positionalArgs;
Q_FOREACH(const QString &op, m_positionalArgs) {
auto ops = op.split('.');
auto ops = op.split(QLatin1Char('.'));
if (ops.count() > 2) {
bool ok;
int output_id = -1;
......@@ -225,7 +225,7 @@ void Doctor::parsePositionalArgs()
qCDebug(KSCREEN_DOCTOR) << "Output" << output_id << "set mode" << mode_id;
} else if (ops.count() == 4 && ops[2] == QStringLiteral("position")) {
QStringList _pos = ops[3].split(',');
QStringList _pos = ops[3].split(QLatin1Char(','));
if (_pos.count() != 2) {