interface: add Qt interface

This commit is contained in:
jussi 2019-09-24 19:43:18 +03:00
parent 981bb36a13
commit a2317e71aa
9 changed files with 82 additions and 2 deletions

View File

@ -1,4 +1,4 @@
project('tuxclocker', 'c')
project('tuxclocker', 'c', 'cpp')
cc = meson.get_compiler('c')

View File

@ -18,6 +18,9 @@ tc_module_t *tc_module_find(enum tc_module_category category, const char *name)
case TC_CATEGORY_ASSIGNABLE:
snprintf(abs_env_path, 128, "%s/%s/%s", env_module_path, "assignable", name);
break;
case TC_CATEGORY_INTERFACE:
snprintf(abs_env_path, 128, "%s/%s/%s", env_module_path, "interface", name);
break;
default:
return NULL;
}

View File

@ -7,10 +7,11 @@
int main(int argc, char **argv) {
// Load an interface here
tc_module_t *mod = tc_module_find(TC_CATEGORY_ASSIGNABLE, "libnvidia.so");
tc_module_t *mod = tc_module_find(TC_CATEGORY_INTERFACE, "/qt/libqt.so");
if (mod != NULL) {
printf("successful load for %s\n", mod->name);
mod->init_callback(argc, argv);
}
return 0;

View File

@ -0,0 +1 @@
subdir('qt')

View File

@ -0,0 +1,7 @@
#include "MainWindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
}
MainWindow::~MainWindow() {
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
};

View File

@ -0,0 +1,37 @@
#include "MainWindow.h"
#include <tc_interface.h>
#include <tc_module.h>
#include <QApplication>
int main(int argc, char **argv);
// Don't scramble the interaction point symbols
extern "C" {
// Module Information
static tc_module_t mod_info = {
.category = TC_CATEGORY_INTERFACE,
.name = "qt",
.description = "Qt Interface",
.init_callback = (int8_t (*)()) &main,
.close_callback = NULL
};
tc_module_t *TC_MODULE_INFO_FUNCTION();
tc_module_t *TC_MODULE_INFO_FUNCTION() {
return &mod_info;
}
}
int main(int argc, char **argv) {
QApplication app(argc, argv);
MainWindow mw;
mw.show();
return app.exec();
}

View File

@ -0,0 +1,15 @@
qt5 = import('qt5')
qt5_dep = dependency('qt5',
modules : ['Widgets'])
moc_files = qt5.preprocess(moc_headers : [ 'MainWindow.h'],
dependencies : qt5_dep)
sources = ['main.cpp',
'MainWindow.cpp']
shared_library('qt',
sources,
moc_files,
include_directories : incdir,
dependencies : qt5_dep)

View File

@ -1 +1,2 @@
subdir('assignable')
subdir('interface')