diff options
Diffstat (limited to 'examples/wayland/custom-extension/cpp-client/main.cpp')
-rw-r--r-- | examples/wayland/custom-extension/cpp-client/main.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/wayland/custom-extension/cpp-client/main.cpp b/examples/wayland/custom-extension/cpp-client/main.cpp index 54c0bcc0b..da6230cc7 100644 --- a/examples/wayland/custom-extension/cpp-client/main.cpp +++ b/examples/wayland/custom-extension/cpp-client/main.cpp @@ -70,6 +70,7 @@ public: , rect1(50, 50, 100, 100) , rect2(50, 200, 100, 100) , rect3(50, 350, 100, 100) + , rect4(200,350, 100, 100) { m_extension->registerWindow(this); connect(m_extension, &CustomExtension::fontSize, this, &TestWindow::handleSetFontSize); @@ -101,6 +102,14 @@ public slots: w->show(); } + CustomExtensionObject *newObject() + { + m_objectCount++; + QColor col = QColor::fromHsv(0, 511/(m_objectCount+1), 255); + + return m_extension->createCustomObject(col.name(), QString::number(m_objectCount)); + } + void handleSetFontSize(QWindow *w, uint pixelSize) { if (w == this) { @@ -121,6 +130,9 @@ protected: p.drawText(rect2, Qt::TextWordWrap, "Press here to send bounce request."); p.fillRect(rect3, QColor("#7EA")); p.drawText(rect3, Qt::TextWordWrap, "Create new window."); + p.fillRect(rect4, QColor("#7EABA6")); + p.drawText(rect4, Qt::TextWordWrap, "Create custom object."); + } void mousePressEvent(QMouseEvent *ev) override @@ -131,6 +143,8 @@ protected: doBounce(); else if (rect3.contains(ev->pos())) newWindow(); + else if (rect4.contains(ev->pos())) + newObject(); } private: @@ -138,9 +152,15 @@ private: QRect rect1; QRect rect2; QRect rect3; + QRect rect4; QFont m_font; + static int m_objectCount; + static int m_hue; }; +int TestWindow::m_objectCount = 0; +int TestWindow::m_hue; + int main (int argc, char **argv) { QGuiApplication app(argc, argv); |