summaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.cpp8
-rw-r--r--tests/manual/cocoa/menurama/mainwindow.ui98
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.cpp16
-rw-r--r--tests/manual/cocoa/menurama/menuramaapplication.h1
-rw-r--r--tests/manual/cocoa/qmaccocoaviewcontainer/main.mm1
-rw-r--r--tests/manual/diaglib/debugproxystyle.cpp42
-rw-r--r--tests/manual/diaglib/debugproxystyle.h1
-rw-r--r--tests/manual/diaglib/qwindowdump.cpp2
-rw-r--r--tests/manual/dialogs/main.cpp3
-rw-r--r--tests/manual/lance/main.cpp2
-rw-r--r--tests/manual/manual.pro12
-rw-r--r--tests/manual/qopenglcontext/qopenglcontext.pro2
-rw-r--r--tests/manual/qopenglcontext/qopenglcontextwindow.cpp2
-rw-r--r--tests/manual/qopenglcontext/qopenglcontextwindow.h2
-rw-r--r--tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp4
-rw-r--r--tests/manual/qopengltextureblitter/qopengltextureblitwindow.h2
-rw-r--r--tests/manual/qsysinfo/main.cpp13
-rw-r--r--tests/manual/textrendering/glyphshaping/main.cpp2
-rw-r--r--tests/manual/windowflags/controllerwindow.cpp237
-rw-r--r--tests/manual/windowflags/controllerwindow.h39
-rw-r--r--tests/manual/windowflags/main.cpp8
-rw-r--r--tests/manual/windowflags/previewwindow.cpp271
-rw-r--r--tests/manual/windowflags/previewwindow.h31
23 files changed, 566 insertions, 233 deletions
diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp
index db8fdafc21..f7762f57f5 100644
--- a/tests/manual/cocoa/menurama/mainwindow.cpp
+++ b/tests/manual/cocoa/menurama/mainwindow.cpp
@@ -56,7 +56,13 @@ MainWindow::MainWindow(QWidget *parent) :
});
connect(ui->menuDynamic_Stuff, &QMenu::aboutToShow, [=] {
- menuApp->addDynMenu(QLatin1String("Added After aboutToShow()"), ui->menuDynamic_Stuff);
+ menuApp->addDynMenu(QLatin1String("Menu Added After aboutToShow()"), ui->menuDynamic_Stuff);
+
+ const QLatin1String itemTitle = QLatin1String("Disabled Item Added After aboutToShow()");
+ if (QAction *a = menuApp->findAction(itemTitle, ui->menuDynamic_Stuff))
+ ui->menuDynamic_Stuff->removeAction(a);
+ QAction *a = ui->menuDynamic_Stuff->addAction(itemTitle);
+ a->setEnabled(false);
});
connect(ui->pushButton, &QPushButton::clicked, [=] {
diff --git a/tests/manual/cocoa/menurama/mainwindow.ui b/tests/manual/cocoa/menurama/mainwindow.ui
index f73b41b861..d3caa6c608 100644
--- a/tests/manual/cocoa/menurama/mainwindow.ui
+++ b/tests/manual/cocoa/menurama/mainwindow.ui
@@ -6,63 +6,71 @@
<rect>
<x>0</x>
<y>0</y>
- <width>566</width>
- <height>300</height>
+ <width>429</width>
+ <height>251</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
- <widget class="QCheckBox" name="checkBox">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>40</y>
- <width>151</width>
- <height>20</height>
- </rect>
- </property>
- <property name="text">
- <string>Enable &quot;Stuff&quot; Menu</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- <widget class="QLabel" name="label">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>321</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>The &quot;Help&quot; menu should NOT be visible.</string>
- </property>
- </widget>
- <widget class="QPushButton" name="pushButton">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>80</y>
- <width>211</width>
- <height>32</height>
- </rect>
- </property>
- <property name="text">
- <string>Populate Dynamic Submenu</string>
- </property>
- </widget>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>24</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>The &quot;Help&quot; menu should NOT be visible.
+
+Click on &quot;Dynamic Stuff&quot; then move left and right to other menus. Disabled items should remain that way.</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="text">
+ <string>Enable &quot;Stuff&quot; Menu</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Populate Dynamic Submenu</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>566</width>
+ <width>429</width>
<height>22</height>
</rect>
</property>
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp
index 534d5fa371..13e457d7dd 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.cpp
+++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp
@@ -69,13 +69,19 @@ void MenuramaApplication::populateMenu(QMenu *menu, bool clear)
void MenuramaApplication::addDynMenu(QLatin1String title, QMenu *parentMenu)
{
- foreach (QAction *a, parentMenu->actions())
- if (a->text() == title) {
- parentMenu->removeAction(a);
- break;
- }
+ if (QAction *a = findAction(title, parentMenu))
+ parentMenu->removeAction(a);
QMenu *subMenu = new QMenu(title, parentMenu);
populateMenu(subMenu, false /*clear*/);
parentMenu->addMenu(subMenu);
}
+
+QAction *MenuramaApplication::findAction(QLatin1String title, QMenu *parentMenu)
+{
+ foreach (QAction *a, parentMenu->actions())
+ if (a->text() == title)
+ return a;
+
+ return Q_NULLPTR;
+}
diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h
index 07c8da27a1..b0670cc53b 100644
--- a/tests/manual/cocoa/menurama/menuramaapplication.h
+++ b/tests/manual/cocoa/menurama/menuramaapplication.h
@@ -50,6 +50,7 @@ class MenuramaApplication : public QApplication
public:
MenuramaApplication(int argc, char **argv);
void addDynMenu(QLatin1String title, QMenu *parentMenu);
+ QAction *findAction(QLatin1String title, QMenu *parentMenu);
public slots:
void populateMenu(QMenu *menu, bool clear);
diff --git a/tests/manual/cocoa/qmaccocoaviewcontainer/main.mm b/tests/manual/cocoa/qmaccocoaviewcontainer/main.mm
index d06c333c9c..9cf06391ca 100644
--- a/tests/manual/cocoa/qmaccocoaviewcontainer/main.mm
+++ b/tests/manual/cocoa/qmaccocoaviewcontainer/main.mm
@@ -80,6 +80,7 @@ int main(int argc, char **argv)
QPoint pos(100,100);
QWidget w;
w.move(pos);
+ w.resize(300, 300);
w.setWindowTitle("QMacCocoaViewContainer");
NSRect r = NSMakeRect(0, 0, 100, 100);
NSView *view = [[TestMouseMovedNSView alloc] initWithFrame: r];
diff --git a/tests/manual/diaglib/debugproxystyle.cpp b/tests/manual/diaglib/debugproxystyle.cpp
index 667ec403b7..d4e62f5dd6 100644
--- a/tests/manual/diaglib/debugproxystyle.cpp
+++ b/tests/manual/diaglib/debugproxystyle.cpp
@@ -45,13 +45,36 @@ QDebug operator<<(QDebug debug, const QStyleOption *option)
{
#if QT_VERSION >= 0x050000
QDebugStateSaver saver(debug);
+# if QT_VERSION >= 0x050400
+ debug.noquote();
+# endif
debug.nospace();
#endif
- debug << "QStyleOption(";
- if (option)
- debug << "rec=" << option->rect;
- else
- debug << '0';
+ if (!option) {
+ debug << "QStyleOption(0)";
+ return debug;
+ }
+ if (const QStyleOptionViewItem *ivo = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
+ debug << "QStyleOptionViewItem(";
+#if QT_VERSION >= 0x050000
+ debug << ivo->index;
+ if (const int textSize = ivo->text.size())
+ debug << ", \"" << (textSize < 20 ? ivo->text : ivo->text.left(20) + QLatin1String("...")) << '"';
+ debug << ", ";
+#else // Qt 5
+ Q_UNUSED(ivo)
+#endif
+ } else {
+ debug << "QStyleOption(";
+ }
+ debug << "rect=" << option->rect.width() << 'x' << option->rect.height()
+ << forcesign << option->rect.x() << option->rect.y() << noforcesign;
+ if (option->state != QStyle::State_None)
+ debug << ", state=" << option->state;
+#if QT_VERSION >= 0x050000
+ if (option->styleObject && !option->styleObject->isWidgetType())
+ debug << ", styleObject=" << option->styleObject;
+#endif
debug << ')';
return debug;
}
@@ -132,6 +155,15 @@ QRect DebugProxyStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &
return result;
}
+int DebugProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
+ QStyleHintReturn *returnData) const
+{
+ const int result = QProxyStyle::styleHint(hint, option, widget, returnData);
+ qDebug() << __FUNCTION__ << hint << option << widget << "returnData="
+ << returnData << "returns" << result;
+ return result;
+}
+
int DebugProxyStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
{
const int result = QProxyStyle::pixelMetric(metric, option, widget);
diff --git a/tests/manual/diaglib/debugproxystyle.h b/tests/manual/diaglib/debugproxystyle.h
index 74407e7f3e..01e1e6b6d1 100644
--- a/tests/manual/diaglib/debugproxystyle.h
+++ b/tests/manual/diaglib/debugproxystyle.h
@@ -48,6 +48,7 @@ public:
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const;
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp
index 19c9ca30e9..4adb1da5f1 100644
--- a/tests/manual/diaglib/qwindowdump.cpp
+++ b/tests/manual/diaglib/qwindowdump.cpp
@@ -113,8 +113,6 @@ void formatWindowFlags(QTextStream &str, const Qt::WindowFlags flags)
debugFlag(str, flags, Qt::WindowStaysOnBottomHint)
debugFlag(str, flags, Qt::MacWindowToolBarButtonHint)
debugFlag(str, flags, Qt::BypassGraphicsProxyWidget)
- debugFlag(str, flags, Qt::WindowOkButtonHint)
- debugFlag(str, flags, Qt::WindowCancelButtonHint)
}
#if QT_VERSION > 0x050000
diff --git a/tests/manual/dialogs/main.cpp b/tests/manual/dialogs/main.cpp
index f0f4e437e9..3f7b33ee7a 100644
--- a/tests/manual/dialogs/main.cpp
+++ b/tests/manual/dialogs/main.cpp
@@ -80,12 +80,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
int main(int argc, char *argv[])
{
+#if QT_VERSION >= 0x050700
for (int a = 1; a < argc; ++a) {
if (!qstrcmp(argv[a], "-n")) {
qDebug("AA_DontUseNativeDialogs");
QCoreApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
}
}
+#endif // Qt 5
+
QApplication a(argc, argv);
MainWindow w;
w.move(500, 200);
diff --git a/tests/manual/lance/main.cpp b/tests/manual/lance/main.cpp
index 5d7edc0a99..c1ace138f9 100644
--- a/tests/manual/lance/main.cpp
+++ b/tests/manual/lance/main.cpp
@@ -327,7 +327,7 @@ int main(int argc, char **argv)
checkers_background = false;
}
} else {
-#if defined (Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
QString input = QString::fromLocal8Bit(argv[i]);
if (input.indexOf('*') >= 0) {
QFileInfo info(input);
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index f8287f7d19..2fe96c2f93 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -53,18 +53,14 @@ dialogs \
windowtransparency \
unc
-!contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions
+!qtConfig(openssl):!qtConfig(openssl-linked): SUBDIRS -= qssloptions
-contains(QT_CONFIG, opengl) {
+qtConfig(opengl) {
SUBDIRS += qopengltextureblitter
- contains(QT_CONFIG, egl): SUBDIRS += qopenglcontext
+ qtConfig(egl): SUBDIRS += qopenglcontext
}
-win32 {
- SUBDIRS -= network_remote_stresstest network_stresstest
- # disable some tests on wince because of missing dependencies
- wince: SUBDIRS -= lance windowmodality
-}
+win32: SUBDIRS -= network_remote_stresstest network_stresstest
lessThan(QT_MAJOR_VERSION, 5): SUBDIRS -= bearerex lance qnetworkaccessmanager/qget qmimedatabase qnetworkreply \
qpainfo qscreen socketengine xembed-raster xembed-widgets windowtransparency \
diff --git a/tests/manual/qopenglcontext/qopenglcontext.pro b/tests/manual/qopenglcontext/qopenglcontext.pro
index c5943809c6..08a9ab407c 100644
--- a/tests/manual/qopenglcontext/qopenglcontext.pro
+++ b/tests/manual/qopenglcontext/qopenglcontext.pro
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = qopenglcontext
-QT += gui-private platformsupport-private
+QT += gui-private egl_support-private
HEADERS += $$PWD/qopenglcontextwindow.h
diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.cpp b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
index f49908ca28..0763d7244c 100644
--- a/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
+++ b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp
@@ -33,7 +33,7 @@
#include <QtGui/QMatrix4x4>
#include <qpa/qplatformnativeinterface.h>
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtEglSupport/private/qeglconvenience_p.h>
#include <QtPlatformHeaders/QEGLNativeContext>
QOpenGLContextWindow::QOpenGLContextWindow()
diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.h b/tests/manual/qopenglcontext/qopenglcontextwindow.h
index f436d1af0e..37ff1b2082 100644
--- a/tests/manual/qopenglcontext/qopenglcontextwindow.h
+++ b/tests/manual/qopenglcontext/qopenglcontextwindow.h
@@ -31,9 +31,9 @@
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLTextureBlitter>
#include <QtGui/QImage>
#include <QtCore/QVariant>
-#include <QtGui/private/qopengltextureblitter_p.h>
class QOpenGLContextWindow : public QWindow
{
diff --git a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp
index 63ac1e4e66..f4e093a967 100644
--- a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp
+++ b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.cpp
@@ -123,9 +123,9 @@ void QOpenGLTextureBlitWindow::render()
m_blitter.blit(texture.textureId(), topRightOriginTopLeftVertex, topLeftOrigin);
m_blitter.blit(texture_mirrored.textureId(), bottomLeftOriginTopLeftVertex, topLeftOrigin);
- m_blitter.setSwizzleRB(true);
+ m_blitter.setRedBlueSwizzle(true);
m_blitter.blit(texture.textureId(), bottomRightOriginTopLeftVertex, texTopLeftOriginTopLeft);
- m_blitter.setSwizzleRB(false);
+ m_blitter.setRedBlueSwizzle(false);
m_blitter.release();
if (m_blitter.supportsExternalOESTarget()) {
diff --git a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h
index 957d833ef3..0912f096e4 100644
--- a/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h
+++ b/tests/manual/qopengltextureblitter/qopengltextureblitwindow.h
@@ -31,7 +31,7 @@
#include <QtGui/QWindow>
#include <QtGui/QOpenGLContext>
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/QOpenGLTextureBlitter>
class QOpenGLTextureBlitWindow : public QWindow
{
diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp
index 13458d27e5..5add1e4f74 100644
--- a/tests/manual/qsysinfo/main.cpp
+++ b/tests/manual/qsysinfo/main.cpp
@@ -57,13 +57,6 @@ QByteArray windowsVersionToString(QSysInfo::WinVersion v)
CASE_VERSION(WV_WINDOWS10);
case QSysInfo::WV_NT_based: // shouldn't happen
break;
-
- CASE_VERSION(WV_CE);
- CASE_VERSION(WV_CENET);
- CASE_VERSION(WV_CE_5);
- CASE_VERSION(WV_CE_6);
- case QSysInfo::WV_CE_based: // shouldn't happen
- break;
}
return "WinVersion(0x" + QByteArray::number(v, 16) + ')';
@@ -87,6 +80,7 @@ QByteArray macVersionToString(QSysInfo::MacVersion v)
CASE_VERSION(MV_10_8);
CASE_VERSION(MV_10_9);
CASE_VERSION(MV_10_10);
+ CASE_VERSION(MV_10_11);
CASE_VERSION(MV_IOS_4_3);
CASE_VERSION(MV_IOS_5_0);
@@ -96,6 +90,11 @@ QByteArray macVersionToString(QSysInfo::MacVersion v)
CASE_VERSION(MV_IOS_7_0);
CASE_VERSION(MV_IOS_7_1);
CASE_VERSION(MV_IOS_8_0);
+ CASE_VERSION(MV_IOS_8_1);
+ CASE_VERSION(MV_IOS_8_2);
+ CASE_VERSION(MV_IOS_8_3);
+ CASE_VERSION(MV_IOS_8_4);
+ CASE_VERSION(MV_IOS_9_0);
case QSysInfo::MV_IOS: // shouldn't happen:
break;
}
diff --git a/tests/manual/textrendering/glyphshaping/main.cpp b/tests/manual/textrendering/glyphshaping/main.cpp
index 62d2475462..c3acda953d 100644
--- a/tests/manual/textrendering/glyphshaping/main.cpp
+++ b/tests/manual/textrendering/glyphshaping/main.cpp
@@ -160,7 +160,7 @@ bool dumpHtml(const QString &pathName)
QString platformName = QString::fromLatin1(
#if defined(Q_OS_WIN)
"Win32"
-#elif defined(Q_DEAD_CODE_FROM_QT4_X11)
+#elif 0 // Used to be included in Qt4 for Q_WS_X11
"X11"
#else
""
diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp
index 7196608aa5..d02f64c27b 100644
--- a/tests/manual/windowflags/controllerwindow.cpp
+++ b/tests/manual/windowflags/controllerwindow.cpp
@@ -26,20 +26,33 @@
**
****************************************************************************/
-#include <QMainWindow>
-#include <QLabel>
-#include <QPushButton>
-#include <QRadioButton>
+#include "controllerwindow.h"
+#include "controls.h"
+
+#include <QAction>
+#include <QApplication>
#include <QCheckBox>
#include <QGroupBox>
-#include <QApplication>
#include <QHBoxLayout>
+#include <QLabel>
+#include <QMainWindow>
+#include <QMenu>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QTabWidget>
-#include "controllerwindow.h"
-#include "controls.h"
+#include <QMoveEvent>
+
+#if QT_VERSION >= 0x050000
+# include <QWindow>
+# include <qlogging.h>
+# include <QLibraryInfo>
+#endif
+#include <QDebug>
-//! [0]
-ControllerWindow::ControllerWindow() : previewWidget(0)
+ControllerWidget::ControllerWidget(QWidget *parent)
+ : QWidget(parent)
+ , previewWidget(0)
{
parentWindow = new QMainWindow;
parentWindow->setWindowTitle(tr("Preview parent window"));
@@ -53,18 +66,6 @@ ControllerWindow::ControllerWindow() : previewWidget(0)
createTypeGroupBox();
- quitButton = new QPushButton(tr("&Quit"));
- connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
-
- QHBoxLayout *bottomLayout = new QHBoxLayout;
- bottomLayout->addStretch();
-
- QPushButton *updateControlsButton = new QPushButton(tr("&Update"));
- connect(updateControlsButton, SIGNAL(clicked()), this, SLOT(updateStateControl()));
-
- bottomLayout->addWidget(updateControlsButton);
- bottomLayout->addWidget(quitButton);
-
hintsControl = new HintControl;
hintsControl->setHints(previewWindow->windowFlags());
connect(hintsControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
@@ -78,39 +79,30 @@ ControllerWindow::ControllerWindow() : previewWidget(0)
typeControl->setType(previewWindow->windowFlags());
connect(typeControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
- QVBoxLayout *mainLayout = new QVBoxLayout;
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(widgetTypeGroupBox);
mainLayout->addWidget(additionalOptionsGroupBox);
mainLayout->addWidget(typeControl);
mainLayout->addWidget(hintsControl);
mainLayout->addWidget(statesControl);
- mainLayout->addLayout(bottomLayout);
- setLayout(mainLayout);
- setWindowTitle(tr("Window Flags (Qt version %1, %2)")
- .arg(QLatin1String(qVersion()),
-#if QT_VERSION >= 0x050000
- qApp->platformName()));
-#else
- QLatin1String("<unknown>")));
-#endif
updatePreview();
}
-bool ControllerWindow::eventFilter(QObject *, QEvent *e)
+bool ControllerWidget::eventFilter(QObject *, QEvent *e)
{
if (e->type() == QEvent::WindowStateChange)
updateStateControl();
return false;
}
-void ControllerWindow::updateStateControl()
+void ControllerWidget::updateStateControl()
{
if (previewWidget)
statesControl->setStates(previewWidget->windowState());
}
-void ControllerWindow::updatePreview()
+void ControllerWidget::updatePreview()
{
const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints();
@@ -154,7 +146,7 @@ void ControllerWindow::updatePreview()
previewWidget->setVisible(statesControl->visibleValue());
}
-void ControllerWindow::createTypeGroupBox()
+void ControllerWidget::createTypeGroupBox()
{
widgetTypeGroupBox = new QGroupBox(tr("Widget Type"));
previewWidgetButton = createRadioButton(tr("QWidget"));
@@ -173,24 +165,181 @@ void ControllerWindow::createTypeGroupBox()
l->addWidget(fixedSizeWindowCheckBox);
additionalOptionsGroupBox->setLayout(l);
}
-//! [5]
-
-//! [6]
-//! [7]
-QCheckBox *ControllerWindow::createCheckBox(const QString &text)
+QCheckBox *ControllerWidget::createCheckBox(const QString &text)
{
QCheckBox *checkBox = new QCheckBox(text);
connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview()));
return checkBox;
}
-//! [7]
-//! [8]
-QRadioButton *ControllerWindow::createRadioButton(const QString &text)
+QRadioButton *ControllerWidget::createRadioButton(const QString &text)
{
QRadioButton *button = new QRadioButton(text);
connect(button, SIGNAL(clicked()), this, SLOT(updatePreview()));
return button;
}
-//! [8]
+
+static bool isTopLevel(const QObject *o)
+{
+ if (o->isWidgetType())
+ return static_cast<const QWidget *>(o)->isWindow();
+#if QT_VERSION >= 0x050000
+ if (o->isWindowType())
+ return static_cast<const QWindow *>(o)->isTopLevel();
+#endif
+ return false;
+}
+
+static Qt::WindowState windowState(const QObject *o)
+{
+ if (o->isWidgetType()) {
+ Qt::WindowStates states = static_cast<const QWidget *>(o)->windowState();
+ states &= ~Qt::WindowActive;
+ return static_cast<Qt::WindowState>(int(states));
+ }
+#if QT_VERSION >= 0x050000
+ if (o->isWindowType())
+ return static_cast<const QWindow *>(o)->windowState();
+#endif
+ return Qt::WindowNoState;
+}
+
+class EventFilter : public QObject {
+public:
+ explicit EventFilter(QObject *parent = 0) : QObject(parent) {}
+
+ bool eventFilter(QObject *o, QEvent *e)
+ {
+ switch (e->type()) {
+ case QEvent::Move:
+ case QEvent::Resize:
+ case QEvent::WindowStateChange:
+ case QEvent::ApplicationActivate:
+ case QEvent::ApplicationDeactivate:
+#if QT_VERSION >= 0x050000
+ case QEvent::ApplicationStateChange:
+#endif
+ if (isTopLevel(o))
+ formatEvent(o, e);
+ break;
+ default:
+ break;
+ }
+ return QObject::eventFilter(o ,e);
+ }
+
+private:
+ void formatEvent(QObject *o, QEvent *e)
+ {
+ static int n = 0;
+ QDebug debug = qDebug().nospace();
+#if QT_VERSION >= 0x050000
+ debug.noquote();
+#endif
+ debug << '#' << n++ << ' ' << o->metaObject()->className();
+ const QString name = o->objectName();
+ if (!name.isEmpty())
+ debug << "/\"" << name << '"';
+ debug << ' ' << e;
+ if (e->type() == QEvent::WindowStateChange)
+ debug << ' ' << windowState(o);
+ }
+};
+
+LogWidget *LogWidget::m_instance = 0;
+
+#if QT_VERSION >= 0x050000
+static void qt5MessageHandler(QtMsgType, const QMessageLogContext &, const QString &text)
+{
+ if (LogWidget *lw = LogWidget::instance())
+ lw->appendText(text);
+}
+#else // Qt 5
+static void qt4MessageHandler(QtMsgType, const char *text)
+{
+ if (LogWidget *lw = LogWidget::instance())
+ lw->appendText(QString::fromLocal8Bit(text));
+}
+#endif // Qt 4
+
+LogWidget::LogWidget(QWidget *parent)
+ : QPlainTextEdit(parent)
+{
+ LogWidget::m_instance = this;
+ setReadOnly(true);
+ appendText(startupMessage());
+}
+
+LogWidget::~LogWidget()
+{
+ LogWidget::m_instance = 0;
+}
+
+void LogWidget::install()
+{
+#if QT_VERSION >= 0x050000
+ qInstallMessageHandler(qt5MessageHandler);
+#else
+ qInstallMsgHandler(qt4MessageHandler);
+#endif
+}
+
+QString LogWidget::startupMessage()
+{
+ QString result;
+#if QT_VERSION >= 0x050300
+ result += QLatin1String(QLibraryInfo::build());
+#else
+ result += QLatin1String("Qt ") + QLatin1String(QT_VERSION_STR);
+#endif
+#if QT_VERSION >= 0x050000
+ result += QLatin1Char(' ');
+ result += QGuiApplication::platformName();
+#endif
+ return result;
+}
+
+void LogWidget::appendText(const QString &message)
+{
+ appendPlainText(message);
+ ensureCursorVisible();
+}
+
+ControllerWindow::ControllerWindow()
+{
+ setWindowTitle(tr("Window Flags (Qt version %1, %2)")
+ .arg(QLatin1String(qVersion()),
+#if QT_VERSION >= 0x050000
+ qApp->platformName()));
+#else
+ QLatin1String("<unknown>")));
+#endif
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QTabWidget *tabWidget = new QTabWidget(this);
+ ControllerWidget *controllerWidget = new ControllerWidget(tabWidget);
+ tabWidget->addTab(controllerWidget, tr("Control"));
+ LogWidget *logWidget = new LogWidget(tabWidget);
+ tabWidget->addTab(logWidget, tr("Event log"));
+ layout->addWidget(tabWidget);
+
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ layout->addLayout(bottomLayout);
+ bottomLayout->addStretch();
+ QPushButton *updateControlsButton = new QPushButton(tr("&Update"));
+ connect(updateControlsButton, SIGNAL(clicked()), controllerWidget, SLOT(updateStateControl()));
+ bottomLayout->addWidget(updateControlsButton);
+ QPushButton *clearLogButton = new QPushButton(tr("Clear &Log"));
+ connect(clearLogButton, SIGNAL(clicked()), logWidget, SLOT(clear()));
+ bottomLayout->addWidget(clearLogButton);
+ QPushButton *quitButton = new QPushButton(tr("&Quit"));
+ connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+ quitButton->setShortcut(Qt::CTRL + Qt::Key_Q);
+ bottomLayout->addWidget(quitButton);
+}
+
+void ControllerWindow::registerEventFilter()
+{
+ qApp->installEventFilter(new EventFilter(qApp));
+}
diff --git a/tests/manual/windowflags/controllerwindow.h b/tests/manual/windowflags/controllerwindow.h
index 81126085ea..43a125a9ae 100644
--- a/tests/manual/windowflags/controllerwindow.h
+++ b/tests/manual/windowflags/controllerwindow.h
@@ -29,7 +29,7 @@
#ifndef CONTROLLERWINDOW_H
#define CONTROLLERWINDOW_H
-#include <QWidget>
+#include <QPlainTextEdit>
#include "previewwindow.h"
@@ -46,13 +46,12 @@ class HintControl;
class WindowStatesControl;
class TypeControl;
-//! [0]
-class ControllerWindow : public QWidget
+class ControllerWidget : public QWidget
{
Q_OBJECT
public:
- ControllerWindow();
+ explicit ControllerWidget(QWidget *parent = 0);
virtual bool eventFilter(QObject *o, QEvent *e);
@@ -75,13 +74,37 @@ private:
HintControl *hintsControl;
WindowStatesControl *statesControl;
- QPushButton *quitButton;
-
QRadioButton *previewWidgetButton;
QRadioButton *previewDialogButton;
QCheckBox *modalWindowCheckBox;
QCheckBox *fixedSizeWindowCheckBox;
};
-//! [0]
-#endif
+class LogWidget : public QPlainTextEdit
+{
+ Q_OBJECT
+public:
+ explicit LogWidget(QWidget *parent = 0);
+ ~LogWidget();
+
+ static LogWidget *instance() { return m_instance; }
+ static void install();
+
+public slots:
+ void appendText(const QString &);
+
+private:
+ static QString startupMessage();
+
+ static LogWidget *m_instance;
+};
+
+class ControllerWindow : public QWidget {
+ Q_OBJECT
+public:
+ ControllerWindow();
+
+ void registerEventFilter();
+};
+
+#endif // CONTROLLERWINDOW_H
diff --git a/tests/manual/windowflags/main.cpp b/tests/manual/windowflags/main.cpp
index 86825dbb0d..a7d7307525 100644
--- a/tests/manual/windowflags/main.cpp
+++ b/tests/manual/windowflags/main.cpp
@@ -27,13 +27,21 @@
****************************************************************************/
#include <QApplication>
+#include <QStringList>
#include "controllerwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QStringList arguments = QCoreApplication::arguments();
+ arguments.pop_front();
+
ControllerWindow controller;
+ if (!arguments.contains(QLatin1String("-l")))
+ LogWidget::install();
+ if (!arguments.contains(QLatin1String("-e")))
+ controller.registerEventFilter();
controller.show();
return app.exec();
}
diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp
index 11810763e7..54084fd1bc 100644
--- a/tests/manual/windowflags/previewwindow.cpp
+++ b/tests/manual/windowflags/previewwindow.cpp
@@ -26,136 +26,235 @@
**
****************************************************************************/
-#include <QTextEdit>
+#include <QPlainTextEdit>
#include <QPushButton>
+#include <QGridLayout>
#include <QVBoxLayout>
+#include <QTextStream>
+#include <QTimer>
#include "previewwindow.h"
-static QString windowFlagsToString(Qt::WindowFlags flags)
+static void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
{
- QString text;
-
- Qt::WindowFlags type = (flags & Qt::WindowType_Mask);
- if (type == Qt::Window) {
- text = "Qt::Window";
- } else if (type == Qt::Dialog) {
- text = "Qt::Dialog";
- } else if (type == Qt::Sheet) {
- text = "Qt::Sheet";
- } else if (type == Qt::Drawer) {
- text = "Qt::Drawer";
- } else if (type == Qt::Popup) {
- text = "Qt::Popup";
- } else if (type == Qt::Tool) {
- text = "Qt::Tool";
- } else if (type == Qt::ToolTip) {
- text = "Qt::ToolTip";
- } else if (type == Qt::SplashScreen) {
- text = "Qt::SplashScreen";
+ str << "Window flags: " << hex << showbase << unsigned(flags) << noshowbase << dec << ' ';
+ switch (flags & Qt::WindowType_Mask) {
+ case Qt::Window:
+ str << "Qt::Window";
+ break;
+ case Qt::Dialog:
+ str << "Qt::Dialog";
+ break;
+ case Qt::Sheet:
+ str << "Qt::Sheet";
+ break;
+ case Qt::Drawer:
+ str << "Qt::Drawer";
+ break;
+ case Qt::Popup:
+ str << "Qt::Popup";
+ break;
+ case Qt::Tool:
+ str << "Qt::Tool";
+ break;
+ case Qt::ToolTip:
+ str << "Qt::ToolTip";
+ break;
+ case Qt::SplashScreen:
+ str << "Qt::SplashScreen";
+ break;
}
if (flags & Qt::MSWindowsFixedSizeDialogHint)
- text += "\n| Qt::MSWindowsFixedSizeDialogHint";
+ str << "\n| Qt::MSWindowsFixedSizeDialogHint";
+#if QT_VERSION >= 0x050000
+ if (flags & Qt::BypassWindowManagerHint)
+ str << "\n| Qt::BypassWindowManagerHint";
+#else
if (flags & Qt::X11BypassWindowManagerHint)
- text += "\n| Qt::X11BypassWindowManagerHint";
+ str << "\n| Qt::X11BypassWindowManagerHint";
+#endif
if (flags & Qt::FramelessWindowHint)
- text += "\n| Qt::FramelessWindowHint";
+ str << "\n| Qt::FramelessWindowHint";
if (flags & Qt::WindowTitleHint)
- text += "\n| Qt::WindowTitleHint";
+ str << "\n| Qt::WindowTitleHint";
if (flags & Qt::WindowSystemMenuHint)
- text += "\n| Qt::WindowSystemMenuHint";
+ str << "\n| Qt::WindowSystemMenuHint";
if (flags & Qt::WindowMinimizeButtonHint)
- text += "\n| Qt::WindowMinimizeButtonHint";
+ str << "\n| Qt::WindowMinimizeButtonHint";
if (flags & Qt::WindowMaximizeButtonHint)
- text += "\n| Qt::WindowMaximizeButtonHint";
+ str << "\n| Qt::WindowMaximizeButtonHint";
if (flags & Qt::WindowCloseButtonHint)
- text += "\n| Qt::WindowCloseButtonHint";
+ str << "\n| Qt::WindowCloseButtonHint";
if (flags & Qt::WindowContextHelpButtonHint)
- text += "\n| Qt::WindowContextHelpButtonHint";
+ str << "\n| Qt::WindowContextHelpButtonHint";
if (flags & Qt::WindowShadeButtonHint)
- text += "\n| Qt::WindowShadeButtonHint";
+ str << "\n| Qt::WindowShadeButtonHint";
if (flags & Qt::WindowStaysOnTopHint)
- text += "\n| Qt::WindowStaysOnTopHint";
+ str << "\n| Qt::WindowStaysOnTopHint";
if (flags & Qt::CustomizeWindowHint)
- text += "\n| Qt::CustomizeWindowHint";
- return text;
+ str << "\n| Qt::CustomizeWindowHint";
+ if (flags & Qt::WindowStaysOnBottomHint)
+ str << "\n| Qt::WindowStaysOnBottomHint";
+#if QT_VERSION >= 0x050000
+ if (flags & Qt::WindowFullscreenButtonHint)
+ str << "\n| Qt::WindowFullscreenButtonHint";
+ if (flags & Qt::WindowTransparentForInput)
+ str << "\n| Qt::WindowTransparentForInput";
+ if (flags & Qt::WindowOverridesSystemGestures)
+ str << "\n| Qt::WindowOverridesSystemGestures";
+ if (flags & Qt::WindowDoesNotAcceptFocus)
+ str << "\n| Qt::WindowDoesNotAcceptFocus";
+ if (flags & Qt::MaximizeUsingFullscreenGeometryHint)
+ str << "\n| Qt::MaximizeUsingFullscreenGeometryHint";
+ if (flags & Qt::NoDropShadowWindowHint)
+ str << "\n| Qt::NoDropShadowWindowHint";
+#endif // Qt 5
}
-PreviewWindow::PreviewWindow(QWidget *parent)
- : QWidget(parent)
+static void formatWindowStates(QTextStream &str, Qt::WindowStates states)
{
- textEdit = new QTextEdit;
- textEdit->setReadOnly(true);
- textEdit->setLineWrapMode(QTextEdit::NoWrap);
+ str << "Window states: " << hex << showbase << unsigned(states) << noshowbase << dec << ' ';
+ if (states & Qt::WindowActive) {
+ str << "Qt::WindowActive ";
+ states &= ~Qt::WindowActive;
+ }
+ switch (states) {
+ case Qt::WindowNoState:
+ str << "Qt::WindowNoState";
+ break;
+ case Qt::WindowMinimized:
+ str << "Qt::WindowMinimized";
+ break;
+ case Qt::WindowMaximized:
+ str << "Qt::WindowMaximized";
+ break;
+ case Qt::WindowFullScreen:
+ str << "Qt::WindowFullScreen";
+ break;
+ default:
+ break;
+ }
+}
- closeButton = new QPushButton(tr("&Close"));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+QTextStream &operator<<(QTextStream &str, const QRect &r)
+{
+ str << r.width() << 'x' << r.height() << forcesign << r.x() << r.y() << noforcesign;
+ return str;
+}
- showNormalButton = new QPushButton(tr("Show normal"));
- connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
- showMinimizedButton = new QPushButton(tr("Show minimized"));
- connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
- showMaximizedButton = new QPushButton(tr("Show maximized"));
- connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
- showFullScreenButton = new QPushButton(tr("Show fullscreen"));
- connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
+static QString formatWidgetInfo(const QWidget *w)
+{
+ QString result;
+ QTextStream str(&result);
+ formatWindowFlags(str, w->windowFlags());
+ str << '\n';
+ formatWindowStates(str, w->windowState());
+ const QRect frame = w->frameGeometry();
+ const QRect geometry = w->geometry();
+ str << "\n\nFrame: " << frame << "\nGeometry: " << geometry << "\nMargins: "
+ << (geometry.x() - frame.x()) << ", " << (geometry.top() - frame.top())
+ << ", " << (frame.right() - geometry.right()) << ", "
+ << (frame.bottom() - geometry.bottom());
+ return result;
+}
- QVBoxLayout *layout = new QVBoxLayout;
+static QPlainTextEdit *createControlPanel(QWidget *widget)
+{
+ QVBoxLayout *layout = new QVBoxLayout(widget);
+ QPlainTextEdit *textEdit = new QPlainTextEdit;
+ textEdit->setReadOnly(true);
+ textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
layout->addWidget(textEdit);
- layout->addWidget(showNormalButton);
- layout->addWidget(showMinimizedButton);
- layout->addWidget(showMaximizedButton);
- layout->addWidget(showFullScreenButton);
- layout->addWidget(closeButton);
- setLayout(layout);
-
- setWindowTitle(tr("Preview <QWidget>"));
+
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ layout ->addLayout(bottomLayout);
+ QGridLayout *buttonLayout = new QGridLayout;
+ bottomLayout->addStretch();
+ bottomLayout->addLayout(buttonLayout);
+ QPushButton *showNormalButton = new QPushButton(PreviewWindow::tr("Show normal"));
+ QObject::connect(showNormalButton, SIGNAL(clicked()), widget, SLOT(showNormal()));
+ buttonLayout->addWidget(showNormalButton, 0, 0);
+ QPushButton *showMinimizedButton = new QPushButton(PreviewWindow::tr("Show minimized"));
+ QObject::connect(showMinimizedButton, SIGNAL(clicked()), widget, SLOT(showMinimized()));
+ buttonLayout->addWidget(showMinimizedButton, 0, 1);
+ QPushButton *showMaximizedButton = new QPushButton(PreviewWindow::tr("Show maximized"));
+ QObject::connect(showMaximizedButton, SIGNAL(clicked()), widget, SLOT(showMaximized()));
+ buttonLayout->addWidget(showMaximizedButton, 0, 2);
+ QPushButton *showFullScreenButton = new QPushButton(PreviewWindow::tr("Show fullscreen"));
+ QObject::connect(showFullScreenButton, SIGNAL(clicked()), widget, SLOT(showFullScreen()));
+ buttonLayout->addWidget(showFullScreenButton, 0, 3);
+
+ QPushButton *updateInfoButton = new QPushButton(PreviewWindow::tr("&Update Info"));
+ QObject::connect(updateInfoButton, SIGNAL(clicked()), widget, SLOT(updateInfo()));
+ buttonLayout->addWidget(updateInfoButton, 1, 0);
+ QPushButton *closeButton = new QPushButton(PreviewWindow::tr("&Close"));
+ QObject::connect(closeButton, SIGNAL(clicked()), widget, SLOT(close()));
+ buttonLayout->addWidget(closeButton, 1, 3);
+
+ return textEdit;
+}
+
+PreviewWindow::PreviewWindow(QWidget *parent)
+ : QWidget(parent)
+{
+ textEdit = createControlPanel(this);
+ setWindowTitle(tr("Preview <QWidget> Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+}
+
+void PreviewWindow::resizeEvent(QResizeEvent *e)
+{
+ QWidget::resizeEvent(e);
+ updateInfo();
+}
+
+void PreviewWindow::moveEvent(QMoveEvent *e)
+{
+ QWidget::moveEvent(e);
+ updateInfo();
}
void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
{
+ if (flags == windowFlags())
+ return;
QWidget::setWindowFlags(flags);
+ QTimer::singleShot(0, this, SLOT(updateInfo()));
+}
- QString text = windowFlagsToString(flags);
- textEdit->setPlainText(text);
+void PreviewWindow::updateInfo()
+{
+ textEdit->setPlainText(formatWidgetInfo(this));
}
PreviewDialog::PreviewDialog(QWidget *parent)
: QDialog(parent)
{
- textEdit = new QTextEdit;
- textEdit->setReadOnly(true);
- textEdit->setLineWrapMode(QTextEdit::NoWrap);
-
- closeButton = new QPushButton(tr("&Close"));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ textEdit = createControlPanel(this);
+ setWindowTitle(tr("Preview <QDialog> Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+}
- showNormalButton = new QPushButton(tr("Show normal"));
- connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
- showMinimizedButton = new QPushButton(tr("Show minimized"));
- connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
- showMaximizedButton = new QPushButton(tr("Show maximized"));
- connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
- showFullScreenButton = new QPushButton(tr("Show fullscreen"));
- connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
+void PreviewDialog::resizeEvent(QResizeEvent *e)
+{
+ QDialog::resizeEvent(e);
+ updateInfo();
+}
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(textEdit);
- layout->addWidget(showNormalButton);
- layout->addWidget(showMinimizedButton);
- layout->addWidget(showMaximizedButton);
- layout->addWidget(showFullScreenButton);
- layout->addWidget(closeButton);
- setLayout(layout);
-
- setWindowTitle(tr("Preview <QDialog>"));
+void PreviewDialog::moveEvent(QMoveEvent *e)
+{
+ QDialog::moveEvent(e);
+ updateInfo();
}
void PreviewDialog::setWindowFlags(Qt::WindowFlags flags)
{
+ if (flags == windowFlags())
+ return;
QWidget::setWindowFlags(flags);
+ QTimer::singleShot(0, this, SLOT(updateInfo()));
+}
- QString text = windowFlagsToString(flags);
- textEdit->setPlainText(text);
+void PreviewDialog::updateInfo()
+{
+ textEdit->setPlainText(formatWidgetInfo(this));
}
diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h
index 00d5cc39f9..acd79735ad 100644
--- a/tests/manual/windowflags/previewwindow.h
+++ b/tests/manual/windowflags/previewwindow.h
@@ -32,8 +32,7 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
-class QPushButton;
-class QTextEdit;
+class QPlainTextEdit;
QT_END_NAMESPACE
class PreviewWindow : public QWidget
@@ -45,13 +44,15 @@ public:
void setWindowFlags(Qt::WindowFlags flags);
+public slots:
+ void updateInfo();
+
+protected:
+ void resizeEvent(QResizeEvent *);
+ void moveEvent(QMoveEvent *);
+
private:
- QTextEdit *textEdit;
- QPushButton *closeButton;
- QPushButton *showNormalButton;
- QPushButton *showMinimizedButton;
- QPushButton *showMaximizedButton;
- QPushButton *showFullScreenButton;
+ QPlainTextEdit *textEdit;
};
class PreviewDialog : public QDialog
@@ -63,13 +64,15 @@ public:
void setWindowFlags(Qt::WindowFlags flags);
+public slots:
+ void updateInfo();
+
+protected:
+ void resizeEvent(QResizeEvent *);
+ void moveEvent(QMoveEvent *);
+
private:
- QTextEdit *textEdit;
- QPushButton *closeButton;
- QPushButton *showNormalButton;
- QPushButton *showMinimizedButton;
- QPushButton *showMaximizedButton;
- QPushButton *showFullScreenButton;
+ QPlainTextEdit *textEdit;
};
#endif