mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-16 14:34:46 -06:00
add new GUI that uses dbus instead of the library directly
This commit is contained in:
parent
81b364c8ef
commit
40d740fd6b
@ -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')
|
||||
|
@ -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
|
||||
|
33
src/tuxclocker-qt/MainWindow.cpp
Normal file
33
src/tuxclocker-qt/MainWindow.cpp
Normal 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;
|
||||
}
|
||||
}
|
10
src/tuxclocker-qt/MainWindow.hpp
Normal file
10
src/tuxclocker-qt/MainWindow.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
private:
|
||||
Q_OBJECT
|
||||
};
|
21
src/tuxclocker-qt/main.cpp
Normal file
21
src/tuxclocker-qt/main.cpp
Normal 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();
|
||||
}
|
15
src/tuxclocker-qt/meson.build
Normal file
15
src/tuxclocker-qt/meson.build
Normal 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)
|
Loading…
Reference in New Issue
Block a user