summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-07-03 14:44:22 (UTC)
committer harlekin <harlekin>2002-07-03 14:44:22 (UTC)
commite1e4956ec7ffa9a07f98b03e831f0f9627556a6c (patch) (unidiff)
treec0545c6a22732f05804bda7704227132f64b7239
parent61770de77f2abe8012d44cce49d04489e4187644 (diff)
downloadopie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.zip
opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.gz
opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.bz2
much more code cleanup, make if look more like c++ code
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h44
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.h12
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp68
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h5
7 files changed, 65 insertions, 125 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 8d3963a..1b0de5d 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -17,3 +17,2 @@ extern MediaPlayerState *mediaPlayerState;
17 17
18
19static const int xo = -2; // movable x offset 18static const int xo = -2; // movable x offset
@@ -22,2 +21,40 @@ static const int yo = 22; // movable y offset
22 21
22Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
23 setFrameStyle( WinPanel | Sunken );
24 setText( "No Song" );
25}
26
27Ticker::~Ticker() {
28}
29
30void Ticker::setText( const QString& text ) {
31 pos = 0; // reset it everytime the text is changed
32 scrollText = text;
33 pixelLen = fontMetrics().width( scrollText );
34 killTimers();
35 if ( pixelLen > width() ) {
36 startTimer( 50 );
37 }
38 update();
39}
40
41
42void Ticker::timerEvent( QTimerEvent * ) {
43 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
44 repaint( FALSE );
45}
46
47void Ticker::drawContents( QPainter *p ) {
48 QPixmap pm( width(), height() );
49 pm.fill( colorGroup().base() );
50 QPainter pmp( &pm );
51 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
52 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
53 }
54 p->drawPixmap( 0, 0, pm );
55}
56
57
58
59
23struct MediaButton { 60struct MediaButton {
@@ -29,2 +66,4 @@ struct MediaButton {
29 66
67
68
30// Layout information for the audioButtons (and if it is a toggle button or not) 69// Layout information for the audioButtons (and if it is a toggle button or not)
@@ -42,3 +81,2 @@ MediaButton audioButtons[] = {
42 81
43
44static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 82static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
@@ -147,3 +185,2 @@ void AudioWidget::setView( char view ) {
147 startTimer( 150 ); 185 startTimer( 150 );
148 // show();
149 showMaximized(); 186 showMaximized();
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index eab5df4..441eb6e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -32,41 +32,11 @@ class Ticker : public QFrame {
32 Q_OBJECT 32 Q_OBJECT
33
33public: 34public:
34 Ticker( QWidget* parent=0 ) : QFrame( parent ) { 35 Ticker( QWidget* parent=0 );
35 setFrameStyle( WinPanel | Sunken ); 36 ~Ticker();
36 setText( "No Song" ); 37 void setText( const QString& text ) ;
37 } 38
38 ~Ticker() { }
39 void setText( const QString& text ) {
40 pos = 0; // reset it everytime the text is changed
41 scrollText = text;
42 pixelLen = fontMetrics().width( scrollText );
43 killTimers();
44 if ( pixelLen > width() )
45 startTimer( 50 );
46 update();
47 }
48protected: 39protected:
49 void timerEvent( QTimerEvent * ) { 40 void timerEvent( QTimerEvent * );
50 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 41 void drawContents( QPainter *p );
51#ifndef USE_DBLBUF
52 scroll( -1, 0, contentsRect() );
53#else
54 repaint( FALSE );
55#endif
56 }
57 void drawContents( QPainter *p ) {
58#ifndef USE_DBLBUF
59 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
60 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
61#else
62 // Double buffering code.
63 // Looks like qvfb makes it look like it flickers but I don't think it really is
64 QPixmap pm( width(), height() );
65 pm.fill( colorGroup().base() );
66 QPainter pmp( &pm );
67 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
68 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
69 p->drawPixmap( 0, 0, pm );
70#endif
71 }
72private: 42private:
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index da8e276..687aff6 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,9 +1 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "inputDialog.h" #include "inputDialog.h"
diff --git a/noncore/multimedia/opieplayer2/inputDialog.h b/noncore/multimedia/opieplayer2/inputDialog.h
index 3e3e36f..d4f5e12 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.h
+++ b/noncore/multimedia/opieplayer2/inputDialog.h
@@ -1,9 +1,2 @@
1/**************************************************************************** 1
2** Form interface generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:54:46 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INPUTDIALOG_H 2#ifndef INPUTDIALOG_H
@@ -16,4 +9,3 @@ class QLineEdit;
16 9
17class InputDialog : public QDialog 10class InputDialog : public QDialog {
18{
19 Q_OBJECT 11 Q_OBJECT
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e6d0525..87184ba 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -56,5 +56,4 @@ void MediaPlayer::setPlaying( bool play ) {
56 if ( !play ) { 56 if ( !play ) {
57 mediaPlayerState->setPaused( FALSE ); 57 mediaPlayerState->setPaused( FALSE );
58// loopControl->stop( FALSE ); 58 return;
59 return;
60 } 59 }
@@ -62,4 +61,4 @@ void MediaPlayer::setPlaying( bool play ) {
62 if ( mediaPlayerState->paused() ) { 61 if ( mediaPlayerState->paused() ) {
63 mediaPlayerState->setPaused( FALSE ); 62 mediaPlayerState->setPaused( FALSE );
64 return; 63 return;
65 } 64 }
@@ -68,53 +67,14 @@ void MediaPlayer::setPlaying( bool play ) {
68 if ( playListCurrent != NULL ) { 67 if ( playListCurrent != NULL ) {
69// loopControl->stop( TRUE ); 68 currentFile = playListCurrent;
70 currentFile = playListCurrent;
71 }
72
73 /*
74
75 if ( currentFile == NULL ) {
76 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
77 mediaPlayerState->setPlaying( FALSE );
78 return;
79 }
80
81 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
82 QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" );
83 mediaPlayerState->setPlaying( FALSE );
84 return;
85 }
86
87 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
88 QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" );
89 mediaPlayerState->setPlaying( FALSE );
90 return;
91 } 69 }
92 70
93// if ( !loopControl->init( currentFile->file() ) ) { 71 audioUI->setTickerText( currentFile->file() );
94// QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
95// mediaPlayerState->setPlaying( FALSE );
96// return;
97// }
98// long seconds = loopControl->totalPlaytime();
99 long seconds = 120;
100 QString time;
101 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
102 QString tickerText;
103 if( currentFile->file().left(4) == "http" )
104 tickerText= tr( " File: " ) + currentFile->name();
105 else
106 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
107 72
108 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
109 if ( !fileInfo.isEmpty() )
110 tickerText += ", " + fileInfo;
111 audioUI->setTickerText( tickerText + "." );
112 73
74 // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben
113 75
114 */ // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben 76 // Ob auch video 'v' : 'a'
77 // mediaPlayerState->setView( 'v' );
115 78
116 79 // abspielen starten.
117 // loopControl->play();
118
119 // mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' );
120} 80}
@@ -147,3 +107,3 @@ void MediaPlayer::startDecreasingVolume() {
147 startTimer( 100 ); 107 startTimer( 100 );
148 // sollte volumeapplet machen 108 // da kommt demchst osound denk ich mal
149 // AudioDevice::decreaseVolume(); 109 // AudioDevice::decreaseVolume();
@@ -165,5 +125,5 @@ void MediaPlayer::stopChangingVolume() {
165void MediaPlayer::timerEvent( QTimerEvent * ) { 125void MediaPlayer::timerEvent( QTimerEvent * ) {
166// if ( volumeDirection == +1 ) 126 // if ( volumeDirection == +1 )
167// AudioDevice::increaseVolume(); 127 // AudioDevice::increaseVolume();
168// else if ( volumeDirection == -1 ) 128 // else if ( volumeDirection == -1 )
169 // AudioDevice::decreaseVolume(); 129 // AudioDevice::decreaseVolume();
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 9b5f70e..d1d30e4 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -14,10 +14,2 @@
14 14
15#ifdef QT_NO_COMPONENT
16// Plugins which are compiled in when no plugin architecture available
17#include "libmad/libmadpluginimpl.h"
18#include "libmpeg3/libmpeg3pluginimpl.h"
19#include "wavplugin/wavpluginimpl.h"
20#endif
21
22
23//#define MediaPlayerDebug(x) qDebug x 15//#define MediaPlayerDebug(x) qDebug x
@@ -27,3 +19,3 @@
27MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 19MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
28 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 20 : QObject( parent, name ), decoder( NULL ) {
29 Config cfg( "OpiePlayer" ); 21 Config cfg( "OpiePlayer" );
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 374e780..8a64939 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -32,4 +32,3 @@ public:
32 MediaPlayerDecoder *curDecoder(); 32 MediaPlayerDecoder *curDecoder();
33 MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the 33
34 // number of audio samples if we are using the libmad plugin
35public slots: 34public slots:
@@ -90,4 +89,2 @@ private:
90 MediaPlayerDecoder *decoder; 89 MediaPlayerDecoder *decoder;
91 MediaPlayerDecoder *libmpeg3decoder;
92// MediaPlayerDecoder *libwavdecoder;
93 90