mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-05-28 02:50:21 -04:00
declarative: Add a QML extension object for accessing the margins property
Otherwise we get the following error message: Property "margins" with type "QMargins", which is not a value type Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
This commit is contained in:
parent
05de6c67b2
commit
44e011e2c6
@ -10,6 +10,31 @@
|
|||||||
|
|
||||||
QML_DECLARE_TYPEINFO(LayerShellQt::Window, QML_HAS_ATTACHED_PROPERTIES)
|
QML_DECLARE_TYPEINFO(LayerShellQt::Window, QML_HAS_ATTACHED_PROPERTIES)
|
||||||
|
|
||||||
|
class ExtQMargins
|
||||||
|
{
|
||||||
|
QMargins m_margins;
|
||||||
|
Q_GADGET
|
||||||
|
Q_PROPERTY(int left READ left WRITE setLeft FINAL)
|
||||||
|
Q_PROPERTY(int right READ right WRITE setRight FINAL)
|
||||||
|
Q_PROPERTY(int top READ top WRITE setTop FINAL)
|
||||||
|
Q_PROPERTY(int bottom READ bottom WRITE setBottom FINAL)
|
||||||
|
QML_FOREIGN(QMargins)
|
||||||
|
QML_EXTENDED(ExtQMargins)
|
||||||
|
public:
|
||||||
|
ExtQMargins(const QMargins &margins);
|
||||||
|
int left() const { return m_margins.left(); }
|
||||||
|
void setLeft(int left) { m_margins.setLeft(left); }
|
||||||
|
|
||||||
|
int right() const { return m_margins.right(); }
|
||||||
|
void setRight(int right) { m_margins.setRight(right); }
|
||||||
|
|
||||||
|
int top() const { return m_margins.top(); }
|
||||||
|
void setTop(int top) { m_margins.setTop(top); }
|
||||||
|
|
||||||
|
int bottom() const { return m_margins.bottom(); }
|
||||||
|
void setBottom(int bottom) { m_margins.setBottom(bottom); }
|
||||||
|
};
|
||||||
|
|
||||||
class Plugin : public QQmlExtensionPlugin
|
class Plugin : public QQmlExtensionPlugin
|
||||||
{
|
{
|
||||||
Q_PLUGIN_METADATA(IID "org.kde.layershellqt")
|
Q_PLUGIN_METADATA(IID "org.kde.layershellqt")
|
||||||
@ -19,6 +44,7 @@ public:
|
|||||||
{
|
{
|
||||||
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.layershell"));
|
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.layershell"));
|
||||||
qmlRegisterType<LayerShellQt::Window>(uri, 1, 0, "Window");
|
qmlRegisterType<LayerShellQt::Window>(uri, 1, 0, "Window");
|
||||||
|
qmlRegisterExtendedUncreatableType<QMargins, ExtQMargins>(uri, 1, 0, "ExtQMargins", QStringLiteral("Only created from C++"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ Item
|
|||||||
LayerShell.Window.anchors: LayerShell.Window.AnchorLeft
|
LayerShell.Window.anchors: LayerShell.Window.AnchorLeft
|
||||||
LayerShell.Window.layer: LayerShell.Window.LayerTop
|
LayerShell.Window.layer: LayerShell.Window.LayerTop
|
||||||
LayerShell.Window.exclusionZone: width
|
LayerShell.Window.exclusionZone: width
|
||||||
|
LayerShell.Window.margins.left: 100
|
||||||
|
|
||||||
width: 100
|
width: 100
|
||||||
height: 100
|
height: 100
|
||||||
|
Loading…
Reference in New Issue
Block a user