Files
JSwitchDisplayApplet/graphicsdriverapplet.h
T

72 lines
1.9 KiB
C++

// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <applet.h>
#include <QDBusInterface>
#include <QDBusPendingCallWatcher>
#include <QTimer>
#include <QJsonObject>
#include <QJsonArray>
DS_BEGIN_NAMESPACE
class GraphicsDriverApplet : public DApplet
{
Q_OBJECT
Q_PROPERTY(QString currentDriver READ currentDriver NOTIFY currentDriverChanged)
Q_PROPERTY(QString deviceInfo READ deviceInfo NOTIFY deviceInfoChanged)
Q_PROPERTY(int installProgress READ installProgress NOTIFY installProgressChanged)
Q_PROPERTY(bool isInstalling READ isInstalling NOTIFY isInstallingChanged)
public:
explicit GraphicsDriverApplet(QObject *parent = nullptr);
~GraphicsDriverApplet();
virtual bool load() override;
virtual bool init() override;
QString currentDriver() const;
QString deviceInfo() const;
int installProgress() const;
bool isInstalling() const;
Q_INVOKABLE void refreshDeviceInfo();
Q_INVOKABLE void prepareInstall(const QString &driverName);
Q_INVOKABLE void testInstall();
Q_INVOKABLE void realInstall();
Q_INVOKABLE void cancelInstall();
signals:
void currentDriverChanged();
void deviceInfoChanged();
void installProgressChanged();
void isInstallingChanged();
void installSuccess();
void installFailed(const QString &error);
void requestReboot();
private slots:
void onGetDeviceReply(QDBusPendingCallWatcher *call);
void onGetCurrDriverReply(QDBusPendingCallWatcher *call);
void onReportProgress(const QString &ratio);
private:
void initDBusConnection();
void setInstalling(bool installing);
QDBusInterface *m_dbusInterface;
QTimer *m_progressTimer;
QString m_currentDriver;
QString m_deviceInfo;
int m_installProgress;
bool m_isInstalling;
};
DS_END_NAMESPACE