Implement basic monitor interface
This commit is contained in:
parent
e5a5ff1958
commit
980da038b7
@ -38,7 +38,21 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto monitors = enumerateMonitors();
|
auto monitors = enumerateMonitors();
|
||||||
|
|
||||||
|
for(auto& monitor: monitors) {
|
||||||
|
const auto brightness = monitor.getBrightness();
|
||||||
|
|
||||||
|
qInfo(ltr("Monitor brightness: %1").arg(brightness));
|
||||||
|
|
||||||
|
if(!monitor.setBrightness(brightness)) {
|
||||||
|
qWarning(ltr("Failed to set brightness"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!monitor) {
|
||||||
|
qWarning(ltr("Monitor invalid"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
@ -19,6 +19,11 @@ class Monitor {
|
|||||||
Monitor() = delete;
|
Monitor() = delete;
|
||||||
~Monitor();
|
~Monitor();
|
||||||
|
|
||||||
|
bool setBrightness(float percentage);
|
||||||
|
float getBrightness();
|
||||||
|
|
||||||
|
operator bool() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PhysicalMonitor {
|
struct PhysicalMonitor {
|
||||||
PhysicalMonitor(HANDLE handle, const WCHAR* name) : handle(handle), name(name) {}
|
PhysicalMonitor(HANDLE handle, const WCHAR* name) : handle(handle), name(name) {}
|
||||||
@ -45,6 +50,11 @@ class Monitor {
|
|||||||
public:
|
public:
|
||||||
Monitor();
|
Monitor();
|
||||||
|
|
||||||
|
bool setBrightness(float);
|
||||||
|
float getBrightness();
|
||||||
|
|
||||||
|
operator bool() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,4 +9,19 @@ Monitor::Monitor()
|
|||||||
assert(!"Not implemented");
|
assert(!"Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Monitor::setBrightness(float)
|
||||||
|
{
|
||||||
|
assert(!"Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
float Monitor::getBrightness()
|
||||||
|
{
|
||||||
|
assert(!"Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
Monitor::operator bool() const
|
||||||
|
{
|
||||||
|
assert(!"Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
@ -28,6 +30,21 @@ Monitor::~Monitor()
|
|||||||
.arg(reinterpret_cast<qulonglong>(m_physicalMonitor.handle), 0, 16));
|
.arg(reinterpret_cast<qulonglong>(m_physicalMonitor.handle), 0, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Monitor::setBrightness(float percentage)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Monitor::getBrightness()
|
||||||
|
{
|
||||||
|
return NAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
Monitor::operator bool() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Monitor::hasBrightnessCapability() const
|
bool Monitor::hasBrightnessCapability() const
|
||||||
{
|
{
|
||||||
qDebug(ltr("Getting capabilities for monitor '%1' with handle '0x%2' and physical handle '0x%3'")
|
qDebug(ltr("Getting capabilities for monitor '%1' with handle '0x%2' and physical handle '0x%3'")
|
||||||
|
Loading…
Reference in New Issue
Block a user