make bluetooth service singleton

This commit is contained in:
2025-12-23 19:57:52 +01:00
parent 8613024f8d
commit a06c96f648
14 changed files with 148 additions and 65 deletions

View File

@@ -2,14 +2,17 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <string>
#include <vector>
#include "sigc++/signal.h"
class BluetoothService {
static BluetoothService *instance;
public:
BluetoothService();
sigc::signal<void(bool)> powerStateChangedSignal;
sigc::signal<void(bool)> isDiscoveringChangedSignal;
bool getPowerState();
@@ -19,10 +22,22 @@ class BluetoothService {
void togglePowerState();
void toggleIsDiscovering();
private:
static BluetoothService *getInstance() {
if (BluetoothService::instance == nullptr) {
BluetoothService::instance = new BluetoothService();
}
return BluetoothService::instance;
}
private:
BluetoothService();
GDBusProxy *adapter_proxy = nullptr;
bool powerState = false;
bool isDiscovering = false;
std::vector<std::string> getDeviceObjectPaths();
bool powerState = false;
bool isDiscovering = false;
void onPropertyChanged(GDBusProxy *proxy,
GVariant *changed_properties,