2024-02-04 12:58:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <qcontainerfwd.h>
|
|
|
|
#include <qobject.h>
|
|
|
|
#include <qqmlintegration.h>
|
|
|
|
#include <qqmllist.h>
|
|
|
|
#include <qtmetamacros.h>
|
|
|
|
#include <qtypes.h>
|
|
|
|
|
|
|
|
#include "qmlscreen.hpp"
|
|
|
|
|
2024-02-12 10:16:22 +00:00
|
|
|
class QuickShellGlobal: public QObject {
|
2024-02-04 12:58:58 +00:00
|
|
|
Q_OBJECT;
|
2024-02-12 12:21:24 +00:00
|
|
|
/// All currently connected screens.
|
|
|
|
///
|
|
|
|
/// This property updates as connected screens change.
|
|
|
|
///
|
|
|
|
/// #### Reusing a window on every screen
|
|
|
|
/// ```qml
|
|
|
|
/// ShellRoot {
|
|
|
|
/// Variants {
|
|
|
|
/// ProxyShellWindow {
|
|
|
|
/// // ...
|
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// // see Variants for details
|
|
|
|
/// variants: QuickShell.screens.map(screen => ({ screen }))
|
|
|
|
/// }
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// This creates an instance of your window once on every screen.
|
|
|
|
/// As screens are added or removed your window will be created or destroyed on those screens.
|
2024-02-12 10:16:22 +00:00
|
|
|
Q_PROPERTY(QQmlListProperty<QuickShellScreenInfo> screens READ screens NOTIFY screensChanged);
|
2024-02-04 12:58:58 +00:00
|
|
|
QML_SINGLETON;
|
2024-02-12 10:16:22 +00:00
|
|
|
QML_NAMED_ELEMENT(QuickShell);
|
2024-02-04 12:58:58 +00:00
|
|
|
|
|
|
|
public:
|
2024-02-12 10:16:22 +00:00
|
|
|
QuickShellGlobal(QObject* parent = nullptr);
|
2024-02-04 12:58:58 +00:00
|
|
|
|
2024-02-12 10:16:22 +00:00
|
|
|
QQmlListProperty<QuickShellScreenInfo> screens();
|
2024-02-04 12:58:58 +00:00
|
|
|
|
2024-02-12 12:21:24 +00:00
|
|
|
/// Reload the shell from the [ShellRoot].
|
|
|
|
///
|
|
|
|
/// `hard` - perform a hard reload. If this is false, QuickShell will attempt to reuse windows
|
|
|
|
/// that already exist. If true windows will be recreated.
|
|
|
|
///
|
|
|
|
/// > [!INFO] QuickShell can only reuse windows that are in a hierarchy of elements known
|
|
|
|
/// > internally as `Scavengeable`. These types are [ShellRoot] and [Variants].
|
|
|
|
/// >
|
|
|
|
/// > ```qml
|
|
|
|
/// > // this will reuse the window on reload
|
|
|
|
/// > ShellRoot {
|
|
|
|
/// > Varaints {
|
|
|
|
/// > ProxyShellWindow {
|
|
|
|
/// > // ...
|
|
|
|
/// > }
|
|
|
|
/// >
|
|
|
|
/// > // ...
|
|
|
|
/// > }
|
|
|
|
/// > }
|
|
|
|
/// >
|
|
|
|
/// > // this will NOT reuse the window on reload,
|
|
|
|
/// > // and will destroy the old one / create a new one every time
|
|
|
|
/// > ShellRoot {
|
|
|
|
/// > AnyNonScavengeableType {
|
|
|
|
/// > ProxyShellWindow {
|
|
|
|
/// > // ...
|
|
|
|
/// > }
|
|
|
|
/// >
|
|
|
|
/// > // ...
|
|
|
|
/// > }
|
|
|
|
/// > }
|
|
|
|
/// > ```
|
|
|
|
/// >
|
|
|
|
/// > [ShellRoot]: ../shellroot
|
|
|
|
/// > [Variants]: ../variants
|
|
|
|
Q_INVOKABLE void reload(bool hard);
|
|
|
|
|
2024-02-04 12:58:58 +00:00
|
|
|
signals:
|
|
|
|
void screensChanged();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void updateScreens();
|
|
|
|
|
|
|
|
private:
|
2024-02-12 10:16:22 +00:00
|
|
|
static qsizetype screensCount(QQmlListProperty<QuickShellScreenInfo>* prop);
|
|
|
|
static QuickShellScreenInfo* screenAt(QQmlListProperty<QuickShellScreenInfo>* prop, qsizetype i);
|
2024-02-04 12:58:58 +00:00
|
|
|
|
2024-02-12 10:16:22 +00:00
|
|
|
QVector<QuickShellScreenInfo*> mScreens;
|
2024-02-04 12:58:58 +00:00
|
|
|
};
|