Esempio n. 1
0
void UIAnimation::prepare()
{
    /* Prepare animation-machine: */
    m_pAnimationMachine = new QStateMachine(this);
    /* Create 'start' state: */
    m_pStateStart = new QState(m_pAnimationMachine);
    connect(m_pStateStart, SIGNAL(propertiesAssigned()), this, SIGNAL(sigStateEnteredStart()));
    /* Create 'final' state: */
    m_pStateFinal = new QState(m_pAnimationMachine);
    connect(m_pStateFinal, SIGNAL(propertiesAssigned()), this, SIGNAL(sigStateEnteredFinal()));

    /* Prepare 'forward' animation: */
    m_pForwardAnimation = new QPropertyAnimation(parent(), m_pszPropertyName, m_pAnimationMachine);
    m_pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
    m_pForwardAnimation->setDuration(m_iAnimationDuration);
    /* Prepare 'reverse' animation: */
    m_pReverseAnimation = new QPropertyAnimation(parent(), m_pszPropertyName, m_pAnimationMachine);
    m_pReverseAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
    m_pReverseAnimation->setDuration(m_iAnimationDuration);

    /* Prepare state-transitions: */
    QSignalTransition *pStartToFinal = m_pStateStart->addTransition(parent(), m_pszSignalForward, m_pStateFinal);
    pStartToFinal->addAnimation(m_pForwardAnimation);
    QSignalTransition *pFinalToStart = m_pStateFinal->addTransition(parent(), m_pszSignalReverse, m_pStateStart);
    pFinalToStart->addAnimation(m_pReverseAnimation);

    /* Fetch animation-borders: */
    update();

    /* Choose initial state: */
    m_pAnimationMachine->setInitialState(!m_fReverse ? m_pStateStart : m_pStateFinal);
    /* Start animation-machine: */
    m_pAnimationMachine->start();
}
Esempio n. 2
0
Tank::Tank(QObject *parent)
    : QGLSceneNode(parent)
    , m_texture(0)
{
    QSequentialAnimationGroup *seq = new QSequentialAnimationGroup(this);
    QGraphicsScale3D *scale = new QGraphicsScale3D(this);
    addTransform(scale);
    QPropertyAnimation *anim = new QPropertyAnimation(scale, "scale");
    anim->setDuration(10000);
    anim->setStartValue(QVector3D(1.0f, 0.1f, 1.0f));
    anim->setEndValue(QVector3D(1.0f, 1.2f, 1.0f));
    anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
    seq->addAnimation(anim);
    seq->addPause(2000);
    anim = new QPropertyAnimation(scale, "scale");
    anim->setDuration(10000);
    anim->setStartValue(QVector3D(1.0f, 1.2f, 1.0f));
    anim->setEndValue(QVector3D(1.0f, 0.1f, 1.0f));
    anim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
    seq->addAnimation(anim);
    seq->setLoopCount(-1);
    seq->start();

    addNode(tankObject());

    QGLMaterial *mat = qCreateFluid();
    m_texture = mat->texture();
    setMaterial(mat);
}
Esempio n. 3
0
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();
    }
}
Esempio n. 4
0
GcChartWindow::GcChartWindow(QWidget *parent) : GcWindow(parent) {
    //
    // Default layout
    //
    setContentsMargins(0,0,0,0);

    // Main layout
    _layout = new QStackedLayout();
    setLayout(_layout);

    _mainWidget = new QWidget(this);
    _mainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    _blank = new QWidget(this);
    _blank->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    _layout->addWidget(_blank);
    _layout->addWidget(_mainWidget);
    _layout->setCurrentWidget(_mainWidget);

    _mainLayout = new QGridLayout();
    _mainLayout->setContentsMargins(2,2,2,2);

    // reveal widget
    _revealControls = new QWidget();
    _revealControls->setFixedHeight(50);
    _revealControls->setStyleSheet("background-color: rgba(100%, 100%, 100%, 100%)");
    _revealControls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

    _revealAnim = new QPropertyAnimation(_revealControls, "pos");
    _revealAnim->setDuration(200);
    _revealAnim->setEasingCurve(QEasingCurve(QEasingCurve::InSine));
    _revealAnim->setKeyValueAt(0,QPoint(2,-50));
    _revealAnim->setKeyValueAt(0.5,QPoint(2,-5));
    _revealAnim->setKeyValueAt(1,QPoint(2,0));

    _unrevealAnim = new QPropertyAnimation(_revealControls, "pos");
    _unrevealAnim->setDuration(150);
    _unrevealAnim->setEasingCurve(QEasingCurve(QEasingCurve::InSine));
    _unrevealAnim->setKeyValueAt(0,QPoint(2,0));
    _unrevealAnim->setKeyValueAt(0.5,QPoint(2,-5));
    _unrevealAnim->setKeyValueAt(1,QPoint(2,-50));

    _unrevealTimer = new QTimer();
    connect(_unrevealTimer, SIGNAL(timeout()), this, SLOT(hideRevealControls()));

    _revealControls->hide();

    _mainLayout->addWidget(_revealControls,0,0, Qt::AlignTop);
    _mainWidget->setLayout(_mainLayout);
}
void Ut_MSceneWindowScroller::testApplyScrolling()
{
    // the scrolling is actually performed by the scene manager in response
    // to the scroller signals. We can't test the scrolling funcionality here
    // but just that the signal is emitted
    QSignalSpy spy(scroller, SIGNAL(sceneWindowDislocationRequest(MSceneWindow*, const QPointF&)));

    // when asking for an empty offset, the signal is not emitted
    scroller->applyScrolling(sceneWindow, QPoint(), 0, QEasingCurve());
    QVERIFY (spy.count() == 0);

    // otherwise the signal is emitted
    scroller->applyScrolling(sceneWindow, QPoint(0, -1000), 0, QEasingCurve());
    QVERIFY (spy.count() == 1);
}
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;
    }
}
QcMapGestureArea::QcMapGestureArea(QcMapItem * map)
  : QQuickItem(map),
    m_map(map),
    m_enabled(true),
    m_accepted_gestures(PinchGesture | PanGesture | FlickGesture),
    m_prevent_stealing(false),
    m_pan_enabled(true)
{
  // qInfo();

  m_flick.m_enabled = true;
  m_flick.m_max_velocity = QML_MAP_FLICK_DEFAULT_MAX_VELOCITY;
  m_flick.m_deceleration = QML_MAP_FLICK_DEFAULT_DECELERATION;

  m_flick.m_animation = new QcGeoCoordinateAnimation(this);
  m_flick.m_animation->setTargetObject(m_map);
  m_flick.m_animation->setProperty(QStringLiteral("center"));
  m_flick.m_animation->setEasing(QEasingCurve(QEasingCurve::OutQuad));
  connect(m_flick.m_animation, &QQuickAbstractAnimation::stopped,
          this, &QcMapGestureArea::handle_flick_animation_stopped);

  m_touch_point_state = TouchPoints0;
  m_pinch_state = PinchInactive;
  m_flick_state = FlickInactive;

  m_press_timer.setSingleShot(true);
  m_press_timer.setInterval(MINIMUM_PRESS_AND_HOLD_TIME);
  connect(&m_press_timer, &QTimer::timeout,
          this, &QcMapGestureArea::handle_press_timer_timeout);

  m_press_time.invalidate();
  m_double_press_time.invalidate();
}
Esempio n. 8
0
MessageListView::MessageListView(QWidget *parent) :
    QTableView(parent)
{
    this->horizontalHeader()->hide();
    this->verticalHeader()->hide();
    this->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    this->verticalHeader()->setDefaultSectionSize(60);
    this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    this->setShowGrid(false);
    this->setSelectionMode(QAbstractItemView::NoSelection);
    /*
     * 添加滑屏操作
    */
    this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    QScroller *scroller = QScroller::scroller(this->viewport());

    QScrollerProperties prop = scroller->scrollerProperties();

    prop.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
    prop.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
    prop.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
    prop.setScrollMetric(QScrollerProperties::MaximumVelocity, 0);
    prop.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
    prop.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
    prop.setScrollMetric(QScrollerProperties::SnapPositionRatio, 0.93);
    prop.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
    prop.setScrollMetric(QScrollerProperties::SnapPositionRatio,0.5);

    scroller->setScrollerProperties(prop);

    scroller->grabGesture(this, QScroller::TouchGesture);
    scroller->grabGesture(this, QScroller::LeftMouseButtonGesture);
}
Esempio n. 9
0
// Test getting and setting easing properties via the metaobject system.
void tst_QEasingCurve::properties()
{
    tst_QEasingProperties obj;

    QEasingCurve inOutBack(QEasingCurve::InOutBack);
    qreal overshoot = 1.5;
    inOutBack.setOvershoot(overshoot);
    qreal amplitude = inOutBack.amplitude();
    qreal period = inOutBack.period();

    obj.setEasing(inOutBack);

    QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
    QCOMPARE(easing.type(), QEasingCurve::InOutBack);
    QCOMPARE(easing.overshoot(), overshoot);
    QCOMPARE(easing.amplitude(), amplitude);
    QCOMPARE(easing.period(), period);

    QEasingCurve linear(QEasingCurve::Linear);
    overshoot = linear.overshoot();
    amplitude = linear.amplitude();
    period = linear.period();

    obj.setProperty("easing",
                    qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));

    easing = qVariantValue<QEasingCurve>(obj.property("easing"));
    QCOMPARE(easing.type(), QEasingCurve::Linear);
    QCOMPARE(easing.overshoot(), overshoot);
    QCOMPARE(easing.amplitude(), amplitude);
    QCOMPARE(easing.period(), period);
}
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();
    }
}
Esempio n. 11
0
File: cube.cpp Progetto: maxxant/qt
Cube *CubeBuilder::newCube(const QVector3D &loc) const
{
    Cube *c = new Cube(loc);
    initialize(c);
    qreal d = 4000.0f;
    qreal d3 = d / 3.0f;
    // Animate movement from left to right
    c->r = new QPropertyAnimation(c, "range");
    c->r->setStartValue(-1.3f);
    c->r->setEndValue(1.3f);
    c->startx = ix * d3 * 3.0f;
    c->r->setDuration(d * 4.0f);
    c->r->setLoopCount(-1);
    c->r->setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve));

    c->animGroup = new QSequentialAnimationGroup(c);

    // Animate movement from bottom to top
    QPropertyAnimation *a_up = new QPropertyAnimation(c, "altitude", c->animGroup);
    a_up->setEndValue(loc.y());
    a_up->setStartValue(loc.y() + amplitudes[ix]);
    a_up->setDuration(d / speeds[ix]);
    a_up->setLoopCount(1);
    a_up->setEasingCurve(QEasingCurve(QEasingCurve::InQuad));

    // Animate movement from top to bottom
    QPropertyAnimation *a_down = new QPropertyAnimation(c, "altitude", c->animGroup);
    a_down->setEndValue(loc.y() + amplitudes[ix]);
    a_down->setStartValue(loc.y());
    a_down->setDuration(d / speeds[ix]);
    a_down->setLoopCount(1);
    a_down->setEasingCurve(QEasingCurve(QEasingCurve::OutQuad));

    c->animGroup->addAnimation(a_up);
    c->animGroup->addAnimation(a_down);
    c->animGroup->setLoopCount(-1);

    // Animate rotation
    c->rtn = new QPropertyAnimation(c, "rotation");
    c->rtn->setStartValue(c->rot);
    c->rtn->setEndValue(359.0f);
    c->rtn->setDuration(d * 2.0f);
    c->rtn->setLoopCount(-1);
    c->rtn->setDuration(d / 2);
    ix = (ix + 1) % 3;
    return c;
}
/*!
    \internal
*/
void QDeclarativeGeoMapGestureArea::setMap(QGeoMap *map)
{
    if (map_ || !map)
        return;
    map_ = map;
    pan_.animation_ = new QPropertyAnimation(map_->mapController(), "center", this);
    pan_.animation_->setEasingCurve(QEasingCurve(QEasingCurve::OutQuad));
    connect(pan_.animation_, SIGNAL(finished()), this, SLOT(endFlick()));
    connect(this, SIGNAL(movementStopped()),
            map_, SLOT(cameraStopped()));
}
Esempio n. 13
0
static VALUE
cVariantAnimation_easingCurve_set(VALUE v_self, VALUE v_easing)
{
  const RPP::QObject<QVariantAnimation> self = v_self;
  const RPP::QEasingCurve easing(v_easing, RPP::UNSAFE);
  if (easing.isNil())
    self->setEasingCurve(QEasingCurve());
  else
    self->setEasingCurve(*easing);
  return v_easing;
}
Esempio n. 14
0
void EasingGraph::setEasingName(const QString &newName)
{
    if (easingName() != newName) {

        if (!m_availableNames.contains(newName)) return;
        m_curveFunction = QEasingCurve(m_availableNames.value(newName));
        emit easingNameChanged();
        emit easingExtremesChanged();
        emit easingShapeChanged();
        update();
    }
}
Esempio n. 15
0
QStateMachine* UIAnimationFramework::installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName,
                                                              const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
                                                              const char *pSignalForward, const char *pSignalBackward,
                                                              bool fReversive /*= false*/, int iAnimationDuration /*= 300*/)
{
    /* State-machine: */
    QStateMachine *pStateMachine = new QStateMachine(pTarget);
    /* State-machine 'start' state: */
    QState *pStateStart = new QState(pStateMachine);
    /* State-machine 'final' state: */
    QState *pStateFinal = new QState(pStateMachine);

    /* State-machine 'forward' animation: */
    QPropertyAnimation *pForwardAnimation = new QPropertyAnimation(pTarget, pszPropertyName, pStateMachine);
    pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
    pForwardAnimation->setDuration(iAnimationDuration);
    pForwardAnimation->setStartValue(pTarget->property(pszValuePropertyNameStart));
    pForwardAnimation->setEndValue(pTarget->property(pszValuePropertyNameFinal));
    /* State-machine 'backward' animation: */
    QPropertyAnimation *pBackwardAnimation = new QPropertyAnimation(pTarget, pszPropertyName, pStateMachine);
    pBackwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic));
    pBackwardAnimation->setDuration(iAnimationDuration);
    pBackwardAnimation->setStartValue(pTarget->property(pszValuePropertyNameFinal));
    pBackwardAnimation->setEndValue(pTarget->property(pszValuePropertyNameStart));

    /* State-machine state transitions: */
    QSignalTransition *pDefaultToHovered = pStateStart->addTransition(pTarget, pSignalForward, pStateFinal);
    pDefaultToHovered->addAnimation(pForwardAnimation);
    QSignalTransition *pHoveredToDefault = pStateFinal->addTransition(pTarget, pSignalBackward, pStateStart);
    pHoveredToDefault->addAnimation(pBackwardAnimation);

    /* Initial state is 'start': */
    pStateMachine->setInitialState(!fReversive ? pStateStart : pStateFinal);
    /* Start hover-machine: */
    pStateMachine->start();
    /* Return machine: */
    return pStateMachine;
}
Qgs3DAnimationSettings Qgs3DAnimationWidget::animation() const
{
  Qgs3DAnimationSettings animSettings;
  animSettings.setEasingCurve( QEasingCurve( ( QEasingCurve::Type ) cboInterpolation->currentIndex() ) );
  Qgs3DAnimationSettings::Keyframes keyframes;
  for ( int i = 1; i < cboKeyframe->count(); ++i )
  {
    Qgs3DAnimationSettings::Keyframe kf;
    kf = cboKeyframe->itemData( i, Qt::UserRole + 1 ).value<Qgs3DAnimationSettings::Keyframe>();
    keyframes << kf;
  }
  animSettings.setKeyframes( keyframes );
  return animSettings;
}
Esempio n. 17
0
void ContentPane::initAnimations()
{
    this->openAnimation = std::unique_ptr<QPropertyAnimation>(new QPropertyAnimation());
    this->closeAnimation = std::unique_ptr<QPropertyAnimation>(new QPropertyAnimation());
    // TODO: Currently these animations only animate maximumHeight. This leads to
    // different behaviour depending on whether the Accordion Widget is placed
    // inside a QScollWidget or not. Maybe we also need to animate minimumHeight
    // as well to get the same effect.
    this->openAnimation->setTargetObject(this->container);
    this->openAnimation->setPropertyName("maximumHeight");
    this->closeAnimation->setTargetObject(this->container);
    this->closeAnimation->setPropertyName("maximumHeight");

    this->openAnimation->setDuration(300);
    this->closeAnimation->setDuration(300);
    this->openAnimation->setStartValue(0);
    this->closeAnimation->setStartValue(this->containerAnimationMaxHeight);
    this->openAnimation->setEndValue(this->containerAnimationMaxHeight);
    this->closeAnimation->setEndValue(0);
    this->openAnimation->setEasingCurve(
        QEasingCurve(QEasingCurve::Type::Linear));
    this->closeAnimation->setEasingCurve(
        QEasingCurve(QEasingCurve::Type::Linear));
}
Esempio n. 18
0
void Qgs3DAnimationSettings::readXml( const QDomElement &elem )
{
  mEasingCurve = QEasingCurve( ( QEasingCurve::Type ) elem.attribute( QStringLiteral( "interpolation" ), QStringLiteral( "0" ) ).toInt() );

  mKeyframes.clear();

  QDomElement elemKeyframes = elem.firstChildElement( QStringLiteral( "keyframes" ) );
  QDomElement elemKeyframe = elemKeyframes.firstChildElement( QStringLiteral( "keyframe" ) );
  while ( !elemKeyframe.isNull() )
  {
    Keyframe kf;
    kf.time = elemKeyframe.attribute( QStringLiteral( "time" ) ).toFloat();
    kf.point.set( elemKeyframe.attribute( QStringLiteral( "x" ) ).toDouble(),
                  elemKeyframe.attribute( QStringLiteral( "y" ) ).toDouble(),
                  elemKeyframe.attribute( QStringLiteral( "z" ) ).toDouble() );
    kf.dist = elemKeyframe.attribute( QStringLiteral( "dist" ) ).toFloat();
    kf.pitch = elemKeyframe.attribute( QStringLiteral( "pitch" ) ).toFloat();
    kf.yaw = elemKeyframe.attribute( QStringLiteral( "yaw" ) ).toFloat();
    mKeyframes.append( kf );
    elemKeyframe = elemKeyframe.nextSiblingElement( QStringLiteral( "keyframe" ) );
  }
}
Esempio n. 19
0
KNMusicBackendMpvThread::KNMusicBackendMpvThread(QObject *parent) :
    KNMusicStandardBackendThread(parent),
    m_volumeCurve(QEasingCurve(QEasingCurve::OutQuad)),
    m_filePath(QString()),
    m_totalDuration(-1),
    m_duration(-1),
    m_startPosition(-1),
    m_endPosition(-1),
    m_mpvHandle(nullptr),
    m_state(MusicUtil::Stopped),
    m_volumeSize(100)
{
    //Initial the locale settings.
    setlocale(LC_NUMERIC, "C");
    //Create the mpv handle.
    m_mpvHandle=mpv_create();
    //Check out the mpv handle.
    if(!m_mpvHandle)
    {
        //Cannot create an instance for mpv.
        return;
    }
    //Set mpv options.
    // No mouse handling.
    mpv_set_option_string(m_mpvHandle, "input-cursor", "no");
    // No cursor-autohide.
    mpv_set_option_string(m_mpvHandle, "cursor-autohide", "no");
    mpv_set_option_string(m_mpvHandle, "no-video", NULL);

    // get updates when these properties change
    mpv_observe_property(m_mpvHandle, 0, "time-pos", MPV_FORMAT_DOUBLE);

    // setup callback event handling
    mpv_set_wakeup_callback(m_mpvHandle,
                            KNMusicBackendMpvThread::instanceWakeUp,
                            this);
    //Initialize the mpv handler.
    mpv_initialize(m_mpvHandle);
}
QtViewportInteractionEngine::QtViewportInteractionEngine(const QQuickWebView* viewport, QQuickWebPage* content)
    : m_viewport(viewport)
    , m_content(content)
    , m_suspendCount(0)
    , m_scaleAnimation(new ScaleAnimation(this))
    , m_pinchStartScale(-1)
{
    reset();

    QScrollerProperties properties = scroller()->scrollerProperties();

    // The QtPanGestureRecognizer is responsible for recognizing the gesture
    // thus we need to disable the drag start distance.
    properties.setScrollMetric(QScrollerProperties::DragStartDistance, 0.0);

    // Set some default QScroller constrains to mimic the physics engine of the N9 browser.
    properties.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
    properties.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
    properties.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
    properties.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.635);
    properties.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
    properties.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);

    scroller()->setScrollerProperties(properties);

    connect(m_content, SIGNAL(widthChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
    connect(m_content, SIGNAL(heightChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);

    connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)),
            SLOT(scaleAnimationValueChanged(QVariant)), Qt::DirectConnection);
    connect(m_scaleAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)),
            SLOT(scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), Qt::DirectConnection);

    connect(scroller(), SIGNAL(stateChanged(QScroller::State)),
            SLOT(scrollStateChanged(QScroller::State)), Qt::DirectConnection);
}
Esempio n. 21
0
 Op(Type t, int l, qreal v, qreal v2, int o, 
    const QDeclarativeTimeLineCallback &ev = QDeclarativeTimeLineCallback(), const QEasingCurve &es = QEasingCurve())
     : type(t), length(l), value(v), value2(v2), order(o), event(ev),
       easing(es) {}
Esempio n. 22
0
KNMusicAlbumDetail::KNMusicAlbumDetail(QWidget *parent, KNMusicTab *tab) :
    QWidget(parent),
    m_currentIndex(QModelIndex()),
    m_inCurve(QEasingCurve(QEasingCurve::OutCubic)),
    m_animeStartRect(QRect()),
    m_albumContent(new KNMouseUnclickableWidget(this)),
    m_albumArt(new KNMusicAlbumTitle(this)),
    m_rightShadow(new KNSideShadowWidget(KNSideShadowWidget::RightShadow,
                                         this)),
    m_leftShadow(new KNSideShadowWidget(KNSideShadowWidget::LeftShadow,
                                        this)),
    m_albumTitle(new KNScrollLabel(this)),
    m_albumDetails(new KNScrollLabel(this)),
    m_albumListView(new KNMusicAlbumListView(this, tab)),
    m_libraryModel(nullptr),
    m_expandAnime(new QSequentialAnimationGroup(this)),
    m_expandStep1(new QParallelAnimationGroup(this)),
    m_expandStep2(new QParallelAnimationGroup(this)),
    m_foldAnime(new QParallelAnimationGroup(this)),
    m_showAlbumArt(new QParallelAnimationGroup(this)),
    m_hideAlbumArt(new QParallelAnimationGroup(this)),
    m_flyAwayAnime(new QParallelAnimationGroup(this)),
    m_albumArtIn1(generateAnime(m_albumArt)),
    m_albumContentIn1(generateAnime(m_albumContent)),
    m_albumArtIn2(generateAnime(m_albumArt)),
    m_albumContentIn2(generateAnime(m_albumContent)),
    m_albumArtOut(generateAnime(m_albumArt)),
    m_albumContentOut(generateAnime(m_albumContent)),
    m_albumArtFlyAway(generateAnime(m_albumArt)),
    m_albumContentFlyAway(generateAnime(m_albumContent)),
    m_showAlbumArtLabel(generateAnime(m_albumArt)),
    m_showAlbumContent(generateAnime(m_albumContent)),
    m_hideAlbumArtLabel(generateAnime(m_albumArt)),
    m_hideAlbumContent(generateAnime(m_albumContent)),
    m_iconSize(0),
    m_panelSize(0),
    m_backgroundAnime(true),
    m_pressed(false)
{
    //Set properties.
    setAutoFillBackground(true);
    setFocusPolicy(Qt::WheelFocus);
    //Set the background color.
    QPalette pal=palette();
    pal.setColor(QPalette::Base, QColor(0,0,0,0));
    pal.setColor(QPalette::Window, QColor(0,0,0,0));
    setPalette(pal);

    //Configure the album content.
    m_albumContent->setAutoFillBackground(true);
    m_albumContent->setFocusPolicy(Qt::StrongFocus);
    QPalette contentPalette=m_albumContent->palette();
    contentPalette.setColor(QPalette::Window, QColor(255,255,255,240));
    m_albumContent->setPalette(contentPalette);
    //Configure the album title label.
    m_albumTitle->setObjectName("MusicAlbumTitleLabel");
    m_albumTitle->setGlowRadius(4.0);
    knTheme->registerWidget(m_albumTitle);
    // Set the font.
    QFont captionFont=m_albumTitle->font();
    captionFont.setBold(true);
    captionFont.setPixelSize(21);
    m_albumTitle->setFont(captionFont);
    //Configure the album artist label.
    m_albumDetails->setObjectName("MusicAlbumDetailLabel");
    m_albumDetails->setGlowRadius(4.0);
    knTheme->registerWidget(m_albumDetails);
    //Link signals.
    connect(m_expandAnime, &QSequentialAnimationGroup::finished,
            this, &KNMusicAlbumDetail::onActionExpandFinished);
    connect(m_albumContentIn1, &QPropertyAnimation::valueChanged,
            this, &KNMusicAlbumDetail::onActionExpandStep1);
    connect(m_expandStep1, &QParallelAnimationGroup::finished,
            this, &KNMusicAlbumDetail::onActionExpandStep1InFinished);
    connect(m_albumContentIn2, &QPropertyAnimation::valueChanged,
            this, &KNMusicAlbumDetail::onActionContentMove);
    connect(m_foldAnime, &QParallelAnimationGroup::finished,
            this, &KNMusicAlbumDetail::onActionFoldFinished);
    connect(m_albumArtOut, &QPropertyAnimation::valueChanged,
            this, &KNMusicAlbumDetail::onActionFold);
    connect(m_flyAwayAnime, &QParallelAnimationGroup::finished,
            this, &KNMusicAlbumDetail::onActionFlyAwayFinished);
    connect(m_albumArtFlyAway, &QPropertyAnimation::valueChanged,
            this, &KNMusicAlbumDetail::onActionFlyAway);
    connect(m_showAlbumContent, &QPropertyAnimation::valueChanged,
            this, &KNMusicAlbumDetail::onActionContentMove);
    connect(m_hideAlbumContent, &QPropertyAnimation::valueChanged,
            this, &KNMusicAlbumDetail::onActionContentMove);
    //Configure the animation groups.
    m_expandStep1->addAnimation(m_albumArtIn1);
    m_expandStep1->addAnimation(m_albumContentIn1);
    m_expandAnime->addAnimation(m_expandStep1);
    m_expandStep2->addAnimation(m_albumArtIn2);
    m_expandStep2->addAnimation(m_albumContentIn2);
    m_expandAnime->addAnimation(m_expandStep2);
    m_foldAnime->addAnimation(m_albumArtOut);
    m_foldAnime->addAnimation(m_albumContentOut);
    m_flyAwayAnime->addAnimation(m_albumArtFlyAway);
    m_flyAwayAnime->addAnimation(m_albumContentFlyAway);
    m_showAlbumArt->addAnimation(m_showAlbumArtLabel);
    m_showAlbumArt->addAnimation(m_showAlbumContent);
    m_hideAlbumArt->addAnimation(m_hideAlbumArtLabel);
    m_hideAlbumArt->addAnimation(m_hideAlbumContent);

    //Initial the content layout for album content.
    QBoxLayout *contentLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                             m_albumContent);
    contentLayout->setContentsMargins(0,0,0,0);
    contentLayout->setSpacing(0);
    m_albumContent->setLayout(contentLayout);
    //Initial the caption layout for the title and detail label.
    QBoxLayout *captionLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                             contentLayout->widget());
    captionLayout->setContentsMargins(21,21,21,14);
    captionLayout->setSpacing(0);
    contentLayout->addLayout(captionLayout);
    //Add widget to caption layout.
    captionLayout->addWidget(m_albumTitle);
    captionLayout->addWidget(m_albumDetails);
    //Add the tree view to content layout.
    contentLayout->addWidget(m_albumListView, 1);
}
RocketStorageSelectionDialog::RocketStorageSelectionDialog(RocketPlugin *plugin, MeshmoonStorage *storage, const QStringList &suffixFilters, 
                                                           bool allowChangingFolder, MeshmoonStorageItem &startDirectory, QWidget *parent) :
    QDialog(parent),
    plugin_(plugin),
    storage_(storage),
    suffixFilters_(suffixFilters),
    allowChangingFolder_(allowChangingFolder),
    startDirectory_(startDirectory),
    currentFolder_(0)
{
    // Setup UI
    ui_.setupUi(this);
    ui_.scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui_.lineEditFilter->installEventFilter(this);

    ui_.buttonSelect->setAutoDefault(false);
    ui_.buttonCancel->setAutoDefault(false);

    view_ = new RocketStorageListWidget(this, plugin_);
    view_->SetPreviewFileOnMouse(true);
    view_->setSelectionMode(QAbstractItemView::SingleSelection);

    QVBoxLayout *l = new QVBoxLayout(ui_.scrollAreaWidgetContents);
    l->setSpacing(0);
    l->setContentsMargins(0,0,0,0);
    l->addWidget(view_);
    ui_.scrollAreaWidgetContents->setLayout(l);

    // Connections
    connect(view_, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(OnItemClicked(QListWidgetItem*)));
    connect(view_, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(OnItemDoubleClicked(QListWidgetItem*)));
    connect(ui_.buttonSelect, SIGNAL(clicked()), SLOT(OnSelect()), Qt::QueuedConnection);
    connect(ui_.buttonCancel, SIGNAL(clicked()), SLOT(reject()), Qt::QueuedConnection);
    connect(this, SIGNAL(rejected()), SLOT(OnCancel()));
    connect(ui_.lineEditFilter, SIGNAL(textChanged(const QString&)), SLOT(OnFilterChanged(const QString&)));

    // Dialog setup
    setAttribute(Qt::WA_DeleteOnClose, true);
    setWindowModality(parent != 0 ? Qt::WindowModal : Qt::ApplicationModal);
    setWindowFlags(parent != 0 ? Qt::Tool : Qt::SplashScreen);
    setWindowTitle(parent != 0 ? "Meshmoon Storage Picker" : "");
    setModal(true);

    // Center to main window or to parent window.
    if (!parent)
    {
        plugin_->Notifications()->DimForeground();
        plugin_->Notifications()->CenterToMainWindow(this);
    }
    else
        plugin_->Notifications()->CenterToWindow(parent, this);
    
    // Show and activate
    show();
    setFocus(Qt::ActiveWindowFocusReason);
    activateWindow();
    
    // If this is a splash dialog animate opacity
    if (!parent)
    {
        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();
    }

    if (!plugin_ || !storage_)
    {
        view_->addItem(new QListWidgetItem("Failed to list storage content"));
        return;
    }
    if (storage_->RootDirectory().IsNull())
        view_->addItem(new QListWidgetItem("Loading..."));

    MeshmoonStorageAuthenticationMonitor *auth = storage_->Authenticate();
    connect(auth, SIGNAL(Completed()), SLOT(OnStorageAuthCompleted()), Qt::QueuedConnection);
    connect(auth, SIGNAL(Canceled()), SLOT(reject()), Qt::QueuedConnection);
    connect(auth, SIGNAL(Failed(const QString&)), SLOT(reject()), Qt::QueuedConnection);
}