diff --git a/src/lib/3rdparty/fancytabwidget.cpp b/src/lib/3rdparty/fancytabwidget.cpp index 750caab25..30bc29e74 100644 --- a/src/lib/3rdparty/fancytabwidget.cpp +++ b/src/lib/3rdparty/fancytabwidget.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -124,7 +123,7 @@ void FancyTabProxyStyle::drawControl( int textFlags = Qt::AlignHCenter | Qt::AlignVCenter; p->drawText(text_rect, textFlags, text); p->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor()); -#ifndef Q_WS_MAC +#if 0 if (widget) { const QString fader_key = "tab_" + text + "_fader"; const QString animation_key = "tab_" + text + "_animation"; @@ -220,25 +219,25 @@ bool FancyTabProxyStyle::eventFilter(QObject* o, QEvent* e) FancyTab::FancyTab(QWidget* tabbar) : QWidget(tabbar), tabbar(tabbar), m_fader(0) { - animator.setPropertyName("fader"); - animator.setTargetObject(this); +// animator.setPropertyName("fader"); +// animator.setTargetObject(this); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); } void FancyTab::fadeIn() { - animator.stop(); - animator.setDuration(80); - animator.setEndValue(40); - animator.start(); +// animator.stop(); +// animator.setDuration(80); +// animator.setEndValue(40); +// animator.start(); } void FancyTab::fadeOut() { - animator.stop(); - animator.setDuration(160); - animator.setEndValue(0); - animator.start(); +// animator.stop(); +// animator.setDuration(160); +// animator.setEndValue(0); +// animator.start(); } void FancyTab::setFader(float value) diff --git a/src/lib/3rdparty/fancytabwidget.h b/src/lib/3rdparty/fancytabwidget.h index 572d6b7f4..39804b640 100644 --- a/src/lib/3rdparty/fancytabwidget.h +++ b/src/lib/3rdparty/fancytabwidget.h @@ -33,7 +33,6 @@ #include "qz_namespace.h" #include -#include #include #include #include @@ -90,7 +89,6 @@ protected: void leaveEvent(QEvent*); private: - QPropertyAnimation animator; QWidget* tabbar; float m_fader; }; @@ -231,8 +229,6 @@ private: } // namespace Internal } // namespace Core -Q_DECLARE_METATYPE(QPropertyAnimation*); - using Core::Internal::FancyTab; using Core::Internal::FancyTabBar; using Core::Internal::FancyTabWidget; diff --git a/src/lib/tools/animatedwidget.cpp b/src/lib/tools/animatedwidget.cpp index 00b89742b..a91854a2d 100644 --- a/src/lib/tools/animatedwidget.cpp +++ b/src/lib/tools/animatedwidget.cpp @@ -17,64 +17,62 @@ * ============================================================ */ #include "animatedwidget.h" -#include -#include #include AnimatedWidget::AnimatedWidget(const Direction &direction, int duration, QWidget* parent) : QWidget(parent) - , m_widget(new QWidget(this)) - , Y_SHOWN(0) - , Y_HIDDEN(0) , m_direction(direction) + , m_stepHeight(0) + , m_stepY(0) + , m_widget(new QWidget(this)) { - m_positionAni = new QPropertyAnimation(m_widget, "pos"); - m_positionAni->setDuration(duration); - - m_heightAni = new QPropertyAnimation(this, "fixedheight"); - m_heightAni->setDuration(duration); - - m_aniGroup = new QParallelAnimationGroup(this); - m_aniGroup->addAnimation(m_positionAni); - m_aniGroup->addAnimation(m_heightAni); + m_timeLine.setDuration(duration); + m_timeLine.setFrameRange(0, 100); + connect(&m_timeLine, SIGNAL(frameChanged(int)), this, SLOT(animateFrame(int))); setMaximumHeight(0); } void AnimatedWidget::startAnimation() { - if (m_aniGroup->state() == QAnimationGroup::Running) { + if (m_timeLine.state() == QTimeLine::Running) { return; } + int shown = 0; + int hidden = 0; + if (m_direction == Down) { - Y_SHOWN = 0; - Y_HIDDEN = -m_widget->height(); - } - else if (m_direction == Up) { - Y_SHOWN = 0; - Y_HIDDEN = 0; + shown = 0; + hidden = -m_widget->height(); } - m_widget->move(QPoint(m_widget->pos().x(), Y_HIDDEN)); + m_widget->move(QPoint(m_widget->pos().x(), hidden)); - m_positionAni->setEndValue(QPoint(m_widget->pos().x(), Y_SHOWN)); - m_heightAni->setEndValue(m_widget->height()); + m_stepY = (hidden - shown) / 100.0; + m_startY = hidden; + m_stepHeight = m_widget->height() / 100.0; - m_aniGroup->start(); + m_timeLine.setDirection(QTimeLine::Forward); + m_timeLine.start(); +} + +void AnimatedWidget::animateFrame(int frame) +{ + setFixedHeight(frame * m_stepHeight); + m_widget->move(pos().x(), m_startY - frame * m_stepY); } void AnimatedWidget::hide() { - if (m_aniGroup->state() == QAnimationGroup::Running) { + if (m_timeLine.state() == QTimeLine::Running) { return; } - m_positionAni->setEndValue(QPoint(m_widget->pos().x(), Y_HIDDEN)); - m_heightAni->setEndValue(0); + m_timeLine.setDirection(QTimeLine::Backward); + m_timeLine.start(); - m_aniGroup->start(); - connect(m_aniGroup, SIGNAL(finished()), this, SLOT(close())); + connect(&m_timeLine, SIGNAL(finished()), this, SLOT(close())); } void AnimatedWidget::resizeEvent(QResizeEvent* event) @@ -85,7 +83,3 @@ void AnimatedWidget::resizeEvent(QResizeEvent* event) QWidget::resizeEvent(event); } - -AnimatedWidget::~AnimatedWidget() -{ -} diff --git a/src/lib/tools/animatedwidget.h b/src/lib/tools/animatedwidget.h index 6cabb6c64..f6b7a1a6d 100644 --- a/src/lib/tools/animatedwidget.h +++ b/src/lib/tools/animatedwidget.h @@ -19,21 +19,18 @@ #define NOTIFICATION_H #include +#include #include "qz_namespace.h" -class QPropertyAnimation; -class QParallelAnimationGroup; - class QT_QUPZILLA_EXPORT AnimatedWidget : public QWidget { Q_OBJECT - Q_PROPERTY(int fixedheight READ height WRITE setFixedHeight) public: enum Direction { Down, Up }; + explicit AnimatedWidget(const Direction &direction = Down, int duration = 300, QWidget* parent = 0); - ~AnimatedWidget(); QWidget* widget() { return m_widget; } @@ -41,18 +38,19 @@ public slots: void hide(); void startAnimation(); +private slots: + void animateFrame(int frame); + private: void resizeEvent(QResizeEvent* e); - QPropertyAnimation* m_positionAni; - QPropertyAnimation* m_heightAni; - QParallelAnimationGroup* m_aniGroup; + Direction m_direction; + QTimeLine m_timeLine; + qreal m_stepHeight; + qreal m_stepY; + int m_startY; QWidget* m_widget; - - int Y_SHOWN; - int Y_HIDDEN; - Direction m_direction; }; #endif // NOTIFICATION_H diff --git a/src/lib/webview/searchtoolbar.h b/src/lib/webview/searchtoolbar.h index 18cdb5df4..b163196b6 100644 --- a/src/lib/webview/searchtoolbar.h +++ b/src/lib/webview/searchtoolbar.h @@ -60,7 +60,6 @@ private: Ui::SearchToolbar* ui; QupZilla* p_QupZilla; - QPropertyAnimation* m_animation; QWebPage::FindFlags m_findFlags; };