Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 540a4b6f authored by Laurent Montel's avatar Laurent Montel 😁

Fix some clazy warning

parent 71751b04
......@@ -62,10 +62,10 @@ private Q_SLOTS:
void testSerializeList()
{
QStringList stringList;
stringList << QLatin1String("Item 1")
<< QLatin1String("Item 2")
<< QLatin1String("Item 3")
<< QLatin1String("Item 4");
stringList << QStringLiteral("Item 1")
<< QStringLiteral("Item 2")
<< QStringLiteral("Item 3")
<< QStringLiteral("Item 4");
QJsonArray arr = KScreen::ConfigSerializer::serializeList<QString>(stringList);
QCOMPARE(arr.size(), stringList.size());
......@@ -115,8 +115,8 @@ private Q_SLOTS:
void testSerializeMode()
{
KScreen::ModePtr mode(new KScreen::Mode);
mode->setId(QLatin1String("755"));
mode->setName(QLatin1String("1280x1024"));
mode->setId(QStringLiteral("755"));
mode->setName(QStringLiteral("1280x1024"));
mode->setRefreshRate(50.666);
mode->setSize(QSize(1280, 1024));
......@@ -135,23 +135,23 @@ private Q_SLOTS:
{
KScreen::ModeList modes;
KScreen::ModePtr mode(new KScreen::Mode);
mode->setId(QLatin1String("1"));
mode->setName(QLatin1String("800x600"));
mode->setId(QStringLiteral("1"));
mode->setName(QStringLiteral("800x600"));
mode->setSize(QSize(800, 600));
mode->setRefreshRate(50.4);
modes.insert(mode->id(), mode);
KScreen::OutputPtr output(new KScreen::Output);
output->setId(60);
output->setName(QLatin1String("LVDS-0"));
output->setName(QStringLiteral("LVDS-0"));
output->setType(KScreen::Output::Panel);
output->setIcon(QString());
output->setModes(modes);
output->setPos(QPoint(1280, 0));
output->setSize(mode->size());
output->setRotation(KScreen::Output::None);
output->setCurrentModeId(QLatin1String("1"));
output->setPreferredModes(QStringList() << QLatin1String("1"));
output->setCurrentModeId(QStringLiteral("1"));
output->setPreferredModes(QStringList() << QStringLiteral("1"));
output->setConnected(true);
output->setEnabled(true);
output->setPrimary(true);
......
......@@ -212,12 +212,12 @@ void testScreenConfig::configCanBeApplied()
QVERIFY(!Config::canBeApplied(brokenConfig));
primaryBroken->setConnected(currentPrimary->isConnected());
QVERIFY(!Config::canBeApplied(brokenConfig));
primaryBroken->setCurrentModeId(QLatin1String("42"));
primaryBroken->setCurrentModeId(QStringLiteral("42"));
QVERIFY(!Config::canBeApplied(brokenConfig));
primaryBroken->setCurrentModeId(currentPrimary->currentModeId());
QVERIFY(!Config::canBeApplied(brokenConfig));
qDebug() << "brokenConfig.modes" << primaryBroken->mode(QStringLiteral("3"));
primaryBroken->mode(QLatin1String("3"))->setSize(QSize(1280, 800));
primaryBroken->mode(QStringLiteral("3"))->setSize(QSize(1280, 800));
qDebug() << "brokenConfig.modes" << primaryBroken->mode(QStringLiteral("3"));
QVERIFY(Config::canBeApplied(brokenConfig));
......
......@@ -47,7 +47,7 @@ Fake::Fake()
if (qgetenv("KSCREEN_BACKEND_INPROCESS") != QByteArray("1")) {
QTimer::singleShot(0, this, SLOT(delayedInit()));
QTimer::singleShot(0, this, &Fake::delayedInit);
}
}
......@@ -65,7 +65,7 @@ void Fake::init(const QVariantMap &arguments)
void Fake::delayedInit()
{
new FakeBackendAdaptor(this);
QDBusConnection::sessionBus().registerObject(QLatin1String("/fake"), this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/fake"), this);
}
Fake::~Fake()
......@@ -79,7 +79,7 @@ QString Fake::name() const
QString Fake::serviceName() const
{
return QLatin1Literal("org.kde.KScreen.Backend.Fake");
return QStringLiteral("org.kde.KScreen.Backend.Fake");
}
ConfigPtr Fake::config() const
......
......@@ -131,7 +131,7 @@ OutputPtr Parser::outputFromJson(QMap< QString, QVariant > map)
output->setModes(modelist);
map.remove(QStringLiteral("modes"));
if(map.contains(QLatin1String("clones"))) {
if(map.contains(QStringLiteral("clones"))) {
QList<int> clones;
Q_FOREACH(const QVariant &id, map[QStringLiteral("clones")].toList()) {
clones.append(id.toInt());
......
......@@ -53,7 +53,7 @@ QString WaylandBackend::name() const
QString WaylandBackend::serviceName() const
{
return QLatin1Literal("org.kde.KScreen.Backend.KWayland");
return QStringLiteral("org.kde.KScreen.Backend.KWayland");
}
ConfigPtr WaylandBackend::config() const
......
......@@ -164,7 +164,7 @@ private:
}
}
template<typename ... Args>
constexpr xcb_window_t requestWindow(const Args & ... args) {
constexpr xcb_window_t requestWindow(const Args & ... args) const {
return std::is_same<typename std::tuple_element<0, std::tuple<Args ...>>::type, xcb_window_t>::value
? std::get<0>(std::tuple<Args ...>(args ...))
: static_cast<xcb_window_t>(XCB_WINDOW_NONE);
......
......@@ -71,12 +71,12 @@ XRandR11::~XRandR11()
QString XRandR11::name() const
{
return QLatin1Literal("XRandR 1.1");
return QStringLiteral("XRandR 1.1");
}
QString XRandR11::serviceName() const
{
return QLatin1Literal("org.kde.KScreen.Backend.XRandR11");
return QStringLiteral("org.kde.KScreen.Backend.XRandR11");
}
......@@ -120,7 +120,7 @@ KScreen::ConfigPtr XRandR11::config() const
output->setConnected(true);
output->setEnabled(true);
output->setName(QLatin1String("Default"));
output->setName(QStringLiteral("Default"));
output->setPos(QPoint(0,0));
output->setPrimary(true);
output->setRotation((KScreen::Output::Rotation) info->rotation);
......@@ -142,10 +142,10 @@ KScreen::ConfigPtr XRandR11::config() const
for (int j = 0; j < nrates; j++) {
float rate = rates[j];
mode = KScreen::ModePtr(new KScreen::Mode);
mode->setId(QString::fromLatin1("%1-%2").arg(x).arg(j));
mode->setId(QStringLiteral("%1-%2").arg(x).arg(j));
mode->setSize(QSize(size.width, size.height));
mode->setRefreshRate(rate);
mode->setName(QString::fromLatin1("%1x%2").arg(size.width).arg(size.height));
mode->setName(QStringLiteral("%1x%2").arg(size.width).arg(size.height));
if (x == info->sizeID && rate == info->rate) {
output->setCurrentModeId(mode->id());
......
......@@ -51,7 +51,7 @@ bool BackendDBusWrapper::init()
{
QDBusConnection dbus = QDBusConnection::sessionBus();
new BackendAdaptor(this);
if (!dbus.registerObject(QLatin1String("/backend"), this, QDBusConnection::ExportAdaptors)) {
if (!dbus.registerObject(QStringLiteral("/backend"), this, QDBusConnection::ExportAdaptors)) {
qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Failed to export backend to DBus: another launcher already running?";
qCWarning(KSCREEN_BACKEND_LAUNCHER) << dbus.lastError().message();
return false;
......
......@@ -63,7 +63,7 @@ bool BackendLoader::init()
{
QDBusConnection dbus = QDBusConnection::sessionBus();
new BackendLoaderAdaptor(this);
if (!dbus.registerObject(QLatin1String("/"), this, QDBusConnection::ExportAdaptors)) {
if (!dbus.registerObject(QStringLiteral("/"), this, QDBusConnection::ExportAdaptors)) {
qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Failed to export backend to DBus: another launcher already running?";
qCWarning(KSCREEN_BACKEND_LAUNCHER) << dbus.lastError().message();
return false;
......
......@@ -178,12 +178,12 @@ ConfigPtr ConfigSerializer::deserializeConfig(const QVariantMap &map)
{
ConfigPtr config(new Config);
if (map.contains(QLatin1String("features"))) {
config->setSupportedFeatures(static_cast<Config::Features>(map[QLatin1String("features")].toInt()));
if (map.contains(QStringLiteral("features"))) {
config->setSupportedFeatures(static_cast<Config::Features>(map[QStringLiteral("features")].toInt()));
}
if (map.contains(QLatin1String("outputs"))) {
const QDBusArgument &outputsArg = map[QLatin1String("outputs")].value<QDBusArgument>();
if (map.contains(QStringLiteral("outputs"))) {
const QDBusArgument &outputsArg = map[QStringLiteral("outputs")].value<QDBusArgument>();
outputsArg.beginArray();
OutputList outputs;
while (!outputsArg.atEnd()) {
......@@ -199,8 +199,8 @@ ConfigPtr ConfigSerializer::deserializeConfig(const QVariantMap &map)
config->setOutputs(outputs);
}
if (map.contains(QLatin1String("screen"))) {
const QDBusArgument &screenArg = map[QLatin1String("screen")].value<QDBusArgument>();
if (map.contains(QStringLiteral("screen"))) {
const QDBusArgument &screenArg = map[QStringLiteral("screen")].value<QDBusArgument>();
const KScreen::ScreenPtr screen = deserializeScreen(screenArg);
if (!screen) {
return ConfigPtr();
......
......@@ -132,7 +132,7 @@ bool Edid::isValid() const
QString Edid::deviceId(const QString &fallbackName) const
{
QString id = QLatin1String("xrandr");
QString id = QStringLiteral("xrandr");
// if no info was added check if the fallbacName is provided
if (vendor().isNull() && name().isNull() && serial().isNull()) {
if (!fallbackName.isEmpty()) {
......
......@@ -27,8 +27,8 @@ int main(int argc, char **argv)
KScreen::WaylandTestServer server;
QCommandLineOption config = QCommandLineOption(QStringList() << QStringLiteral("c") << QLatin1String("config"),
QStringLiteral("Config file"), QLatin1String("config"));
QCommandLineOption config = QCommandLineOption(QStringList() << QStringLiteral("c") << QStringLiteral("config"),
QStringLiteral("Config file"), QStringLiteral("config"));
QCommandLineParser parser;
parser.addHelpOption();
parser.addOption(config);
......
......@@ -38,35 +38,35 @@ QString typetoString(const Output::Type& type)
{
switch (type) {
case Output::Unknown:
return QLatin1String("Unknown");
return QStringLiteral("Unknown");
case Output::Panel:
return QLatin1String("Panel (Laptop)");
return QStringLiteral("Panel (Laptop)");
case Output::VGA:
return QLatin1String("VGA");
return QStringLiteral("VGA");
case Output::DVII:
return QLatin1String("DVI-I");
return QStringLiteral("DVI-I");
case Output::DVIA:
return QLatin1String("DVI-A");
return QStringLiteral("DVI-A");
case Output::DVID:
return QLatin1String("DVI-D");
return QStringLiteral("DVI-D");
case Output::HDMI:
return QLatin1String("HDMI");
return QStringLiteral("HDMI");
case Output::TV:
return QLatin1String("TV");
return QStringLiteral("TV");
case Output::TVComposite:
return QLatin1String("TV-Composite");
return QStringLiteral("TV-Composite");
case Output::TVSVideo:
return QLatin1String("TV-SVideo");
return QStringLiteral("TV-SVideo");
case Output::TVComponent:
return QLatin1String("TV-Component");
return QStringLiteral("TV-Component");
case Output::TVSCART:
return QLatin1String("TV-SCART");
return QStringLiteral("TV-SCART");
case Output::TVC4:
return QLatin1String("TV-C4");
return QStringLiteral("TV-C4");
case Output::DisplayPort:
return QLatin1String("DisplayPort");
return QStringLiteral("DisplayPort");
default:
return QLatin1String("Invalid Type");
return QStringLiteral("Invalid Type");
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment