summaryrefslogtreecommitdiff
path: root/libopie/oticker.cpp
Unidiff
Diffstat (limited to 'libopie/oticker.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oticker.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/libopie/oticker.cpp b/libopie/oticker.cpp
index b4afbf9..6cd0dc8 100644
--- a/libopie/oticker.cpp
+++ b/libopie/oticker.cpp
@@ -40,24 +40,25 @@
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <stdio.h> 43#include <stdio.h>
44 44
45#include "oticker.h" 45#include "oticker.h"
46 46
47OTicker::OTicker( QWidget* parent ) 47OTicker::OTicker( QWidget* parent )
48 : QFrame( parent ) { 48 : QLabel( parent ) {
49 49 // : QFrame( parent ) {
50// setFrameStyle( NoFrame/*WinPanel | Sunken */); 50 setTextFormat(Qt::RichText);
51
52 Config cfg("qpe"); 51 Config cfg("qpe");
53 cfg.setGroup("Appearance"); 52 cfg.setGroup("Appearance");
54 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); 53 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
55 foregroundcolor= Qt::black; 54 foregroundcolor= Qt::black;
55 updateTimerTime = 50;
56 scrollLength = 1;
56} 57}
57 58
58OTicker::~OTicker() { 59OTicker::~OTicker() {
59} 60}
60 61
61void OTicker::setBackgroundColor(QColor backcolor) { 62void OTicker::setBackgroundColor(QColor backcolor) {
62 backgroundcolor = backcolor; 63 backgroundcolor = backcolor;
63 update(); 64 update();
@@ -84,30 +85,40 @@ void OTicker::setText( const QString& text ) {
84 pm.fill(backgroundcolor); 85 pm.fill(backgroundcolor);
85 QPainter pmp( &pm ); 86 QPainter pmp( &pm );
86 pmp.setPen(foregroundcolor ); 87 pmp.setPen(foregroundcolor );
87 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText ); 88 pmp.drawText( 0, 0, pixelLen, contentsRect().height(), AlignVCenter, scrollText );
88 pmp.end(); 89 pmp.end();
89 scrollTextPixmap = pm; 90 scrollTextPixmap = pm;
90 91
91 killTimers(); 92 killTimers();
93 // qDebug("Scrollupdate %d", updateTimerTime);
92 if ( pixelLen > contentsRect().width() ) 94 if ( pixelLen > contentsRect().width() )
93 startTimer( 50 ); 95 startTimer( updateTimerTime);
94 update(); 96 update();
95} 97}
96 98
97 99
98void OTicker::timerEvent( QTimerEvent * ) { 100void OTicker::timerEvent( QTimerEvent * ) {
99 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - 1; 101 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength;//1;
100 repaint( FALSE ); 102 repaint( FALSE );
101} 103}
102 104
103void OTicker::drawContents( QPainter *p ) { 105void OTicker::drawContents( QPainter *p ) {
104 int pixelLen = scrollTextPixmap.width(); 106 int pixelLen = scrollTextPixmap.width();
105 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); 107 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
106 if ( pixelLen > contentsRect().width() ) // Scrolling 108 if ( pixelLen > contentsRect().width() ) // Scrolling
107 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); 109 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
108} 110}
109 111
110void OTicker::mouseReleaseEvent( QMouseEvent * ) { 112void OTicker::mouseReleaseEvent( QMouseEvent * ) {
111// qDebug("<<<<<<<>>>>>>>>>"); 113// qDebug("<<<<<<<>>>>>>>>>");
112 emit mousePressed(); 114 emit mousePressed();
113} 115}
116
117void OTicker::setUpdateTime(int time) {
118 updateTimerTime=time;
119}
120
121void OTicker::setScrollLength(int len) {
122scrollLength=len;
123}
124