From 3eaa0d6ab1c7efc0bdd91fcd789d8187c6c27678 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleixpol@kde.org>
Date: Thu, 24 Jun 2021 12:34:13 +0200
Subject: [PATCH] Bump to Qt 5.15, port away from deprecated APIs
---
CMakeLists.txt | 2 +-
README.md | 2 +-
src/auth/Auth.cpp | 6 +++---
src/auth/AuthRequest.cpp | 2 +-
src/common/ConfigReader.cpp | 4 ++--
src/daemon/PowerManager.cpp | 8 ++++++--
src/daemon/XorgDisplayServer.cpp | 17 +++++++++--------
src/greeter/GreeterProxy.cpp | 2 +-
8 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 41aee21d4..6936b31f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,7 +96,7 @@ find_package(XCB REQUIRED)
find_package(XKB REQUIRED)
# Qt 5
-find_package(Qt5 5.8.0 CONFIG REQUIRED Core DBus Gui Qml Quick LinguistTools Test)
+find_package(Qt5 5.15.0 CONFIG REQUIRED Core DBus Gui Qml Quick LinguistTools Test)
# find qt5 imports dir
get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
diff --git a/README.md b/README.md
index 7c7a55588..97cb2221c 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ money that can be used to support the features that you most desire.
## INSTALLATION
-Qt >= 5.8.0 is required to use SDDM.
+Qt >= 5.15.0 is required to use SDDM.
SDDM runs the greeter as a system user named "sddm" whose home directory needs
to be set to `/var/lib/sddm`.
diff --git a/src/auth/Auth.cpp b/src/auth/Auth.cpp
index 4450cc606..1dc2dd186 100644
--- a/src/auth/Auth.cpp
+++ b/src/auth/Auth.cpp
@@ -134,7 +134,7 @@ namespace SDDM {
env.insert(QStringLiteral("LANG"), QStringLiteral("C"));
child->setProcessEnvironment(env);
connect(child, QOverload<int,QProcess::ExitStatus>::of(&QProcess::finished), this, &Auth::Private::childExited);
- connect(child, QOverload<QProcess::ProcessError>::of(&QProcess::error), this, &Auth::Private::childError);
+ connect(child, &QProcess::errorOccurred, this, &Auth::Private::childError);
connect(request, &AuthRequest::finished, this, &Auth::Private::requestFinished);
connect(request, &AuthRequest::promptsChanged, parent, &Auth::requestChanged);
}
@@ -267,8 +267,8 @@ namespace SDDM {
}
void Auth::registerTypes() {
- qmlRegisterType<AuthPrompt>();
- qmlRegisterType<AuthRequest>();
+ qmlRegisterAnonymousType<AuthPrompt>("Auth", 1);
+ qmlRegisterAnonymousType<AuthRequest>("Auth", 1);
qmlRegisterType<Auth>("Auth", 1, 0, "Auth");
}
diff --git a/src/auth/AuthRequest.cpp b/src/auth/AuthRequest.cpp
index 9583b0a4d..9ccc2d259 100644
--- a/src/auth/AuthRequest.cpp
+++ b/src/auth/AuthRequest.cpp
@@ -73,7 +73,7 @@ namespace SDDM {
}
QQmlListProperty<AuthPrompt> AuthRequest::promptsDecl() {
- return QQmlListProperty<AuthPrompt>(this, d->prompts);
+ return QQmlListProperty<AuthPrompt>(this, &d->prompts);
}
void AuthRequest::done() {
diff --git a/src/common/ConfigReader.cpp b/src/common/ConfigReader.cpp
index 041e5ed22..503b55e69 100644
--- a/src/common/ConfigReader.cpp
+++ b/src/common/ConfigReader.cpp
@@ -265,7 +265,7 @@ namespace SDDM {
QByteArray junk;
// stores the junk to the temporary storage
auto collectJunk = [&junk](const QString &data) {
- junk.append(data);
+ junk.append(data.toUtf8());
};
// a short function to assign the current junk and current line to the right section, eventually create a new one
@@ -275,7 +275,7 @@ namespace SDDM {
sectionData[currentSection] = QByteArray();
}
sectionData[currentSection].append(junk);
- sectionData[currentSection].append(data);
+ sectionData[currentSection].append(data.toUtf8());
junk.clear();
};
diff --git a/src/daemon/PowerManager.cpp b/src/daemon/PowerManager.cpp
index 6eca29f55..ab1d6ac03 100644
--- a/src/daemon/PowerManager.cpp
+++ b/src/daemon/PowerManager.cpp
@@ -87,11 +87,15 @@ const QString UPOWER_OBJECT = QStringLiteral("org.freedesktop.UPower");
}
void powerOff() const {
- QProcess::execute(mainConfig.HaltCommand.get());
+ auto command = QProcess::splitCommand(mainConfig.HaltCommand.get());
+ const QString program = command.takeFirst();
+ QProcess::execute(program, command);
}
void reboot() const {
- QProcess::execute(mainConfig.RebootCommand.get());
+ auto command = QProcess::splitCommand(mainConfig.RebootCommand.get());
+ const QString program = command.takeFirst();
+ QProcess::execute(program, command);
}
void suspend() const {
diff --git a/src/daemon/XorgDisplayServer.cpp b/src/daemon/XorgDisplayServer.cpp
index fc61ee2dd..13a1691b8 100644
--- a/src/daemon/XorgDisplayServer.cpp
+++ b/src/daemon/XorgDisplayServer.cpp
@@ -110,7 +110,7 @@ namespace SDDM {
QStringList args;
if (!daemonApp->testing()) {
process->setProgram(mainConfig.X11.ServerPath.get());
- args << mainConfig.X11.ServerArguments.get().split(QLatin1Char(' '), QString::SkipEmptyParts)
+ args << mainConfig.X11.ServerArguments.get().split(QLatin1Char(' '), Qt::SkipEmptyParts)
<< QStringLiteral("-background") << QStringLiteral("none")
<< QStringLiteral("-seat") << displayPtr()->seat()->name()
<< QStringLiteral("vt%1").arg(displayPtr()->terminalId());
@@ -221,7 +221,7 @@ namespace SDDM {
// log message
qDebug() << "Display server stopped.";
- QString displayStopCommand = mainConfig.X11.DisplayStopCommand.get();
+ QStringList displayStopCommand = QProcess::splitCommand(mainConfig.X11.DisplayStopCommand.get());
// create display setup script process
QProcess *displayStopScript = new QProcess();
@@ -236,7 +236,8 @@ namespace SDDM {
// start display stop script
qDebug() << "Running display stop script " << displayStopCommand;
- displayStopScript->start(displayStopCommand);
+ const auto program = displayStopCommand.takeFirst();
+ displayStopScript->start(program, displayStopCommand);
// wait for finished
if (!displayStopScript->waitForFinished(5000))
@@ -254,8 +255,6 @@ namespace SDDM {
}
void XorgDisplayServer::setupDisplay() {
- QString displayCommand = mainConfig.X11.DisplayCommand.get();
-
// create cursor setup process
QProcess *setCursor = new QProcess();
// create display setup script process
@@ -273,7 +272,7 @@ namespace SDDM {
displayScript->setProcessEnvironment(env);
qDebug() << "Setting default cursor";
- setCursor->start(QStringLiteral("xsetroot -cursor_name left_ptr"));
+ setCursor->start(QStringLiteral("xsetroot"), { QStringLiteral("-cursor_name"), QStringLiteral("left_ptr") });
// delete setCursor on finish
connect(setCursor, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), setCursor, &QProcess::deleteLater);
@@ -285,8 +284,10 @@ namespace SDDM {
}
// start display setup script
- qDebug() << "Running display setup script " << displayCommand;
- displayScript->start(displayCommand);
+ qDebug() << "Running display setup script " << mainConfig.X11.DisplayCommand.get();
+ QStringList displayCommand = QProcess::splitCommand(mainConfig.X11.DisplayCommand.get());
+ const QString program = displayCommand.takeFirst();
+ displayScript->start(program, displayCommand);
// delete displayScript on finish
connect(displayScript, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), displayScript, &QProcess::deleteLater);
diff --git a/src/greeter/GreeterProxy.cpp b/src/greeter/GreeterProxy.cpp
index 8fde3d904..d6e62cc75 100644
--- a/src/greeter/GreeterProxy.cpp
+++ b/src/greeter/GreeterProxy.cpp
@@ -46,7 +46,7 @@ namespace SDDM {
connect(d->socket, &QLocalSocket::connected, this, &GreeterProxy::connected);
connect(d->socket, &QLocalSocket::disconnected, this, &GreeterProxy::disconnected);
connect(d->socket, &QLocalSocket::readyRead, this, &GreeterProxy::readyRead);
- connect(d->socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error), this, &GreeterProxy::error);
+ connect(d->socket, &QLocalSocket::errorOccurred, this, &GreeterProxy::error);
// connect to server
d->socket->connectToServer(socket);