iCub-main
loadingwidget.cpp
Go to the documentation of this file.
1 #include "loadingwidget.h"
2 #include "ui_loadingwidget.h"
3 
4 LoadingWidget::LoadingWidget(QWidget *parent) :
5  QDialog(parent),
6  ui(new Ui::LoadingWidget)
7 {
8  ui->setupUi(this);
9  counter=0;
10 
11  setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
12  setAttribute(Qt::WA_TranslucentBackground);
13 
14  setModal(true);
15 
16 
17  splashTimer.setInterval(50);
18  splashTimer.setSingleShot(false);
19  connect(&splashTimer,SIGNAL(timeout()),this,SLOT(onSplashTimer()),Qt::DirectConnection);
20 }
21 
23 {
24  delete ui;
25 }
26 
27 
28 void LoadingWidget::onSplashTimer()
29 {
30  QString name = QString(":/images/splash/bg%1.png").arg(counter+1);
31  counter++;
32  counter = counter % 8;
33  ui->loadingIco->setPixmap(QPixmap(name));
34  ui->loadingIco->repaint();
35 }
36 
37 
39 {
40  mutex.lock();
41  splashTimer.start();
42  QWidget *w =((QWidget*)parent());
43  int x = w->x() + ((w->width() - width()) / 2);
44  int y = w->y() + ((w->height() - height()) / 2);
45  this->setGeometry(x,y,width(),height());
46  mutex.unlock();
47  return exec();
48 }
49 
51 {
52  mutex.lock();
53  splashTimer.stop();
54  mutex.unlock();
55 }
LoadingWidget(QWidget *parent=0)