Qt 4.8
Public Functions | Private Types | Private Slots | Properties | List of all members
QWidgetAnimator Class Reference

#include <qwidgetanimator_p.h>

Inheritance diagram for QWidgetAnimator:
QObject

Public Functions

void abort (QWidget *widget)
 
void animate (QWidget *widget, const QRect &final_geometry, bool animate)
 
bool animating () const
 
 QWidgetAnimator (QMainWindowLayout *layout)
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Types

typedef QMap< QWidget *, QPointer< QPropertyAnimation > > AnimationMap
 

Private Slots

void animationFinished ()
 

Properties

AnimationMap m_animation_map
 
QMainWindowLayoutm_mainWindowLayout
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 67 of file qwidgetanimator_p.h.

Typedefs

◆ AnimationMap

Definition at line 83 of file qwidgetanimator_p.h.

Constructors and Destructors

◆ QWidgetAnimator()

QWidgetAnimator::QWidgetAnimator ( QMainWindowLayout layout)

Definition at line 50 of file qwidgetanimator.cpp.

50  : m_mainWindowLayout(layout)
51 {
52 }
QMainWindowLayout * m_mainWindowLayout

Functions

◆ abort()

void QWidgetAnimator::abort ( QWidget widget)

Definition at line 54 of file qwidgetanimator.cpp.

Referenced by animationFinished().

55 {
56 #ifndef QT_NO_ANIMATION
58  if (it == m_animation_map.end())
59  return;
60  QPropertyAnimation *anim = *it;
62  if (anim) {
63  anim->stop();
64  }
65 #ifndef QT_NO_MAINWINDOW
67 #endif
68 #else
69  Q_UNUSED(w); //there is no animation to abort
70 #endif //QT_NO_ANIMATION
71 }
The QPropertyAnimation class animates Qt properties.
#define it(className, varName)
iterator find(const Key &key)
Returns an iterator pointing to the item with key key in the map.
Definition: qmap.h:618
QMainWindowLayout * m_mainWindowLayout
void stop()
Stops the animation.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:375
iterator erase(iterator it)
Removes the (key, value) pair pointed to by the iterator pos from the map, and returns an iterator to...
Definition: qmap.h:717
void animationFinished(QWidget *widget)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
AnimationMap m_animation_map

◆ animate()

void QWidgetAnimator::animate ( QWidget widget,
const QRect final_geometry,
bool  animate 
)

Definition at line 81 of file qwidgetanimator.cpp.

Referenced by QMainWindowLayoutState::apply(), QDockAreaLayoutInfo::apply(), QToolBarAreaLayout::apply(), and QDockAreaLayout::apply().

82 {
83  QRect r = widget->geometry();
84  if (r.right() < 0 || r.bottom() < 0)
85  r = QRect();
86 
87  animate = animate && !r.isNull() && !_final_geometry.isNull();
88 
89  // might make the wigdet go away by sending it to negative space
90  const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry :
91  QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());
92 
93 #ifndef QT_NO_ANIMATION
95  if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
96  return;
97 
98  QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);
99  anim->setDuration(animate ? 200 : 0);
101  anim->setEndValue(final_geometry);
102  m_animation_map[widget] = anim;
103  connect(anim, SIGNAL(finished()), SLOT(animationFinished()));
105 #else
106  //we do it in one shot
107  widget->setGeometry(final_geometry);
108 #ifndef QT_NO_MAINWINDOW
110 #endif //QT_NO_MAINWINDOW
111 #endif //QT_NO_ANIMATION
112 }
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:231
The QPropertyAnimation class animates Qt properties.
QPointer< QWidget > widget
int width
the width of the widget excluding any window frame
Definition: qwidget.h:166
#define it(className, varName)
bool isWindow() const
Returns true if the widget is an independent window, otherwise returns false.
Definition: qwidget.h:945
#define SLOT(a)
Definition: qobjectdefs.h:226
void setEasingCurve(const QEasingCurve &easing)
void start(QAbstractAnimation::DeletionPolicy policy=KeepWhenStopped)
Starts the animation.
void setGeometry(int x, int y, int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qwidget.h:1017
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void setEndValue(const QVariant &value)
QMainWindowLayout * m_mainWindowLayout
void setDuration(int msecs)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
int height
the height of the widget excluding any window frame
Definition: qwidget.h:167
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:165
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const_iterator constFind(const Key &key) const
Returns an const iterator pointing to the item with key key in the map.
Definition: qmap.h:612
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
void animationFinished(QWidget *widget)
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
void animate(QWidget *widget, const QRect &final_geometry, bool animate)
AnimationMap m_animation_map

◆ animating()

bool QWidgetAnimator::animating ( ) const

Definition at line 114 of file qwidgetanimator.cpp.

Referenced by QMainWindowLayout::updateGapIndicator().

115 {
116  return !m_animation_map.isEmpty();
117 }
bool isEmpty() const
Returns true if the map contains no items; otherwise returns false.
Definition: qmap.h:203
AnimationMap m_animation_map

◆ animationFinished

void QWidgetAnimator::animationFinished ( )
privateslot

Definition at line 74 of file qwidgetanimator.cpp.

Referenced by animate().

75 {
77  abort(static_cast<QWidget*>(anim->targetObject()));
78 }
The QPropertyAnimation class animates Qt properties.
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QObject * targetObject
the target QObject for this animation.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
void abort(QWidget *widget)

Properties

◆ m_animation_map

AnimationMap QWidgetAnimator::m_animation_map
private

Definition at line 84 of file qwidgetanimator_p.h.

Referenced by abort(), animate(), and animating().

◆ m_mainWindowLayout

QMainWindowLayout* QWidgetAnimator::m_mainWindowLayout
private

Definition at line 85 of file qwidgetanimator_p.h.

Referenced by abort(), and animate().


The documentation for this class was generated from the following files: