forked from quickshell/quickshell
core/window: add QsWindow attached object to contained Items
This commit is contained in:
parent
d1c33d48cd
commit
e48af44607
4 changed files with 75 additions and 1 deletions
|
@ -1 +1,29 @@
|
|||
#include "windowinterface.hpp" // NOLINT
|
||||
#include "windowinterface.hpp"
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qquickitem.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
#include "proxywindow.hpp"
|
||||
|
||||
QsWindowAttached* WindowInterface::qmlAttachedProperties(QObject* object) {
|
||||
auto* item = qobject_cast<QQuickItem*>(object);
|
||||
if (!item) return nullptr;
|
||||
auto* window = item->window();
|
||||
if (!window) return nullptr;
|
||||
auto* proxy = window->property("__qs_proxywindow").value<ProxyWindowBase*>();
|
||||
if (!proxy) return nullptr;
|
||||
|
||||
auto v = proxy->property("__qs_window_attached");
|
||||
if (auto* attached = v.value<QsWindowAttached*>()) {
|
||||
return attached;
|
||||
}
|
||||
|
||||
auto* attached = new ProxyWindowAttached(proxy);
|
||||
|
||||
if (attached) {
|
||||
proxy->setProperty("__qs_window_attached", QVariant::fromValue(attached));
|
||||
}
|
||||
|
||||
return attached;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue