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:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
43
#include <QPushButton>
44
#include <QVBoxLayout>
46
#include "previewwindow.h"
48
static QString windowFlagsToString(Qt::WindowFlags flags)
52
Qt::WindowFlags type = (flags & Qt::WindowType_Mask);
53
if (type == Qt::Window) {
55
} else if (type == Qt::Dialog) {
57
} else if (type == Qt::Sheet) {
59
} else if (type == Qt::Drawer) {
61
} else if (type == Qt::Popup) {
63
} else if (type == Qt::Tool) {
65
} else if (type == Qt::ToolTip) {
67
} else if (type == Qt::SplashScreen) {
68
text = "Qt::SplashScreen";
71
if (flags & Qt::MSWindowsFixedSizeDialogHint)
72
text += "\n| Qt::MSWindowsFixedSizeDialogHint";
73
if (flags & Qt::X11BypassWindowManagerHint)
74
text += "\n| Qt::X11BypassWindowManagerHint";
75
if (flags & Qt::FramelessWindowHint)
76
text += "\n| Qt::FramelessWindowHint";
77
if (flags & Qt::WindowTitleHint)
78
text += "\n| Qt::WindowTitleHint";
79
if (flags & Qt::WindowSystemMenuHint)
80
text += "\n| Qt::WindowSystemMenuHint";
81
if (flags & Qt::WindowMinimizeButtonHint)
82
text += "\n| Qt::WindowMinimizeButtonHint";
83
if (flags & Qt::WindowMaximizeButtonHint)
84
text += "\n| Qt::WindowMaximizeButtonHint";
85
if (flags & Qt::WindowCloseButtonHint)
86
text += "\n| Qt::WindowCloseButtonHint";
87
if (flags & Qt::WindowContextHelpButtonHint)
88
text += "\n| Qt::WindowContextHelpButtonHint";
89
if (flags & Qt::WindowShadeButtonHint)
90
text += "\n| Qt::WindowShadeButtonHint";
91
if (flags & Qt::WindowStaysOnTopHint)
92
text += "\n| Qt::WindowStaysOnTopHint";
93
if (flags & Qt::CustomizeWindowHint)
94
text += "\n| Qt::CustomizeWindowHint";
98
PreviewWindow::PreviewWindow(QWidget *parent)
101
textEdit = new QTextEdit;
102
textEdit->setReadOnly(true);
103
textEdit->setLineWrapMode(QTextEdit::NoWrap);
105
closeButton = new QPushButton(tr("&Close"));
106
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
108
showNormalButton = new QPushButton(tr("Show normal"));
109
connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
110
showMinimizedButton = new QPushButton(tr("Show minimized"));
111
connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
112
showMaximizedButton = new QPushButton(tr("Show maximized"));
113
connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
114
showFullScreenButton = new QPushButton(tr("Show fullscreen"));
115
connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
117
QVBoxLayout *layout = new QVBoxLayout;
118
layout->addWidget(textEdit);
119
layout->addWidget(showNormalButton);
120
layout->addWidget(showMinimizedButton);
121
layout->addWidget(showMaximizedButton);
122
layout->addWidget(showFullScreenButton);
123
layout->addWidget(closeButton);
126
setWindowTitle(tr("Preview <QWidget>"));
129
void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
131
QWidget::setWindowFlags(flags);
133
QString text = windowFlagsToString(flags);
134
textEdit->setPlainText(text);
137
PreviewDialog::PreviewDialog(QWidget *parent)
140
textEdit = new QTextEdit;
141
textEdit->setReadOnly(true);
142
textEdit->setLineWrapMode(QTextEdit::NoWrap);
144
closeButton = new QPushButton(tr("&Close"));
145
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
147
showNormalButton = new QPushButton(tr("Show normal"));
148
connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
149
showMinimizedButton = new QPushButton(tr("Show minimized"));
150
connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
151
showMaximizedButton = new QPushButton(tr("Show maximized"));
152
connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
153
showFullScreenButton = new QPushButton(tr("Show fullscreen"));
154
connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
156
QVBoxLayout *layout = new QVBoxLayout;
157
layout->addWidget(textEdit);
158
layout->addWidget(showNormalButton);
159
layout->addWidget(showMinimizedButton);
160
layout->addWidget(showMaximizedButton);
161
layout->addWidget(showFullScreenButton);
162
layout->addWidget(closeButton);
165
setWindowTitle(tr("Preview <QDialog>"));
168
void PreviewDialog::setWindowFlags(Qt::WindowFlags flags)
170
QWidget::setWindowFlags(flags);
172
QString text = windowFlagsToString(flags);
173
textEdit->setPlainText(text);