void AnimatedSplitter::show( int index, bool animate ) { m_animateIndex = index; QWidget* w = widget( index ); QSize size = w->sizeHint(); if ( w->height() == size.height() ) return; emit shown( w ); w->setMaximumHeight( QWIDGETSIZE_MAX ); qDebug() << "animating to:" << size.height() << "from" << w->height(); m_animateForward = true; if ( animate ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( w->height(), size.height() ); m_timeLine->setDirection( QTimeLine::Forward ); m_timeLine->start(); } else { onAnimationStep( size.height() ); onAnimationFinished(); } }
void AnimatedSplitter::hide( int index, bool animate ) { m_animateIndex = index; QWidget* w = widget( index ); int minHeight = m_sizes.at( index ).height(); if ( w->height() == minHeight ) return; emit hidden( w ); w->setMinimumHeight( minHeight ); qDebug() << "animating to:" << w->height() << "from" << minHeight; m_animateForward = false; if ( animate ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( minHeight, w->height() ); m_timeLine->setDirection( QTimeLine::Backward ); m_timeLine->start(); } else { onAnimationStep( minHeight ); onAnimationFinished(); } }
void AnimatedWidget::onHidden( QWidget* widget, bool animated ) { if ( widget != this ) return; m_animateForward = false; int minHeight = hiddenSize().height(); if ( animated ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( minHeight, height() ); m_timeLine->setDirection( QTimeLine::Backward ); m_timeLine->start(); } else { onAnimationStep( minHeight ); onAnimationFinished(); } m_isHidden = true; }
AnimatedWidget::AnimatedWidget( AnimatedSplitter* parent ) : m_parent( parent ) , m_isHidden( false ) { m_timeLine = new QTimeLine( ANIMATION_TIME, this ); m_timeLine->setUpdateInterval( 20 ); m_timeLine->setEasingCurve( QEasingCurve::OutCubic ); connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) ); connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) ); }
MibitDialog::MibitDialog( QWidget *parent, const QString &msg, const QString &file, const QPixmap &icon, AnimationType animation ) : QSvgWidget( parent ) { if (file != 0) setSVG(file); m_parent = parent; animType = animation; setMinimumHeight(100); setFixedSize(0,0); //until show we grow it setMaxHeight(maxH); //default sizes setMaxWidth(maxW); animRate = 500; //default animation speed (half second rate). shakeTimeToLive = 0; par = false; parTimes = 0; img = new QLabel(); hLayout = new QHBoxLayout(); vLayout = new QVBoxLayout(); text = new QLabel(msg); btnClose = new QPushButton("Close"); ///TODO: what about translations??? shakeTimer = new QTimer(this); shakeTimer->setInterval(20); img->setPixmap(icon); img->setMaximumHeight(54); //the icon size is hardcoded now. img->setMaximumWidth(54); img->setAlignment(Qt::AlignLeft); img->setMargin(4); btnClose->setMaximumWidth(120); setLayout(vLayout); text->setWordWrap(true); text->setAlignment(Qt::AlignJustify|Qt::AlignVCenter); text->setMargin(5); hLayout->addWidget(img,0,Qt::AlignCenter); hLayout->addWidget(text,1,Qt::AlignCenter); vLayout->addLayout(hLayout,2); vLayout->addWidget(btnClose,1,Qt::AlignCenter); timeLine = new QTimeLine(animRate, this); wTimeLine = new QTimeLine(2000, this); wTimeLine->setFrameRange(90,190); wTimeLine->setCurveShape(QTimeLine::CosineCurve); connect(timeLine, SIGNAL(frameChanged(int)), this, SLOT(animate(int))); connect(wTimeLine, SIGNAL(frameChanged(int)), this, SLOT(waveIt(int))); connect(btnClose,SIGNAL(clicked()),this, SLOT(hideDialog())); connect(timeLine,SIGNAL(finished()), this, SLOT(onAnimationFinished())); connect(shakeTimer,SIGNAL(timeout()), this, SLOT(shakeIt())); }
AnimatedSplitter::AnimatedSplitter( QWidget* parent ) : QSplitter( parent ) , m_animateIndex( -1 ) , m_greedyIndex( 0 ) { setHandleWidth( 1 ); m_timeLine = new QTimeLine( ANIMATION_TIME, this ); m_timeLine->setUpdateInterval( 5 ); m_timeLine->setEasingCurve( QEasingCurve::OutBack ); connect( m_timeLine, SIGNAL( frameChanged( int ) ), SLOT( onAnimationStep( int ) ) ); connect( m_timeLine, SIGNAL( finished() ), SLOT( onAnimationFinished() ) ); }
void AnimatedWidget::onShown( QWidget* widget, bool animated ) { if ( widget != this ) return; m_animateForward = true; if ( animated ) { if ( m_timeLine->state() == QTimeLine::Running ) m_timeLine->stop(); m_timeLine->setFrameRange( height(), sizeHint().height() ); m_timeLine->setDirection( QTimeLine::Forward ); m_timeLine->start(); } else { onAnimationStep( sizeHint().height() ); onAnimationFinished(); } m_isHidden = false; }
foreach (TrailerProvider *provider, Manager::instance()->trailerProviders()) { ui->comboScraper->addItem(provider->name(), Manager::instance()->trailerProviders().indexOf(provider)); connect(provider, SIGNAL(sigSearchDone(QList<ScraperSearchResult>)), this, SLOT(showResults(QList<ScraperSearchResult>))); connect(provider, SIGNAL(sigLoadDone(QList<TrailerResult>)), this, SLOT(showTrailers(QList<TrailerResult>))); } connect(ui->comboScraper, SIGNAL(currentIndexChanged(int)), this, SLOT(search())); connect(ui->searchString, SIGNAL(returnPressed()), this, SLOT(search())); connect(ui->results, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(resultClicked(QTableWidgetItem*))); connect(ui->trailers, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(trailerClicked(QTableWidgetItem*))); connect(ui->buttonBackToResults, SIGNAL(clicked()), this, SLOT(backToResults())); connect(ui->buttonBackToTrailers, SIGNAL(clicked()), this, SLOT(backToTrailers())); connect(ui->buttonDownload, SIGNAL(clicked()), this, SLOT(startDownload())); connect(ui->buttonCancelDownload, SIGNAL(clicked()), this, SLOT(cancelDownload())); connect(ui->stackedWidget, SIGNAL(animationFinished()), this, SLOT(onAnimationFinished())); m_mediaPlayer = new QMediaPlayer(); m_videoWidget = new QVideoWidget(this); m_mediaPlayer->setVideoOutput(m_videoWidget); QVBoxLayout *layout = new QVBoxLayout(ui->video); layout->addWidget(m_videoWidget); ui->video->setLayout(layout); connect(m_mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(onStateChanged(QMediaPlayer::State))); connect(m_mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(onNewTotalTime(qint64))); connect(m_mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(onUpdateTime(qint64))); connect(ui->btnPlayPause, SIGNAL(clicked()), this, SLOT(onPlayPause())); connect(ui->seekSlider, SIGNAL(sliderReleased()), this, SLOT(onSliderPositionChanged())); }