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

feat: QT6 adaptation #351

Merged
merged 1 commit into from
Jan 15, 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
11 changes: 5 additions & 6 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Priority: optional
Maintainer: Deepin Packages Builder <[email protected]>
Build-Depends:
debhelper (>=9),cmake,
pkg-config,qtbase5-dev,libdtkgui-dev,libdtkwidget-dev,qtmultimedia5-dev,
libavutil-dev, libavformat-dev, libavcodec-dev,libavfilter-dev,qttools5-dev,
qttools5-dev-tools,deepin-gettext-tools,
pkg-config,qt6-base-dev,libdtk6gui-dev,libdtk6widget-dev,qt6-multimedia-dev,
libavutil-dev, libavformat-dev, libavcodec-dev,libavfilter-dev,qt6-tools-dev,
qt6-tools-dev-tools,deepin-gettext-tools, qt6-svg-dev,
libv4l-dev,libsdl2-dev,portaudio19-dev,libpng-dev,libasound2-dev,libpciaccess-dev,
libusb-1.0-0-dev,zlib1g-dev,libudev-dev,libswscale-dev,libswresample-dev,libffmpegthumbnailer-dev,
libx11-dev,libva-dev,libimageeditor-dev,
Expand All @@ -20,9 +20,8 @@ Depends:
${shlibs:Depends},
${misc:Depends},
libavcodec58 (>= 7:4.0) | libavcodec60, libavformat58 (>= 7:4.1) | libavformat60, libavutil56 (>= 7:4.0) | libavutil58, libswresample3 (>= 7:4.0) | libswresample4, libswscale5 (>= 7:4.0) | libswscale7,
libdtkcore5, libdtkgui5, libdtkwidget5, libffmpegthumbnailer4v5, libgl1, libpng16-16 (>= 1.6.2-1), libportaudio2 (>= 19+svn20101113), libqt5concurrent5 (>= 5.0.2), libqt5core5a (>= 5.11.0~rc1),
libqt5dbus5 (>= 5.0.2), libqt5gui5 (>= 5.8.0), libqt5network5 (>= 5.0.2), libqt5printsupport5 (>= 5.0.2), libqt5widgets5 (>= 5.2.0~alpha1), libqt5x11extras5 (>= 5.6.0), libasound2 (>= 1.0.16),
libqt5xml5 (>= 5.0.2), libsdl2-2.0-0 (>= 2.0.9), libstdc++6 (>= 7), libudev1 (>= 183), libusb-1.0-0 (>= 2:1.0.8), libv4l-0 (>= 0.5.0), zlib1g (>= 1:1.1.4), libgstreamer-plugins-base1.0-0 (>= 1.0.0), libgstreamer1.0-0 (>= 1.4.0), dde-api
libdtkcore6, libdtkgui6, libdtkwidget6, libffmpegthumbnailer4v5, libgl1, libpng16-16 (>= 1.6.2-1), libportaudio2 (>= 19+svn20101113), libqt6concurrent6 (>= 6.8.0), libqt6core6 (>= 6.8.0), libqt6gui6 (>= 6.8.0), libqt6network6 (>= 6.8.0), libqt6printsupport6 (>= 6.8.0), libqt6widgets6 (>= 6.8.0), libasound2 (>= 1.0.16),
libqt6xml6 (>= 6.8.0), libsdl2-2.0-0 (>= 2.0.9), libstdc++6 (>= 7), libudev1 (>= 183), libusb-1.0-0 (>= 2:1.0.8), libv4l-0 (>= 0.5.0), zlib1g (>= 1:1.1.4), libgstreamer-plugins-base1.0-0 (>= 1.0.0), libgstreamer1.0-0 (>= 1.4.0), dde-api
Recommends: libimageeditor, uos-reporter, deepin-event-log
Description:this package software for UOS
deepin-camera is a tool to view camera, and also a smart take photo and video in life.
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/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)

MODULE_NAME=deepin-camera
Expand Down
50 changes: 37 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ project(deepin-camera VERSION 1.0.0)
set(CMD_NAME deepin-camera)
set(TARGET_NAME deepin-camera)

set(QT_VERSION_MAJOR 6)
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
set(DTK_VERSION 6)
endif()

#option (__mips__ "Use UNITTEST" ON)

# cube文件目录,libvisualresult在打包时,会自动将cube文件安装到share目录下
Expand All @@ -33,9 +38,9 @@ elseif(MAJOR_VERSION MATCHES "25")
endif()

include(GNUInstallDirs)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()
# endif ()

if(DEFINED LINGLONG_BUILD_ON)
# 玲珑构建编译开关
Expand Down Expand Up @@ -79,10 +84,10 @@ set(PROJECT_INCLUDE
)

# 设置Qt模块
set(QtModule Core Gui Widgets DBus Concurrent LinguistTools Multimedia PrintSupport Svg)
set(QtModule Core Gui Widgets DBus Concurrent LinguistTools Multimedia PrintSupport Svg SvgWidgets OpenGL OpenGLWidgets)

# 查找Qt相关的库链接
find_package(Qt5 REQUIRED ${QtModule})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED ${QtModule})
find_package(PkgConfig REQUIRED)

include(FindPkgConfig)
Expand Down Expand Up @@ -110,8 +115,28 @@ file (GLOB_RECURSE HEADERS

file (GLOB_RECURSE RESOURCES ${PROJECT_SOURCE_DIR}/assets/assets.qrc)

if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
set(CXX_FILES_TO_REMOVE
${PROJECT_SOURCE_DIR}/./src/videosurface.cpp
)
set(HEAD_FILES_TO_REMOVE
${PROJECT_SOURCE_DIR}/./src/videosurface.h
)
else()
endif()

foreach(file ${CXX_FILES_TO_REMOVE})
list(REMOVE_ITEM CXXSOURCES ${file})
# list(REMOVE_ITEM HEAD_FILES_TO_REMOVE ${file})
endforeach()
foreach(file ${HEAD_FILES_TO_REMOVE})
list(REMOVE_ITEM HEADERS ${file})
endforeach()

pkg_check_modules(3rd_lib REQUIRED
dtkwidget dtkcore gobject-2.0
dtk${DTK_VERSION}widget
dtk${DTK_VERSION}core
gobject-2.0
pciaccess
# libv4l2
# libudev
Expand Down Expand Up @@ -140,11 +165,7 @@ file (GLOB TS LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/translations/${TARGET

set_source_files_properties(${TS} PROPERTIES OUTPUT_LOCATION ${PROJECT_SOURCE_DIR}/translations)

qt5_create_translation(QM ${CXXSOURCES} ${TS})

if (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
qt5_create_translation(QM ${CXXSOURCES} ${TS})
endif ()
qt_create_translation(QM ${CXXSOURCES} ${TS})

# 设置不删除生成的文件夹内容文件
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
Expand All @@ -159,13 +180,16 @@ target_link_libraries(${TARGET_NAME} ${3rd_lib_LIBRARIES}
dl
imagevisualresult
${LIBS}
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Multimedia
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::SvgWidgets
Qt${QT_VERSION_MAJOR}::OpenGL
Qt${QT_VERSION_MAJOR}::OpenGLWidgets
)

include_directories("${CMAKE_INSTALL_PREFIX}/include")

# 将工程与Qt模块链接起来
qt5_use_modules(${TARGET_NAME} ${QtModule})

#application
install(TARGETS ${TARGET_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})

Expand Down
21 changes: 20 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
#include <libimagevisualresult/visualresult.h>
}

#include <DMainWindow>

Check warning on line 23 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 24 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 25 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DLog> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#if QT_VERSION_MAJOR <= 5
#include <DApplicationSettings>

Check warning on line 27 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <QSharedMemory>

Check warning on line 30 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

Check warning on line 31 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <unistd.h>
#include <fcntl.h>
Expand Down Expand Up @@ -59,14 +61,25 @@
QString path = QLibraryInfo::location(QLibraryInfo::LibrariesPath);
dir.setPath(path);
QStringList list = dir.entryList(QStringList() << (QString("libavcodec") + "*"), QDir::NoDotAndDotDot | QDir::Files);
QString libName = "libavcodec.so"; // set default name for load if not find in LibrariesPath
QString libName = "libavcodec.so"; // set default name for load if not find in LibrariesPath
#if QT_VERSION_MAJOR > 5
QRegularExpression re("libavcodec.so.*"); //Sometimes libavcodec.so may not exist, so find it through regular expression.
for (int i = 0; i < list.count(); i++) {
QRegularExpressionMatch match = re.match(list[i]);
if (match.hasMatch()) {
libName = list[i];
break;
}
}
#else
QRegExp re("libavcodec.so.*"); //Sometimes libavcodec.so may not exist, so find it through regular expression.
for (int i = 0; i < list.count(); i++) {
if (re.exactMatch(list[i])) {
libName = list[i];
break;
}
}
#endif

QLibrary libavcodec; //检查编码器是否存在
libavcodec.setFileName(libName);
Expand Down Expand Up @@ -158,7 +171,11 @@
qInfo() << "last mp4EncodeMode value is:" << get_pugx_status();
}

#if QT_VERSION_MAJOR > 5
QElapsedTimer time;
#else
QTime time;
#endif
time.start();
QString lutDir = LUT_DIR;
initFilters(lutDir.toStdString().c_str());
Expand Down Expand Up @@ -199,7 +216,9 @@

dc::Settings::get().init();

#if QT_VERSION_MAJOR <= 5
DApplicationSettings saveTheme;
#endif

if (!qApp->setSingleInstance("deepin-camera")) {
qDebug() << "another deepin camera instance has started";
Expand Down
8 changes: 4 additions & 4 deletions src/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,22 +223,22 @@ void Settings::onValueChanged(const QString & key, const QVariant & value)
{
if (key.startsWith("outsetting.resolutionsetting.resolution")) {
auto mode_opt = m_settings->option("outsetting.resolutionsetting.resolution");
if (value >= 0 && mode_opt->data("items").toStringList().size() > value.toInt()) {
if (value.toInt() >= 0 && mode_opt->data("items").toStringList().size() > value.toInt()) {
QString mode = mode_opt->data("items").toStringList()[value.toInt()];
emit resolutionchanged(mode);
}
}

if (key.startsWith("base.photogrid.photogrids")) {
auto grid_opt1 = m_settings->option("base.photogrid.photogrids");
if (value >= 0 && grid_opt1->data("items").toStringList().size() > value.toInt()) {
if (value.toInt() >= 0 && grid_opt1->data("items").toStringList().size() > value.toInt()) {
emit gridTypeChanged(value.toInt());
}
}

if (key.startsWith("photosetting.photosdelay.photodelays")) {
auto mode_opt1 = m_settings->option("photosetting.photosdelay.photodelays");
if (value >= 0 && mode_opt1->data("items").toStringList().size() > value.toInt()) {
if (value.toInt() >= 0 && mode_opt1->data("items").toStringList().size() > value.toInt()) {
QString mode1 = mode_opt1->data("items").toStringList()[value.toInt()];
emit delayTimeChanged(mode1);
}
Expand All @@ -256,7 +256,7 @@ void Settings::onValueChanged(const QString & key, const QVariant & value)

if (key.startsWith("outsetting.outformat.vidformat")) {
QPointer<DSettingsOption> formatOpt = m_settings->option("outsetting.outformat.vidformat");
if (value >= 0 && formatOpt->data("items").toStringList().size() > value.toInt()) {
if (value.toInt() >= 0 && formatOpt->data("items").toStringList().size() > value.toInt()) {
QString videoFormat = formatOpt->data("items").toStringList()[value.toInt()];
emit videoFormatChanged(videoFormat);
}
Expand Down
Loading
Loading