Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
FloatingWindow.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorShell/phosphorshell_export.h>
7
8#include <QQuickItem>
9#include <QString>
10
11#include <memory>
12
13QT_BEGIN_NAMESPACE
14class QQuickWindow;
15QT_END_NAMESPACE
16
17namespace PhosphorShell {
18
19class PHOSPHORSHELL_EXPORT FloatingWindow : public QQuickItem
20{
21 Q_OBJECT
22
23 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
24 Q_PROPERTY(int windowWidth READ windowWidth WRITE setWindowWidth NOTIFY windowWidthChanged)
25 Q_PROPERTY(int windowHeight READ windowHeight WRITE setWindowHeight NOTIFY windowHeightChanged)
26 Q_PROPERTY(bool windowVisible READ isWindowVisible WRITE setWindowVisible NOTIFY windowVisibleChanged)
27
28public:
29 explicit FloatingWindow(QQuickItem* parent = nullptr);
30 ~FloatingWindow() override;
31
32 [[nodiscard]] QString title() const;
33 void setTitle(const QString& title);
34
35 [[nodiscard]] int windowWidth() const;
36 void setWindowWidth(int width);
37
38 [[nodiscard]] int windowHeight() const;
39 void setWindowHeight(int height);
40
41 [[nodiscard]] bool isWindowVisible() const;
42 void setWindowVisible(bool visible);
43
44Q_SIGNALS:
49
50protected:
51 void itemChange(ItemChange change, const ItemChangeData& value) override;
52
53private:
54 void ensureWindow();
55 void reparentChildToWindow(QQuickItem* child);
56
57 QString m_title;
58 int m_windowWidth = 400;
59 int m_windowHeight = 300;
60 bool m_windowVisible = false;
61 std::unique_ptr<QQuickWindow> m_window;
62};
63
64} // namespace PhosphorShell
Definition FloatingWindow.h:20
void setWindowWidth(int width)
void setWindowVisible(bool visible)
void setTitle(const QString &title)
void setWindowHeight(int height)
void itemChange(ItemChange change, const ItemChangeData &value) override
FloatingWindow(QQuickItem *parent=nullptr)
Definition Environment.h:11