widgets/qeffects.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
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. -
16** -
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. -
24** -
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. -
28** -
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. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qapplication.h" -
43#ifndef QT_NO_EFFECTS -
44#include "qdesktopwidget.h" -
45#include "qeffects_p.h" -
46#include "qevent.h" -
47#include "qimage.h" -
48#include "qpainter.h" -
49#include "qscreen.h" -
50#include "qpixmap.h" -
51#include "qpointer.h" -
52#include "qtimer.h" -
53#include "qelapsedtimer.h" -
54#include "qdebug.h" -
55 -
56QT_BEGIN_NAMESPACE -
57 -
58/* -
59 Internal class QAlphaWidget. -
60 -
61 The QAlphaWidget is shown while the animation lasts -
62 and displays the pixmap resulting from the alpha blending. -
63*/ -
64 -
65class QAlphaWidget: public QWidget, private QEffects -
66{ -
67 Q_OBJECT -
68public: -
69 QAlphaWidget(QWidget* w, Qt::WindowFlags f = 0); -
70 ~QAlphaWidget(); -
71 -
72 void run(int time); -
73 -
74protected: -
75 void paintEvent(QPaintEvent* e); -
76 void closeEvent(QCloseEvent*); -
77 void alphaBlend(); -
78 bool eventFilter(QObject *, QEvent *); -
79 -
80protected slots: -
81 void render(); -
82 -
83private: -
84 QPixmap pm; -
85 double alpha; -
86 QImage backImage; -
87 QImage frontImage; -
88 QImage mixedImage; -
89 QPointer<QWidget> widget; -
90 int duration; -
91 int elapsed; -
92 bool showWidget; -
93 QTimer anim; -
94 QElapsedTimer checkTime; -
95}; -
96 -
97static QAlphaWidget* q_blend = 0; -
98 -
99/* -
100 Constructs a QAlphaWidget. -
101*/ -
102QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f) -
103 : QWidget(QApplication::desktop()->screen(QApplication::desktop()->screenNumber(w)), f) -
104{ -
105#ifndef Q_OS_WIN -
106 setEnabled(false);
never executed (the execution status of this line is deduced): setEnabled(false);
-
107#endif -
108 setAttribute(Qt::WA_NoSystemBackground, true);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground, true);
-
109 widget = w;
never executed (the execution status of this line is deduced): widget = w;
-
110 alpha = 0;
never executed (the execution status of this line is deduced): alpha = 0;
-
111}
never executed: }
0
112 -
113QAlphaWidget::~QAlphaWidget() -
114{ -
115#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
116 // Restore user-defined opacity value -
117 if (widget) -
118 widget->setWindowOpacity(1); -
119#endif -
120} -
121 -
122/* -
123 \reimp -
124*/ -
125void QAlphaWidget::paintEvent(QPaintEvent*) -
126{ -
127 QPainter p(this);
never executed (the execution status of this line is deduced): QPainter p(this);
-
128 p.drawPixmap(0, 0, pm);
never executed (the execution status of this line is deduced): p.drawPixmap(0, 0, pm);
-
129}
never executed: }
0
130 -
131/* -
132 Starts the alphablending animation. -
133 The animation will take about \a time ms -
134*/ -
135void QAlphaWidget::run(int time) -
136{ -
137 duration = time;
never executed (the execution status of this line is deduced): duration = time;
-
138 -
139 if (duration < 0)
never evaluated: duration < 0
0
140 duration = 150;
never executed: duration = 150;
0
141 -
142 if (!widget)
never evaluated: !widget
0
143 return;
never executed: return;
0
144 -
145 elapsed = 0;
never executed (the execution status of this line is deduced): elapsed = 0;
-
146 checkTime.start();
never executed (the execution status of this line is deduced): checkTime.start();
-
147 -
148 showWidget = true;
never executed (the execution status of this line is deduced): showWidget = true;
-
149#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
150 qApp->installEventFilter(this); -
151 widget->setWindowOpacity(0.0); -
152 widget->show(); -
153 connect(&anim, SIGNAL(timeout()), this, SLOT(render())); -
154 anim.start(1); -
155#else -
156 //This is roughly equivalent to calling setVisible(true) without actually showing the widget -
157 widget->setAttribute(Qt::WA_WState_ExplicitShowHide, true);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_WState_ExplicitShowHide, true);
-
158 widget->setAttribute(Qt::WA_WState_Hidden, false);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_WState_Hidden, false);
-
159 -
160 qApp->installEventFilter(this);
never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this);
-
161 -
162 move(widget->geometry().x(),widget->geometry().y());
never executed (the execution status of this line is deduced): move(widget->geometry().x(),widget->geometry().y());
-
163 resize(widget->size().width(), widget->size().height());
never executed (the execution status of this line is deduced): resize(widget->size().width(), widget->size().height());
-
164 -
165 frontImage = widget->grab().toImage();
never executed (the execution status of this line is deduced): frontImage = widget->grab().toImage();
-
166 backImage = QGuiApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId(),
never executed (the execution status of this line is deduced): backImage = QGuiApplication::primaryScreen()->grabWindow(QApplication::desktop()->winId(),
-
167 widget->geometry().x(), widget->geometry().y(),
never executed (the execution status of this line is deduced): widget->geometry().x(), widget->geometry().y(),
-
168 widget->geometry().width(), widget->geometry().height()).toImage();
never executed (the execution status of this line is deduced): widget->geometry().width(), widget->geometry().height()).toImage();
-
169 -
170 if (!backImage.isNull() && checkTime.elapsed() < duration / 2) {
never evaluated: !backImage.isNull()
never evaluated: checkTime.elapsed() < duration / 2
0
171 mixedImage = backImage.copy();
never executed (the execution status of this line is deduced): mixedImage = backImage.copy();
-
172 pm = QPixmap::fromImage(mixedImage);
never executed (the execution status of this line is deduced): pm = QPixmap::fromImage(mixedImage);
-
173 show();
never executed (the execution status of this line is deduced): show();
-
174 setEnabled(false);
never executed (the execution status of this line is deduced): setEnabled(false);
-
175 -
176 connect(&anim, SIGNAL(timeout()), this, SLOT(render()));
never executed (the execution status of this line is deduced): connect(&anim, "2""timeout()", this, "1""render()");
-
177 anim.start(1);
never executed (the execution status of this line is deduced): anim.start(1);
-
178 } else {
never executed: }
0
179 duration = 0;
never executed (the execution status of this line is deduced): duration = 0;
-
180 render();
never executed (the execution status of this line is deduced): render();
-
181 }
never executed: }
0
182#endif -
183} -
184 -
185/* -
186 \reimp -
187*/ -
188bool QAlphaWidget::eventFilter(QObject *o, QEvent *e) -
189{ -
190 switch (e->type()) { -
191 case QEvent::Move: -
192 if (o != widget)
never evaluated: o != widget
0
193 break;
never executed: break;
0
194 move(widget->geometry().x(),widget->geometry().y());
never executed (the execution status of this line is deduced): move(widget->geometry().x(),widget->geometry().y());
-
195 update();
never executed (the execution status of this line is deduced): update();
-
196 break;
never executed: break;
0
197 case QEvent::Hide: -
198 case QEvent::Close: -
199 if (o != widget)
never evaluated: o != widget
0
200 break;
never executed: break;
0
201 case QEvent::MouseButtonPress:
code before this statement never executed: case QEvent::MouseButtonPress:
0
202 case QEvent::MouseButtonDblClick: -
203 showWidget = false;
never executed (the execution status of this line is deduced): showWidget = false;
-
204 render();
never executed (the execution status of this line is deduced): render();
-
205 break;
never executed: break;
0
206 case QEvent::KeyPress: { -
207 QKeyEvent *ke = (QKeyEvent*)e;
never executed (the execution status of this line is deduced): QKeyEvent *ke = (QKeyEvent*)e;
-
208 if (ke->key() == Qt::Key_Escape) {
never evaluated: ke->key() == Qt::Key_Escape
0
209 showWidget = false;
never executed (the execution status of this line is deduced): showWidget = false;
-
210 } else {
never executed: }
0
211 duration = 0;
never executed (the execution status of this line is deduced): duration = 0;
-
212 }
never executed: }
0
213 render();
never executed (the execution status of this line is deduced): render();
-
214 break;
never executed: break;
0
215 } -
216 default: -
217 break;
never executed: break;
0
218 } -
219 return QWidget::eventFilter(o, e);
never executed: return QWidget::eventFilter(o, e);
0
220} -
221 -
222/* -
223 \reimp -
224*/ -
225void QAlphaWidget::closeEvent(QCloseEvent *e) -
226{ -
227 e->accept();
never executed (the execution status of this line is deduced): e->accept();
-
228 if (!q_blend)
never evaluated: !q_blend
0
229 return;
never executed: return;
0
230 -
231 showWidget = false;
never executed (the execution status of this line is deduced): showWidget = false;
-
232 render();
never executed (the execution status of this line is deduced): render();
-
233 -
234 QWidget::closeEvent(e);
never executed (the execution status of this line is deduced): QWidget::closeEvent(e);
-
235}
never executed: }
0
236 -
237/* -
238 Render alphablending for the time elapsed. -
239 -
240 Show the blended widget and free all allocated source -
241 if the blending is finished. -
242*/ -
243void QAlphaWidget::render() -
244{ -
245 int tempel = checkTime.elapsed();
never executed (the execution status of this line is deduced): int tempel = checkTime.elapsed();
-
246 if (elapsed >= tempel)
never evaluated: elapsed >= tempel
0
247 elapsed++;
never executed: elapsed++;
0
248 else -
249 elapsed = tempel;
never executed: elapsed = tempel;
0
250 -
251 if (duration != 0)
never evaluated: duration != 0
0
252 alpha = tempel / double(duration);
never executed: alpha = tempel / double(duration);
0
253 else -
254 alpha = 1;
never executed: alpha = 1;
0
255 -
256#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
257 if (alpha >= 1 || !showWidget) { -
258 anim.stop(); -
259 qApp->removeEventFilter(this); -
260 widget->setWindowOpacity(1); -
261 q_blend = 0; -
262 deleteLater(); -
263 } else { -
264 widget->setWindowOpacity(alpha); -
265 } -
266#else -
267 if (alpha >= 1 || !showWidget) {
never evaluated: alpha >= 1
never evaluated: !showWidget
0
268 anim.stop();
never executed (the execution status of this line is deduced): anim.stop();
-
269 qApp->removeEventFilter(this);
never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->removeEventFilter(this);
-
270 -
271 if (widget) {
never evaluated: widget
0
272 if (!showWidget) {
never evaluated: !showWidget
0
273#ifdef Q_OS_WIN -
274 setEnabled(true); -
275 setFocus(); -
276#endif // Q_OS_WIN -
277 widget->hide();
never executed (the execution status of this line is deduced): widget->hide();
-
278 } else {
never executed: }
0
279 //Since we are faking the visibility of the widget -
280 //we need to unset the hidden state on it before calling show -
281 widget->setAttribute(Qt::WA_WState_Hidden, true);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_WState_Hidden, true);
-
282 widget->show();
never executed (the execution status of this line is deduced): widget->show();
-
283 lower();
never executed (the execution status of this line is deduced): lower();
-
284 }
never executed: }
0
285 } -
286 q_blend = 0;
never executed (the execution status of this line is deduced): q_blend = 0;
-
287 deleteLater();
never executed (the execution status of this line is deduced): deleteLater();
-
288 } else {
never executed: }
0
289 alphaBlend();
never executed (the execution status of this line is deduced): alphaBlend();
-
290 pm = QPixmap::fromImage(mixedImage);
never executed (the execution status of this line is deduced): pm = QPixmap::fromImage(mixedImage);
-
291 repaint();
never executed (the execution status of this line is deduced): repaint();
-
292 }
never executed: }
0
293#endif // defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
294} -
295 -
296/* -
297 Calculate an alphablended image. -
298*/ -
299void QAlphaWidget::alphaBlend() -
300{ -
301 const int a = qRound(alpha*256);
never executed (the execution status of this line is deduced): const int a = qRound(alpha*256);
-
302 const int ia = 256 - a;
never executed (the execution status of this line is deduced): const int ia = 256 - a;
-
303 -
304 const int sw = frontImage.width();
never executed (the execution status of this line is deduced): const int sw = frontImage.width();
-
305 const int sh = frontImage.height();
never executed (the execution status of this line is deduced): const int sh = frontImage.height();
-
306 const int bpl = frontImage.bytesPerLine();
never executed (the execution status of this line is deduced): const int bpl = frontImage.bytesPerLine();
-
307 switch(frontImage.depth()) { -
308 case 32: -
309 { -
310 uchar *mixed_data = mixedImage.bits();
never executed (the execution status of this line is deduced): uchar *mixed_data = mixedImage.bits();
-
311 const uchar *back_data = backImage.bits();
never executed (the execution status of this line is deduced): const uchar *back_data = backImage.bits();
-
312 const uchar *front_data = frontImage.bits();
never executed (the execution status of this line is deduced): const uchar *front_data = frontImage.bits();
-
313 -
314 for (int sy = 0; sy < sh; sy++) {
never evaluated: sy < sh
0
315 quint32* mixed = (quint32*)mixed_data;
never executed (the execution status of this line is deduced): quint32* mixed = (quint32*)mixed_data;
-
316 const quint32* back = (const quint32*)back_data;
never executed (the execution status of this line is deduced): const quint32* back = (const quint32*)back_data;
-
317 const quint32* front = (const quint32*)front_data;
never executed (the execution status of this line is deduced): const quint32* front = (const quint32*)front_data;
-
318 for (int sx = 0; sx < sw; sx++) {
never evaluated: sx < sw
0
319 quint32 bp = back[sx];
never executed (the execution status of this line is deduced): quint32 bp = back[sx];
-
320 quint32 fp = front[sx];
never executed (the execution status of this line is deduced): quint32 fp = front[sx];
-
321 -
322 mixed[sx] = qRgb((qRed(bp)*ia + qRed(fp)*a)>>8,
never executed (the execution status of this line is deduced): mixed[sx] = qRgb((qRed(bp)*ia + qRed(fp)*a)>>8,
-
323 (qGreen(bp)*ia + qGreen(fp)*a)>>8,
never executed (the execution status of this line is deduced): (qGreen(bp)*ia + qGreen(fp)*a)>>8,
-
324 (qBlue(bp)*ia + qBlue(fp)*a)>>8);
never executed (the execution status of this line is deduced): (qBlue(bp)*ia + qBlue(fp)*a)>>8);
-
325 }
never executed: }
0
326 mixed_data += bpl;
never executed (the execution status of this line is deduced): mixed_data += bpl;
-
327 back_data += bpl;
never executed (the execution status of this line is deduced): back_data += bpl;
-
328 front_data += bpl;
never executed (the execution status of this line is deduced): front_data += bpl;
-
329 }
never executed: }
0
330 } -
331 default: -
332 break;
never executed: break;
0
333 } -
334}
never executed: }
0
335 -
336/* -
337 Internal class QRollEffect -
338 -
339 The QRollEffect widget is shown while the animation lasts -
340 and displays a scrolling pixmap. -
341*/ -
342 -
343class QRollEffect : public QWidget, private QEffects -
344{ -
345 Q_OBJECT -
346public: -
347 QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient); -
348 -
349 void run(int time); -
350 -
351protected: -
352 void paintEvent(QPaintEvent*); -
353 void closeEvent(QCloseEvent*); -
354 -
355private slots: -
356 void scroll(); -
357 -
358private: -
359 QPointer<QWidget> widget; -
360 -
361 int currentHeight; -
362 int currentWidth; -
363 int totalHeight; -
364 int totalWidth; -
365 -
366 int duration; -
367 int elapsed; -
368 bool done; -
369 bool showWidget; -
370 int orientation; -
371 -
372 QTimer anim; -
373 QElapsedTimer checkTime; -
374 -
375 QPixmap pm; -
376}; -
377 -
378static QRollEffect* q_roll = 0; -
379 -
380/* -
381 Construct a QRollEffect widget. -
382*/ -
383QRollEffect::QRollEffect(QWidget* w, Qt::WindowFlags f, DirFlags orient) -
384 : QWidget(0, f), orientation(orient) -
385{ -
386#ifndef Q_OS_WIN -
387 setEnabled(false);
never executed (the execution status of this line is deduced): setEnabled(false);
-
388#endif -
389 -
390 widget = w;
never executed (the execution status of this line is deduced): widget = w;
-
391 Q_ASSERT(widget);
never executed (the execution status of this line is deduced): qt_noop();
-
392 -
393 setAttribute(Qt::WA_NoSystemBackground, true);
never executed (the execution status of this line is deduced): setAttribute(Qt::WA_NoSystemBackground, true);
-
394 -
395 if (widget->testAttribute(Qt::WA_Resized)) {
never evaluated: widget->testAttribute(Qt::WA_Resized)
0
396 totalWidth = widget->width();
never executed (the execution status of this line is deduced): totalWidth = widget->width();
-
397 totalHeight = widget->height();
never executed (the execution status of this line is deduced): totalHeight = widget->height();
-
398 } else {
never executed: }
0
399 totalWidth = widget->sizeHint().width();
never executed (the execution status of this line is deduced): totalWidth = widget->sizeHint().width();
-
400 totalHeight = widget->sizeHint().height();
never executed (the execution status of this line is deduced): totalHeight = widget->sizeHint().height();
-
401 }
never executed: }
0
402 -
403 currentHeight = totalHeight;
never executed (the execution status of this line is deduced): currentHeight = totalHeight;
-
404 currentWidth = totalWidth;
never executed (the execution status of this line is deduced): currentWidth = totalWidth;
-
405 -
406 if (orientation & (RightScroll|LeftScroll))
never evaluated: orientation & (RightScroll|LeftScroll)
0
407 currentWidth = 0;
never executed: currentWidth = 0;
0
408 if (orientation & (DownScroll|UpScroll))
never evaluated: orientation & (DownScroll|UpScroll)
0
409 currentHeight = 0;
never executed: currentHeight = 0;
0
410 -
411 pm = widget->grab();
never executed (the execution status of this line is deduced): pm = widget->grab();
-
412}
never executed: }
0
413 -
414/* -
415 \reimp -
416*/ -
417void QRollEffect::paintEvent(QPaintEvent*) -
418{ -
419 int x = orientation & RightScroll ? qMin(0, currentWidth - totalWidth) : 0;
never evaluated: orientation & RightScroll
0
420 int y = orientation & DownScroll ? qMin(0, currentHeight - totalHeight) : 0;
never evaluated: orientation & DownScroll
0
421 -
422 QPainter p(this);
never executed (the execution status of this line is deduced): QPainter p(this);
-
423 p.drawPixmap(x, y, pm);
never executed (the execution status of this line is deduced): p.drawPixmap(x, y, pm);
-
424}
never executed: }
0
425 -
426/* -
427 \reimp -
428*/ -
429void QRollEffect::closeEvent(QCloseEvent *e) -
430{ -
431 e->accept();
never executed (the execution status of this line is deduced): e->accept();
-
432 if (done)
never evaluated: done
0
433 return;
never executed: return;
0
434 -
435 showWidget = false;
never executed (the execution status of this line is deduced): showWidget = false;
-
436 done = true;
never executed (the execution status of this line is deduced): done = true;
-
437 scroll();
never executed (the execution status of this line is deduced): scroll();
-
438 -
439 QWidget::closeEvent(e);
never executed (the execution status of this line is deduced): QWidget::closeEvent(e);
-
440}
never executed: }
0
441 -
442/* -
443 Start the animation. -
444 -
445 The animation will take about \a time ms, or is -
446 calculated if \a time is negative -
447*/ -
448void QRollEffect::run(int time) -
449{ -
450 if (!widget)
never evaluated: !widget
0
451 return;
never executed: return;
0
452 -
453 duration = time;
never executed (the execution status of this line is deduced): duration = time;
-
454 elapsed = 0;
never executed (the execution status of this line is deduced): elapsed = 0;
-
455 -
456 if (duration < 0) {
never evaluated: duration < 0
0
457 int dist = 0;
never executed (the execution status of this line is deduced): int dist = 0;
-
458 if (orientation & (RightScroll|LeftScroll))
never evaluated: orientation & (RightScroll|LeftScroll)
0
459 dist += totalWidth - currentWidth;
never executed: dist += totalWidth - currentWidth;
0
460 if (orientation & (DownScroll|UpScroll))
never evaluated: orientation & (DownScroll|UpScroll)
0
461 dist += totalHeight - currentHeight;
never executed: dist += totalHeight - currentHeight;
0
462 duration = qMin(qMax(dist/3, 50), 120);
never executed (the execution status of this line is deduced): duration = qMin(qMax(dist/3, 50), 120);
-
463 }
never executed: }
0
464 -
465 connect(&anim, SIGNAL(timeout()), this, SLOT(scroll()));
never executed (the execution status of this line is deduced): connect(&anim, "2""timeout()", this, "1""scroll()");
-
466 -
467 move(widget->geometry().x(),widget->geometry().y());
never executed (the execution status of this line is deduced): move(widget->geometry().x(),widget->geometry().y());
-
468 resize(qMin(currentWidth, totalWidth), qMin(currentHeight, totalHeight));
never executed (the execution status of this line is deduced): resize(qMin(currentWidth, totalWidth), qMin(currentHeight, totalHeight));
-
469 -
470 //This is roughly equivalent to calling setVisible(true) without actually showing the widget -
471 widget->setAttribute(Qt::WA_WState_ExplicitShowHide, true);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_WState_ExplicitShowHide, true);
-
472 widget->setAttribute(Qt::WA_WState_Hidden, false);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_WState_Hidden, false);
-
473 -
474 show();
never executed (the execution status of this line is deduced): show();
-
475 setEnabled(false);
never executed (the execution status of this line is deduced): setEnabled(false);
-
476 -
477 showWidget = true;
never executed (the execution status of this line is deduced): showWidget = true;
-
478 done = false;
never executed (the execution status of this line is deduced): done = false;
-
479 anim.start(1);
never executed (the execution status of this line is deduced): anim.start(1);
-
480 checkTime.start();
never executed (the execution status of this line is deduced): checkTime.start();
-
481}
never executed: }
0
482 -
483/* -
484 Roll according to the time elapsed. -
485*/ -
486void QRollEffect::scroll() -
487{ -
488 if (!done && widget) {
never evaluated: !done
never evaluated: widget
0
489 int tempel = checkTime.elapsed();
never executed (the execution status of this line is deduced): int tempel = checkTime.elapsed();
-
490 if (elapsed >= tempel)
never evaluated: elapsed >= tempel
0
491 elapsed++;
never executed: elapsed++;
0
492 else -
493 elapsed = tempel;
never executed: elapsed = tempel;
0
494 -
495 if (currentWidth != totalWidth) {
never evaluated: currentWidth != totalWidth
0
496 currentWidth = totalWidth * (elapsed/duration)
never executed (the execution status of this line is deduced): currentWidth = totalWidth * (elapsed/duration)
-
497 + (2 * totalWidth * (elapsed%duration) + duration)
never executed (the execution status of this line is deduced): + (2 * totalWidth * (elapsed%duration) + duration)
-
498 / (2 * duration);
never executed (the execution status of this line is deduced): / (2 * duration);
-
499 // equiv. to int((totalWidth*elapsed) / duration + 0.5) -
500 done = (currentWidth >= totalWidth);
never executed (the execution status of this line is deduced): done = (currentWidth >= totalWidth);
-
501 }
never executed: }
0
502 if (currentHeight != totalHeight) {
never evaluated: currentHeight != totalHeight
0
503 currentHeight = totalHeight * (elapsed/duration)
never executed (the execution status of this line is deduced): currentHeight = totalHeight * (elapsed/duration)
-
504 + (2 * totalHeight * (elapsed%duration) + duration)
never executed (the execution status of this line is deduced): + (2 * totalHeight * (elapsed%duration) + duration)
-
505 / (2 * duration);
never executed (the execution status of this line is deduced): / (2 * duration);
-
506 // equiv. to int((totalHeight*elapsed) / duration + 0.5) -
507 done = (currentHeight >= totalHeight);
never executed (the execution status of this line is deduced): done = (currentHeight >= totalHeight);
-
508 }
never executed: }
0
509 done = (currentHeight >= totalHeight) &&
never evaluated: (currentHeight >= totalHeight)
0
510 (currentWidth >= totalWidth);
never evaluated: (currentWidth >= totalWidth)
0
511 -
512 int w = totalWidth;
never executed (the execution status of this line is deduced): int w = totalWidth;
-
513 int h = totalHeight;
never executed (the execution status of this line is deduced): int h = totalHeight;
-
514 int x = widget->geometry().x();
never executed (the execution status of this line is deduced): int x = widget->geometry().x();
-
515 int y = widget->geometry().y();
never executed (the execution status of this line is deduced): int y = widget->geometry().y();
-
516 -
517 if (orientation & RightScroll || orientation & LeftScroll)
never evaluated: orientation & RightScroll
never evaluated: orientation & LeftScroll
0
518 w = qMin(currentWidth, totalWidth);
never executed: w = qMin(currentWidth, totalWidth);
0
519 if (orientation & DownScroll || orientation & UpScroll)
never evaluated: orientation & DownScroll
never evaluated: orientation & UpScroll
0
520 h = qMin(currentHeight, totalHeight);
never executed: h = qMin(currentHeight, totalHeight);
0
521 -
522 setUpdatesEnabled(false);
never executed (the execution status of this line is deduced): setUpdatesEnabled(false);
-
523 if (orientation & UpScroll)
never evaluated: orientation & UpScroll
0
524 y = widget->geometry().y() + qMax(0, totalHeight - currentHeight);
never executed: y = widget->geometry().y() + qMax(0, totalHeight - currentHeight);
0
525 if (orientation & LeftScroll)
never evaluated: orientation & LeftScroll
0
526 x = widget->geometry().x() + qMax(0, totalWidth - currentWidth);
never executed: x = widget->geometry().x() + qMax(0, totalWidth - currentWidth);
0
527 if (orientation & UpScroll || orientation & LeftScroll)
never evaluated: orientation & UpScroll
never evaluated: orientation & LeftScroll
0
528 move(x, y);
never executed: move(x, y);
0
529 -
530 resize(w, h);
never executed (the execution status of this line is deduced): resize(w, h);
-
531 setUpdatesEnabled(true);
never executed (the execution status of this line is deduced): setUpdatesEnabled(true);
-
532 repaint();
never executed (the execution status of this line is deduced): repaint();
-
533 }
never executed: }
0
534 if (done || !widget) {
never evaluated: done
never evaluated: !widget
0
535 anim.stop();
never executed (the execution status of this line is deduced): anim.stop();
-
536 if (widget) {
never evaluated: widget
0
537 if (!showWidget) {
never evaluated: !showWidget
0
538#ifdef Q_OS_WIN -
539 setEnabled(true); -
540 setFocus(); -
541#endif -
542 widget->hide();
never executed (the execution status of this line is deduced): widget->hide();
-
543 } else {
never executed: }
0
544 //Since we are faking the visibility of the widget -
545 //we need to unset the hidden state on it before calling show -
546 widget->setAttribute(Qt::WA_WState_Hidden, true);
never executed (the execution status of this line is deduced): widget->setAttribute(Qt::WA_WState_Hidden, true);
-
547 widget->show();
never executed (the execution status of this line is deduced): widget->show();
-
548 lower();
never executed (the execution status of this line is deduced): lower();
-
549 }
never executed: }
0
550 } -
551 q_roll = 0;
never executed (the execution status of this line is deduced): q_roll = 0;
-
552 deleteLater();
never executed (the execution status of this line is deduced): deleteLater();
-
553 }
never executed: }
0
554}
never executed: }
0
555 -
556/*! -
557 Scroll widget \a w in \a time ms. \a orient may be 1 (vertical), 2 -
558 (horizontal) or 3 (diagonal). -
559*/ -
560void qScrollEffect(QWidget* w, QEffects::DirFlags orient, int time) -
561{ -
562 if (q_roll) {
partially evaluated: q_roll
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
563 q_roll->deleteLater();
never executed (the execution status of this line is deduced): q_roll->deleteLater();
-
564 q_roll = 0;
never executed (the execution status of this line is deduced): q_roll = 0;
-
565 }
never executed: }
0
566 -
567 if (!w)
partially evaluated: !w
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
568 return;
executed: return;
Execution Count:1
1
569 -
570 QApplication::sendPostedEvents(w, QEvent::Move);
never executed (the execution status of this line is deduced): QApplication::sendPostedEvents(w, QEvent::Move);
-
571 QApplication::sendPostedEvents(w, QEvent::Resize);
never executed (the execution status of this line is deduced): QApplication::sendPostedEvents(w, QEvent::Resize);
-
572 Qt::WindowFlags flags = Qt::ToolTip;
never executed (the execution status of this line is deduced): Qt::WindowFlags flags = Qt::ToolTip;
-
573 -
574 // those can be popups - they would steal the focus, but are disabled -
575 q_roll = new QRollEffect(w, flags, orient);
never executed (the execution status of this line is deduced): q_roll = new QRollEffect(w, flags, orient);
-
576 q_roll->run(time);
never executed (the execution status of this line is deduced): q_roll->run(time);
-
577}
never executed: }
0
578 -
579/*! -
580 Fade in widget \a w in \a time ms. -
581*/ -
582void qFadeEffect(QWidget* w, int time) -
583{ -
584 if (q_blend) {
partially evaluated: q_blend
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
585 q_blend->deleteLater();
never executed (the execution status of this line is deduced): q_blend->deleteLater();
-
586 q_blend = 0;
never executed (the execution status of this line is deduced): q_blend = 0;
-
587 }
never executed: }
0
588 -
589 if (!w)
partially evaluated: !w
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
590 return;
executed: return;
Execution Count:1
1
591 -
592 QApplication::sendPostedEvents(w, QEvent::Move);
never executed (the execution status of this line is deduced): QApplication::sendPostedEvents(w, QEvent::Move);
-
593 QApplication::sendPostedEvents(w, QEvent::Resize);
never executed (the execution status of this line is deduced): QApplication::sendPostedEvents(w, QEvent::Resize);
-
594 -
595 Qt::WindowFlags flags = Qt::ToolTip;
never executed (the execution status of this line is deduced): Qt::WindowFlags flags = Qt::ToolTip;
-
596 -
597 // those can be popups - they would steal the focus, but are disabled -
598 q_blend = new QAlphaWidget(w, flags);
never executed (the execution status of this line is deduced): q_blend = new QAlphaWidget(w, flags);
-
599 -
600 q_blend->run(time);
never executed (the execution status of this line is deduced): q_blend->run(time);
-
601}
never executed: }
0
602 -
603QT_END_NAMESPACE -
604 -
605/* -
606 Delete this after timeout -
607*/ -
608 -
609#include "qeffects.moc" -
610 -
611#endif //QT_NO_EFFECTS -
612 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial