diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
new file mode 100644
index 0000000..07b9785
--- /dev/null
+++ b/CMakeLists.txt.user
@@ -0,0 +1,423 @@
+
+
+
+
+
+ EnvironmentId
+ {fee06c99-aad9-4dcd-8049-533ec7195f7e}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ 0
+ false
+ true
+ false
+ 2
+ true
+ true
+ 0
+ 8
+ true
+ false
+ 1
+ true
+ true
+ true
+ *.md, *.MD, Makefile
+ false
+ true
+ true
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+ true
+ false
+ true
+ true
+ true
+ true
+
+ false
+
+
+ 0
+ true
+
+ true
+ true
+ Builtin.DefaultTidyAndClazy
+ 8
+ true
+
+
+
+ true
+
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ KDE Builder kit
+ KDE Builder kit
+ {fdedbf4d-4ea6-4ab8-9ea3-be8687b40e86}
+ 0
+ 0
+ 0
+
+ Debug
+ 2
+ false
+
+ -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DCMAKE_BUILD_TYPE:STRING=Debug
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ 0
+ /home/denis/repos/a811/build/KDE_Builder_kit-Debug
+
+
+
+
+ all
+
+ false
+
+ true
+ Build
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ Build
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Debug
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ Release
+ 2
+ false
+
+ -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DCMAKE_BUILD_TYPE:STRING=Release
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ /home/denis/repos/a811/build/KDE_Builder_kit-Release
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ RelWithDebInfo
+ 2
+ false
+
+ -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ /home/denis/repos/a811/build/KDE_Builder_kit-RelWithDebInfo
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Release with Debug Information
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ RelWithDebInfo
+ 2
+ false
+
+ -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ 0
+ /home/denis/repos/a811/build/KDE_Builder_kit-Profile
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Profile
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+ MinSizeRel
+ 2
+ false
+
+ -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
+-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
+-DCMAKE_GENERATOR:STRING=Unix Makefiles
+-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
+-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
+-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
+-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
+-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
+ /home/denis/repos/a811/build/KDE_Builder_kit-MinSizeRel
+
+
+
+
+ all
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+ Build
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ clean
+
+ false
+
+ true
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+ Clean
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ false
+
+ Minimum Size Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+ 5
+
+
+ 0
+ Deploy
+ Deploy
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+
+ false
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+ true
+ true
+ 0
+ true
+
+ 2
+
+ false
+ -e cpu-cycles --call-graph dwarf,4096 -F 250
+ kirigami-hello
+ CMakeProjectManager.CMakeRunConfiguration.kirigami-hello
+ kirigami-hello
+ true
+ true
+ true
+ true
+ true
+ /home/denis/repos/a811/build/KDE_Builder_kit-Debug/bin
+
+ 1
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 22
+
+
+ Version
+ 22
+
+
diff --git a/flake.nix b/flake.nix
index e0eaa6b..f768299 100644
--- a/flake.nix
+++ b/flake.nix
@@ -34,6 +34,7 @@
qt6.qtbase
libusb1
hidapi
+ ninja
];
};
};
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e726f34..33e377e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,10 +8,6 @@ ecm_add_qml_module(kirigami-hello
target_sources(kirigami-hello
PRIVATE
main.cpp
- conf.cpp
- conf.h
- test.h
- test.cpp
conf.cpp conf.h
)
diff --git a/src/Main.qml b/src/Main.qml
index 833e73d..83b152f 100644
--- a/src/Main.qml
+++ b/src/Main.qml
@@ -15,23 +15,6 @@ Kirigami.ApplicationWindow {
property var devices: Conf.deviceList
- function updateDevices() {
-
- for (var i = 0; i < devices.length; i++) {
- var component = Qt.createComponent("action.qml");
- var sprite = component.createObject(null, {
- text: devices[i],
- shortcut: StandardKey.Quit
- });
-
- drawer.actions.push(sprite);
- if (sprite == null) {
- // Error Handling
- console.log("Error creating object");
- }
- }
- }
-
// Window title
// i18nc() makes a string translatable
// and provides additional context for the translators
@@ -40,8 +23,7 @@ Kirigami.ApplicationWindow {
globalDrawer: Kirigami.GlobalDrawer {
id: drawer
isMenu: true
- actions: []
- Component.onCompleted: updateDevices()
+ actions: devices
}
// Set the first page that will be loaded when the app opens
diff --git a/src/action.qml b/src/action.qml
index c6fe3e9..f2a1ccb 100644
--- a/src/action.qml
+++ b/src/action.qml
@@ -4,11 +4,9 @@ import QtQuick.Layouts
import QtQuick.Controls as Controls
import org.kde.kirigami as Kirigami
-
- Kirigami.Action {
- text: "ff"
- //icon.name: "gtk-quit"
- shortcut: StandardKey.Quit
- //onTriggered: Conf.setDeviceList(null)
- }
-
+Kirigami.Action {
+ text: "ff"
+ icon.name: "gtk-quit"
+ shortcut: StandardKey.Quit
+ onTriggered: Conf.setDeviceList(null)
+}
diff --git a/src/conf.cpp b/src/conf.cpp
index 26e3a14..f1b428c 100644
--- a/src/conf.cpp
+++ b/src/conf.cpp
@@ -1,10 +1,9 @@
#include "conf.h"
#include
#include
-#include "test.h"
Conf::Conf(QObject *parent) : QObject(parent) {}
-QStringList Conf::deviceList()
+QList Conf::deviceList()
{
libusb_context *ctx;
int r = libusb_init(&ctx);
@@ -13,14 +12,14 @@ QStringList Conf::deviceList()
std::cout << libusb_error_name(r) << std::endl;
exit(1);
}
- QStringList deviceLists;
libusb_device **list;
libusb_device *found = NULL;
ssize_t cnt = libusb_get_device_list(ctx, &list);
- ssize_t i = 0;
- //std::cout << cnt << "\n";
- for (i = 0; i < cnt; i++)
+ QQmlEngine engine;
+ QList asd;
+
+ for (ssize_t i = 0; i < cnt; i++)
{
libusb_device *device = list[i];
found = device;
@@ -29,39 +28,20 @@ QStringList Conf::deviceList()
libusb_device_descriptor desc;
libusb_get_device_descriptor(found, &desc);
QString formattedString = QString::asprintf("%04X:%04X", desc.idVendor, desc.idProduct);
- deviceLists.append(formattedString);
- //std::cout << "Bus " << unsigned(bus) << " Device " << unsigned(addr) << ": ID " << std::hex << desc.idVendor << ":" << desc.idProduct << std::dec << std::endl;
+ QQmlComponent component(&engine,
+ QUrl::fromLocalFile(QString::fromStdString("/home/denis/repos/a811/src/action.qml")));
+ QObject *object = component.create();
+ QQmlProperty::write(object, QString::fromStdString("text"), formattedString);
+ //object->setProperty("shortcut", QString::fromStdString("StandardKey.Quit"));
+ //object->setProperty("icon.name", QString::fromStdString("application-exit-symbolic"));
+ //object->setProperty("onTriggered", QString::fromStdString("showPassiveNotification('Action 2 clicked')"));
+ asd.append(object);
}
- return deviceLists;
+ return asd;
}
-void Conf::setDeviceList(QStringList deviceList)
+void Conf::setDeviceList(QList deviceList)
{
- QStringList deviceLists;
- libusb_device **list;
- libusb_device *found = NULL;
- ssize_t cnt = libusb_get_device_list(NULL, &list);
- ssize_t i = 0;
- std::cout << cnt << "\n";
-
- for (i = 0; i < cnt; i++)
- {
- libusb_device *device = list[i];
- found = device;
- uint8_t addr = libusb_get_device_address(found);
- uint8_t bus = libusb_get_bus_number(found);
- libusb_device_descriptor desc;
- libusb_get_device_descriptor(found, &desc);
- deviceLists << QString::number(desc.idVendor) << QString::fromUtf8(":") << QString::number(desc.idProduct);
- std::cout << "Bus " << unsigned(bus) << " Device " << unsigned(addr) << ": ID " << std::hex << desc.idVendor << ":" << desc.idProduct << std::dec << std::endl;
- if (desc.idProduct == 0x2f && desc.idVendor == 0x258a)
- {
- // std::cout << std::hex << (int)(desc.bNumConfigurations) << std::endl;
- break;
- }
- }
-
- m_deviceList = deviceLists;
Q_EMIT deviceListChanged();
}
\ No newline at end of file
diff --git a/src/conf.h b/src/conf.h
index 1d222aa..0953ae3 100644
--- a/src/conf.h
+++ b/src/conf.h
@@ -6,23 +6,26 @@
#include
#include
#include
+#include
+#include
+#include
class Conf : public QObject
{
Q_OBJECT
- Q_PROPERTY(QStringList deviceList READ deviceList WRITE setDeviceList NOTIFY deviceListChanged)
+ Q_PROPERTY(QList deviceList READ deviceList WRITE setDeviceList NOTIFY deviceListChanged)
public:
explicit Conf(QObject *parent = nullptr);
- QStringList deviceList();
- Q_INVOKABLE void setDeviceList(QStringList deviceList);
+ QList deviceList();
+ Q_INVOKABLE void setDeviceList(QList deviceList);
Q_SIGNAL void deviceListChanged();
Q_SIGNALS:
private:
- QStringList m_deviceList = {QString::fromStdString("nullptr"), QString::fromStdString("bsd")};
+ QList m_deviceList;
};
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 77ba407..6ba7fa9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -32,8 +32,6 @@ int main(int argc, char *argv[])
QApplication::setApplicationName(QStringLiteral("Kirigami Tutorial"));
QApplication::setDesktopFileName(QStringLiteral("org.kde.tutorial"));
-
-
QApplication::setStyle(QStringLiteral("breeze"));
if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE"))
{
@@ -49,8 +47,6 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.loadFromModule("org.kde.tutorial", "Main");
-
-
if (engine.rootObjects().isEmpty())
{
return -1;
@@ -165,7 +161,5 @@ int main(int argc, char *argv[])
libusb_free_device_list(list, 1);
-
-
return app.exec();
}
diff --git a/src/test.cpp b/src/test.cpp
deleted file mode 100644
index 493a113..0000000
--- a/src/test.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "test.h"
-
-DataEntryModel::DataEntryModel(QObject *parent)
- : QAbstractListModel(parent)
-{
- // initialize our data (QList) with a list of color names
- m_data = QColor::colorNames();
-}
-
-DataEntryModel::~DataEntryModel()
-{
-}
-
-int DataEntryModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- // return our data count
- return m_data.count();
-}
-
-QVariant DataEntryModel::data(const QModelIndex &index, int role) const
-{
- // the index returns the requested row and column information.
- // we ignore the column and only use the row information
- int row = index.row();
-
- // boundary check for the row
- if(row < 0 || row >= m_data.count()) {
- return QVariant();
- }
-
- // A model can return data for different roles.
- // The default role is the display role.
- // it can be accesses in QML with "model.display"
- switch(role) {
- case Qt::DisplayRole:
- // Return the color name for the particular row
- // Qt automatically converts it to the QVariant type
- return m_data.value(row);
- }
-
- // The view asked for other data, just return an empty QVariant
- return QVariant();
-}
diff --git a/src/test.h b/src/test.h
deleted file mode 100644
index df3ccb2..0000000
--- a/src/test.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef DATAENTRYMODEL_H
-#define DATAENTRYMODEL_H
-
-#include
-#include
-
-class DataEntryModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit DataEntryModel(QObject *parent = 0);
- ~DataEntryModel();
-
-public: // QAbstractItemModel interface
- virtual int rowCount(const QModelIndex &parent) const;
- virtual QVariant data(const QModelIndex &index, int role) const;
-private:
- QList m_data;
-};
-
-#endif // DATAENTRYMODEL_H