Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d799e61c79
|
|||
| 9cefdf509c | |||
| 27924aca37 | |||
| b4716d25c0 | |||
| d8f047dbc9 | |||
| 91b50b312d | |||
| 3e933a8b78 | |||
| e127928126 | |||
| 94f2cf076c | |||
| 9168b6e893 | |||
| 6586cc2788 | |||
| 0be98a64ac | |||
| d246ba1800 |
+1
-2
@@ -24,8 +24,7 @@ CheckOptions:
|
|||||||
readability-identifier-naming.StaticConstantCase: UPPER_CASE
|
readability-identifier-naming.StaticConstantCase: UPPER_CASE
|
||||||
readability-identifier-naming.StaticConstantPrefix: k
|
readability-identifier-naming.StaticConstantPrefix: k
|
||||||
readability-identifier-naming.VariableCase: camelBack
|
readability-identifier-naming.VariableCase: camelBack
|
||||||
WarningsAsErrors: "*"
|
HeaderFilterRegex: ""
|
||||||
HeaderFilterRegex: ".*"
|
|
||||||
FormatStyle: file
|
FormatStyle: file
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|||||||
@@ -69,14 +69,17 @@ Item {
|
|||||||
root.singleGestureTriggered = false;
|
root.singleGestureTriggered = false;
|
||||||
}
|
}
|
||||||
onCentroidChanged: {
|
onCentroidChanged: {
|
||||||
if (root.singleGestureTriggered)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const x = centroid.position.x;
|
const x = centroid.position.x;
|
||||||
const y = centroid.position.y;
|
const y = centroid.position.y;
|
||||||
const dragX = x - centroid.pressPosition.x;
|
const dragX = x - centroid.pressPosition.x;
|
||||||
const dragY = y - centroid.pressPosition.y;
|
const dragY = y - centroid.pressPosition.y;
|
||||||
|
|
||||||
|
if (centroid.pressPosition.y >= root.screen.height - Config.barConfig.border && dragY < -200)
|
||||||
|
root.visibilities.launcher = true;
|
||||||
|
|
||||||
|
if (root.singleGestureTriggered)
|
||||||
|
return;
|
||||||
|
|
||||||
if (centroid.pressPosition.y < root.bar.implicitHeight) {
|
if (centroid.pressPosition.y < root.bar.implicitHeight) {
|
||||||
if (dragY > 20) {
|
if (dragY > 20) {
|
||||||
root.visibilities.settings = true;
|
root.visibilities.settings = true;
|
||||||
|
|||||||
+11
-59
@@ -2,12 +2,13 @@ pragma Singleton
|
|||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import ZShell.Services
|
||||||
import qs.Config
|
import qs.Config
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property bool enabled
|
readonly property bool enabled: service.enabled
|
||||||
readonly property int end: Config.general.color.scheduleHyprsunsetEnd
|
readonly property int end: Config.general.color.scheduleHyprsunsetEnd
|
||||||
property bool manualToggle: false
|
property bool manualToggle: false
|
||||||
readonly property int start: Config.general.color.scheduleHyprsunsetStart
|
readonly property int start: Config.general.color.scheduleHyprsunsetStart
|
||||||
@@ -17,69 +18,20 @@ Singleton {
|
|||||||
if (!Config.general.color.scheduleHyprsunset)
|
if (!Config.general.color.scheduleHyprsunset)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var now = new Date();
|
service.apply();
|
||||||
if (now.getHours() >= root.start || now.getHours() < root.end) {
|
|
||||||
root.startNightLight(root.temp);
|
|
||||||
} else {
|
|
||||||
root.stopNightLight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startNightLight(temp: int): void {
|
|
||||||
Quickshell.execDetached(["hyprctl", "hyprsunset", "temperature", `${temp}`]);
|
|
||||||
root.enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function stopNightLight(): void {
|
|
||||||
Quickshell.execDetached(["hyprctl", "hyprsunset", "identity"]);
|
|
||||||
root.enabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleNightLight(): void {
|
function toggleNightLight(): void {
|
||||||
if (enabled)
|
service.manualToggle = true;
|
||||||
stopNightLight();
|
service.toggle();
|
||||||
else
|
|
||||||
startNightLight(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onManualToggleChanged: {
|
HyprsunsetManager {
|
||||||
if (root.manualToggle)
|
id: service
|
||||||
manualTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
activeAuto: Config.general.color.scheduleHyprsunset
|
||||||
id: manualTimer
|
endTime: root.end
|
||||||
|
startTime: root.start
|
||||||
interval: 60000 * 60
|
temp: root.temp
|
||||||
repeat: false
|
|
||||||
running: false
|
|
||||||
|
|
||||||
onTriggered: {
|
|
||||||
root.manualToggle = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
interval: 5000
|
|
||||||
repeat: true
|
|
||||||
running: true
|
|
||||||
triggeredOnStart: true
|
|
||||||
|
|
||||||
onTriggered: {
|
|
||||||
if (!Config.general.color.scheduleHyprsunset)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (root.manualToggle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var now = new Date();
|
|
||||||
if (now.getHours() >= root.start || now.getHours() < root.end) {
|
|
||||||
if (!root.enabled)
|
|
||||||
root.startNightLight(root.temp);
|
|
||||||
} else {
|
|
||||||
if (root.enabled)
|
|
||||||
root.stopNightLight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ CustomRect {
|
|||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
color: root.visibilities.dashboard ? DynamicColors.palette.m3onPrimary : DynamicColors.palette.m3onSurface
|
color: root.visibilities.dashboard ? DynamicColors.palette.m3onPrimary : DynamicColors.palette.m3onSurface
|
||||||
font: Appearance.font.family.mono
|
font: Appearance.font.family.mono // qmllint disable incompatible-type
|
||||||
text: Time.dateStr
|
text: Time.dateStr
|
||||||
|
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ Item {
|
|||||||
|
|
||||||
spacing: 1
|
spacing: 1
|
||||||
|
|
||||||
Component.onCompleted: console.log(Battery.isLaptop)
|
|
||||||
|
|
||||||
CustomRect {
|
CustomRect {
|
||||||
id: track
|
id: track
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ public:
|
|||||||
explicit BlobGroup(QObject* parent = nullptr);
|
explicit BlobGroup(QObject* parent = nullptr);
|
||||||
~BlobGroup() override;
|
~BlobGroup() override;
|
||||||
|
|
||||||
qreal smoothing() const {
|
[[nodiscard]] qreal smoothing() const {
|
||||||
return m_smoothing;
|
return m_smoothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSmoothing(qreal s);
|
void setSmoothing(qreal s);
|
||||||
|
|
||||||
QColor color() const {
|
[[nodiscard]] QColor color() const {
|
||||||
return m_color;
|
return m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,11 +36,11 @@ void removeShape(BlobShape* shape);
|
|||||||
void setInvertedRect(BlobInvertedRect* rect);
|
void setInvertedRect(BlobInvertedRect* rect);
|
||||||
void clearInvertedRect(BlobInvertedRect* rect);
|
void clearInvertedRect(BlobInvertedRect* rect);
|
||||||
|
|
||||||
const QList<BlobShape*>& shapes() const {
|
[[nodiscard]] const QList<BlobShape*>& shapes() const {
|
||||||
return m_shapes;
|
return m_shapes;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlobInvertedRect* invertedRect() const {
|
[[nodiscard]] BlobInvertedRect* invertedRect() const {
|
||||||
return m_invertedRect;
|
return m_invertedRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,25 +16,25 @@ public:
|
|||||||
explicit BlobInvertedRect(QQuickItem* parent = nullptr);
|
explicit BlobInvertedRect(QQuickItem* parent = nullptr);
|
||||||
~BlobInvertedRect() override;
|
~BlobInvertedRect() override;
|
||||||
|
|
||||||
qreal borderLeft() const {
|
[[nodiscard]] qreal borderLeft() const {
|
||||||
return m_borderLeft;
|
return m_borderLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBorderLeft(qreal v);
|
void setBorderLeft(qreal v);
|
||||||
|
|
||||||
qreal borderRight() const {
|
[[nodiscard]] qreal borderRight() const {
|
||||||
return m_borderRight;
|
return m_borderRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBorderRight(qreal v);
|
void setBorderRight(qreal v);
|
||||||
|
|
||||||
qreal borderTop() const {
|
[[nodiscard]] qreal borderTop() const {
|
||||||
return m_borderTop;
|
return m_borderTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBorderTop(qreal v);
|
void setBorderTop(qreal v);
|
||||||
|
|
||||||
qreal borderBottom() const {
|
[[nodiscard]] qreal borderBottom() const {
|
||||||
return m_borderBottom;
|
return m_borderBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ void borderTopChanged();
|
|||||||
void borderBottomChanged();
|
void borderBottomChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isInvertedRect() const override {
|
[[nodiscard]] bool isInvertedRect() const override {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ struct BlobRectData {
|
|||||||
|
|
||||||
class BlobMaterial : public QSGMaterial {
|
class BlobMaterial : public QSGMaterial {
|
||||||
public:
|
public:
|
||||||
QSGMaterialType* type() const override;
|
[[nodiscard]] QSGMaterialType* type() const override;
|
||||||
QSGMaterialShader* createShader(QSGRendererInterface::RenderMode) const override;
|
[[nodiscard]] QSGMaterialShader* createShader(QSGRendererInterface::RenderMode) const override;
|
||||||
int compare(const QSGMaterial* other) const override;
|
int compare(const QSGMaterial* other) const override;
|
||||||
|
|
||||||
float m_paddedX = 0;
|
float m_paddedX = 0;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
explicit BlobRect(QQuickItem* parent = nullptr);
|
explicit BlobRect(QQuickItem* parent = nullptr);
|
||||||
~BlobRect() override;
|
~BlobRect() override;
|
||||||
|
|
||||||
qreal stiffness() const {
|
[[nodiscard]] qreal stiffness() const {
|
||||||
return m_stiffness;
|
return m_stiffness;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ void setStiffness(qreal s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal damping() const {
|
[[nodiscard]] qreal damping() const {
|
||||||
return m_damping;
|
return m_damping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ void setDamping(qreal d) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal deformScale() const {
|
[[nodiscard]] qreal deformScale() const {
|
||||||
return m_deformScale;
|
return m_deformScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,25 +62,25 @@ QQmlListProperty<BlobRect> exclude();
|
|||||||
bool isExcluded(const BlobShape* other) const override;
|
bool isExcluded(const BlobShape* other) const override;
|
||||||
void cornerRadii(float out[4]) const override;
|
void cornerRadii(float out[4]) const override;
|
||||||
|
|
||||||
qreal topLeftRadius() const {
|
[[nodiscard]] qreal topLeftRadius() const {
|
||||||
return m_topLeftRadius;
|
return m_topLeftRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTopLeftRadius(qreal r);
|
void setTopLeftRadius(qreal r);
|
||||||
|
|
||||||
qreal topRightRadius() const {
|
[[nodiscard]] qreal topRightRadius() const {
|
||||||
return m_topRightRadius;
|
return m_topRightRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTopRightRadius(qreal r);
|
void setTopRightRadius(qreal r);
|
||||||
|
|
||||||
qreal bottomLeftRadius() const {
|
[[nodiscard]] qreal bottomLeftRadius() const {
|
||||||
return m_bottomLeftRadius;
|
return m_bottomLeftRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBottomLeftRadius(qreal r);
|
void setBottomLeftRadius(qreal r);
|
||||||
|
|
||||||
qreal bottomRightRadius() const {
|
[[nodiscard]] qreal bottomRightRadius() const {
|
||||||
return m_bottomRightRadius;
|
return m_bottomRightRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,23 +21,23 @@ public:
|
|||||||
explicit BlobShape(QQuickItem* parent = nullptr);
|
explicit BlobShape(QQuickItem* parent = nullptr);
|
||||||
~BlobShape() override = default;
|
~BlobShape() override = default;
|
||||||
|
|
||||||
BlobGroup* group() const {
|
[[nodiscard]] BlobGroup* group() const {
|
||||||
return m_group;
|
return m_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGroup(BlobGroup* g);
|
void setGroup(BlobGroup* g);
|
||||||
|
|
||||||
qreal radius() const {
|
[[nodiscard]] qreal radius() const {
|
||||||
return m_radius;
|
return m_radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRadius(qreal r);
|
void setRadius(qreal r);
|
||||||
|
|
||||||
QMatrix4x4 deformMatrix() const {
|
[[nodiscard]] QMatrix4x4 deformMatrix() const {
|
||||||
return m_centeredDeformMatrix;
|
return m_centeredDeformMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMatrix4x4 rawDeformMatrix() const {
|
[[nodiscard]] QMatrix4x4 rawDeformMatrix() const {
|
||||||
return m_deformMatrix;
|
return m_deformMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) overri
|
|||||||
void updatePolish() override;
|
void updatePolish() override;
|
||||||
QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) override;
|
QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) override;
|
||||||
|
|
||||||
virtual bool isInvertedRect() const {
|
[[nodiscard]] virtual bool isInvertedRect() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +72,9 @@ void updateCenteredDeformMatrix();
|
|||||||
|
|
||||||
BlobGroup* m_group = nullptr;
|
BlobGroup* m_group = nullptr;
|
||||||
qreal m_radius = 0;
|
qreal m_radius = 0;
|
||||||
QMatrix4x4 m_deformMatrix; // identity by default
|
QMatrix4x4 m_deformMatrix;
|
||||||
QMatrix4x4 m_centeredDeformMatrix;
|
QMatrix4x4 m_centeredDeformMatrix;
|
||||||
|
|
||||||
// Cached data from updatePolish
|
|
||||||
float m_cachedPaddedX = 0;
|
float m_cachedPaddedX = 0;
|
||||||
float m_cachedPaddedY = 0;
|
float m_cachedPaddedY = 0;
|
||||||
float m_cachedPaddedW = 0;
|
float m_cachedPaddedW = 0;
|
||||||
@@ -84,10 +83,10 @@ QRectF m_localPaddedRect;
|
|||||||
QVector<BlobRectData> m_cachedRects;
|
QVector<BlobRectData> m_cachedRects;
|
||||||
int m_cachedMyIndex = -2;
|
int m_cachedMyIndex = -2;
|
||||||
float m_pendingDx = 0;
|
float m_pendingDx = 0;
|
||||||
float m_pendingDy = 0;
|
float m_pendingDy = 0;
|
||||||
float m_pendingDw = 0;
|
float m_pendingDw = 0;
|
||||||
float m_pendingDh = 0;
|
float m_pendingDh = 0;
|
||||||
bool m_cachedHasInverted = false;
|
bool m_cachedHasInverted = false;
|
||||||
float m_cachedInvertedRadius = 0;
|
float m_cachedInvertedRadius = 0;
|
||||||
float m_cachedInvertedOuter[4] = {};
|
float m_cachedInvertedOuter[4] = {};
|
||||||
float m_cachedInvertedInner[4] = {};
|
float m_cachedInvertedInner[4] = {};
|
||||||
|
|||||||
@@ -58,4 +58,4 @@ qreal m_sweepAngle = 1.5 * M_PI;
|
|||||||
qreal m_lineWidth = 10.0;
|
qreal m_lineWidth = 10.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::internal
|
} // namespace ZShell::Internal
|
||||||
|
|||||||
@@ -7,59 +7,60 @@
|
|||||||
namespace ZShell::internal {
|
namespace ZShell::internal {
|
||||||
|
|
||||||
class CachingImageManager : public QObject {
|
class CachingImageManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
Q_PROPERTY(QQuickItem* item READ item WRITE setItem NOTIFY itemChanged REQUIRED)
|
Q_PROPERTY(QQuickItem* item READ item WRITE setItem NOTIFY itemChanged REQUIRED)
|
||||||
Q_PROPERTY(QUrl cacheDir READ cacheDir WRITE setCacheDir NOTIFY cacheDirChanged REQUIRED)
|
Q_PROPERTY(QUrl cacheDir READ cacheDir WRITE setCacheDir NOTIFY cacheDirChanged REQUIRED)
|
||||||
|
|
||||||
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
||||||
Q_PROPERTY(QUrl cachePath READ cachePath NOTIFY cachePathChanged)
|
Q_PROPERTY(QUrl cachePath READ cachePath NOTIFY cachePathChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CachingImageManager(QObject* parent = nullptr)
|
explicit CachingImageManager(QObject* parent = nullptr)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_item(nullptr) {}
|
, m_item(nullptr) {
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] QQuickItem* item() const;
|
[[nodiscard]] QQuickItem* item() const;
|
||||||
void setItem(QQuickItem* item);
|
void setItem(QQuickItem* item);
|
||||||
|
|
||||||
[[nodiscard]] QUrl cacheDir() const;
|
[[nodiscard]] QUrl cacheDir() const;
|
||||||
void setCacheDir(const QUrl& cacheDir);
|
void setCacheDir(const QUrl& cacheDir);
|
||||||
|
|
||||||
[[nodiscard]] QString path() const;
|
[[nodiscard]] QString path() const;
|
||||||
void setPath(const QString& path);
|
void setPath(const QString& path);
|
||||||
|
|
||||||
[[nodiscard]] QUrl cachePath() const;
|
[[nodiscard]] QUrl cachePath() const;
|
||||||
|
|
||||||
Q_INVOKABLE void updateSource();
|
Q_INVOKABLE void updateSource();
|
||||||
Q_INVOKABLE void updateSource(const QString& path);
|
Q_INVOKABLE void updateSource(const QString& path);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void itemChanged();
|
void itemChanged();
|
||||||
void cacheDirChanged();
|
void cacheDirChanged();
|
||||||
|
|
||||||
void pathChanged();
|
void pathChanged();
|
||||||
void cachePathChanged();
|
void cachePathChanged();
|
||||||
void usingCacheChanged();
|
void usingCacheChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_shaPath;
|
QString m_shaPath;
|
||||||
|
|
||||||
QQuickItem* m_item;
|
QQuickItem* m_item;
|
||||||
QUrl m_cacheDir;
|
QUrl m_cacheDir;
|
||||||
|
|
||||||
QString m_path;
|
QString m_path;
|
||||||
QUrl m_cachePath;
|
QUrl m_cachePath;
|
||||||
|
|
||||||
QMetaObject::Connection m_widthConn;
|
QMetaObject::Connection m_widthConn;
|
||||||
QMetaObject::Connection m_heightConn;
|
QMetaObject::Connection m_heightConn;
|
||||||
|
|
||||||
[[nodiscard]] qreal effectiveScale() const;
|
[[nodiscard]] qreal effectiveScale() const;
|
||||||
[[nodiscard]] QSize effectiveSize() const;
|
[[nodiscard]] QSize effectiveSize() const;
|
||||||
|
|
||||||
void createCache(const QString& path, const QString& cache, const QString& fillMode, const QSize& size) const;
|
void createCache(const QString& path, const QString& cache, const QString& fillMode, const QSize& size) const;
|
||||||
[[nodiscard]] static QString sha256sum(const QString& path);
|
[[nodiscard]] static QString sha256sum(const QString& path);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::internal
|
} // namespace ZShell::internal
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <qeasingcurve.h>
|
#include <qeasingcurve.h>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
|
|||||||
@@ -8,67 +8,67 @@
|
|||||||
namespace ZShell::internal::hypr {
|
namespace ZShell::internal::hypr {
|
||||||
|
|
||||||
class HyprKeyboard : public QObject {
|
class HyprKeyboard : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
QML_UNCREATABLE("HyprKeyboard instances can only be retrieved from a HyprDevices")
|
QML_UNCREATABLE("HyprKeyboard instances can only be retrieved from a HyprDevices")
|
||||||
|
|
||||||
Q_PROPERTY(QVariantHash lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged)
|
Q_PROPERTY(QVariantHash lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged)
|
||||||
Q_PROPERTY(QString address READ address NOTIFY addressChanged)
|
Q_PROPERTY(QString address READ address NOTIFY addressChanged)
|
||||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(QString layout READ layout NOTIFY layoutChanged)
|
Q_PROPERTY(QString layout READ layout NOTIFY layoutChanged)
|
||||||
Q_PROPERTY(QString activeKeymap READ activeKeymap NOTIFY activeKeymapChanged)
|
Q_PROPERTY(QString activeKeymap READ activeKeymap NOTIFY activeKeymapChanged)
|
||||||
Q_PROPERTY(bool capsLock READ capsLock NOTIFY capsLockChanged)
|
Q_PROPERTY(bool capsLock READ capsLock NOTIFY capsLockChanged)
|
||||||
Q_PROPERTY(bool numLock READ numLock NOTIFY numLockChanged)
|
Q_PROPERTY(bool numLock READ numLock NOTIFY numLockChanged)
|
||||||
Q_PROPERTY(bool main READ main NOTIFY mainChanged)
|
Q_PROPERTY(bool main READ main NOTIFY mainChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HyprKeyboard(QJsonObject ipcObject, QObject* parent = nullptr);
|
explicit HyprKeyboard(QJsonObject ipcObject, QObject* parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] QVariantHash lastIpcObject() const;
|
[[nodiscard]] QVariantHash lastIpcObject() const;
|
||||||
[[nodiscard]] QString address() const;
|
[[nodiscard]] QString address() const;
|
||||||
[[nodiscard]] QString name() const;
|
[[nodiscard]] QString name() const;
|
||||||
[[nodiscard]] QString layout() const;
|
[[nodiscard]] QString layout() const;
|
||||||
[[nodiscard]] QString activeKeymap() const;
|
[[nodiscard]] QString activeKeymap() const;
|
||||||
[[nodiscard]] bool capsLock() const;
|
[[nodiscard]] bool capsLock() const;
|
||||||
[[nodiscard]] bool numLock() const;
|
[[nodiscard]] bool numLock() const;
|
||||||
[[nodiscard]] bool main() const;
|
[[nodiscard]] bool main() const;
|
||||||
|
|
||||||
bool updateLastIpcObject(QJsonObject object);
|
bool updateLastIpcObject(QJsonObject object);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void lastIpcObjectChanged();
|
void lastIpcObjectChanged();
|
||||||
void addressChanged();
|
void addressChanged();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void layoutChanged();
|
void layoutChanged();
|
||||||
void activeKeymapChanged();
|
void activeKeymapChanged();
|
||||||
void capsLockChanged();
|
void capsLockChanged();
|
||||||
void numLockChanged();
|
void numLockChanged();
|
||||||
void mainChanged();
|
void mainChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QJsonObject m_lastIpcObject;
|
QJsonObject m_lastIpcObject;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HyprDevices : public QObject {
|
class HyprDevices : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
QML_UNCREATABLE("HyprDevices instances can only be retrieved from a HyprExtras")
|
QML_UNCREATABLE("HyprDevices instances can only be retrieved from a HyprExtras")
|
||||||
|
|
||||||
Q_PROPERTY(
|
Q_PROPERTY(
|
||||||
QQmlListProperty<ZShell::internal::hypr::HyprKeyboard> keyboards READ keyboards NOTIFY keyboardsChanged)
|
QQmlListProperty<ZShell::internal::hypr::HyprKeyboard> keyboards READ keyboards NOTIFY keyboardsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HyprDevices(QObject* parent = nullptr);
|
explicit HyprDevices(QObject* parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] QQmlListProperty<HyprKeyboard> keyboards();
|
[[nodiscard]] QQmlListProperty<HyprKeyboard> keyboards();
|
||||||
|
|
||||||
bool updateLastIpcObject(QJsonObject object);
|
bool updateLastIpcObject(QJsonObject object);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void keyboardsChanged();
|
void keyboardsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<HyprKeyboard*> m_keyboards;
|
QList<HyprKeyboard*> m_keyboards;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::internal::hypr
|
} // namespace ZShell::internal::hypr
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <qabstractitemmodel.h>
|
#include <qabstractitemmodel.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <qfilesystemwatcher.h>
|
#include <qfilesystemwatcher.h>
|
||||||
@@ -13,136 +14,136 @@
|
|||||||
namespace ZShell::models {
|
namespace ZShell::models {
|
||||||
|
|
||||||
class FileSystemEntry : public QObject {
|
class FileSystemEntry : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
QML_UNCREATABLE("FileSystemEntry instances can only be retrieved from a FileSystemModel")
|
QML_UNCREATABLE("FileSystemEntry instances can only be retrieved from a FileSystemModel")
|
||||||
|
|
||||||
Q_PROPERTY(QString path READ path CONSTANT)
|
Q_PROPERTY(QString path READ path CONSTANT)
|
||||||
Q_PROPERTY(QString relativePath READ relativePath NOTIFY relativePathChanged)
|
Q_PROPERTY(QString relativePath READ relativePath NOTIFY relativePathChanged)
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
Q_PROPERTY(QString name READ name CONSTANT)
|
||||||
Q_PROPERTY(QString baseName READ baseName CONSTANT)
|
Q_PROPERTY(QString baseName READ baseName CONSTANT)
|
||||||
Q_PROPERTY(QString parentDir READ parentDir CONSTANT)
|
Q_PROPERTY(QString parentDir READ parentDir CONSTANT)
|
||||||
Q_PROPERTY(QString suffix READ suffix CONSTANT)
|
Q_PROPERTY(QString suffix READ suffix CONSTANT)
|
||||||
Q_PROPERTY(qint64 size READ size CONSTANT)
|
Q_PROPERTY(qint64 size READ size CONSTANT)
|
||||||
Q_PROPERTY(bool isDir READ isDir CONSTANT)
|
Q_PROPERTY(bool isDir READ isDir CONSTANT)
|
||||||
Q_PROPERTY(bool isImage READ isImage CONSTANT)
|
Q_PROPERTY(bool isImage READ isImage CONSTANT)
|
||||||
Q_PROPERTY(QString mimeType READ mimeType CONSTANT)
|
Q_PROPERTY(QString mimeType READ mimeType CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FileSystemEntry(const QString& path, const QString& relativePath, QObject* parent = nullptr);
|
explicit FileSystemEntry(const QString& path, const QString& relativePath, QObject* parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] QString path() const;
|
[[nodiscard]] QString path() const;
|
||||||
[[nodiscard]] QString relativePath() const;
|
[[nodiscard]] QString relativePath() const;
|
||||||
[[nodiscard]] QString name() const;
|
[[nodiscard]] QString name() const;
|
||||||
[[nodiscard]] QString baseName() const;
|
[[nodiscard]] QString baseName() const;
|
||||||
[[nodiscard]] QString parentDir() const;
|
[[nodiscard]] QString parentDir() const;
|
||||||
[[nodiscard]] QString suffix() const;
|
[[nodiscard]] QString suffix() const;
|
||||||
[[nodiscard]] qint64 size() const;
|
[[nodiscard]] qint64 size() const;
|
||||||
[[nodiscard]] bool isDir() const;
|
[[nodiscard]] bool isDir() const;
|
||||||
[[nodiscard]] bool isImage() const;
|
[[nodiscard]] bool isImage() const;
|
||||||
[[nodiscard]] QString mimeType() const;
|
[[nodiscard]] QString mimeType() const;
|
||||||
|
|
||||||
void updateRelativePath(const QDir& dir);
|
void updateRelativePath(const QDir& dir);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void relativePathChanged();
|
void relativePathChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QFileInfo m_fileInfo;
|
const QFileInfo m_fileInfo;
|
||||||
|
|
||||||
const QString m_path;
|
const QString m_path;
|
||||||
QString m_relativePath;
|
QString m_relativePath;
|
||||||
|
|
||||||
mutable bool m_isImage;
|
mutable bool m_isImage;
|
||||||
mutable bool m_isImageInitialised;
|
mutable bool m_isImageInitialised;
|
||||||
|
|
||||||
mutable QString m_mimeType;
|
mutable QString m_mimeType;
|
||||||
mutable bool m_mimeTypeInitialised;
|
mutable bool m_mimeTypeInitialised;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileSystemModel : public QAbstractListModel {
|
class FileSystemModel : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
|
||||||
Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
|
Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
|
||||||
Q_PROPERTY(bool watchChanges READ watchChanges WRITE setWatchChanges NOTIFY watchChangesChanged)
|
Q_PROPERTY(bool watchChanges READ watchChanges WRITE setWatchChanges NOTIFY watchChangesChanged)
|
||||||
Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden NOTIFY showHiddenChanged)
|
Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden NOTIFY showHiddenChanged)
|
||||||
Q_PROPERTY(bool sortReverse READ sortReverse WRITE setSortReverse NOTIFY sortReverseChanged)
|
Q_PROPERTY(bool sortReverse READ sortReverse WRITE setSortReverse NOTIFY sortReverseChanged)
|
||||||
Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY filterChanged)
|
Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY filterChanged)
|
||||||
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged)
|
Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged)
|
||||||
|
|
||||||
Q_PROPERTY(QQmlListProperty<ZShell::models::FileSystemEntry> entries READ entries NOTIFY entriesChanged)
|
Q_PROPERTY(QQmlListProperty<ZShell::models::FileSystemEntry> entries READ entries NOTIFY entriesChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Filter {
|
enum Filter {
|
||||||
NoFilter,
|
NoFilter,
|
||||||
Images,
|
Images,
|
||||||
Files,
|
Files,
|
||||||
Dirs
|
Dirs
|
||||||
};
|
};
|
||||||
Q_ENUM(Filter)
|
Q_ENUM(Filter)
|
||||||
|
|
||||||
explicit FileSystemModel(QObject* parent = nullptr);
|
explicit FileSystemModel(QObject* parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
[[nodiscard]] int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
[[nodiscard]] QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
[[nodiscard]] QString path() const;
|
[[nodiscard]] QString path() const;
|
||||||
void setPath(const QString& path);
|
void setPath(const QString& path);
|
||||||
|
|
||||||
[[nodiscard]] bool recursive() const;
|
[[nodiscard]] bool recursive() const;
|
||||||
void setRecursive(bool recursive);
|
void setRecursive(bool recursive);
|
||||||
|
|
||||||
[[nodiscard]] bool watchChanges() const;
|
[[nodiscard]] bool watchChanges() const;
|
||||||
void setWatchChanges(bool watchChanges);
|
void setWatchChanges(bool watchChanges);
|
||||||
|
|
||||||
[[nodiscard]] bool showHidden() const;
|
[[nodiscard]] bool showHidden() const;
|
||||||
void setShowHidden(bool showHidden);
|
void setShowHidden(bool showHidden);
|
||||||
|
|
||||||
[[nodiscard]] bool sortReverse() const;
|
[[nodiscard]] bool sortReverse() const;
|
||||||
void setSortReverse(bool sortReverse);
|
void setSortReverse(bool sortReverse);
|
||||||
|
|
||||||
[[nodiscard]] Filter filter() const;
|
[[nodiscard]] Filter filter() const;
|
||||||
void setFilter(Filter filter);
|
void setFilter(Filter filter);
|
||||||
|
|
||||||
[[nodiscard]] QStringList nameFilters() const;
|
[[nodiscard]] QStringList nameFilters() const;
|
||||||
void setNameFilters(const QStringList& nameFilters);
|
void setNameFilters(const QStringList& nameFilters);
|
||||||
|
|
||||||
[[nodiscard]] QQmlListProperty<FileSystemEntry> entries();
|
[[nodiscard]] QQmlListProperty<FileSystemEntry> entries();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pathChanged();
|
void pathChanged();
|
||||||
void recursiveChanged();
|
void recursiveChanged();
|
||||||
void watchChangesChanged();
|
void watchChangesChanged();
|
||||||
void showHiddenChanged();
|
void showHiddenChanged();
|
||||||
void sortReverseChanged();
|
void sortReverseChanged();
|
||||||
void filterChanged();
|
void filterChanged();
|
||||||
void nameFiltersChanged();
|
void nameFiltersChanged();
|
||||||
void entriesChanged();
|
void entriesChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDir m_dir;
|
QDir m_dir;
|
||||||
QFileSystemWatcher m_watcher;
|
QFileSystemWatcher m_watcher;
|
||||||
QList<FileSystemEntry*> m_entries;
|
QList<FileSystemEntry*> m_entries;
|
||||||
QHash<QString, QFuture<QPair<QSet<QString>, QSet<QString>>>> m_futures;
|
QHash<QString, QFuture<QPair<QSet<QString>, QSet<QString> > > > m_futures;
|
||||||
|
|
||||||
QString m_path;
|
QString m_path;
|
||||||
bool m_recursive;
|
bool m_recursive;
|
||||||
bool m_watchChanges;
|
bool m_watchChanges;
|
||||||
bool m_showHidden;
|
bool m_showHidden;
|
||||||
bool m_sortReverse;
|
bool m_sortReverse;
|
||||||
Filter m_filter;
|
Filter m_filter;
|
||||||
QStringList m_nameFilters;
|
QStringList m_nameFilters;
|
||||||
|
|
||||||
void watchDirIfRecursive(const QString& path);
|
void watchDirIfRecursive(const QString& path);
|
||||||
void update();
|
void update();
|
||||||
void updateWatcher();
|
void updateWatcher();
|
||||||
void updateEntries();
|
void updateEntries();
|
||||||
void updateEntriesForDir(const QString& dir);
|
void updateEntriesForDir(const QString& dir);
|
||||||
void applyChanges(const QSet<QString>& removedPaths, const QSet<QString>& addedPaths);
|
void applyChanges(const QSet<QString>& removedPaths, const QSet<QString>& addedPaths);
|
||||||
[[nodiscard]] bool compareEntries(const FileSystemEntry* a, const FileSystemEntry* b) const;
|
[[nodiscard]] bool compareEntries(const FileSystemEntry* a, const FileSystemEntry* b) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::models
|
} // namespace ZShell::models
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ qml_module(ZShell-services
|
|||||||
cavaprovider.hpp cavaprovider.cpp
|
cavaprovider.hpp cavaprovider.cpp
|
||||||
desktopmodel.hpp desktopmodel.cpp
|
desktopmodel.hpp desktopmodel.cpp
|
||||||
desktopstatemanager.hpp desktopstatemanager.cpp
|
desktopstatemanager.hpp desktopstatemanager.cpp
|
||||||
|
hyprsunsetmanager.hpp hyprsunsetmanager.cpp
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt6::Core
|
Qt6::Core
|
||||||
Qt6::Qml
|
Qt6::Qml
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ quint32 readChunk(double* out, quint32 count = 0);
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AudioCollector(QObject* parent = nullptr);
|
explicit AudioCollector(QObject* parent = nullptr);
|
||||||
~AudioCollector();
|
~AudioCollector() override;
|
||||||
|
|
||||||
std::jthread m_thread;
|
std::jthread m_thread;
|
||||||
std::vector<float> m_buffer1;
|
std::vector<float> m_buffer1;
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ Q_OBJECT
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AudioProcessor(QObject* parent = nullptr);
|
explicit AudioProcessor(QObject* parent = nullptr);
|
||||||
~AudioProcessor();
|
~AudioProcessor() override;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
@@ -31,7 +30,7 @@ Q_OBJECT
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AudioProvider(QObject* parent = nullptr);
|
explicit AudioProvider(QObject* parent = nullptr);
|
||||||
~AudioProvider();
|
~AudioProvider() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AudioProcessor* m_processor;
|
AudioProcessor* m_processor;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Q_OBJECT
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BeatProcessor(QObject* parent = nullptr);
|
explicit BeatProcessor(QObject* parent = nullptr);
|
||||||
~BeatProcessor();
|
~BeatProcessor() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void beat(smpl_t bpm);
|
void beat(smpl_t bpm);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Q_OBJECT
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CavaProcessor(QObject* parent = nullptr);
|
explicit CavaProcessor(QObject* parent = nullptr);
|
||||||
~CavaProcessor();
|
~CavaProcessor() override;
|
||||||
|
|
||||||
void setBars(int bars);
|
void setBars(int bars);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace ZShell::services {
|
namespace ZShell::services {
|
||||||
|
|
||||||
@@ -30,9 +31,9 @@ enum DesktopRoles {
|
|||||||
|
|
||||||
explicit DesktopModel(QObject *parent = nullptr);
|
explicit DesktopModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
[[nodiscard]] QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
||||||
Q_INVOKABLE void loadDirectory(const QString &path);
|
Q_INVOKABLE void loadDirectory(const QString &path);
|
||||||
Q_INVOKABLE void moveIcon(int index, int newX, int newY);
|
Q_INVOKABLE void moveIcon(int index, int newX, int newY);
|
||||||
@@ -43,4 +44,4 @@ QList<DesktopItem> m_items;
|
|||||||
void saveCurrentLayout();
|
void saveCurrentLayout();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::services
|
} // namespace ZShell::Services
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ Q_INVOKABLE void saveLayout(const QVariantMap& layout);
|
|||||||
Q_INVOKABLE QVariantMap getLayout();
|
Q_INVOKABLE QVariantMap getLayout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getConfigFilePath() const;
|
[[nodiscard]] QString getConfigFilePath() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell::services
|
} // namespace ZShell::services
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
#include "hyprsunsetmanager.hpp"
|
||||||
|
#include <qlogging.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qprocess.h>
|
||||||
|
#include <qtimer.h>
|
||||||
|
|
||||||
|
namespace ZShell::services {
|
||||||
|
|
||||||
|
HyprsunsetManager::HyprsunsetManager(QObject* parent) : QObject(parent) {
|
||||||
|
connect(&m_timer, &QTimer::timeout, this, &HyprsunsetManager::apply);
|
||||||
|
connect(&m_manualTimer, &QTimer::timeout, this, [this] {
|
||||||
|
m_manualToggle = false;
|
||||||
|
emit manualToggleChanged();
|
||||||
|
apply();
|
||||||
|
});
|
||||||
|
connect(&m_startCooldown, &QTimer::timeout, this, [this] {
|
||||||
|
m_startAllowed = true;
|
||||||
|
apply();
|
||||||
|
});
|
||||||
|
|
||||||
|
m_startCooldown.start(2000);
|
||||||
|
m_manualTimer.setSingleShot(true);
|
||||||
|
m_timer.start(60000);
|
||||||
|
|
||||||
|
m_process.setStandardInputFile(QProcess::nullDevice());
|
||||||
|
m_process.setStandardOutputFile(QProcess::nullDevice());
|
||||||
|
}
|
||||||
|
|
||||||
|
int HyprsunsetManager::startTime() const {
|
||||||
|
return m_startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HyprsunsetManager::endTime() const {
|
||||||
|
return m_endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HyprsunsetManager::manualToggle() const {
|
||||||
|
return m_manualToggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HyprsunsetManager::enabled() const {
|
||||||
|
return m_enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HyprsunsetManager::activeAuto() const {
|
||||||
|
return m_activeAuto;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HyprsunsetManager::temp() const {
|
||||||
|
return m_temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::setActiveAuto(bool activeAuto) {
|
||||||
|
if (activeAuto == m_activeAuto)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_activeAuto = activeAuto;
|
||||||
|
emit activeAutoChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::setManualToggle(bool toggle) {
|
||||||
|
if (toggle == m_manualToggle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_manualToggle = toggle;
|
||||||
|
emit manualToggleChanged();
|
||||||
|
|
||||||
|
m_manualTimer.start(60 * 60 * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::setEndTime(const int& time) {
|
||||||
|
if (time == m_endTime)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_endTime = time;
|
||||||
|
emit endTimeChanged();
|
||||||
|
apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::setStartTime(const int& time) {
|
||||||
|
if (time == m_startTime)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_startTime = time;
|
||||||
|
emit startTimeChanged();
|
||||||
|
apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::setTemp(const int& temp) {
|
||||||
|
if (temp == m_temp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_temp = temp;
|
||||||
|
emit tempChanged();
|
||||||
|
apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::toggle() {
|
||||||
|
if (m_enabled) {
|
||||||
|
end();
|
||||||
|
} else {
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::start() {
|
||||||
|
if (m_enabled && m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
m_enabled = true;
|
||||||
|
|
||||||
|
emit enabledChanged();
|
||||||
|
|
||||||
|
m_process.setProgram("hyprctl");
|
||||||
|
m_process.setArguments({"hyprsunset", "temperature", QString::number(m_temp)});
|
||||||
|
m_process.startDetached();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::end() {
|
||||||
|
if (!m_enabled && m_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
m_enabled = false;
|
||||||
|
|
||||||
|
emit enabledChanged();
|
||||||
|
|
||||||
|
m_process.setProgram("hyprctl");
|
||||||
|
m_process.setArguments({"hyprsunset", "identity"});
|
||||||
|
m_process.startDetached();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HyprsunsetManager::apply() {
|
||||||
|
if (m_manualToggle || !m_activeAuto || !m_startAllowed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto current = QTime::currentTime().hour();
|
||||||
|
|
||||||
|
if (current >= m_startTime || current < m_endTime) {
|
||||||
|
start();
|
||||||
|
} else {
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <qqmlintegration.h>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
|
namespace ZShell::services {
|
||||||
|
|
||||||
|
class HyprsunsetManager : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
QML_ELEMENT
|
||||||
|
Q_PROPERTY(bool enabled READ enabled NOTIFY enabledChanged)
|
||||||
|
Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
|
||||||
|
Q_PROPERTY(int endTime READ endTime WRITE setEndTime NOTIFY endTimeChanged)
|
||||||
|
Q_PROPERTY(int temp READ temp WRITE setTemp NOTIFY tempChanged)
|
||||||
|
Q_PROPERTY(bool activeAuto READ activeAuto WRITE setActiveAuto NOTIFY activeAutoChanged)
|
||||||
|
Q_PROPERTY(bool manualToggle READ manualToggle WRITE setManualToggle NOTIFY manualToggleChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit HyprsunsetManager(QObject* parent = nullptr);
|
||||||
|
|
||||||
|
[[nodiscard]] int startTime() const;
|
||||||
|
[[nodiscard]] int endTime() const;
|
||||||
|
[[nodiscard]] bool enabled() const;
|
||||||
|
[[nodiscard]] int temp() const;
|
||||||
|
[[nodiscard]] bool activeAuto() const;
|
||||||
|
[[nodiscard]] bool manualToggle() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void toggle();
|
||||||
|
Q_INVOKABLE void apply();
|
||||||
|
|
||||||
|
void setStartTime(const int& time);
|
||||||
|
void setEndTime(const int& time);
|
||||||
|
void setTemp(const int& temp);
|
||||||
|
void setActiveAuto(bool activeAuto);
|
||||||
|
void setManualToggle(bool toggle);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void enabledChanged();
|
||||||
|
void startTimeChanged();
|
||||||
|
void activeAutoChanged();
|
||||||
|
void endTimeChanged();
|
||||||
|
void tempChanged();
|
||||||
|
void manualToggleChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_startTime;
|
||||||
|
int m_endTime;
|
||||||
|
bool m_enabled = false;
|
||||||
|
bool m_manualToggle = false;
|
||||||
|
bool m_activeAuto;
|
||||||
|
bool m_startAllowed = false;
|
||||||
|
bool m_initialized = false;
|
||||||
|
QTimer m_startCooldown;
|
||||||
|
int m_temp;
|
||||||
|
QProcess m_process;
|
||||||
|
QTimer m_timer;
|
||||||
|
QTimer m_manualTimer;
|
||||||
|
void start();
|
||||||
|
void end();
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
+64
-64
@@ -9,98 +9,98 @@
|
|||||||
namespace ZShell {
|
namespace ZShell {
|
||||||
|
|
||||||
class AppEntry : public QObject {
|
class AppEntry : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
QML_UNCREATABLE("AppEntry instances can only be retrieved from an AppDb")
|
QML_UNCREATABLE("AppEntry instances can only be retrieved from an AppDb")
|
||||||
|
|
||||||
// The actual DesktopEntry, but we don't have access to the type so it's a QObject
|
// The actual DesktopEntry, but we don't have access to the type so it's a QObject
|
||||||
Q_PROPERTY(QObject* entry READ entry CONSTANT)
|
Q_PROPERTY(QObject* entry READ entry CONSTANT)
|
||||||
|
|
||||||
Q_PROPERTY(quint32 frequency READ frequency NOTIFY frequencyChanged)
|
Q_PROPERTY(quint32 frequency READ frequency NOTIFY frequencyChanged)
|
||||||
Q_PROPERTY(QString id READ id CONSTANT)
|
Q_PROPERTY(QString id READ id CONSTANT)
|
||||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(QString comment READ comment NOTIFY commentChanged)
|
Q_PROPERTY(QString comment READ comment NOTIFY commentChanged)
|
||||||
Q_PROPERTY(QString execString READ execString NOTIFY execStringChanged)
|
Q_PROPERTY(QString execString READ execString NOTIFY execStringChanged)
|
||||||
Q_PROPERTY(QString startupClass READ startupClass NOTIFY startupClassChanged)
|
Q_PROPERTY(QString startupClass READ startupClass NOTIFY startupClassChanged)
|
||||||
Q_PROPERTY(QString genericName READ genericName NOTIFY genericNameChanged)
|
Q_PROPERTY(QString genericName READ genericName NOTIFY genericNameChanged)
|
||||||
Q_PROPERTY(QString categories READ categories NOTIFY categoriesChanged)
|
Q_PROPERTY(QString categories READ categories NOTIFY categoriesChanged)
|
||||||
Q_PROPERTY(QString keywords READ keywords NOTIFY keywordsChanged)
|
Q_PROPERTY(QString keywords READ keywords NOTIFY keywordsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AppEntry(QObject* entry, quint32 frequency, QObject* parent = nullptr);
|
explicit AppEntry(QObject* entry, quint32 frequency, QObject* parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] QObject* entry() const;
|
[[nodiscard]] QObject* entry() const;
|
||||||
|
|
||||||
[[nodiscard]] quint32 frequency() const;
|
[[nodiscard]] quint32 frequency() const;
|
||||||
void setFrequency(quint32 frequency);
|
void setFrequency(quint32 frequency);
|
||||||
void incrementFrequency();
|
void incrementFrequency();
|
||||||
|
|
||||||
[[nodiscard]] QString id() const;
|
[[nodiscard]] QString id() const;
|
||||||
[[nodiscard]] QString name() const;
|
[[nodiscard]] QString name() const;
|
||||||
[[nodiscard]] QString comment() const;
|
[[nodiscard]] QString comment() const;
|
||||||
[[nodiscard]] QString execString() const;
|
[[nodiscard]] QString execString() const;
|
||||||
[[nodiscard]] QString startupClass() const;
|
[[nodiscard]] QString startupClass() const;
|
||||||
[[nodiscard]] QString genericName() const;
|
[[nodiscard]] QString genericName() const;
|
||||||
[[nodiscard]] QString categories() const;
|
[[nodiscard]] QString categories() const;
|
||||||
[[nodiscard]] QString keywords() const;
|
[[nodiscard]] QString keywords() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void frequencyChanged();
|
void frequencyChanged();
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void commentChanged();
|
void commentChanged();
|
||||||
void execStringChanged();
|
void execStringChanged();
|
||||||
void startupClassChanged();
|
void startupClassChanged();
|
||||||
void genericNameChanged();
|
void genericNameChanged();
|
||||||
void categoriesChanged();
|
void categoriesChanged();
|
||||||
void keywordsChanged();
|
void keywordsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QObject* m_entry;
|
QObject* m_entry;
|
||||||
quint32 m_frequency;
|
quint32 m_frequency;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppDb : public QObject {
|
class AppDb : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
Q_PROPERTY(QString uuid READ uuid CONSTANT)
|
Q_PROPERTY(QString uuid READ uuid CONSTANT)
|
||||||
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged REQUIRED)
|
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged REQUIRED)
|
||||||
Q_PROPERTY(QObjectList entries READ entries WRITE setEntries NOTIFY entriesChanged REQUIRED)
|
Q_PROPERTY(QObjectList entries READ entries WRITE setEntries NOTIFY entriesChanged REQUIRED)
|
||||||
Q_PROPERTY(QQmlListProperty<ZShell::AppEntry> apps READ apps NOTIFY appsChanged)
|
Q_PROPERTY(QQmlListProperty<ZShell::AppEntry> apps READ apps NOTIFY appsChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AppDb(QObject* parent = nullptr);
|
explicit AppDb(QObject* parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] QString uuid() const;
|
[[nodiscard]] QString uuid() const;
|
||||||
|
|
||||||
[[nodiscard]] QString path() const;
|
[[nodiscard]] QString path() const;
|
||||||
void setPath(const QString& path);
|
void setPath(const QString& path);
|
||||||
|
|
||||||
[[nodiscard]] QObjectList entries() const;
|
[[nodiscard]] QObjectList entries() const;
|
||||||
void setEntries(const QObjectList& entries);
|
void setEntries(const QObjectList& entries);
|
||||||
|
|
||||||
[[nodiscard]] QQmlListProperty<AppEntry> apps();
|
[[nodiscard]] QQmlListProperty<AppEntry> apps();
|
||||||
|
|
||||||
Q_INVOKABLE void incrementFrequency(const QString& id);
|
Q_INVOKABLE void incrementFrequency(const QString& id);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pathChanged();
|
void pathChanged();
|
||||||
void entriesChanged();
|
void entriesChanged();
|
||||||
void appsChanged();
|
void appsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer* m_timer;
|
QTimer* m_timer;
|
||||||
|
|
||||||
const QString m_uuid;
|
const QString m_uuid;
|
||||||
QString m_path;
|
QString m_path;
|
||||||
QObjectList m_entries;
|
QObjectList m_entries;
|
||||||
QHash<QString, AppEntry*> m_apps;
|
QHash<QString, AppEntry*> m_apps;
|
||||||
mutable QList<AppEntry*> m_sortedApps;
|
mutable QList<AppEntry*> m_sortedApps;
|
||||||
|
|
||||||
QList<AppEntry*>& getSortedApps() const;
|
QList<AppEntry*>& getSortedApps() const;
|
||||||
quint32 getFrequency(const QString& id) const;
|
quint32 getFrequency(const QString& id) const;
|
||||||
void updateAppFrequencies();
|
void updateAppFrequencies();
|
||||||
void updateApps();
|
void updateApps();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell
|
} // namespace ZShell
|
||||||
|
|||||||
@@ -9,53 +9,53 @@
|
|||||||
namespace ZShell {
|
namespace ZShell {
|
||||||
|
|
||||||
class ImageAnalyser : public QObject {
|
class ImageAnalyser : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_ELEMENT
|
QML_ELEMENT
|
||||||
|
|
||||||
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
|
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
|
||||||
Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
|
Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
|
||||||
Q_PROPERTY(int rescaleSize READ rescaleSize WRITE setRescaleSize NOTIFY rescaleSizeChanged)
|
Q_PROPERTY(int rescaleSize READ rescaleSize WRITE setRescaleSize NOTIFY rescaleSizeChanged)
|
||||||
Q_PROPERTY(QColor dominantColour READ dominantColour NOTIFY dominantColourChanged)
|
Q_PROPERTY(QColor dominantColour READ dominantColour NOTIFY dominantColourChanged)
|
||||||
Q_PROPERTY(qreal luminance READ luminance NOTIFY luminanceChanged)
|
Q_PROPERTY(qreal luminance READ luminance NOTIFY luminanceChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ImageAnalyser(QObject* parent = nullptr);
|
explicit ImageAnalyser(QObject* parent = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] QString source() const;
|
[[nodiscard]] QString source() const;
|
||||||
void setSource(const QString& source);
|
void setSource(const QString& source);
|
||||||
|
|
||||||
[[nodiscard]] QQuickItem* sourceItem() const;
|
[[nodiscard]] QQuickItem* sourceItem() const;
|
||||||
void setSourceItem(QQuickItem* sourceItem);
|
void setSourceItem(QQuickItem* sourceItem);
|
||||||
|
|
||||||
[[nodiscard]] int rescaleSize() const;
|
[[nodiscard]] int rescaleSize() const;
|
||||||
void setRescaleSize(int rescaleSize);
|
void setRescaleSize(int rescaleSize);
|
||||||
|
|
||||||
[[nodiscard]] QColor dominantColour() const;
|
[[nodiscard]] QColor dominantColour() const;
|
||||||
[[nodiscard]] qreal luminance() const;
|
[[nodiscard]] qreal luminance() const;
|
||||||
|
|
||||||
Q_INVOKABLE void requestUpdate();
|
Q_INVOKABLE void requestUpdate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sourceChanged();
|
void sourceChanged();
|
||||||
void sourceItemChanged();
|
void sourceItemChanged();
|
||||||
void rescaleSizeChanged();
|
void rescaleSizeChanged();
|
||||||
void dominantColourChanged();
|
void dominantColourChanged();
|
||||||
void luminanceChanged();
|
void luminanceChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using AnalyseResult = QPair<QColor, qreal>;
|
using AnalyseResult = QPair<QColor, qreal>;
|
||||||
|
|
||||||
QFutureWatcher<AnalyseResult>* const m_futureWatcher;
|
QFutureWatcher<AnalyseResult>* const m_futureWatcher;
|
||||||
|
|
||||||
QString m_source;
|
QString m_source;
|
||||||
QQuickItem* m_sourceItem;
|
QQuickItem* m_sourceItem;
|
||||||
int m_rescaleSize;
|
int m_rescaleSize;
|
||||||
|
|
||||||
QColor m_dominantColour;
|
QColor m_dominantColour;
|
||||||
qreal m_luminance;
|
qreal m_luminance;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
static void analyse(QPromise<AnalyseResult>& promise, const QImage& image, int rescaleSize);
|
static void analyse(QPromise<AnalyseResult>& promise, const QImage& image, int rescaleSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell
|
} // namespace ZShell
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ QML_SINGLETON
|
|||||||
public:
|
public:
|
||||||
explicit Qalculator(QObject* parent = nullptr);
|
explicit Qalculator(QObject* parent = nullptr);
|
||||||
|
|
||||||
Q_INVOKABLE QString eval(const QString& expr, bool printExpr = true) const;
|
Q_INVOKABLE [[nodiscard]] QString eval(const QString& expr, bool printExpr = true) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ZShell
|
} // namespace ZShell
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qqmlintegration.h>
|
#include <qqmlintegration.h>
|
||||||
#include <qqmllist.h>
|
#include <qqmllist.h>
|
||||||
@@ -20,7 +21,7 @@ Q_PROPERTY(int timeout READ timeout CONSTANT)
|
|||||||
Q_PROPERTY(Type type READ type CONSTANT)
|
Q_PROPERTY(Type type READ type CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Type {
|
enum class Type: std::uint8_t {
|
||||||
Info = 0,
|
Info = 0,
|
||||||
Success,
|
Success,
|
||||||
Warning,
|
Warning,
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ Q_INVOKABLE void cacheImage(const QUrl& source, const QString& cacheDir, QJSValu
|
|||||||
Q_INVOKABLE void cacheImage(const QUrl& source, const QString& cacheDir, QJSValue onSaved, QJSValue onFailed);
|
Q_INVOKABLE void cacheImage(const QUrl& source, const QString& cacheDir, QJSValue onSaved, QJSValue onFailed);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
Q_INVOKABLE bool copyFile(const QUrl& source, const QUrl& target, bool overwrite = true) const;
|
Q_INVOKABLE [[nodiscard]] bool copyFile(const QUrl& source, const QUrl& target, bool overwrite = true) const;
|
||||||
Q_INVOKABLE bool deleteFile(const QUrl& path) const;
|
Q_INVOKABLE [[nodiscard]] bool deleteFile(const QUrl& path) const;
|
||||||
Q_INVOKABLE QString toLocalFile(const QUrl& url) const;
|
Q_INVOKABLE [[nodiscard]] QString toLocalFile(const QUrl& url) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool loadSourceImage(const QUrl& source, QImage& image) const;
|
bool loadSourceImage(const QUrl& source, QImage& image) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user