Somethings working
This commit is contained in:
parent
de6ce3178f
commit
1808515221
16
src/Main.qml
16
src/Main.qml
|
|
@ -13,7 +13,7 @@ Kirigami.ApplicationWindow {
|
|||
width: 400
|
||||
height: 300
|
||||
|
||||
property var devices: Conf.deviceList
|
||||
property var devices: Conf.stat
|
||||
|
||||
// Window title
|
||||
// i18nc() makes a string translatable
|
||||
|
|
@ -23,7 +23,14 @@ Kirigami.ApplicationWindow {
|
|||
globalDrawer: Kirigami.GlobalDrawer {
|
||||
id: drawer
|
||||
isMenu: true
|
||||
actions: devices
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: "fff"
|
||||
icon.name: "gtk-quit"
|
||||
shortcut: StandardKey.Quit
|
||||
onTriggered: Conf.deviceConfig()
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// Set the first page that will be loaded when the app opens
|
||||
|
|
@ -35,6 +42,9 @@ Kirigami.ApplicationWindow {
|
|||
anchors.centerIn: parent
|
||||
text: i18n("Hello World!")
|
||||
}
|
||||
Controls.TextField {
|
||||
placeholderText: qsTr("Enter name")
|
||||
}
|
||||
Component {
|
||||
id: nameDelegate
|
||||
Text {
|
||||
|
|
@ -42,6 +52,8 @@ Kirigami.ApplicationWindow {
|
|||
font.pixelSize: 32
|
||||
}
|
||||
}
|
||||
actions: [
|
||||
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
src/conf.cpp
42
src/conf.cpp
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
Conf::Conf(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_conf1 = (conf_1 *)malloc(sizeof(conf_1));
|
||||
m_conf2 = (conf_2 *)malloc(sizeof(conf_2));
|
||||
|
||||
int r = libusb_init(&m_ctx);
|
||||
if (r < 0)
|
||||
{
|
||||
|
|
@ -17,8 +20,6 @@ Conf::Conf(QObject *parent) : QObject(parent)
|
|||
{
|
||||
libusb_device *device = list[i];
|
||||
m_device = device;
|
||||
uint8_t addr = libusb_get_device_address(m_device);
|
||||
uint8_t bus = libusb_get_bus_number(m_device);
|
||||
libusb_device_descriptor desc;
|
||||
libusb_get_device_descriptor(m_device, &desc);
|
||||
if (desc.idProduct == 0x2f && desc.idVendor == 0x258a)
|
||||
|
|
@ -26,19 +27,38 @@ Conf::Conf(QObject *parent) : QObject(parent)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//read initial config from device
|
||||
readConfigFromDevice(m_conf1);
|
||||
readConfigFromDevice(m_conf2);
|
||||
|
||||
libusb_free_device_list(list, 1);
|
||||
}
|
||||
QList<QObject *> Conf::deviceList()
|
||||
|
||||
ssize_t Conf::lightMode(){
|
||||
return m_conf1->light_mode;
|
||||
}
|
||||
|
||||
void Conf::setLightMode(ssize_t mode){
|
||||
m_conf1->light_mode = mode;
|
||||
|
||||
|
||||
Q_EMIT lightModeChanged();
|
||||
}
|
||||
|
||||
ssize_t Conf::deviceConfig()
|
||||
{
|
||||
conf_1 *conf = (conf_1 *)malloc(sizeof(conf_1));
|
||||
conf_2 *conf2 = (conf_2 *)malloc(sizeof(conf_2));
|
||||
|
||||
writeConfigToDevice(m_conf1);
|
||||
|
||||
// readConfigFromDevice(conf);
|
||||
readConfigFromFile("conf1.bin", conf);
|
||||
readConfigFromDevice(conf2);
|
||||
|
||||
// edit data
|
||||
// conf->light_mode = 0x2;
|
||||
conf->light_mode = 0x1;
|
||||
conf->req_type = 0x92;
|
||||
conf->st_brightness_colnr = {0x16};
|
||||
conf->col_steady[18] = 0x00;
|
||||
|
|
@ -54,20 +74,12 @@ QList<QObject *> Conf::deviceList()
|
|||
writeConfigToFile(conf, "conf1.bin");
|
||||
writeConfigToFile(conf2, "conf2.bin");
|
||||
|
||||
QQmlEngine engine;
|
||||
|
||||
QList<QObject *> asd;
|
||||
QQmlComponent component(&engine,
|
||||
QUrl::fromLocalFile(QString::fromStdString("/home/denis/repos/a811/src/action.qml")));
|
||||
QObject *object = component.create();
|
||||
asd.append(object);
|
||||
|
||||
return asd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Conf::setDeviceList(QList<QObject *> deviceList)
|
||||
void Conf::setDeviceConfig(ssize_t stat)
|
||||
{
|
||||
Q_EMIT deviceListChanged();
|
||||
Q_EMIT deviceConfigChanged();
|
||||
}
|
||||
|
||||
ssize_t Conf::writeConfigToDevice(conf_2 *conf)
|
||||
|
|
|
|||
19
src/conf.h
19
src/conf.h
|
|
@ -19,13 +19,19 @@
|
|||
class Conf : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QList<QObject *> deviceList READ deviceList WRITE setDeviceList NOTIFY deviceListChanged)
|
||||
Q_PROPERTY(ssize_t deviceConfig READ deviceConfig WRITE setDeviceConfig NOTIFY deviceConfigChanged)
|
||||
Q_PROPERTY(ssize_t lightMode READ lightMode WRITE setLightMode NOTIFY lightModeChanged)
|
||||
|
||||
public:
|
||||
explicit Conf(QObject *parent = nullptr);
|
||||
QList<QObject *> deviceList();
|
||||
Q_INVOKABLE void setDeviceList(QList<QObject *> deviceList);
|
||||
Q_SIGNAL void deviceListChanged();
|
||||
ssize_t deviceConfig();
|
||||
Q_INVOKABLE void setDeviceConfig(ssize_t stat);
|
||||
Q_SIGNAL void deviceConfigChanged();
|
||||
|
||||
ssize_t lightMode();
|
||||
Q_INVOKABLE void setLightMode(ssize_t mode);
|
||||
Q_SIGNAL void lightModeChanged();
|
||||
|
||||
ssize_t writeConfigToFile(conf_1 *conf, const char *filePath);
|
||||
ssize_t writeConfigToFile(conf_2 *conf, const char *filePath);
|
||||
ssize_t readConfigFromFile(const char *filePath, conf_1 *conf);
|
||||
|
|
@ -38,7 +44,10 @@ public:
|
|||
Q_SIGNALS:
|
||||
|
||||
private:
|
||||
QList<QObject *> m_deviceList;
|
||||
ssize_t m_stat;
|
||||
ssize_t m_lightMode;
|
||||
conf_1* m_conf1;
|
||||
conf_2* m_conf2;
|
||||
libusb_device* m_device = NULL;
|
||||
libusb_context* m_ctx = NULL;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
KIconTheme::initTheme(); // this is not available in nixpkgs version of
|
||||
// KiconTheme
|
||||
// KiconTheme // how did i fix this??????
|
||||
QApplication app(argc, argv);
|
||||
KLocalizedString::setApplicationDomain("tutorial");
|
||||
QApplication::setOrganizationName(QStringLiteral("KDE"));
|
||||
|
|
|
|||
Loading…
Reference in a new issue