Cpp changes, minor refactor plus separate signal logic, typo.
- typo in searchindex - Cpp plugin changed to use enum lidstate - minor refactor - Using signals instead of direct property access. - Using states instead - checking lidclosed instead of preparetosleep
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QVariantMap>
|
||||
#include <qqmlintegration.h>
|
||||
|
||||
namespace ZShell {
|
||||
@@ -11,22 +13,32 @@ class LidWatcher : public QObject {
|
||||
QML_SINGLETON
|
||||
|
||||
Q_PROPERTY(bool available READ available NOTIFY availableChanged)
|
||||
Q_PROPERTY(LidState state READ state NOTIFY stateChanged)
|
||||
|
||||
public:
|
||||
enum LidState {
|
||||
Opened,
|
||||
Closed
|
||||
};
|
||||
Q_ENUM(LidState)
|
||||
|
||||
explicit LidWatcher(QObject* parent = nullptr);
|
||||
|
||||
[[nodiscard]] bool available() const;
|
||||
[[nodiscard]] LidState state() const;
|
||||
|
||||
private:
|
||||
void queryInitialState();
|
||||
|
||||
bool m_available;
|
||||
LidState m_state = Opened;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPrepareForSleep(bool goingDown);
|
||||
void onPropertiesChanged(const QString& interface, const QVariantMap& changed, const QStringList& invalidated);
|
||||
|
||||
Q_SIGNALS:
|
||||
void availableChanged();
|
||||
void lidClosing();
|
||||
void lidOpened();
|
||||
|
||||
private:
|
||||
bool m_available;
|
||||
void stateChanged();
|
||||
};
|
||||
|
||||
} // namespace ZShell
|
||||
|
||||
Reference in New Issue
Block a user