From e7e8c5b9bd50a77d98d8edfc3648a70d5bb52906 Mon Sep 17 00:00:00 2001 From: Wang Cong Date: Thu, 6 Jul 2023 10:34:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20hw=E6=9C=BA=E5=9E=8B=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=82=E9=85=8Ddconfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: hw机型判断适配dconfig Log: hw机型判断适配dconfig Task: https://pms.uniontech.com/task-view-276433.html --- assets/org.deepin.movie.minimode.json | 16 ++++++++++ debian/deepin-movie.install | 1 + src/CMakeLists.txt | 9 ++++++ src/common/mainwindow.cpp | 46 +++++++++++++++++---------- src/common/mainwindow.h | 3 ++ 5 files changed, 59 insertions(+), 16 deletions(-) create mode 100755 assets/org.deepin.movie.minimode.json diff --git a/assets/org.deepin.movie.minimode.json b/assets/org.deepin.movie.minimode.json new file mode 100755 index 000000000..0fcd9bc59 --- /dev/null +++ b/assets/org.deepin.movie.minimode.json @@ -0,0 +1,16 @@ +{ + "magic": "dsg.config.meta", + "version": "1.0", + "contents": { + "miniModeSpecialHandling": { + "value": 0, + "serial": 0, + "flags": ["global"], + "name": "Mini Mode Special Handling", + "name[zh_CN]": "迷你模式特殊处理", + "description": "Mini mode special handling, like Huawei", + "permissions": "readwrite", + "visibility": "private" + } + } +} diff --git a/debian/deepin-movie.install b/debian/deepin-movie.install index 74dd86b33..c804e0aa6 100644 --- a/debian/deepin-movie.install +++ b/debian/deepin-movie.install @@ -4,3 +4,4 @@ usr/share/glib-2.0/schemas/com.deepin.deepin-movie.gschema.xml usr/share/deepin-movie/translations/*.qm usr/share/icons/* usr/share/deepin-manual/manual-assets/application/* +usr/share/dsg/configs/org.deepin.movie/* \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03161940b..804d526b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,6 +26,7 @@ find_package(Qt5Svg) find_package(Qt5Multimedia) find_package(Qt5MultimediaWidgets) find_package(Qt5Xml) +find_package(DtkWidget REQUIRED) pkg_check_modules(Dtk REQUIRED IMPORTED_TARGET dtkwidget) pkg_check_modules(Dtk REQUIRED IMPORTED_TARGET dtkcore) @@ -99,6 +100,14 @@ install(FILES ${PROJECT_SOURCE_DIR}/assets/resources/icons/logo-big.svg RENAME deepin-movie.svg) install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/deepin-movie DESTINATION ${CMAKE_INSTALL_DATADIR}/deepin-manual/manual-assets/application/) +#hw机型增加DConfig配置 +set(APPID org.deepin.movie) +set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.movie.minimode.json) +if (DEFINED DSG_DATA_DIR) + message("-- DConfig is supported by DTK") + dconfig_meta_files(APPID ${APPID} FILES ${configFile}) +endif() + # 加速编译优化参数 if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "mips64") SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O3 -ftree-vectorize -march=loongson3a -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions -mloongson-ext2 -mloongson-mmi -Wl,--as-needed -fPIE -z noexecstack") diff --git a/src/common/mainwindow.cpp b/src/common/mainwindow.cpp index a7096656d..94572f3b9 100644 --- a/src/common/mainwindow.cpp +++ b/src/common/mainwindow.cpp @@ -1886,22 +1886,36 @@ void MainWindow::requestAction(ActionFactory::ActionKind actionKind, bool bFromU if (m_bMouseMoved) { // can't toggle minimode,when window is moving break; } - - QString result(cpuHardwareByDBus()); - bool boardVendorFlag = result.contains("PGUW", Qt::CaseInsensitive) - || result.contains("PANGU M900", Qt::CaseInsensitive); -// || result.contains("KLVU", Qt::CaseInsensitive) -// || result.contains("PGUV", Qt::CaseInsensitive) -// || result.contains("KLVV", Qt::CaseInsensitive) -// || result.contains("L540", Qt::CaseInsensitive); - - QProcess process; - process.start("bash", QStringList() << "-c" << "dmidecode | grep -i \"String 4\""); - process.waitForStarted(); - process.waitForFinished(); - result = process.readAll(); - boardVendorFlag = boardVendorFlag || result.contains("PWC30", Qt::CaseInsensitive); //w525 - process.close(); + bool boardVendorFlag = false; + int miniModeSpecialHandling = -1; +#ifdef DTKCORE_CLASS_DConfigFile + //wayland下需要查询是否支持特殊录屏模式,例如hw机型 + DConfig *dconfig = DConfig::create("org.deepin.movie","org.deepin.movie.minimode"); + if(dconfig && dconfig->isValid()){ + miniModeSpecialHandling = dconfig->value("miniModeSpecialHandling").toInt(); + } +#endif + qInfo() << "miniModeSpecialHandling value is:" << miniModeSpecialHandling; + if(miniModeSpecialHandling != -1){ + boardVendorFlag = miniModeSpecialHandling? true:false; + }else{ + QString result(cpuHardwareByDBus()); + boardVendorFlag = result.contains("PGUW", Qt::CaseInsensitive) + || result.contains("PANGU M900", Qt::CaseInsensitive); + // || result.contains("KLVU", Qt::CaseInsensitive) + // || result.contains("PGUV", Qt::CaseInsensitive) + // || result.contains("KLVV", Qt::CaseInsensitive) + // || result.contains("L540", Qt::CaseInsensitive); + + QProcess process; + process.start("bash", QStringList() << "-c" << "dmidecode | grep -i \"String 4\""); + process.waitForStarted(); + process.waitForFinished(); + result = process.readAll(); + boardVendorFlag = boardVendorFlag || result.contains("PWC30", Qt::CaseInsensitive); //w525 + process.close(); + } + qInfo() << "Whether special mini mode is supported? " << boardVendorFlag; int nDelayTime = 0; if (m_pPlaylist->state() == PlaylistWidget::Opened) { diff --git a/src/common/mainwindow.h b/src/common/mainwindow.h index fd4b5a5a9..aa82b9aa9 100644 --- a/src/common/mainwindow.h +++ b/src/common/mainwindow.h @@ -14,6 +14,9 @@ #include #include #include +#ifdef DTKCORE_CLASS_DConfigFile +#include +#endif #include #include