qwidgetanimator.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qwidgetanimator.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include <QtCore/qpropertyanimation.h>-
35#include <QtWidgets/qwidget.h>-
36#include <QtWidgets/qstyle.h>-
37#include <private/qmainwindowlayout_p.h>-
38-
39#include "qwidgetanimator_p.h"-
40-
41QT_BEGIN_NAMESPACE-
42-
43QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout)-
44{-
45}
never executed: end of block
0
46-
47void QWidgetAnimator::abort(QWidget *w)-
48{-
49#ifndef QT_NO_ANIMATION-
50 AnimationMap::iterator it = m_animation_map.find(w);-
51 if (it == m_animation_map.end())
it == m_animation_map.end()Description
TRUEnever evaluated
FALSEnever evaluated
0
52 return;
never executed: return;
0
53 QPropertyAnimation *anim = *it;-
54 m_animation_map.erase(it);-
55 if (anim) {
animDescription
TRUEnever evaluated
FALSEnever evaluated
0
56 anim->stop();-
57 }
never executed: end of block
0
58#ifndef QT_NO_MAINWINDOW-
59 m_mainWindowLayout->animationFinished(w);-
60#endif-
61#else-
62 Q_UNUSED(w); //there is no animation to abort-
63#endif //QT_NO_ANIMATION-
64}
never executed: end of block
0
65-
66#ifndef QT_NO_ANIMATION-
67void QWidgetAnimator::animationFinished()-
68{-
69 QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());-
70 abort(static_cast<QWidget*>(anim->targetObject()));
never executed: abort(static_cast<QWidget*>(anim->targetObject()));
0
71}-
72#endif //QT_NO_ANIMATION-
73-
74void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)-
75{-
76 QRect r = widget->geometry();-
77 if (r.right() < 0 || r.bottom() < 0)
r.right() < 0Description
TRUEnever evaluated
FALSEnever evaluated
r.bottom() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
78 r = QRect();
never executed: r = QRect();
0
79-
80 animate = animate && !r.isNull() && !_final_geometry.isNull();
animateDescription
TRUEnever evaluated
FALSEnever evaluated
!r.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!_final_geometry.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
81-
82 // might make the wigdet go away by sending it to negative space-
83 const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry :
_final_geometry.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
widget->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
84 QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());-
85-
86#ifndef QT_NO_ANIMATION-
87 //If the QStyle has animations, animate-
88 if (widget->style()->styleHint(QStyle::SH_Widget_Animate, 0, widget)) {
widget->style(...te, 0, widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
89 AnimationMap::const_iterator it = m_animation_map.constFind(widget);-
90 if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
it != m_animat...map.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
(*it)->endValu...final_geometryDescription
TRUEnever evaluated
FALSEnever evaluated
0
91 return;
never executed: return;
0
92-
93 QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);-
94 anim->setDuration(animate ? 200 : 0);-
95 anim->setEasingCurve(QEasingCurve::InOutQuad);-
96 anim->setEndValue(final_geometry);-
97 m_animation_map[widget] = anim;-
98 connect(anim, SIGNAL(finished()), SLOT(animationFinished()));-
99 anim->start(QPropertyAnimation::DeleteWhenStopped);-
100 } else
never executed: end of block
0
101#endif //QT_NO_ANIMATION-
102 {-
103 //we do it in one shot-
104 widget->setGeometry(final_geometry);-
105#ifndef QT_NO_MAINWINDOW-
106 m_mainWindowLayout->animationFinished(widget);-
107#endif //QT_NO_MAINWINDOW-
108 }
never executed: end of block
0
109}-
110-
111bool QWidgetAnimator::animating() const-
112{-
113 return !m_animation_map.isEmpty();
never executed: return !m_animation_map.isEmpty();
0
114}-
115-
116QT_END_NAMESPACE-
117-
118#include "moc_qwidgetanimator_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9