Skip to content

Commit

Permalink
feat: hw机型判断适配dconfig
Browse files Browse the repository at this point in the history
Description: hw机型判断适配dconfig

Log: hw机型判断适配dconfig

Task: https://pms.uniontech.com/task-view-276433.html
  • Loading branch information
hundundadi committed Jul 6, 2023
1 parent b7e47d8 commit c2665a1
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 16 deletions.
16 changes: 16 additions & 0 deletions assets/org.deepin.movie.minimode.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
1 change: 1 addition & 0 deletions debian/deepin-movie.install
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
49 changes: 33 additions & 16 deletions src/common/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#include <DInputDialog>
#include <DImageButton>
#include <DWidgetUtil>
#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>
#endif
#include <DSettingsWidgetFactory>
#include <DLineEdit>
#include <DFileDialog>
Expand Down Expand Up @@ -1886,22 +1889,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;

Check warning on line 1893 in src/common/mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
#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) {
Expand Down

0 comments on commit c2665a1

Please sign in to comment.