summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 23:22:22 (UTC)
committer simon <simon>2002-12-02 23:22:22 (UTC)
commit24a00c944aace8d7627c1eb0d7cc0ebf40731c57 (patch) (side-by-side diff)
tree3ae5406e15f169849a50e12fec01faa4cfc035e3
parent779219b813f0eba82a8d9236fafd28dbafc594d1 (diff)
downloadopie-24a00c944aace8d7627c1eb0d7cc0ebf40731c57.zip
opie-24a00c944aace8d7627c1eb0d7cc0ebf40731c57.tar.gz
opie-24a00c944aace8d7627c1eb0d7cc0ebf40731c57.tar.bz2
- AudioWidget and VideoWidget are no more singletons via audioUI and
videoUI. this allows switching skins at run-time (the appropriate connections are already made and it works quite nicely :)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp39
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h9
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h6
7 files changed, 52 insertions, 27 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 7d11ca0..7fc7b94 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -2,13 +2,9 @@
#include <qpe/qpeapplication.h>
#include "mediaplayerstate.h"
#include "playlistwidget.h"
-#include "audiowidget.h"
-#include "videowidget.h"
#include "mediaplayer.h"
PlayListWidget *playList;
-AudioWidget *audioUI;
-VideoWidget *videoUI;
int main(int argc, char **argv) {
QPEApplication a(argc,argv);
@@ -17,12 +13,9 @@ int main(int argc, char **argv) {
PlayListWidget pl( st, 0, "playList" );
playList = &pl;
pl.showMaximized();
- AudioWidget aw( st, 0, "audioUI" );
- audioUI = &aw;
- VideoWidget vw( st, 0, "videoUI" );
- videoUI = &vw;
- a.processEvents();
MediaPlayer mp( st, 0, "mediaPlayer" );
+ QObject::connect( &pl, SIGNAL( skinSelected() ),
+ &mp, SLOT( recreateAudioAndVideoWidgets() ) );
a.showMainDocumentWidget(&pl);
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index eccb5d9..a9c74c4 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -24,7 +24,6 @@
#include <sys/ioctl.h>
-extern AudioWidget *audioUI;
extern VideoWidget *videoUI;
extern PlayListWidget *playList;
@@ -34,6 +33,11 @@ extern PlayListWidget *playList;
MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
: QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) {
+ audioUI = 0;
+ videoUI = 0;
+ xineControl = 0;
+ recreateAudioAndVideoWidgets();
+
fd=-1;fl=-1;
playList->setCaption( tr( "OpiePlayer: Initializating" ) );
@@ -49,18 +53,7 @@ MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent,
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( mediaPlayerState );
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
@@ -351,3 +344,25 @@ void MediaPlayer::cleanUp() {// this happens on closing
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
}
+
+void MediaPlayer::recreateAudioAndVideoWidgets()
+{
+ delete xineControl;
+ delete audioUI;
+ delete videoUI;
+ audioUI = new AudioWidget( mediaPlayerState, 0, "audioUI" );
+ videoUI = new VideoWidget( mediaPlayerState, 0, "videoUI" );
+
+ 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() ) );
+
+ xineControl = new XineControl( videoUI, mediaPlayerState );
+}
+
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index 6aeac7c..0d6f722 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -42,12 +42,18 @@
class DocLnk;
class VolumeControl;
class MediaPlayerState;
+class AudioWidget;
+class VideoWidget;
class MediaPlayer : public QObject {
Q_OBJECT
public:
MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name );
~MediaPlayer();
+
+public slots:
+ void recreateAudioAndVideoWidgets();
+
private slots:
void setPlaying( bool );
void pauseCheck( bool );
@@ -64,12 +70,15 @@ protected:
void timerEvent( QTimerEvent *e );
void keyReleaseEvent( QKeyEvent *e);
private:
+
bool isBlanked, l, r;
int fd, fl;
int volumeDirection;
XineControl *xineControl;
VolumeControl *volControl;
MediaPlayerState &mediaPlayerState;
+ AudioWidget *audioUI;
+ VideoWidget *videoUI;
};
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 7ba342b..6bda71e 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1095,11 +1095,13 @@ void PlayListWidget::skinsMenuActivated( int item ) {
}
skinsMenu->setItemChecked( item, TRUE );
+ {
Config cfg( "OpiePlayer" );
cfg.setGroup("Options");
cfg.writeEntry("Skin", skinsMenu->text( item ) );
- QMessageBox::warning( this, tr( "OpiePlayer" ),
- tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) );
+ }
+
+ emit skinSelected();
}
PlayListWidget::TabType PlayListWidget::currentTab() const
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 3f52e63..ad5c9a3 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -94,6 +94,9 @@ public slots:
protected:
void keyReleaseEvent( QKeyEvent *e);
+signals:
+ void skinSelected();
+
private:
int defaultSkinIndex;
bool audioScan, videoScan, audioPopulated, videoPopulated;
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 071ef7c..b4ae783 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -40,9 +40,8 @@
#include "mediaplayerstate.h"
#include "videowidget.h"
-extern VideoWidget *videoUI;
-XineControl::XineControl( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
- : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) {
+XineControl::XineControl( VideoWidget *videoWidget, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
+ : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), videoUI( videoWidget ) {
libXine = new XINE::Lib( videoUI->vidWidget() );
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 00486f2..24e966b 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -39,10 +39,12 @@
#include "mediaplayerstate.h"
+class VideoWidget;
+
class XineControl : public QObject {
Q_OBJECT
public:
- XineControl( MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 );
+ XineControl( VideoWidget *videoWidget, MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 );
~XineControl();
bool hasVideo() const { return hasVideoChannel; }
@@ -113,6 +115,8 @@ private:
signals:
void positionChanged( long );
+private:
+ VideoWidget *videoUI;
};