Compare commits
3 Commits
7b791a071b
...
994e08bebc
Author | SHA1 | Date | |
---|---|---|---|
994e08bebc | |||
86dbcfda4f | |||
5e4aba8140 |
@ -10,6 +10,8 @@
|
|||||||
#include <physicalmonitorenumerationapi.h>
|
#include <physicalmonitorenumerationapi.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
extern BOOL enumMonitorsCallback(HMONITOR, HDC, LPRECT, LPARAM);
|
extern BOOL enumMonitorsCallback(HMONITOR, HDC, LPRECT, LPARAM);
|
||||||
@ -26,6 +28,8 @@ class Monitor {
|
|||||||
bool setBrightness(float percentage);
|
bool setBrightness(float percentage);
|
||||||
float getBrightness();
|
float getBrightness();
|
||||||
|
|
||||||
|
QString getName() const;
|
||||||
|
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -24,6 +24,8 @@ Monitor::Monitor(Monitor&& other) noexcept
|
|||||||
other.m_hMonitor = 0;
|
other.m_hMonitor = 0;
|
||||||
other.m_physicalMonitor.name.clear();
|
other.m_physicalMonitor.name.clear();
|
||||||
other.m_physicalMonitor.handle = 0;
|
other.m_physicalMonitor.handle = 0;
|
||||||
|
other.m_brightnessRange.reset();
|
||||||
|
other.m_errorOccurred = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Monitor::~Monitor()
|
Monitor::~Monitor()
|
||||||
@ -111,6 +113,14 @@ float Monitor::getBrightness()
|
|||||||
return std::clamp(utils::map(brightness, minBrightness, maxBrightness, 0.f, 1.f), 0.f, 1.f);
|
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
|
Monitor::operator bool() const
|
||||||
{
|
{
|
||||||
return !m_errorOccurred;
|
return !m_errorOccurred;
|
||||||
|
@ -15,6 +15,13 @@ Sensor::~Sensor()
|
|||||||
qDebug(ltr("Destroying sensor on serial port %1").arg(m_serialPortName));
|
qDebug(ltr("Destroying sensor on serial port %1").arg(m_serialPortName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sensor::Sensor(Sensor&& other) noexcept : m_serialPortName(other.m_serialPortName), m_errorOccurred(other.m_errorOccurred), m_range(other.m_range)
|
||||||
|
{
|
||||||
|
other.m_serialPortName.clear();
|
||||||
|
other.m_errorOccurred = false;
|
||||||
|
other.m_range.reset();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<float> Sensor::readValues()
|
std::vector<float> Sensor::readValues()
|
||||||
{
|
{
|
||||||
qDebug(ltr("Reading values of sensor on port %1").arg(m_serialPortName));
|
qDebug(ltr("Reading values of sensor on port %1").arg(m_serialPortName));
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
class Sensor {
|
class Sensor {
|
||||||
public:
|
public:
|
||||||
|
Sensor(const Sensor&) = delete;
|
||||||
|
Sensor(Sensor&& other) noexcept;
|
||||||
~Sensor();
|
~Sensor();
|
||||||
|
|
||||||
std::vector<float> readValues();
|
std::vector<float> readValues();
|
||||||
@ -26,7 +28,7 @@ class Sensor {
|
|||||||
|
|
||||||
static constexpr auto SUPPORTED_FIRMWARE = std::string_view{"AdaptiveBrightness v1.2"};
|
static constexpr auto SUPPORTED_FIRMWARE = std::string_view{"AdaptiveBrightness v1.2"};
|
||||||
|
|
||||||
const QString m_serialPortName;
|
QString m_serialPortName;
|
||||||
bool m_errorOccurred = false;
|
bool m_errorOccurred = false;
|
||||||
|
|
||||||
std::optional<std::pair<int, int>> m_range;
|
std::optional<std::pair<int, int>> m_range;
|
||||||
|
@ -21,7 +21,7 @@ std::vector<Sensor> enumerateSensors()
|
|||||||
auto sensor = Sensor(portInfo.portName());
|
auto sensor = Sensor(portInfo.portName());
|
||||||
if(sensor.isValidSensor()) {
|
if(sensor.isValidSensor()) {
|
||||||
qInfo(ltr("Successfully enumerated sensor on port %1").arg(portInfo.portName()));
|
qInfo(ltr("Successfully enumerated sensor on port %1").arg(portInfo.portName()));
|
||||||
sensors.push_back(sensor);
|
sensors.push_back(std::move(sensor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user