~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/widgets/busyindicator.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "busyindicator.h"
19
19
 
 
20
#include <QHBoxLayout>
20
21
#include <QMovie>
21
22
 
 
23
BusyIndicator::BusyIndicator(const QString& text, QWidget* parent)
 
24
  : QWidget(parent) {
 
25
  Init(text);
 
26
}
 
27
 
22
28
BusyIndicator::BusyIndicator(QWidget* parent)
23
 
    : QLabel(parent),
24
 
      movie_(new QMovie(":spinner.gif"))
25
 
{
26
 
  setMovie(movie_);
27
 
  setMinimumSize(16, 16);
 
29
  : QWidget(parent) {
 
30
  Init(QString::null);
 
31
}
 
32
 
 
33
void BusyIndicator::Init(const QString& text) {
 
34
  movie_ = new QMovie(":spinner.gif"),
 
35
  label_ = new QLabel;
 
36
 
 
37
  QLabel* icon = new QLabel;
 
38
  icon->setMovie(movie_);
 
39
  icon->setMinimumSize(16, 16);
 
40
 
 
41
  label_->setWordWrap(true);
 
42
  label_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
 
43
 
 
44
  QHBoxLayout* layout = new QHBoxLayout(this);
 
45
  layout->setContentsMargins(0, 0, 0, 0);
 
46
  layout->addWidget(icon);
 
47
  layout->addSpacing(6);
 
48
  layout->addWidget(label_);
 
49
 
 
50
  set_text(text);
28
51
}
29
52
 
30
53
BusyIndicator::~BusyIndicator() {
38
61
void BusyIndicator::hideEvent(QHideEvent*) {
39
62
  movie_->stop();
40
63
}
 
64
 
 
65
void BusyIndicator::set_text(const QString& text) {
 
66
  label_->setText(text);
 
67
  label_->setVisible(!text.isEmpty());
 
68
}
 
69
 
 
70
QString BusyIndicator::text() const {
 
71
  return label_->text();
 
72
}
 
73