• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

kpimutils

  • kpimutils
progressindicatorwidget.cpp
1 /*
2  Copyright (c) 2013 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "progressindicatorwidget.h"
19 
20 #include <QTimer>
21 
22 namespace KPIMUtils {
23 
24 IndicatorProgress::IndicatorProgress(ProgressIndicatorWidget *widget, QObject *parent)
25  : QObject(parent),
26  mProgressCount(0),
27  mIndicator(widget)
28 {
29  mProgressPix = KPixmapSequence(QLatin1String("process-working"), KIconLoader::SizeSmallMedium);
30  mProgressTimer = new QTimer(this);
31  connect(mProgressTimer, SIGNAL(timeout()), this, SLOT(slotTimerDone()));
32 }
33 
34 IndicatorProgress::~IndicatorProgress()
35 {
36 }
37 
38 void IndicatorProgress::slotTimerDone()
39 {
40  mIndicator->setPixmap(mProgressPix.frameAt(mProgressCount));
41  ++mProgressCount;
42  if (mProgressCount == 8)
43  mProgressCount = 0;
44 
45  mProgressTimer->start(300);
46 }
47 
48 void IndicatorProgress::startAnimation()
49 {
50  mProgressCount = 0;
51  mProgressTimer->start(300);
52 }
53 
54 void IndicatorProgress::stopAnimation()
55 {
56  if (mProgressTimer->isActive())
57  mProgressTimer->stop();
58  mIndicator->clear();
59 }
60 
61 class ProgressIndicatorWidgetPrivate
62 {
63 public:
64  ProgressIndicatorWidgetPrivate(ProgressIndicatorWidget *qq)
65  : q(qq)
66  {
67  indicator = new IndicatorProgress(q);
68  }
69 
70  ~ProgressIndicatorWidgetPrivate()
71  {
72  delete indicator;
73  }
74 
75  IndicatorProgress *indicator;
76  ProgressIndicatorWidget *q;
77 };
78 
79 ProgressIndicatorWidget::ProgressIndicatorWidget(QWidget *parent)
80  : QLabel(parent),
81  d(new ProgressIndicatorWidgetPrivate(this))
82 {
83  setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
84 }
85 
86 ProgressIndicatorWidget::~ProgressIndicatorWidget()
87 {
88  delete d;
89 }
90 
91 void ProgressIndicatorWidget::start()
92 {
93  d->indicator->startAnimation();
94 }
95 
96 void ProgressIndicatorWidget::stop()
97 {
98  d->indicator->stopAnimation();
99 }
100 
101 }
102 
103 #include "progressindicatorwidget.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:02:35 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kpimutils

Skip menu "kpimutils"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal