author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 09:15:16 +0300 | |
branch | RCL_3 |
changeset 10 | 68d3b337861b |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
||
43 |
#include <QtTest/QtTest> |
|
44 |
||
45 |
||
46 |
#include <qdockwidget.h> |
|
47 |
#include <qlayout.h> |
|
48 |
#include <qmainwindow.h> |
|
49 |
#include <qmenubar.h> |
|
50 |
#include <qstatusbar.h> |
|
51 |
#include <qstyle.h> |
|
52 |
#include <qtoolbar.h> |
|
53 |
#include <qpushbutton.h> |
|
54 |
#include <qlabel.h> |
|
55 |
#include <qtextedit.h> |
|
56 |
#include <private/qmainwindowlayout_p.h> |
|
57 |
#include <private/qdockarealayout_p.h> |
|
58 |
||
59 |
//TESTED_FILES= |
|
60 |
||
61 |
static uchar restoreData41[] = { 0x0, 0x0, 0x0, 0xff, 0x0, 0x0, 0x0, 0x0, 0xfc, 0x0, 0x0, 0x0, 0x0, 0xfd, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x1, 0x19, 0xfc, 0x2, 0x0, 0x0, 0x0, 0x4, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x30, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x34, 0x1, 0x0, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xfb, 0x0, 0x0, 0x0, 0xc, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x38, 0x1, 0x0, 0x0, 0x0, 0x8d, 0x0, 0x0, 0x0, 0x43, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0x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e, 0x0, 0x64, 0x0, 0x6f, 0x0, 0x63, 0x0, 0x6b, 0x0, 0x20, 0x0, 0x31, 0x0, 0x35, 0x1, 0x0, 0x0, 0x1, 0x42, 0x0, 0x0, 0x0, 0x66, 0x0, 0x0, 0x0, 0x50, 0x0, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0xb8, 0x0, 0x0, 0x0, 0xa0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0xfc, 0x0, 0x0, 0x0, 0x0}; |
|
64 |
||
65 |
class tst_QMainWindow : public QObject |
|
66 |
{ |
|
67 |
Q_OBJECT |
|
68 |
||
69 |
public: |
|
70 |
tst_QMainWindow(); |
|
71 |
||
72 |
private slots: |
|
73 |
void getSetCheck(); |
|
74 |
void constructor(); |
|
75 |
void iconSize(); |
|
76 |
void setIconSize(); |
|
77 |
void toolButtonStyle(); |
|
78 |
void setToolButtonStyle(); |
|
79 |
void menuBar(); |
|
80 |
void setMenuBar(); |
|
81 |
void statusBar(); |
|
82 |
void setStatusBar(); |
|
83 |
void centralWidget(); |
|
84 |
void setCentralWidget(); |
|
85 |
void corner(); |
|
86 |
void setCorner(); |
|
87 |
void addToolBarBreak(); |
|
88 |
void insertToolBarBreak(); |
|
89 |
void addToolBar(); |
|
90 |
void insertToolBar(); |
|
91 |
void removeToolBar(); |
|
92 |
void toolBarArea(); |
|
93 |
void addDockWidget(); |
|
94 |
void splitDockWidget(); |
|
95 |
void removeDockWidget(); |
|
96 |
void dockWidgetArea(); |
|
97 |
void saveState(); |
|
98 |
void restoreState(); |
|
99 |
void restoreStateFromPreviousVersion(); |
|
100 |
void createPopupMenu(); |
|
101 |
void iconSizeChanged(); |
|
102 |
void toolButtonStyleChanged(); |
|
103 |
void hideBeforeLayout(); |
|
104 |
void saveRestore(); |
|
105 |
void saveRestore_data(); |
|
106 |
void isSeparator(); |
|
107 |
void setCursor(); |
|
108 |
void addToolbarAfterShow(); |
|
109 |
void centralWidgetSize(); |
|
110 |
void dockWidgetSize(); |
|
111 |
}; |
|
112 |
||
113 |
// Testing get/set functions |
|
114 |
void tst_QMainWindow::getSetCheck() |
|
115 |
{ |
|
116 |
QMainWindow obj1; |
|
117 |
// QMenuBar * QMainWindow::menuBar() |
|
118 |
// void QMainWindow::setMenuBar(QMenuBar *) |
|
119 |
QPointer<QMenuBar> var1 = new QMenuBar; |
|
120 |
obj1.setMenuBar(var1); |
|
121 |
QCOMPARE(static_cast<QMenuBar *>(var1), obj1.menuBar()); |
|
122 |
obj1.setMenuBar((QMenuBar *)0); |
|
123 |
QVERIFY(obj1.menuBar()); |
|
124 |
//we now call deleteLater on the previous menubar |
|
125 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
126 |
QVERIFY(!var1); |
|
127 |
// delete var1; // No delete, since QMainWindow takes ownership |
|
128 |
||
129 |
// QStatusBar * QMainWindow::statusBar() |
|
130 |
// void QMainWindow::setStatusBar(QStatusBar *) |
|
131 |
QPointer<QStatusBar> var2 = new QStatusBar; |
|
132 |
obj1.setStatusBar(var2); |
|
133 |
QCOMPARE(static_cast<QStatusBar *>(var2), obj1.statusBar()); |
|
134 |
obj1.setStatusBar((QStatusBar *)0); |
|
135 |
QVERIFY(obj1.statusBar()); |
|
136 |
//we now call deleteLater on the previous menubar |
|
137 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
138 |
QVERIFY(!var2); |
|
139 |
// delete var2; // No delete, since QMainWindow takes ownership |
|
140 |
||
141 |
// QWidget * QMainWindow::centralWidget() |
|
142 |
// void QMainWindow::setCentralWidget(QWidget *) |
|
143 |
QWidget *var3 = new QWidget; |
|
144 |
obj1.setCentralWidget(var3); |
|
145 |
QCOMPARE(var3, obj1.centralWidget()); |
|
146 |
obj1.setCentralWidget((QWidget *)0); |
|
147 |
QCOMPARE((QWidget *)0, obj1.centralWidget()); |
|
148 |
// delete var3; // No delete, since QMainWindow takes ownership |
|
149 |
} |
|
150 |
||
151 |
tst_QMainWindow::tst_QMainWindow() |
|
152 |
{ |
|
153 |
qRegisterMetaType<QSize>("QSize"); |
|
154 |
qRegisterMetaType<Qt::ToolButtonStyle>("Qt::ToolButtonStyle"); |
|
155 |
} |
|
156 |
||
157 |
void tst_QMainWindow::constructor() |
|
158 |
{ |
|
159 |
QMainWindow mw; |
|
160 |
QVERIFY(mw.parentWidget() == 0); |
|
161 |
QVERIFY(mw.isWindow()); |
|
162 |
||
163 |
QMainWindow mw2(&mw); |
|
164 |
QVERIFY(mw2.parentWidget() == &mw); |
|
165 |
QVERIFY(mw2.isWindow()); |
|
166 |
||
167 |
QMainWindow mw3(&mw, Qt::FramelessWindowHint); |
|
168 |
QVERIFY(mw3.parentWidget() == &mw); |
|
169 |
QVERIFY(mw3.isWindow()); |
|
170 |
} |
|
171 |
||
172 |
void tst_QMainWindow::iconSize() |
|
173 |
{ |
|
174 |
{ |
|
175 |
QMainWindow mw; |
|
176 |
QSignalSpy spy(&mw, SIGNAL(iconSizeChanged(QSize))); |
|
177 |
||
178 |
// the default is determined by the style |
|
179 |
const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize); |
|
180 |
const QSize defaultIconSize = QSize(metric, metric); |
|
181 |
const QSize smallIconSize = QSize(metric / 2, metric / 2); |
|
182 |
const QSize largeIconSize = QSize(metric * 2, metric * 2); |
|
183 |
||
184 |
// no-op |
|
185 |
QCOMPARE(mw.iconSize(), defaultIconSize); |
|
186 |
mw.setIconSize(defaultIconSize); |
|
187 |
QCOMPARE(mw.iconSize(), defaultIconSize); |
|
188 |
QCOMPARE(spy.size(), 0); |
|
189 |
||
190 |
mw.setIconSize(largeIconSize); |
|
191 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
192 |
QCOMPARE(spy.size(), 1); |
|
193 |
QCOMPARE(spy.first().first().toSize(), largeIconSize); |
|
194 |
spy.clear(); |
|
195 |
||
196 |
// no-op |
|
197 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
198 |
mw.setIconSize(largeIconSize); |
|
199 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
200 |
QCOMPARE(spy.size(), 0); |
|
201 |
||
202 |
mw.setIconSize(smallIconSize); |
|
203 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
204 |
QCOMPARE(spy.size(), 1); |
|
205 |
QCOMPARE(spy.first().first().toSize(), smallIconSize); |
|
206 |
spy.clear(); |
|
207 |
||
208 |
// no-op |
|
209 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
210 |
mw.setIconSize(smallIconSize); |
|
211 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
212 |
QCOMPARE(spy.size(), 0); |
|
213 |
||
214 |
// setting the icon size to an invalid QSize will reset the |
|
215 |
// iconSize property to the default |
|
216 |
mw.setIconSize(QSize()); |
|
217 |
QCOMPARE(mw.iconSize(), defaultIconSize); |
|
218 |
QCOMPARE(spy.size(), 1); |
|
219 |
QCOMPARE(spy.first().first().toSize(), defaultIconSize); |
|
220 |
spy.clear(); |
|
221 |
} |
|
222 |
||
223 |
{ |
|
224 |
// toolbars should follow the mainwindow's icon size |
|
225 |
QMainWindow mw; |
|
226 |
QToolBar tb; |
|
227 |
mw.addToolBar(&tb); |
|
228 |
||
229 |
QSignalSpy mwSpy(&mw, SIGNAL(iconSizeChanged(QSize))); |
|
230 |
QSignalSpy tbSpy(&tb, SIGNAL(iconSizeChanged(QSize))); |
|
231 |
||
232 |
// the default is determined by the style |
|
233 |
const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize); |
|
234 |
const QSize defaultIconSize = QSize(metric, metric); |
|
235 |
const QSize smallIconSize = QSize(metric / 2, metric / 2); |
|
236 |
const QSize largeIconSize = QSize(metric * 2, metric * 2); |
|
237 |
||
238 |
// no-op |
|
239 |
QCOMPARE(mw.iconSize(), defaultIconSize); |
|
240 |
mw.setIconSize(defaultIconSize); |
|
241 |
QCOMPARE(mw.iconSize(), defaultIconSize); |
|
242 |
QCOMPARE(tb.iconSize(), defaultIconSize); |
|
243 |
QCOMPARE(mwSpy.size(), 0); |
|
244 |
QCOMPARE(tbSpy.size(), 0); |
|
245 |
||
246 |
mw.setIconSize(largeIconSize); |
|
247 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
248 |
QCOMPARE(tb.iconSize(), largeIconSize); |
|
249 |
QCOMPARE(mwSpy.size(), 1); |
|
250 |
QCOMPARE(mwSpy.first().first().toSize(), largeIconSize); |
|
251 |
QCOMPARE(tbSpy.size(), 1); |
|
252 |
QCOMPARE(tbSpy.first().first().toSize(), largeIconSize); |
|
253 |
mwSpy.clear(); |
|
254 |
tbSpy.clear(); |
|
255 |
||
256 |
// no-op |
|
257 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
258 |
mw.setIconSize(largeIconSize); |
|
259 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
260 |
QCOMPARE(tb.iconSize(), largeIconSize); |
|
261 |
QCOMPARE(mwSpy.size(), 0); |
|
262 |
QCOMPARE(tbSpy.size(), 0); |
|
263 |
||
264 |
mw.setIconSize(smallIconSize); |
|
265 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
266 |
QCOMPARE(tb.iconSize(), smallIconSize); |
|
267 |
QCOMPARE(mwSpy.size(), 1); |
|
268 |
QCOMPARE(mwSpy.first().first().toSize(), smallIconSize); |
|
269 |
QCOMPARE(tbSpy.size(), 1); |
|
270 |
QCOMPARE(tbSpy.first().first().toSize(), smallIconSize); |
|
271 |
mwSpy.clear(); |
|
272 |
tbSpy.clear(); |
|
273 |
||
274 |
// no-op |
|
275 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
276 |
mw.setIconSize(smallIconSize); |
|
277 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
278 |
QCOMPARE(tb.iconSize(), smallIconSize); |
|
279 |
QCOMPARE(mwSpy.size(), 0); |
|
280 |
QCOMPARE(tbSpy.size(), 0); |
|
281 |
||
282 |
// setting the icon size to an invalid QSize will reset the |
|
283 |
// iconSize property to the default |
|
284 |
mw.setIconSize(QSize()); |
|
285 |
QCOMPARE(mw.iconSize(), defaultIconSize); |
|
286 |
QCOMPARE(tb.iconSize(), defaultIconSize); |
|
287 |
QCOMPARE(mwSpy.size(), 1); |
|
288 |
QCOMPARE(mwSpy.first().first().toSize(), defaultIconSize); |
|
289 |
QCOMPARE(tbSpy.size(), 1); |
|
290 |
QCOMPARE(tbSpy.first().first().toSize(), defaultIconSize); |
|
291 |
mwSpy.clear(); |
|
292 |
tbSpy.clear(); |
|
293 |
} |
|
294 |
||
295 |
{ |
|
296 |
QMainWindow mw; |
|
297 |
QSignalSpy mwSpy(&mw, SIGNAL(iconSizeChanged(QSize))); |
|
298 |
||
299 |
// the default is determined by the style |
|
300 |
const int metric = mw.style()->pixelMetric(QStyle::PM_ToolBarIconSize); |
|
301 |
const QSize defaultIconSize = QSize(metric, metric); |
|
302 |
const QSize smallIconSize = QSize(metric / 2, metric / 2); |
|
303 |
const QSize largeIconSize = QSize(metric * 2, metric * 2); |
|
304 |
||
305 |
mw.setIconSize(smallIconSize); |
|
306 |
QCOMPARE(mw.iconSize(), smallIconSize); |
|
307 |
QCOMPARE(mwSpy.size(), 1); |
|
308 |
QCOMPARE(mwSpy.first().first().toSize(), smallIconSize); |
|
309 |
mwSpy.clear(); |
|
310 |
||
311 |
QToolBar tb; |
|
312 |
QSignalSpy tbSpy(&tb, SIGNAL(iconSizeChanged(QSize))); |
|
313 |
||
314 |
mw.addToolBar(&tb); |
|
315 |
||
316 |
// newly added toolbars should also automatically pick up any |
|
317 |
// size set on the main window |
|
318 |
QCOMPARE(tb.iconSize(), smallIconSize); |
|
319 |
QCOMPARE(tbSpy.size(), 1); |
|
320 |
QCOMPARE(tbSpy.first().first().toSize(), smallIconSize); |
|
321 |
tbSpy.clear(); |
|
322 |
||
323 |
mw.removeToolBar(&tb); |
|
324 |
||
325 |
// removed toolbars should keep their existing size and ignore |
|
326 |
// mainwindow icon size changes |
|
327 |
mw.setIconSize(largeIconSize); |
|
328 |
QCOMPARE(mw.iconSize(), largeIconSize); |
|
329 |
QCOMPARE(tb.iconSize(), smallIconSize); |
|
330 |
QCOMPARE(mwSpy.size(), 1); |
|
331 |
QCOMPARE(mwSpy.first().first().toSize(), largeIconSize); |
|
332 |
QCOMPARE(tbSpy.size(), 0); |
|
333 |
mwSpy.clear(); |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
void tst_QMainWindow::setIconSize() |
|
338 |
{ DEPENDS_ON("iconSize()"); |
|
339 |
} |
|
340 |
||
341 |
void tst_QMainWindow::toolButtonStyle() |
|
342 |
{ |
|
343 |
{ |
|
344 |
QMainWindow mw; |
|
345 |
||
346 |
QSignalSpy spy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle))); |
|
347 |
||
348 |
// no-op |
|
349 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
350 |
mw.setToolButtonStyle(Qt::ToolButtonIconOnly); |
|
351 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
352 |
QCOMPARE(spy.size(), 0); |
|
353 |
||
354 |
mw.setToolButtonStyle(Qt::ToolButtonTextOnly); |
|
355 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly); |
|
356 |
QCOMPARE(spy.size(), 1); |
|
357 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()), |
|
358 |
Qt::ToolButtonTextOnly); |
|
359 |
spy.clear(); |
|
360 |
||
361 |
// no-op |
|
362 |
mw.setToolButtonStyle(Qt::ToolButtonTextOnly); |
|
363 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly); |
|
364 |
QCOMPARE(spy.size(), 0); |
|
365 |
||
366 |
mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
|
367 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
368 |
QCOMPARE(spy.size(), 1); |
|
369 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()), |
|
370 |
Qt::ToolButtonTextBesideIcon); |
|
371 |
spy.clear(); |
|
372 |
||
373 |
// no-op |
|
374 |
mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
|
375 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
376 |
QCOMPARE(spy.size(), 0); |
|
377 |
||
378 |
mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
|
379 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
380 |
QCOMPARE(spy.size(), 1); |
|
381 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()), |
|
382 |
Qt::ToolButtonTextUnderIcon); |
|
383 |
spy.clear(); |
|
384 |
||
385 |
// no-op |
|
386 |
mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
|
387 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
388 |
QCOMPARE(spy.size(), 0); |
|
389 |
||
390 |
mw.setToolButtonStyle(Qt::ToolButtonIconOnly); |
|
391 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
392 |
QCOMPARE(spy.size(), 1); |
|
393 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(spy.first().first().constData()), |
|
394 |
Qt::ToolButtonIconOnly); |
|
395 |
spy.clear(); |
|
396 |
||
397 |
// no-op |
|
398 |
mw.setToolButtonStyle(Qt::ToolButtonIconOnly); |
|
399 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
400 |
QCOMPARE(spy.size(), 0); |
|
401 |
} |
|
402 |
||
403 |
{ |
|
404 |
// toolbars should follow the mainwindow's tool button style |
|
405 |
QMainWindow mw; |
|
406 |
QToolBar tb; |
|
407 |
mw.addToolBar(&tb); |
|
408 |
||
409 |
QSignalSpy mwSpy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle))); |
|
410 |
QSignalSpy tbSpy(&tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle))); |
|
411 |
||
412 |
// no-op |
|
413 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
414 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
415 |
mw.setToolButtonStyle(Qt::ToolButtonIconOnly); |
|
416 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
417 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
418 |
QCOMPARE(mwSpy.size(), 0); |
|
419 |
QCOMPARE(tbSpy.size(), 0); |
|
420 |
||
421 |
mw.setToolButtonStyle(Qt::ToolButtonTextOnly); |
|
422 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly); |
|
423 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly); |
|
424 |
QCOMPARE(mwSpy.size(), 1); |
|
425 |
QCOMPARE(tbSpy.size(), 1); |
|
426 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()), |
|
427 |
Qt::ToolButtonTextOnly); |
|
428 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()), |
|
429 |
Qt::ToolButtonTextOnly); |
|
430 |
mwSpy.clear(); |
|
431 |
tbSpy.clear(); |
|
432 |
||
433 |
// no-op |
|
434 |
mw.setToolButtonStyle(Qt::ToolButtonTextOnly); |
|
435 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextOnly); |
|
436 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextOnly); |
|
437 |
QCOMPARE(mwSpy.size(), 0); |
|
438 |
QCOMPARE(tbSpy.size(), 0); |
|
439 |
||
440 |
mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
|
441 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
442 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
443 |
QCOMPARE(mwSpy.size(), 1); |
|
444 |
QCOMPARE(tbSpy.size(), 1); |
|
445 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()), |
|
446 |
Qt::ToolButtonTextBesideIcon); |
|
447 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()), |
|
448 |
Qt::ToolButtonTextBesideIcon); |
|
449 |
mwSpy.clear(); |
|
450 |
tbSpy.clear(); |
|
451 |
||
452 |
// no-op |
|
453 |
mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
|
454 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
455 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
456 |
QCOMPARE(mwSpy.size(), 0); |
|
457 |
QCOMPARE(tbSpy.size(), 0); |
|
458 |
||
459 |
mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
|
460 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
461 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
462 |
QCOMPARE(mwSpy.size(), 1); |
|
463 |
QCOMPARE(tbSpy.size(), 1); |
|
464 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()), |
|
465 |
Qt::ToolButtonTextUnderIcon); |
|
466 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()), |
|
467 |
Qt::ToolButtonTextUnderIcon); |
|
468 |
mwSpy.clear(); |
|
469 |
tbSpy.clear(); |
|
470 |
||
471 |
// no-op |
|
472 |
mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
|
473 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
474 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
475 |
QCOMPARE(mwSpy.size(), 0); |
|
476 |
QCOMPARE(tbSpy.size(), 0); |
|
477 |
||
478 |
mw.setToolButtonStyle(Qt::ToolButtonIconOnly); |
|
479 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
480 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
481 |
QCOMPARE(mwSpy.size(), 1); |
|
482 |
QCOMPARE(tbSpy.size(), 1); |
|
483 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()), |
|
484 |
Qt::ToolButtonIconOnly); |
|
485 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()), |
|
486 |
Qt::ToolButtonIconOnly); |
|
487 |
mwSpy.clear(); |
|
488 |
tbSpy.clear(); |
|
489 |
||
490 |
// no-op |
|
491 |
mw.setToolButtonStyle(Qt::ToolButtonIconOnly); |
|
492 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
493 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonIconOnly); |
|
494 |
QCOMPARE(mwSpy.size(), 0); |
|
495 |
QCOMPARE(tbSpy.size(), 0); |
|
496 |
} |
|
497 |
||
498 |
{ |
|
499 |
QMainWindow mw; |
|
500 |
QSignalSpy mwSpy(&mw, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle))); |
|
501 |
||
502 |
mw.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); |
|
503 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
504 |
QCOMPARE(mwSpy.size(), 1); |
|
505 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()), |
|
506 |
Qt::ToolButtonTextBesideIcon); |
|
507 |
mwSpy.clear(); |
|
508 |
||
509 |
QToolBar tb; |
|
510 |
QSignalSpy tbSpy(&tb, SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle))); |
|
511 |
||
512 |
mw.addToolBar(&tb); |
|
513 |
||
514 |
// newly added toolbars should also automatically pick up any |
|
515 |
// size set on the main window |
|
516 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
517 |
QCOMPARE(tbSpy.size(), 1); |
|
518 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(tbSpy.first().first().constData()), |
|
519 |
Qt::ToolButtonTextBesideIcon); |
|
520 |
tbSpy.clear(); |
|
521 |
||
522 |
mw.removeToolBar(&tb); |
|
523 |
||
524 |
// removed toolbars should keep their existing size and ignore |
|
525 |
// mainwindow icon size changes |
|
526 |
mw.setToolButtonStyle(Qt::ToolButtonTextUnderIcon); |
|
527 |
QCOMPARE(mw.toolButtonStyle(), Qt::ToolButtonTextUnderIcon); |
|
528 |
QCOMPARE(tb.toolButtonStyle(), Qt::ToolButtonTextBesideIcon); |
|
529 |
QCOMPARE(mwSpy.size(), 1); |
|
530 |
QCOMPARE(*static_cast<const Qt::ToolButtonStyle *>(mwSpy.first().first().constData()), |
|
531 |
Qt::ToolButtonTextUnderIcon); |
|
532 |
QCOMPARE(tbSpy.size(), 0); |
|
533 |
mwSpy.clear(); |
|
534 |
} |
|
535 |
} |
|
536 |
||
537 |
void tst_QMainWindow::setToolButtonStyle() |
|
538 |
{ DEPENDS_ON("toolButtonStyle()"); } |
|
539 |
||
540 |
void tst_QMainWindow::menuBar() |
|
541 |
{ |
|
542 |
{ |
|
543 |
QMainWindow mw; |
|
544 |
QVERIFY(mw.menuBar() != 0); |
|
545 |
} |
|
546 |
||
547 |
{ |
|
548 |
QMainWindow mw; |
|
549 |
QPointer<QMenuBar> mb1 = new QMenuBar; |
|
550 |
QPointer<QMenuBar> mb2 = new QMenuBar; |
|
551 |
||
552 |
mw.setMenuBar(mb1); |
|
553 |
QVERIFY(mw.menuBar() != 0); |
|
554 |
QCOMPARE(mw.menuBar(), (QMenuBar *)mb1); |
|
555 |
#ifdef Q_WS_WINCE_WM |
|
556 |
QSKIP("With native menubar integration the menubar is not a child", SkipSingle); |
|
557 |
#endif |
|
558 |
QCOMPARE(mb1->parentWidget(), (QWidget *)&mw); |
|
559 |
||
560 |
mw.setMenuBar(0); |
|
561 |
QVERIFY(mw.menuBar() != 0); |
|
562 |
//we now call deleteLater on the previous menubar |
|
563 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
564 |
QVERIFY(mb1 == 0); |
|
565 |
||
566 |
mw.setMenuBar(mb2); |
|
567 |
QVERIFY(mw.menuBar() != 0); |
|
568 |
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2); |
|
569 |
QCOMPARE(mb2->parentWidget(), (QWidget *)&mw); |
|
570 |
||
571 |
mw.setMenuBar(0); |
|
572 |
QVERIFY(mw.menuBar() != 0); |
|
573 |
//we now call deleteLater on the previous menubar |
|
574 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
575 |
QVERIFY(mb2 == 0); |
|
576 |
||
577 |
mb1 = new QMenuBar; |
|
578 |
mw.setMenuBar(mb1); |
|
579 |
QVERIFY(mw.menuBar() != 0); |
|
580 |
QCOMPARE(mw.menuBar(), (QMenuBar *)mb1); |
|
581 |
||
582 |
mb2 = new QMenuBar; |
|
583 |
mw.setMenuBar(mb2); |
|
584 |
QVERIFY(mw.menuBar() != 0); |
|
585 |
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2); |
|
586 |
//we now call deleteLater on the previous menubar |
|
587 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
588 |
QVERIFY(mb1 == 0); |
|
589 |
||
590 |
mb1 = new QMenuBar; |
|
591 |
mw.setMenuBar(mb1); |
|
592 |
QVERIFY(mw.menuBar() != 0); |
|
593 |
QCOMPARE(mw.menuBar(), (QMenuBar *)mb1); |
|
594 |
//we now call deleteLater on the previous menubar |
|
595 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
596 |
QVERIFY(mb2 == 0); |
|
597 |
||
598 |
QPointer<QWidget> topLeftCornerWidget = new QWidget; |
|
599 |
mb1->setCornerWidget(topLeftCornerWidget, Qt::TopLeftCorner); |
|
600 |
QPointer<QWidget> topRightCornerWidget = new QWidget; |
|
601 |
mb1->setCornerWidget(topRightCornerWidget, Qt::TopRightCorner); |
|
602 |
||
603 |
mb2 = new QMenuBar; |
|
604 |
mw.setMenuBar(mb2); |
|
605 |
QVERIFY(mw.menuBar() != 0); |
|
606 |
QCOMPARE(mw.menuBar(), (QMenuBar *)mb2); |
|
607 |
//we now call deleteLater on the previous menubar |
|
608 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
609 |
QVERIFY(mb1 == 0); |
|
610 |
||
611 |
QVERIFY(topLeftCornerWidget); |
|
612 |
QCOMPARE(mb2->cornerWidget(Qt::TopLeftCorner), static_cast<QWidget *>(topLeftCornerWidget)); |
|
613 |
QVERIFY(topRightCornerWidget); |
|
614 |
QCOMPARE(mb2->cornerWidget(Qt::TopRightCorner), static_cast<QWidget *>(topRightCornerWidget)); |
|
615 |
||
616 |
mw.setMenuBar(0); |
|
617 |
QVERIFY(mw.menuBar() != 0); |
|
618 |
//we now call deleteLater on the previous menubar |
|
619 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
620 |
QVERIFY(mb2 == 0); |
|
621 |
||
622 |
QVERIFY(!topLeftCornerWidget); |
|
623 |
QVERIFY(!topRightCornerWidget); |
|
624 |
} |
|
625 |
} |
|
626 |
||
627 |
void tst_QMainWindow::setMenuBar() |
|
628 |
{ DEPENDS_ON("menuBar()"); } |
|
629 |
||
630 |
void tst_QMainWindow::statusBar() |
|
631 |
{ |
|
632 |
{ |
|
633 |
QMainWindow mw; |
|
634 |
QVERIFY(mw.statusBar() != 0); |
|
635 |
} |
|
636 |
||
637 |
{ |
|
638 |
QMainWindow mw; |
|
639 |
QPointer<QStatusBar> sb1 = new QStatusBar; |
|
640 |
QPointer<QStatusBar> sb2 = new QStatusBar; |
|
641 |
||
642 |
mw.setStatusBar(sb1); |
|
643 |
QVERIFY(mw.statusBar() != 0); |
|
644 |
QCOMPARE(mw.statusBar(), (QStatusBar *)sb1); |
|
645 |
QCOMPARE(sb1->parentWidget(), (QWidget *)&mw); |
|
646 |
||
647 |
mw.setStatusBar(0); |
|
648 |
QVERIFY(mw.statusBar() != 0); |
|
649 |
//we now call deleteLater on the previous statusbar |
|
650 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
651 |
QVERIFY(sb1 == 0); |
|
652 |
||
653 |
mw.setStatusBar(sb2); |
|
654 |
QVERIFY(mw.statusBar() != 0); |
|
655 |
QCOMPARE(mw.statusBar(), (QStatusBar *)sb2); |
|
656 |
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw); |
|
657 |
||
658 |
mw.setStatusBar(0); |
|
659 |
QVERIFY(mw.statusBar() != 0); |
|
660 |
//we now call deleteLater on the previous statusbar |
|
661 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
662 |
QVERIFY(sb2 == 0); |
|
663 |
||
664 |
sb1 = new QStatusBar; |
|
665 |
mw.setStatusBar(sb1); |
|
666 |
QVERIFY(mw.statusBar() != 0); |
|
667 |
QCOMPARE(mw.statusBar(), (QStatusBar *)sb1); |
|
668 |
QCOMPARE(sb1->parentWidget(), (QWidget *)&mw); |
|
669 |
||
670 |
sb2 = new QStatusBar; |
|
671 |
mw.setStatusBar(sb2); |
|
672 |
QVERIFY(mw.statusBar() != 0); |
|
673 |
QCOMPARE(mw.statusBar(), (QStatusBar *)sb2); |
|
674 |
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw); |
|
675 |
//we now call deleteLater on the previous statusbar |
|
676 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
677 |
QVERIFY(sb1 == 0); |
|
678 |
||
679 |
sb1 = new QStatusBar; |
|
680 |
mw.setStatusBar(sb1); |
|
681 |
QVERIFY(mw.statusBar() != 0); |
|
682 |
QCOMPARE(mw.statusBar(), (QStatusBar *)sb1); |
|
683 |
QCOMPARE(sb1->parentWidget(), (QWidget *)&mw); |
|
684 |
//we now call deleteLater on the previous statusbar |
|
685 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
686 |
QVERIFY(sb2 == 0); |
|
687 |
||
688 |
sb2 = new QStatusBar; |
|
689 |
mw.setStatusBar(sb2); |
|
690 |
QVERIFY(mw.statusBar() != 0); |
|
691 |
QCOMPARE(mw.statusBar(), (QStatusBar *)sb2); |
|
692 |
QCOMPARE(sb2->parentWidget(), (QWidget *)&mw); |
|
693 |
//we now call deleteLater on the previous statusbar |
|
694 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
695 |
QVERIFY(sb1 == 0); |
|
696 |
} |
|
697 |
||
698 |
{ |
|
699 |
// deleting the status bar should remove it from the main window |
|
700 |
QMainWindow mw; |
|
701 |
QStatusBar *sb = mw.statusBar(); |
|
702 |
int indexOfSb = mw.layout()->indexOf(sb); |
|
703 |
QVERIFY(indexOfSb != -1); |
|
704 |
delete sb; |
|
705 |
indexOfSb = mw.layout()->indexOf(sb); |
|
706 |
QVERIFY(indexOfSb == -1); |
|
707 |
} |
|
708 |
} |
|
709 |
||
710 |
void tst_QMainWindow::setStatusBar() |
|
711 |
{ DEPENDS_ON("statusBar()"); } |
|
712 |
||
713 |
void tst_QMainWindow::centralWidget() |
|
714 |
{ |
|
715 |
{ |
|
716 |
QMainWindow mw; |
|
717 |
QVERIFY(mw.centralWidget() == 0); |
|
718 |
} |
|
719 |
||
720 |
{ |
|
721 |
QMainWindow mw; |
|
722 |
QPointer<QWidget> w1 = new QWidget; |
|
723 |
QPointer<QWidget> w2 = new QWidget; |
|
724 |
||
725 |
QVERIFY(mw.centralWidget() == 0); |
|
726 |
||
727 |
mw.setCentralWidget(w1); |
|
728 |
QVERIFY(mw.centralWidget() != 0); |
|
729 |
QCOMPARE(mw.centralWidget(), (QWidget *)w1); |
|
730 |
QCOMPARE(w1->parentWidget(), (QWidget *)&mw); |
|
731 |
||
732 |
mw.setCentralWidget(w2); |
|
733 |
QVERIFY(mw.centralWidget() != 0); |
|
734 |
QCOMPARE(mw.centralWidget(), (QWidget *)w2); |
|
735 |
QCOMPARE(w2->parentWidget(), (QWidget *)&mw); |
|
736 |
||
737 |
mw.setCentralWidget(0); |
|
738 |
QVERIFY(mw.centralWidget() == 0); |
|
739 |
||
740 |
//we now call deleteLater on the previous central widgets |
|
741 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
742 |
QVERIFY(w1 == 0); |
|
743 |
QVERIFY(w2 == 0); |
|
744 |
} |
|
745 |
||
746 |
{ |
|
747 |
// do it again, this time with the mainwindow shown, since |
|
748 |
// this tends will activate the layout when setting the new |
|
749 |
// central widget |
|
750 |
||
751 |
QMainWindow mw; |
|
752 |
mw.show(); |
|
753 |
||
754 |
QPointer<QWidget> w1 = new QWidget; |
|
755 |
QPointer<QWidget> w2 = new QWidget; |
|
756 |
||
757 |
QVERIFY(mw.centralWidget() == 0); |
|
758 |
||
759 |
mw.setCentralWidget(w1); |
|
760 |
QVERIFY(mw.centralWidget() != 0); |
|
761 |
QCOMPARE(mw.centralWidget(), (QWidget *)w1); |
|
762 |
QCOMPARE(w1->parentWidget(), (QWidget *)&mw); |
|
763 |
||
764 |
mw.setCentralWidget(w2); |
|
765 |
QVERIFY(mw.centralWidget() != 0); |
|
766 |
QCOMPARE(mw.centralWidget(), (QWidget *)w2); |
|
767 |
QCOMPARE(w2->parentWidget(), (QWidget *)&mw); |
|
768 |
||
769 |
mw.setCentralWidget(0); |
|
770 |
QVERIFY(mw.centralWidget() == 0); |
|
771 |
||
772 |
//we now call deleteLater on the previous central widgets |
|
773 |
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); |
|
774 |
QVERIFY(w1 == 0); |
|
775 |
QVERIFY(w2 == 0); |
|
776 |
} |
|
777 |
} |
|
778 |
||
779 |
void tst_QMainWindow::setCentralWidget() |
|
780 |
{ DEPENDS_ON("centralwidget()"); } |
|
781 |
||
782 |
void tst_QMainWindow::corner() |
|
783 |
{ |
|
784 |
{ |
|
785 |
QMainWindow mw; |
|
786 |
||
787 |
QCOMPARE(mw.corner(Qt::TopLeftCorner), Qt::TopDockWidgetArea); |
|
788 |
QCOMPARE(mw.corner(Qt::TopRightCorner), Qt::TopDockWidgetArea); |
|
789 |
QCOMPARE(mw.corner(Qt::BottomLeftCorner), Qt::BottomDockWidgetArea); |
|
790 |
QCOMPARE(mw.corner(Qt::BottomRightCorner), Qt::BottomDockWidgetArea); |
|
791 |
} |
|
792 |
||
793 |
{ |
|
794 |
QMainWindow mw; |
|
795 |
||
796 |
mw.setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); |
|
797 |
QCOMPARE(mw.corner(Qt::TopLeftCorner), Qt::LeftDockWidgetArea); |
|
798 |
mw.setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea); |
|
799 |
QCOMPARE(mw.corner(Qt::TopLeftCorner), Qt::TopDockWidgetArea); |
|
800 |
||
801 |
mw.setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); |
|
802 |
QCOMPARE(mw.corner(Qt::TopRightCorner), Qt::RightDockWidgetArea); |
|
803 |
mw.setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea); |
|
804 |
QCOMPARE(mw.corner(Qt::TopRightCorner), Qt::TopDockWidgetArea); |
|
805 |
||
806 |
mw.setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); |
|
807 |
QCOMPARE(mw.corner(Qt::BottomLeftCorner), Qt::LeftDockWidgetArea); |
|
808 |
mw.setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea); |
|
809 |
QCOMPARE(mw.corner(Qt::BottomLeftCorner), Qt::BottomDockWidgetArea); |
|
810 |
||
811 |
mw.setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); |
|
812 |
QCOMPARE(mw.corner(Qt::BottomRightCorner), Qt::RightDockWidgetArea); |
|
813 |
mw.setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); |
|
814 |
QCOMPARE(mw.corner(Qt::BottomRightCorner), Qt::BottomDockWidgetArea); |
|
815 |
} |
|
816 |
} |
|
817 |
||
818 |
void tst_QMainWindow::setCorner() |
|
819 |
{ DEPENDS_ON("corner()"); } |
|
820 |
||
821 |
void tst_QMainWindow::addToolBarBreak() |
|
822 |
{ |
|
823 |
{ |
|
824 |
QMainWindow mw; |
|
825 |
QToolBar tb1(&mw); |
|
826 |
mw.addToolBar(Qt::TopToolBarArea, &tb1); |
|
827 |
mw.addToolBarBreak(Qt::TopToolBarArea); |
|
828 |
QToolBar tb2(&mw); |
|
829 |
mw.addToolBar(Qt::TopToolBarArea, &tb2); |
|
830 |
mw.addToolBarBreak(Qt::TopToolBarArea); |
|
831 |
QToolBar tb3(&mw); |
|
832 |
mw.addToolBar(Qt::TopToolBarArea, &tb3); |
|
833 |
mw.addToolBarBreak(Qt::TopToolBarArea); |
|
834 |
QToolBar tb4(&mw); |
|
835 |
mw.addToolBar(Qt::TopToolBarArea, &tb4); |
|
836 |
||
837 |
mw.layout()->invalidate(); |
|
838 |
mw.layout()->activate(); |
|
839 |
||
840 |
QCOMPARE(tb1.x(), 0); |
|
841 |
QCOMPARE(tb1.y(), 0); |
|
842 |
QCOMPARE(tb2.x(), 0); |
|
843 |
QVERIFY(tb1.y() != tb2.y()); |
|
844 |
QCOMPARE(tb3.x(), 0); |
|
845 |
QVERIFY(tb2.y() != tb3.y()); |
|
846 |
QCOMPARE(tb4.x(), 0); |
|
847 |
QVERIFY(tb3.y() != tb4.y()); |
|
848 |
} |
|
849 |
||
850 |
{ |
|
851 |
QMainWindow mw; |
|
852 |
// should not crash, should get a warning instead |
|
853 |
QTest::ignoreMessage(QtWarningMsg, "QMainWindow::addToolBarBreak: invalid 'area' argument"); |
|
854 |
mw.addToolBarBreak(Qt::NoToolBarArea); |
|
855 |
} |
|
856 |
} |
|
857 |
||
858 |
void tst_QMainWindow::insertToolBarBreak() |
|
859 |
{ |
|
860 |
QMainWindow mw; |
|
861 |
QToolBar tb1(&mw); |
|
862 |
mw.addToolBar(Qt::TopToolBarArea, &tb1); |
|
863 |
QToolBar tb2(&mw); |
|
864 |
mw.addToolBar(Qt::TopToolBarArea, &tb2); |
|
865 |
QToolBar tb3(&mw); |
|
866 |
mw.addToolBar(Qt::TopToolBarArea, &tb3); |
|
867 |
QToolBar tb4(&mw); |
|
868 |
mw.addToolBar(Qt::TopToolBarArea, &tb4); |
|
869 |
||
870 |
mw.insertToolBarBreak(&tb2); |
|
871 |
mw.insertToolBarBreak(&tb3); |
|
872 |
mw.insertToolBarBreak(&tb4); |
|
873 |
||
874 |
mw.layout()->invalidate(); |
|
875 |
mw.layout()->activate(); |
|
876 |
||
877 |
QCOMPARE(tb1.x(), 0); |
|
878 |
QCOMPARE(tb1.y(), 0); |
|
879 |
QCOMPARE(tb2.x(), 0); |
|
880 |
QVERIFY(tb1.y() != tb2.y()); |
|
881 |
QCOMPARE(tb3.x(), 0); |
|
882 |
QVERIFY(tb2.y() != tb3.y()); |
|
883 |
QCOMPARE(tb4.x(), 0); |
|
884 |
QVERIFY(tb3.y() != tb4.y()); |
|
885 |
||
886 |
QVERIFY(!mw.toolBarBreak(&tb1)); |
|
887 |
QVERIFY(mw.toolBarBreak(&tb4)); |
|
888 |
mw.removeToolBarBreak(&tb4); |
|
889 |
QVERIFY(!mw.toolBarBreak(&tb4)); |
|
890 |
||
891 |
} |
|
892 |
||
893 |
static bool findWidgetRecursively(QLayoutItem *li, QWidget *w) |
|
894 |
{ |
|
895 |
QLayout *lay = li->layout(); |
|
896 |
if (!lay) |
|
897 |
return false; |
|
898 |
int i = 0; |
|
899 |
QLayoutItem *child; |
|
900 |
while ((child = lay->itemAt(i))) { |
|
901 |
if (child->widget() == w) { |
|
902 |
return true; |
|
903 |
} else if (findWidgetRecursively(child, w)) { |
|
904 |
return true; |
|
905 |
} else { |
|
906 |
++i; |
|
907 |
} |
|
908 |
} |
|
909 |
return false; |
|
910 |
} |
|
911 |
||
912 |
void tst_QMainWindow::addToolBar() |
|
913 |
{ |
|
914 |
Qt::ToolBarArea areas[] = { |
|
915 |
Qt::LeftToolBarArea, |
|
916 |
Qt::RightToolBarArea, |
|
917 |
Qt::TopToolBarArea, |
|
918 |
Qt::BottomToolBarArea |
|
919 |
}; |
|
920 |
const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea); |
|
921 |
||
922 |
for (int i = 0; i < areaCount; ++i) { |
|
923 |
Qt::ToolBarArea area = areas[i]; |
|
924 |
||
925 |
QMainWindow mw; |
|
926 |
QToolBar tb(&mw); |
|
927 |
QVERIFY(!findWidgetRecursively(mw.layout(), &tb)); |
|
928 |
mw.addToolBar(area, &tb); |
|
929 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb)); |
|
930 |
} |
|
931 |
||
932 |
{ |
|
933 |
// addToolBar() with no area, equivalent to top |
|
934 |
QMainWindow mw; |
|
935 |
QToolBar tb(&mw); |
|
936 |
QVERIFY(!findWidgetRecursively(mw.layout(), &tb)); |
|
937 |
mw.addToolBar(&tb); |
|
938 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb)); |
|
939 |
} |
|
940 |
||
941 |
{ |
|
942 |
QMainWindow mw; |
|
943 |
QToolBar tb(&mw); |
|
944 |
// should not crash, should get a warning instead |
|
945 |
QTest::ignoreMessage(QtWarningMsg, "QMainWindow::addToolBar: invalid 'area' argument"); |
|
946 |
mw.addToolBar(Qt::NoToolBarArea, &tb); |
|
947 |
} |
|
948 |
} |
|
949 |
||
950 |
void tst_QMainWindow::insertToolBar() |
|
951 |
{ |
|
952 |
Qt::ToolBarArea areas[] = { |
|
953 |
Qt::LeftToolBarArea, |
|
954 |
Qt::RightToolBarArea, |
|
955 |
Qt::TopToolBarArea, |
|
956 |
Qt::BottomToolBarArea |
|
957 |
}; |
|
958 |
const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea); |
|
959 |
||
960 |
for (int i = 0; i < areaCount; ++i) { |
|
961 |
Qt::ToolBarArea area = areas[i]; |
|
962 |
||
963 |
QMainWindow mw; |
|
964 |
QToolBar tb1(&mw); |
|
965 |
mw.addToolBar(area, &tb1); |
|
966 |
QToolBar tb2(&mw); |
|
967 |
mw.insertToolBar(&tb1, &tb2); |
|
968 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb1)); |
|
969 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb2)); |
|
970 |
} |
|
971 |
||
972 |
{ |
|
973 |
QMainWindow window; |
|
974 |
QToolBar *bar1 = new QToolBar(QObject::tr("bar1"), &window); |
|
975 |
bar1->addWidget(new QPushButton(QObject::tr("bar1"))); |
|
976 |
QToolBar *bar2 = new QToolBar(QLatin1String("bar2")); |
|
977 |
bar2->addWidget(new QPushButton(QLatin1String("bar2"))); |
|
978 |
QToolBar *bar3 = new QToolBar(QLatin1String("bar3")); |
|
979 |
bar3->addWidget(new QPushButton(QLatin1String("bar3"))); |
|
980 |
||
981 |
window.addToolBar(bar1); |
|
982 |
window.addToolBar(bar3); |
|
983 |
window.insertToolBar(bar1,bar2); |
|
984 |
window.insertToolBar(bar1, bar3); |
|
985 |
||
986 |
QVERIFY(!window.isVisible()); |
|
987 |
QVERIFY(!bar1->isVisible()); |
|
988 |
QVERIFY(!bar2->isVisible()); |
|
989 |
QVERIFY(!bar3->isVisible()); |
|
990 |
||
991 |
window.show(); |
|
992 |
||
993 |
QVERIFY(window.isVisible()); |
|
994 |
QVERIFY(bar1->isVisible()); |
|
995 |
QVERIFY(bar2->isVisible()); |
|
996 |
QVERIFY(bar3->isVisible()); |
|
997 |
} |
|
998 |
} |
|
999 |
||
1000 |
void tst_QMainWindow::removeToolBar() |
|
1001 |
{ |
|
1002 |
Qt::ToolBarArea areas[] = { |
|
1003 |
Qt::LeftToolBarArea, |
|
1004 |
Qt::RightToolBarArea, |
|
1005 |
Qt::TopToolBarArea, |
|
1006 |
Qt::BottomToolBarArea |
|
1007 |
}; |
|
1008 |
const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea); |
|
1009 |
||
1010 |
for (int i = 0; i < areaCount; ++i) { |
|
1011 |
Qt::ToolBarArea area = areas[i]; |
|
1012 |
||
1013 |
QMainWindow mw; |
|
1014 |
QToolBar tb1(&mw); |
|
1015 |
mw.addToolBar(area, &tb1); |
|
1016 |
QToolBar tb2(&mw); |
|
1017 |
mw.insertToolBar(&tb1, &tb2); |
|
1018 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb1)); |
|
1019 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb2)); |
|
1020 |
||
1021 |
mw.removeToolBar(&tb1); |
|
1022 |
QVERIFY(!findWidgetRecursively(mw.layout(), &tb1)); |
|
1023 |
QVERIFY(findWidgetRecursively(mw.layout(), &tb2)); |
|
1024 |
||
1025 |
mw.removeToolBar(&tb2); |
|
1026 |
QVERIFY(!findWidgetRecursively(mw.layout(), &tb1)); |
|
1027 |
QVERIFY(!findWidgetRecursively(mw.layout(), &tb2)); |
|
1028 |
} |
|
1029 |
} |
|
1030 |
||
1031 |
void tst_QMainWindow::toolBarArea() |
|
1032 |
{ |
|
1033 |
Qt::ToolBarArea areas[] = { |
|
1034 |
Qt::LeftToolBarArea, |
|
1035 |
Qt::RightToolBarArea, |
|
1036 |
Qt::TopToolBarArea, |
|
1037 |
Qt::BottomToolBarArea |
|
1038 |
}; |
|
1039 |
const int areaCount = sizeof(areas) / sizeof(Qt::ToolBarArea); |
|
1040 |
||
1041 |
for (int i = 0; i < areaCount; ++i) { |
|
1042 |
Qt::ToolBarArea area = areas[i]; |
|
1043 |
||
1044 |
QMainWindow mw; |
|
1045 |
QToolBar tb(&mw); |
|
1046 |
||
1047 |
for (int j = 0; j < areaCount; ++j) { |
|
1048 |
Qt::ToolBarArea otherArea = areas[j]; |
|
1049 |
||
1050 |
mw.addToolBar(area, &tb); |
|
1051 |
QCOMPARE(mw.toolBarArea(&tb), area); |
|
1052 |
mw.addToolBar(otherArea, &tb); |
|
1053 |
QCOMPARE(mw.toolBarArea(&tb), otherArea); |
|
1054 |
} |
|
1055 |
} |
|
1056 |
||
1057 |
{ |
|
1058 |
// addToolBar() with no area, equivalent to top |
|
1059 |
QMainWindow mw; |
|
1060 |
QToolBar tb(&mw); |
|
1061 |
||
1062 |
for (int j = 0; j < areaCount; ++j) { |
|
1063 |
Qt::ToolBarArea otherArea = areas[j]; |
|
1064 |
||
1065 |
mw.addToolBar(&tb); |
|
1066 |
QCOMPARE(mw.toolBarArea(&tb), Qt::TopToolBarArea); |
|
1067 |
mw.addToolBar(otherArea, &tb); |
|
1068 |
QCOMPARE(mw.toolBarArea(&tb), otherArea); |
|
1069 |
} |
|
1070 |
} |
|
1071 |
} |
|
1072 |
||
1073 |
void tst_QMainWindow::addDockWidget() |
|
1074 |
{ |
|
1075 |
Qt::DockWidgetArea areas[] = { |
|
1076 |
Qt::LeftDockWidgetArea, |
|
1077 |
Qt::RightDockWidgetArea, |
|
1078 |
Qt::TopDockWidgetArea, |
|
1079 |
Qt::BottomDockWidgetArea |
|
1080 |
}; |
|
1081 |
const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea); |
|
1082 |
||
1083 |
for (int i = 0; i < areaCount; ++i) { |
|
1084 |
Qt::DockWidgetArea area = areas[i]; |
|
1085 |
||
1086 |
QMainWindow mw; |
|
1087 |
QDockWidget dw(&mw); |
|
1088 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw)); |
|
1089 |
mw.addDockWidget(area, &dw); |
|
1090 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw)); |
|
1091 |
} |
|
1092 |
||
1093 |
for (int i = 0; i < areaCount; ++i) { |
|
1094 |
Qt::DockWidgetArea area = areas[i]; |
|
1095 |
||
1096 |
{ |
|
1097 |
QMainWindow mw; |
|
1098 |
QDockWidget dw(&mw); |
|
1099 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw)); |
|
1100 |
mw.addDockWidget(area, &dw, Qt::Horizontal); |
|
1101 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw)); |
|
1102 |
} |
|
1103 |
||
1104 |
{ |
|
1105 |
QMainWindow mw; |
|
1106 |
QDockWidget dw(&mw); |
|
1107 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw)); |
|
1108 |
mw.addDockWidget(area, &dw, Qt::Vertical); |
|
1109 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw)); |
|
1110 |
} |
|
1111 |
} |
|
1112 |
||
1113 |
{ |
|
1114 |
QMainWindow mw; |
|
1115 |
QDockWidget dw(&mw); |
|
1116 |
// should not crash, should get a warning instead |
|
1117 |
QTest::ignoreMessage(QtWarningMsg, "QMainWindow::addDockWidget: invalid 'area' argument"); |
|
1118 |
mw.addDockWidget(Qt::NoDockWidgetArea, &dw); |
|
1119 |
} |
|
1120 |
} |
|
1121 |
||
1122 |
void tst_QMainWindow::splitDockWidget() |
|
1123 |
{ |
|
1124 |
Qt::DockWidgetArea areas[] = { |
|
1125 |
Qt::LeftDockWidgetArea, |
|
1126 |
Qt::RightDockWidgetArea, |
|
1127 |
Qt::TopDockWidgetArea, |
|
1128 |
Qt::BottomDockWidgetArea |
|
1129 |
}; |
|
1130 |
const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea); |
|
1131 |
||
1132 |
for (int i = 0; i < areaCount; ++i) { |
|
1133 |
Qt::DockWidgetArea area = areas[i]; |
|
1134 |
||
1135 |
{ |
|
1136 |
QMainWindow mw; |
|
1137 |
QDockWidget dw1(&mw); |
|
1138 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw1)); |
|
1139 |
mw.addDockWidget(area, &dw1); |
|
1140 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw1)); |
|
1141 |
QDockWidget dw2(&mw); |
|
1142 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw2)); |
|
1143 |
mw.splitDockWidget(&dw1, &dw2, Qt::Horizontal); |
|
1144 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw2)); |
|
1145 |
} |
|
1146 |
||
1147 |
{ |
|
1148 |
QMainWindow mw; |
|
1149 |
QDockWidget dw1(&mw); |
|
1150 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw1)); |
|
1151 |
mw.addDockWidget(area, &dw1); |
|
1152 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw1)); |
|
1153 |
QDockWidget dw2(&mw); |
|
1154 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw2)); |
|
1155 |
mw.splitDockWidget(&dw1, &dw2, Qt::Horizontal); |
|
1156 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw2)); |
|
1157 |
} |
|
1158 |
} |
|
1159 |
} |
|
1160 |
||
1161 |
void tst_QMainWindow::removeDockWidget() |
|
1162 |
{ |
|
1163 |
Qt::DockWidgetArea areas[] = { |
|
1164 |
Qt::LeftDockWidgetArea, |
|
1165 |
Qt::RightDockWidgetArea, |
|
1166 |
Qt::TopDockWidgetArea, |
|
1167 |
Qt::BottomDockWidgetArea |
|
1168 |
}; |
|
1169 |
const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea); |
|
1170 |
||
1171 |
for (int i = 0; i < areaCount; ++i) { |
|
1172 |
Qt::DockWidgetArea area = areas[i]; |
|
1173 |
||
1174 |
QMainWindow mw; |
|
1175 |
QDockWidget dw1(&mw); |
|
1176 |
mw.addDockWidget(area, &dw1); |
|
1177 |
QDockWidget dw2(&mw); |
|
1178 |
mw.addDockWidget(area, &dw2); |
|
1179 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw1)); |
|
1180 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw2)); |
|
1181 |
||
1182 |
mw.removeDockWidget(&dw1); |
|
1183 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw1)); |
|
1184 |
QVERIFY(findWidgetRecursively(mw.layout(), &dw2)); |
|
1185 |
||
1186 |
mw.removeDockWidget(&dw2); |
|
1187 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw1)); |
|
1188 |
QVERIFY(!findWidgetRecursively(mw.layout(), &dw2)); |
|
1189 |
} |
|
1190 |
} |
|
1191 |
||
1192 |
void tst_QMainWindow::dockWidgetArea() |
|
1193 |
{ |
|
1194 |
Qt::DockWidgetArea areas[] = { |
|
1195 |
Qt::LeftDockWidgetArea, |
|
1196 |
Qt::RightDockWidgetArea, |
|
1197 |
Qt::TopDockWidgetArea, |
|
1198 |
Qt::BottomDockWidgetArea |
|
1199 |
}; |
|
1200 |
const int areaCount = sizeof(areas) / sizeof(Qt::DockWidgetArea); |
|
1201 |
||
1202 |
for (int i = 0; i < areaCount; ++i) { |
|
1203 |
Qt::DockWidgetArea area = areas[i]; |
|
1204 |
||
1205 |
QMainWindow mw; |
|
1206 |
QDockWidget dw(&mw); |
|
1207 |
||
1208 |
for (int j = 0; j < areaCount; ++j) { |
|
1209 |
Qt::DockWidgetArea otherArea = areas[i]; |
|
1210 |
||
1211 |
mw.addDockWidget(area, &dw); |
|
1212 |
QCOMPARE(mw.dockWidgetArea(&dw), area); |
|
1213 |
mw.addDockWidget(otherArea, &dw); |
|
1214 |
QCOMPARE(mw.dockWidgetArea(&dw), otherArea); |
|
1215 |
} |
|
1216 |
} |
|
1217 |
} |
|
1218 |
||
1219 |
void tst_QMainWindow::saveState() |
|
1220 |
{ DEPENDS_ON("restoreState()"); } |
|
1221 |
||
1222 |
void tst_QMainWindow::restoreState() |
|
1223 |
{ |
|
1224 |
QMainWindow mw; |
|
1225 |
QToolBar tb(&mw); |
|
1226 |
mw.addToolBar(Qt::TopToolBarArea, &tb); |
|
1227 |
QDockWidget dw(&mw); |
|
1228 |
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw); |
|
1229 |
||
1230 |
QByteArray state; |
|
1231 |
||
1232 |
state = mw.saveState(); |
|
1233 |
QVERIFY(mw.restoreState(state)); |
|
1234 |
||
1235 |
state = mw.saveState(1); |
|
1236 |
QVERIFY(!mw.restoreState(state)); |
|
1237 |
QVERIFY(mw.restoreState(state, 1)); |
|
1238 |
} |
|
1239 |
||
1240 |
//tests the restoration of the previous versions of window settings |
|
1241 |
void tst_QMainWindow::restoreStateFromPreviousVersion() |
|
1242 |
{ |
|
1243 |
QList<QByteArray> restoreData; |
|
1244 |
restoreData << QByteArray((char*)restoreData41, sizeof(restoreData41)) |
|
1245 |
<< QByteArray((char*)restoreData42, sizeof(restoreData42)) |
|
1246 |
<< QByteArray((char*)restoreData43, sizeof(restoreData43)); |
|
1247 |
||
1248 |
foreach(QByteArray ba, restoreData) { |
|
1249 |
||
1250 |
QMainWindow win; |
|
1251 |
win.setCentralWidget(new QTextEdit); |
|
1252 |
QVector<QDockWidget*> docks; |
|
1253 |
||
1254 |
for(int i = 0; i < 16; ++i) { |
|
1255 |
const QString name = QString::fromLatin1("dock %1").arg(i); |
|
1256 |
QDockWidget *dock = new QDockWidget(name); |
|
1257 |
docks += dock; |
|
1258 |
dock->setObjectName(name); |
|
1259 |
win.addDockWidget(Qt::TopDockWidgetArea, dock); |
|
1260 |
} |
|
1261 |
win.show(); |
|
1262 |
QCOMPARE(win.restoreState(ba), true); |
|
1263 |
||
1264 |
for( int i = 0; i < docks.size(); ++i) { |
|
1265 |
QCOMPARE( win.dockWidgetArea(docks[i]), Qt::DockWidgetArea(1 << i%4)); |
|
1266 |
} |
|
1267 |
} |
|
1268 |
||
1269 |
} |
|
1270 |
||
1271 |
||
1272 |
void tst_QMainWindow::createPopupMenu() |
|
1273 |
{ |
|
1274 |
{ |
|
1275 |
QMainWindow mainwindow; |
|
1276 |
QVERIFY(!mainwindow.createPopupMenu()); |
|
1277 |
||
1278 |
QToolBar toolbar1(&mainwindow); |
|
1279 |
toolbar1.setWindowTitle("toolbar1"); |
|
1280 |
QToolBar toolbar2(&mainwindow); |
|
1281 |
toolbar2.setWindowTitle("toolbar2"); |
|
1282 |
||
1283 |
mainwindow.addToolBar(&toolbar1); |
|
1284 |
mainwindow.addToolBar(&toolbar2); |
|
1285 |
||
1286 |
QDockWidget dockwidget1(&mainwindow); |
|
1287 |
dockwidget1.setWindowTitle("dockwidget1"); |
|
1288 |
QDockWidget dockwidget2(&mainwindow); |
|
1289 |
dockwidget2.setWindowTitle("dockwidget2"); |
|
1290 |
QDockWidget dockwidget3(&mainwindow); |
|
1291 |
dockwidget3.setWindowTitle("dockwidget3"); |
|
1292 |
QDockWidget dockwidget4(&mainwindow); |
|
1293 |
dockwidget4.setWindowTitle("dockwidget4"); |
|
1294 |
||
1295 |
mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget1); |
|
1296 |
mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget2); |
|
1297 |
mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget3); |
|
1298 |
mainwindow.addDockWidget(Qt::LeftDockWidgetArea, &dockwidget4); |
|
1299 |
||
1300 |
||
1301 |
#ifdef QT_SOFTKEYS_ENABLED |
|
1302 |
// Softkeys add extra "Select" and "Back" actions to menu by default. |
|
1303 |
// Two first actions will be Select and Back when softkeys are enabled |
|
1304 |
int numSoftkeyActions = 2; |
|
1305 |
#else |
|
1306 |
int numSoftkeyActions = 0; |
|
1307 |
#endif |
|
1308 |
||
1309 |
QMenu *menu = mainwindow.createPopupMenu(); |
|
1310 |
QVERIFY(menu != 0); |
|
1311 |
QList<QAction *> actions = menu->actions(); |
|
1312 |
QCOMPARE(actions.size(), 7 + numSoftkeyActions); |
|
1313 |
||
1314 |
QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget1.toggleViewAction()); |
|
1315 |
QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget2.toggleViewAction()); |
|
1316 |
QCOMPARE(actions.at(2 + numSoftkeyActions), dockwidget3.toggleViewAction()); |
|
1317 |
QCOMPARE(actions.at(3 + numSoftkeyActions), dockwidget4.toggleViewAction()); |
|
1318 |
QVERIFY(actions.at(4 + numSoftkeyActions)->isSeparator()); |
|
1319 |
QCOMPARE(actions.at(5 + numSoftkeyActions), toolbar1.toggleViewAction()); |
|
1320 |
QCOMPARE(actions.at(6 + numSoftkeyActions), toolbar2.toggleViewAction()); |
|
1321 |
||
1322 |
delete menu; |
|
1323 |
||
1324 |
mainwindow.removeToolBar(&toolbar1); |
|
1325 |
mainwindow.removeDockWidget(&dockwidget1); |
|
1326 |
mainwindow.removeDockWidget(&dockwidget4); |
|
1327 |
||
1328 |
menu = mainwindow.createPopupMenu(); |
|
1329 |
QVERIFY(menu != 0); |
|
1330 |
actions = menu->actions(); |
|
1331 |
QCOMPARE(actions.size(), 4 + numSoftkeyActions); |
|
1332 |
||
1333 |
QCOMPARE(actions.at(0 + numSoftkeyActions), dockwidget2.toggleViewAction()); |
|
1334 |
QCOMPARE(actions.at(1 + numSoftkeyActions), dockwidget3.toggleViewAction()); |
|
1335 |
QVERIFY(actions.at(2 + numSoftkeyActions)->isSeparator()); |
|
1336 |
QCOMPARE(actions.at(3 + numSoftkeyActions), toolbar2.toggleViewAction()); |
|
1337 |
||
1338 |
delete menu; |
|
1339 |
} |
|
1340 |
} |
|
1341 |
||
1342 |
class MyDockWidget : public QDockWidget |
|
1343 |
{ |
|
1344 |
public: |
|
1345 |
MyDockWidget(QWidget * = 0) { |
|
1346 |
create(); // otherwise hide() doesn't result in a hide event |
|
1347 |
} |
|
1348 |
}; |
|
1349 |
||
1350 |
class MyWidget : public QWidget |
|
1351 |
{ |
|
1352 |
public: |
|
1353 |
MyWidget(QWidget *parent = 0) : QWidget(parent) |
|
1354 |
{ |
|
1355 |
} |
|
1356 |
||
1357 |
QSize sizeHint() const |
|
1358 |
{ |
|
1359 |
return QSize(200, 200); |
|
1360 |
} |
|
1361 |
}; |
|
1362 |
||
1363 |
void tst_QMainWindow::hideBeforeLayout() |
|
1364 |
{ |
|
1365 |
QMainWindow win; |
|
1366 |
QDockWidget *dock = new MyDockWidget(&win); |
|
1367 |
dock->setWidget(new QLabel("hello")); |
|
1368 |
win.addDockWidget(Qt::LeftDockWidgetArea, dock); |
|
1369 |
dock->hide(); |
|
1370 |
win.resize(300, 300); |
|
1371 |
win.show(); |
|
1372 |
dock->show(); |
|
1373 |
QVERIFY(dock->geometry().bottomRight().x() >= 0); |
|
1374 |
} |
|
1375 |
||
1376 |
struct AddDockWidget |
|
1377 |
{ |
|
1378 |
enum Mode { AddMode, SplitMode, TabMode }; |
|
1379 |
||
1380 |
AddDockWidget() {} |
|
1381 |
AddDockWidget(const QString &_name, Qt::DockWidgetArea _a) |
|
1382 |
: name(_name), mode(AddMode), a(_a) {} |
|
1383 |
AddDockWidget(const QString &_name, const QString &_other, Qt::Orientation _o) |
|
1384 |
: name(_name), mode(SplitMode), o(_o), other(_other) {} |
|
1385 |
AddDockWidget(const QString &_name, const QString &_other) |
|
1386 |
: name(_name), mode(TabMode), other(_other) {} |
|
1387 |
||
1388 |
QString name; |
|
1389 |
Mode mode; |
|
1390 |
||
1391 |
Qt::Orientation o; |
|
1392 |
Qt::DockWidgetArea a; |
|
1393 |
QString other; |
|
1394 |
||
1395 |
void apply(QMainWindow *mw) const; |
|
1396 |
}; |
|
1397 |
||
1398 |
typedef QList<AddDockWidget> AddList; |
|
1399 |
Q_DECLARE_METATYPE(AddList) |
|
1400 |
||
1401 |
void AddDockWidget::apply(QMainWindow *mw) const |
|
1402 |
{ |
|
1403 |
QDockWidget *dw = new QDockWidget(); |
|
1404 |
QWidget *w = new QWidget(); |
|
1405 |
w->setMinimumSize(100, 50); |
|
1406 |
dw->setWidget(w); |
|
1407 |
||
1408 |
dw->setObjectName(name); |
|
1409 |
dw->setWindowTitle(name); |
|
1410 |
||
1411 |
QDockWidget *other = 0; |
|
1412 |
if (mode == SplitMode || mode == TabMode) { |
|
1413 |
other = qFindChild<QDockWidget*>(mw, this->other); |
|
1414 |
QVERIFY(other != 0); |
|
1415 |
} |
|
1416 |
||
1417 |
switch (mode) { |
|
1418 |
case AddMode: |
|
1419 |
mw->addDockWidget(a, dw); |
|
1420 |
break; |
|
1421 |
case SplitMode: |
|
1422 |
mw->splitDockWidget(other, dw, o); |
|
1423 |
break; |
|
1424 |
case TabMode: |
|
1425 |
mw->tabifyDockWidget(other, dw); |
|
1426 |
break; |
|
1427 |
} |
|
1428 |
} |
|
1429 |
||
1430 |
#ifdef QT_BUILD_INTERNAL |
|
1431 |
struct MoveSeparator |
|
1432 |
{ |
|
1433 |
MoveSeparator() {} |
|
1434 |
MoveSeparator(int _delta, const QString &_name) |
|
1435 |
: delta(_delta), name(_name) {} |
|
1436 |
MoveSeparator(int _delta, int _area) |
|
1437 |
: delta(_delta), area(_area) {} |
|
1438 |
||
1439 |
int delta; |
|
1440 |
int area; |
|
1441 |
QString name; |
|
1442 |
||
1443 |
void apply(QMainWindow *mw) const; |
|
1444 |
}; |
|
1445 |
||
1446 |
typedef QList<MoveSeparator> MoveList; |
|
1447 |
Q_DECLARE_METATYPE(MoveList) |
|
1448 |
||
1449 |
void MoveSeparator::apply(QMainWindow *mw) const |
|
1450 |
{ |
|
1451 |
||
1452 |
QMainWindowLayout *l = qobject_cast<QMainWindowLayout*>(mw->layout()); |
|
1453 |
QVERIFY(l); |
|
1454 |
||
1455 |
QList<int> path; |
|
1456 |
if (name.isEmpty()) { |
|
1457 |
path << area; |
|
1458 |
} else { |
|
1459 |
QDockWidget *dw = qFindChild<QDockWidget*>(mw, name); |
|
1460 |
QVERIFY(dw != 0); |
|
1461 |
path = l->layoutState.dockAreaLayout.indexOf(dw); |
|
1462 |
} |
|
1463 |
QVERIFY(!path.isEmpty()); |
|
1464 |
||
1465 |
l->layoutState.dockAreaLayout.separatorMove(path, QPoint(0, 0), QPoint(delta, delta)); |
|
1466 |
} |
|
1467 |
#endif |
|
1468 |
||
1469 |
QMap<QString, QRect> dockWidgetGeometries(QMainWindow *mw) |
|
1470 |
{ |
|
1471 |
QMap<QString, QRect> result; |
|
1472 |
QList<QDockWidget*> dockWidgets = qFindChildren<QDockWidget*>(mw); |
|
1473 |
foreach (QDockWidget *dw, dockWidgets) |
|
1474 |
result.insert(dw->objectName(), dw->geometry()); |
|
1475 |
return result; |
|
1476 |
} |
|
1477 |
||
1478 |
#define COMPARE_DOCK_WIDGET_GEOS(_oldGeos, _newGeos) \ |
|
1479 |
{ \ |
|
1480 |
QMap<QString, QRect> __oldGeos = _oldGeos; \ |
|
1481 |
QMap<QString, QRect> __newGeos = _newGeos; \ |
|
1482 |
QCOMPARE(__newGeos.keys(), __oldGeos.keys()); \ |
|
1483 |
QStringList __keys = __newGeos.keys(); \ |
|
1484 |
foreach (const QString &key, __keys) { \ |
|
1485 |
QRect __r1 = __oldGeos[key]; \ |
|
1486 |
QRect __r2 = __newGeos[key]; \ |
|
1487 |
if (__r1 != __r2) \ |
|
1488 |
qWarning() << key << __r1 << __r2; \ |
|
1489 |
} \ |
|
1490 |
QCOMPARE(__newGeos, __oldGeos); \ |
|
1491 |
} |
|
1492 |
||
1493 |
void tst_QMainWindow::saveRestore_data() |
|
1494 |
{ |
|
1495 |
#ifdef QT_BUILD_INTERNAL |
|
1496 |
QTest::addColumn<AddList >("addList"); |
|
1497 |
QTest::addColumn<MoveList >("moveList"); |
|
1498 |
||
1499 |
QTest::newRow("1") << (AddList() |
|
1500 |
<< AddDockWidget("left", Qt::LeftDockWidgetArea)) |
|
1501 |
<< (MoveList() |
|
1502 |
<< MoveSeparator(100, QInternal::LeftDock)); |
|
1503 |
||
1504 |
QTest::newRow("2") << (AddList() |
|
1505 |
<< AddDockWidget("left", Qt::LeftDockWidgetArea) |
|
1506 |
<< AddDockWidget("right", Qt::RightDockWidgetArea)) |
|
1507 |
<< (MoveList() |
|
1508 |
<< MoveSeparator(70, QInternal::LeftDock) |
|
1509 |
<< MoveSeparator(-40, QInternal::RightDock)); |
|
1510 |
QTest::newRow("3") << (AddList() |
|
1511 |
<< AddDockWidget("left", Qt::LeftDockWidgetArea) |
|
1512 |
<< AddDockWidget("right1", Qt::RightDockWidgetArea) |
|
1513 |
<< AddDockWidget("right2", Qt::RightDockWidgetArea)) |
|
1514 |
<< (MoveList() |
|
1515 |
<< MoveSeparator(70, QInternal::LeftDock) |
|
1516 |
<< MoveSeparator(-40, QInternal::RightDock)); |
|
1517 |
||
1518 |
QTest::newRow("4") << (AddList() |
|
1519 |
<< AddDockWidget("left", Qt::LeftDockWidgetArea) |
|
1520 |
<< AddDockWidget("right1", Qt::RightDockWidgetArea) |
|
1521 |
<< AddDockWidget("right2a", Qt::RightDockWidgetArea) |
|
1522 |
<< AddDockWidget("right2b", "right2a", Qt::Horizontal) |
|
1523 |
) |
|
1524 |
<< (MoveList() |
|
1525 |
<< MoveSeparator(70, QInternal::LeftDock) |
|
1526 |
<< MoveSeparator(-40, QInternal::RightDock) |
|
1527 |
<< MoveSeparator(-30, "right1") |
|
1528 |
<< MoveSeparator(30, "right2a") |
|
1529 |
); |
|
1530 |
#endif |
|
1531 |
} |
|
1532 |
||
1533 |
void tst_QMainWindow::saveRestore() |
|
1534 |
{ |
|
1535 |
#ifdef QT_BUILD_INTERNAL |
|
1536 |
QFETCH(AddList, addList); |
|
1537 |
QFETCH(MoveList, moveList); |
|
1538 |
||
1539 |
QByteArray stateData; |
|
1540 |
QMap<QString, QRect> dockWidgetGeos; |
|
1541 |
QSize size; |
|
1542 |
||
1543 |
{ |
|
1544 |
QMainWindow mainWindow; |
|
1545 |
mainWindow.setDockNestingEnabled(true); |
|
1546 |
QTextEdit centralWidget("The rain in Spain falls mainly on the plains"); |
|
1547 |
mainWindow.setCentralWidget(¢ralWidget); |
|
1548 |
||
1549 |
foreach (const AddDockWidget &adw, addList) |
|
1550 |
adw.apply(&mainWindow); |
|
1551 |
||
1552 |
mainWindow.show(); |
|
1553 |
||
1554 |
foreach (const MoveSeparator &ms, moveList) |
|
1555 |
ms.apply(&mainWindow); |
|
1556 |
||
1557 |
dockWidgetGeos = dockWidgetGeometries(&mainWindow); |
|
1558 |
size = mainWindow.size(); |
|
1559 |
stateData = mainWindow.saveState(); |
|
1560 |
||
1561 |
mainWindow.layout()->setGeometry(mainWindow.rect()); |
|
1562 |
COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow)); |
|
1563 |
||
1564 |
#if 0 |
|
1565 |
QEventLoop eventLoop; |
|
1566 |
QPushButton quitButton("Quit", ¢ralWidget); |
|
1567 |
quitButton.setGeometry(0, 0, 100, 40); |
|
1568 |
connect(&quitButton, SIGNAL(clicked()), &eventLoop, SLOT(quit())); |
|
1569 |
quitButton.show(); |
|
1570 |
eventLoop.exec(); |
|
1571 |
#endif |
|
1572 |
} |
|
1573 |
||
1574 |
// restoreState() after show |
|
1575 |
{ |
|
1576 |
QMainWindow mainWindow; |
|
1577 |
mainWindow.setDockNestingEnabled(true); |
|
1578 |
QTextEdit centralWidget("The rain in Spain falls mainly on the plains"); |
|
1579 |
mainWindow.setCentralWidget(¢ralWidget); |
|
1580 |
||
1581 |
foreach (const AddDockWidget &adw, addList) |
|
1582 |
adw.apply(&mainWindow); |
|
1583 |
||
1584 |
mainWindow.show(); |
|
1585 |
mainWindow.restoreState(stateData); |
|
1586 |
||
1587 |
COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow)); |
|
1588 |
} |
|
1589 |
||
1590 |
// restoreState() before show |
|
1591 |
{ |
|
1592 |
QMainWindow mainWindow; |
|
1593 |
mainWindow.setDockNestingEnabled(true); |
|
1594 |
QTextEdit centralWidget("The rain in Spain falls mainly on the plains"); |
|
1595 |
mainWindow.setCentralWidget(¢ralWidget); |
|
1596 |
||
1597 |
foreach (const AddDockWidget &adw, addList) |
|
1598 |
adw.apply(&mainWindow); |
|
1599 |
mainWindow.resize(size); |
|
1600 |
mainWindow.restoreState(stateData); |
|
1601 |
||
1602 |
mainWindow.show(); |
|
1603 |
COMPARE_DOCK_WIDGET_GEOS(dockWidgetGeos, dockWidgetGeometries(&mainWindow)); |
|
1604 |
} |
|
1605 |
#endif |
|
1606 |
} |
|
1607 |
||
1608 |
void tst_QMainWindow::iconSizeChanged() |
|
1609 |
{ DEPENDS_ON("iconSize()"); } |
|
1610 |
||
1611 |
void tst_QMainWindow::toolButtonStyleChanged() |
|
1612 |
{ DEPENDS_ON("toolButtonStyle()"); } |
|
1613 |
||
1614 |
void tst_QMainWindow::isSeparator() |
|
1615 |
{ |
|
1616 |
QMainWindow mw; |
|
1617 |
QDockWidget *dockw = new QDockWidget(); |
|
1618 |
mw.addDockWidget(Qt::LeftDockWidgetArea, dockw); |
|
1619 |
mw.addDockWidget(Qt::LeftDockWidgetArea, new QDockWidget()); |
|
1620 |
dockw->resize(10,10); |
|
1621 |
mw.show(); |
|
1622 |
||
1623 |
//In case the separator size is 1, we increase it to 3 inside the QMainWindow class |
|
1624 |
const int margin = mw.style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, &mw) == 1 ? 2 : 0; |
|
1625 |
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y()))); |
|
1626 |
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() - 1 - margin))); |
|
1627 |
QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height()))); |
|
1628 |
QVERIFY( mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + margin))); |
|
1629 |
QVERIFY(!mw.isSeparator(QPoint(4, dockw->pos().y() + dockw->size().height() + 15))); |
|
1630 |
||
1631 |
} |
|
1632 |
||
1633 |
class MainWindow : public QMainWindow { |
|
1634 |
public: |
|
1635 |
using QMainWindow::event; |
|
1636 |
}; |
|
1637 |
||
1638 |
void tst_QMainWindow::setCursor() |
|
1639 |
{ |
|
1640 |
#ifdef QT_NO_CURSOR |
|
1641 |
QSKIP("Qt compiled without cursor support(QT_NO_CURSOR)", SkipAll); |
|
1642 |
#else |
|
1643 |
MainWindow mw; |
|
1644 |
QCursor cur = Qt::WaitCursor; |
|
1645 |
mw.setCursor(cur); |
|
1646 |
QCOMPARE(cur.shape(), mw.cursor().shape()); |
|
1647 |
mw.resize(200,200); |
|
1648 |
mw.show(); |
|
1649 |
QTest::qWait(50); |
|
1650 |
QCOMPARE(cur.shape(), mw.cursor().shape()); |
|
1651 |
||
1652 |
QHoverEvent enterE(QEvent::HoverEnter, QPoint(10,10), QPoint()); |
|
1653 |
mw.event(&enterE); |
|
1654 |
QTest::qWait(50); |
|
1655 |
QCOMPARE(cur.shape(), mw.cursor().shape()); |
|
1656 |
||
1657 |
QHoverEvent leaveE(QEvent::HoverLeave, QPoint(), QPoint()); |
|
1658 |
mw.event(&leaveE); |
|
1659 |
QTest::qWait(50); |
|
1660 |
QCOMPARE(cur.shape(), mw.cursor().shape()); |
|
1661 |
#endif |
|
1662 |
} |
|
1663 |
||
1664 |
void tst_QMainWindow::addToolbarAfterShow() |
|
1665 |
{ |
|
1666 |
//this is for task 243119 |
|
1667 |
QMainWindow mainWindow; |
|
1668 |
mainWindow.show(); |
|
1669 |
||
1670 |
QToolBar toolBar; |
|
1671 |
mainWindow.addToolBar(&toolBar); |
|
1672 |
QTest::qWait(100); |
|
1673 |
||
1674 |
QVERIFY(!toolBar.isHidden()); |
|
1675 |
} |
|
1676 |
||
1677 |
void tst_QMainWindow::centralWidgetSize() |
|
1678 |
{ |
|
1679 |
QMainWindow mainWindow; |
|
1680 |
mainWindow.menuBar()->addMenu("menu"); |
|
1681 |
||
1682 |
MyWidget widget; |
|
1683 |
mainWindow.setCentralWidget(&widget); |
|
1684 |
||
1685 |
mainWindow.show(); |
|
1686 |
QTest::qWait(100); |
|
1687 |
QCOMPARE(widget.size(), widget.sizeHint()); |
|
1688 |
} |
|
1689 |
||
1690 |
void tst_QMainWindow::dockWidgetSize() |
|
1691 |
{ |
|
1692 |
QMainWindow mainWindow; |
|
1693 |
mainWindow.menuBar()->addMenu("menu"); |
|
1694 |
||
1695 |
MyWidget widget; |
|
1696 |
mainWindow.setCentralWidget(&widget); |
|
1697 |
||
1698 |
QDockWidget dock; |
|
1699 |
dock.setWidget(new MyWidget); |
|
1700 |
mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock); |
|
1701 |
||
1702 |
mainWindow.show(); |
|
1703 |
QTest::qWait(100); |
|
1704 |
if (mainWindow.size() == mainWindow.sizeHint()) { |
|
1705 |
QCOMPARE(widget.size(), widget.sizeHint()); |
|
1706 |
QCOMPARE(dock.widget()->size(), dock.widget()->sizeHint()); |
|
1707 |
} else { |
|
1708 |
//otherwise the screen is too small and the size are irrelevant |
|
1709 |
} |
|
1710 |
} |
|
1711 |
||
1712 |
||
1713 |
QTEST_MAIN(tst_QMainWindow) |
|
1714 |
#include "tst_qmainwindow.moc" |