correct item resize

comment out more old api

will be reenable one by one only when needed
This commit is contained in:
Marco Martin 2013-02-20 15:51:28 +01:00
parent 059682af85
commit 8ba734f05b
4 changed files with 67 additions and 56 deletions

View File

@ -128,14 +128,14 @@ void DialogProxy::setMainItem(QQuickItem *mainItem)
if (m_mainItem.data() != mainItem) {
qDebug() << "YYYYY Main ITem: " << mainItem->width() << mainItem->height();
if (m_mainItem) {
m_mainItem.data()->setParent(mainItem ? mainItem->parent() : 0);
m_mainItem.data()->setParent(parent());
}
m_mainItem = mainItem;
if (mainItem) {
//mainItem->setParentItem(0);
mainItem->setParent(this);
mainItem->setParent(contentItem());
}
//if this is called in Compenent.onCompleted we have to wait a loop the item is added to a scene
@ -272,35 +272,35 @@ QPoint DialogProxy::popupPosition(QQuickItem *item, int alignment)
}
int DialogProxy::x() const
{
return geometry().topLeft().x();
}
void DialogProxy::setX(int x)
{
//m_dialog->move(x, m_dialog->geometry().topLeft().y());
}
int DialogProxy::y() const
{
return geometry().topLeft().y();
}
void DialogProxy::setY(int y)
{
//m_dialog->move(m_dialog->geometry().topLeft().x(), y);
}
int DialogProxy::width() const
{
return size().width();
}
int DialogProxy::height() const
{
return size().height();
}
// int DialogProxy::x() const
// {
// return geometry().topLeft().x();
// }
//
// void DialogProxy::setX(int x)
// {
// //m_dialog->move(x, m_dialog->geometry().topLeft().y());
// }
//
// int DialogProxy::y() const
// {
// return geometry().topLeft().y();
// }
//
// void DialogProxy::setY(int y)
// {
// //m_dialog->move(m_dialog->geometry().topLeft().x(), y);
// }
//
// int DialogProxy::width() const
// {
// return size().width();
// }
//
// int DialogProxy::height() const
// {
// return size().height();
// }
bool DialogProxy::isActiveWindow() const
{
@ -353,16 +353,18 @@ QObject *DialogProxy::margins() const
void DialogProxy::resizeEvent(QResizeEvent *re)
{
if (contentItem()) {
contentItem()->setWidth(re->size().width());
contentItem()->setHeight(re->size().height());
}
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());
}
QQuickWindow::resizeEvent(re);
}
/*
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
{
if (watched == this && event->type() == QEvent::Move) {
@ -403,7 +405,7 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
emit activeWindowChanged();
}
return false;
}
}*/
void DialogProxy::setAttribute(int attribute, bool on)
{

View File

@ -108,23 +108,23 @@ class DialogProxy : public QQuickWindow
/**
* X position of the dialog window in screen coordinates.
*/
Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
// Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
/**
* X position of the dialog window in screen coordinates.
*/
Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
// Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
//to set the size try to force doing so from the inner item
/**
* Read only width of the dialog window. It depends from the width of the mainItem
*/
Q_PROPERTY(int width READ width NOTIFY widthChanged)
//Q_PROPERTY(int width READ width NOTIFY widthChanged)
/**
* Read only height of the dialog window. It depends from the height of the mainItem
*/
Q_PROPERTY(int height READ height NOTIFY heightChanged)
//Q_PROPERTY(int height READ height NOTIFY heightChanged)
/**
* Window flags of the Dialog window
@ -168,14 +168,14 @@ public:
bool isVisible() const;
void setVisible(const bool visible);
int x() const;
void setX(int x);
int y() const;
void setY(int y);
int width() const;
int height() const;
// int x() const;
// void setX(int x);
//
// int y() const;
// void setY(int y);
//
// int width() const;
// int height() const;
bool isActiveWindow() const;
@ -218,16 +218,16 @@ public:
Q_SIGNALS:
void mainItemChanged();
void visibleChanged();
void xChanged();
void yChanged();
void widthChanged();
void heightChanged();
// void xChanged();
// void yChanged();
// void widthChanged();
// void heightChanged();
void activeWindowChanged();
void locationChanged();
protected:
bool eventFilter(QObject *watched, QEvent *event);
// bool eventFilter(QObject *watched, QEvent *event);
void resizeEvent(QResizeEvent *re);
private:

View File

@ -565,6 +565,11 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
m_compactUiObject.data()->deleteLater();
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "parent");
QQmlProperty prop(m_qmlObject->rootObject(), "anchors.fill");
prop.write(expr.evaluate());
}
}

View File

@ -29,7 +29,10 @@ Item {
property Item compactRepresentation
onAppletChanged: applet.parent = appletParent
onAppletChanged: {
applet.parent = appletParent
applet.anchors.fill = applet.parent
}
onCompactRepresentationChanged: {
compactRepresentation.parent = root
compactRepresentation.anchors.fill = root
@ -46,11 +49,12 @@ Item {
plasmoid.expanded = false
}
}
onWidthChanged: appletParent.width = width
onHeightChanged:appletParent.height = height
//onWidthChanged: appletParent.width = width
//onHeightChanged:appletParent.height = height
mainItem: appletParent
Rectangle {
id: appletParent
radius: 10
width: 200//applet.implicitWidth
height: 200//applet.implicitHeight
onWidthChanged: applet.width = width