correctly restore popup size

This commit is contained in:
Marco Martin 2013-09-16 16:09:13 +02:00
parent 0ead10fe0b
commit e923afe0ee
2 changed files with 34 additions and 8 deletions

View File

@ -687,12 +687,31 @@ void AppletInterface::compactRepresentationCheck()
//replace the full applet with the collapsed view
m_compactUiObject.data()->setProperty("visible", true);
m_compactUiObject.data()->setProperty("parent", QVariant::fromValue(this));
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent");
QQmlProperty prop(m_compactUiObject.data(), "anchors.fill");
prop.write(expr.evaluate());
{
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent");
QQmlProperty prop(m_compactUiObject.data(), "anchors.fill");
prop.write(expr.evaluate());
}
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(m_compactUiObject.data()));
{
//reset all the anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "anchors.fill=undefined;anchors.left=undefined;anchors.right=undefined;anchors.top=undefined;anchors.bottom=undefined;");
expr.evaluate();
}
KConfigGroup cg = applet()->config();
cg = KConfigGroup(&cg, "PopupApplet");
int width = cg.readEntry("DialogWidth", 0);
int height = cg.readEntry("DialogHeight", 0);
m_qmlObject->rootObject()->setProperty("width", width);
m_qmlObject->rootObject()->setProperty("height", height);
m_compactUiObject.data()->setProperty("applet", QVariant::fromValue(m_qmlObject->rootObject()));
//hook m_compactUiObject size hints to this size hint

View File

@ -42,8 +42,17 @@ Item {
property Item compactRepresentation
onAppletChanged: {
applet.parent = appletParent
applet.anchors.fill = applet.parent
//if the applet size was restored to a stored size, or if is dragged from the desktop, restore popup size
if (applet.width > 0) {
popupWindow.mainItem.width = applet.width;
}
if (applet.height > 0) {
popupWindow.mainItem.height = applet.height;
}
applet.parent = appletParent;
applet.anchors.fill = applet.parent;
}
onCompactRepresentationChanged: {
compactRepresentation.parent = root
@ -62,8 +71,6 @@ Item {
width: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.mSize(theme.defaultFont).width * 35
height: applet && applet.implicitHeight > 0 ? applet.implicitHeight : theme.mSize(theme.defaultFont).height * 25
onWidthChanged: applet.width = width
onHeightChanged: applet.height = height
}
onActiveWindowChanged: {