Initial release of Lumen Wallpaper
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "rendernode.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QElapsedTimer>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QQuickItem>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QVector4D>
|
||||
|
||||
class VulkanWallpaperItem : public QQuickItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUrl shaderUrl READ shaderUrl WRITE setShaderUrl NOTIFY shaderUrlChanged)
|
||||
Q_PROPERTY(int targetFps READ targetFps WRITE setTargetFps NOTIFY targetFpsChanged)
|
||||
Q_PROPERTY(double speed READ speed WRITE setSpeed NOTIFY speedChanged)
|
||||
Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
|
||||
Q_PROPERTY(bool mouseEnabled READ mouseEnabled WRITE setMouseEnabled NOTIFY mouseEnabledChanged)
|
||||
Q_PROPERTY(bool watchSource READ watchSource WRITE setWatchSource NOTIFY watchSourceChanged)
|
||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
|
||||
Q_PROPERTY(bool fallbackActive READ fallbackActive NOTIFY fallbackActiveChanged)
|
||||
|
||||
public:
|
||||
explicit VulkanWallpaperItem(QQuickItem *parent = nullptr);
|
||||
~VulkanWallpaperItem() override = default;
|
||||
|
||||
QUrl shaderUrl() const { return m_shaderUrl; }
|
||||
int targetFps() const { return m_targetFps; }
|
||||
double speed() const { return m_speed; }
|
||||
bool running() const { return m_running; }
|
||||
bool mouseEnabled() const { return m_mouseEnabled; }
|
||||
bool watchSource() const { return m_watchSource; }
|
||||
QString errorMessage() const { return m_errorMessage; }
|
||||
bool fallbackActive() const { return m_fallbackActive; }
|
||||
|
||||
void setShaderUrl(const QUrl &url);
|
||||
void setTargetFps(int fps);
|
||||
void setSpeed(double speed);
|
||||
void setRunning(bool running);
|
||||
void setMouseEnabled(bool enabled);
|
||||
void setWatchSource(bool enabled);
|
||||
void applyRenderStatus(int status, const QString &message);
|
||||
|
||||
Q_SIGNALS:
|
||||
void shaderUrlChanged();
|
||||
void targetFpsChanged();
|
||||
void speedChanged();
|
||||
void runningChanged();
|
||||
void mouseEnabledChanged();
|
||||
void watchSourceChanged();
|
||||
void errorMessageChanged();
|
||||
void fallbackActiveChanged();
|
||||
|
||||
protected:
|
||||
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
|
||||
void itemChange(ItemChange change, const ItemChangeData &value) override;
|
||||
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
||||
void hoverMoveEvent(QHoverEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseUngrabEvent() override;
|
||||
|
||||
private:
|
||||
void loadShader();
|
||||
void updateWatcher();
|
||||
void updateTimer();
|
||||
void tick();
|
||||
void setMousePosition(const QPointF &position);
|
||||
void setMouseDown(bool down);
|
||||
void updateErrorState();
|
||||
|
||||
QUrl m_shaderUrl;
|
||||
QString m_shaderFile;
|
||||
QByteArray m_shaderSource;
|
||||
QString m_fileError;
|
||||
QString m_renderError;
|
||||
QString m_errorMessage;
|
||||
QFileSystemWatcher m_watcher;
|
||||
QTimer m_renderTimer;
|
||||
QTimer m_reloadTimer;
|
||||
QElapsedTimer m_clock;
|
||||
qint64 m_lastTickNs = 0;
|
||||
double m_animationTime = 0.0;
|
||||
double m_timeDelta = 1.0 / 30.0;
|
||||
double m_frameRate = 30.0;
|
||||
quint64 m_frame = 0;
|
||||
int m_targetFps = 30;
|
||||
double m_speed = 1.0;
|
||||
bool m_running = true;
|
||||
bool m_mouseEnabled = true;
|
||||
bool m_watchSource = true;
|
||||
bool m_fallbackActive = false;
|
||||
int m_renderStatus = -2;
|
||||
QVector4D m_mouse;
|
||||
};
|
||||
Reference in New Issue
Block a user