112 lines
4.5 KiB
C++
112 lines
4.5 KiB
C++
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include "packageutils.h"
|
|
#include "toolmodel.h"
|
|
|
|
#include <KQuickConfigModule>
|
|
|
|
#include <QProcess>
|
|
#include <QUrl>
|
|
|
|
class KJob;
|
|
|
|
class FedoraToolsKcm : public KQuickConfigModule
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QAbstractItemModel *tools READ tools CONSTANT)
|
|
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
|
|
Q_PROPERTY(QString message READ message NOTIFY messageChanged)
|
|
Q_PROPERTY(bool error READ error NOTIFY messageChanged)
|
|
Q_PROPERTY(bool fingerprintEnabled READ fingerprintEnabled NOTIFY fingerprintEnabledChanged)
|
|
Q_PROPERTY(QString activePackage READ activePackage NOTIFY packageOperationChanged)
|
|
Q_PROPERTY(QString packageOperation READ packageOperation NOTIFY packageOperationChanged)
|
|
Q_PROPERTY(bool shortcutStartWithFirst READ shortcutStartWithFirst NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(bool shortcutInitialShiftOpensNew READ shortcutInitialShiftOpensNew NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(bool shortcutShiftCyclesBackward READ shortcutShiftCyclesBackward NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(int touchpadMinimumAnchorAge READ touchpadMinimumAnchorAge NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(int touchpadMinimumPause READ touchpadMinimumPause NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(int touchpadMinimumTap READ touchpadMinimumTap NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(int touchpadMaximumTap READ touchpadMaximumTap NOTIFY toolSettingsChanged)
|
|
Q_PROPERTY(QString touchpadOutputEvent READ touchpadOutputEvent NOTIFY toolSettingsChanged)
|
|
|
|
public:
|
|
FedoraToolsKcm(QObject *parent, const KPluginMetaData &data);
|
|
|
|
QAbstractItemModel *tools();
|
|
bool busy() const;
|
|
QString message() const;
|
|
bool error() const;
|
|
bool fingerprintEnabled() const;
|
|
QString activePackage() const;
|
|
QString packageOperation() const;
|
|
bool shortcutStartWithFirst() const;
|
|
bool shortcutInitialShiftOpensNew() const;
|
|
bool shortcutShiftCyclesBackward() const;
|
|
int touchpadMinimumAnchorAge() const;
|
|
int touchpadMinimumPause() const;
|
|
int touchpadMinimumTap() const;
|
|
int touchpadMaximumTap() const;
|
|
QString touchpadOutputEvent() const;
|
|
|
|
Q_INVOKABLE void refresh(bool refreshMetadata = false);
|
|
Q_INVOKABLE void clearMessage();
|
|
Q_INVOKABLE void configureExternalTool(const QString &packageName);
|
|
Q_INVOKABLE void installTool(const QString &packageName);
|
|
Q_INVOKABLE void removeTool(const QString &packageName);
|
|
Q_INVOKABLE void saveShortcutSettings(bool startWithFirst, bool initialShiftOpensNew, bool shiftCyclesBackward);
|
|
Q_INVOKABLE void resetShortcutSettings();
|
|
Q_INVOKABLE void saveTouchpadSettings(int minimumAnchorAge, int minimumPause, int minimumTap, int maximumTap, const QString &outputEvent);
|
|
Q_INVOKABLE void resetTouchpadSettings();
|
|
Q_INVOKABLE void enableFingerprintWorkaround(const QUrl &rpmFile, bool force);
|
|
Q_INVOKABLE void disableFingerprintWorkaround();
|
|
|
|
Q_SIGNALS:
|
|
void busyChanged();
|
|
void messageChanged();
|
|
void fingerprintEnabledChanged();
|
|
void packageOperationChanged();
|
|
void toolSettingsChanged();
|
|
|
|
private:
|
|
enum class QueryStage {
|
|
Idle,
|
|
InstalledProviders,
|
|
Available,
|
|
KnownInstalled,
|
|
};
|
|
|
|
void startQuery(const QString &program, const QStringList &arguments, QueryStage stage);
|
|
void queryFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
void finishRefresh();
|
|
void runAuthorizedAction(const QString &name, const QVariantMap &arguments, const QString &successMessage, bool refreshTools);
|
|
void actionFinished(KJob *job, const QString &successMessage, bool refreshTools);
|
|
void setBusy(bool busy);
|
|
void setPackageOperation(const QString &packageName, const QString &operation);
|
|
void setMessage(const QString &message, bool error = false);
|
|
void updateFingerprintStatus();
|
|
void loadToolSettings();
|
|
|
|
ToolModel m_tools;
|
|
QProcess m_query;
|
|
QueryStage m_stage = QueryStage::Idle;
|
|
QList<PackageRecord> m_installedPackages;
|
|
QList<PackageRecord> m_availablePackages;
|
|
bool m_refreshMetadata = false;
|
|
bool m_busy = false;
|
|
bool m_error = false;
|
|
bool m_fingerprintEnabled = false;
|
|
QString m_activePackage;
|
|
QString m_packageOperation;
|
|
QString m_message;
|
|
bool m_shortcutStartWithFirst = true;
|
|
bool m_shortcutInitialShiftOpensNew = true;
|
|
bool m_shortcutShiftCyclesBackward = true;
|
|
int m_touchpadMinimumAnchorAge = 100;
|
|
int m_touchpadMinimumPause = 100;
|
|
int m_touchpadMinimumTap = 10;
|
|
int m_touchpadMaximumTap = 150;
|
|
QString m_touchpadOutputEvent = QStringLiteral("BTN_MIDDLE");
|
|
};
|