mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
add conversions from dbus types to AssignableInfo
This commit is contained in:
parent
8b80c9c9a6
commit
32ed6c460d
@ -1,10 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Device.hpp>
|
||||||
#include <QDBusArgument>
|
#include <QDBusArgument>
|
||||||
#include <QDBusVariant>
|
#include <QDBusVariant>
|
||||||
#include <QDBusMetaType>
|
#include <QDBusMetaType>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
namespace TC = TuxClocker;
|
||||||
|
|
||||||
namespace TuxClocker::DBus {
|
namespace TuxClocker::DBus {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -41,6 +44,17 @@ struct Range {
|
|||||||
arg.endStructure();
|
arg.endStructure();
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
TC::Device::AssignableInfo toAssignableInfo() {
|
||||||
|
auto min_v = min.variant();
|
||||||
|
auto max_v = max.variant();
|
||||||
|
|
||||||
|
if (min_v.type() == QMetaType::Int && max_v.type() == QMetaType::Int)
|
||||||
|
return TC::Device::Range<int>(min_v.value<int>(), max_v.value<int>());
|
||||||
|
if (min_v.type() == QMetaType::Double && max_v.type() == QMetaType::Double)
|
||||||
|
return TC::Device::Range<double>(min_v.value<double>(), max_v.value<double>());
|
||||||
|
// Should never reach here
|
||||||
|
return TC::Device::Range<int>(0, 0);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Enumeration {
|
struct Enumeration {
|
||||||
@ -60,6 +74,15 @@ struct Enumeration {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* MOC crap doubles this somewhere
|
||||||
|
TC::Device::AssignableInfo enumVecToAssignableInfo(QVector<Enumeration> enums) {
|
||||||
|
TC::Device::EnumerationVec v;
|
||||||
|
for (const auto &e : enums)
|
||||||
|
v.push_back(TC::Device::Enumeration(e.name.toStdString(), e.key));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
struct DeviceNode {
|
struct DeviceNode {
|
||||||
QString interface;
|
QString interface;
|
||||||
QString path;
|
QString path;
|
||||||
|
Loading…
Reference in New Issue
Block a user