From 1928ecce74f71d08035e5f010a674e18e9168cef Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 20 Feb 2013 15:18:58 +0100 Subject: [PATCH] make sure a transparent window --- src/declarativeimports/core/dialog.cpp | 21 +++++++++++++++++-- src/declarativeimports/core/dialog.h | 1 + .../desktop/contents/ui/CompactApplet.qml | 17 +++++++++------ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/declarativeimports/core/dialog.cpp b/src/declarativeimports/core/dialog.cpp index 8d087841b..df824490b 100644 --- a/src/declarativeimports/core/dialog.cpp +++ b/src/declarativeimports/core/dialog.cpp @@ -99,12 +99,17 @@ DialogProxy::DialogProxy(QQuickItem *parent) m_activeWindow(false), m_location(Plasma::Floating) { + QSurfaceFormat format; + format.setAlphaBufferSize(8); + setFormat(format); + setClearBeforeRendering(true); + setColor(QColor(Qt::transparent)); + setFlags(Qt::FramelessWindowHint); + //m_dialog = new QQuickWindow(); m_margins = new DialogMargins(m_dialog, this); //m_dialog->installEventFilter(this); m_flags = flags(); - setWindowFlags(Qt::FramelessWindowHint); - setColor(Qt::transparent); } DialogProxy::~DialogProxy() @@ -412,6 +417,18 @@ QObject *DialogProxy::margins() const return m_margins; } +void DialogProxy::resizeEvent(QResizeEvent *re) +{ + if (contentItem()) { + contentItem()->setWidth(re->size().width()); + contentItem()->setHeight(re->size().height()); + } + if (m_mainItem) { + m_mainItem.data()->setWidth(re->size().width()); + m_mainItem.data()->setHeight(re->size().height()); + } +} + bool DialogProxy::eventFilter(QObject *watched, QEvent *event) { if (watched == this && event->type() == QEvent::Move) { diff --git a/src/declarativeimports/core/dialog.h b/src/declarativeimports/core/dialog.h index b6620e8a3..bf2d97224 100644 --- a/src/declarativeimports/core/dialog.h +++ b/src/declarativeimports/core/dialog.h @@ -230,6 +230,7 @@ protected Q_SLOTS: protected: bool eventFilter(QObject *watched, QEvent *event); + void resizeEvent(QResizeEvent *re); private: QQuickWindow *m_dialog; diff --git a/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml b/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml index 775a3895b..57a255ac2 100644 --- a/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml +++ b/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml @@ -36,20 +36,25 @@ Item { } - Window { + PlasmaCore.Dialog { id: popupWindow + //windowFlags: Qt.Popup + color: Qt.rgba(0,0,0,0) visible: plasmoid.expanded onVisibleChanged: { if (!visible) { plasmoid.expanded = false } } - width: 200 - height: 200 - Item { + onWidthChanged: appletParent.width = width + onHeightChanged:appletParent.height = height + mainItem: appletParent + Rectangle { id: appletParent - width: applet.implicitWidth - height: applet.implicitHeight + width: 200//applet.implicitWidth + height: 200//applet.implicitHeight + onWidthChanged: applet.width = width + onHeightChanged: applet.height = height } } }