forked from quickshell/quickshell
The hot reloader previously attempted to figure out which parent a component would attach to as it loaded. This was fairly error prone as it was heuristic based and didn't work as soon as you split definitions into multiple QML files. The new hot reloader functions by first completely building the widget tree, then applying the old tree to the first tree and pulling out usable values. Proxy windows now wait to appear until being reloaded. Additionally added support for `reloadableId` to help match a Reloadable to its value in the previous widget tree.
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <qcontainerfwd.h>
|
|
#include <qobject.h>
|
|
#include <qqmlintegration.h>
|
|
#include <qqmllist.h>
|
|
#include <qtmetamacros.h>
|
|
#include <qtypes.h>
|
|
|
|
#include "qmlscreen.hpp"
|
|
|
|
class QuickShellGlobal: public QObject {
|
|
Q_OBJECT;
|
|
/// 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.
|
|
Q_PROPERTY(QQmlListProperty<QuickShellScreenInfo> screens READ screens NOTIFY screensChanged);
|
|
QML_SINGLETON;
|
|
QML_NAMED_ELEMENT(QuickShell);
|
|
|
|
public:
|
|
QuickShellGlobal(QObject* parent = nullptr);
|
|
|
|
QQmlListProperty<QuickShellScreenInfo> screens();
|
|
|
|
/// 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.
|
|
///
|
|
/// See [Reloadable] for more information on what can be reloaded and how.
|
|
///
|
|
/// [Reloadable]: ../reloadable
|
|
Q_INVOKABLE void reload(bool hard);
|
|
|
|
signals:
|
|
void screensChanged();
|
|
|
|
public slots:
|
|
void updateScreens();
|
|
|
|
private:
|
|
static qsizetype screensCount(QQmlListProperty<QuickShellScreenInfo>* prop);
|
|
static QuickShellScreenInfo* screenAt(QQmlListProperty<QuickShellScreenInfo>* prop, qsizetype i);
|
|
|
|
QVector<QuickShellScreenInfo*> mScreens;
|
|
};
|