correct item resize
comment out more old api will be reenable one by one only when needed
This commit is contained in:
parent
059682af85
commit
8ba734f05b
@ -128,14 +128,14 @@ void DialogProxy::setMainItem(QQuickItem *mainItem)
|
|||||||
if (m_mainItem.data() != mainItem) {
|
if (m_mainItem.data() != mainItem) {
|
||||||
qDebug() << "YYYYY Main ITem: " << mainItem->width() << mainItem->height();
|
qDebug() << "YYYYY Main ITem: " << mainItem->width() << mainItem->height();
|
||||||
if (m_mainItem) {
|
if (m_mainItem) {
|
||||||
m_mainItem.data()->setParent(mainItem ? mainItem->parent() : 0);
|
m_mainItem.data()->setParent(parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mainItem = mainItem;
|
m_mainItem = mainItem;
|
||||||
|
|
||||||
if (mainItem) {
|
if (mainItem) {
|
||||||
//mainItem->setParentItem(0);
|
//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
|
//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
|
// int DialogProxy::x() const
|
||||||
{
|
// {
|
||||||
return geometry().topLeft().x();
|
// return geometry().topLeft().x();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void DialogProxy::setX(int x)
|
// void DialogProxy::setX(int x)
|
||||||
{
|
// {
|
||||||
//m_dialog->move(x, m_dialog->geometry().topLeft().y());
|
// //m_dialog->move(x, m_dialog->geometry().topLeft().y());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int DialogProxy::y() const
|
// int DialogProxy::y() const
|
||||||
{
|
// {
|
||||||
return geometry().topLeft().y();
|
// return geometry().topLeft().y();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void DialogProxy::setY(int y)
|
// void DialogProxy::setY(int y)
|
||||||
{
|
// {
|
||||||
//m_dialog->move(m_dialog->geometry().topLeft().x(), y);
|
// //m_dialog->move(m_dialog->geometry().topLeft().x(), y);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int DialogProxy::width() const
|
// int DialogProxy::width() const
|
||||||
{
|
// {
|
||||||
return size().width();
|
// return size().width();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
int DialogProxy::height() const
|
// int DialogProxy::height() const
|
||||||
{
|
// {
|
||||||
return size().height();
|
// return size().height();
|
||||||
}
|
// }
|
||||||
|
|
||||||
bool DialogProxy::isActiveWindow() const
|
bool DialogProxy::isActiveWindow() const
|
||||||
{
|
{
|
||||||
@ -353,16 +353,18 @@ QObject *DialogProxy::margins() const
|
|||||||
|
|
||||||
void DialogProxy::resizeEvent(QResizeEvent *re)
|
void DialogProxy::resizeEvent(QResizeEvent *re)
|
||||||
{
|
{
|
||||||
if (contentItem()) {
|
contentItem()->setX(0);
|
||||||
contentItem()->setWidth(re->size().width());
|
contentItem()->setY(0);
|
||||||
contentItem()->setHeight(re->size().height());
|
|
||||||
}
|
|
||||||
if (m_mainItem) {
|
if (m_mainItem) {
|
||||||
|
m_mainItem.data()->setX(0);
|
||||||
|
m_mainItem.data()->setY(0);
|
||||||
m_mainItem.data()->setWidth(re->size().width());
|
m_mainItem.data()->setWidth(re->size().width());
|
||||||
m_mainItem.data()->setHeight(re->size().height());
|
m_mainItem.data()->setHeight(re->size().height());
|
||||||
}
|
}
|
||||||
|
QQuickWindow::resizeEvent(re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
|
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if (watched == this && event->type() == QEvent::Move) {
|
if (watched == this && event->type() == QEvent::Move) {
|
||||||
@ -403,7 +405,7 @@ bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
|
|||||||
emit activeWindowChanged();
|
emit activeWindowChanged();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void DialogProxy::setAttribute(int attribute, bool on)
|
void DialogProxy::setAttribute(int attribute, bool on)
|
||||||
{
|
{
|
||||||
|
@ -108,23 +108,23 @@ class DialogProxy : public QQuickWindow
|
|||||||
/**
|
/**
|
||||||
* X position of the dialog window in screen coordinates.
|
* 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.
|
* 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
|
//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
|
* 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
|
* 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
|
* Window flags of the Dialog window
|
||||||
@ -168,14 +168,14 @@ public:
|
|||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
void setVisible(const bool visible);
|
void setVisible(const bool visible);
|
||||||
|
|
||||||
int x() const;
|
// int x() const;
|
||||||
void setX(int x);
|
// void setX(int x);
|
||||||
|
//
|
||||||
int y() const;
|
// int y() const;
|
||||||
void setY(int y);
|
// void setY(int y);
|
||||||
|
//
|
||||||
int width() const;
|
// int width() const;
|
||||||
int height() const;
|
// int height() const;
|
||||||
|
|
||||||
bool isActiveWindow() const;
|
bool isActiveWindow() const;
|
||||||
|
|
||||||
@ -218,16 +218,16 @@ public:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void mainItemChanged();
|
void mainItemChanged();
|
||||||
void visibleChanged();
|
void visibleChanged();
|
||||||
void xChanged();
|
// void xChanged();
|
||||||
void yChanged();
|
// void yChanged();
|
||||||
void widthChanged();
|
// void widthChanged();
|
||||||
void heightChanged();
|
// void heightChanged();
|
||||||
void activeWindowChanged();
|
void activeWindowChanged();
|
||||||
void locationChanged();
|
void locationChanged();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *watched, QEvent *event);
|
// bool eventFilter(QObject *watched, QEvent *event);
|
||||||
void resizeEvent(QResizeEvent *re);
|
void resizeEvent(QResizeEvent *re);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -565,6 +565,11 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o
|
|||||||
|
|
||||||
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
|
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
|
||||||
m_compactUiObject.data()->deleteLater();
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,10 @@ Item {
|
|||||||
property Item compactRepresentation
|
property Item compactRepresentation
|
||||||
|
|
||||||
|
|
||||||
onAppletChanged: applet.parent = appletParent
|
onAppletChanged: {
|
||||||
|
applet.parent = appletParent
|
||||||
|
applet.anchors.fill = applet.parent
|
||||||
|
}
|
||||||
onCompactRepresentationChanged: {
|
onCompactRepresentationChanged: {
|
||||||
compactRepresentation.parent = root
|
compactRepresentation.parent = root
|
||||||
compactRepresentation.anchors.fill = root
|
compactRepresentation.anchors.fill = root
|
||||||
@ -46,11 +49,12 @@ Item {
|
|||||||
plasmoid.expanded = false
|
plasmoid.expanded = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onWidthChanged: appletParent.width = width
|
//onWidthChanged: appletParent.width = width
|
||||||
onHeightChanged:appletParent.height = height
|
//onHeightChanged:appletParent.height = height
|
||||||
mainItem: appletParent
|
mainItem: appletParent
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: appletParent
|
id: appletParent
|
||||||
|
radius: 10
|
||||||
width: 200//applet.implicitWidth
|
width: 200//applet.implicitWidth
|
||||||
height: 200//applet.implicitHeight
|
height: 200//applet.implicitHeight
|
||||||
onWidthChanged: applet.width = width
|
onWidthChanged: applet.width = width
|
||||||
|
Loading…
x
Reference in New Issue
Block a user