summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-16 15:16:13 (UTC)
committer harlekin <harlekin>2002-08-16 15:16:13 (UTC)
commitaa9eba407a8236c72822d24643b58d4d48ae80c0 (patch) (side-by-side diff)
tree178c91d1a1d33a3ae6ae7bf91746fc1a4fd499e2
parentc150d03ae4d626c57531f89413710033d1ef5151 (diff)
downloadopie-aa9eba407a8236c72822d24643b58d4d48ae80c0.zip
opie-aa9eba407a8236c72822d24643b58d4d48ae80c0.tar.gz
opie-aa9eba407a8236c72822d24643b58d4d48ae80c0.tar.bz2
blank now works, mail key on ipaq
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h2
4 files changed, 13 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 56203e0..604ed3a 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -439,151 +439,152 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
emit backClicked();
return;
}
}
else if ( !isOnButton && audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
if ( audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
if ( !audioButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
switch (i) {
case AudioPlay:
if( mediaPlayerState->isPaused ) {
// setToggleButton( i, FALSE );
mediaPlayerState->setPaused( FALSE );
return;
} else if( !mediaPlayerState->isPaused ) {
// setToggleButton( i, TRUE );
mediaPlayerState->setPaused( TRUE );
return;
} else {
// setToggleButton( i, TRUE );
// mediaPlayerState->setPlaying( videoButtons[i].isDown );
}
case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
case AudioNext: mediaPlayerState->setNext(); return;
case AudioPrevious: mediaPlayerState->setPrev(); return;
case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
case AudioVolumeUp: emit moreReleased(); return;
case AudioVolumeDown: emit lessReleased(); return;
case AudioPlayList: mediaPlayerState->setList(); return;
case AudioForward: emit forwardReleased(); return;
case AudioBack: emit backReleased(); return;
}
}
}
}
}
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
void AudioWidget::closeEvent( QCloseEvent* ) {
mediaPlayerState->setList();
}
void AudioWidget::paintEvent( QPaintEvent * pe) {
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
QPainter p( &pix );
p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
}
}
void AudioWidget::keyReleaseEvent( QKeyEvent *e)
{
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
hide();
// qDebug("Audio F9");
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
+ mediaPlayerState->toggleBlank();
break;
case Key_F12: //home
break;
case Key_F13: //mail
- mediaPlayerState->toggleBlank();
+ mediaPlayerState->toggleBlank();
break;
case Key_Space: {
if(mediaPlayerState->playing()) {
// toggleButton(1);
mediaPlayerState->setPlaying(FALSE);
// toggleButton(1);
} else {
// toggleButton(0);
mediaPlayerState->setPlaying(TRUE);
// toggleButton(0);
}
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
// toggleButton(6);
break;
case Key_Up:
// toggleButton(5);
emit moreClicked();
emit moreReleased();
// toggleButton(5);
break;
case Key_Right:
// toggleButton(3);
mediaPlayerState->setNext();
// toggleButton(3);
break;
case Key_Left:
// toggleButton(4);
mediaPlayerState->setPrev();
// toggleButton(4);
break;
case Key_Escape: {
#if defined(QT_QWS_IPAQ)
if( mediaPlayerState->isPaused ) {
setToggleButton( i, FALSE );
mediaPlayerState->setPaused( FALSE );
} else if( !mediaPlayerState->isPaused ) {
setToggleButton( i, TRUE );
mediaPlayerState->setPaused( TRUE );
}
#endif
}
break;
};
}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 858b51f..87f4f0c 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,127 +1,129 @@
#include <qpe/qpeapplication.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qwidgetstack.h>
#include <qfile.h>
#include "mediaplayer.h"
#include "playlistwidget.h"
#include "audiowidget.h"
#include "videowidget.h"
#include "volumecontrol.h"
#include "mediaplayerstate.h"
// for setBacklight()
#include <linux/fb.h>
#include <sys/file.h>
#include <sys/ioctl.h>
extern AudioWidget *audioUI;
extern VideoWidget *videoUI;
extern PlayListWidget *playList;
extern MediaPlayerState *mediaPlayerState;
+#define FBIOBLANK 0x4611
+
MediaPlayer::MediaPlayer( QObject *parent, const char *name )
: QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
// xineControl = new XineControl();
// QPEApplication::grabKeyboard(); // EVIL
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
volControl = new VolumeControl;
xineControl = new XineControl();
}
MediaPlayer::~MediaPlayer() {
delete xineControl;
delete volControl;
}
void MediaPlayer::pauseCheck( bool b ) {
if ( b && !mediaPlayerState->playing() ) {
mediaPlayerState->setPaused( FALSE );
}
}
void MediaPlayer::play() {
mediaPlayerState->setPlaying( FALSE );
mediaPlayerState->setPlaying( TRUE );
}
void MediaPlayer::setPlaying( bool play ) {
if ( !play ) {
return;
}
if ( mediaPlayerState->paused() ) {
mediaPlayerState->setPaused( FALSE );
return;
}
const DocLnk *playListCurrent = playList->current();
if ( playListCurrent != NULL ) {
currentFile = playListCurrent;
}
xineControl->play( currentFile->file() );
xineControl->length();
long seconds = mediaPlayerState->length();//
QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
qDebug(time);
QString tickerText;
if( currentFile->file().left(4) == "http" )
tickerText= tr( " File: " ) + currentFile->name();
else
tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
audioUI->setTickerText( currentFile->file( ) );
}
void MediaPlayer::prev() {
if ( playList->prev() ) {
play();
} else if ( mediaPlayerState->looping() ) {
if ( playList->last() ) {
play();
}
} else {
mediaPlayerState->setList();
}
}
void MediaPlayer::next() {
if ( playList->next() ) {
play();
} else if ( mediaPlayerState->looping() ) {
@@ -159,136 +161,137 @@ void MediaPlayer::stopChangingVolume() {
onScreenDisplayVolume = 0;
int w=0;
int h=0;
if( !xineControl->hasVideo()) {
w = audioUI->width();
h = audioUI->height();
audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
} else {
w = videoUI->width();
h = videoUI->height();
videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
}
}
void MediaPlayer::timerEvent( QTimerEvent * ) {
if ( volumeDirection == +1 ) {
volControl->incVol(2);
} else if ( volumeDirection == -1 ) {
volControl->decVol(2);
}
// TODO FIXME
unsigned int v;
v = volControl->getVolume();
v = v / 10;
if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
return;
}
int w=0; int h=0;
if( !xineControl->hasVideo()) {
w = audioUI->width();
h = audioUI->height();
if ( drawnOnScreenDisplay ) {
if ( onScreenDisplayVolume > v ) {
audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
}
}
drawnOnScreenDisplay = TRUE;
onScreenDisplayVolume = v;
QPainter p( audioUI );
p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
QFont f;
f.setPixelSize( 20 );
f.setBold( TRUE );
p.setFont( f );
p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
for ( unsigned int i = 0; i < 10; i++ ) {
if ( v > i ) {
p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
} else {
p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
}
}
} else {
w = videoUI->width();
h = videoUI->height();
if ( drawnOnScreenDisplay ) {
if ( onScreenDisplayVolume > v ) {
videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
}
}
drawnOnScreenDisplay = TRUE;
onScreenDisplayVolume = v;
QPainter p( videoUI );
p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
QFont f;
f.setPixelSize( 20 );
f.setBold( TRUE );
p.setFont( f );
p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
for ( unsigned int i = 0; i < 10; i++ ) {
if ( v > i ) {
p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
} else {
p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
}
}
}
}
void MediaPlayer::blank( bool b ) {
fd=open("/dev/fb0",O_RDWR);
if (fd != -1) {
-
- if ( !b ) {
+ if ( b ) {
qDebug("do blanking");
ioctl( fd, FBIOBLANK, 3 );
isBlanked = TRUE;
} else {
qDebug("do unblanking");
ioctl( fd, FBIOBLANK, 0);
isBlanked = FALSE;
}
close( fd );
+ } else {
+ qDebug("<< /dev/fb0 could not be opend >>");
}
}
void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
break;
case Key_F12: //home
qDebug("Blank here");
// mediaPlayerState->toggleBlank();
break;
case Key_F13: //mail
qDebug("Blank here");
-// mediaPlayerState->toggleBlank();
- break;
+ // mediaPlayerState->toggleBlank();
+ break;
}
}
void MediaPlayer::cleanUp() {
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 6aafb88..6833e07 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -22,260 +22,260 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
MediaPlayerState::~MediaPlayerState() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
}
void MediaPlayerState::readConfig( Config& cfg ) {
cfg.setGroup("Options");
isFullscreen = cfg.readBoolEntry( "FullScreen" );
isScaled = cfg.readBoolEntry( "Scaling" );
isLooping = cfg.readBoolEntry( "Looping" );
isShuffled = cfg.readBoolEntry( "Shuffle" );
usePlaylist = cfg.readBoolEntry( "UsePlayList" );
usePlaylist = TRUE;
isPlaying = FALSE;
isPaused = FALSE;
curPosition = 0;
curLength = 0;
curView = 'l';
}
void MediaPlayerState::writeConfig( Config& cfg ) const {
cfg.setGroup("Options");
cfg.writeEntry("FullScreen", isFullscreen );
cfg.writeEntry("Scaling", isScaled );
cfg.writeEntry("Looping", isLooping );
cfg.writeEntry("Shuffle", isShuffled );
cfg.writeEntry("UsePlayList", usePlaylist );
}
// public stuff
bool MediaPlayerState::streaming() {
return isStreaming;
}
bool MediaPlayerState::fullscreen() {
return isFullscreen;
}
bool MediaPlayerState::scaled() {
return isScaled;
}
bool MediaPlayerState::looping() {
return isLooping;
}
bool MediaPlayerState::shuffled() {
return isShuffled;
}
bool MediaPlayerState:: playlist() {
return usePlaylist;
}
bool MediaPlayerState::paused() {
return isPaused;
}
bool MediaPlayerState::playing() {
return isPlaying;
}
bool MediaPlayerState::stop() {
return isStoped;
}
long MediaPlayerState::position() {
return curPosition;
}
long MediaPlayerState::length() {
return curLength;
}
char MediaPlayerState::view() {
return curView;
}
// slots
void MediaPlayerState::setIsStreaming( bool b ) {
if ( isStreaming == b ) {
return;
}
isStreaming = b;
}
-void MediaPlayerState::setBlank( bool b ) {
+void MediaPlayerState::setFullscreen( bool b ) {
if ( isFullscreen == b ) {
return;
}
isFullscreen = b;
emit fullscreenToggled(b);
}
-void MediaPlayerState::setFullscreen( bool b ) {
+void MediaPlayerState::setBlanked( bool b ) {
if ( isBlanked == b ) {
return;
}
isBlanked = b;
emit blankToggled(b);
}
void MediaPlayerState::setScaled( bool b ) {
if ( isScaled == b ) {
return;
}
isScaled = b;
emit scaledToggled(b);
}
void MediaPlayerState::setLooping( bool b ) {
if ( isLooping == b ) {
return;
}
isLooping = b;
emit loopingToggled(b);
}
void MediaPlayerState::setShuffled( bool b ) {
if ( isShuffled == b ) {
return;
}
isShuffled = b;
emit shuffledToggled(b);
}
void MediaPlayerState::setPlaylist( bool b ) {
if ( usePlaylist == b ) {
return;
}
usePlaylist = b;
emit playlistToggled(b);
}
void MediaPlayerState::setPaused( bool b ) {
if ( isPaused == b ) {
isPaused = FALSE;
emit pausedToggled(FALSE);
return;
}
isPaused = b;
emit pausedToggled(b);
}
void MediaPlayerState::setPlaying( bool b ) {
if ( isPlaying == b ) {
return;
}
isPlaying = b;
isStoped = !b;
emit playingToggled(b);
}
void MediaPlayerState::setStop( bool b ) {
if ( isStoped == b ) {
return;
}
isStoped = b;
emit stopToggled(b);
}
void MediaPlayerState::setPosition( long p ) {
if ( curPosition == p ) {
return;
}
curPosition = p;
emit positionChanged(p);
}
void MediaPlayerState::updatePosition( long p ){
if ( curPosition == p ) {
return;
}
curPosition = p;
emit positionUpdated(p);
}
void MediaPlayerState::setLength( long l ) {
if ( curLength == l ) {
return;
}
curLength = l;
emit lengthChanged(l);
}
void MediaPlayerState::setView( char v ) {
if ( curView == v ) {
return;
}
curView = v;
emit viewChanged(v);
}
void MediaPlayerState::setPrev(){
emit prev();
}
void MediaPlayerState::setNext() {
emit next();
}
void MediaPlayerState::setList() {
setPlaying( FALSE );
setView('l');
}
void MediaPlayerState::setVideo() {
setView('v');
}
void MediaPlayerState::setAudio() {
setView('a');
}
void MediaPlayerState::toggleFullscreen() {
setFullscreen( !isFullscreen );
}
void MediaPlayerState::toggleScaled() {
setScaled( !isScaled);
}
void MediaPlayerState::toggleLooping() {
setLooping( !isLooping);
}
void MediaPlayerState::toggleShuffled() {
setShuffled( !isShuffled);
}
void MediaPlayerState::togglePlaylist() {
setPlaylist( !usePlaylist);
}
void MediaPlayerState::togglePaused() {
setPaused( !isPaused);
}
void MediaPlayerState::togglePlaying() {
setPlaying( !isPlaying);
}
void MediaPlayerState::toggleBlank() {
- setBlank( !isBlanked);
+ setBlanked( !isBlanked);
}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 3baffd3..b3431d7 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,135 +1,135 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef MEDIA_PLAYER_STATE_H
#define MEDIA_PLAYER_STATE_H
#include <qobject.h>
class MediaPlayerDecoder;
class Config;
class MediaPlayerState : public QObject {
Q_OBJECT
public:
MediaPlayerState( QObject *parent, const char *name );
~MediaPlayerState();
bool isPaused;
bool isPlaying;
bool isStoped;
bool streaming();
bool fullscreen();
bool scaled();
bool looping();
bool shuffled();
bool playlist();
bool paused();
bool playing();
bool stop();
long position();
long length();
char view();
public slots:
void setIsStreaming( bool b );
void setFullscreen( bool b );
void setScaled( bool b );
void setLooping( bool b );
void setShuffled( bool b );
void setPlaylist( bool b );
void setPaused( bool b );
void setPlaying( bool b );
void setStop( bool b );
void setPosition( long p );
void updatePosition( long p );
void setLength( long l );
void setView( char v );
- void setBlank( bool b );
+ void setBlanked( bool b );
void setPrev();
void setNext();
void setList();
void setVideo();
void setAudio();
void toggleFullscreen();
void toggleScaled();
void toggleLooping();
void toggleShuffled();
void togglePlaylist();
void togglePaused();
void togglePlaying();
void toggleBlank();
signals:
void fullscreenToggled( bool );
void scaledToggled( bool );
void loopingToggled( bool );
void shuffledToggled( bool );
void playlistToggled( bool );
void pausedToggled( bool );
void playingToggled( bool );
void stopToggled( bool );
void positionChanged( long ); // When the slider is moved
void positionUpdated( long ); // When the media file progresses
void lengthChanged( long );
void viewChanged( char );
void blankToggled( bool );
void prev();
void next();
private:
bool isStreaming;
bool isFullscreen;
bool isScaled;
bool isBlanked;
bool isLooping;
bool isShuffled;
bool usePlaylist;
long curPosition;
long curLength;
char curView;
void readConfig( Config& cfg );
void writeConfig( Config& cfg ) const;
};
#endif // MEDIA_PLAYER_STATE_H