Skip to content

Commit

Permalink
chore: Support Qt6
Browse files Browse the repository at this point in the history
xcb module compatible with Qt6.
wayland module temporarily don't compatible with Qt6, as a result of dwayland or
kwayland doesn't support Qt6.

Log: Support Qt6
  • Loading branch information
wangfei authored and FeiWang1119 committed Jun 19, 2023
1 parent da0b0c0 commit bca181d
Show file tree
Hide file tree
Showing 26 changed files with 338 additions and 116 deletions.
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)

set(VERSION
set(DTK_VERSION
"5.6.8"
CACHE STRING "define project version"
)

project(qt5platform-plugins
VERSION ${VERSION}
VERSION ${DTK_VERSION}
DESCRIPTION "DTK platform plugin module"
HOMEPAGE_URL "https://github.com/linuxdeepin/qt5platform-plugins"
LANGUAGES CXX C
Expand All @@ -19,6 +19,16 @@ project(qt5platform-plugins
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

if("${PROJECT_VERSION_MAJOR}" STREQUAL "5")
set(QT_VERSION_MAJOR "5")
elseif("${PROJECT_VERSION_MAJOR}" STREQUAL "6")
set(QT_VERSION_MAJOR "6")
set(DTK_VERSION_MAJOR "6")
else()
message(SEND_ERROR "not support Prject Version ${PROJECT_VERSION}.")
endif()
message(${PROJECT_VERSION_MAJOR})

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_AUTOMOC ON)
Expand All @@ -28,4 +38,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(REQUIRED_QT_VERSION 5.15.0)

add_subdirectory(xcb)
add_subdirectory(wayland)
if("${PROJECT_VERSION_MAJOR}" STREQUAL "5")
add_subdirectory(wayland)
endif()
message(${PROJECT_VERSION_MAJOR})
21 changes: 10 additions & 11 deletions archlinux/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@ url="https://github.com/linuxdeepin/qt5platform-plugins"
license=('GPL3')
provides=('deepin-qt5platform-plugins')
conflicts=('deepin-qt5platform-plugins')
depends=('cairo' 'kwayland' 'qt5-wayland' 'qt5-x11extras')
makedepends=('git' 'expac' 'qt5-xcb-private-headers' 'libglvnd' 'libxcb')
depends=('cairo' 'kwayland' 'qt5-wayland' 'qt5-x11extras' 'qtbase5-private-dev')
makedepends=('git' 'expac' 'qt5-xcb-private-headers' 'libglvnd' 'ninja' 'cmake' 'libxcb')
groups=('deepin-git')
source=("${sourcetars[@]}")
sha512sums=('SKIP')

build() {
cd $sourcedir
cmake . -GNinja \
-DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules/\
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release
ninja
cd $sourcedir
cmake . -GNinja \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release
ninja
}

package() {
cd $sourcedir
make INSTALL_ROOT="$pkgdir" install
cd $sourcedir
make INSTALL_ROOT="$pkgdir" install
}
1 change: 0 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/make -f
export QT_SELECT=5
%:
dh $@

Expand Down
11 changes: 10 additions & 1 deletion src/dapplicationeventmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

#include <QGuiApplication>
#include <QInputEvent>

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include <QPointingDevice>
typedef QPointingDevice QTouchDevice;
#else
#include <QTouchDevice>
#endif

DPP_BEGIN_NAMESPACE

Expand Down Expand Up @@ -58,8 +64,11 @@ DApplicationEventMonitor::InputDeviceType DApplicationEventMonitor::eventType(QE
case QEvent::TouchEnd:
case QEvent::TouchCancel: {
QTouchEvent *pTouchEvent = static_cast<QTouchEvent *>(event);

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
if (pTouchEvent->device()->type() == QInputDevice::DeviceType::TouchScreen) {
#else
if (pTouchEvent->device()->type() == QTouchDevice::TouchScreen) {
#endif
last_input_device_type = TouchScreen;
}
break;
Expand Down
16 changes: 15 additions & 1 deletion src/dnativesettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ void DNativeSettings::init(const QMetaObject *metaObject)
int allKeyPropertyTyep = 0;

QMetaObjectBuilder &ob = m_objectBuilder;

#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
ob.setFlags(ob.flags() | DynamicMetaObject);
#else
ob.setFlags(ob.flags() | QMetaObjectBuilder::DynamicMetaObject);
#endif

// 先删除所有的属性,等待重构
while (ob.propertyCount() > 0) {
Expand Down Expand Up @@ -177,7 +182,8 @@ void DNativeSettings::init(const QMetaObject *metaObject)

// 将所有属性名称设置给对象
if (allKeyPropertyTyep == qMetaTypeId<QSet<QByteArray>>()) {
m_base->setProperty(ALL_KEYS, QVariant::fromValue(m_settings->settingKeys().toSet()));
QSet<QString> set(m_settings->settingKeys().begin(), m_settings->settingKeys().end());
m_base->setProperty(ALL_KEYS, QVariant::fromValue(set));
} else {
m_base->setProperty(ALL_KEYS, QVariant::fromValue(m_settings->settingKeys()));
}
Expand Down Expand Up @@ -438,13 +444,21 @@ int DNativeSettings::metaCall(QMetaObject::Call _c, int _id, void ** _a)

// 0为return type, 因此参数值下标从1开始
if (signal_method.parameterCount() > 0) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QVariant arg(signal_method.parameterMetaType(0), _a[1]);
#else
QVariant arg(signal_method.parameterType(0), _a[1]);
#endif
// 获取参数1,获取参数2
data1 = arg.toInt();
}

if (signal_method.parameterCount() > 1) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QVariant arg(signal_method.parameterMetaType(1), _a[2]);
#else
QVariant arg(signal_method.parameterType(1), _a[2]);
#endif
data2 = arg.toInt();
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/dselectedtexttooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void DSelectedTextTooltip::onFontChanged()
QFontMetrics font_metrics(qApp->font());
int tooltip_width = 0;
for (auto &font_info : m_textInfoVec) {
int tmp_width = font_metrics.width(font_info.optName);
int tmp_width = font_metrics.horizontalAdvance(font_info.optName);
font_info.textWidth = tmp_width + 2 * TEXT_SPACINGWIDGET;
tooltip_width += font_info.textWidth;
}
Expand All @@ -64,7 +64,8 @@ void DSelectedTextTooltip::onFontChanged()
void DSelectedTextTooltip::updateColor()
{
// 参考DtkGui
QColor rgb_color = qApp->palette().background().color().toRgb();
QColor rgb_color = qApp->palette().window().color().toRgb();

float luminance = 0.299 * rgb_color.redF() + 0.587 * rgb_color.greenF() + 0.114 * rgb_color.blueF();

if (qRound(luminance * 255) > 191) {
Expand Down
2 changes: 1 addition & 1 deletion src/dxcbxsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class Q_DECL_HIDDEN DXcbXSettingsPrivate
void init(xcb_window_t setting_window, DXcbXSettings *object)
{
x_settings_window = setting_window;
mapped.insertMulti(x_settings_window, object);
mapped.insert(x_settings_window, object);
initialized = true;

populateSettings(getSettings());
Expand Down
26 changes: 20 additions & 6 deletions wayland/dwayland/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

project(dwayland)

find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient XkbCommonSupport)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient)
if(${QT_VERSION_MAJOR} STREQUAL "5")
find_package(Qt5 REQUIRED COMPONENTS XkbCommonSupport)
endif()

add_definitions(-DQT5DWAYLANDPLUGIN_LIBRARY -DQT_DEPRECATED_WARNINGS)

Expand Down Expand Up @@ -40,15 +43,26 @@ PRIVATE
${CMAKE_SOURCE_DIR}/src
)

if("${QT_VERSION_MAJOR}" STREQUAL "6")
list(GET Qt6WaylandClient_PRIVATE_INCLUDE_DIRS 0 dir)
if(EXISTS ${dir})
target_include_directories(${PROJECT_NAME} PRIVATE ${Qt6WaylandClient_PRIVATE_INCLUDE_DIRS})
else()
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/wayland/qtwayland-dev/${Qt6_VERSION})
endif()
endif()

target_link_libraries(${PROJECT_NAME}
PRIVATE
Qt5::Core
Qt5::GuiPrivate
Qt5::XkbCommonSupportPrivate
Qt5::WaylandClientPrivate
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::GuiPrivate
Qt${QT_VERSION_MAJOR}::WaylandClient
)
if(${QT_VERSION_MAJOR} STREQUAL "5")
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::XkbCommonSupportPrivate Qt5::WaylandClientPrivate)
endif()

if(NOT INSTALL_PATH)
set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt5/plugins/platforms)
set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/plugins/platforms)
endif()
install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_PATH})
30 changes: 18 additions & 12 deletions wayland/wayland-shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

project(kwayland-shell)

find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets XkbCommonSupport WaylandClient)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui Widgets WaylandClient)

if(${QT_VERSION_MAJOR} STREQUAL "5")
find_package(Qt5 REQUIRED COMPONENTS XkbCommonSupport)
endif()

include(wayland-shell.cmake)

try_compile(DEEPIN_KWIN_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR}/deepin-kwin-test
${CMAKE_CURRENT_LIST_DIR}/config.tests/deepin-kwin-test deepin-kwin-test)
${CMAKE_CURRENT_LIST_DIR}/config.tests/deepin-kwin-test deepin-kwin-test CMAKE_FLAGS -DQT_VERSION_MAJOR=${QT_VERSION_MAJOR})

try_compile(WAYLAND_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR}/wayland_test
${CMAKE_CURRENT_LIST_DIR}/config.tests/wayland_test wayland_test)
${CMAKE_CURRENT_LIST_DIR}/config.tests/wayland_test wayland_test CMAKE_FLAGS -DQT_VERSION_MAJOR=${QT_VERSION_MAJOR})

if(WAYLAND_TEST_COMPILE_RESULT)
add_definitions(-DUSE_DEEPIN_WAYLAND)
Expand Down Expand Up @@ -49,18 +53,20 @@ endif()
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)

list(APPEND COMMON_LIBS
Qt5::Core
Qt5::Gui
Qt5::GuiPrivate
Qt5::Widgets
Qt5::WidgetsPrivate
Qt5::WaylandClient
Qt5::WaylandClientPrivate
Qt5::XkbCommonSupportPrivate
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::GuiPrivate
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::WidgetsPrivate
Qt${QT_VERSION_MAJOR}::WaylandClient
)
if(${QT_VERSION_MAJOR} STREQUAL "5")
list(APPEND COMMON_LIBS Qt5::XkbCommonSupportPrivate Qt5::WaylandClientPrivate)
endif()

target_link_libraries(${PROJECT_NAME} ${COMMON_LIBS})

if(NOT INSTALL_PATH)
set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt5/plugins/wayland-shell-integration)
set(INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/qt${QT_VERSION_MAJOR}/plugins/wayland-shell-integration)
endif()
install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_PATH})
18 changes: 12 additions & 6 deletions wayland/wayland-shell/config.tests/deepin-kwin-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later

cmake_minimum_required(VERSION 3.10)

project(deepin-kwin-test)

set(REQUIRED_QT_VERSION 5.15.0)
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS WaylandClient)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS WaylandClient)

include(../../wayland-shell.cmake)

Expand All @@ -18,11 +16,19 @@ set(AUTOMOC_COMPILER_PREDEFINES ON)

add_executable(${PROJECT_NAME} main.cpp)

list(APPEND COMMON_LIBS
Qt5::WaylandClientPrivate
)
if("${QT_VERSION_MAJOR}" STREQUAL "5")
list(APPEND COMMON_LIBS Qt5::WaylandClientPrivate)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${COMMON_LIBS})

if(${QT_VERSION_MAJOR} STREQUAL "6")
list(GET Qt6WaylandClient_PRIVATE_INCLUDE_DIRS 0 dir)
if(EXISTS ${dir})
target_include_directories(${PROJECT_NAME} PRIVATE ${Qt6WaylandClient_PRIVATE_INCLUDE_DIRS})
else()
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../../../qtwayland-dev/${Qt6_VERSION})
endif()
endif()
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}
Expand Down
18 changes: 10 additions & 8 deletions wayland/wayland-shell/config.tests/wayland_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later

cmake_minimum_required(VERSION 3.10)

project(wayland_test)

set(REQUIRED_QT_VERSION 5.15.0)
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient XkbCommonSupport)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Core Gui WaylandClient)
if(${QT_VERSION_MAJOR} STREQUAL "5")
find_package(Qt5 REQUIRED COMPONENTS XkbCommonSupport)
endif()

include(../../wayland-shell.cmake)

Expand All @@ -19,12 +20,13 @@ set(AUTOMOC_COMPILER_PREDEFINES ON)
add_executable(${PROJECT_NAME} main.cpp)

list(APPEND COMMON_LIBS
Qt5::Core
Qt5::CorePrivate
Qt5::GuiPrivate
Qt5::WaylandClientPrivate
Qt5::XkbCommonSupportPrivate
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::CorePrivate
Qt${QT_VERSION_MAJOR}::GuiPrivate
)
if(${QT_VERSION_MAJOR} STREQUAL "5")
list(APPEND COMMON_LIBS Qt5::WaylandClientPrivate Qt5::XkbCommonSupportPrivate)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${COMMON_LIBS})

target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down
1 change: 0 additions & 1 deletion wayland/wayland-shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class QKWaylandShellIntegrationPlugin : public QWaylandShellIntegrationPlugin
QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override {
Q_UNUSED(key);
Q_UNUSED(paramList);
qWarning() << "shell is nullptr" << shellVersion;
return nullptr;
}
};
Expand Down
Loading

0 comments on commit bca181d

Please sign in to comment.