修改以正确引入WinDevice项目
This commit is contained in:
parent
de8a41fff1
commit
50298ad6e8
2
.gitignore
vendored
2
.gitignore
vendored
@ -73,4 +73,6 @@ CMakeLists.txt.user*
|
|||||||
*.exe
|
*.exe
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
|
.vs
|
||||||
|
|
||||||
|
@ -9,13 +9,17 @@ set(CMAKE_AUTORCC ON)
|
|||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# 设置源代码文件编码为UTF-8
|
||||||
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||||
|
|
||||||
# 添加sdplog目录
|
# 添加sdplog目录
|
||||||
include_directories(include/third_lib/spdlog)
|
include_directories(include/third_lib)
|
||||||
# 添加WinDevice目录
|
|
||||||
include_directories(../WinDevice)
|
# 添加WinDevice项目
|
||||||
|
add_subdirectory(../WinDevice WinDevice)
|
||||||
|
|
||||||
set(PROJECT_SOURCES
|
set(PROJECT_SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
@ -48,6 +52,14 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
target_link_libraries(DeviceManager PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
# 链接WinDevice项目
|
||||||
|
target_include_directories(DeviceManager PRIVATE
|
||||||
|
../WinDevice
|
||||||
|
)
|
||||||
|
# 将WinDevice项目的头文件路径添加到DeviceManager项目中
|
||||||
|
target_include_directories(DeviceManager PRIVATE
|
||||||
|
../WinDevice/src # 根据实际路径进行修改
|
||||||
|
)
|
||||||
|
|
||||||
set_target_properties(DeviceManager PROPERTIES
|
set_target_properties(DeviceManager PROPERTIES
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include "Video/ScreenManager.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
1
WinDevice/.gitignore
vendored
Normal file
1
WinDevice/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/cmake-*
|
@ -1,24 +1,23 @@
|
|||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
|
||||||
project(WinDevice)
|
project(WinDevice VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
# 添加主项目的源文件
|
set(CMAKE_AUTOUIC ON)
|
||||||
add_executable(WinDevice
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTORCC ON)
|
||||||
|
|
||||||
)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# 设置头文件目录,包括spdlog头文件和功能模块的头文件目录
|
# 设置源代码文件编码为UTF-8
|
||||||
target_include_directories(WinDevice PRIVATE
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
|
||||||
include/
|
|
||||||
include/third_lib/
|
# 添加sdplog目录
|
||||||
src/Audio/
|
include_directories(include/third_lib)
|
||||||
src/Video/
|
|
||||||
src/Utils/
|
|
||||||
)
|
|
||||||
|
|
||||||
# 添加功能模块的源文件
|
# 添加功能模块的源文件
|
||||||
target_sources(WinDevice PRIVATE
|
set(PROJECT_SOURCES
|
||||||
src/Audio/*.cpp
|
"src/Audio"
|
||||||
src/Video/*.cpp
|
"src/Video"
|
||||||
src/Utils/*.cpp
|
"src/Utils"
|
||||||
)
|
)
|
||||||
|
@ -46,33 +46,33 @@ BOOL ScreenManager::_EnumMonitorProc(HMONITOR hMonitor)
|
|||||||
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
monitorInfo.cbSize = sizeof(MONITORINFOEX);
|
||||||
if (GetMonitorInfo(hMonitor, &monitorInfo))
|
if (GetMonitorInfo(hMonitor, &monitorInfo))
|
||||||
{
|
{
|
||||||
// 输出友好名称
|
// 输出友好名称
|
||||||
spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice),
|
spdlog::info("_UpdateMonitorInfoMap, szDevice:{0}, right:{1}, bottom:{2}", Wchar2String(monitorInfo.szDevice),
|
||||||
monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
monitorInfo.rcMonitor.right, monitorInfo.rcMonitor.bottom);
|
||||||
}
|
}
|
||||||
auto it = ScreenManager::_hMonitorInfoMap.find(hMonitor);
|
auto it = ScreenManager::_hMonitorInfoMap.find(hMonitor);
|
||||||
if (it != ScreenManager::_hMonitorInfoMap.end())
|
if (it != ScreenManager::_hMonitorInfoMap.end())
|
||||||
{
|
{
|
||||||
// 键已经存在,表示存在重复
|
// 键已经存在,表示存在重复
|
||||||
// 在这里处理重复的情况
|
// 在这里处理重复的情况
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ScreenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo));
|
ScreenManager::_hMonitorInfoMap.insert(std::make_pair(hMonitor, monitorInfo));
|
||||||
// 键不存在,表示没有重复
|
// 键不存在,表示没有重复
|
||||||
// 在这里处理非重复的情况
|
// 在这里处理非重复的情况
|
||||||
}
|
}
|
||||||
|
|
||||||
DISPLAYCONFIG_TARGET_DEVICE_NAME targetDeviceName = {};
|
DISPLAYCONFIG_TARGET_DEVICE_NAME targetDeviceName = {};
|
||||||
targetDeviceName.header.size = sizeof(targetDeviceName);
|
targetDeviceName.header.size = sizeof(targetDeviceName);
|
||||||
|
|
||||||
// 获取指定 HMONITOR 的目标设备名称信息
|
// 获取指定 HMONITOR 的目标设备名称信息
|
||||||
if (DisplayConfigGetDeviceInfo(&targetDeviceName.header) == ERROR_SUCCESS)
|
if (DisplayConfigGetDeviceInfo(&targetDeviceName.header) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
spdlog::info("_UpdateMonitorInfoMap, monitorDevicePath:{0}, monitorFriendlyDeviceName:{1}",
|
spdlog::info("_UpdateMonitorInfoMap, monitorDevicePath:{0}, monitorFriendlyDeviceName:{1}",
|
||||||
Wchar2String(targetDeviceName.monitorDevicePath), Wchar2String(targetDeviceName.monitorFriendlyDeviceName));
|
Wchar2String(targetDeviceName.monitorDevicePath), Wchar2String(targetDeviceName.monitorFriendlyDeviceName));
|
||||||
|
|
||||||
// 获取指定 HMONITOR 的分辨率信息
|
// 获取指定 HMONITOR 的分辨率信息
|
||||||
DEVMODE dm;
|
DEVMODE dm;
|
||||||
dm.dmSize = sizeof(DEVMODE);
|
dm.dmSize = sizeof(DEVMODE);
|
||||||
dm.dmDriverExtra = 0;
|
dm.dmDriverExtra = 0;
|
||||||
@ -101,7 +101,7 @@ BOOL CALLBACK ScreenManager::EnumMonitorsProc(HMONITOR hMonitor, HDC hdcMonitor,
|
|||||||
void ScreenManager::_UpdateMonitorInfoMap()
|
void ScreenManager::_UpdateMonitorInfoMap()
|
||||||
{
|
{
|
||||||
spdlog::info("=====GetInfoByEnumDisplayMonitors start=====");
|
spdlog::info("=====GetInfoByEnumDisplayMonitors start=====");
|
||||||
// 枚举显示器
|
// 枚举显示器
|
||||||
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorsProc, reinterpret_cast<LPARAM>(this));
|
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorsProc, reinterpret_cast<LPARAM>(this));
|
||||||
spdlog::info("=====GetInfoByEnumDisplayMonitors end=====");
|
spdlog::info("=====GetInfoByEnumDisplayMonitors end=====");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user