Author: tgoettlicher Date: Fri Jan 11 16:47:13 2008 New Revision: 43562 URL: http://svn.opensuse.org/viewcvs/yast?rev=43562&view=rev Log: BusyIndicator facelift Modified: trunk/qt/VERSION.cmake trunk/qt/package/yast2-qt.changes trunk/qt/src/YQBusyIndicator.cc trunk/qt/src/YQBusyIndicator.h Modified: trunk/qt/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/VERSION.cmake?rev=43562&r1... ============================================================================== --- trunk/qt/VERSION.cmake (original) +++ trunk/qt/VERSION.cmake Fri Jan 11 16:47:13 2008 @@ -1,3 +1,3 @@ SET(VERSION_MAJOR "2") SET(VERSION_MINOR "16") -SET(VERSION_PATCH "15") +SET(VERSION_PATCH "16") Modified: trunk/qt/package/yast2-qt.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/package/yast2-qt.changes?rev=4... ============================================================================== --- trunk/qt/package/yast2-qt.changes (original) +++ trunk/qt/package/yast2-qt.changes Fri Jan 11 16:47:13 2008 @@ -1,3 +1,10 @@ +Fri Jan 11 16:47:00 CET 2008 - tgoettlicher@suse.de + +- BusyIndicator facelift +- V 2.16.16 + +------------------------------------------------------------------- + Thu Jan 10 17:28:00 CET 2008 - tgoettlicher@suse.de - added BusyIndicator widget (fate #302559) Modified: trunk/qt/src/YQBusyIndicator.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQBusyIndicator.cc?rev=435... ============================================================================== --- trunk/qt/src/YQBusyIndicator.cc (original) +++ trunk/qt/src/YQBusyIndicator.cc Fri Jan 11 16:47:13 2008 @@ -17,11 +17,15 @@ /-*/ -#include <qprogressbar.h> -#include <QVBoxLayout> +//#include <qprogressbar.h> +#include <QLabel> +#include <QPalette> #include <QTimer> +#include <QVBoxLayout> +#include <QFrame> + +#include <QPainter> -#include <qlabel.h> #define y2log_component "qt-ui" #include <ycp/y2log.h> @@ -33,6 +37,76 @@ #include "YQWidgetCaption.h" +#define REPAINT_INTERVAL 100 +#define STEP_SIZE .05 +#define MINIMUM_WITDH 100 +#define MINIMUM_HEIGHT 24 + + +BusyBar::BusyBar(QWidget *parent) + : QFrame(parent) + , _position(.5) + , _rightwards(true) + , _alive(true) +{ + setMinimumSize(MINIMUM_WITDH, MINIMUM_HEIGHT); + + _timer = new QTimer(this); + connect(_timer, SIGNAL(timeout()), this, SLOT(update())); + _timer->start(REPAINT_INTERVAL); + + setFrameStyle (QFrame::Panel | QFrame::Sunken ); + setLineWidth(2); + setMidLineWidth(2); +} + +void BusyBar::update() +{ + if (!_alive) + return; + + if (_position > 1.0 - STEP_SIZE || _position < STEP_SIZE ) + _rightwards = !_rightwards; + + if (_rightwards) + _position += STEP_SIZE; + else + _position -= STEP_SIZE; + + repaint(); +} + +void BusyBar::run() +{ + _alive=true; +} + +void BusyBar::stop() +{ + _alive=false; +} + +void BusyBar::paintEvent(QPaintEvent * e) +{ + + QPalette palette = QApplication::palette(); + QColor foreground = palette.color(QPalette::Active, QPalette::Highlight); + QColor background = palette.color(QPalette::Active, QPalette::Base); + + QPainter painter(this); + QLinearGradient gradient(0, 0, width()-1, 0); + gradient.setColorAt(min(_position - STEP_SIZE, 0.0), background ); + gradient.setColorAt(_position, foreground ); + gradient.setColorAt(max(_position + STEP_SIZE, 1.0), background ); + + painter.setBrush(gradient); + painter.setPen(Qt::NoPen); + painter.drawRect(rect()); + + QFrame::paintEvent(e); +} + + YQBusyIndicator::YQBusyIndicator( YWidget * parent, const string & label, int timeout ) @@ -57,12 +131,11 @@ YUI_CHECK_NEW( _caption ); layout->addWidget( _caption ); - _qt_progressbar = new QProgressBar( this ); - _qt_progressbar->setRange(0, 0); - YUI_CHECK_NEW( _qt_progressbar ); - layout->addWidget( _qt_progressbar ); - - _caption->setBuddy( _qt_progressbar ); + _bar = new BusyBar( this ); + YUI_CHECK_NEW ( _bar ); + layout->addWidget( _bar ); + _caption->setBuddy( _bar ); + } @@ -84,14 +157,13 @@ YBusyIndicator::setAlive( newAlive ); if (newAlive) { - _qt_progressbar->setRange(0, 0); + _bar->run(); _timer->stop(); _timer->start(_timeout); } else { - _qt_progressbar->setRange(0, 1); - _qt_progressbar->reset(); + _bar->stop(); _timer->stop(); } } @@ -113,7 +185,7 @@ void YQBusyIndicator::setEnabled( bool enabled ) { _caption->setEnabled( enabled ); - _qt_progressbar->setEnabled( enabled ); + _bar->setEnabled( enabled ); YWidget::setEnabled( enabled ); } @@ -141,7 +213,7 @@ bool YQBusyIndicator::setKeyboardFocus() { - _qt_progressbar->setFocus(); + _bar->setFocus(); return true; } Modified: trunk/qt/src/YQBusyIndicator.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQBusyIndicator.h?rev=4356... ============================================================================== --- trunk/qt/src/YQBusyIndicator.h (original) +++ trunk/qt/src/YQBusyIndicator.h Fri Jan 11 16:47:13 2008 @@ -22,12 +22,13 @@ #include <QFrame> #include <QTimer> +#include <QLabel> #include "YBusyIndicator.h" class QString; class YQWidgetCaption; -class QProgressBar; +class BusyBar; class YQBusyIndicator : public QFrame, public YBusyIndicator { @@ -111,7 +112,7 @@ protected: YQWidgetCaption * _caption; - QProgressBar * _qt_progressbar; + BusyBar * _bar; QTimer * _timer; int _timeout; @@ -120,4 +121,40 @@ }; + + + + +class BusyBar : public QFrame +{ + Q_OBJECT +public: + BusyBar(QWidget * parent); + + + /** + * start moving bar animation + **/ + void run(); + + /** + * stop moving bar animation + **/ + void stop(); + +protected: + void paintEvent(QPaintEvent *event); + +private: + float _position; // the position of the bar + bool _rightwards; // direction the bar moves + QTimer * _timer; + bool _alive; + +private slots: + void update(); + +}; + + #endif // YQBusyIndicator_h -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org