libyui-qt
2.43.5
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YQBusyIndicator.h 00020 00021 Author: Thomas Goettlicher <tgoettlicher@suse.de> 00022 00023 /-*/ 00024 00025 00026 #ifndef YQBusyIndicator_h 00027 #define YQBusyIndicator_h 00028 00029 #include <QFrame> 00030 #include <QTimer> 00031 #include <QLabel> 00032 #include <yui/YBusyIndicator.h> 00033 00034 00035 class QString; 00036 class YQWidgetCaption; 00037 class BusyBar; 00038 00039 class YQBusyIndicator : public QFrame, public YBusyIndicator 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 /** 00045 * Constructor. 00046 **/ 00047 YQBusyIndicator( YWidget * parent, 00048 const std::string & label, 00049 int timeout = 1000 ); 00050 /** 00051 * Destructor. 00052 **/ 00053 virtual ~YQBusyIndicator(); 00054 00055 /** 00056 * Set the label (the caption above the progress bar). 00057 * 00058 * Reimplemented from YBusyIndicator. 00059 **/ 00060 virtual void setLabel( const std::string & label ); 00061 00062 /** 00063 * Set the timeout is ms after that the widget shows 'stalled' when no 00064 * new tick is received. 00065 * 00066 * Reimplemented from YBusyIndicator. 00067 **/ 00068 virtual void setTimeout( int newTimeout ); 00069 00070 /** 00071 * Return the timeout is ms after that the widget shows 'stalled' when no 00072 * new tick is received. 00073 * 00074 * Reimplemented from YBusyIndicator. 00075 **/ 00076 int timeout() const { return _timeout; } 00077 00078 /** 00079 * Send a keep allive message. 00080 * 00081 * Reimplemented from YBusyIndicator. 00082 **/ 00083 virtual void setAlive( bool newAlive ); 00084 00085 /** 00086 * Set enabled/disabled state. 00087 * 00088 * Reimplemented from YWidget. 00089 **/ 00090 virtual void setEnabled( bool enabled ); 00091 00092 /** 00093 * Preferred width of the widget. 00094 * 00095 * Reimplemented from YWidget. 00096 **/ 00097 virtual int preferredWidth(); 00098 00099 /** 00100 * Preferred height of the widget. 00101 * 00102 * Reimplemented from YWidget. 00103 **/ 00104 virtual int preferredHeight(); 00105 00106 /** 00107 * Set the new size of the widget. 00108 * 00109 * Reimplemented from YWidget. 00110 **/ 00111 virtual void setSize( int newWidth, int newHeight ); 00112 00113 /** 00114 * Accept the keyboard focus. 00115 **/ 00116 virtual bool setKeyboardFocus(); 00117 00118 protected: 00119 00120 YQWidgetCaption * _caption; 00121 BusyBar * _bar; 00122 QTimer * _timer; 00123 int _timeout; 00124 00125 private slots: 00126 void setStalled(); 00127 00128 }; 00129 00130 00131 00132 00133 00134 class BusyBar : public QFrame 00135 { 00136 Q_OBJECT 00137 public: 00138 BusyBar(QWidget * parent); 00139 00140 00141 /** 00142 * start moving bar animation 00143 **/ 00144 void run(); 00145 00146 /** 00147 * stop moving bar animation 00148 **/ 00149 void stop(); 00150 00151 protected: 00152 void paintEvent(QPaintEvent *event); 00153 00154 private: 00155 double _position; // the position of the bar 00156 bool _rightwards; // direction the bar moves 00157 QTimer * _timer; 00158 bool _alive; 00159 00160 private slots: 00161 void update(); 00162 00163 }; 00164 00165 00166 #endif // YQBusyIndicator_h