summaryrefslogtreecommitdiffstats
path: root/tests/manual/windowflags
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-04-20 13:54:52 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-20 16:21:17 +0200
commit9b7739899e5040cb6fbb4825a6ac96d9eaca60d6 (patch)
tree2a9c7cf292cb8065355cc8c7d64967d3cb65dfcc /tests/manual/windowflags
parent4c6d12e6d22c4b78885c6fe5ac0c1d64a87e3bcf (diff)
Window geometry manual tests: Add Window state controls.
- Factor out controls from the window flags test, split state into Qt::WindowState (QWindow) and Qt::WindowStates(Qt::Widget). - Add to geometry test. Change-Id: I25b9a8696bfb7f4faef113ac82559ebb90a140c5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'tests/manual/windowflags')
-rw-r--r--tests/manual/windowflags/controllerwindow.cpp163
-rw-r--r--tests/manual/windowflags/controllerwindow.h43
-rw-r--r--tests/manual/windowflags/controls.cpp314
-rw-r--r--tests/manual/windowflags/controls.h171
-rw-r--r--tests/manual/windowflags/windowflags.pro8
5 files changed, 519 insertions, 180 deletions
diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp
index cee8976cfe..1b547117d7 100644
--- a/tests/manual/windowflags/controllerwindow.cpp
+++ b/tests/manual/windowflags/controllerwindow.cpp
@@ -49,6 +49,7 @@
#include <QtWidgets/QHBoxLayout>
#include "controllerwindow.h"
+#include "controls.h"
//! [0]
ControllerWindow::ControllerWindow()
@@ -62,8 +63,6 @@ ControllerWindow::ControllerWindow()
previewDialog = new PreviewDialog;
createTypeGroupBox();
- createStateGroupBox();
- createHintsGroupBox();
quitButton = new QPushButton(tr("&Quit"));
connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
@@ -72,12 +71,25 @@ ControllerWindow::ControllerWindow()
bottomLayout->addStretch();
bottomLayout->addWidget(quitButton);
+ hintsControl = new HintControl;
+ hintsControl->setHints(previewWindow->windowFlags());
+ connect(hintsControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
+
+ statesControl = new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox);
+ statesControl->setStates(previewWindow->windowState());
+ statesControl->setVisibleValue(true);
+ connect(statesControl, SIGNAL(changed()), this, SLOT(updatePreview()));
+
+ typeControl = new TypeControl;
+ typeControl->setType(previewWindow->windowFlags());
+ connect(typeControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
+
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(widgetTypeGroupBox);
- mainLayout->addWidget(windowStateGroupBox);
mainLayout->addWidget(additionalOptionsGroupBox);
- mainLayout->addWidget(typeGroupBox);
- mainLayout->addWidget(hintsGroupBox);
+ mainLayout->addWidget(typeControl);
+ mainLayout->addWidget(hintsControl);
+ mainLayout->addWidget(statesControl);
mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
@@ -88,52 +100,7 @@ ControllerWindow::ControllerWindow()
void ControllerWindow::updatePreview()
{
- Qt::WindowFlags flags = 0;
-
- if (windowRadioButton->isChecked()) {
- flags = Qt::Window;
- } else if (dialogRadioButton->isChecked()) {
- flags = Qt::Dialog;
- } else if (sheetRadioButton->isChecked()) {
- flags = Qt::Sheet;
- } else if (drawerRadioButton->isChecked()) {
- flags = Qt::Drawer;
- } else if (popupRadioButton->isChecked()) {
- flags = Qt::Popup;
- } else if (toolRadioButton->isChecked()) {
- flags = Qt::Tool;
- } else if (toolTipRadioButton->isChecked()) {
- flags = Qt::ToolTip;
- } else if (splashScreenRadioButton->isChecked()) {
- flags = Qt::SplashScreen;
- }
-
- if (msWindowsFixedSizeDialogCheckBox->isChecked())
- flags |= Qt::MSWindowsFixedSizeDialogHint;
- if (x11BypassWindowManagerCheckBox->isChecked())
- flags |= Qt::X11BypassWindowManagerHint;
- if (framelessWindowCheckBox->isChecked())
- flags |= Qt::FramelessWindowHint;
- if (windowTitleCheckBox->isChecked())
- flags |= Qt::WindowTitleHint;
- if (windowSystemMenuCheckBox->isChecked())
- flags |= Qt::WindowSystemMenuHint;
- if (windowMinimizeButtonCheckBox->isChecked())
- flags |= Qt::WindowMinimizeButtonHint;
- if (windowMaximizeButtonCheckBox->isChecked())
- flags |= Qt::WindowMaximizeButtonHint;
- if (windowCloseButtonCheckBox->isChecked())
- flags |= Qt::WindowCloseButtonHint;
- if (windowContextHelpButtonCheckBox->isChecked())
- flags |= Qt::WindowContextHelpButtonHint;
- if (windowShadeButtonCheckBox->isChecked())
- flags |= Qt::WindowShadeButtonHint;
- if (windowStaysOnTopCheckBox->isChecked())
- flags |= Qt::WindowStaysOnTopHint;
- if (windowStaysOnBottomCheckBox->isChecked())
- flags |= Qt::WindowStaysOnBottomHint;
- if (customizeWindowHintCheckBox->isChecked())
- flags |= Qt::CustomizeWindowHint;
+ const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints();
previewWindow->hide();
previewDialog->hide();
@@ -168,16 +135,8 @@ void ControllerWindow::updatePreview()
pos.setY(0);
widget->move(pos);
- Qt::WindowState windowState = Qt::WindowNoState;
- if (minimizeButton->isChecked())
- windowState = Qt::WindowMinimized;
- else if (maximizeButton->isChecked())
- windowState = Qt::WindowMaximized;
- else if (fullscreenButton->isChecked())
- windowState = Qt::WindowFullScreen;
-
- widget->setWindowState(windowState);
- widget->setVisible(visibleCheckBox->isChecked());
+ widget->setWindowState(statesControl->states());
+ widget->setVisible(statesControl->visibleValue());
}
void ControllerWindow::createTypeGroupBox()
@@ -198,91 +157,9 @@ void ControllerWindow::createTypeGroupBox()
l->addWidget(modalWindowCheckBox);
l->addWidget(fixedSizeWindowCheckBox);
additionalOptionsGroupBox->setLayout(l);
-
- typeGroupBox = new QGroupBox(tr("Type"));
-
- windowRadioButton = createRadioButton(tr("Window"));
- dialogRadioButton = createRadioButton(tr("Dialog"));
- sheetRadioButton = createRadioButton(tr("Sheet"));
- drawerRadioButton = createRadioButton(tr("Drawer"));
- popupRadioButton = createRadioButton(tr("Popup"));
- toolRadioButton = createRadioButton(tr("Tool"));
- toolTipRadioButton = createRadioButton(tr("Tooltip"));
- splashScreenRadioButton = createRadioButton(tr("Splash screen"));
- windowRadioButton->setChecked(true);
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(windowRadioButton, 0, 0);
- layout->addWidget(dialogRadioButton, 1, 0);
- layout->addWidget(sheetRadioButton, 2, 0);
- layout->addWidget(drawerRadioButton, 3, 0);
- layout->addWidget(popupRadioButton, 0, 1);
- layout->addWidget(toolRadioButton, 1, 1);
- layout->addWidget(toolTipRadioButton, 2, 1);
- layout->addWidget(splashScreenRadioButton, 3, 1);
- typeGroupBox->setLayout(layout);
}
//! [5]
-void ControllerWindow::createStateGroupBox()
-{
- windowStateGroupBox = new QGroupBox(tr("Window State"));
- visibleCheckBox = createCheckBox(tr("Visible"));
- visibleCheckBox->setChecked(true);
-
- restoreButton = createRadioButton(tr("Normal"));
- restoreButton->setChecked(true);
- minimizeButton = createRadioButton(tr("Minimized"));
- maximizeButton = createRadioButton(tr("Maximized"));
- fullscreenButton = createRadioButton(tr("Fullscreen"));;
-
- QHBoxLayout *l = new QHBoxLayout;
- l->addWidget(visibleCheckBox);
- l->addWidget(restoreButton);
- l->addWidget(minimizeButton);
- l->addWidget(maximizeButton);
- l->addWidget(fullscreenButton);
- windowStateGroupBox->setLayout(l);
-}
-
-//! [6]
-void ControllerWindow::createHintsGroupBox()
-{
- hintsGroupBox = new QGroupBox(tr("Hints"));
-
- msWindowsFixedSizeDialogCheckBox =
- createCheckBox(tr("MS Windows fixed size dialog"));
- x11BypassWindowManagerCheckBox =
- createCheckBox(tr("X11 bypass window manager"));
- framelessWindowCheckBox = createCheckBox(tr("Frameless window"));
- windowTitleCheckBox = createCheckBox(tr("Window title"));
- windowSystemMenuCheckBox = createCheckBox(tr("Window system menu"));
- windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button"));
- windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button"));
- windowCloseButtonCheckBox = createCheckBox(tr("Window close button"));
- windowContextHelpButtonCheckBox =
- createCheckBox(tr("Window context help button"));
- windowShadeButtonCheckBox = createCheckBox(tr("Window shade button"));
- windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top"));
- windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom"));
- customizeWindowHintCheckBox= createCheckBox(tr("Customize window"));
-
- QGridLayout *layout = new QGridLayout;
- layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0);
- layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0);
- layout->addWidget(framelessWindowCheckBox, 2, 0);
- layout->addWidget(windowTitleCheckBox, 3, 0);
- layout->addWidget(windowSystemMenuCheckBox, 4, 0);
- layout->addWidget(windowMinimizeButtonCheckBox, 0, 1);
- layout->addWidget(windowMaximizeButtonCheckBox, 1, 1);
- layout->addWidget(windowCloseButtonCheckBox, 2, 1);
- layout->addWidget(windowContextHelpButtonCheckBox, 3, 1);
- layout->addWidget(windowShadeButtonCheckBox, 4, 1);
- layout->addWidget(windowStaysOnTopCheckBox, 5, 1);
- layout->addWidget(windowStaysOnBottomCheckBox, 6, 1);
- layout->addWidget(customizeWindowHintCheckBox, 5, 0);
- hintsGroupBox->setLayout(layout);
-}
//! [6]
//! [7]
diff --git a/tests/manual/windowflags/controllerwindow.h b/tests/manual/windowflags/controllerwindow.h
index 02a8eb98ab..5f6edbb3cb 100644
--- a/tests/manual/windowflags/controllerwindow.h
+++ b/tests/manual/windowflags/controllerwindow.h
@@ -55,6 +55,10 @@ class QRadioButton;
class QMainWindow;
QT_END_NAMESPACE
+class HintControl;
+class WindowStatesControl;
+class TypeControl;
+
//! [0]
class ControllerWindow : public QWidget
{
@@ -68,55 +72,24 @@ private slots:
private:
void createTypeGroupBox();
- void createStateGroupBox();
- void createHintsGroupBox();
QCheckBox *createCheckBox(const QString &text);
QRadioButton *createRadioButton(const QString &text);
QMainWindow *parentWindow;
PreviewWindow *previewWindow;
PreviewDialog *previewDialog;
-
QGroupBox *widgetTypeGroupBox;
- QGroupBox *windowStateGroupBox;
QGroupBox *additionalOptionsGroupBox;
- QGroupBox *typeGroupBox;
- QGroupBox *hintsGroupBox;
+ TypeControl *typeControl;
+ HintControl *hintsControl;
+ WindowStatesControl *statesControl;
+
QPushButton *quitButton;
QRadioButton *previewWidgetButton;
QRadioButton *previewDialogButton;
QCheckBox *modalWindowCheckBox;
QCheckBox *fixedSizeWindowCheckBox;
-
- QCheckBox *visibleCheckBox;
- QRadioButton *restoreButton;
- QRadioButton *minimizeButton;
- QRadioButton *maximizeButton;
- QRadioButton *fullscreenButton;
-
- QRadioButton *windowRadioButton;
- QRadioButton *dialogRadioButton;
- QRadioButton *sheetRadioButton;
- QRadioButton *drawerRadioButton;
- QRadioButton *popupRadioButton;
- QRadioButton *toolRadioButton;
- QRadioButton *toolTipRadioButton;
- QRadioButton *splashScreenRadioButton;
-
- QCheckBox *msWindowsFixedSizeDialogCheckBox;
- QCheckBox *x11BypassWindowManagerCheckBox;
- QCheckBox *framelessWindowCheckBox;
- QCheckBox *windowTitleCheckBox;
- QCheckBox *windowSystemMenuCheckBox;
- QCheckBox *windowMinimizeButtonCheckBox;
- QCheckBox *windowMaximizeButtonCheckBox;
- QCheckBox *windowCloseButtonCheckBox;
- QCheckBox *windowContextHelpButtonCheckBox;
- QCheckBox *windowShadeButtonCheckBox;
- QCheckBox *windowStaysOnTopCheckBox;
- QCheckBox *windowStaysOnBottomCheckBox;
- QCheckBox *customizeWindowHintCheckBox;
};
//! [0]
diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp
new file mode 100644
index 0000000000..bdd8894c0d
--- /dev/null
+++ b/tests/manual/windowflags/controls.cpp
@@ -0,0 +1,314 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "controls.h"
+
+#include <QGridLayout>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QRadioButton>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QButtonGroup>
+#include <QDebug>
+
+HintControl::HintControl(QWidget *parent)
+ : QGroupBox(tr("Hints"), parent)
+ , msWindowsFixedSizeDialogCheckBox(new QCheckBox(tr("MS Windows fixed size dialog")))
+ , x11BypassWindowManagerCheckBox(new QCheckBox(tr("X11 bypass window manager")))
+ , framelessWindowCheckBox(new QCheckBox(tr("Frameless window")))
+ , windowTitleCheckBox(new QCheckBox(tr("Window title")))
+ , windowSystemMenuCheckBox(new QCheckBox(tr("Window system menu")))
+ , windowMinimizeButtonCheckBox(new QCheckBox(tr("Window minimize button")))
+ , windowMaximizeButtonCheckBox(new QCheckBox(tr("Window maximize button")))
+ , windowCloseButtonCheckBox(new QCheckBox(tr("Window close button")))
+ , windowContextHelpButtonCheckBox(new QCheckBox(tr("Window context help button")))
+ , windowShadeButtonCheckBox(new QCheckBox(tr("Window shade button")))
+ , windowStaysOnTopCheckBox(new QCheckBox(tr("Window stays on top")))
+ , windowStaysOnBottomCheckBox(new QCheckBox(tr("Window stays on bottom")))
+ , customizeWindowHintCheckBox(new QCheckBox(tr("Customize window")))
+{
+ connect(msWindowsFixedSizeDialogCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(x11BypassWindowManagerCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(framelessWindowCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowTitleCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowSystemMenuCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowMinimizeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowMaximizeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowCloseButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowContextHelpButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowShadeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowStaysOnTopCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(windowStaysOnBottomCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ connect(customizeWindowHintCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
+ QGridLayout *layout = new QGridLayout(this);
+ layout->setSpacing(0);
+ layout->setMargin(ControlLayoutMargin);
+ layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0);
+ layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0);
+ layout->addWidget(framelessWindowCheckBox, 2, 0);
+ layout->addWidget(windowTitleCheckBox, 3, 0);
+ layout->addWidget(windowSystemMenuCheckBox, 4, 0);
+ layout->addWidget(windowMinimizeButtonCheckBox, 0, 1);
+ layout->addWidget(windowMaximizeButtonCheckBox, 1, 1);
+ layout->addWidget(windowCloseButtonCheckBox, 2, 1);
+ layout->addWidget(windowContextHelpButtonCheckBox, 3, 1);
+ layout->addWidget(windowShadeButtonCheckBox, 4, 1);
+ layout->addWidget(windowStaysOnTopCheckBox, 5, 1);
+ layout->addWidget(windowStaysOnBottomCheckBox, 6, 1);
+ layout->addWidget(customizeWindowHintCheckBox, 5, 0);
+}
+
+Qt::WindowFlags HintControl::hints() const
+{
+ Qt::WindowFlags flags = 0;
+ if (msWindowsFixedSizeDialogCheckBox->isChecked())
+ flags |= Qt::MSWindowsFixedSizeDialogHint;
+ if (x11BypassWindowManagerCheckBox->isChecked())
+ flags |= Qt::X11BypassWindowManagerHint;
+ if (framelessWindowCheckBox->isChecked())
+ flags |= Qt::FramelessWindowHint;
+ if (windowTitleCheckBox->isChecked())
+ flags |= Qt::WindowTitleHint;
+ if (windowSystemMenuCheckBox->isChecked())
+ flags |= Qt::WindowSystemMenuHint;
+ if (windowMinimizeButtonCheckBox->isChecked())
+ flags |= Qt::WindowMinimizeButtonHint;
+ if (windowMaximizeButtonCheckBox->isChecked())
+ flags |= Qt::WindowMaximizeButtonHint;
+ if (windowCloseButtonCheckBox->isChecked())
+ flags |= Qt::WindowCloseButtonHint;
+ if (windowContextHelpButtonCheckBox->isChecked())
+ flags |= Qt::WindowContextHelpButtonHint;
+ if (windowShadeButtonCheckBox->isChecked())
+ flags |= Qt::WindowShadeButtonHint;
+ if (windowStaysOnTopCheckBox->isChecked())
+ flags |= Qt::WindowStaysOnTopHint;
+ if (windowStaysOnBottomCheckBox->isChecked())
+ flags |= Qt::WindowStaysOnBottomHint;
+ if (customizeWindowHintCheckBox->isChecked())
+ flags |= Qt::CustomizeWindowHint;
+ return flags;
+}
+
+void HintControl::setHints(Qt::WindowFlags flags)
+{
+ msWindowsFixedSizeDialogCheckBox->setChecked(flags & Qt::MSWindowsFixedSizeDialogHint);
+ x11BypassWindowManagerCheckBox->setChecked(flags & Qt::X11BypassWindowManagerHint);
+ framelessWindowCheckBox->setChecked(flags & Qt::FramelessWindowHint);
+ windowTitleCheckBox->setChecked(flags & Qt::WindowTitleHint);
+ windowSystemMenuCheckBox->setChecked(flags & Qt::WindowSystemMenuHint);
+ windowMinimizeButtonCheckBox->setChecked(flags & Qt::WindowMinimizeButtonHint);
+ windowMaximizeButtonCheckBox->setChecked(flags & Qt::WindowMaximizeButtonHint);
+ windowCloseButtonCheckBox->setChecked(flags & Qt::WindowCloseButtonHint);
+ windowContextHelpButtonCheckBox->setChecked(flags & Qt::WindowContextHelpButtonHint);
+ windowShadeButtonCheckBox->setChecked(flags & Qt::WindowShadeButtonHint);
+ windowStaysOnTopCheckBox->setChecked(flags & Qt::WindowStaysOnTopHint);
+ windowStaysOnBottomCheckBox->setChecked(flags & Qt::WindowStaysOnBottomHint);
+ customizeWindowHintCheckBox->setChecked(flags & Qt::CustomizeWindowHint);
+}
+
+void HintControl::slotCheckBoxChanged()
+{
+ emit changed(hints());
+}
+
+WindowStateControl::WindowStateControl(unsigned flags, QWidget *parent)
+ : QWidget(parent)
+ , group(new QButtonGroup)
+ , visibleCheckBox(0)
+ , restoreButton(new QRadioButton(tr("Normal")))
+ , minimizeButton(0)
+ , maximizeButton(new QRadioButton(tr("Maximized")))
+ , fullscreenButton(new QRadioButton(tr("Fullscreen")))
+{
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->setSpacing(0);
+ layout->setMargin(ControlLayoutMargin);
+ if (flags & WantVisibleCheckBox) {
+ visibleCheckBox = new QCheckBox(tr("Visible"));
+ connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ layout->addWidget(visibleCheckBox);
+ }
+
+ group->setExclusive(true);
+ if (flags & WantMinimizeRadioButton) {
+ minimizeButton = new QRadioButton(tr("Minimized"));
+ group->addButton(minimizeButton, Qt::WindowMinimized);
+ layout->addWidget(minimizeButton);
+ }
+ group->addButton(restoreButton, Qt::WindowNoState);
+ layout->addWidget(restoreButton);
+ group->addButton(maximizeButton, Qt::WindowMaximized);
+ layout->addWidget(maximizeButton);
+ group->addButton(fullscreenButton, Qt::WindowFullScreen);
+ layout->addWidget(fullscreenButton);
+ connect(group, SIGNAL(buttonReleased(int)), this, SIGNAL(changed()));
+}
+
+Qt::WindowState WindowStateControl::state() const
+{
+ return Qt::WindowState(group->checkedId());
+}
+
+void WindowStateControl::setState(Qt::WindowState s)
+{
+ group->blockSignals(true);
+ if (QAbstractButton *b = group->button(s))
+ b->setChecked(true);
+ group->blockSignals(false);
+}
+
+bool WindowStateControl::visibleValue() const
+{
+ return visibleCheckBox && visibleCheckBox->isChecked();
+}
+
+void WindowStateControl::setVisibleValue(bool v)
+{
+ if (visibleCheckBox) {
+ visibleCheckBox->blockSignals(true);
+ visibleCheckBox->setChecked(v);
+ visibleCheckBox->blockSignals(false);
+ }
+}
+
+WindowStatesControl::WindowStatesControl(unsigned flags, QWidget *parent)
+ : QGroupBox(tr("States"), parent)
+ , visibleCheckBox(0)
+ , minimizeCheckBox(new QCheckBox(tr("Minimized")))
+ , stateControl(new WindowStateControl(0))
+{
+ QHBoxLayout *layout = new QHBoxLayout(this);
+ layout->setSpacing(0);
+ layout->setMargin(ControlLayoutMargin);
+ if (flags & WantVisibleCheckBox) {
+ visibleCheckBox = new QCheckBox(tr("Visible"));
+ connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
+ layout->addWidget(visibleCheckBox);
+ }
+ layout->addWidget(minimizeCheckBox);
+ layout->addWidget(stateControl);
+ connect(stateControl, SIGNAL(changed()), this, SIGNAL(changed()));
+ connect(minimizeCheckBox, SIGNAL(clicked()), this, SIGNAL(changed()));
+}
+
+Qt::WindowStates WindowStatesControl::states() const
+{
+ Qt::WindowStates s = stateControl->state();
+ if (minimizeCheckBox->isChecked())
+ s |= Qt::WindowMinimized;
+ return s;
+}
+
+void WindowStatesControl::setStates(Qt::WindowStates s)
+{
+ minimizeCheckBox->blockSignals(true);
+ minimizeCheckBox->setChecked(s & Qt::WindowMinimized);
+ minimizeCheckBox->blockSignals(false);
+ s &= ~Qt::WindowMinimized;
+ stateControl->setState(Qt::WindowState(int(s)));
+}
+
+bool WindowStatesControl::visibleValue() const
+{
+ return visibleCheckBox && visibleCheckBox->isChecked();
+}
+
+void WindowStatesControl::setVisibleValue(bool v)
+{
+ if (visibleCheckBox) {
+ visibleCheckBox->blockSignals(true);
+ visibleCheckBox->setChecked(v);
+ visibleCheckBox->blockSignals(false);
+ }
+}
+
+TypeControl::TypeControl(QWidget *parent)
+ : QGroupBox(tr("Type"), parent)
+ , group(new QButtonGroup)
+ , windowRadioButton(new QRadioButton(tr("Window")))
+ , dialogRadioButton(new QRadioButton(tr("Dialog")))
+ , sheetRadioButton(new QRadioButton(tr("Sheet")))
+ , drawerRadioButton(new QRadioButton(tr("Drawer")))
+ , popupRadioButton(new QRadioButton(tr("Popup")))
+ , toolRadioButton(new QRadioButton(tr("Tool")))
+ , toolTipRadioButton(new QRadioButton(tr("Tooltip")))
+ , splashScreenRadioButton(new QRadioButton(tr("Splash screen")))
+{
+ group->setExclusive(true);
+ QGridLayout *layout = new QGridLayout(this);
+ layout->setSpacing(0);
+ layout->setMargin(ControlLayoutMargin);
+ group->addButton(windowRadioButton, Qt::Window);
+ layout->addWidget(windowRadioButton, 0, 0);
+ group->addButton(dialogRadioButton, Qt::Dialog);
+ layout->addWidget(dialogRadioButton, 1, 0);
+ group->addButton(sheetRadioButton, Qt::Sheet);
+ layout->addWidget(sheetRadioButton, 2, 0);
+ group->addButton(drawerRadioButton, Qt::Drawer);
+ layout->addWidget(drawerRadioButton, 3, 0);
+ group->addButton(popupRadioButton, Qt::Popup);
+ layout->addWidget(popupRadioButton, 0, 1);
+ group->addButton(toolRadioButton, Qt::Tool);
+ layout->addWidget(toolRadioButton, 1, 1);
+ group->addButton(toolTipRadioButton, Qt::ToolTip);
+ layout->addWidget(toolTipRadioButton, 2, 1);
+ group->addButton(splashScreenRadioButton, Qt::SplashScreen);
+ layout->addWidget(splashScreenRadioButton, 3, 1);
+ connect(group, SIGNAL(buttonReleased(int)), this, SLOT(slotChanged()));
+}
+
+Qt::WindowFlags TypeControl::type() const
+{
+ return Qt::WindowFlags(group->checkedId());
+}
+
+void TypeControl::setType(Qt::WindowFlags s)
+{
+ if (QAbstractButton *b = group->button(s & Qt::WindowType_Mask))
+ b->setChecked(true);
+}
+
+void TypeControl::slotChanged()
+{
+ emit changed(type());
+}
diff --git a/tests/manual/windowflags/controls.h b/tests/manual/windowflags/controls.h
new file mode 100644
index 0000000000..57d9798882
--- /dev/null
+++ b/tests/manual/windowflags/controls.h
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONTROLS_H
+#define CONTROLS_H
+
+#include <QGroupBox>
+
+QT_BEGIN_NAMESPACE
+class QCheckBox;
+class QRadioButton;
+class QButtonGroup;
+QT_END_NAMESPACE
+
+enum { ControlLayoutMargin = 4 };
+
+// Control for the hint part of Qt::WindowFlags
+class HintControl : public QGroupBox
+{
+ Q_OBJECT
+public:
+ explicit HintControl(QWidget *parent= 0);
+
+ Qt::WindowFlags hints() const;
+ void setHints(Qt::WindowFlags hints);
+
+signals:
+ void changed(Qt::WindowFlags);
+
+private slots:
+ void slotCheckBoxChanged();
+
+private:
+ QCheckBox *msWindowsFixedSizeDialogCheckBox;
+ QCheckBox *x11BypassWindowManagerCheckBox;
+ QCheckBox *framelessWindowCheckBox;
+ QCheckBox *windowTitleCheckBox;
+ QCheckBox *windowSystemMenuCheckBox;
+ QCheckBox *windowMinimizeButtonCheckBox;
+ QCheckBox *windowMaximizeButtonCheckBox;
+ QCheckBox *windowCloseButtonCheckBox;
+ QCheckBox *windowContextHelpButtonCheckBox;
+ QCheckBox *windowShadeButtonCheckBox;
+ QCheckBox *windowStaysOnTopCheckBox;
+ QCheckBox *windowStaysOnBottomCheckBox;
+ QCheckBox *customizeWindowHintCheckBox;
+};
+
+// Control for the Qt::WindowState enum, optional with a "visible" QCheckbox
+class WindowStateControl : public QWidget {
+ Q_OBJECT
+public:
+ enum Flags {
+ WantVisibleCheckBox = 0x1,
+ WantMinimizeRadioButton = 0x2
+ };
+
+ explicit WindowStateControl(unsigned flags, QWidget *parent= 0);
+
+ Qt::WindowState state() const;
+ void setState(Qt::WindowState s);
+
+ bool visibleValue() const;
+ void setVisibleValue(bool);
+
+signals:
+ void changed();
+
+private:
+ QButtonGroup *group;
+ QCheckBox *visibleCheckBox;
+ QRadioButton *restoreButton;
+ QRadioButton *minimizeButton;
+ QRadioButton *maximizeButton;
+ QRadioButton *fullscreenButton;
+};
+
+// Control for the Qt::WindowStates flags (normal, maximized, fullscreen exclusively
+// combined with minimized and optionally, with a "visible" QCheckbox)
+class WindowStatesControl : public QGroupBox
+{
+ Q_OBJECT
+public:
+ enum Flags {
+ WantVisibleCheckBox = 0x1
+ };
+
+ explicit WindowStatesControl(unsigned flags, QWidget *parent= 0);
+
+ Qt::WindowStates states() const;
+ void setStates(Qt::WindowStates s);
+
+ bool visibleValue() const;
+ void setVisibleValue(bool);
+
+signals:
+ void changed();
+
+private:
+ QCheckBox *visibleCheckBox;
+ QCheckBox *minimizeCheckBox;
+ WindowStateControl *stateControl;
+};
+
+// Control for the type part of Qt::WindowFlags
+class TypeControl : public QGroupBox
+{
+ Q_OBJECT
+public:
+ explicit TypeControl(QWidget *parent= 0);
+
+ Qt::WindowFlags type() const;
+ void setType(Qt::WindowFlags);
+
+signals:
+ void changed(Qt::WindowFlags);
+
+private slots:
+ void slotChanged();
+
+private:
+ QButtonGroup *group;
+ QRadioButton *windowRadioButton;
+ QRadioButton *dialogRadioButton;
+ QRadioButton *sheetRadioButton;
+ QRadioButton *drawerRadioButton;
+ QRadioButton *popupRadioButton;
+ QRadioButton *toolRadioButton;
+ QRadioButton *toolTipRadioButton;
+ QRadioButton *splashScreenRadioButton;
+};
+
+#endif // CONTROLS_H
diff --git a/tests/manual/windowflags/windowflags.pro b/tests/manual/windowflags/windowflags.pro
index 81ca7ad0e0..46e9475800 100644
--- a/tests/manual/windowflags/windowflags.pro
+++ b/tests/manual/windowflags/windowflags.pro
@@ -1,8 +1,12 @@
QT += widgets
HEADERS = controllerwindow.h \
- previewwindow.h
+ previewwindow.h \
+ controls.h
+
SOURCES = controllerwindow.cpp \
previewwindow.cpp \
- main.cpp
+ main.cpp \
+ controls.cpp
+
QT += widgets