add new GUI that uses dbus instead of the library directly

This commit is contained in:
Jussi Kuokkanen 2020-05-06 20:24:10 +03:00
parent 81b364c8ef
commit 40d740fd6b
6 changed files with 87 additions and 2 deletions

View File

@ -4,3 +4,4 @@ option('daemon', type: 'boolean', value: 'false', description: 'Build daemon')
option('plugins', type: 'boolean', value: 'true', description: 'Build plugins')
option('interfaces', type: 'boolean', value: 'false', description: 'Build interfaces')
option('library', type: 'boolean', value: 'true', description: 'Build library')
option('gui', type: 'boolean', value: 'false', description: 'Build Qt GUI')

View File

@ -33,10 +33,11 @@ plugin_path_def = plugin_path_def_template.format(get_option('prefix'), get_opti
# install : true)
libtuxclocker = shared_library('tuxclocker',
['lib/Plugin.cpp'],
['lib/Crypto.cpp',
'lib/Plugin.cpp'],
override_options : ['cpp_std=c++17'],
include_directories : incdir,
dependencies : [boost_dep, dl],
dependencies : [boost_dep, dl, openssl_dep],
cpp_args : plugin_path_def,
install : true)
@ -54,3 +55,7 @@ endif
if get_option('daemon')
subdir('tuxclockerd')
endif
if get_option('gui')
subdir('tuxclocker-qt')
endif

View File

@ -0,0 +1,33 @@
#include <DBusTypes.hpp>
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusMetaType>
#include <QDBusReply>
#include <QDebug>
#include <QString>
#include <QVector>
#include "MainWindow.hpp"
namespace TCDBus = TuxClocker::DBus;
Q_DECLARE_METATYPE(TCDBus::DeviceNode)
Q_DECLARE_METATYPE(TCDBus::FlatTreeNode<TCDBus::DeviceNode>)
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
qDBusRegisterMetaType<TCDBus::DeviceNode>();
qDBusRegisterMetaType<TCDBus::FlatTreeNode<TCDBus::DeviceNode>>();
qDBusRegisterMetaType<QVector<TCDBus::FlatTreeNode<TCDBus::DeviceNode>>>();
auto conn = QDBusConnection::systemBus();
QDBusInterface tuxclockerd("org.tuxclocker", "/", "org.tuxclocker", conn);
QDBusReply<QVector<TCDBus::FlatTreeNode<TCDBus::DeviceNode>>> reply =
tuxclockerd.call("flatDeviceTree");
if (reply.isValid()) {
auto flatTree = reply.value();
for (auto &f_node : flatTree)
qDebug() << f_node.childIndices << f_node.value.interface;
}
}

View File

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

View File

@ -0,0 +1,21 @@
#include <QApplication>
#include "MainWindow.hpp"
#include <QDBusConnection>
int main(int argc, char **argv) {
QApplication app(argc, argv);
MainWindow mw;
mw.show();
QObject o;
auto conn = QDBusConnection::sessionBus();
conn.registerObject("/", &o);
conn.registerService("org.tuxclockerqt");
return app.exec();
}

View File

@ -0,0 +1,15 @@
qt5 = import('qt5')
qt5_dep = dependency('qt5', modules: ['DBus', 'Charts', 'Widgets'])
moc_files = qt5.preprocess(moc_headers: ['MainWindow.hpp'],
dependencies: qt5_dep)
sources = ['main.cpp',
'MainWindow.cpp']
executable('tuxclocker-qt',
moc_files,
sources,
dependencies: qt5_dep,
include_directories: [incdir],
install: true)