author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 02 Feb 2010 00:43:10 +0200 | |
changeset 3 | 41300fa6a67c |
parent 0 | 1918ee327afb |
child 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
** All rights reserved. |
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the examples 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 |
#include <QtGui> |
|
43 |
||
44 |
#include "previewwindow.h" |
|
45 |
||
46 |
static QString windowFlagsToString(Qt::WindowFlags flags) |
|
47 |
{ |
|
48 |
QString text; |
|
49 |
||
50 |
Qt::WindowFlags type = (flags & Qt::WindowType_Mask); |
|
51 |
if (type == Qt::Window) { |
|
52 |
text = "Qt::Window"; |
|
53 |
} else if (type == Qt::Dialog) { |
|
54 |
text = "Qt::Dialog"; |
|
55 |
} else if (type == Qt::Sheet) { |
|
56 |
text = "Qt::Sheet"; |
|
57 |
} else if (type == Qt::Drawer) { |
|
58 |
text = "Qt::Drawer"; |
|
59 |
} else if (type == Qt::Popup) { |
|
60 |
text = "Qt::Popup"; |
|
61 |
} else if (type == Qt::Tool) { |
|
62 |
text = "Qt::Tool"; |
|
63 |
} else if (type == Qt::ToolTip) { |
|
64 |
text = "Qt::ToolTip"; |
|
65 |
} else if (type == Qt::SplashScreen) { |
|
66 |
text = "Qt::SplashScreen"; |
|
67 |
} |
|
68 |
||
69 |
if (flags & Qt::MSWindowsFixedSizeDialogHint) |
|
70 |
text += "\n| Qt::MSWindowsFixedSizeDialogHint"; |
|
71 |
if (flags & Qt::X11BypassWindowManagerHint) |
|
72 |
text += "\n| Qt::X11BypassWindowManagerHint"; |
|
73 |
if (flags & Qt::FramelessWindowHint) |
|
74 |
text += "\n| Qt::FramelessWindowHint"; |
|
75 |
if (flags & Qt::WindowTitleHint) |
|
76 |
text += "\n| Qt::WindowTitleHint"; |
|
77 |
if (flags & Qt::WindowSystemMenuHint) |
|
78 |
text += "\n| Qt::WindowSystemMenuHint"; |
|
79 |
if (flags & Qt::WindowMinimizeButtonHint) |
|
80 |
text += "\n| Qt::WindowMinimizeButtonHint"; |
|
81 |
if (flags & Qt::WindowMaximizeButtonHint) |
|
82 |
text += "\n| Qt::WindowMaximizeButtonHint"; |
|
83 |
if (flags & Qt::WindowCloseButtonHint) |
|
84 |
text += "\n| Qt::WindowCloseButtonHint"; |
|
85 |
if (flags & Qt::WindowContextHelpButtonHint) |
|
86 |
text += "\n| Qt::WindowContextHelpButtonHint"; |
|
87 |
if (flags & Qt::WindowShadeButtonHint) |
|
88 |
text += "\n| Qt::WindowShadeButtonHint"; |
|
89 |
if (flags & Qt::WindowStaysOnTopHint) |
|
90 |
text += "\n| Qt::WindowStaysOnTopHint"; |
|
91 |
if (flags & Qt::CustomizeWindowHint) |
|
92 |
text += "\n| Qt::CustomizeWindowHint"; |
|
93 |
return text; |
|
94 |
} |
|
95 |
||
96 |
PreviewWindow::PreviewWindow(QWidget *parent) |
|
97 |
: QWidget(parent) |
|
98 |
{ |
|
99 |
textEdit = new QTextEdit; |
|
100 |
textEdit->setReadOnly(true); |
|
101 |
textEdit->setLineWrapMode(QTextEdit::NoWrap); |
|
102 |
||
103 |
closeButton = new QPushButton(tr("&Close")); |
|
104 |
connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); |
|
105 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
showNormalButton = new QPushButton(tr("Show normal")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
108 |
showMaximizedButton = new QPushButton(tr("Show maximized")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
showFullScreenButton = new QPushButton(tr("Show fullscreen")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
|
0 | 113 |
QVBoxLayout *layout = new QVBoxLayout; |
114 |
layout->addWidget(textEdit); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
layout->addWidget(showNormalButton); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
layout->addWidget(showMaximizedButton); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
layout->addWidget(showFullScreenButton); |
0 | 118 |
layout->addWidget(closeButton); |
119 |
setLayout(layout); |
|
120 |
||
121 |
setWindowTitle(tr("Preview <QWidget>")); |
|
122 |
} |
|
123 |
||
124 |
void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) |
|
125 |
{ |
|
126 |
QWidget::setWindowFlags(flags); |
|
127 |
||
128 |
QString text = windowFlagsToString(flags); |
|
129 |
textEdit->setPlainText(text); |
|
130 |
} |
|
131 |
||
132 |
PreviewDialog::PreviewDialog(QWidget *parent) |
|
133 |
: QDialog(parent) |
|
134 |
{ |
|
135 |
textEdit = new QTextEdit; |
|
136 |
textEdit->setReadOnly(true); |
|
137 |
textEdit->setLineWrapMode(QTextEdit::NoWrap); |
|
138 |
||
139 |
closeButton = new QPushButton(tr("&Close")); |
|
140 |
connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); |
|
141 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
showNormalButton = new QPushButton(tr("Show normal")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
showMaximizedButton = new QPushButton(tr("Show maximized")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
showFullScreenButton = new QPushButton(tr("Show fullscreen")); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen())); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
|
0 | 149 |
QVBoxLayout *layout = new QVBoxLayout; |
150 |
layout->addWidget(textEdit); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
layout->addWidget(showNormalButton); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
layout->addWidget(showMaximizedButton); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
153 |
layout->addWidget(showFullScreenButton); |
0 | 154 |
layout->addWidget(closeButton); |
155 |
setLayout(layout); |
|
156 |
||
157 |
setWindowTitle(tr("Preview <QDialog>")); |
|
158 |
} |
|
159 |
||
160 |
void PreviewDialog::setWindowFlags(Qt::WindowFlags flags) |
|
161 |
{ |
|
162 |
QWidget::setWindowFlags(flags); |
|
163 |
||
164 |
QString text = windowFlagsToString(flags); |
|
165 |
textEdit->setPlainText(text); |
|
166 |
} |