Add function to get monitor name

This commit is contained in:
BlackMark 2020-07-12 21:02:51 +02:00
parent 86dbcfda4f
commit 994e08bebc
2 changed files with 12 additions and 0 deletions

View File

@ -10,6 +10,8 @@
#include <physicalmonitorenumerationapi.h>
#include <windows.h>
#include <QString>
namespace detail {
extern BOOL enumMonitorsCallback(HMONITOR, HDC, LPRECT, LPARAM);
@ -26,6 +28,8 @@ class Monitor {
bool setBrightness(float percentage);
float getBrightness();
QString getName() const;
operator bool() const;
private:

View File

@ -113,6 +113,14 @@ float Monitor::getBrightness()
return std::clamp(utils::map(brightness, minBrightness, maxBrightness, 0.f, 1.f), 0.f, 1.f);
}
QString Monitor::getName() const
{
return QString("%1 (0x%2:0x%3)")
.arg(m_physicalMonitor.name)
.arg(reinterpret_cast<qulonglong>(m_hMonitor), 0, 16)
.arg(reinterpret_cast<qulonglong>(m_physicalMonitor.handle), 0, 16);
}
Monitor::operator bool() const
{
return !m_errorOccurred;