summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-05-23 13:46:18 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-05-23 13:46:18 +0200
commit1894da818656dd69a1309ecb7ce7ff816481ecfa (patch)
treebb58330182a9346f1e56e4a313ad665029861a17 /src/gui
parentc5d1f239426b4cf9b3ddc0f34fd1514504dfb985 (diff)
Added QWindow::setTransientParent().
Make the transient parent relationship explicit instead of having it encoded through the window flags.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qwindow.cpp23
-rw-r--r--src/gui/kernel/qwindow.h3
-rw-r--r--src/gui/kernel/qwindow_p.h2
3 files changed, 24 insertions, 4 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index b5bcc72d10..e53a205e88 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -105,7 +105,7 @@ void QWindow::create()
QObject *object = childObjects.at(i);
if(object->isWindowType()) {
QWindow *window = static_cast<QWindow *>(object);
- if (window->d_func()->platformWindow && !window->isTopLevel())
+ if (window->d_func()->platformWindow)
window->d_func()->platformWindow->setParent(d->platformWindow);
}
}
@@ -138,7 +138,7 @@ void QWindow::setParent(QWindow *parent)
QObject::setParent(parent);
if (d->platformWindow) {
- if (parent && parent->d_func()->platformWindow && !isTopLevel()) {
+ if (parent && parent->d_func()->platformWindow) {
d->platformWindow->setParent(parent->d_func()->platformWindow);
} else {
d->platformWindow->setParent(0);
@@ -149,12 +149,12 @@ void QWindow::setParent(QWindow *parent)
}
/*!
- Returns whether the window is top level.
+ Returns whether the window is top level, i.e. has no parent window.
*/
bool QWindow::isTopLevel() const
{
Q_D(const QWindow);
- return d->windowFlags & Qt::Window;
+ return d->parentWindow != 0;
}
bool QWindow::isModal() const
@@ -293,6 +293,21 @@ void QWindow::setWindowState(Qt::WindowState state)
d->windowState = state;
}
+/*!
+ Sets the transient parent, which is a hint to the window manager that this window is a dialog or pop-up on behalf of the given window.
+*/
+void QWindow::setTransientParent(QWindow *parent)
+{
+ Q_D(QWindow);
+ d->transientParent = parent;
+}
+
+QWindow *QWindow::transientParent() const
+{
+ Q_D(const QWindow);
+ return d->transientParent.data();
+}
+
QSize QWindow::minimumSize() const
{
Q_D(const QWindow);
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 998a48fb42..5b002a4791 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -119,6 +119,9 @@ public:
Qt::WindowState windowState() const;
void setWindowState(Qt::WindowState state);
+ void setTransientParent(QWindow *parent);
+ QWindow *transientParent() const;
+
QSize minimumSize() const;
QSize maximumSize() const;
QSize baseSize() const;
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index f52dd559f1..aca26089ce 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -68,6 +68,7 @@ public:
, surface(0)
, windowState(Qt::WindowNoState)
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
+ , transientParent(0)
{
isWindow = true;
}
@@ -94,6 +95,7 @@ public:
QSize sizeIncrement;
Qt::WindowModality modality;
+ QPointer<QWindow> transientParent;
};