test: 创建最简测试插件
This commit is contained in:
@@ -6,82 +6,17 @@
|
||||
|
||||
#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 newDriver READ newDriver NOTIFY newDriverChanged)
|
||||
Q_PROPERTY(QString deviceInfo READ deviceInfo NOTIFY deviceInfoChanged)
|
||||
Q_PROPERTY(int installProgress READ installProgress NOTIFY installProgressChanged)
|
||||
Q_PROPERTY(bool isInstalling READ isInstalling NOTIFY isInstallingChanged)
|
||||
Q_PROPERTY(bool isTestSuccess READ isTestSuccess NOTIFY isTestSuccessChanged)
|
||||
Q_PROPERTY(QJsonArray availableDrivers READ availableDrivers NOTIFY availableDriversChanged)
|
||||
|
||||
public:
|
||||
explicit GraphicsDriverApplet(QObject *parent = nullptr);
|
||||
~GraphicsDriverApplet();
|
||||
|
||||
virtual bool load() override;
|
||||
virtual bool init() override;
|
||||
|
||||
QString currentDriver() const;
|
||||
QString newDriver() const;
|
||||
QString deviceInfo() const;
|
||||
int installProgress() const;
|
||||
bool isInstalling() const;
|
||||
bool isTestSuccess() const;
|
||||
QJsonArray availableDrivers() 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 newDriverChanged();
|
||||
void deviceInfoChanged();
|
||||
void installProgressChanged();
|
||||
void isInstallingChanged();
|
||||
void isTestSuccessChanged();
|
||||
void availableDriversChanged();
|
||||
void installSuccess();
|
||||
void installFailed(const QString &error);
|
||||
void requestReboot();
|
||||
|
||||
private slots:
|
||||
void onDBusReply(QDBusPendingCallWatcher *call);
|
||||
void onReportProgress(const QString &ratio);
|
||||
void onCancel();
|
||||
void onPollProgress();
|
||||
|
||||
private:
|
||||
void initDBusConnection();
|
||||
void updateDeviceInfo();
|
||||
void parseDeviceInfo(const QString &jsonStr);
|
||||
void setInstalling(bool installing);
|
||||
|
||||
QDBusInterface *m_dbusInterface;
|
||||
QTimer *m_progressTimer;
|
||||
|
||||
QString m_currentDriver;
|
||||
QString m_newDriver;
|
||||
QString m_deviceInfo;
|
||||
int m_installProgress;
|
||||
bool m_isInstalling;
|
||||
bool m_isTestSuccess;
|
||||
QJsonArray m_availableDrivers;
|
||||
QString m_pendingInstallDriver;
|
||||
};
|
||||
|
||||
DS_END_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user