void KNScrollLabel::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); //Update the animations. updateAnimeParam(); //Check is it still need to scroll. if(m_leftMostX==0) { //If not then stopAllTimer(); m_textX=0; update(); } }
void KNScrollLabel::setText(const QString &text) { //Stop timers before. stopAllTimer(); //Reset the Timer. m_waiting->setInterval(5000); //Set texts and values. m_text=text; m_textX=0; //Update viewport. update(); //Update animation parameters. updateAnimeParam(); }
void KNScrollLabel::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); //Update the animations. updateAnimeParameters(); //Check is it still need to scroll, here's a hack: //If the left most is 0, means no need to move. if(m_leftMostX==0) { //Just stop all timer and repaint. stopAllTimer(); m_textX=m_glowRadius/4; update(); } }
void KNScrollLabel::onActionMoving() { //If moving left, if(m_movingLeft) { //Check is it at the most left, if sure. if(m_textX<=m_leftMostX) { //Change direction. m_movingLeft=false; //Stop moving, start short waiting. stopAllTimer(); m_waiting->setInterval(2500); m_waiting->start(); return; } //Move left. m_textX--; update(); return; } //Moving right, Check is at most right or not, if sure. if(m_textX>=m_glowRadius/4) { //Change direction, m_movingLeft=true; //Stop moving, start long waitng. stopAllTimer(); m_waiting->setInterval(5000); m_waiting->start(); return; } //Move right. m_textX++; update(); }
void KNScrollLabel::setText(const QString &text) { //Stop timers before. stopAllTimer(); //Reset moving direction and position parameters. m_movingLeft=true; m_textX=m_glowRadius/4; //Reset the Timer. m_waiting->setInterval(5000); //Set datas. m_text=text; //Update animation parameters. updateAnimeParameters(); //Update viewport. update(); }
void KNScrollLabel::updateAnimeParam() { //If text is so long, enable timer. int textWidth=fontMetrics().width(m_text), rectWidth=contentsRect().width(); if(textWidth>rectWidth) { stopAllTimer(); m_leftMostX=rectWidth-textWidth; setToolTip(m_text); m_waiting->start(); } else { m_leftMostX=0; setToolTip(""); } }
void KNScrollLabel::updateAnimeParameters() { //Get the text width int textWidth=fontMetrics().width(m_text)+m_glowRadius; //If text is too long, enabled the scrolling. if(textWidth>contentsRect().width()) { //Stop the animation timer. stopAllTimer(); //Set tooltip. setToolTip(m_text); //Calculate most left X. This can control the right spacing. m_leftMostX=contentsRect().width()-textWidth; //Start waiting. m_waiting->start(); return; } //Clear the tooltip, and reset text position. m_leftMostX=0; setToolTip(""); }
void LayerBaCayAvatar::runTimer(int posUser) { stopAllTimer(); getUserByPos(posUser)->startTimer(); }