Implement QWindow::close()
Implement the public slot QWindow::close() and add the correspondent test. Change-Id: If3f07cce3b26640f06fc52d0e4dca875d9894b3d Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
parent
43270da01a
commit
76a5ce8acb
@ -845,8 +845,28 @@ void QWindow::showNormal()
|
||||
|
||||
bool QWindow::close()
|
||||
{
|
||||
//should we have close?
|
||||
qDebug() << "unimplemented:" << __FILE__ << __LINE__;
|
||||
Q_D(QWindow);
|
||||
|
||||
// Do not close non top level windows
|
||||
if (parent())
|
||||
return false;
|
||||
|
||||
if (QGuiApplicationPrivate::focus_window == this)
|
||||
QGuiApplicationPrivate::focus_window = 0;
|
||||
|
||||
QObjectList childrenWindows = children();
|
||||
for (int i = 0; i < childrenWindows.size(); i++) {
|
||||
QObject *object = childrenWindows.at(i);
|
||||
if (object->isWindowType()) {
|
||||
QWindow *w = static_cast<QWindow*>(object);
|
||||
QGuiApplicationPrivate::window_list.removeAll(w);
|
||||
w->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
QGuiApplicationPrivate::window_list.removeAll(this);
|
||||
destroy();
|
||||
d->maybeQuitOnLastWindowClosed();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ private slots:
|
||||
void mouseToTouchTranslation();
|
||||
void mouseToTouchLoop();
|
||||
void orientation();
|
||||
void close();
|
||||
void initTestCase()
|
||||
{
|
||||
touchDevice = new QTouchDevice;
|
||||
@ -503,5 +504,20 @@ void tst_QWindow::orientation()
|
||||
QCOMPARE(spy.count(), 1);
|
||||
}
|
||||
|
||||
void tst_QWindow::close()
|
||||
{
|
||||
QWindow a;
|
||||
QWindow b;
|
||||
QWindow c(&a);
|
||||
|
||||
a.show();
|
||||
b.show();
|
||||
|
||||
// we can not close a non top level window
|
||||
QVERIFY(!c.close());
|
||||
QVERIFY(a.close());
|
||||
QVERIFY(b.close());
|
||||
}
|
||||
|
||||
#include <tst_qwindow.moc>
|
||||
QTEST_MAIN(tst_QWindow);
|
||||
|
Loading…
Reference in New Issue
Block a user