Cockatrice/cockatrice/src/interface/widgets/onboarding/shader_banner_widget.h
BruebachL 2b7b4e8168
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
[App] Add onboarding wizard (#7064)
* [App] Add onboarding wizard

Took 10 minutes

Took 3 minutes

Took 7 minutes

Took 9 minutes

Took 2 minutes

Took 1 minute


Took 7 minutes

* Adjust CI

Took 14 minutes

Took 56 seconds

Took 2 seconds

Took 3 seconds

* Adjust CI again

Took 14 minutes

Took 2 seconds

* Comments and fixes

Took 9 seconds


Took 1 minute

* Rebase.

Took 5 minutes

Took 50 seconds

Took 15 seconds

* Comments.

Took 7 minutes

* CI lol

Took 3 minutes

* CI again lol

Took 4 minutes

* Drop some settings, add some new ones.

Took 19 minutes

* Resize when expanding section

Took 4 minutes

Took 3 minutes

Took 7 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-08-24 23:05:58 +02:00

83 lines
2.3 KiB
C++

#ifndef SHADER_BANNER_WIDGET_H
#define SHADER_BANNER_WIDGET_H
#include <QElapsedTimer>
#include <QTimer>
#include <QWidget>
class BannerShaderConfig;
class QQuickWidget;
class GradientFallbackWidget;
class QStackedLayout;
/** @brief Onboarding banner: a subtle, looping brand-shader animation, one of six
* per-page "motifs" driving the same prebaked fragment shader
* (onboarding/shaders/brand_banner.frag) with different uniform values, so
* every page feels distinct but unmistakably part of the same family.
*
* Motif switches crossfade smoothly (see BrandBanner.qml's two stacked
* ShaderEffect layers + Behavior on opacity) rather than cutting instantly
* -- BannerHost just writes the new preset into whichever layer is
* currently hidden and flips BannerShaderConfig::frontIsA; QML handles the
* actual animation declaratively.
*
* Falls back to a static two-stop gradient (no shader, no QQuickWidget) if
* the platform's Qt Quick scenegraph can't initialize -- e.g. software
* rendering only, or a CI/VM environment with no GPU -- so onboarding
* never blocks or blanks out over a graphics driver problem. The fallback
* is permanent for the lifetime of this widget once triggered. */
class BannerHost : public QWidget
{
Q_OBJECT
public:
enum class Motif
{
Welcome,
CardDatabase,
Theming,
Account,
Preferences,
Finish,
};
explicit BannerHost(QWidget *parent = nullptr);
void setMotif(Motif motif);
protected:
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private slots:
void tick();
void onSceneGraphFailed();
private:
struct Preset
{
qreal mode;
qreal speed;
qreal seed;
};
static Preset presetFor(Motif motif);
void applyMotifPreset(Motif motif);
void updateAspect();
void activateFallback();
QStackedLayout *stack;
QQuickWidget *quickWidget = nullptr;
BannerShaderConfig *config = nullptr;
GradientFallbackWidget *fallback = nullptr;
QTimer clock;
QElapsedTimer elapsed;
Motif currentMotif = Motif::Welcome;
bool usingFallback = false;
bool isFirstApply = true;
};
#endif // SHADER_BANNER_WIDGET_H