diff --git a/src/declarativeimports/core/dialog.cpp b/src/declarativeimports/core/dialog.cpp index 7668bab57..fb11d7663 100644 --- a/src/declarativeimports/core/dialog.cpp +++ b/src/declarativeimports/core/dialog.cpp @@ -42,7 +42,7 @@ DialogProxy::DialogProxy(QQuickItem *parent) : QQuickWindow(), m_activeWindow(false), - m_location(Plasma::Floating) + m_location(Qt::AlignCenter) { QSurfaceFormat format; format.setAlphaBufferSize(8); @@ -212,6 +212,24 @@ QPoint DialogProxy::popupPosition(QQuickItem *item, Qt::AlignmentFlag alignment) int xOffset = 0; int yOffset = 0; + int _x = 0; + int _y = 0; + + if (location() == Qt::AlignBottom) { + _y = item->y() + item->height(); + } else if (location() == Qt::AlignTop) { + _y = item->y() - height(); + } else if ((location() & Qt::AlignCenter) || (location() & Qt::AlignVCenter)) { + // align our item's vertical center with our own vertical center + _y = (item->y() + item->height()/2) - height()/2; + } else { + + // Location is left or right + } + + + + if (alignment == Qt::AlignCenter) { xOffset = item->boundingRect().width()/2 - width()/2; yOffset = item->boundingRect().height()/2 - height()/2; @@ -262,17 +280,17 @@ void DialogProxy::setWindowFlags(const int flags) setFlags(Qt::FramelessWindowHint|m_flags); } -int DialogProxy::location() const +Qt::AlignmentFlag DialogProxy::location() const { - return (int)m_location; + return (Qt::AlignmentFlag)m_location; } -void DialogProxy::setLocation(int location) +void DialogProxy::setLocation(Qt::AlignmentFlag location) { if (m_location == location) { return; } - m_location = (Plasma::Location)location; + m_location = (Qt::AlignmentFlag)location; emit locationChanged(); } diff --git a/src/declarativeimports/core/dialog.h b/src/declarativeimports/core/dialog.h index 5f35a4035..cb621c86a 100644 --- a/src/declarativeimports/core/dialog.h +++ b/src/declarativeimports/core/dialog.h @@ -78,7 +78,7 @@ class DialogProxy : public QQuickWindow /** * Plasma Location of the dialog window. Useful if this dialog is apopup for a panel */ - Q_PROPERTY(int location READ location WRITE setLocation NOTIFY locationChanged) + Q_PROPERTY(Qt::AlignmentFlag location READ location WRITE setLocation NOTIFY locationChanged) //This won't be available on windows, but should be used only by kwin and never by applets anyways #ifndef Q_WS_WIN /** @@ -118,8 +118,8 @@ public: int windowFlags() const; void setWindowFlags(const int); - int location() const; - void setLocation(int location); + Qt::AlignmentFlag location() const; + void setLocation(Qt::AlignmentFlag location); QObject *margins() const; @@ -167,7 +167,7 @@ private: QWeakPointer m_mainItem; QWeakPointer m_visualParent; bool m_activeWindow; - Plasma::Location m_location; + Qt::AlignmentFlag m_location; Plasma::FrameSvgItem *m_frameSvgItem; };