Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt to Qt6 #8

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Copyright: None
License: CC0-1.0

# Project file
Files: *CMakeLists.txt *pc.in
Files: *CMakeLists.txt *pc.in *.cmake.in
Copyright: None
License: CC0-1.0

Expand Down
57 changes: 51 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.15)

set(VERSION "1.0.0" CACHE STRING "PDF rendering library based on PDFium")

project(deepin-pdfium
VERSION 1.0.0
VERSION ${VERSION}
DESCRIPTION "PDF rendering library based on PDFium"
LANGUAGES CXX C
)
Expand All @@ -10,6 +12,10 @@ project(deepin-pdfium
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 编译选项
add_compile_options(
-fstack-protector-strong
Expand All @@ -33,9 +39,6 @@ execute_process(
)
add_definitions(-DSYSTEMPAGESIZE=${SYSTEM_PAGE_SIZE})

# 定义构建宏
add_definitions(-DBUILD_DEEPDF_LIB)

# 查找Qt6依赖包
find_package(Qt6 COMPONENTS Core Gui REQUIRED)
find_package(PkgConfig REQUIRED)
Expand All @@ -51,15 +54,26 @@ add_subdirectory(src/3rdparty/pdfium)

# 主库目标
add_library(${PROJECT_NAME} SHARED
include/dpdfglobal.h
include/dpdfdoc.h
include/dpdfpage.h
include/dpdfannot.h
src/dpdfglobal.cpp
src/dpdfdoc.cpp
src/dpdfpage.cpp
src/dpdfannot.cpp
)

# 设置库的版本信息和 SOVERSION
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
)

target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/deepin-pdfium>
PRIVATE
${DEPS_INCLUDE_DIRS}
)
Expand Down Expand Up @@ -100,4 +114,35 @@ configure_file(
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfium.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
)

include(CMakePackageConfigHelpers)

set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/deepin-pdfium)
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})

configure_package_config_file(
misc/deepin-pdfiumConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfiumConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deepin-pdfium
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/deepin-pdfiumConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deepin-pdfium
)

install(TARGETS deepin-pdfium
EXPORT deepin-pdfiumTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(EXPORT deepin-pdfiumTargets
FILE deepin-pdfiumTargets.cmake
NAMESPACE deepin-pdfium::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/deepin-pdfium
)
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ development library for pdf on Deepin.

### Build dependencies

- qtbase5-dev
- chardet
- lcms2
- freetype2
- libopenjp2
- cmake,
- qt6-base-dev,
- pkg-config,
- libjpeg-dev,
- libicu-dev,
- libpng-dev,
- zlib1g-dev,
- liblcms2-dev,
- libopenjp2-7-dev,
- libfreetype6-dev,
- libgtest-dev,
- libchardet-dev

### Build from source code

Expand Down
17 changes: 12 additions & 5 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ Deepin上的pdf开发库。

### 编译依赖

- qtbase5-dev
- chardet
- lcms2
- freetype2
- libopenjp2
- cmake,
- qt6-base-dev,
- pkg-config,
- libjpeg-dev,
- libicu-dev,
- libpng-dev,
- zlib1g-dev,
- liblcms2-dev,
- libopenjp2-7-dev,
- libfreetype6-dev,
- libgtest-dev,
- libchardet-dev

## 安装

Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
deepin-pdfium (1.5.1) unstable; urgency=medium

* adapt to Qt6

-- Zhang Sheng <[email protected]> Fri, 03 Jan 2025 16:49:00 +0800

deepin-pdfium (1.5.0) unstable; urgency=medium

* adapt to Qt6
Expand Down
1 change: 1 addition & 0 deletions debian/libdeepin-pdfium-dev.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/usr/include/deepin-pdfium/*
/usr/lib/*/pkgconfig/deepin-pdfium.pc
/usr/lib/*/cmake/deepin-pdfium/*
6 changes: 3 additions & 3 deletions deepin-pdfium.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/deepin-pdfium
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Requires: Qt5Core Qt5Gui
Libs: -L${libdir} -ldeepinpdfium
Cflags: -I${includedir}
Requires: Qt6Core Qt6Gui
Libs: -L${libdir} -ldeepin-pdfium
Cflags: -I${includedir}
18 changes: 9 additions & 9 deletions include/dpdfannot.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <QList>
#include <QColor>

class DEEPDF_EXPORT DPdfAnnot
class DPdfAnnot
{
public:
enum AnnotType {
Expand Down Expand Up @@ -52,7 +52,7 @@ class DEEPDF_EXPORT DPdfAnnot
QString m_text;
};

class DEEPDF_EXPORT DPdfTextAnnot : public DPdfAnnot
class DPdfTextAnnot : public DPdfAnnot
{
friend class DPdfPage;
friend class DPdfPagePrivate;
Expand All @@ -69,7 +69,7 @@ class DEEPDF_EXPORT DPdfTextAnnot : public DPdfAnnot
QRectF m_rect;
};

class DEEPDF_EXPORT DPdfSquareAnnot : public DPdfAnnot
class DPdfSquareAnnot : public DPdfAnnot
{
public:
DPdfSquareAnnot();
Expand All @@ -84,7 +84,7 @@ class DEEPDF_EXPORT DPdfSquareAnnot : public DPdfAnnot
QRectF m_rect;
};

class DEEPDF_EXPORT DPdfCIRCLEAnnot : public DPdfAnnot
class DPdfCIRCLEAnnot : public DPdfAnnot
{
friend class DPdfPage;
friend class DPdfPagePrivate;
Expand All @@ -104,7 +104,7 @@ class DEEPDF_EXPORT DPdfCIRCLEAnnot : public DPdfAnnot
QRectF m_rect;
};

class DEEPDF_EXPORT DPdfHightLightAnnot : public DPdfAnnot
class DPdfHightLightAnnot : public DPdfAnnot
{
friend class DPdfPage;
friend class DPdfPagePrivate;
Expand All @@ -126,7 +126,7 @@ class DEEPDF_EXPORT DPdfHightLightAnnot : public DPdfAnnot
QColor m_color;
};

class DEEPDF_EXPORT DPdfLinkAnnot : public DPdfAnnot
class DPdfLinkAnnot : public DPdfAnnot
{
public:
DPdfLinkAnnot();
Expand Down Expand Up @@ -175,7 +175,7 @@ class DEEPDF_EXPORT DPdfLinkAnnot : public DPdfAnnot
float m_top = 0;
};

class DEEPDF_EXPORT DPdfWidgetAnnot : public DPdfAnnot
class DPdfWidgetAnnot : public DPdfAnnot
{
public:
DPdfWidgetAnnot();
Expand All @@ -186,7 +186,7 @@ class DEEPDF_EXPORT DPdfWidgetAnnot : public DPdfAnnot

};

class DEEPDF_EXPORT DPdfUnknownAnnot : public DPdfAnnot
class DPdfUnknownAnnot : public DPdfAnnot
{
public:
DPdfUnknownAnnot();
Expand All @@ -197,7 +197,7 @@ class DEEPDF_EXPORT DPdfUnknownAnnot : public DPdfAnnot

};

class DEEPDF_EXPORT DPdfUnderlineAnnot : public DPdfAnnot
class DPdfUnderlineAnnot : public DPdfAnnot
{
public:
DPdfUnderlineAnnot();
Expand Down
2 changes: 1 addition & 1 deletion include/dpdfdoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class DPdfPage;
class DPdfDocHandler;
class DPdfDocPrivate;
class DEEPDF_EXPORT DPdfDoc : public QObject
class DPdfDoc : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(DPdfDoc)
Expand Down
12 changes: 1 addition & 11 deletions include/dpdfglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@
#include <QTime>
#include <QRectF>

#ifndef BUILD_DEEPDF_STATIC
# if defined(BUILD_DEEPDF_LIB)
# define DEEPDF_EXPORT Q_DECL_EXPORT
# else
# define DEEPDF_EXPORT Q_DECL_IMPORT
# endif
#else
# define DEEPDF_EXPORT
#endif

class DPdfGlobal
{
public:
Expand Down Expand Up @@ -50,7 +40,7 @@ class DPdfGlobal
};

//pdfium即使不同文档之间loadpage和renderpage也不是线程安全,需要加锁
class DEEPDF_EXPORT DPdfMutexLocker : public QMutexLocker<QRecursiveMutex>
class DPdfMutexLocker : public QMutexLocker<QRecursiveMutex>
{
public:
DPdfMutexLocker(const QString &tmpLog);
Expand Down
10 changes: 5 additions & 5 deletions include/dpdfpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
class DPdfAnnot;
class DPdfPagePrivate;
class DPdfDocHandler;
class DEEPDF_EXPORT DPdfPage : public QObject
class DPdfPage : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(DPdfPage)
friend class DPdfDoc;

public:
~DPdfPage();
virtual ~DPdfPage();

/**
* @brief 是否有效
Expand Down Expand Up @@ -182,19 +182,19 @@ class DEEPDF_EXPORT DPdfPage : public QObject
* @brief 添加注释时触发 ,在需要的时候可以重新获取annotations()
* @param annot 新增加的annot
*/
void annotAdded(DPdfAnnot *dAnnot);
void annotAdded(DPdfAnnot *annot);

/**
* @brief 注释被更新时触发 ,在需要的时候可以重新获取annotations()
* @param annot 被更新的annot
*/
void annotUpdated(DPdfAnnot *dAnnot);
void annotUpdated(DPdfAnnot *annot);

/**
* @brief 注释被删除时触发 ,在需要的时候可以重新获取annotations()
* @param annot 被移除的annot 注意这个已经是个将要被析构后的地址 只用于做匹配移除
*/
void annotRemoved(DPdfAnnot *dAnnot);
void annotRemoved(DPdfAnnot *annot);

private:
DPdfPage(DPdfDocHandler *handler, int pageIndex, qreal xRes = 72, qreal yRes = 72);
Expand Down
23 changes: 23 additions & 0 deletions misc/deepin-pdfiumConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

# 设置路径
set_and_check(DEEPIN_PDFIUM_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(DEEPIN_PDFIUM_LIBRARY_DIR "@PACKAGE_LIB_INSTALL_DIR@")

# 检查依赖
find_dependency(PkgConfig)
pkg_check_modules(PDFIUM_DEPS REQUIRED
libopenjp2
lcms2
freetype2
zlib
libpng
libjpeg
)

# 包含导出的目标
include("${CMAKE_CURRENT_LIST_DIR}/deepin-pdfiumTargets.cmake")

check_required_components(deepin-pdfium)
Loading