1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the examples of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:BSD$
9
** You may use this file under the terms of the BSD license as follows:
11
** "Redistribution and use in source and binary forms, with or without
12
** modification, are permitted provided that the following conditions are
14
** * Redistributions of source code must retain the above copyright
15
** notice, this list of conditions and the following disclaimer.
16
** * Redistributions in binary form must reproduce the above copyright
17
** notice, this list of conditions and the following disclaimer in
18
** the documentation and/or other materials provided with the
20
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21
** of its contributors may be used to endorse or promote products derived
22
** from this software without specific prior written permission.
25
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39
****************************************************************************/
43
#include "controllerwindow.h"
46
ControllerWindow::ControllerWindow()
48
previewWindow = new PreviewWindow(this);
51
createHintsGroupBox();
53
quitButton = new QPushButton(tr("&Quit"));
54
connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
56
QHBoxLayout *bottomLayout = new QHBoxLayout;
57
bottomLayout->addStretch();
58
bottomLayout->addWidget(quitButton);
60
QHBoxLayout *mainLayout = new QHBoxLayout;
61
mainLayout->addWidget(typeGroupBox);
62
mainLayout->addWidget(hintsGroupBox);
63
mainLayout->addLayout(bottomLayout);
64
setLayout(mainLayout);
66
setWindowTitle(tr("Window Flags"));
72
void ControllerWindow::updatePreview()
74
Qt::WindowFlags flags = 0;
76
if (windowRadioButton->isChecked()) {
78
} else if (dialogRadioButton->isChecked()) {
80
} else if (sheetRadioButton->isChecked()) {
82
} else if (drawerRadioButton->isChecked()) {
84
} else if (popupRadioButton->isChecked()) {
86
} else if (toolRadioButton->isChecked()) {
88
} else if (toolTipRadioButton->isChecked()) {
90
} else if (splashScreenRadioButton->isChecked()) {
91
flags = Qt::SplashScreen;
96
if (msWindowsFixedSizeDialogCheckBox->isChecked())
97
flags |= Qt::MSWindowsFixedSizeDialogHint;
98
if (x11BypassWindowManagerCheckBox->isChecked())
99
flags |= Qt::X11BypassWindowManagerHint;
100
if (framelessWindowCheckBox->isChecked())
101
flags |= Qt::FramelessWindowHint;
102
if (windowNoShadowCheckBox->isChecked())
103
flags |= Qt::NoDropShadowWindowHint;
104
if (windowTitleCheckBox->isChecked())
105
flags |= Qt::WindowTitleHint;
106
if (windowSystemMenuCheckBox->isChecked())
107
flags |= Qt::WindowSystemMenuHint;
108
if (windowMinimizeButtonCheckBox->isChecked())
109
flags |= Qt::WindowMinimizeButtonHint;
110
if (windowMaximizeButtonCheckBox->isChecked())
111
flags |= Qt::WindowMaximizeButtonHint;
112
if (windowCloseButtonCheckBox->isChecked())
113
flags |= Qt::WindowCloseButtonHint;
114
if (windowContextHelpButtonCheckBox->isChecked())
115
flags |= Qt::WindowContextHelpButtonHint;
116
if (windowShadeButtonCheckBox->isChecked())
117
flags |= Qt::WindowShadeButtonHint;
118
if (windowStaysOnTopCheckBox->isChecked())
119
flags |= Qt::WindowStaysOnTopHint;
120
if (windowStaysOnBottomCheckBox->isChecked())
121
flags |= Qt::WindowStaysOnBottomHint;
122
if (customizeWindowHintCheckBox->isChecked())
123
flags |= Qt::CustomizeWindowHint;
125
previewWindow->setWindowFlags(flags);
128
QPoint pos = previewWindow->pos();
133
previewWindow->move(pos);
134
previewWindow->show();
139
void ControllerWindow::createTypeGroupBox()
141
typeGroupBox = new QGroupBox(tr("Type"));
143
windowRadioButton = createRadioButton(tr("Window"));
144
dialogRadioButton = createRadioButton(tr("Dialog"));
145
sheetRadioButton = createRadioButton(tr("Sheet"));
146
drawerRadioButton = createRadioButton(tr("Drawer"));
147
popupRadioButton = createRadioButton(tr("Popup"));
148
toolRadioButton = createRadioButton(tr("Tool"));
149
toolTipRadioButton = createRadioButton(tr("Tooltip"));
150
splashScreenRadioButton = createRadioButton(tr("Splash screen"));
151
windowRadioButton->setChecked(true);
153
QGridLayout *layout = new QGridLayout;
154
layout->addWidget(windowRadioButton, 0, 0);
155
layout->addWidget(dialogRadioButton, 1, 0);
156
layout->addWidget(sheetRadioButton, 2, 0);
157
layout->addWidget(drawerRadioButton, 3, 0);
158
layout->addWidget(popupRadioButton, 0, 1);
159
layout->addWidget(toolRadioButton, 1, 1);
160
layout->addWidget(toolTipRadioButton, 2, 1);
161
layout->addWidget(splashScreenRadioButton, 3, 1);
162
typeGroupBox->setLayout(layout);
167
void ControllerWindow::createHintsGroupBox()
169
hintsGroupBox = new QGroupBox(tr("Hints"));
171
msWindowsFixedSizeDialogCheckBox =
172
createCheckBox(tr("MS Windows fixed size dialog"));
173
x11BypassWindowManagerCheckBox =
174
createCheckBox(tr("X11 bypass window manager"));
175
framelessWindowCheckBox = createCheckBox(tr("Frameless window"));
176
windowNoShadowCheckBox = createCheckBox(tr("No drop shadow"));
177
windowTitleCheckBox = createCheckBox(tr("Window title"));
178
windowSystemMenuCheckBox = createCheckBox(tr("Window system menu"));
179
windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button"));
180
windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button"));
181
windowCloseButtonCheckBox = createCheckBox(tr("Window close button"));
182
windowContextHelpButtonCheckBox =
183
createCheckBox(tr("Window context help button"));
184
windowShadeButtonCheckBox = createCheckBox(tr("Window shade button"));
185
windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top"));
186
windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom"));
187
customizeWindowHintCheckBox= createCheckBox(tr("Customize window"));
189
QGridLayout *layout = new QGridLayout;
190
layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0);
191
layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0);
192
layout->addWidget(framelessWindowCheckBox, 2, 0);
193
layout->addWidget(windowNoShadowCheckBox, 3, 0);
194
layout->addWidget(windowTitleCheckBox, 4, 0);
195
layout->addWidget(windowSystemMenuCheckBox, 5, 0);
196
layout->addWidget(customizeWindowHintCheckBox, 6, 0);
197
layout->addWidget(windowMinimizeButtonCheckBox, 0, 1);
198
layout->addWidget(windowMaximizeButtonCheckBox, 1, 1);
199
layout->addWidget(windowCloseButtonCheckBox, 2, 1);
200
layout->addWidget(windowContextHelpButtonCheckBox, 3, 1);
201
layout->addWidget(windowShadeButtonCheckBox, 4, 1);
202
layout->addWidget(windowStaysOnTopCheckBox, 5, 1);
203
layout->addWidget(windowStaysOnBottomCheckBox, 6, 1);
204
hintsGroupBox->setLayout(layout);
209
QCheckBox *ControllerWindow::createCheckBox(const QString &text)
211
QCheckBox *checkBox = new QCheckBox(text);
212
connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview()));
218
QRadioButton *ControllerWindow::createRadioButton(const QString &text)
220
QRadioButton *button = new QRadioButton(text);
221
connect(button, SIGNAL(clicked()), this, SLOT(updatePreview()));