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) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets 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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <QtCore/qpropertyanimation.h>-
41#include <QtWidgets/qwidget.h>-
42#include <QtWidgets/qstyle.h>-
43#include <private/qmainwindowlayout_p.h>-
44-
45#include "qwidgetanimator_p.h"-
46-
47QT_BEGIN_NAMESPACE-
48-
49QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout)-
50{-
51}
never executed: end of block
0
52-
53void QWidgetAnimator::abort(QWidget *w)-
54{-
55#ifndef QT_NO_ANIMATION-
56 const auto it = m_animation_map.constFind(w);-
57 if (it == m_animation_map.cend())
it == m_animation_map.cend()Description
TRUEnever evaluated
FALSEnever evaluated
0
58 return;
never executed: return;
0
59 QPropertyAnimation *anim = *it;-
60 m_animation_map.erase(it);-
61 if (anim) {
animDescription
TRUEnever evaluated
FALSEnever evaluated
0
62 anim->stop();-
63 }
never executed: end of block
0
64#ifndef QT_NO_MAINWINDOW-
65 m_mainWindowLayout->animationFinished(w);-
66#endif-
67#else-
68 Q_UNUSED(w); //there is no animation to abort-
69#endif //QT_NO_ANIMATION-
70}
never executed: end of block
0
71-
72#ifndef QT_NO_ANIMATION-
73void QWidgetAnimator::animationFinished()-
74{-
75 QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());-
76 abort(static_cast<QWidget*>(anim->targetObject()));
never executed: abort(static_cast<QWidget*>(anim->targetObject()));
0
77}-
78#endif //QT_NO_ANIMATION-
79-
80void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)-
81{-
82 QRect r = widget->geometry();-
83 if (r.right() < 0 || r.bottom() < 0)
r.right() < 0Description
TRUEnever evaluated
FALSEnever evaluated
r.bottom() < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
84 r = QRect();
never executed: r = QRect();
0
85-
86 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
87-
88 // might make the wigdet go away by sending it to negative space-
89 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
90 QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());-
91-
92#ifndef QT_NO_ANIMATION-
93 //If the QStyle has animations, animate-
94 if (widget->style()->styleHint(QStyle::SH_Widget_Animate, 0, widget)) {
widget->style(...te, 0, widget)Description
TRUEnever evaluated
FALSEnever evaluated
0
95 AnimationMap::const_iterator it = m_animation_map.constFind(widget);-
96 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
97 return;
never executed: return;
0
98-
99 QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);-
100 anim->setDuration(animate ? 200 : 0);-
101 anim->setEasingCurve(QEasingCurve::InOutQuad);-
102 anim->setEndValue(final_geometry);-
103 m_animation_map[widget] = anim;-
104 connect(anim, SIGNAL(finished()), SLOT(animationFinished()));-
105 anim->start(QPropertyAnimation::DeleteWhenStopped);-
106 } else
never executed: end of block
0
107#endif //QT_NO_ANIMATION-
108 {-
109 //we do it in one shot-
110 widget->setGeometry(final_geometry);-
111#ifndef QT_NO_MAINWINDOW-
112 m_mainWindowLayout->animationFinished(widget);-
113#endif //QT_NO_MAINWINDOW-
114 }
never executed: end of block
0
115}-
116-
117bool QWidgetAnimator::animating() const-
118{-
119 return !m_animation_map.isEmpty();
never executed: return !m_animation_map.isEmpty();
0
120}-
121-
122QT_END_NAMESPACE-
123-
124#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