QTfrontend/ui/widget/bgwidget.cpp
changeset 6579 fc52f7c22c9b
parent 6574 ec059b55aa72
child 6583 4218782d8ca0
equal deleted inserted replaced
6578:d4ad42283125 6579:fc52f7c22c9b
    16  * along with this program; if not, write to the Free Software
    16  * along with this program; if not, write to the Free Software
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    18  */
    18  */
    19 
    19 
    20 #include "bgwidget.h"
    20 #include "bgwidget.h"
       
    21 #include "hwconsts.h"
    21 
    22 
    22 SpritePosition::SpritePosition(QWidget * parent, int sw, int sh)
    23 SpritePosition::SpritePosition(QWidget * parent, int sw, int sh)
    23 {
    24 {
    24     wParent = parent;
    25     wParent = parent;
    25     iSpriteWidth = sw;
    26     iSpriteWidth = sw;
    83 }
    84 }
    84 
    85 
    85 BGWidget::BGWidget(QWidget * parent) : QWidget(parent), enabled(false)
    86 BGWidget::BGWidget(QWidget * parent) : QWidget(parent), enabled(false)
    86 {
    87 {
    87     setAttribute(Qt::WA_NoSystemBackground, true);
    88     setAttribute(Qt::WA_NoSystemBackground, true);
    88     sprite.load(":/res/Star.png");
    89 
       
    90     QString fname;
       
    91 
       
    92     //For each season, there is a replacement for the star (Star.png)
       
    93     //Todo: change element for easter and birthday
       
    94     //Simply replace Confetti.png and Egg.png with an appropriate graphic)
       
    95     switch (season)
       
    96     {
       
    97     case SEASON_CHRISTMAS : fname = "Flake.png";
       
    98 			    break;
       
    99     case SEASON_EASTER : fname = "Egg.png";
       
   100 			 break;
       
   101     case SEASON_HWBDAY : fname = "Confetti.png";
       
   102 			 break;
       
   103     default : fname = "Star.png";
       
   104     }
       
   105 
       
   106     sprite.load(":/res/" + fname);
    89 
   107 
    90     setAutoFillBackground(false);
   108     setAutoFillBackground(false);
    91 
   109 
    92     for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i] = new SpritePosition(this, sprite.width(), sprite.height());
   110     for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i] = new SpritePosition(this, sprite.width(), sprite.height());
    93 
   111 
   162 }
   180 }
   163 
   181 
   164 void BGWidget::stopAnimation()
   182 void BGWidget::stopAnimation()
   165 {
   183 {
   166     timerAnimation->stop();
   184     timerAnimation->stop();
   167     repaint();
   185 	repaint();
   168 }
   186 }
   169 
   187 
   170 void BGWidget::init()
   188 void BGWidget::init()
   171 {
   189 {
   172     for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i]->init();
   190     for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i]->init();