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()
|
bool QWindow::close()
|
||||||
{
|
{
|
||||||
//should we have close?
|
Q_D(QWindow);
|
||||||
qDebug() << "unimplemented:" << __FILE__ << __LINE__;
|
|
||||||
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ private slots:
|
|||||||
void mouseToTouchTranslation();
|
void mouseToTouchTranslation();
|
||||||
void mouseToTouchLoop();
|
void mouseToTouchLoop();
|
||||||
void orientation();
|
void orientation();
|
||||||
|
void close();
|
||||||
void initTestCase()
|
void initTestCase()
|
||||||
{
|
{
|
||||||
touchDevice = new QTouchDevice;
|
touchDevice = new QTouchDevice;
|
||||||
@ -503,5 +504,20 @@ void tst_QWindow::orientation()
|
|||||||
QCOMPARE(spy.count(), 1);
|
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>
|
#include <tst_qwindow.moc>
|
||||||
QTEST_MAIN(tst_QWindow);
|
QTEST_MAIN(tst_QWindow);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user