use a framesvgitem as background
This commit is contained in:
parent
de81cdada3
commit
efc725acec
@ -19,7 +19,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
//#include "declarativeitemcontainer_p.h"
|
#include "framesvgitem.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
@ -112,6 +112,12 @@ DialogProxy::DialogProxy(QQuickItem *parent)
|
|||||||
m_syncTimer->setSingleShot(true);
|
m_syncTimer->setSingleShot(true);
|
||||||
m_syncTimer->setInterval(250);
|
m_syncTimer->setInterval(250);
|
||||||
connect(m_syncTimer, &QTimer::timeout, this, &DialogProxy::syncToMainItemSize);
|
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()
|
DialogProxy::~DialogProxy()
|
||||||
@ -131,8 +137,6 @@ void DialogProxy::setMainItem(QQuickItem *mainItem)
|
|||||||
if (m_mainItem) {
|
if (m_mainItem) {
|
||||||
m_mainItem.data()->setParent(parent());
|
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;
|
m_mainItem = mainItem;
|
||||||
@ -309,17 +313,25 @@ QObject *DialogProxy::margins() const
|
|||||||
|
|
||||||
void DialogProxy::resizeEvent(QResizeEvent *re)
|
void DialogProxy::resizeEvent(QResizeEvent *re)
|
||||||
{
|
{
|
||||||
contentItem()->setX(0);
|
syncMainItemToSize();
|
||||||
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());
|
|
||||||
}
|
|
||||||
QQuickWindow::resizeEvent(re);
|
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()
|
void DialogProxy::syncToMainItemSize()
|
||||||
{
|
{
|
||||||
if (!m_mainItem) {
|
if (!m_mainItem) {
|
||||||
@ -327,7 +339,9 @@ void DialogProxy::syncToMainItemSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: workaround to prevent dialogs of Popup type disappearing on the second show
|
//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(0,0);
|
||||||
resize(s);
|
resize(s);
|
||||||
emit widthChanged(s.width());
|
emit widthChanged(s.width());
|
||||||
|
@ -31,10 +31,9 @@ class QQuickItem;
|
|||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
class Dialog;
|
class FrameSvgItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeclarativeItemContainer;
|
|
||||||
|
|
||||||
class DialogMargins : public QObject
|
class DialogMargins : public QObject
|
||||||
{
|
{
|
||||||
@ -219,6 +218,7 @@ private:
|
|||||||
DialogMargins *m_margins;
|
DialogMargins *m_margins;
|
||||||
bool m_activeWindow;
|
bool m_activeWindow;
|
||||||
Plasma::Location m_location;
|
Plasma::Location m_location;
|
||||||
|
Plasma::FrameSvgItem *m_frameSvgItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,9 +45,9 @@ Item {
|
|||||||
color: Qt.rgba(0,0,0,0)
|
color: Qt.rgba(0,0,0,0)
|
||||||
visible: plasmoid.expanded
|
visible: plasmoid.expanded
|
||||||
visualParent: root
|
visualParent: root
|
||||||
mainItem: Rectangle {
|
mainItem: Item {
|
||||||
id: appletParent
|
id: appletParent
|
||||||
radius: 5
|
|
||||||
width: applet && applet.implicitWidth > 0 ? applet.implicitWidth : theme.defaultFont.mSize.width * 35
|
width: applet && applet.implicitWidth > 0 ? applet.implicitWidth : theme.defaultFont.mSize.width * 35
|
||||||
height: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.defaultFont.mSize.height * 25
|
height: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.defaultFont.mSize.height * 25
|
||||||
onWidthChanged: applet.width = width
|
onWidthChanged: applet.width = width
|
||||||
@ -56,7 +56,7 @@ Item {
|
|||||||
|
|
||||||
onActiveWindowChanged: {
|
onActiveWindowChanged: {
|
||||||
if (!activeWindow) {
|
if (!activeWindow) {
|
||||||
plasmoid.expanded = false
|
// plasmoid.expanded = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
|
Loading…
Reference in New Issue
Block a user