feat: 恢复完整功能,包含D-Bus通信和QML界面

This commit is contained in:
2026-07-12 21:35:44 +08:00
parent 1a3ba4ec60
commit 8d0c1ec5a6
4 changed files with 402 additions and 1 deletions
+49
View File
@@ -6,17 +6,66 @@
#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