mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-26 17:03:08 +00:00
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2026 A-La-Karte Contributors
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QVariantList>
|
|
#include <QVariantMap>
|
|
|
|
class QDBusServiceWatcher;
|
|
|
|
class InputServiceClient : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
|
|
Q_PROPERTY(QString lastError READ lastError NOTIFY lastErrorChanged)
|
|
Q_PROPERTY(QVariantList controllers READ controllers NOTIFY controllersChanged)
|
|
Q_PROPERTY(QVariantList profiles READ profiles NOTIFY profilesChanged)
|
|
|
|
public:
|
|
explicit InputServiceClient(QObject *parent = nullptr);
|
|
~InputServiceClient() override;
|
|
|
|
bool available() const;
|
|
QString lastError() const;
|
|
|
|
QVariantList controllers() const;
|
|
QVariantList profiles() const;
|
|
|
|
Q_INVOKABLE void refresh();
|
|
Q_INVOKABLE void refreshControllers();
|
|
Q_INVOKABLE void refreshProfiles();
|
|
|
|
Q_INVOKABLE bool setActiveProfile(const QString &controllerId, const QString &profileId);
|
|
Q_INVOKABLE QString createProfile(const QString &name);
|
|
Q_INVOKABLE bool deleteProfile(const QString &profileId);
|
|
|
|
Q_SIGNALS:
|
|
void availableChanged();
|
|
void lastErrorChanged();
|
|
void controllersChanged();
|
|
void profilesChanged();
|
|
|
|
private Q_SLOTS:
|
|
void onControllerAdded(QVariantMap controller);
|
|
void onControllerChanged(QVariantMap controller);
|
|
void onControllerRemoved(const QString &controllerId);
|
|
void onProfilesChanged();
|
|
|
|
private:
|
|
void ensureService();
|
|
void connectSignals();
|
|
void setAvailable(bool available);
|
|
void setLastError(const QString &error);
|
|
|
|
void upsertController(const QVariantMap &controller);
|
|
void removeControllerById(const QString &controllerId);
|
|
|
|
bool m_available = false;
|
|
QString m_lastError;
|
|
|
|
QVariantList m_controllers;
|
|
QVariantList m_profiles;
|
|
|
|
QDBusServiceWatcher *m_watcher = nullptr;
|
|
bool m_connectedSignals = false;
|
|
};
|