Skip to content

Commit d916457

Browse files
committed
core/window: add title property to floating windows
1 parent 2032248 commit d916457

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/window/floatingwindow.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
void ProxyFloatingWindow::connectWindow() {
1414
this->ProxyWindowBase::connectWindow();
1515

16+
this->window->setTitle(this->bTitle);
1617
this->window->setMinimumSize(this->bMinimumSize);
1718
this->window->setMaximumSize(this->bMaximumSize);
1819
}
@@ -29,6 +30,11 @@ void ProxyFloatingWindow::trySetHeight(qint32 implicitHeight) {
2930
}
3031
}
3132

33+
void ProxyFloatingWindow::onTitleChanged() {
34+
if (this->window) this->window->setTitle(this->bTitle);
35+
emit this->titleChanged();
36+
}
37+
3238
void ProxyFloatingWindow::onMinimumSizeChanged() {
3339
if (this->window) this->window->setMinimumSize(this->bMinimumSize);
3440
emit this->minimumSizeChanged();
@@ -59,6 +65,7 @@ FloatingWindowInterface::FloatingWindowInterface(QObject* parent)
5965
QObject::connect(this->window, &ProxyWindowBase::maskChanged, this, &FloatingWindowInterface::maskChanged);
6066
QObject::connect(this->window, &ProxyWindowBase::surfaceFormatChanged, this, &FloatingWindowInterface::surfaceFormatChanged);
6167

68+
QObject::connect(this->window, &ProxyFloatingWindow::titleChanged, this, &FloatingWindowInterface::titleChanged);
6269
QObject::connect(this->window, &ProxyFloatingWindow::minimumSizeChanged, this, &FloatingWindowInterface::minimumSizeChanged);
6370
QObject::connect(this->window, &ProxyFloatingWindow::maximumSizeChanged, this, &FloatingWindowInterface::maximumSizeChanged);
6471
// clang-format on

src/window/floatingwindow.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ class ProxyFloatingWindow: public ProxyWindowBase {
2424
signals:
2525
void minimumSizeChanged();
2626
void maximumSizeChanged();
27+
void titleChanged();
2728

2829
private:
2930
void onMinimumSizeChanged();
3031
void onMaximumSizeChanged();
32+
void onTitleChanged();
3133

3234
public:
35+
Q_OBJECT_BINDABLE_PROPERTY(
36+
ProxyFloatingWindow,
37+
QString,
38+
bTitle,
39+
&ProxyFloatingWindow::onTitleChanged
40+
);
41+
3342
Q_OBJECT_BINDABLE_PROPERTY(
3443
ProxyFloatingWindow,
3544
QSize,
@@ -49,6 +58,8 @@ class ProxyFloatingWindow: public ProxyWindowBase {
4958
class FloatingWindowInterface: public WindowInterface {
5059
Q_OBJECT;
5160
// clang-format off
61+
/// Window title.
62+
Q_PROPERTY(QString title READ default WRITE default NOTIFY titleChanged BINDABLE bindableTitle);
5263
/// Minimum window size given to the window system.
5364
Q_PROPERTY(QSize minimumSize READ default WRITE default NOTIFY minimumSizeChanged BINDABLE bindableMinimumSize);
5465
/// Maximum window size given to the window system.
@@ -100,10 +111,12 @@ class FloatingWindowInterface: public WindowInterface {
100111

101112
QBindable<QSize> bindableMinimumSize() { return &this->window->bMinimumSize; }
102113
QBindable<QSize> bindableMaximumSize() { return &this->window->bMaximumSize; }
114+
QBindable<QString> bindableTitle() { return &this->window->bTitle; }
103115

104116
signals:
105117
void minimumSizeChanged();
106118
void maximumSizeChanged();
119+
void titleChanged();
107120

108121
private:
109122
ProxyFloatingWindow* window;

0 commit comments

Comments
 (0)