libyui-qt
YQBusyIndicator.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YQBusyIndicator.h
20 
21  Author: Thomas Goettlicher <tgoettlicher@suse.de>
22 
23 /-*/
24 
25 
26 #ifndef YQBusyIndicator_h
27 #define YQBusyIndicator_h
28 
29 #include <QFrame>
30 #include <QTimer>
31 #include <QLabel>
32 #include <yui/YBusyIndicator.h>
33 
34 
35 class QString;
36 class YQWidgetCaption;
37 class BusyBar;
38 
39 class YQBusyIndicator : public QFrame, public YBusyIndicator
40 {
41  Q_OBJECT
42 
43 public:
47  YQBusyIndicator( YWidget * parent,
48  const std::string & label,
49  int timeout = 1000 );
53  virtual ~YQBusyIndicator();
54 
60  virtual void setLabel( const std::string & label );
61 
68  virtual void setTimeout( int newTimeout );
69 
76  int timeout() const { return _timeout; }
77 
83  virtual void setAlive( bool newAlive );
84 
90  virtual void setEnabled( bool enabled );
91 
97  virtual int preferredWidth();
98 
104  virtual int preferredHeight();
105 
111  virtual void setSize( int newWidth, int newHeight );
112 
116  virtual bool setKeyboardFocus();
117 
118 protected:
119 
120  YQWidgetCaption * _caption;
121  BusyBar * _bar;
122  QTimer * _timer;
123  int _timeout;
124 
125 private slots:
126  void setStalled();
127 
128 };
129 
130 
131 
132 
133 
134 class BusyBar : public QFrame
135 {
136  Q_OBJECT
137 public:
138  BusyBar(QWidget * parent);
139 
140 
144  void run();
145 
149  void stop();
150 
151 protected:
152  void paintEvent(QPaintEvent *event);
153 
154 private:
155  double _position; // the position of the bar
156  bool _rightwards; // direction the bar moves
157  QTimer * _timer;
158  bool _alive;
159 
160 private slots:
161  void update();
162 
163 };
164 
165 
166 #endif // YQBusyIndicator_h
virtual void setLabel(const std::string &label)
Definition: YQBusyIndicator.cc:157
Definition: YQBusyIndicator.h:134
virtual int preferredHeight()
Definition: YQBusyIndicator.cc:211
void run()
Definition: YQBusyIndicator.cc:86
virtual void setEnabled(bool enabled)
Definition: YQBusyIndicator.cc:194
virtual int preferredWidth()
Definition: YQBusyIndicator.cc:202
void stop()
Definition: YQBusyIndicator.cc:91
virtual void setSize(int newWidth, int newHeight)
Definition: YQBusyIndicator.cc:217
virtual void setAlive(bool newAlive)
Definition: YQBusyIndicator.cc:164
virtual void setTimeout(int newTimeout)
Definition: YQBusyIndicator.cc:187
int timeout() const
Definition: YQBusyIndicator.h:76
Definition: YQWidgetCaption.h:38
virtual bool setKeyboardFocus()
Definition: YQBusyIndicator.cc:223
YQBusyIndicator(YWidget *parent, const std::string &label, int timeout=1000)
Definition: YQBusyIndicator.cc:119
virtual ~YQBusyIndicator()
Definition: YQBusyIndicator.cc:151
Definition: YQBusyIndicator.h:39