Skip to content

Commit

Permalink
feat: qt6 adaptation
Browse files Browse the repository at this point in the history
qt6 adaptation
  • Loading branch information
JWWTSL committed Jan 7, 2025
1 parent 38a5255 commit cfc3e3e
Show file tree
Hide file tree
Showing 75 changed files with 1,625 additions and 2,205 deletions.
39 changes: 29 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,84 @@
cmake_minimum_required(VERSION 3.0)
# 设置CMake的最低版本要求为3.0
cmake_minimum_required(VERSION 3.5)

# 定义项目名称为deepin-movie-reborn
project(deepin-movie-reborn)


# 定义选项,用于控制是否启用dxcb平台插件的集成,默认关闭
option(USE_DXCB "integration with dxcb platform plugin" OFF)
# 定义选项,用于控制是否开启调试输出,默认关闭
option(DMR_DEBUG "turn on debug output" off)
# 定义选项,用于控制是否开启dman portal支持,默认关闭
option(DTK_DMAN_PORTAL "turn on dman portal support" off)

# 执行命令获取当前系统的架构信息,存储在变量MACH中
execute_process(COMMAND uname -m OUTPUT_VARIABLE MACH
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

# 如果构建类型是Debug,则开启调试输出
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DMR_DEBUG on)
endif()

# 如果使用GNU编译器,设置C++标准为C++11
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

# 设置C++标准为C++17
set(CMAKE_CXX_STANDARD 17)

# 导出编译命令到compile_commands.json文件
set(CMAKE_EXPORT_COMPILE_COMMANDS on)

# 查找PkgConfig包管理工具
find_package(PkgConfig REQUIRED)
find_package(Qt5Core)

pkg_check_modules(MPRIS REQUIRED IMPORTED_TARGET mpris-qt5)
# 使用PkgConfig查找mpris-qt5库
#pkg_check_modules(MPRIS REQUIRED IMPORTED_TARGET mpris-qt5)
pkg_check_modules(MPRIS REQUIRED IMPORTED_TARGET mpris-qt6)

# test deepin fork mpris-qt5
# 测试是否使用deepin fork的mpris-qt5
try_compile(USE_FORK_MPRIS
${CMAKE_CURRENT_BINARY_DIR}/try_compile
SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/tests/mpris_test.cc
LINK_LIBRARIES
PkgConfig::MPRIS
Qt5::Core
OUTPUT_VARIABLE TRY_COMPILE_OUTPUT
)

message(STATUS "use deepin fork mpris-qt5: ${USE_FORK_MPRIS}")
# 输出是否使用deepin fork的mpris-qt5
#message(STATUS "use deepin fork mpris-qt5: ${USE_FORK_MPRIS}")

# 如果使用deepin fork的mpris-qt5,添加编译定义
if(USE_FORK_MPRIS)
add_definitions(-DUSE_FORK_MPRIS)
endif()

# Find includes in corresponding build directories
# 在相应的构建目录中查找包含文件
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# 包含项目的二进制目录和源代码目录
include_directories(${PROJECT_BINARY_DIR})
include_directories(${PROJECT_SOURCE_DIR})

# 包含GNU安装目录模块
include(GNUInstallDirs)
# 如果安装前缀未初始化为默认值,则设置安装前缀为/usr
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif()

# 配置文件,将config.h.in转换为config.h
configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h @ONLY)

# 添加src子目录
add_subdirectory(src)
add_subdirectory(examples/test)
# 添加examples/test子目录
#add_subdirectory(examples/test)

# 如果构建类型是Debug,添加tests子目录
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_subdirectory(tests)
# add_subdirectory(tests)
endif()
54 changes: 42 additions & 12 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,48 @@ Source: deepin-movie-reborn
Section: libdevel
Priority: extra
Maintainer: Deepin Packages Builder <packages@deepin.com>
Build-Depends: debhelper, cmake, pkg-config, qttools5-dev-tools,
libqt5svg5-dev, qtmultimedia5-dev, qttools5-dev,
libqt5x11extras5-dev, libdtkcore5-bin, libdtkwidget-dev,
libqt5sql5-sqlite,
libmpv-dev, libxcb1-dev, libxcb-util0-dev,
libffmpegthumbnailer-dev,
libxcb-shape0-dev,libxcb-ewmh-dev, xcb-proto,
x11proto-record-dev, libxtst-dev,
libavcodec-dev, libavformat-dev,libavutil-dev,
libpulse-dev, libdvdnav-dev, libgsettings-qt-dev,
libmpris-qt5-dev, libdbusextended-qt5-dev, libva-dev,
libgstreamer-plugins-base1.0-dev, libgstreamer1.0-dev
Build-Depends:
debhelper,
cmake,
pkg-config,
libmpv-dev,
libxcb1-dev,
libxcb-util0-dev,
libffmpegthumbnailer-dev,
libxcb-shape0-dev,
libxcb-ewmh-dev,
xcb-proto,
x11proto-record-dev,
libxtst-dev,
libavcodec-dev,
libavformat-dev,
libavutil-dev,
libpulse-dev,
libdvdnav-dev,
libgsettings-qt-dev,
libdbusextended-qt5-dev,
libva-dev,
qtbase5-private-dev,
libgstreamer-plugins-base1.0-dev,
libgstreamer1.0-dev,
# qt6
qt6-base-dev,
qt6-base-dev-tools,
qt6-base-private-dev,
qt6-l10n-tools,
qt6-svg-dev,
qt6-tools-dev-tools,
qt6-tools-dev,
libqt6multimediawidgets6,
qt6-multimedia-dev,
libqt6sql6-sqlite,
libmpris-qt6-dev,
libqt6opengl6,
libqt6opengl6-dev,
# dtk
libdtk6gui-dev,
libdtk6widget-dev,
libdtk6core-dev
Standards-Version: 3.9.8
Homepage: https://www.deepin.org/

Expand Down
13 changes: 10 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#!/usr/bin/make -f
include /usr/share/dpkg/default.mk
export QT_SELECT=5
export QT_SELECT=6
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
dh $@ --parallel
dh $@ --parallel --with-compat=10

override_dh_auto_configure:
dh_auto_configure -- \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) -DVERSION=$(DEB_VERSION_UPSTREAM) LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) \
-DVERSION=$(DEB_VERSION_UPSTREAM) \
-DLIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
-DQT_VERSION=6

override_dh_install:
dh_install --exclude=usr/share/dsg/configs/org.deepin.movie \
--exclude=usr/lib/uos-ai-assistant/functions

57 changes: 40 additions & 17 deletions examples/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,54 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -fpermissive -Wno-error")

include_directories(${CMAKE_INCLUDE_CURRENT_DIR})

find_package(Qt5Widgets)
find_package(Qt5Concurrent)
find_package(Qt5Network)
find_package(Qt5X11Extras)
find_package(Qt5Sql)
find_package(Qt5DBus)
find_package(Qt5Svg)

pkg_check_modules(Dtk REQUIRED IMPORTED_TARGET dtkwidget)
pkg_check_modules(Gst REQUIRED IMPORTED_TARGET libffmpegthumbnailer gstreamer-1.0 glib-2.0)
#qt5
# find_package(Qt5Widgets)
# find_package(Qt5Concurrent)
# find_package(Qt5Network)
# find_package(Qt5X11Extras)
# find_package(Qt5Sql)
# find_package(Qt5DBus)
# find_package(Qt5Svg)

#qt6
find_package(Qt6Widgets)
find_package(Qt6Concurrent)
find_package(Qt6Network)
find_package(Qt6Sql)
find_package(Qt6DBus)
find_package(Qt6Svg)

pkg_check_modules(Dtk REQUIRED IMPORTED_TARGET dtk6widget)
pkg_check_modules(Gst REQUIRED IMPORTED_TARGET gstreamer-1.0 glib-2.0)
include_directories(${Gst_INCLUDE_DIRS})

# 定义 source 文件
FILE (GLOB SRCS
*.cpp
)
../../src/libdmr/sysutils.cpp
)

# add_subdirectory(../../src/libdmr ${CMAKE_CURRENT_BINARY_DIR}/libdmr)
add_executable(${CMD_NAME} ${SRCS})

target_link_libraries(${CMD_NAME} PkgConfig::Dtk Qt5::Widgets Qt5::Concurrent
Qt5::Network Qt5::X11Extras Qt5::Sql Qt5::DBus PkgConfig::Gst GL)
target_include_directories(${CMD_NAME} PUBLIC

if (Qt6_FOUND)
# Qt6 environment
target_link_libraries(${CMD_NAME} PkgConfig::Dtk Qt6::Widgets Qt6::Concurrent
Qt6::Network Qt6::Sql Qt6::DBus PkgConfig::Gst GL)
else()
# Qt5 environment
target_link_libraries(${CMD_NAME} PkgConfig::Dtk Qt5::Widgets Qt5::Concurrent
Qt5::Network Qt5::X11Extras Qt5::Sql Qt5::DBus PkgConfig::Gst GL)
endif()

target_include_directories(${CMD_NAME} PUBLIC
${PROJECT_SOURCE_DIR}/../../src/libdmr
${PROJECT_SOURCE_DIR}
)

target_link_libraries(${CMD_NAME} Qt5::Widgets dmr)
/usr/include/glib-2.0 /usr/include/gstreamer-1.0)

if (Qt6_FOUND)
target_link_libraries(${CMD_NAME} Qt6::Widgets dmr)
else()
target_link_libraries(${CMD_NAME} Qt5::Widgets dmr)
endif()
5 changes: 4 additions & 1 deletion examples/test/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#include <playlist_model.h>

Check warning on line 10 in examples/test/window.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <playlist_model.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <compositing_manager.h>

Check warning on line 11 in examples/test/window.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <compositing_manager.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWidget>

Check warning on line 12 in examples/test/window.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWidget> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QVBoxLayout>

Check warning on line 13 in examples/test/window.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QVBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QHBoxLayout>

Check warning on line 14 in examples/test/window.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QHBoxLayout> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPushButton>

Check warning on line 15 in examples/test/window.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPushButton> not found. Please note: Cppcheck does not need standard library headers to get proper results.

class Window: public QWidget {
Q_OBJECT
public:
Window(QWidget *parent = 0);
explicit Window(QWidget *parent = nullptr);
void play(const QUrl& url);

private:
Expand Down
Loading

0 comments on commit cfc3e3e

Please sign in to comment.