Commit bf650409 authored by Mike Kremer's avatar Mike Kremer

Do slide-down animation after a certain timeout in order to give the user the...

Do slide-down animation after a certain timeout in order to give the user the opportunity to re-enter the logger widget.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11997 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7043fdca
......@@ -54,11 +54,11 @@
#define BACKGROUND_BLUE 0xff
#define BACKGROUND_ALPHA 0xcf
#define SLIDE_DURATION 400
#define SLIDE_DURATION 300
#define WAIT_UNTIL_SLIDE_DOWN 500
//== INCLUDES =================================================================
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QPainter>
......@@ -81,7 +81,8 @@ QtSlideWindow::QtSlideWindow(QString _name, QGraphicsItem *_parent) :
detachButton_(0),
dialog_(0),
down_(false),
animating_(false) {
animating_(false),
timer_(0) {
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
setWindowFrameMargins(2, 15, 2, 2);
......@@ -103,9 +104,16 @@ QtSlideWindow::QtSlideWindow(QString _name, QGraphicsItem *_parent) :
// Create animation object
animation_ = new QPropertyAnimation(this, "pos");
animation_->setDuration(300); // 300 ms animation
animation_->setDuration(SLIDE_DURATION);
connect(animation_, SIGNAL(finished()), this, SLOT(animationFinished()));
// Create timer
timer_ = new QTimer();
timer_->setSingleShot(true);
// Wait some milliseconds before starting the actual slide down animation
connect(timer_, SIGNAL(timeout()), this, SLOT(startSlideDownAnimation()));
// Hide widget
hide();
......@@ -202,6 +210,13 @@ Qt::WindowFrameSection QtSlideWindow::windowFrameSectionAt(const QPointF &_pos)
void QtSlideWindow::hoverEnterEvent(QGraphicsSceneHoverEvent *) {
// Stop slide down action after timeout if the cursor
// re-enters the logger within the timeout interval
if(timer_->isActive()) {
timer_->stop();
return;
}
// Don't do anything if animation is currently in progress
if(animating_) return;
......@@ -312,6 +327,8 @@ void QtSlideWindow::animationFinished() {
animating_ = false;
}
//-----------------------------------------------------------------------------
void QtSlideWindow::slideUp() {
if(!widget()) return;
......@@ -335,6 +352,13 @@ void QtSlideWindow::slideDown() {
updateParentGeometry();
timer_->start(WAIT_UNTIL_SLIDE_DOWN);
}
//-----------------------------------------------------------------------------
void QtSlideWindow::startSlideDownAnimation() {
down_ = true;
animating_ = true;
......
......@@ -54,6 +54,7 @@
#include <QSettings>
#include <QGraphicsProxyWidget>
#include <QPropertyAnimation>
#include <QTimer>
#include <OpenFlipper/common/GlobalDefines.hh>
......@@ -140,6 +141,9 @@ class DLLEXPORT QtSlideWindow : public QGraphicsProxyWidget
// Slot is called whenever the animation is finished
void animationFinished();
// Start actual slide down
void startSlideDownAnimation();
private:
// name
......@@ -169,6 +173,9 @@ class DLLEXPORT QtSlideWindow : public QGraphicsProxyWidget
// Is widget animating in this moment?
bool animating_;
// Wait some milliseconds before sliding widget down
QTimer* timer_;
};
//=============================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment