Skip to content

Commit

Permalink
Support Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Jan 10, 2022
1 parent ae2322c commit 8153ef3
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 7 deletions.
122 changes: 122 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.so.*
*.dll
*.dylib
*.json

# Qt-es
object_script.*.Release
object_script.*.Debug
*_plugin_import.cpp
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
*.qmlc
*.jsc
Makefile*
*build-*
*.qm
*.prl

# Qt unit tests
target_wrapper.*

# QtCreator
*.autosave

# QtCreator Qml
*.qmlproject.user
*.qmlproject.user.*

# QtCreator CMake
CMakeLists.txt.user*

# QtCreator 4.8< compilation database
compile_commands.json

# QtCreator local machine specific files for imported projects
*creator.user*

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Platform Specifics - auto generated files
PlatformSpecifics/Windows/*.rc

# Visual studio - project files
*.sln
*.suo
*.vcxproj
*.vcxproj.filters
*.vcxproj.user

# Visual Studio - Build Results
[Dd]ebug/
[Rr]elease/
[Mm]in[Ss]ize[Rr]el/
[Rr]el[Ww]ith[Dd]eb[Ii]nfo/
build*/

# Visual Studio - Browsing Database File
*.sdf
*.opensdf

#osx xcode
DerivedData/
*.DS_Store
*.build
*.xcodeproj

#CPACK related files
CPackConfig-*.cmake
_CPack_Packages/

#packages
*.tar.gz
*.zip

*.swp
*.*~

build_doxygen
8 changes: 5 additions & 3 deletions qtservice/cmake/QtServiceConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/")

include(CMakeFindDependencyMacro)
foreach(dependens_lib @QTSERVICE_DEPENDENS@)
find_dependency(${dependens_lib})
endforeach()
#foreach(dependens_lib @QTSERVICE_DEPENDENS@)
# find_dependency(${dependens_lib})
#endforeach()

find_dependency(Qt@QT_VERSION_MAJOR@ COMPONENTS @QT_COMPONENTS@)

include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")

4 changes: 4 additions & 0 deletions qtservice/examples/interactive/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
****************************************************************************/

#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QDesktopWidget>
#endif
#include <QLabel>
#include <QDir>
#include <QSettings>
Expand Down Expand Up @@ -87,7 +89,9 @@ void InteractiveService::start()
qApp->setQuitOnLastWindowClosed(false);

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

Expand Down
12 changes: 10 additions & 2 deletions qtservice/examples/server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
#include <QStringList>
#include <QDir>
#include <QSettings>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QRegularExpression>
#endif
#include "qtservice.h"

// HttpDaemon is the the class that implements the simple HTTP server.
Expand Down Expand Up @@ -98,7 +100,13 @@ private slots:
// document back.
QTcpSocket* socket = (QTcpSocket*)sender();
if (socket->canReadLine()) {
QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));

QStringList tokens;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
tokens = QString(socket->readLine()).split(QRegularExpression("[ \r\n][ \r\n]*"));
#else
tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
#endif
if (tokens[0] == "GET") {
QTextStream os(socket);
os.setAutoDetectUnicode(true);
Expand Down
2 changes: 1 addition & 1 deletion qtservice/src/qtservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ QtServiceBase::QtServiceBase(int argc, char **argv, const QString &name)
d_ptr = new QtServiceBasePrivate(nm);
d_ptr->q_ptr = this;

d_ptr->serviceFlags = 0;
d_ptr->serviceFlags = static_cast<ServiceFlags>(0);
d_ptr->sysd = 0;
for (int i = 0; i < argc; ++i)
d_ptr->args.append(QString::fromLocal8Bit(argv[i]));
Expand Down
1 change: 0 additions & 1 deletion qtservice/src/qtservice.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
# define QT_QTSERVICE_EXPORT
#endif

class QStringList;
class QtServiceControllerPrivate;

class QT_QTSERVICE_EXPORT QtServiceController
Expand Down

0 comments on commit 8153ef3

Please sign in to comment.