From efc725acec31adcafb8b2a3ee0e1ad9b093e35ad Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 21 Feb 2013 14:32:48 +0100 Subject: [PATCH] use a framesvgitem as background --- src/declarativeimports/core/dialog.cpp | 38 +++++++++++++------ src/declarativeimports/core/dialog.h | 4 +- .../desktop/contents/ui/CompactApplet.qml | 6 +-- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/declarativeimports/core/dialog.cpp b/src/declarativeimports/core/dialog.cpp index 75e2c167f..43528a8fd 100644 --- a/src/declarativeimports/core/dialog.cpp +++ b/src/declarativeimports/core/dialog.cpp @@ -19,7 +19,7 @@ ***************************************************************************/ #include "dialog.h" -//#include "declarativeitemcontainer_p.h" +#include "framesvgitem.h" #include #include @@ -112,6 +112,12 @@ DialogProxy::DialogProxy(QQuickItem *parent) m_syncTimer->setSingleShot(true); m_syncTimer->setInterval(250); connect(m_syncTimer, &QTimer::timeout, this, &DialogProxy::syncToMainItemSize); + + //HACK: this property is invoked due to the initialization that gets done to contentItem() in the getter + property("data"); + //Create the FrameSvg background. + m_frameSvgItem = new Plasma::FrameSvgItem(contentItem()); + m_frameSvgItem->setImagePath("dialogs/background"); } DialogProxy::~DialogProxy() @@ -131,8 +137,6 @@ void DialogProxy::setMainItem(QQuickItem *mainItem) if (m_mainItem) { m_mainItem.data()->setParent(parent()); } - //HACK: this property is invoked due to the initialization that gets done to contentItem() in the getter - property("data"); m_mainItem = mainItem; @@ -309,17 +313,25 @@ QObject *DialogProxy::margins() const void DialogProxy::resizeEvent(QResizeEvent *re) { - contentItem()->setX(0); - contentItem()->setY(0); - if (m_mainItem) { - m_mainItem.data()->setX(0); - m_mainItem.data()->setY(0); - m_mainItem.data()->setWidth(re->size().width()); - m_mainItem.data()->setHeight(re->size().height()); - } + syncMainItemToSize(); QQuickWindow::resizeEvent(re); } +void DialogProxy::syncMainItemToSize() +{ + m_frameSvgItem->setX(0); + m_frameSvgItem->setY(0); + m_frameSvgItem->setWidth(width()); + m_frameSvgItem->setHeight(height()); + + if (m_mainItem) { + m_mainItem.data()->setX(m_frameSvgItem->margins()->left()); + m_mainItem.data()->setY(m_frameSvgItem->margins()->top()); + m_mainItem.data()->setWidth(width() - m_frameSvgItem->margins()->left() - m_frameSvgItem->margins()->right()); + m_mainItem.data()->setHeight(height() - m_frameSvgItem->margins()->top() - m_frameSvgItem->margins()->bottom()); + } +} + void DialogProxy::syncToMainItemSize() { if (!m_mainItem) { @@ -327,7 +339,9 @@ void DialogProxy::syncToMainItemSize() } //FIXME: workaround to prevent dialogs of Popup type disappearing on the second show - const QSize s = QSize(m_mainItem.data()->width(), m_mainItem.data()->height()); + const QSize s = QSize(m_mainItem.data()->width(), m_mainItem.data()->height()) + + QSize(m_frameSvgItem->margins()->left() + m_frameSvgItem->margins()->right(), + m_frameSvgItem->margins()->top() + m_frameSvgItem->margins()->bottom()); //resize(0,0); resize(s); emit widthChanged(s.width()); diff --git a/src/declarativeimports/core/dialog.h b/src/declarativeimports/core/dialog.h index 2a5ab65c2..ef15c1169 100644 --- a/src/declarativeimports/core/dialog.h +++ b/src/declarativeimports/core/dialog.h @@ -31,10 +31,9 @@ class QQuickItem; namespace Plasma { - class Dialog; + class FrameSvgItem; } -class DeclarativeItemContainer; class DialogMargins : public QObject { @@ -219,6 +218,7 @@ private: DialogMargins *m_margins; bool m_activeWindow; Plasma::Location m_location; + Plasma::FrameSvgItem *m_frameSvgItem; }; #endif diff --git a/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml b/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml index dca851933..23ee39aa5 100644 --- a/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml +++ b/src/shell/qmlpackages/desktop/contents/ui/CompactApplet.qml @@ -45,9 +45,9 @@ Item { color: Qt.rgba(0,0,0,0) visible: plasmoid.expanded visualParent: root - mainItem: Rectangle { + mainItem: Item { id: appletParent - radius: 5 + width: applet && applet.implicitWidth > 0 ? applet.implicitWidth : theme.defaultFont.mSize.width * 35 height: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.defaultFont.mSize.height * 25 onWidthChanged: applet.width = width @@ -56,7 +56,7 @@ Item { onActiveWindowChanged: { if (!activeWindow) { - plasmoid.expanded = false + // plasmoid.expanded = false } } onVisibleChanged: {