修改以正确引入WinDevice项目

This commit is contained in:
DevWiki 2023-10-10 11:54:29 +08:00
parent de8a41fff1
commit 50298ad6e8
6 changed files with 44 additions and 28 deletions

2
.gitignore vendored
View File

@ -73,4 +73,6 @@ CMakeLists.txt.user*
*.exe *.exe
.vscode .vscode
.idea
.vs

View File

@ -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
)
# WinDeviceDeviceManager
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

View File

@ -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
View File

@ -0,0 +1 @@
/cmake-*

View File

@ -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"
) )

View File

@ -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=====");
} }