mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-30 12:48:55 +01:00
feat: ambient scene system + unlock-screen banner (reduced-motion aware)
Reusable SceneWidget (QQuickWidget host) loads scene.qml — dusk sky, tiled grass, running doge, bouncing WOW coins (slowed per feedback), drifting money — and feeds it Config::reducedMotion so it freezes to a still when that's set. First placement: a banner atop the unlock form. Scene rendered & verified at banner + screensaver aspects via local qml6 harness. Assets from wow-lite-wallet (friend's). Home banner / idle screensaver / per-tab idle to follow on the same SceneWidget.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: The Monero Project
|
||||
|
||||
#include "SceneWidget.h"
|
||||
|
||||
#include <QQmlContext>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
SceneWidget::SceneWidget(QWidget *parent)
|
||||
: QQuickWidget(parent)
|
||||
, m_backend(new SceneBackend(this))
|
||||
{
|
||||
m_backend->setReducedMotion(conf()->get(Config::reducedMotion).toBool());
|
||||
this->rootContext()->setContextProperty("sceneCtx", m_backend);
|
||||
this->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
this->setSource(QUrl("qrc:/qml/scene.qml"));
|
||||
}
|
||||
|
||||
void SceneWidget::refreshReducedMotion() {
|
||||
m_backend->setReducedMotion(conf()->get(Config::reducedMotion).toBool());
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: The Monero Project
|
||||
|
||||
#ifndef WOWLET_SCENEWIDGET_H
|
||||
#define WOWLET_SCENEWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQuickWidget>
|
||||
|
||||
// Context object exposed to scene.qml as `sceneCtx`. Carries the reduced-motion
|
||||
// setting so the scene freezes into its still (reduced-motion) form.
|
||||
class SceneBackend : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool reducedMotion READ reducedMotion NOTIFY reducedMotionChanged)
|
||||
public:
|
||||
explicit SceneBackend(QObject *parent = nullptr) : QObject(parent) {}
|
||||
bool reducedMotion() const { return m_reducedMotion; }
|
||||
void setReducedMotion(bool r) { if (m_reducedMotion != r) { m_reducedMotion = r; emit reducedMotionChanged(); } }
|
||||
signals:
|
||||
void reducedMotionChanged();
|
||||
private:
|
||||
bool m_reducedMotion = false;
|
||||
};
|
||||
|
||||
// wowlet: reusable ambient-scene surface. Hosts scene.qml and reads the
|
||||
// reduced-motion preference from Config. Drop it behind a form, into a banner,
|
||||
// or over the window as an idle screensaver.
|
||||
class SceneWidget : public QQuickWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SceneWidget(QWidget *parent = nullptr);
|
||||
void refreshReducedMotion();
|
||||
private:
|
||||
SceneBackend *m_backend;
|
||||
};
|
||||
|
||||
#endif //WOWLET_SCENEWIDGET_H
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "utils/Utils.h"
|
||||
#include "libwalletqt/Wallet.h"
|
||||
#include "widgets/SceneWidget.h"
|
||||
|
||||
WalletUnlockWidget::WalletUnlockWidget(QWidget *parent, Wallet *wallet)
|
||||
: QWidget(parent)
|
||||
@@ -18,6 +19,13 @@ WalletUnlockWidget::WalletUnlockWidget(QWidget *parent, Wallet *wallet)
|
||||
ui->setupUi(this);
|
||||
this->reset();
|
||||
|
||||
// wowlet: ambient scene banner above the unlock form (freezes itself into a
|
||||
// still when "Prefer reduced motion" is set).
|
||||
auto *scene = new SceneWidget(this);
|
||||
scene->setMinimumHeight(120);
|
||||
scene->setMaximumHeight(140);
|
||||
ui->verticalLayout->insertWidget(0, scene);
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setAutoDefault(true);
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &WalletUnlockWidget::tryUnlock);
|
||||
|
||||
Reference in New Issue
Block a user