CubeView::CubeView(QWidget *parent) : QGLView(parent) , fbo(0) , tangle(0.0f) , cangle(0.0f) , oangle(0.0f) , needsUpdate(true) { innerCamera = new QGLCamera(this); QPropertyAnimation *animation; animation = new QPropertyAnimation(this, "teapotAngle", this); animation->setStartValue(0.0f); animation->setEndValue(360.0f); animation->setDuration(1000); animation->setLoopCount(-1); animation->start(); animation = new QPropertyAnimation(this, "cubeAngle", this); animation->setStartValue(0.0f); animation->setEndValue(360.0f); animation->setDuration(5000); animation->setLoopCount(-1); animation->start(); animation = new QPropertyAnimation(this, "orbitAngle", this); animation->setStartValue(0.0f); animation->setEndValue(360.0f); animation->setDuration(5000); animation->setLoopCount(-1); animation->start(); }
void ActiveLabel::showActiveWithAnimation() { if (m_loopCount != 0) return; m_loopCount = 0; setFixedSize(28, 13); emit sizeChange(); setVisible(true); m_iconPath = m_openingIndicatorIcon; QPropertyAnimation *animation = new QPropertyAnimation(this, "opacity"); animation->setDuration(500); animation->setStartValue(0); animation->setEndValue(1); animation->start(); connect(animation, &QPropertyAnimation::finished, [=]{ ++ m_loopCount; if (m_loopCount == 4){ m_loopCount = 0; emit showAnimationFinish(); } else{ if (m_loopCount % 2 == 0){ animation->setStartValue(0); animation->setEndValue(1); animation->start(); } else{ animation->setStartValue(1); animation->setEndValue(0); animation->start(); } } }); }
void HideBlock::showBlock() { if(block->isVisible()) { btnTitle->setIcon(QIcon(":/img/down.png")); QPropertyAnimation *animation = new QPropertyAnimation(block,"maximumHeight"); animation->setDuration(350); animation->setEasingCurve(QEasingCurve::OutCirc); animation->setStartValue(blockHeight); animation->setEndValue(0); animation->start(); connect(animation,SIGNAL(finished()),block,SLOT(hide())); } else { block->show(); btnTitle->setIcon(QIcon(":/img/up.png")); QPropertyAnimation *animation = new QPropertyAnimation(block,"maximumHeight"); animation->setDuration(500); animation->setEasingCurve(QEasingCurve::InCirc); animation->setStartValue(0); animation->setEndValue(blockHeight+10000); animation->start(); } }
void StatsGauge::setValue( int v ) { if ( maximum() == 0 || v == 0 ) return; if ( v == m_targetValue ) return; m_targetValue = v; { QPropertyAnimation* a = new QPropertyAnimation( (QProgressBar*)this, "value" ); a->setEasingCurve( QEasingCurve( QEasingCurve::OutQuad ) ); a->setStartValue( value() > 0 ? value() : 1 ); a->setEndValue( v ); a->setDuration( 2000 ); connect( a, SIGNAL( finished() ), a, SLOT( deleteLater() ) ); a->start(); } { QPropertyAnimation* a = new QPropertyAnimation( (QProgressBar*)this, "percentage" ); a->setEasingCurve( QEasingCurve( QEasingCurve::OutQuad ) ); a->setStartValue( (float)0 ); a->setEndValue( (float)v / (float)maximum() ); a->setDuration( 2000 ); connect( a, SIGNAL( finished() ), a, SLOT( deleteLater() ) ); a->start(); } }
void View::articleClicked() { Button *btn = dynamic_cast<Button*>(sender()); if (!btn) return; QPropertyAnimation *animation = new QPropertyAnimation(btn, "geometry"); animation->setDuration(750); animation->setEasingCurve(QEasingCurve::OutExpo); if (btn->isFront()) { btn->setZValue(1); animation->setStartValue(btn->geometry()); animation->setEndValue(btn->gridGeometry()); connect(animation, SIGNAL(finished()), btn, SLOT(setBack())); animation->start(); //_actButton = NULL; } else { if (_actButton != NULL && _actButton != btn) { delete animation; return; } btn->setFront(); btn->setGridGeometry(btn->geometry()); animation->setStartValue(btn->geometry()); unsigned int w = size().width() / 17; unsigned int h = (size().height() - _topBar->size().height()) / 15; animation->setEndValue(QRectF(w, h + _topBar->size().height(), 15 * w, 13 * h)); animation->start(); _actButton = btn; } btn->setEnabled(false); connect(animation, SIGNAL(finished()), animation, SLOT(deleteLater())); connect(animation, SIGNAL(finished()), this, SLOT(animationFinished())); }
void IconButton::animateShow(bool visible) { if (visible) { QPropertyAnimation *animation = new QPropertyAnimation(this, "iconOpacity"); animation->setDuration(FADE_TIME); animation->setEndValue(1.0); animation->start(QAbstractAnimation::DeleteWhenStopped); } else { QPropertyAnimation *animation = new QPropertyAnimation(this, "iconOpacity"); animation->setDuration(FADE_TIME); animation->setEndValue(0.0); animation->start(QAbstractAnimation::DeleteWhenStopped); } }
void FadeManager::start(bool deleteWhenFinished) { //TODO : Clean up ressources when finished and add similiar logic to groups QPropertyAnimation *anim; a_effectContainer = new QGraphicsOpacityEffect(this); anim = new QPropertyAnimation(a_effectContainer, "opacity", this); a_target->setGraphicsEffect(a_effectContainer); anim->setDuration(a_duration); setMode(anim, a_mode, a_effectContainer); if(deleteWhenFinished) anim->start(QAbstractAnimation::DeleteWhenStopped); else anim->start(); }
void Canvas::spinTo(float new_yaw, float new_pitch) { QPropertyAnimation* a = new QPropertyAnimation(this, "_yaw", this); a->setDuration(100); a->setStartValue(yaw); a->setEndValue(new_yaw); QPropertyAnimation* b = new QPropertyAnimation(this, "_pitch", this); b->setDuration(100); b->setStartValue(pitch); b->setEndValue(new_pitch); a->start(QPropertyAnimation::DeleteWhenStopped); b->start(QPropertyAnimation::DeleteWhenStopped); }
void RocketStorageInfoDialog::Open() { if (isVisible()) return; show(); setFocus(Qt::ActiveWindowFocusReason); activateWindow(); setWindowOpacity(0.0); QPropertyAnimation *showAnim = new QPropertyAnimation(this, "windowOpacity", this); showAnim->setStartValue(0.0); showAnim->setEndValue(1.0); showAnim->setDuration(300); showAnim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad)); showAnim->start(); plugin_->Notifications()->CenterToMainWindow(this); plugin_->Notifications()->DimForeground(); // If input mode is enabled, focus the input field and // select the text so user can start writing. if (ui.lineEditInput->isVisible()) { ui.lineEditInput->setFocus(Qt::MouseFocusReason); ui.lineEditInput->selectAll(); } }
void ContextMenu::show() { if(!isHidden()) { hide(); return; } //qDebug() << "[debug] parent: " << parentWidget()->size(); //qDebug() << "[debug] pos: " << pos(); //resize(QSize(parentWidget()->size().width(), 32)); //move(0, parentWidget()->size().height()-32); QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry"); animation->setDuration(170); animation->setStartValue(QRect(0, parentWidget()->size().height(), parentWidget()->size().width(), 0)); animation->setEndValue(QRect(0, parentWidget()->size().height()-42, parentWidget()->size().width(), 42)); animation->start(); QDialog::show(); calendar->setFocus(); calendar->setDefault(true); }
void FadingWidget::fadeTo(qreal value) { QPropertyAnimation *animation = new QPropertyAnimation(m_opacityEffect, "opacity"); animation->setDuration(200); animation->setEndValue(value); animation->start(QAbstractAnimation::DeleteWhenStopped); }
void hide(QObject *obj) { QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity"); animation->setStartValue(1); animation->setEndValue(0); animation->start(QAbstractAnimation::DeleteWhenStopped); }
/** * @brief Shows or hides the right menu with an animation * according to the value of \ref _rightMenuHidden attribute. */ void MainWindow::on_showHidePushButton_clicked() { QPropertyAnimation * animation = new QPropertyAnimation(ui->rightMenuWidget, "maximumWidth"); animation->setDuration(1000); animation->setStartValue(ui->rightMenuWidget->maximumWidth()); if(!_rightMenuHidden) { ui->showHidePushButton->setIcon(QIcon(":/icons/2left")); animation->setEndValue(0); animation->setEasingCurve(QEasingCurve::InBack); _rightMenuHidden = true; } else { animation->setEndValue(314); animation->setEasingCurve(QEasingCurve::OutBack); ui->showHidePushButton->setIcon(QIcon(":/icons/2right")); _rightMenuHidden = false; } animation->start(QPropertyAnimation::DeleteWhenStopped); }
void Photo::setEmotion(const QString &emotion, bool permanent) { if (emotion == ".") { hideEmotion(); return; } QString path = QString("image/system/emotion/%1.png").arg(emotion); if (QFile::exists(path)) { QPixmap pixmap = QPixmap(path); emotion_item->setPixmap(pixmap); emotion_item->setPos((G_PHOTO_LAYOUT.m_normalWidth - pixmap.width()) / 2, (G_PHOTO_LAYOUT.m_normalHeight - pixmap.height()) / 2); _layBetween(emotion_item, _m_chainIcon, _m_roleComboBox); QPropertyAnimation *appear = new QPropertyAnimation(emotion_item, "opacity"); appear->setStartValue(0.0); if (permanent) { appear->setEndValue(1.0); appear->setDuration(500); } else { appear->setKeyValueAt(0.25, 1.0); appear->setKeyValueAt(0.75, 1.0); appear->setEndValue(0.0); appear->setDuration(2000); } appear->start(QAbstractAnimation::DeleteWhenStopped); } else { PixmapAnimation::GetPixmapAnimation(this, emotion); } }
SelectContacts::SelectContacts(QWidget *parent, QListWidget *list) : QFrame(parent), ui(new Ui::SelectContacts) { ui->setupUi(this); //To hide the edges of the form and standard buttons. this->setWindowFlags(Qt::Popup | Qt::Window); setWindowOpacity(0); show(); // Setting animation when opening window QPropertyAnimation* animation = new QPropertyAnimation(this, "windowOpacity"); animation->setDuration(500); animation->setStartValue(0); animation->setEndValue(1); animation->start(); ui->userList->setItemDelegate(new UserListDelegate(ui->userList)); for (int i = 0; i < list->count(); i++) { QListWidgetItem *item = new QListWidgetItem(); item->setData(Qt::DisplayRole, list->item(i)->data(Qt::DisplayRole).toString()); item->setData(Qt::ToolTipRole, list->item(i)->data(Qt::ToolTipRole).toString()); item->setData(Qt::UserRole + 1, list->item(i)->data(Qt::UserRole + 1).toString()); item->setData(Qt::DecorationRole, list->item(i)->data(Qt::DecorationRole)); ui->userList->addItem(item); } }
void QLineEditIconButton::startOpacityAnimation(qreal endValue) { QPropertyAnimation *animation = new QPropertyAnimation(this, QByteArrayLiteral("opacity")); animation->setDuration(160); animation->setEndValue(endValue); animation->start(QAbstractAnimation::DeleteWhenStopped); }
void Widget::startBounce() { if (!m_settings.get("gui/bounce").toBool()) { return; } doneBounce(); QPropertyAnimation* anim = new QPropertyAnimation(this); anim->setTargetObject(this); m_animation.addAnimation(anim); anim->setEasingCurve(QEasingCurve::OutQuad); anim->setDuration(m_settings.get("gui/bounce_duration").toInt() * 0.25f); anim->setStartValue(0); QString position = m_messageQueue.front().data["pos"]->toString(); if (position == "top_center" || position == "tc" || position == "bottom_center" || position == "bc" || position == "center" || position == "c") anim->setEndValue(height()); else anim->setEndValue(40); tmpBouncePos = pos(); anim->start(); connect(anim, SIGNAL(valueChanged(QVariant)), this, SLOT(updateBounceAnimation(QVariant))); connect(anim, SIGNAL(finished()), this, SLOT(unbounce())); }
void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate) { QRect r = widget->geometry(); if (r.right() < 0 || r.bottom() < 0) r = QRect(); animate = animate && !r.isNull() && !_final_geometry.isNull(); // might make the wigdet go away by sending it to negative space const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry : QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size()); #ifndef QT_NO_ANIMATION AnimationMap::const_iterator it = m_animation_map.constFind(widget); if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) return; QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); anim->setDuration(animate ? 200 : 0); anim->setEasingCurve(QEasingCurve::InOutQuad); anim->setEndValue(final_geometry); m_animation_map[widget] = anim; connect(anim, SIGNAL(finished()), SLOT(animationFinished())); anim->start(QPropertyAnimation::DeleteWhenStopped); #else //we do it in one shot widget->setGeometry(final_geometry); #ifndef QT_NO_MAINWINDOW m_mainWindowLayout->animationFinished(widget); #endif //QT_NO_MAINWINDOW #endif //QT_NO_ANIMATION }
void LogoScene::setupLogo() { Qneed* background = new Qneed(this, get_window()); background->loadImage(":images/logo/logo_background.png"); set_background(background); logo = new Qneed(this, get_window()); logo->loadImage(":images/logo/logo.png"); logo->setPos(307, 240); OnemoreButton* one = new OnemoreButton(this,get_window()); one->setPos(400, 553); one->hide(); QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(); opacityEffect->setOpacity(0.0); logo->setGraphicsEffect(opacityEffect); QPropertyAnimation * animation = new QPropertyAnimation(); animation->setTargetObject(opacityEffect); animation->setPropertyName("opacity"); animation->setDuration(2000); animation->setStartValue(0.0); animation->setEndValue(1.0); animation->setEasingCurve(QEasingCurve::OutQuad); connect(animation, SIGNAL(finished()), this, SLOT(goinit())); animation->start(); }
void Item::resize ( const QSize& size, bool animated ) { if ( !animated || Settings::animationSpeed() == Settings::EnumAnimationSpeed::Instant ) { setRenderSize ( size ); } else { int duration = 0; switch ( Settings::animationSpeed() ) { case Settings::EnumAnimationSpeed::Fast: duration = fastAnimationDuration; break; case Settings::EnumAnimationSpeed::Normal: duration = normalAnimationDuration; break; case Settings::EnumAnimationSpeed::Slow: duration = slowAnimationDuration; break; default: break; } QPropertyAnimation* anim = new QPropertyAnimation ( this, "renderSize" ); anim->setDuration ( duration ); anim->setEasingCurve ( QEasingCurve::InOutCubic ); anim->setEndValue ( size ); anim->start ( QAbstractAnimation::DeleteWhenStopped ); } }
void Item::move ( const QPointF& pos, qreal tileSize, bool animated ) { if ( !animated || Settings::animationSpeed() == Settings::EnumAnimationSpeed::Instant ) { setPos ( pos ); } else { int duration = 0; switch ( Settings::animationSpeed() ) { case Settings::EnumAnimationSpeed::Fast: duration = fastAnimationDuration; break; case Settings::EnumAnimationSpeed::Normal: duration = normalAnimationDuration; break; case Settings::EnumAnimationSpeed::Slow: duration = slowAnimationDuration; break; default: break; } duration *= qSqrt ( QPointF ( this->pos() - pos ).manhattanLength() / tileSize ); QPropertyAnimation* anim = new QPropertyAnimation ( this, "pos" ); anim->setDuration ( duration ); anim->setEasingCurve ( QEasingCurve::InOutCubic ); anim->setEndValue ( pos ); anim->start ( QAbstractAnimation::DeleteWhenStopped ); } }
void CardItem::goBack(bool kieru){ if(home_pos == pos()){ if(kieru) setOpacity(0.0); return; } QPropertyAnimation *goback = new QPropertyAnimation(this, "pos"); goback->setEndValue(home_pos); goback->setEasingCurve(QEasingCurve::OutBounce); if(kieru){ QParallelAnimationGroup *group = new QParallelAnimationGroup; QPropertyAnimation *disappear = new QPropertyAnimation(this, "opacity"); disappear->setKeyValueAt(0.9, 1.0); disappear->setEndValue(0.0); goback->setDuration(1000); disappear->setDuration(1000); group->addAnimation(goback); group->addAnimation(disappear); group->start(QParallelAnimationGroup::DeleteWhenStopped); }else goback->start(QPropertyAnimation::DeleteWhenStopped); }
void DeckHandler::adjustDrawSize() { if(drawAnimating) { QTimer::singleShot(ANIMATION_TIME+50, this, SLOT(adjustDrawSize())); return; } int rowHeight = ui->drawListWidget->sizeHintForRow(0); int rows = drawCardList.count(); int height = rows*rowHeight + 2*ui->drawListWidget->frameWidth(); int maxHeight = (ui->drawListWidget->height()+ui->enemyHandListWidget->height())*4/5; if(height>maxHeight) height = maxHeight; QPropertyAnimation *animation = new QPropertyAnimation(ui->drawListWidget, "minimumHeight"); animation->setDuration(ANIMATION_TIME); animation->setStartValue(ui->drawListWidget->minimumHeight()); animation->setEndValue(height); animation->setEasingCurve(QEasingCurve::OutBounce); animation->start(); QPropertyAnimation *animation2 = new QPropertyAnimation(ui->drawListWidget, "maximumHeight"); animation2->setDuration(ANIMATION_TIME); animation2->setStartValue(ui->drawListWidget->maximumHeight()); animation2->setEndValue(height); animation2->setEasingCurve(QEasingCurve::OutBounce); animation2->start(); this->drawAnimating = true; connect(animation, SIGNAL(finished()), this, SLOT(clearDrawAnimating())); }
void RocketStorageAuthDialog::Show() { if (isVisible()) return; show(); setFocus(Qt::ActiveWindowFocusReason); activateWindow(); setWindowOpacity(0.0); QPropertyAnimation *showAnim = new QPropertyAnimation(this, "windowOpacity", this); showAnim->setStartValue(0.0); showAnim->setEndValue(1.0); showAnim->setDuration(300); showAnim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad)); showAnim->start(); plugin_->Notifications()->CenterToMainWindow(this); if (!plugin_->Notifications()->IsForegroundDimmed()) { plugin_->Notifications()->DimForeground(); restoreForeground_ = true; } }
void DialogController::closeDialog() { QWidget *dialog = m_dialog; m_dialog = nullptr; m_widget = nullptr; if(!dialog) return; QRect geom = dialog->geometry(); int w = geom.width() + m_dialogOffsetLeft; QPropertyAnimation *animation = new QPropertyAnimation(dialog, "geometry"); animation->setStartValue(visibleGeometry(dialog)); animation->setEndValue(hiddenGeometry(dialog)); animation->setDuration(300); animation->setEasingCurve(QEasingCurve::OutExpo); animation->start(); connect(animation, &QPropertyAnimation::finished, [=]{ animation->deleteLater(); dialog->close(); dialog->deleteLater(); }); emit dialogClosed(); }
int MPF::showHelp() { QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this); helpTextEdit->setGraphicsEffect(opacityEffect); //helpTextEdit->setText(""); QPropertyAnimation* anim = new QPropertyAnimation(this); if(helpTextEdit->isHidden()) { opacityEffect->setOpacity(1); anim->setEndValue(0); helpPushButton->setText(trUtf8("&Hide Help")); helpTextEdit->show(); fullHelpPushButton->show(); } else { opacityEffect->setOpacity(0); anim->setEndValue(1); helpPushButton->setText(trUtf8("&Show Help")); helpTextEdit->hide(); fullHelpPushButton->hide(); } anim->setTargetObject(opacityEffect); anim->setPropertyName("opacity"); anim->setDuration(3000); anim->setStartValue(opacityEffect->opacity()); anim->setEasingCurve(QEasingCurve::InBounce); anim->start(QAbstractAnimation::DeleteWhenStopped); return 0; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QGraphicsScene scene; QGraphicsView view(&scene); view.setMinimumHeight(150); QGraphicsPixmapItem *item = new QGraphicsPixmapItem(QPixmap(":/img/qt-logo.jpg")); scene.addItem(item); QGraphicsRotation *rotation = new QGraphicsRotation(); rotation->setAxis(Qt::ZAxis); rotation->setOrigin(QVector3D(QPoint(item->boundingRect().width() / 2.0, item->boundingRect().height() / 2.0))); item->setTransformations(QList<QGraphicsTransform *>() << rotation); QPropertyAnimation *anim = new QPropertyAnimation(rotation, "angle"); anim->setDuration(5000); anim->setStartValue(0); anim->setEndValue(360); anim->start(QAbstractAnimation::DeleteWhenStopped); view.show(); return a.exec(); }
int MPF::animateWidget(QWidget* widget, bool hide, int effect) { if(!widget) { return 1; } if(effect == FADING) { QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this); opacityEffect->setOpacity(0); widget->setGraphicsEffect(opacityEffect); QPropertyAnimation* anim = new QPropertyAnimation(this); anim->setTargetObject(opacityEffect); anim->setPropertyName("opacity"); anim->setDuration(3000); anim->setStartValue(opacityEffect->opacity()); anim->setEndValue(1); anim->setEasingCurve(QEasingCurve::OutQuad); anim->start(QAbstractAnimation::DeleteWhenStopped); } return 0; }
void Photo::hideEmotion() { QPropertyAnimation *disappear = new QPropertyAnimation(emotion_item, "opacity"); disappear->setStartValue(1.0); disappear->setEndValue(0.0); disappear->setDuration(500); disappear->start(QAbstractAnimation::DeleteWhenStopped); }
void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type, const QVariant& endValue) { stop(widget, type); QPropertyAnimation* propertyAnim = nullptr; const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1; switch (type) { case MovingAnimation: { const QPointF newPos = endValue.toPointF(); if (newPos == widget->pos()) { return; } propertyAnim = new QPropertyAnimation(widget, "pos"); propertyAnim->setDuration(animationDuration); propertyAnim->setEndValue(newPos); break; } case CreateAnimation: { propertyAnim = new QPropertyAnimation(widget, "opacity"); propertyAnim->setEasingCurve(QEasingCurve::InQuart); propertyAnim->setDuration(animationDuration); propertyAnim->setStartValue(0.0); propertyAnim->setEndValue(1.0); break; } case DeleteAnimation: { propertyAnim = new QPropertyAnimation(widget, "opacity"); propertyAnim->setEasingCurve(QEasingCurve::OutQuart); propertyAnim->setDuration(animationDuration); propertyAnim->setStartValue(1.0); propertyAnim->setEndValue(0.0); break; } case ResizeAnimation: { const QSizeF newSize = endValue.toSizeF(); if (newSize == widget->size()) { return; } propertyAnim = new QPropertyAnimation(widget, "size"); propertyAnim->setDuration(animationDuration); propertyAnim->setEndValue(newSize); break; } default: break; } Q_ASSERT(propertyAnim); connect(propertyAnim, &QPropertyAnimation::finished, this, &KItemListViewAnimation::slotFinished); m_animation[type].insert(widget, propertyAnim); propertyAnim->start(); }