[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeedu/keduca/keduca
From:       Henrique Pinto <stampede () coltec ! ufmg ! br>
Date:       2004-11-14 13:42:31
Message-ID: 20041114134231.4A0C316CA5 () office ! kde ! org
[Download RAW message or body]

CVS commit by pinto: 

Show "X seconds left" instead of a percentage, plus some cleanups.


  M +31 -36    kquestion.cpp   1.11
  M +7 -6      kquestion.h   1.10


--- kdeedu/keduca/keduca/kquestion.cpp  #1.10:1.11
@@ -22,9 +22,12 @@
 #include <qlayout.h>
 #include <qpixmap.h>
+#include <qvbox.h>
 #include <qtimer.h>
-#include <qprogressbar.h>
 
-KQuestion::KQuestion(QWidget *parent, const char *name ) : QFrame(parent,name),
-                                                           _countdownTimer(0L)
+#include <kprogress.h>
+#include <klocale.h>
+
+KQuestion::KQuestion( QWidget *parent, const char *name )
+  : QHBox( parent, name ), _countdownTimer( 0 )
 {
     initGUI();
@@ -40,33 +43,23 @@ void KQuestion::initGUI()
     setFrameShape( QFrame::Box );
     setFrameShadow( QFrame::Plain );
-    setPalette( QPalette( QColor(255, 255, 255) ) );
-
-    QHBoxLayout *form1Layout = new QHBoxLayout( this );
-    form1Layout->setSpacing( 0 );
-    form1Layout->setMargin( 5 );
+  setPalette( QPalette( Qt::white ) );
 
-    QVBoxLayout *picLayout=new QVBoxLayout(form1Layout);
-    picLayout->setSpacing(0);
-    picLayout->setMargin(0);
+  QVBox *picBox = new QVBox( this );
 
-    _picture = new QLabel( this, "PixmapLabel1" );
+  _picture = new QLabel( picBox, "PixmapLabel1" );
     _picture->setScaledContents( FALSE );
-    _picture->setPalette( QPalette( QColor(255, 255, 255) ) );
-    picLayout->addWidget( _picture );
-
-    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
-    picLayout->addItem( spacer );
+  _picture->setPalette( QPalette( Qt::white ) );
 
-    _countdownWidget = new QProgressBar(this);
-    _countdownWidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
-                                                QSizePolicy::Preferred));
-    picLayout->addWidget(_countdownWidget);
+  _countdownWidget = new KProgress( picBox );
+  _countdownWidget->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,
+                                                QSizePolicy::Preferred ) );
+  _countdownWidget->setFormat( i18n( "%v seconds left" ) );
 
-    _view = new QTextView( this, "TextView1" );
-    _view->setFrameShape( QTextView::NoFrame );
-    _view->setHScrollBarMode( QTextView::AlwaysOff );
-    _view->setTextFormat( QTextView::RichText );
+    _view = new QTextEdit( this, "TextView1" );
+    _view->setReadOnly( true );
+    _view->setFrameShape( QTextEdit::NoFrame );
+    _view->setHScrollBarMode( QTextEdit::AlwaysOff );
+    _view->setTextFormat( QTextEdit::RichText );
     _view->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, true ) );
-    form1Layout->addWidget( _view );
 }
 
@@ -98,5 +91,6 @@ void KQuestion::countdown(int starttime)
     // make one step less than time passes by in seconds
     // so that the user will see when time is up
-    _countdownWidget->setTotalSteps(starttime-1);
+    _countdownWidget->setTotalSteps(starttime);
+    _countdownWidget->setProgress(starttime);
   }else{
     _countdownTimer->stop();
@@ -108,5 +102,6 @@ void KQuestion::countDownOne()
 {
   _currentCount--;
-  _countdownWidget->setProgress(_totalCount - _currentCount);
+  //_countdownWidget->setProgress(_totalCount - _currentCount);
+  _countdownWidget->advance(-1);
 
   if (_currentCount == 0)

--- kdeedu/keduca/keduca/kquestion.h  #1.9:1.10
@@ -20,10 +20,10 @@
 #define KQUESTION_H
 
-
-#include <qtextview.h>
+#include <qhbox.h>
+#include <qtextedit.h>
 #include <qlabel.h>
 
 class QTimer;
-class QProgressBar;
+class KProgress;
 
 /**Question view
@@ -31,5 +31,6 @@ class QProgressBar;
  *@author Javier Campos Morales
  */
-class KQuestion : public QFrame  {
+class KQuestion : public QHBox
+{
     Q_OBJECT
 
@@ -67,9 +68,9 @@ private:
 
     /** Main View */
-    QTextView *_view;
+    QTextEdit *_view;
     /** Main Picture */
     QLabel *_picture;
     QTimer *_countdownTimer;
-    QProgressBar *_countdownWidget;
+    KProgress *_countdownWidget;
     int _currentCount;
     int _totalCount;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic