author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 8 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
0 | 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 "qdesktopwidget.h" |
|
43 |
#include "qapplication_p.h" |
|
44 |
#include "qwidget_p.h" |
|
45 |
#include "qt_s60_p.h" |
|
46 |
#include <w32std.h> |
|
47 |
||
48 |
#include "hal.h" |
|
49 |
#include "hal_data.h" |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
53 |
class QDesktopWidgetPrivate : public QWidgetPrivate |
|
54 |
{ |
|
55 |
||
56 |
public: |
|
57 |
QDesktopWidgetPrivate(); |
|
58 |
~QDesktopWidgetPrivate(); |
|
59 |
||
60 |
static void init(QDesktopWidget *that); |
|
61 |
static void cleanup(); |
|
62 |
||
63 |
static int screenCount; |
|
64 |
static int primaryScreen; |
|
65 |
||
66 |
static QVector<QRect> *rects; |
|
67 |
static QVector<QRect> *workrects; |
|
68 |
||
69 |
static int refcount; |
|
70 |
}; |
|
71 |
||
72 |
int QDesktopWidgetPrivate::screenCount = 1; |
|
73 |
int QDesktopWidgetPrivate::primaryScreen = 0; |
|
74 |
QVector<QRect> *QDesktopWidgetPrivate::rects = 0; |
|
75 |
QVector<QRect> *QDesktopWidgetPrivate::workrects = 0; |
|
76 |
int QDesktopWidgetPrivate::refcount = 0; |
|
77 |
||
78 |
QDesktopWidgetPrivate::QDesktopWidgetPrivate() |
|
79 |
{ |
|
80 |
++refcount; |
|
81 |
} |
|
82 |
||
83 |
QDesktopWidgetPrivate::~QDesktopWidgetPrivate() |
|
84 |
{ |
|
85 |
if (!--refcount) |
|
86 |
cleanup(); |
|
87 |
} |
|
88 |
||
89 |
void QDesktopWidgetPrivate::init(QDesktopWidget *that) |
|
90 |
{ |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
91 |
Q_UNUSED(that); |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
92 |
// int screenCount=0; |
0 | 93 |
|
8
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
94 |
// ### TODO: Implement proper multi-display support |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
95 |
QDesktopWidgetPrivate::screenCount = 1; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
96 |
// if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone) |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
97 |
// QDesktopWidgetPrivate::screenCount = screenCount; |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
98 |
// else |
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
99 |
// QDesktopWidgetPrivate::screenCount = 0; |
0 | 100 |
|
101 |
rects = new QVector<QRect>(); |
|
102 |
workrects = new QVector<QRect>(); |
|
103 |
||
104 |
rects->resize(QDesktopWidgetPrivate::screenCount); |
|
105 |
workrects->resize(QDesktopWidgetPrivate::screenCount); |
|
106 |
} |
|
107 |
||
108 |
void QDesktopWidgetPrivate::cleanup() |
|
109 |
{ |
|
110 |
delete rects; |
|
111 |
rects = 0; |
|
112 |
delete workrects; |
|
113 |
workrects = 0; |
|
114 |
} |
|
115 |
||
116 |
||
117 |
QDesktopWidget::QDesktopWidget() |
|
118 |
: QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop) |
|
119 |
{ |
|
120 |
setObjectName(QLatin1String("desktop")); |
|
121 |
QDesktopWidgetPrivate::init(this); |
|
122 |
} |
|
123 |
||
124 |
QDesktopWidget::~QDesktopWidget() |
|
125 |
{ |
|
126 |
} |
|
127 |
||
128 |
bool QDesktopWidget::isVirtualDesktop() const |
|
129 |
{ |
|
130 |
return true; |
|
131 |
} |
|
132 |
||
133 |
int QDesktopWidget::primaryScreen() const |
|
134 |
{ |
|
135 |
return QDesktopWidgetPrivate::primaryScreen; |
|
136 |
} |
|
137 |
||
138 |
int QDesktopWidget::numScreens() const |
|
139 |
{ |
|
140 |
Q_D(const QDesktopWidget); |
|
141 |
return QDesktopWidgetPrivate::screenCount; |
|
142 |
} |
|
143 |
||
144 |
QWidget *QDesktopWidget::screen(int /* screen */) |
|
145 |
{ |
|
146 |
return this; |
|
147 |
} |
|
148 |
||
149 |
const QRect QDesktopWidget::availableGeometry(int /* screen */) const |
|
150 |
{ |
|
151 |
TRect clientRect = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); |
|
152 |
return qt_TRect2QRect(clientRect); |
|
153 |
} |
|
154 |
||
155 |
const QRect QDesktopWidget::screenGeometry(int /* screen */) const |
|
156 |
{ |
|
157 |
Q_D(const QDesktopWidget); |
|
158 |
return QRect(0, 0, S60->screenWidthInPixels, S60->screenHeightInPixels); |
|
159 |
} |
|
160 |
||
161 |
int QDesktopWidget::screenNumber(const QWidget * /* widget */) const |
|
162 |
{ |
|
163 |
return QDesktopWidgetPrivate::primaryScreen; |
|
164 |
} |
|
165 |
||
166 |
int QDesktopWidget::screenNumber(const QPoint & /* point */) const |
|
167 |
{ |
|
168 |
return QDesktopWidgetPrivate::primaryScreen; |
|
169 |
} |
|
170 |
||
171 |
void QDesktopWidget::resizeEvent(QResizeEvent *) |
|
172 |
{ |
|
173 |
Q_D(QDesktopWidget); |
|
174 |
QVector<QRect> oldrects; |
|
175 |
oldrects = *d->rects; |
|
176 |
QVector<QRect> oldworkrects; |
|
177 |
oldworkrects = *d->workrects; |
|
178 |
int oldscreencount = d->screenCount; |
|
179 |
||
180 |
QDesktopWidgetPrivate::cleanup(); |
|
181 |
QDesktopWidgetPrivate::init(this); |
|
182 |
||
183 |
for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) { |
|
184 |
QRect oldrect = oldrects[i]; |
|
185 |
QRect newrect = d->rects->at(i); |
|
186 |
if (oldrect != newrect) |
|
187 |
emit resized(i); |
|
188 |
} |
|
189 |
||
190 |
for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) { |
|
191 |
QRect oldrect = oldworkrects[j]; |
|
192 |
QRect newrect = d->workrects->at(j); |
|
193 |
if (oldrect != newrect) |
|
194 |
emit workAreaResized(j); |
|
195 |
} |
|
196 |
} |
|
197 |
||
198 |
QT_END_NAMESPACE |