Skip to content

Commit 9c3a3ec

Browse files
committed
QtService: support qt6
Change-Id: I1a2aa1cb83e7cbff96ba1d4f3bd2cc7d8c0756cd
1 parent 67af2fe commit 9c3a3ec

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

qtservice/examples/interactive/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
****************************************************************************/
4040

4141
#include <QApplication>
42+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
4243
#include <QDesktopWidget>
44+
#endif
4345
#include <QLabel>
4446
#include <QDir>
4547
#include <QSettings>
@@ -87,7 +89,9 @@ void InteractiveService::start()
8789
qApp->setQuitOnLastWindowClosed(false);
8890

8991
gui = new QLabel("Service", 0, Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
92+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
9093
gui->move(QApplication::desktop()->availableGeometry().topLeft());
94+
#endif
9195
gui->show();
9296
}
9397

qtservice/examples/server/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
#include <QStringList>
4747
#include <QDir>
4848
#include <QSettings>
49-
49+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
50+
#include <QRegularExpression>
51+
#endif
5052
#include "qtservice.h"
5153

5254
// HttpDaemon is the the class that implements the simple HTTP server.
@@ -98,7 +100,13 @@ private slots:
98100
// document back.
99101
QTcpSocket* socket = (QTcpSocket*)sender();
100102
if (socket->canReadLine()) {
101-
QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
103+
104+
QStringList tokens;
105+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
106+
tokens = QString(socket->readLine()).split(QRegularExpression("[ \r\n][ \r\n]*"));
107+
#else
108+
tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
109+
#endif
102110
if (tokens[0] == "GET") {
103111
QTextStream os(socket);
104112
os.setAutoDetectUnicode(true);

qtservice/src/qtservice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ QtServiceBase::QtServiceBase(int argc, char **argv, const QString &name)
663663
d_ptr = new QtServiceBasePrivate(nm);
664664
d_ptr->q_ptr = this;
665665

666-
d_ptr->serviceFlags = 0;
666+
d_ptr->serviceFlags = static_cast<ServiceFlags>(0);
667667
d_ptr->sysd = 0;
668668
for (int i = 0; i < argc; ++i)
669669
d_ptr->args.append(QString::fromLocal8Bit(argv[i]));

qtservice/src/qtservice_win.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,10 +737,17 @@ class QtServiceAppEventFilter : public QAbstractNativeEventFilter
737737
{
738738
public:
739739
QtServiceAppEventFilter() {}
740-
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
740+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
741+
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result);
742+
#else
743+
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
744+
#endif
741745
};
742-
746+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
747+
bool QtServiceAppEventFilter::nativeEventFilter(const QByteArray &, void *message, qintptr *result)
748+
#else
743749
bool QtServiceAppEventFilter::nativeEventFilter(const QByteArray &, void *message, long *result)
750+
#endif
744751
{
745752
MSG *winMessage = (MSG*)message;
746753
if (winMessage->message == WM_ENDSESSION && (winMessage->lParam & ENDSESSION_LOGOFF)) {

0 commit comments

Comments
 (0)