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

kpimutils

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

kdepimlibs API Reference

Skip menu "kdepimlibs 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

Search



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