summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-14 11:21:03 (UTC)
committer zecke <zecke>2004-03-14 11:21:03 (UTC)
commitced17a6b39a2b4e282b5912dbb58262d4ad2b6d1 (patch) (unidiff)
tree171a164f98398128f906f647b47d2d4d2f2cb513
parent6b5ec807e25094979f5631a3a46baf7415326d8a (diff)
downloadopie-ced17a6b39a2b4e282b5912dbb58262d4ad2b6d1.zip
opie-ced17a6b39a2b4e282b5912dbb58262d4ad2b6d1.tar.gz
opie-ced17a6b39a2b4e282b5912dbb58262d4ad2b6d1.tar.bz2
Use ODP namespace
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h4
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp3
-rw-r--r--noncore/multimedia/showimg/main.cpp2
-rw-r--r--noncore/multimedia/showimg/showimg.cpp5
6 files changed, 13 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 452117c..28a42eb 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,166 +1,167 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35#include "audiowidget.h" 35#include "audiowidget.h"
36 36
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38 38
39using namespace Opie::Ui;
39namespace 40namespace
40{ 41{
41 42
42const int xo = -2; // movable x offset 43const int xo = -2; // movable x offset
43const int yo = 22; // movable y offset 44const int yo = 22; // movable y offset
44 45
45const MediaWidget::SkinButtonInfo skinInfo[] = 46const MediaWidget::SkinButtonInfo skinInfo[] =
46{ 47{
47 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 48 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
48 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 49 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
49 { MediaWidget::Next, "next", MediaWidget::NormalButton }, 50 { MediaWidget::Next, "next", MediaWidget::NormalButton },
50 { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, 51 { MediaWidget::Previous, "prev", MediaWidget::NormalButton },
51 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 52 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
52 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 53 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
53 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, 54 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
54 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, 55 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
55 { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, 56 { MediaWidget::Forward, "forward", MediaWidget::NormalButton },
56 { MediaWidget::Back, "back", MediaWidget::NormalButton } 57 { MediaWidget::Back, "back", MediaWidget::NormalButton }
57}; 58};
58 59
59const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 60const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
60 61
61void changeTextColor( QWidget * w) { 62void changeTextColor( QWidget * w) {
62 QPalette p = w->palette(); 63 QPalette p = w->palette();
63 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 64 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
64 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 65 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
65 w->setPalette( p ); 66 w->setPalette( p );
66} 67}
67 68
68} 69}
69 70
70AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 71AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
71 72
72 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 73 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
73 audioSliderBeingMoved( false ) 74 audioSliderBeingMoved( false )
74{ 75{
75 setCaption( tr("OpiePlayer") ); 76 setCaption( tr("OpiePlayer") );
76 77
77 loadSkin(); 78 loadSkin();
78 79
79 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 80 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
80 connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); 81 connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) );
81 82
82 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 83 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
83 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 84 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
84 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 85 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
85 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 86 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
86 87
87 // Intialise state 88 // Intialise state
88 setLength( mediaPlayerState.length() ); 89 setLength( mediaPlayerState.length() );
89 setPosition( mediaPlayerState.position() ); 90 setPosition( mediaPlayerState.position() );
90 setLooping( mediaPlayerState.isFullscreen() ); 91 setLooping( mediaPlayerState.isFullscreen() );
91 // setPaused( mediaPlayerState->paused() ); 92 // setPaused( mediaPlayerState->paused() );
92 setPlaying( mediaPlayerState.isPlaying() ); 93 setPlaying( mediaPlayerState.isPlaying() );
93} 94}
94 95
95AudioWidget::~AudioWidget() { 96AudioWidget::~AudioWidget() {
96 97
97// mediaPlayerState->setPlaying(false); 98// mediaPlayerState->setPlaying(false);
98} 99}
99 100
100MediaWidget::GUIInfo AudioWidget::guiInfo() 101MediaWidget::GUIInfo AudioWidget::guiInfo()
101{ 102{
102 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); 103 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount );
103} 104}
104 105
105void AudioWidget::resizeEvent( QResizeEvent *e ) { 106void AudioWidget::resizeEvent( QResizeEvent *e ) {
106 int h = height(); 107 int h = height();
107 int w = width(); 108 int w = width();
108 109
109 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 110 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
110 slider.setFixedWidth( w - 110 ); 111 slider.setFixedWidth( w - 110 );
111 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 112 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
112 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 113 slider.setBackgroundOrigin( QWidget::ParentOrigin );
113 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 114 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
114 115
115 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; 116 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2;
116 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; 117 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
117 118
118 MediaWidget::resizeEvent( e ); 119 MediaWidget::resizeEvent( e );
119} 120}
120 121
121void AudioWidget::sliderPressed() { 122void AudioWidget::sliderPressed() {
122 audioSliderBeingMoved = TRUE; 123 audioSliderBeingMoved = TRUE;
123} 124}
124 125
125 126
126void AudioWidget::sliderReleased() { 127void AudioWidget::sliderReleased() {
127 audioSliderBeingMoved = FALSE; 128 audioSliderBeingMoved = FALSE;
128 if ( slider.width() == 0 ) 129 if ( slider.width() == 0 )
129 return; 130 return;
130 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 131 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
131 mediaPlayerState.setPosition( val ); 132 mediaPlayerState.setPosition( val );
132} 133}
133 134
134void AudioWidget::setPosition( long i ) { 135void AudioWidget::setPosition( long i ) {
135 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 136 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
136 updateSlider( i, mediaPlayerState.length() ); 137 updateSlider( i, mediaPlayerState.length() );
137} 138}
138 139
139 140
140void AudioWidget::setLength( long max ) { 141void AudioWidget::setLength( long max ) {
141 updateSlider( mediaPlayerState.position(), max ); 142 updateSlider( mediaPlayerState.position(), max );
142} 143}
143 144
144 145
145void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 146void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
146 if ( mediaType == MediaPlayerState::Audio ) { 147 if ( mediaType == MediaPlayerState::Audio ) {
147 // startTimer( 150 ); 148 // startTimer( 150 );
148 QPEApplication::showWidget( this ); 149 QPEApplication::showWidget( this );
149 return; 150 return;
150 } 151 }
151 152
152 killTimers(); 153 killTimers();
153 hide(); 154 hide();
154} 155}
155 156
156void AudioWidget::loadSkin() 157void AudioWidget::loadSkin()
157{ 158{
158 loadDefaultSkin( guiInfo() ); 159 loadDefaultSkin( guiInfo() );
159 160
160 songInfo.setFocusPolicy( QWidget::NoFocus ); 161 songInfo.setFocusPolicy( QWidget::NoFocus );
161// changeTextColor( &songInfo ); 162// changeTextColor( &songInfo );
162// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 163// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
163// songInfo.setFrameStyle( QFrame::NoFrame); 164// songInfo.setFrameStyle( QFrame::NoFrame);
164 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 165 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
165// songInfo.setForegroundColor(Qt::white); 166// songInfo.setForegroundColor(Qt::white);
166 167
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index b436239..aea4146 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,95 +1,95 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qlineedit.h> 37#include <qlineedit.h>
38 38
39#include <opie/oticker.h> 39#include <opie2/oticker.h>
40 40
41#include "mediawidget.h" 41#include "mediawidget.h"
42 42
43class QPixmap; 43class QPixmap;
44 44
45class AudioWidget : public MediaWidget { 45class AudioWidget : public MediaWidget {
46 Q_OBJECT 46 Q_OBJECT
47public: 47public:
48 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 48 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
49 ~AudioWidget(); 49 ~AudioWidget();
50 void setTickerText( const QString &text ) { songInfo.setText( text ); } 50 void setTickerText( const QString &text ) { songInfo.setText( text ); }
51 51
52 static MediaWidget::GUIInfo guiInfo(); 52 static MediaWidget::GUIInfo guiInfo();
53 53
54public slots: 54public slots:
55 void updateSlider( long, long ); 55 void updateSlider( long, long );
56 void sliderPressed( ); 56 void sliderPressed( );
57 void sliderReleased( ); 57 void sliderReleased( );
58 void setLooping( bool b) { setToggleButton( Loop, b ); } 58 void setLooping( bool b) { setToggleButton( Loop, b ); }
59 void setPosition( long ); 59 void setPosition( long );
60 void setSeekable( bool ); 60 void setSeekable( bool );
61 61
62public: 62public:
63 virtual void setLength( long ); 63 virtual void setLength( long );
64 virtual void setPlaying( bool b) { setToggleButton( Play, b ); } 64 virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
65 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 65 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
66 66
67 virtual void loadSkin(); 67 virtual void loadSkin();
68 68
69signals: 69signals:
70 void sliderMoved(long); 70 void sliderMoved(long);
71 71
72protected: 72protected:
73 void doBlank(); 73 void doBlank();
74 void doUnblank(); 74 void doUnblank();
75 void resizeEvent( QResizeEvent *re ); 75 void resizeEvent( QResizeEvent *re );
76 void timerEvent( QTimerEvent *event ); 76 void timerEvent( QTimerEvent *event );
77 void keyReleaseEvent( QKeyEvent *e); 77 void keyReleaseEvent( QKeyEvent *e);
78private slots: 78private slots:
79 void skipFor(); 79 void skipFor();
80 void skipBack(); 80 void skipBack();
81 void stopSkip(); 81 void stopSkip();
82private: 82private:
83 int skipDirection; 83 int skipDirection;
84 QString skin; 84 QString skin;
85 85
86 OTicker songInfo; 86 Opie::Ui::OTicker songInfo;
87 QSlider slider; 87 QSlider slider;
88 QLineEdit time; 88 QLineEdit time;
89 bool isStreaming : 1; 89 bool isStreaming : 1;
90 bool audioSliderBeingMoved : 1; 90 bool audioSliderBeingMoved : 1;
91}; 91};
92 92
93 93
94#endif // AUDIO_WIDGET_H 94#endif // AUDIO_WIDGET_H
95 95
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 00f72d1..6283ae3 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -1,26 +1,28 @@
1 1
2#include "mediaplayer.h" 2#include "mediaplayer.h"
3 3
4 4
5 5
6#include <opie/oapplicationfactory.h> 6#include <opie2/oapplicationfactory.h>
7 7
8using namespace Opie::Core;
8OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> ) 9OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> )
9 10
10#if 0 11#if 0
12using namespace Opie::Core;
11int main(int argc, char **argv) { 13int main(int argc, char **argv) {
12 QPEApplication a(argc,argv); 14 QPEApplication a(argc,argv);
13 15
14 MediaPlayerState st( 0, "mediaPlayerState" ); 16 MediaPlayerState st( 0, "mediaPlayerState" );
15 PlayListWidget pl( st, 0, "playList" ); 17 PlayListWidget pl( st, 0, "playList" );
16 pl.showMaximized(); 18 pl.showMaximized();
17 MediaPlayer mp( pl, st, 0, "mediaPlayer" ); 19 MediaPlayer mp( pl, st, 0, "mediaPlayer" );
18 QObject::connect( &pl, SIGNAL( skinSelected() ), 20 QObject::connect( &pl, SIGNAL( skinSelected() ),
19 &mp, SLOT( reloadSkins() ) ); 21 &mp, SLOT( reloadSkins() ) );
20 22
21 a.showMainDocumentWidget(&pl); 23 a.showMainDocumentWidget(&pl);
22 24
23 return a.exec(); 25 return a.exec();
24} 26}
25#endif 27#endif
26 28
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 84aba55..1a5e474 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,177 +1,178 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qtoolbar.h> 34#include <qtoolbar.h>
35 35
36#include <opie/ofiledialog.h> 36#include <opie2/ofiledialog.h>
37 37
38#include <qmessagebox.h> 38#include <qmessagebox.h>
39 39
40#include "playlistselection.h" 40#include "playlistselection.h"
41#include "playlistwidget.h" 41#include "playlistwidget.h"
42#include "mediaplayer.h" 42#include "mediaplayer.h"
43#include "inputDialog.h" 43#include "inputDialog.h"
44#include "om3u.h" 44#include "om3u.h"
45#include "playlistfileview.h" 45#include "playlistfileview.h"
46 46
47//only needed for the random play 47//only needed for the random play
48#include <assert.h> 48#include <assert.h>
49 49
50using namespace Opie::Ui;
50PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 51PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
51 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) 52 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
52{ 53{
53 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); 54 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
54 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); 55 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
55 56
56 57
57 58
58 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 59 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
59 "opieplayer2/add_to_playlist", 60 "opieplayer2/add_to_playlist",
60 this , SLOT(addSelected() ) ); 61 this , SLOT(addSelected() ) );
61 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 62 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
62 "opieplayer2/remove_from_playlist", 63 "opieplayer2/remove_from_playlist",
63 this , SLOT(removeSelected() ) ); 64 this , SLOT(removeSelected() ) );
64 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 65 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
65 this , SLOT( btnPlay(bool) ), TRUE ); 66 this , SLOT( btnPlay(bool) ), TRUE );
66 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 67 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
67 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); 68 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
68 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 69 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
69 mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); 70 mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
70 71
71 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 72 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
72 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 73 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
73 this, SLOT( addAllMusicToList() ) ); 74 this, SLOT( addAllMusicToList() ) );
74 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 75 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
75 this, SLOT( addAllVideoToList() ) ); 76 this, SLOT( addAllVideoToList() ) );
76 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 77 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
77 this, SLOT( addAllToList() ) ); 78 this, SLOT( addAllToList() ) );
78 pmPlayList->insertSeparator(-1); 79 pmPlayList->insertSeparator(-1);
79 (void)new MenuItem( pmPlayList, tr( "Add File" ), 80 (void)new MenuItem( pmPlayList, tr( "Add File" ),
80 this,SLOT( openFile() ) ); 81 this,SLOT( openFile() ) );
81 (void)new MenuItem( pmPlayList, tr("Add URL"), 82 (void)new MenuItem( pmPlayList, tr("Add URL"),
82 this,SLOT( openURL() ) ); 83 this,SLOT( openURL() ) );
83 pmPlayList->insertSeparator(-1); 84 pmPlayList->insertSeparator(-1);
84 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 85 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
85 this, SLOT(writem3u() ) ); 86 this, SLOT(writem3u() ) );
86 pmPlayList->insertSeparator(-1); 87 pmPlayList->insertSeparator(-1);
87 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 88 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
88 audioView, SLOT( scanFiles() ) ); 89 audioView, SLOT( scanFiles() ) );
89 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 90 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
90 videoView, SLOT( scanFiles() ) ); 91 videoView, SLOT( scanFiles() ) );
91 92
92 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 93 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
93 mediaPlayerState, SLOT( toggleFullscreen() ) ); 94 mediaPlayerState, SLOT( toggleFullscreen() ) );
94 95
95 Config cfg( "OpiePlayer" ); 96 Config cfg( "OpiePlayer" );
96 bool b= cfg.readBoolEntry("FullScreen", 0); 97 bool b= cfg.readBoolEntry("FullScreen", 0);
97 mediaPlayerState->setFullscreen( b ); 98 mediaPlayerState->setFullscreen( b );
98 pmView->setItemChecked( -16, b ); 99 pmView->setItemChecked( -16, b );
99 100
100 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 101 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
101 d->selectedFiles, SLOT(moveSelectedUp() ) ); 102 d->selectedFiles, SLOT(moveSelectedUp() ) );
102 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 103 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
103 d->selectedFiles, SLOT(removeSelected() ) ); 104 d->selectedFiles, SLOT(removeSelected() ) );
104 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 105 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
105 d->selectedFiles, SLOT(moveSelectedDown() ) ); 106 d->selectedFiles, SLOT(moveSelectedDown() ) );
106 QVBox *stretch2 = new QVBox( vbox1 ); 107 QVBox *stretch2 = new QVBox( vbox1 );
107 108
108 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 109 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
109 SLOT( deletePlaylist() ) ); 110 SLOT( deletePlaylist() ) );
110 connect( pmView, SIGNAL( activated(int) ), 111 connect( pmView, SIGNAL( activated(int) ),
111 this, SLOT( pmViewActivated(int) ) ); 112 this, SLOT( pmViewActivated(int) ) );
112 connect( skinsMenu, SIGNAL( activated(int) ) , 113 connect( skinsMenu, SIGNAL( activated(int) ) ,
113 this, SLOT( skinsMenuActivated(int) ) ); 114 this, SLOT( skinsMenuActivated(int) ) );
114 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 115 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
115 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); 116 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) );
116 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 117 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
117 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 118 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
118 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), 119 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ),
119 this,SLOT( playIt(QListViewItem*) ) ); 120 this,SLOT( playIt(QListViewItem*) ) );
120 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), 121 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ),
121 this, SLOT( addToSelection(QListViewItem*) ) ); 122 this, SLOT( addToSelection(QListViewItem*) ) );
122 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 123 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
123 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
124 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), 125 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ),
125 this,SLOT( playIt(QListViewItem*) ) ); 126 this,SLOT( playIt(QListViewItem*) ) );
126 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), 127 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ),
127 this, SLOT( addToSelection(QListViewItem*) ) ); 128 this, SLOT( addToSelection(QListViewItem*) ) );
128 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), 129 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ),
129 this, SLOT( loadList(const DocLnk&) ) ); 130 this, SLOT( loadList(const DocLnk&) ) );
130 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 131 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
131 this, SLOT( tabChanged(QWidget*) ) ); 132 this, SLOT( tabChanged(QWidget*) ) );
132 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), 133 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ),
133 d->tbPlay, SLOT( setOn(bool) ) ); 134 d->tbPlay, SLOT( setOn(bool) ) );
134 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), 135 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ),
135 d->tbLoop, SLOT( setOn(bool) ) ); 136 d->tbLoop, SLOT( setOn(bool) ) );
136 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), 137 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ),
137 d->tbShuffle, SLOT( setOn(bool) ) ); 138 d->tbShuffle, SLOT( setOn(bool) ) );
138 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), 139 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
139 this, SLOT( playIt(QListViewItem*) ) ); 140 this, SLOT( playIt(QListViewItem*) ) );
140 connect ( gammaSlider, SIGNAL( valueChanged(int) ), 141 connect ( gammaSlider, SIGNAL( valueChanged(int) ),
141 mediaPlayerState, SLOT( setVideoGamma(int) ) ); 142 mediaPlayerState, SLOT( setVideoGamma(int) ) );
142 143
143 connect( this, SIGNAL(skinSelected() ), 144 connect( this, SIGNAL(skinSelected() ),
144 m_mp, SLOT( reloadSkins() ) ); 145 m_mp, SLOT( reloadSkins() ) );
145 146
146 // see which skins are installed 147 // see which skins are installed
147 populateSkinsMenu(); 148 populateSkinsMenu();
148 initializeStates(); 149 initializeStates();
149 150
150 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 151 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
151 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 152 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
152 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 153 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
153 154
154 155
155 cfg.setGroup("PlayList"); 156 cfg.setGroup("PlayList");
156 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 157 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
157 loadList(DocLnk( currentPlaylist ) ); 158 loadList(DocLnk( currentPlaylist ) );
158 159
159 tabWidget->showPage( playListTab ); 160 tabWidget->showPage( playListTab );
160} 161}
161 162
162 163
163PlayListWidget::~PlayListWidget() { 164PlayListWidget::~PlayListWidget() {
164 delete d; 165 delete d;
165 delete m_mp; 166 delete m_mp;
166} 167}
167 168
168 169
169void PlayListWidget::initializeStates() { 170void PlayListWidget::initializeStates() {
170 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 171 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
171 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 172 d->tbLoop->setOn( mediaPlayerState->isLooping() );
172 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 173 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
173 d->playListFrame->show(); 174 d->playListFrame->show();
174} 175}
175 176
176void PlayListWidget::writeDefaultPlaylist() { 177void PlayListWidget::writeDefaultPlaylist() {
177 178
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp
index b61cffb..b7ea071 100644
--- a/noncore/multimedia/showimg/main.cpp
+++ b/noncore/multimedia/showimg/main.cpp
@@ -1,26 +1,28 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "showimg.h" 21#include "showimg.h"
22 22
23 23
24#include <opie2/oapplicationfactory.h> 24#include <opie2/oapplicationfactory.h>
25 25
26using namespace Opie::Core;
27using namespace Opie::Core;
26OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) 28OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> )
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp
index 6c0c4db..696a57b 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -1,172 +1,173 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// 21//
22// Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com> 22// Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com>
23// 23//
24 24
25#include "showimg.h" 25#include "showimg.h"
26#include "ImageFileSelector.h" 26#include "ImageFileSelector.h"
27#include "settingsdialog.h" 27#include "settingsdialog.h"
28 28
29 29
30#include <opie2/ofiledialog.h> 30#include <opie2/ofiledialog.h>
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/config.h> 33#include <qpe/config.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/qpetoolbar.h> 35#include <qtoolbar.h>
36 36
37#include <qaction.h> 37#include <qaction.h>
38#include <qfiledialog.h> 38#include <qfiledialog.h>
39#include <qmenubar.h> 39#include <qmenubar.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41 41
42#include <math.h> 42#include <math.h>
43 43
44 44
45using namespace Opie::Ui;
45ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) 46ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent)
46 : QDialog(parent,0,true) 47 : QDialog(parent,0,true)
47{ 48{
48 setCaption(caption); 49 setCaption(caption);
49 50
50 if ( parent ) { 51 if ( parent ) {
51 setPalette(parent->palette()); 52 setPalette(parent->palette());
52 } 53 }
53 54
54 b=brightness; 55 b=brightness;
55 img=image; 56 img=image;
56 57
57 setMinimumSize(140,80); 58 setMinimumSize(140,80);
58 59
59 QGridLayout *gl= new QGridLayout(this,2,2,4,4); 60 QGridLayout *gl= new QGridLayout(this,2,2,4,4);
60 61
61 pixmap =new ImageWidget(this);; 62 pixmap =new ImageWidget(this);;
62 QPixmap pm; 63 QPixmap pm;
63 pm.convertFromImage(img); 64 pm.convertFromImage(img);
64 pixmap->setPixmap(pm); 65 pixmap->setPixmap(pm);
65 pixmap->setMinimumSize(pm.width(),pm.height()); 66 pixmap->setMinimumSize(pm.width(),pm.height());
66 gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); 67 gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter);
67 QLabel *l=new QLabel(tr("Brightness")+":",this); 68 QLabel *l=new QLabel(tr("Brightness")+":",this);
68 gl->addWidget(l,1,0,AlignLeft); 69 gl->addWidget(l,1,0,AlignLeft);
69 spb=new QSpinBox(-100,100,2,this); 70 spb=new QSpinBox(-100,100,2,this);
70 gl->addWidget(spb,1,1,AlignRight); 71 gl->addWidget(spb,1,1,AlignRight);
71 72
72 spb->setValue(0); 73 spb->setValue(0);
73 74
74 connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); 75 connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int)));
75 76
76} 77}
77 78
78void ControlsDialog::bValueChanged(int value) 79void ControlsDialog::bValueChanged(int value)
79{ 80{
80 QImage nImage=img; 81 QImage nImage=img;
81 nImage.detach(); 82 nImage.detach();
82 ImageViewer::intensity(nImage, (float)value/100); 83 ImageViewer::intensity(nImage, (float)value/100);
83 QPixmap pm; 84 QPixmap pm;
84 pm.convertFromImage(nImage); 85 pm.convertFromImage(nImage);
85 pixmap->setPixmap(pm); 86 pixmap->setPixmap(pm);
86 pixmap->repaint(false); 87 pixmap->repaint(false);
87 88
88 89
89} 90}
90 91
91void ControlsDialog::accept() 92void ControlsDialog::accept()
92{ 93{
93 *b=spb->value(); 94 *b=spb->value();
94 done(1); 95 done(1);
95} 96}
96 97
97//=========================================================================== 98//===========================================================================
98 99
99InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) 100InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent)
100 : QDialog(parent,0,true) 101 : QDialog(parent,0,true)
101{ 102{
102 setCaption(caption); 103 setCaption(caption);
103 104
104 if ( parent ) 105 if ( parent )
105 { 106 {
106 setPalette(parent->palette()); 107 setPalette(parent->palette());
107 } 108 }
108 109
109 110
110 111
111 QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; 112 QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") };
112 113
113 setMinimumSize(180,80); 114 setMinimumSize(180,80);
114 int num=ImageViewer::LAST+1; 115 int num=ImageViewer::LAST+1;
115 if ( text[ImageViewer::ALPHA].isEmpty() ) 116 if ( text[ImageViewer::ALPHA].isEmpty() )
116 num--; 117 num--;
117 QGridLayout *gl= new QGridLayout(this,num,2,4,2); 118 QGridLayout *gl= new QGridLayout(this,num,2,4,2);
118 QLabel *l; 119 QLabel *l;
119 int count=0; 120 int count=0;
120 for ( int i=0;i<num;i++ ) 121 for ( int i=0;i<num;i++ )
121 { 122 {
122 if ( i==1 ) 123 if ( i==1 )
123 { 124 {
124 QFrame *frm=new QFrame(this); 125 QFrame *frm=new QFrame(this);
125 frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); 126 frm->setFrameStyle(QFrame::HLine|QFrame::Sunken);
126 gl->addMultiCellWidget(frm,i,i,0,1); 127 gl->addMultiCellWidget(frm,i,i,0,1);
127 } 128 }
128 else 129 else
129 { 130 {
130 l=new QLabel( tr( labels[count] )+":",this); 131 l=new QLabel( tr( labels[count] )+":",this);
131 gl->addWidget(l,i,0,AlignLeft); 132 gl->addWidget(l,i,0,AlignLeft);
132 l=new QLabel(text[count],this); 133 l=new QLabel(text[count],this);
133 gl->addWidget(l,i,1,AlignRight); 134 gl->addWidget(l,i,1,AlignRight);
134 count++; 135 count++;
135 } 136 }
136 137
137 } 138 }
138 139
139} 140}
140 141
141void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) 142void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent)
142{ 143{
143 InfoDialog *dlg=new InfoDialog(caption,text,parent); 144 InfoDialog *dlg=new InfoDialog(caption,text,parent);
144 dlg->exec(); 145 dlg->exec();
145 delete dlg; 146 delete dlg;
146} 147}
147 148
148//=========================================================================== 149//===========================================================================
149 150
150 151
151ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) 152ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
152{ 153{
153 vb = new QVBoxLayout( this ); 154 vb = new QVBoxLayout( this );
154 155
155 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); 156 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity);
156 pic=new ImageWidget(image); 157 pic=new ImageWidget(image);
157 image->addChild(pic); 158 image->addChild(pic);
158 159
159 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); 160 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() ));
160 161
161 vb->addWidget( image ); 162 vb->addWidget( image );
162 163
163} 164}
164 165
165void ImagePane::setPixmap( const QPixmap &pm ) 166void ImagePane::setPixmap( const QPixmap &pm )
166{ 167{
167 pic->setPixmap( pm ); 168 pic->setPixmap( pm );
168 pic->resize(pm.width(),pm.height()); 169 pic->resize(pm.width(),pm.height());
169 image->updateScrollBars (); 170 image->updateScrollBars ();
170 pic->repaint(false); 171 pic->repaint(false);
171} 172}
172 173
@@ -398,257 +399,257 @@ ImageViewer::~ImageViewer()
398} 399}
399 400
400void ImageViewer::help() { 401void ImageViewer::help() {
401 402
402} 403}
403 404
404 405
405void ImageViewer::settings() 406void ImageViewer::settings()
406{ 407{
407 SettingsDialog dlg( this, 0, TRUE ); 408 SettingsDialog dlg( this, 0, TRUE );
408 dlg.setDelay( slideDelay ); 409 dlg.setDelay( slideDelay );
409 dlg.setRepeat( slideRepeat ); 410 dlg.setRepeat( slideRepeat );
410 dlg.setReverse( slideReverse ); 411 dlg.setReverse( slideReverse );
411 dlg.setRotate(rotateOnLoad); 412 dlg.setRotate(rotateOnLoad);
412 dlg.setFastLoad(fastLoad); 413 dlg.setFastLoad(fastLoad);
413 414
414 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { 415 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) {
415 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); 416 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>");
416 slideDelay = dlg.delay(); 417 slideDelay = dlg.delay();
417 slideRepeat = dlg.repeat(); 418 slideRepeat = dlg.repeat();
418 slideReverse = dlg.reverse(); 419 slideReverse = dlg.reverse();
419 rotateOnLoad = dlg.rotate(); 420 rotateOnLoad = dlg.rotate();
420 fastLoad = dlg.fastLoad(); 421 fastLoad = dlg.fastLoad();
421 422
422 Config config( "ImageViewer" ); 423 Config config( "ImageViewer" );
423 config.setGroup( "SlideShow" ); 424 config.setGroup( "SlideShow" );
424 config.writeEntry( "Delay", slideDelay ); 425 config.writeEntry( "Delay", slideDelay );
425 config.writeEntry( "Repeat", slideRepeat ); 426 config.writeEntry( "Repeat", slideRepeat );
426 config.writeEntry("Reverse", slideReverse); 427 config.writeEntry("Reverse", slideReverse);
427 428
428 config.setGroup("Default"); 429 config.setGroup("Default");
429 config.writeEntry("Rotate", rotateOnLoad); 430 config.writeEntry("Rotate", rotateOnLoad);
430 config.writeEntry("FastLoad", fastLoad); 431 config.writeEntry("FastLoad", fastLoad);
431 } 432 }
432} 433}
433 434
434void ImageViewer::switchSizeToScreen() 435void ImageViewer::switchSizeToScreen()
435{ 436{
436 isSized=!isSized; 437 isSized=!isSized;
437 sss->setOn(isSized); 438 sss->setOn(isSized);
438 updateImage(); 439 updateImage();
439} 440}
440 441
441void ImageViewer::updateImage() 442void ImageViewer::updateImage()
442{ 443{
443 if ( isSized ) { 444 if ( isSized ) {
444 imagePanel->setPixmap(pmScaled); 445 imagePanel->setPixmap(pmScaled);
445 } else { 446 } else {
446 imagePanel->setPixmap(pm); 447 imagePanel->setPixmap(pm);
447 } 448 }
448} 449}
449 450
450void ImageViewer::switchThumbView() 451void ImageViewer::switchThumbView()
451{ 452{
452 453
453 showThumbView=!showThumbView; 454 showThumbView=!showThumbView;
454 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 455 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
455 fileSelector->switchView(); 456 fileSelector->switchView();
456 457
457} 458}
458 459
459void ImageViewer::switchToFileSelector() 460void ImageViewer::switchToFileSelector()
460{ 461{
461 stack->raiseWidget(fileSelector); 462 stack->raiseWidget(fileSelector);
462 menuBar->clear(); 463 menuBar->clear();
463 menuBar->insertItem( tr("File"), fileMenuFile ); 464 menuBar->insertItem( tr("File"), fileMenuFile );
464 menuBar->insertItem( tr("View"), viewMenuFile ); 465 menuBar->insertItem( tr("View"), viewMenuFile );
465 menuBar->insertItem( tr("Options"), optionsMenuFile ); 466 menuBar->insertItem( tr("Options"), optionsMenuFile );
466 iconToolBar->hide(); 467 iconToolBar->hide();
467 imagePanel->disable(); 468 imagePanel->disable();
468 slideShow(false); 469 slideShow(false);
469 470
470} 471}
471 472
472void ImageViewer::switchToImageView() 473void ImageViewer::switchToImageView()
473{ 474{
474 stack->raiseWidget(imagePanel); 475 stack->raiseWidget(imagePanel);
475 476
476 menuBar->clear(); 477 menuBar->clear();
477 menuBar->insertItem( tr("File"), fileMenuView ); 478 menuBar->insertItem( tr("File"), fileMenuView );
478 menuBar->insertItem( tr("View"), viewMenuView ); 479 menuBar->insertItem( tr("View"), viewMenuView );
479 viewMenuView->setItemEnabled(BLACKANDWHITE,true); 480 viewMenuView->setItemEnabled(BLACKANDWHITE,true);
480 iconToolBar->show(); 481 iconToolBar->show();
481 482
482 imagePanel->setPosition(0,0); 483 imagePanel->setPosition(0,0);
483 484
484} 485}
485 486
486 487
487void ImageViewer::setDocument(const QString& fileref) 488void ImageViewer::setDocument(const QString& fileref)
488{ 489{
489 delayLoad = fileref; 490 delayLoad = fileref;
490 switchToImageView(); 491 switchToImageView();
491 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); 492 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) );
492} 493}
493 494
494void ImageViewer::doDelayedLoad() 495void ImageViewer::doDelayedLoad()
495{ 496{
496 show(delayLoad); 497 show(delayLoad);
497} 498}
498 499
499void ImageViewer::show() 500void ImageViewer::show()
500{ 501{
501 normalView(); 502 normalView();
502 QMainWindow::show(); 503 QMainWindow::show();
503} 504}
504 505
505void ImageViewer::show(const QString& fileref) 506void ImageViewer::show(const QString& fileref)
506{ 507{
507// qDebug("Show "+fileref); 508// qDebug("Show "+fileref);
508 bFromDocView = TRUE; 509 bFromDocView = TRUE;
509 closeFileSelector(); 510 closeFileSelector();
510 DocLnk link(fileref); 511 DocLnk link(fileref);
511 if ( link.isValid() ) { 512 if ( link.isValid() ) {
512 openFile(link); 513 openFile(link);
513 } else { 514 } else {
514 filename = fileref; 515 filename = fileref;
515 updateCaption( fileref ); 516 updateCaption( fileref );
516 loadImage( fileref ); 517 loadImage( fileref );
517 } 518 }
518} 519}
519 520
520void ImageViewer::openFile() { 521void ImageViewer::openFile() {
521 MimeTypes types; 522 MimeTypes types;
522 QStringList image; 523 QStringList image;
523 image << "image/*"; 524 image << "image/*";
524 types.insert("Images", image); 525 types.insert("Images", image);
525 526
526 QString str = Opie::OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); 527 QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 );
527 DocLnk link(str); 528 DocLnk link(str);
528// if ( link.isValid() ) 529// if ( link.isValid() )
529 openFile(link); 530 openFile(link);
530 531
531} 532}
532 533
533void ImageViewer::openFile( const DocLnk &link ) 534void ImageViewer::openFile( const DocLnk &link )
534{ 535{
535 closeFileSelector(); 536 closeFileSelector();
536// DocLnk link(file); 537// DocLnk link(file);
537 qDebug("open "+link.name()); 538 qDebug("open "+link.name());
538 updateCaption( link.name() ); 539 updateCaption( link.name() );
539 loadImage( link.file() ); 540 loadImage( link.file() );
540 if (slideTimer->isActive()) { 541 if (slideTimer->isActive()) {
541 slideTimer->start(slideDelay * 1000, FALSE); 542 slideTimer->start(slideDelay * 1000, FALSE);
542 } 543 }
543 544
544} 545}
545 546
546void ImageViewer::open() 547void ImageViewer::open()
547{ 548{
548 switchToFileSelector(); 549 switchToFileSelector();
549} 550}
550 551
551void ImageViewer::closeFileSelector() 552void ImageViewer::closeFileSelector()
552{ 553{
553 switchToImageView(); 554 switchToImageView();
554} 555}
555 556
556void ImageViewer::updateCaption( QString name ) 557void ImageViewer::updateCaption( QString name )
557{ 558{
558 int sep = name.findRev( '/' ); 559 int sep = name.findRev( '/' );
559 if ( sep >= 0 ) 560 if ( sep >= 0 )
560 name = name.mid( sep+1 ); 561 name = name.mid( sep+1 );
561 setCaption( name + tr(" - Image Viewer") ); 562 setCaption( name + tr(" - Image Viewer") );
562} 563}
563 564
564/* 565/*
565 This function loads an image from a file. 566 This function loads an image from a file.
566*/ 567*/
567 568
568void ImageViewer::loadImage( const char *fileName ) 569void ImageViewer::loadImage( const char *fileName )
569{ 570{
570 filename = fileName; 571 filename = fileName;
571 if ( filename ) { 572 if ( filename ) {
572 QApplication::setOverrideCursor( waitCursor ); // this might take time 573 QApplication::setOverrideCursor( waitCursor ); // this might take time
573 //imagePanel->statusLabel()->setText( tr("Loading image...") ); 574 //imagePanel->statusLabel()->setText( tr("Loading image...") );
574 qApp->processEvents(); 575 qApp->processEvents();
575 bool ok = image.load(filename, 0); 576 bool ok = image.load(filename, 0);
576 if ( ok ) { 577 if ( ok ) {
577 ok = reconvertImage(); 578 ok = reconvertImage();
578 updateImageInfo(filename); 579 updateImageInfo(filename);
579 } 580 }
580 if ( !ok ) { 581 if ( !ok ) {
581 pm.resize(0,0); // couldn't load image 582 pm.resize(0,0); // couldn't load image
582 update(); 583 update();
583 } 584 }
584 QApplication::restoreOverrideCursor(); // restore original cursor 585 QApplication::restoreOverrideCursor(); // restore original cursor
585 } 586 }
586 587
587// fastLoad ? ", Fast" : "", 588// fastLoad ? ", Fast" : "",
588// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); 589// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1);
589 590
590 591
591// matrix.reset(); 592// matrix.reset();
592 rotated90 = FALSE; 593 rotated90 = FALSE;
593 594
594 if (rotateOnLoad) { 595 if (rotateOnLoad) {
595 rotated90 = TRUE; 596 rotated90 = TRUE;
596 rot90(); 597 rot90();
597// matrix.rotate( -90.0 ); 598// matrix.rotate( -90.0 );
598 } 599 }
599 600
600 switchToImageView(); 601 switchToImageView();
601 updateImage(); 602 updateImage();
602 603
603} 604}
604 605
605bool ImageViewer::loadSelected() 606bool ImageViewer::loadSelected()
606{ 607{
607 bool ok = false; 608 bool ok = false;
608 if ( stack->visibleWidget() == fileSelector ) 609 if ( stack->visibleWidget() == fileSelector )
609 { 610 {
610 const DocLnk *link = fileSelector->selected(); 611 const DocLnk *link = fileSelector->selected();
611 if ( link ) 612 if ( link )
612 { 613 {
613 if ( link->file() != filename ) 614 if ( link->file() != filename )
614 { 615 {
615 updateCaption( link->name() ); 616 updateCaption( link->name() );
616 filename = link->file(); 617 filename = link->file();
617 qApp->processEvents(); 618 qApp->processEvents();
618 ok = image.load(filename, 0); 619 ok = image.load(filename, 0);
619 if ( ok ) 620 if ( ok )
620 { 621 {
621 updateImageInfo(filename); 622 updateImageInfo(filename);
622 ok = reconvertImage(); 623 ok = reconvertImage();
623 } 624 }
624 if ( !ok ) 625 if ( !ok )
625 pm.resize(0,0); 626 pm.resize(0,0);
626 } 627 }
627 } 628 }
628 } 629 }
629 if ( !image.isNull() ) 630 if ( !image.isNull() )
630 { 631 {
631 ok = true; 632 ok = true;
632 closeFileSelector(); 633 closeFileSelector();
633 } 634 }
634 635
635 return ok; 636 return ok;
636} 637}
637 638
638bool ImageViewer::reconvertImage() 639bool ImageViewer::reconvertImage()
639{ 640{
640 bool success = FALSE; 641 bool success = FALSE;
641 642
642 if ( image.isNull() ) return FALSE; 643 if ( image.isNull() ) return FALSE;
643 644
644 QApplication::setOverrideCursor( waitCursor ); // this might take time 645 QApplication::setOverrideCursor( waitCursor ); // this might take time
645 if ( pm.convertFromImage(image /*, conversion_flags */ ) ) 646 if ( pm.convertFromImage(image /*, conversion_flags */ ) )
646 { 647 {
647 pmScaled = QPixmap(); 648 pmScaled = QPixmap();
648 scale(); 649 scale();
649 success = TRUE; // load successful 650 success = TRUE; // load successful
650 } 651 }
651 else 652 else
652 { 653 {
653 pm.resize(0,0); // couldn't load image 654 pm.resize(0,0); // couldn't load image
654 } 655 }