diff --git a/CMakeLists.txt b/CMakeLists.txt index 554dfaa77..ac9661e78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ message(STATUS DEEPIN_NMQT_TEST ": ${DEEPIN_NMQT_TEST}") if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "/usr") endif() +include(GNUInstallDirs) add_subdirectory("src") add_subdirectory("dcc-network-plugin") diff --git a/dcc-network-plugin/CMakeLists.txt b/dcc-network-plugin/CMakeLists.txt index 759143c35..74a7dec6d 100644 --- a/dcc-network-plugin/CMakeLists.txt +++ b/dcc-network-plugin/CMakeLists.txt @@ -82,9 +82,6 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE # ${DDE-Network-Core_LIBRARIES} ) -# 设置安装路径的前缀(默认为"/usr/local") -set(CMAKE_INSTALL_PREFIX "/usr") - # 设置执行 make install 时哪个目标应该被 install 到哪个位置 install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/dde-control-center/modules) diff --git a/dock-network-plugin/CMakeLists.txt b/dock-network-plugin/CMakeLists.txt index f55e375c0..3096e0511 100644 --- a/dock-network-plugin/CMakeLists.txt +++ b/dock-network-plugin/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.7) set(PLUGIN_NAME "dock-network-plugin") project(${PLUGIN_NAME}) -include(GNUInstallDirs) # 启用 qt moc 的支持 set(CMAKE_AUTOMOC ON) # 启用 qrc 资源文件的支持 @@ -67,6 +66,6 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE ${Qt5Network_LIBRARIES} ) -install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION /usr/lib/dde-dock/plugins/quick-trays) +install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/quick-trays) # 安装 .qm 文件 install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PLUGIN_NAME}/translations) diff --git a/dock-network-plugin/networkplugin.cpp b/dock-network-plugin/networkplugin.cpp index 99748fd74..c522a704e 100644 --- a/dock-network-plugin/networkplugin.cpp +++ b/dock-network-plugin/networkplugin.cpp @@ -31,7 +31,10 @@ NetworkPlugin::NetworkPlugin(QObject *parent) { NetworkController::setIPConflictCheck(true); QTranslator *translator = new QTranslator(this); - translator->load(QString("/usr/share/dock-network-plugin/translations/dock-network-plugin_%1.qm").arg(QLocale::system().name())); + QString languagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QString("dock-network-plugin/translations"), + QStandardPaths::LocateDirectory); + translator->load(QString(languagePath+"/dock-network-plugin_%1.qm").arg(QLocale::system().name())); QCoreApplication::installTranslator(translator); } diff --git a/dss-network-plugin/CMakeLists.txt b/dss-network-plugin/CMakeLists.txt index d0036b290..e2dc8c540 100644 --- a/dss-network-plugin/CMakeLists.txt +++ b/dss-network-plugin/CMakeLists.txt @@ -4,7 +4,6 @@ set(PLUGIN_NAME "dss-network-plugin") project(${PLUGIN_NAME}) -include(GNUInstallDirs) # 启用 qt moc 的支持 set(CMAKE_AUTOMOC ON) # 启用 qrc 资源文件的支持 @@ -63,7 +62,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE ${Qt5Network_LIBRARIES} ) -install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION /lib/dde-session-shell/modules) +install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-session-shell/modules) # 安装 .qm 文件 install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PLUGIN_NAME}/translations) diff --git a/dss-network-plugin/network_module.cpp b/dss-network-plugin/network_module.cpp index 4809f22d3..87dc3806f 100644 --- a/dss-network-plugin/network_module.cpp +++ b/dss-network-plugin/network_module.cpp @@ -152,7 +152,10 @@ void NetworkModule::installTranslator(QString locale) } localTmp = locale; QApplication::removeTranslator(&translator); - translator.load(QString("/usr/share/dss-network-plugin/translations/dss-network-plugin_%1.qm").arg(locale)); + QString languagePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QString("dss-network-plugin/translations"), + QStandardPaths::LocateDirectory); + translator.load(QString(languagePath+"/dss-network-plugin_%1.qm").arg(locale)); QApplication::installTranslator(&translator); dde::network::NetworkController::instance()->retranslate(); m_networkHelper->updateTooltips(); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9b36d1cb0..db539b59a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -include(GNUInstallDirs) set(CMAKE_PREFIX_PATH $ENV{Qt5_DIR}) file(GLOB_RECURSE SOURCEFILES "*.h" "*.cpp") diff --git a/src/proxycontroller.cpp b/src/proxycontroller.cpp index ad0c58904..98b28434f 100644 --- a/src/proxycontroller.cpp +++ b/src/proxycontroller.cpp @@ -6,8 +6,7 @@ #include "networkdbusproxy.h" #include - -const QString chains4Path = "/usr/bin/proxychains4"; +#include using namespace dde::network; @@ -33,7 +32,7 @@ ProxyController::ProxyController(NetworkDBusProxy *networkInter, QObject *parent m_appProxyConfig.username = m_networkInter->user(); m_appProxyConfig.password = m_networkInter->password(); // 判断是否存在proxychains4来决定是否存在应用代理 - m_appProxyExist = QFile().exists(chains4Path); + m_appProxyExist = !QStandardPaths::findExecutable("proxychains4").isEmpty(); } ProxyController::~ProxyController()