34 files changed, 1 insertions, 110 deletions
diff --git a/noncore/multimedia/camera/gui/mainwindow.h b/noncore/multimedia/camera/gui/mainwindow.h index 451ad5f..d93cca1 100644 --- a/noncore/multimedia/camera/gui/mainwindow.h +++ b/noncore/multimedia/camera/gui/mainwindow.h | |||
@@ -1,107 +1,105 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie 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 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef MAINWINDOW_H | 16 | #ifndef MAINWINDOW_H |
17 | #define MAINWINDOW_H | 17 | #define MAINWINDOW_H |
18 | 18 | ||
19 | #include <qmainwindow.h> | 19 | #include <qmainwindow.h> |
20 | #include <qdatetime.h> | ||
21 | #include <qimage.h> | 20 | #include <qimage.h> |
22 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
23 | #include <qdatetime.h> | ||
24 | 22 | ||
25 | class QAction; | 23 | class QAction; |
26 | class QActionGroup; | 24 | class QActionGroup; |
27 | class QIconSet; | 25 | class QIconSet; |
28 | class QTimerEvent; | 26 | class QTimerEvent; |
29 | class QToolButton; | 27 | class QToolButton; |
30 | class QLabel; | 28 | class QLabel; |
31 | class MainWindowBase; | 29 | class MainWindowBase; |
32 | class QCopChannel; | 30 | class QCopChannel; |
33 | class PreviewWidget; | 31 | class PreviewWidget; |
34 | 32 | ||
35 | class CameraMainWindow: public QMainWindow | 33 | class CameraMainWindow: public QMainWindow |
36 | { | 34 | { |
37 | Q_OBJECT | 35 | Q_OBJECT |
38 | 36 | ||
39 | public: | 37 | public: |
40 | CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); | 38 | CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); |
41 | virtual ~CameraMainWindow(); | 39 | virtual ~CameraMainWindow(); |
42 | 40 | ||
43 | public slots: | 41 | public slots: |
44 | void changeZoom( int ); | 42 | void changeZoom( int ); |
45 | void systemMessage( const QCString&, const QByteArray& ); | 43 | void systemMessage( const QCString&, const QByteArray& ); |
46 | void showContextMenu(); | 44 | void showContextMenu(); |
47 | void resoMenuItemClicked( QAction* ); | 45 | void resoMenuItemClicked( QAction* ); |
48 | void qualityMenuItemClicked( QAction* ); | 46 | void qualityMenuItemClicked( QAction* ); |
49 | void zoomMenuItemClicked( QAction* ); | 47 | void zoomMenuItemClicked( QAction* ); |
50 | void flipMenuItemClicked( QAction* ); | 48 | void flipMenuItemClicked( QAction* ); |
51 | void outputToMenuItemClicked( QAction* ); | 49 | void outputToMenuItemClicked( QAction* ); |
52 | void outputMenuItemClicked( QAction* ); | 50 | void outputMenuItemClicked( QAction* ); |
53 | void prefixItemChoosen(); | 51 | void prefixItemChoosen(); |
54 | void appendSettingsChoosen(); | 52 | void appendSettingsChoosen(); |
55 | void shutterClicked(); | 53 | void shutterClicked(); |
56 | 54 | ||
57 | void updateCaption(); | 55 | void updateCaption(); |
58 | 56 | ||
59 | protected: | 57 | protected: |
60 | void init(); | 58 | void init(); |
61 | void startVideoCapture(); | 59 | void startVideoCapture(); |
62 | void stopVideoCapture(); | 60 | void stopVideoCapture(); |
63 | void postProcessVideo( const QString&, const QString& ); | 61 | void postProcessVideo( const QString&, const QString& ); |
64 | void performCapture( const QString& ); | 62 | void performCapture( const QString& ); |
65 | 63 | ||
66 | virtual void timerEvent( QTimerEvent* ); | 64 | virtual void timerEvent( QTimerEvent* ); |
67 | 65 | ||
68 | protected slots: | 66 | protected slots: |
69 | void doSomething(); // solely for debugging purposes | 67 | void doSomething(); // solely for debugging purposes |
70 | 68 | ||
71 | private: | 69 | private: |
72 | PreviewWidget* preview; | 70 | PreviewWidget* preview; |
73 | int _rotation; | 71 | int _rotation; |
74 | QCopChannel* _sysChannel; | 72 | QCopChannel* _sysChannel; |
75 | 73 | ||
76 | QActionGroup* resog; | 74 | QActionGroup* resog; |
77 | QActionGroup* qualityg; | 75 | QActionGroup* qualityg; |
78 | QActionGroup* zoomg; | 76 | QActionGroup* zoomg; |
79 | QActionGroup* flipg; | 77 | QActionGroup* flipg; |
80 | QActionGroup* outputTog; | 78 | QActionGroup* outputTog; |
81 | QAction* custom; | 79 | QAction* custom; |
82 | QAction* docfolder; | 80 | QAction* docfolder; |
83 | QActionGroup* outputg; | 81 | QActionGroup* outputg; |
84 | 82 | ||
85 | QString flip; | 83 | QString flip; |
86 | int quality; | 84 | int quality; |
87 | int zoom; | 85 | int zoom; |
88 | int captureX; | 86 | int captureX; |
89 | int captureY; | 87 | int captureY; |
90 | QString captureFormat; | 88 | QString captureFormat; |
91 | 89 | ||
92 | QString outputTo; | 90 | QString outputTo; |
93 | QString prefix; | 91 | QString prefix; |
94 | bool appendSettings; | 92 | bool appendSettings; |
95 | 93 | ||
96 | bool _capturing; | 94 | bool _capturing; |
97 | int _pics; | 95 | int _pics; |
98 | int _videos; | 96 | int _videos; |
99 | 97 | ||
100 | QTime _time; | 98 | QTime _time; |
101 | int _videopics; | 99 | int _videopics; |
102 | int _capturefd; | 100 | int _capturefd; |
103 | int _framerate; | 101 | int _framerate; |
104 | unsigned char* _capturebuf; | 102 | unsigned char* _capturebuf; |
105 | }; | 103 | }; |
106 | 104 | ||
107 | #endif | 105 | #endif |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index f3eafab..452117c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,326 +1,324 @@ | |||
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 | #include "mediaplayerstate.h" | ||
37 | #include "playlistwidget.h" | ||
38 | 36 | ||
39 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
40 | 38 | ||
41 | namespace | 39 | namespace |
42 | { | 40 | { |
43 | 41 | ||
44 | const int xo = -2; // movable x offset | 42 | const int xo = -2; // movable x offset |
45 | const int yo = 22; // movable y offset | 43 | const int yo = 22; // movable y offset |
46 | 44 | ||
47 | const MediaWidget::SkinButtonInfo skinInfo[] = | 45 | const MediaWidget::SkinButtonInfo skinInfo[] = |
48 | { | 46 | { |
49 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 47 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
50 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 48 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
51 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | 49 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, |
52 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | 50 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, |
53 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 51 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
54 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 52 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
55 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 53 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
56 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 54 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
57 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 55 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
58 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 56 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
59 | }; | 57 | }; |
60 | 58 | ||
61 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 59 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
62 | 60 | ||
63 | void changeTextColor( QWidget * w) { | 61 | void changeTextColor( QWidget * w) { |
64 | QPalette p = w->palette(); | 62 | QPalette p = w->palette(); |
65 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 63 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
66 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 64 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
67 | w->setPalette( p ); | 65 | w->setPalette( p ); |
68 | } | 66 | } |
69 | 67 | ||
70 | } | 68 | } |
71 | 69 | ||
72 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 70 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
73 | 71 | ||
74 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 72 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
75 | audioSliderBeingMoved( false ) | 73 | audioSliderBeingMoved( false ) |
76 | { | 74 | { |
77 | setCaption( tr("OpiePlayer") ); | 75 | setCaption( tr("OpiePlayer") ); |
78 | 76 | ||
79 | loadSkin(); | 77 | loadSkin(); |
80 | 78 | ||
81 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 79 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
82 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); | 80 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); |
83 | 81 | ||
84 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 82 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
85 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 83 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
86 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 84 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
87 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 85 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
88 | 86 | ||
89 | // Intialise state | 87 | // Intialise state |
90 | setLength( mediaPlayerState.length() ); | 88 | setLength( mediaPlayerState.length() ); |
91 | setPosition( mediaPlayerState.position() ); | 89 | setPosition( mediaPlayerState.position() ); |
92 | setLooping( mediaPlayerState.isFullscreen() ); | 90 | setLooping( mediaPlayerState.isFullscreen() ); |
93 | // setPaused( mediaPlayerState->paused() ); | 91 | // setPaused( mediaPlayerState->paused() ); |
94 | setPlaying( mediaPlayerState.isPlaying() ); | 92 | setPlaying( mediaPlayerState.isPlaying() ); |
95 | } | 93 | } |
96 | 94 | ||
97 | AudioWidget::~AudioWidget() { | 95 | AudioWidget::~AudioWidget() { |
98 | 96 | ||
99 | // mediaPlayerState->setPlaying(false); | 97 | // mediaPlayerState->setPlaying(false); |
100 | } | 98 | } |
101 | 99 | ||
102 | MediaWidget::GUIInfo AudioWidget::guiInfo() | 100 | MediaWidget::GUIInfo AudioWidget::guiInfo() |
103 | { | 101 | { |
104 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); | 102 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); |
105 | } | 103 | } |
106 | 104 | ||
107 | void AudioWidget::resizeEvent( QResizeEvent *e ) { | 105 | void AudioWidget::resizeEvent( QResizeEvent *e ) { |
108 | int h = height(); | 106 | int h = height(); |
109 | int w = width(); | 107 | int w = width(); |
110 | 108 | ||
111 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 109 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
112 | slider.setFixedWidth( w - 110 ); | 110 | slider.setFixedWidth( w - 110 ); |
113 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 111 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
114 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 112 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
115 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 113 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
116 | 114 | ||
117 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; | 115 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; |
118 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; | 116 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; |
119 | 117 | ||
120 | MediaWidget::resizeEvent( e ); | 118 | MediaWidget::resizeEvent( e ); |
121 | } | 119 | } |
122 | 120 | ||
123 | void AudioWidget::sliderPressed() { | 121 | void AudioWidget::sliderPressed() { |
124 | audioSliderBeingMoved = TRUE; | 122 | audioSliderBeingMoved = TRUE; |
125 | } | 123 | } |
126 | 124 | ||
127 | 125 | ||
128 | void AudioWidget::sliderReleased() { | 126 | void AudioWidget::sliderReleased() { |
129 | audioSliderBeingMoved = FALSE; | 127 | audioSliderBeingMoved = FALSE; |
130 | if ( slider.width() == 0 ) | 128 | if ( slider.width() == 0 ) |
131 | return; | 129 | return; |
132 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 130 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
133 | mediaPlayerState.setPosition( val ); | 131 | mediaPlayerState.setPosition( val ); |
134 | } | 132 | } |
135 | 133 | ||
136 | void AudioWidget::setPosition( long i ) { | 134 | void AudioWidget::setPosition( long i ) { |
137 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 135 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
138 | updateSlider( i, mediaPlayerState.length() ); | 136 | updateSlider( i, mediaPlayerState.length() ); |
139 | } | 137 | } |
140 | 138 | ||
141 | 139 | ||
142 | void AudioWidget::setLength( long max ) { | 140 | void AudioWidget::setLength( long max ) { |
143 | updateSlider( mediaPlayerState.position(), max ); | 141 | updateSlider( mediaPlayerState.position(), max ); |
144 | } | 142 | } |
145 | 143 | ||
146 | 144 | ||
147 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 145 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
148 | if ( mediaType == MediaPlayerState::Audio ) { | 146 | if ( mediaType == MediaPlayerState::Audio ) { |
149 | // startTimer( 150 ); | 147 | // startTimer( 150 ); |
150 | QPEApplication::showWidget( this ); | 148 | QPEApplication::showWidget( this ); |
151 | return; | 149 | return; |
152 | } | 150 | } |
153 | 151 | ||
154 | killTimers(); | 152 | killTimers(); |
155 | hide(); | 153 | hide(); |
156 | } | 154 | } |
157 | 155 | ||
158 | void AudioWidget::loadSkin() | 156 | void AudioWidget::loadSkin() |
159 | { | 157 | { |
160 | loadDefaultSkin( guiInfo() ); | 158 | loadDefaultSkin( guiInfo() ); |
161 | 159 | ||
162 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 160 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
163 | // changeTextColor( &songInfo ); | 161 | // changeTextColor( &songInfo ); |
164 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 162 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
165 | // songInfo.setFrameStyle( QFrame::NoFrame); | 163 | // songInfo.setFrameStyle( QFrame::NoFrame); |
166 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 164 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
167 | // songInfo.setForegroundColor(Qt::white); | 165 | // songInfo.setForegroundColor(Qt::white); |
168 | 166 | ||
169 | slider.setFixedHeight( 20 ); | 167 | slider.setFixedHeight( 20 ); |
170 | slider.setMinValue( 0 ); | 168 | slider.setMinValue( 0 ); |
171 | slider.setMaxValue( 1 ); | 169 | slider.setMaxValue( 1 ); |
172 | slider.setFocusPolicy( QWidget::NoFocus ); | 170 | slider.setFocusPolicy( QWidget::NoFocus ); |
173 | slider.setBackgroundPixmap( backgroundPixmap ); | 171 | slider.setBackgroundPixmap( backgroundPixmap ); |
174 | 172 | ||
175 | // Config cofg("qpe"); | 173 | // Config cofg("qpe"); |
176 | // cofg.setGroup("Appearance"); | 174 | // cofg.setGroup("Appearance"); |
177 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 175 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
178 | 176 | ||
179 | time.setFocusPolicy( QWidget::NoFocus ); | 177 | time.setFocusPolicy( QWidget::NoFocus ); |
180 | time.setAlignment( Qt::AlignCenter ); | 178 | time.setAlignment( Qt::AlignCenter ); |
181 | 179 | ||
182 | // time.setFrame(FALSE); | 180 | // time.setFrame(FALSE); |
183 | // changeTextColor( &time ); | 181 | // changeTextColor( &time ); |
184 | 182 | ||
185 | resizeEvent( 0 ); | 183 | resizeEvent( 0 ); |
186 | } | 184 | } |
187 | 185 | ||
188 | void AudioWidget::setSeekable( bool isSeekable ) { | 186 | void AudioWidget::setSeekable( bool isSeekable ) { |
189 | 187 | ||
190 | if ( !isSeekable ) { | 188 | if ( !isSeekable ) { |
191 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 189 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
192 | if( !slider.isHidden()) { | 190 | if( !slider.isHidden()) { |
193 | slider.hide(); | 191 | slider.hide(); |
194 | } | 192 | } |
195 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 193 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
196 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 194 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
197 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 195 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
198 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 196 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
199 | } else { | 197 | } else { |
200 | // this stops the slider from being moved, thus | 198 | // this stops the slider from being moved, thus |
201 | // does not stop stream when it reaches the end | 199 | // does not stop stream when it reaches the end |
202 | slider.show(); | 200 | slider.show(); |
203 | qDebug( " CONNECT SET POSTION " ); | 201 | qDebug( " CONNECT SET POSTION " ); |
204 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 202 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
205 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 203 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
206 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 204 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
207 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 205 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
208 | } | 206 | } |
209 | } | 207 | } |
210 | 208 | ||
211 | 209 | ||
212 | static QString timeAsString( long length ) { | 210 | static QString timeAsString( long length ) { |
213 | int minutes = length / 60; | 211 | int minutes = length / 60; |
214 | int seconds = length % 60; | 212 | int seconds = length % 60; |
215 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 213 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
216 | } | 214 | } |
217 | 215 | ||
218 | void AudioWidget::updateSlider( long i, long max ) { | 216 | void AudioWidget::updateSlider( long i, long max ) { |
219 | 217 | ||
220 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 218 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
221 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 219 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
222 | 220 | ||
223 | if ( max == 0 ) { | 221 | if ( max == 0 ) { |
224 | return; | 222 | return; |
225 | } | 223 | } |
226 | // Will flicker too much if we don't do this | 224 | // Will flicker too much if we don't do this |
227 | // Scale to something reasonable | 225 | // Scale to something reasonable |
228 | int width = slider.width(); | 226 | int width = slider.width(); |
229 | int val = int((double)i * width / max); | 227 | int val = int((double)i * width / max); |
230 | if ( !audioSliderBeingMoved ) { | 228 | if ( !audioSliderBeingMoved ) { |
231 | if ( slider.value() != val ) { | 229 | if ( slider.value() != val ) { |
232 | slider.setValue( val ); | 230 | slider.setValue( val ); |
233 | } | 231 | } |
234 | 232 | ||
235 | if ( slider.maxValue() != width ) { | 233 | if ( slider.maxValue() != width ) { |
236 | slider.setMaxValue( width ); | 234 | slider.setMaxValue( width ); |
237 | } | 235 | } |
238 | } | 236 | } |
239 | } | 237 | } |
240 | 238 | ||
241 | void AudioWidget::skipFor() { | 239 | void AudioWidget::skipFor() { |
242 | skipDirection = +1; | 240 | skipDirection = +1; |
243 | startTimer( 50 ); | 241 | startTimer( 50 ); |
244 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 242 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
245 | } | 243 | } |
246 | 244 | ||
247 | void AudioWidget::skipBack() { | 245 | void AudioWidget::skipBack() { |
248 | skipDirection = -1; | 246 | skipDirection = -1; |
249 | startTimer( 50 ); | 247 | startTimer( 50 ); |
250 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 248 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
251 | } | 249 | } |
252 | 250 | ||
253 | 251 | ||
254 | 252 | ||
255 | void AudioWidget::stopSkip() { | 253 | void AudioWidget::stopSkip() { |
256 | killTimers(); | 254 | killTimers(); |
257 | } | 255 | } |
258 | 256 | ||
259 | 257 | ||
260 | void AudioWidget::timerEvent( QTimerEvent * ) { | 258 | void AudioWidget::timerEvent( QTimerEvent * ) { |
261 | if ( skipDirection == +1 ) { | 259 | if ( skipDirection == +1 ) { |
262 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 260 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
263 | } else if ( skipDirection == -1 ) { | 261 | } else if ( skipDirection == -1 ) { |
264 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 262 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
265 | } | 263 | } |
266 | } | 264 | } |
267 | 265 | ||
268 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 266 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
269 | switch ( e->key() ) { | 267 | switch ( e->key() ) { |
270 | ////////////////////////////// Zaurus keys | 268 | ////////////////////////////// Zaurus keys |
271 | case Key_Home: | 269 | case Key_Home: |
272 | break; | 270 | break; |
273 | case Key_F9: //activity | 271 | case Key_F9: //activity |
274 | hide(); | 272 | hide(); |
275 | // qDebug("Audio F9"); | 273 | // qDebug("Audio F9"); |
276 | e->accept(); | 274 | e->accept(); |
277 | break; | 275 | break; |
278 | case Key_F10: //contacts | 276 | case Key_F10: //contacts |
279 | break; | 277 | break; |
280 | case Key_F11: //menu | 278 | case Key_F11: //menu |
281 | mediaPlayerState.toggleBlank(); | 279 | mediaPlayerState.toggleBlank(); |
282 | e->accept(); | 280 | e->accept(); |
283 | break; | 281 | break; |
284 | case Key_F12: //home | 282 | case Key_F12: //home |
285 | break; | 283 | break; |
286 | case Key_F13: //mail | 284 | case Key_F13: //mail |
287 | mediaPlayerState.toggleBlank(); | 285 | mediaPlayerState.toggleBlank(); |
288 | e->accept(); | 286 | e->accept(); |
289 | break; | 287 | break; |
290 | case Key_Space: { | 288 | case Key_Space: { |
291 | e->accept(); | 289 | e->accept(); |
292 | mediaPlayerState.togglePaused(); | 290 | mediaPlayerState.togglePaused(); |
293 | } | 291 | } |
294 | break; | 292 | break; |
295 | case Key_Down: | 293 | case Key_Down: |
296 | // toggleButton(6); | 294 | // toggleButton(6); |
297 | emit lessClicked(); | 295 | emit lessClicked(); |
298 | emit lessReleased(); | 296 | emit lessReleased(); |
299 | // toggleButton(6); | 297 | // toggleButton(6); |
300 | e->accept(); | 298 | e->accept(); |
301 | break; | 299 | break; |
302 | case Key_Up: | 300 | case Key_Up: |
303 | // toggleButton(5); | 301 | // toggleButton(5); |
304 | emit moreClicked(); | 302 | emit moreClicked(); |
305 | emit moreReleased(); | 303 | emit moreReleased(); |
306 | // toggleButton(5); | 304 | // toggleButton(5); |
307 | e->accept(); | 305 | e->accept(); |
308 | break; | 306 | break; |
309 | case Key_Right: | 307 | case Key_Right: |
310 | // toggleButton(3); | 308 | // toggleButton(3); |
311 | mediaPlayerState.setNext(); | 309 | mediaPlayerState.setNext(); |
312 | // toggleButton(3); | 310 | // toggleButton(3); |
313 | e->accept(); | 311 | e->accept(); |
314 | break; | 312 | break; |
315 | case Key_Left: | 313 | case Key_Left: |
316 | // toggleButton(4); | 314 | // toggleButton(4); |
317 | mediaPlayerState.setPrev(); | 315 | mediaPlayerState.setPrev(); |
318 | // toggleButton(4); | 316 | // toggleButton(4); |
319 | e->accept(); | 317 | e->accept(); |
320 | break; | 318 | break; |
321 | case Key_Escape: { | 319 | case Key_Escape: { |
322 | } | 320 | } |
323 | break; | 321 | break; |
324 | 322 | ||
325 | }; | 323 | }; |
326 | } | 324 | } |
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp index ebde9c6..05dc2d1 100644 --- a/noncore/multimedia/opieplayer2/inputDialog.cpp +++ b/noncore/multimedia/opieplayer2/inputDialog.cpp | |||
@@ -1,74 +1,67 @@ | |||
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 | =. | 6 | =. |
7 | .=l. | 7 | .=l. |
8 | .>+-= | 8 | .>+-= |
9 | _;:, .> :=|. This program is free software; you can | 9 | _;:, .> :=|. This program is free software; you can |
10 | .> <`_, > . <= redistribute it and/or modify it under | 10 | .> <`_, > . <= redistribute it and/or modify it under |
11 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 11 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
12 | .="- .-=="i, .._ License as published by the Free Software | 12 | .="- .-=="i, .._ License as published by the Free Software |
13 | - . .-<_> .<> Foundation; either version 2 of the License, | 13 | - . .-<_> .<> Foundation; either version 2 of the License, |
14 | ._= =} : or (at your option) any later version. | 14 | ._= =} : or (at your option) any later version. |
15 | .%`+i> _;_. | 15 | .%`+i> _;_. |
16 | .i_,=:_. -<s. This program is distributed in the hope that | 16 | .i_,=:_. -<s. This program is distributed in the hope that |
17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 17 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
18 | : .. .:, . . . without even the implied warranty of | 18 | : .. .:, . . . without even the implied warranty of |
19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 19 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 20 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
21 | ..}^=.= = ; General Public License for more | 21 | ..}^=.= = ; General Public License for more |
22 | ++= -. .` .: details. | 22 | ++= -. .` .: details. |
23 | : = ...= . :.=- | 23 | : = ...= . :.=- |
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = General Public License along with | 25 | -_. . . )=. = General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | 30 | ||
31 | */ | 31 | */ |
32 | 32 | ||
33 | 33 | ||
34 | #include "inputDialog.h" | 34 | #include "inputDialog.h" |
35 | 35 | ||
36 | #include <qpe/resource.h> | ||
37 | #include <qpe/qpeapplication.h> | ||
38 | 36 | ||
39 | #include <qfileinfo.h> | ||
40 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
41 | #include <qlayout.h> | ||
42 | #include <qvariant.h> | ||
43 | #include <qpushbutton.h> | ||
44 | #include <qwhatsthis.h> | ||
45 | 38 | ||
46 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 39 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
47 | : QDialog( parent, name, modal, fl ) { | 40 | : QDialog( parent, name, modal, fl ) { |
48 | if ( !name ) { | 41 | if ( !name ) { |
49 | setName( "InputDialog" ); | 42 | setName( "InputDialog" ); |
50 | } | 43 | } |
51 | resize( 234, 115); | 44 | resize( 234, 115); |
52 | setMaximumSize( QSize( 240, 40)); | 45 | setMaximumSize( QSize( 240, 40)); |
53 | setCaption( tr( name ) ); | 46 | setCaption( tr( name ) ); |
54 | 47 | ||
55 | QPushButton *browserButton; | 48 | QPushButton *browserButton; |
56 | //browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); | 49 | //browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); |
57 | //browserButton->setGeometry( QRect( 205, 10, 22, 22)); | 50 | //browserButton->setGeometry( QRect( 205, 10, 22, 22)); |
58 | //connect( browserButton, SIGNAL(released()),this,SLOT(browse())); | 51 | //connect( browserButton, SIGNAL(released()),this,SLOT(browse())); |
59 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 52 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
60 | LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); | 53 | LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); |
61 | LineEdit1->setFocus(); | 54 | LineEdit1->setFocus(); |
62 | } | 55 | } |
63 | /* | 56 | /* |
64 | * return the current text(input) | 57 | * return the current text(input) |
65 | */ | 58 | */ |
66 | QString InputDialog::text() const { | 59 | QString InputDialog::text() const { |
67 | return LineEdit1->text(); | 60 | return LineEdit1->text(); |
68 | } | 61 | } |
69 | /* | 62 | /* |
70 | * Destroys the object and frees any allocated resources | 63 | * Destroys the object and frees any allocated resources |
71 | */ | 64 | */ |
72 | InputDialog::~InputDialog() { | 65 | InputDialog::~InputDialog() { |
73 | } | 66 | } |
74 | 67 | ||
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 664ec65..a42b8e5 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,433 +1,432 @@ | |||
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 LJP <> | 5 | Copyright (c) 2002 LJP <> |
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 <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | 38 | ||
39 | #include <qgfx_qws.h> | 39 | #include <qgfx_qws.h> |
40 | #include <qdirectpainter_qws.h> | ||
41 | 40 | ||
42 | #include <assert.h> | 41 | #include <assert.h> |
43 | 42 | ||
44 | #include "xinevideowidget.h" | 43 | #include "xinevideowidget.h" |
45 | #include "frame.h" | 44 | #include "frame.h" |
46 | #include "lib.h" | 45 | #include "lib.h" |
47 | 46 | ||
48 | 47 | ||
49 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 48 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
50 | int width, int height,int bytes ); | 49 | int width, int height,int bytes ); |
51 | 50 | ||
52 | extern "C" { | 51 | extern "C" { |
53 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 52 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
54 | int null_is_showing_video( const xine_vo_driver_t* self ); | 53 | int null_is_showing_video( const xine_vo_driver_t* self ); |
55 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 54 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
56 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 55 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
57 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 56 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
58 | int null_is_scaling( const xine_vo_driver_t* self ); | 57 | int null_is_scaling( const xine_vo_driver_t* self ); |
59 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 58 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
60 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 59 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
61 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 60 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
62 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 61 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
63 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 62 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
64 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 63 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
65 | 64 | ||
66 | void null_preload_decoders( xine_stream_t *stream ); | 65 | void null_preload_decoders( xine_stream_t *stream ); |
67 | } | 66 | } |
68 | 67 | ||
69 | using namespace XINE; | 68 | using namespace XINE; |
70 | 69 | ||
71 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 70 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
72 | { | 71 | { |
73 | m_initialized = false; | 72 | m_initialized = false; |
74 | m_duringInitialization = false; | 73 | m_duringInitialization = false; |
75 | m_video = false; | 74 | m_video = false; |
76 | m_wid = widget; | 75 | m_wid = widget; |
77 | printf("Lib"); | 76 | printf("Lib"); |
78 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 77 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
79 | // get the configuration | 78 | // get the configuration |
80 | 79 | ||
81 | // not really OO, should be an extra class, later | 80 | // not really OO, should be an extra class, later |
82 | if ( !QFile::exists(configPath) ) { | 81 | if ( !QFile::exists(configPath) ) { |
83 | QFile f(configPath); | 82 | QFile f(configPath); |
84 | f.open(IO_WriteOnly); | 83 | f.open(IO_WriteOnly); |
85 | QTextStream ts( &f ); | 84 | QTextStream ts( &f ); |
86 | ts << "misc.memcpy_method:glibc\n"; | 85 | ts << "misc.memcpy_method:glibc\n"; |
87 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; | 86 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; |
88 | ts << "codec.ffmpeg_pp_quality:3\n"; | 87 | ts << "codec.ffmpeg_pp_quality:3\n"; |
89 | ts << "audio.num_buffers:50\n"; | 88 | ts << "audio.num_buffers:50\n"; |
90 | ts << "audio.size_buffers:4096\n"; | 89 | ts << "audio.size_buffers:4096\n"; |
91 | ts << "video.num_buffers:20\n"; | 90 | ts << "video.num_buffers:20\n"; |
92 | ts << "video.size_buffers:4096\n"; | 91 | ts << "video.size_buffers:4096\n"; |
93 | ts << "audio.out_num_audio_buf:16\n"; | 92 | ts << "audio.out_num_audio_buf:16\n"; |
94 | ts << "audio.out_size_audio_buf:8096\n"; | 93 | ts << "audio.out_size_audio_buf:8096\n"; |
95 | ts << "audio.out_size_zero_buf:1024\n"; | 94 | ts << "audio.out_size_zero_buf:1024\n"; |
96 | ts << "audio.passthrough_offset:0\n"; | 95 | ts << "audio.passthrough_offset:0\n"; |
97 | f.close(); | 96 | f.close(); |
98 | } | 97 | } |
99 | 98 | ||
100 | if ( initMode == InitializeImmediately ) { | 99 | if ( initMode == InitializeImmediately ) { |
101 | initialize(); | 100 | initialize(); |
102 | m_initialized = true; | 101 | m_initialized = true; |
103 | } | 102 | } |
104 | else | 103 | else |
105 | start(); | 104 | start(); |
106 | } | 105 | } |
107 | 106 | ||
108 | void Lib::run() | 107 | void Lib::run() |
109 | { | 108 | { |
110 | qDebug( "Lib::run() started" ); | 109 | qDebug( "Lib::run() started" ); |
111 | initialize(); | 110 | initialize(); |
112 | m_initialized = true; | 111 | m_initialized = true; |
113 | qDebug( "Lib::run() finished" ); | 112 | qDebug( "Lib::run() finished" ); |
114 | } | 113 | } |
115 | 114 | ||
116 | void Lib::initialize() | 115 | void Lib::initialize() |
117 | { | 116 | { |
118 | m_duringInitialization = true; | 117 | m_duringInitialization = true; |
119 | m_xine = xine_new( ); | 118 | m_xine = xine_new( ); |
120 | 119 | ||
121 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 120 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
122 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); | 121 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); |
123 | 122 | ||
124 | xine_init( m_xine ); | 123 | xine_init( m_xine ); |
125 | 124 | ||
126 | // allocate oss for sound | 125 | // allocate oss for sound |
127 | // and fb for framebuffer | 126 | // and fb for framebuffer |
128 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 127 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
129 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 128 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
130 | 129 | ||
131 | 130 | ||
132 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 131 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
133 | 132 | ||
134 | 133 | ||
135 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 134 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
136 | 135 | ||
137 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 136 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
138 | 137 | ||
139 | if (m_wid != 0 ) { | 138 | if (m_wid != 0 ) { |
140 | printf( "!0\n" ); | 139 | printf( "!0\n" ); |
141 | setWidget( m_wid ); | 140 | setWidget( m_wid ); |
142 | } | 141 | } |
143 | 142 | ||
144 | m_queue = xine_event_new_queue (m_stream); | 143 | m_queue = xine_event_new_queue (m_stream); |
145 | 144 | ||
146 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 145 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
147 | 146 | ||
148 | ::null_preload_decoders( m_stream ); | 147 | ::null_preload_decoders( m_stream ); |
149 | 148 | ||
150 | m_duringInitialization = false; | 149 | m_duringInitialization = false; |
151 | } | 150 | } |
152 | 151 | ||
153 | Lib::~Lib() { | 152 | Lib::~Lib() { |
154 | assert( isRunning() == false ); | 153 | assert( isRunning() == false ); |
155 | assert( m_initialized ); | 154 | assert( m_initialized ); |
156 | 155 | ||
157 | // free( m_config ); | 156 | // free( m_config ); |
158 | 157 | ||
159 | xine_close( m_stream ); | 158 | xine_close( m_stream ); |
160 | 159 | ||
161 | xine_event_dispose_queue( m_queue ); | 160 | xine_event_dispose_queue( m_queue ); |
162 | 161 | ||
163 | xine_dispose( m_stream ); | 162 | xine_dispose( m_stream ); |
164 | 163 | ||
165 | xine_exit( m_xine ); | 164 | xine_exit( m_xine ); |
166 | /* FIXME either free or delete but valgrind bitches against both */ | 165 | /* FIXME either free or delete but valgrind bitches against both */ |
167 | //free( m_videoOutput ); | 166 | //free( m_videoOutput ); |
168 | //delete m_audioOutput; | 167 | //delete m_audioOutput; |
169 | } | 168 | } |
170 | 169 | ||
171 | void Lib::resize ( const QSize &s ) { | 170 | void Lib::resize ( const QSize &s ) { |
172 | assert( m_initialized || m_duringInitialization ); | 171 | assert( m_initialized || m_duringInitialization ); |
173 | 172 | ||
174 | if ( s. width ( ) && s. height ( ) ) { | 173 | if ( s. width ( ) && s. height ( ) ) { |
175 | ::null_set_gui_width( m_videoOutput, s. width() ); | 174 | ::null_set_gui_width( m_videoOutput, s. width() ); |
176 | ::null_set_gui_height( m_videoOutput, s. height() ); | 175 | ::null_set_gui_height( m_videoOutput, s. height() ); |
177 | } | 176 | } |
178 | } | 177 | } |
179 | 178 | ||
180 | int Lib::majorVersion() { | 179 | int Lib::majorVersion() { |
181 | int major, minor, sub; | 180 | int major, minor, sub; |
182 | xine_get_version ( &major, &minor, &sub ); | 181 | xine_get_version ( &major, &minor, &sub ); |
183 | return major; | 182 | return major; |
184 | } | 183 | } |
185 | 184 | ||
186 | int Lib::minorVersion() { | 185 | int Lib::minorVersion() { |
187 | int major, minor, sub; | 186 | int major, minor, sub; |
188 | xine_get_version ( &major, &minor, &sub ); | 187 | xine_get_version ( &major, &minor, &sub ); |
189 | return minor; | 188 | return minor; |
190 | } | 189 | } |
191 | 190 | ||
192 | int Lib::subVersion() { | 191 | int Lib::subVersion() { |
193 | int major, minor, sub; | 192 | int major, minor, sub; |
194 | xine_get_version ( &major, &minor, &sub ); | 193 | xine_get_version ( &major, &minor, &sub ); |
195 | return sub; | 194 | return sub; |
196 | } | 195 | } |
197 | 196 | ||
198 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 197 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
199 | assert( m_initialized ); | 198 | assert( m_initialized ); |
200 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream | 199 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream |
201 | // but without we get wrong media length reads from libxine for the second media | 200 | // but without we get wrong media length reads from libxine for the second media |
202 | //xine_dispose ( m_stream ); | 201 | //xine_dispose ( m_stream ); |
203 | 202 | ||
204 | QString str = fileName.stripWhiteSpace(); | 203 | QString str = fileName.stripWhiteSpace(); |
205 | 204 | ||
206 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 205 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
207 | //m_queue = xine_event_new_queue (m_stream); | 206 | //m_queue = xine_event_new_queue (m_stream); |
208 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 207 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
209 | 208 | ||
210 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 209 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
211 | return 0; | 210 | return 0; |
212 | } | 211 | } |
213 | return xine_play( m_stream, startPos, start_time); | 212 | return xine_play( m_stream, startPos, start_time); |
214 | } | 213 | } |
215 | 214 | ||
216 | void Lib::stop() { | 215 | void Lib::stop() { |
217 | assert( m_initialized ); | 216 | assert( m_initialized ); |
218 | 217 | ||
219 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 218 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
220 | xine_stop( m_stream ); | 219 | xine_stop( m_stream ); |
221 | } | 220 | } |
222 | 221 | ||
223 | void Lib::pause( bool toggle ) { | 222 | void Lib::pause( bool toggle ) { |
224 | assert( m_initialized ); | 223 | assert( m_initialized ); |
225 | 224 | ||
226 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 225 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
227 | } | 226 | } |
228 | 227 | ||
229 | int Lib::speed() const { | 228 | int Lib::speed() const { |
230 | assert( m_initialized ); | 229 | assert( m_initialized ); |
231 | 230 | ||
232 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 231 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
233 | } | 232 | } |
234 | 233 | ||
235 | void Lib::setSpeed( int speed ) { | 234 | void Lib::setSpeed( int speed ) { |
236 | assert( m_initialized ); | 235 | assert( m_initialized ); |
237 | 236 | ||
238 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 237 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
239 | } | 238 | } |
240 | 239 | ||
241 | int Lib::status() const { | 240 | int Lib::status() const { |
242 | assert( m_initialized ); | 241 | assert( m_initialized ); |
243 | 242 | ||
244 | return xine_get_status( m_stream ); | 243 | return xine_get_status( m_stream ); |
245 | } | 244 | } |
246 | 245 | ||
247 | int Lib::currentPosition() const { | 246 | int Lib::currentPosition() const { |
248 | assert( m_initialized ); | 247 | assert( m_initialized ); |
249 | 248 | ||
250 | int pos, time, length; | 249 | int pos, time, length; |
251 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 250 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
252 | return pos; | 251 | return pos; |
253 | } | 252 | } |
254 | 253 | ||
255 | int Lib::currentTime() const { | 254 | int Lib::currentTime() const { |
256 | assert( m_initialized ); | 255 | assert( m_initialized ); |
257 | 256 | ||
258 | int pos, time, length; | 257 | int pos, time, length; |
259 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 258 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
260 | if ( time > 0 ) { | 259 | if ( time > 0 ) { |
261 | return time/1000; | 260 | return time/1000; |
262 | } else { | 261 | } else { |
263 | return 0; | 262 | return 0; |
264 | } | 263 | } |
265 | } | 264 | } |
266 | 265 | ||
267 | int Lib::length() const { | 266 | int Lib::length() const { |
268 | assert( m_initialized ); | 267 | assert( m_initialized ); |
269 | 268 | ||
270 | int pos, time, length; | 269 | int pos, time, length; |
271 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ | 270 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ |
272 | int iRetVal=0, iTestLoop=0; | 271 | int iRetVal=0, iTestLoop=0; |
273 | 272 | ||
274 | do | 273 | do |
275 | { | 274 | { |
276 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); | 275 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); |
277 | if (iRetVal) | 276 | if (iRetVal) |
278 | {/* if the function didn't return 0, then pos, time and length are valid.*/ | 277 | {/* if the function didn't return 0, then pos, time and length are valid.*/ |
279 | return length/1000; | 278 | return length/1000; |
280 | } | 279 | } |
281 | /*don't poll too much*/ | 280 | /*don't poll too much*/ |
282 | usleep(100000); | 281 | usleep(100000); |
283 | iTestLoop++; | 282 | iTestLoop++; |
284 | } | 283 | } |
285 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any | 284 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any |
286 | valid stream, then return -1 (this value could be used to make the stream | 285 | valid stream, then return -1 (this value could be used to make the stream |
287 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 286 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
288 | 287 | ||
289 | return -1; | 288 | return -1; |
290 | } | 289 | } |
291 | 290 | ||
292 | bool Lib::isSeekable() const { | 291 | bool Lib::isSeekable() const { |
293 | assert( m_initialized ); | 292 | assert( m_initialized ); |
294 | 293 | ||
295 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 294 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
296 | } | 295 | } |
297 | 296 | ||
298 | void Lib::seekTo( int time ) { | 297 | void Lib::seekTo( int time ) { |
299 | assert( m_initialized ); | 298 | assert( m_initialized ); |
300 | 299 | ||
301 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 300 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
302 | // since its now milliseconds we need *1000 | 301 | // since its now milliseconds we need *1000 |
303 | xine_play( m_stream, 0, time*1000 ); | 302 | xine_play( m_stream, 0, time*1000 ); |
304 | } | 303 | } |
305 | 304 | ||
306 | 305 | ||
307 | Frame Lib::currentFrame() const { | 306 | Frame Lib::currentFrame() const { |
308 | assert( m_initialized ); | 307 | assert( m_initialized ); |
309 | 308 | ||
310 | Frame frame; | 309 | Frame frame; |
311 | return frame; | 310 | return frame; |
312 | }; | 311 | }; |
313 | 312 | ||
314 | QString Lib::metaInfo( int number) const { | 313 | QString Lib::metaInfo( int number) const { |
315 | assert( m_initialized ); | 314 | assert( m_initialized ); |
316 | 315 | ||
317 | return xine_get_meta_info( m_stream, number ); | 316 | return xine_get_meta_info( m_stream, number ); |
318 | } | 317 | } |
319 | 318 | ||
320 | int Lib::error() const { | 319 | int Lib::error() const { |
321 | assert( m_initialized ); | 320 | assert( m_initialized ); |
322 | 321 | ||
323 | return xine_get_error( m_stream ); | 322 | return xine_get_error( m_stream ); |
324 | }; | 323 | }; |
325 | 324 | ||
326 | void Lib::ensureInitialized() | 325 | void Lib::ensureInitialized() |
327 | { | 326 | { |
328 | if ( m_initialized ) | 327 | if ( m_initialized ) |
329 | return; | 328 | return; |
330 | 329 | ||
331 | qDebug( "waiting for initialization thread to finish" ); | 330 | qDebug( "waiting for initialization thread to finish" ); |
332 | wait(); | 331 | wait(); |
333 | qDebug( "initialization thread finished!" ); | 332 | qDebug( "initialization thread finished!" ); |
334 | } | 333 | } |
335 | 334 | ||
336 | void Lib::setWidget( XineVideoWidget *widget ) | 335 | void Lib::setWidget( XineVideoWidget *widget ) |
337 | { | 336 | { |
338 | m_wid = widget; | 337 | m_wid = widget; |
339 | resize ( m_wid-> size ( ) ); | 338 | resize ( m_wid-> size ( ) ); |
340 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 339 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
341 | m_wid->repaint(); | 340 | m_wid->repaint(); |
342 | } | 341 | } |
343 | 342 | ||
344 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 343 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
345 | { | 344 | { |
346 | assert( sendType == ThreadUtil::Channel::OneWay ); | 345 | assert( sendType == ThreadUtil::Channel::OneWay ); |
347 | handleXineEvent( msg->type() ); | 346 | handleXineEvent( msg->type() ); |
348 | delete msg; | 347 | delete msg; |
349 | } | 348 | } |
350 | 349 | ||
351 | void Lib::handleXineEvent( const xine_event_t* t ) { | 350 | void Lib::handleXineEvent( const xine_event_t* t ) { |
352 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 351 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
353 | } | 352 | } |
354 | 353 | ||
355 | void Lib::handleXineEvent( int type ) { | 354 | void Lib::handleXineEvent( int type ) { |
356 | assert( m_initialized ); | 355 | assert( m_initialized ); |
357 | 356 | ||
358 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 357 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
359 | emit stopped(); | 358 | emit stopped(); |
360 | } | 359 | } |
361 | } | 360 | } |
362 | 361 | ||
363 | 362 | ||
364 | void Lib::setShowVideo( bool video ) { | 363 | void Lib::setShowVideo( bool video ) { |
365 | assert( m_initialized ); | 364 | assert( m_initialized ); |
366 | 365 | ||
367 | m_video = video; | 366 | m_video = video; |
368 | ::null_set_show_video( m_videoOutput, video ); | 367 | ::null_set_show_video( m_videoOutput, video ); |
369 | } | 368 | } |
370 | 369 | ||
371 | bool Lib::isShowingVideo() const { | 370 | bool Lib::isShowingVideo() const { |
372 | assert( m_initialized ); | 371 | assert( m_initialized ); |
373 | 372 | ||
374 | return ::null_is_showing_video( m_videoOutput ); | 373 | return ::null_is_showing_video( m_videoOutput ); |
375 | } | 374 | } |
376 | 375 | ||
377 | bool Lib::hasVideo() const { | 376 | bool Lib::hasVideo() const { |
378 | assert( m_initialized ); | 377 | assert( m_initialized ); |
379 | 378 | ||
380 | return xine_get_stream_info( m_stream, 18 ); | 379 | return xine_get_stream_info( m_stream, 18 ); |
381 | } | 380 | } |
382 | 381 | ||
383 | void Lib::showVideoFullScreen( bool fullScreen ) { | 382 | void Lib::showVideoFullScreen( bool fullScreen ) { |
384 | assert( m_initialized ); | 383 | assert( m_initialized ); |
385 | 384 | ||
386 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 385 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
387 | } | 386 | } |
388 | 387 | ||
389 | bool Lib::isVideoFullScreen() const { | 388 | bool Lib::isVideoFullScreen() const { |
390 | assert( m_initialized ); | 389 | assert( m_initialized ); |
391 | 390 | ||
392 | return ::null_is_fullscreen( m_videoOutput ); | 391 | return ::null_is_fullscreen( m_videoOutput ); |
393 | } | 392 | } |
394 | 393 | ||
395 | void Lib::setScaling( bool scale ) { | 394 | void Lib::setScaling( bool scale ) { |
396 | assert( m_initialized ); | 395 | assert( m_initialized ); |
397 | 396 | ||
398 | ::null_set_scaling( m_videoOutput, scale ); | 397 | ::null_set_scaling( m_videoOutput, scale ); |
399 | } | 398 | } |
400 | 399 | ||
401 | void Lib::setGamma( int value ) { | 400 | void Lib::setGamma( int value ) { |
402 | assert( m_initialized ); | 401 | assert( m_initialized ); |
403 | 402 | ||
404 | ::null_set_videoGamma( m_videoOutput, value ); | 403 | ::null_set_videoGamma( m_videoOutput, value ); |
405 | } | 404 | } |
406 | 405 | ||
407 | bool Lib::isScaling() const { | 406 | bool Lib::isScaling() const { |
408 | assert( m_initialized ); | 407 | assert( m_initialized ); |
409 | 408 | ||
410 | return ::null_is_scaling( m_videoOutput ); | 409 | return ::null_is_scaling( m_videoOutput ); |
411 | } | 410 | } |
412 | 411 | ||
413 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 412 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
414 | ( (Lib*)user_data)->handleXineEvent( t ); | 413 | ( (Lib*)user_data)->handleXineEvent( t ); |
415 | } | 414 | } |
416 | 415 | ||
417 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 416 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
418 | int width, int height, int bytes ) { | 417 | int width, int height, int bytes ) { |
419 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 418 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
420 | } | 419 | } |
421 | 420 | ||
422 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 421 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
423 | assert( m_initialized ); | 422 | assert( m_initialized ); |
424 | 423 | ||
425 | if ( !m_video ) { | 424 | if ( !m_video ) { |
426 | qWarning("not showing video now"); | 425 | qWarning("not showing video now"); |
427 | return; | 426 | return; |
428 | } | 427 | } |
429 | 428 | ||
430 | assert( m_wid ); | 429 | assert( m_wid ); |
431 | 430 | ||
432 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 431 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
433 | } | 432 | } |
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index b0a22b2..00f72d1 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp | |||
@@ -1,29 +1,26 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | ||
3 | #include "mediaplayerstate.h" | ||
4 | #include "playlistwidget.h" | ||
5 | #include "mediaplayer.h" | 2 | #include "mediaplayer.h" |
6 | 3 | ||
7 | 4 | ||
8 | 5 | ||
9 | #include <opie/oapplicationfactory.h> | 6 | #include <opie/oapplicationfactory.h> |
10 | 7 | ||
11 | OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> ) | 8 | OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> ) |
12 | 9 | ||
13 | #if 0 | 10 | #if 0 |
14 | int main(int argc, char **argv) { | 11 | int main(int argc, char **argv) { |
15 | QPEApplication a(argc,argv); | 12 | QPEApplication a(argc,argv); |
16 | 13 | ||
17 | MediaPlayerState st( 0, "mediaPlayerState" ); | 14 | MediaPlayerState st( 0, "mediaPlayerState" ); |
18 | PlayListWidget pl( st, 0, "playList" ); | 15 | PlayListWidget pl( st, 0, "playList" ); |
19 | pl.showMaximized(); | 16 | pl.showMaximized(); |
20 | MediaPlayer mp( pl, st, 0, "mediaPlayer" ); | 17 | MediaPlayer mp( pl, st, 0, "mediaPlayer" ); |
21 | QObject::connect( &pl, SIGNAL( skinSelected() ), | 18 | QObject::connect( &pl, SIGNAL( skinSelected() ), |
22 | &mp, SLOT( reloadSkins() ) ); | 19 | &mp, SLOT( reloadSkins() ) ); |
23 | 20 | ||
24 | a.showMainDocumentWidget(&pl); | 21 | a.showMainDocumentWidget(&pl); |
25 | 22 | ||
26 | return a.exec(); | 23 | return a.exec(); |
27 | } | 24 | } |
28 | #endif | 25 | #endif |
29 | 26 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 1e6bc4d..a236775 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,405 +1,401 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
3 | #include <qpe/qcopenvelope_qws.h> | ||
4 | #include <qfileinfo.h> | 3 | #include <qfileinfo.h> |
5 | 4 | ||
6 | #include "mediaplayer.h" | 5 | #include "mediaplayer.h" |
7 | #include "playlistwidget.h" | ||
8 | #include "audiowidget.h" | 6 | #include "audiowidget.h" |
9 | #include "videowidget.h" | 7 | #include "videowidget.h" |
10 | #include "volumecontrol.h" | 8 | #include "volumecontrol.h" |
11 | #include "lib.h" | ||
12 | 9 | ||
13 | #include "mediaplayerstate.h" | ||
14 | 10 | ||
15 | // for setBacklight() | 11 | // for setBacklight() |
16 | #include <linux/fb.h> | 12 | #include <linux/fb.h> |
17 | #include <sys/file.h> | 13 | #include <sys/file.h> |
18 | #include <sys/ioctl.h> | 14 | #include <sys/ioctl.h> |
19 | 15 | ||
20 | 16 | ||
21 | #define FBIOBLANK 0x4611 | 17 | #define FBIOBLANK 0x4611 |
22 | 18 | ||
23 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 19 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
24 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 20 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
25 | 21 | ||
26 | m_audioUI = 0; | 22 | m_audioUI = 0; |
27 | m_videoUI = 0; | 23 | m_videoUI = 0; |
28 | m_xineControl = 0; | 24 | m_xineControl = 0; |
29 | xine = new XINE::Lib( XINE::Lib::InitializeInThread ); | 25 | xine = new XINE::Lib( XINE::Lib::InitializeInThread ); |
30 | 26 | ||
31 | fd=-1;fl=-1; | 27 | fd=-1;fl=-1; |
32 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 28 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
33 | 29 | ||
34 | qApp->processEvents(); | 30 | qApp->processEvents(); |
35 | // QPEApplication::grabKeyboard(); // EVIL | 31 | // QPEApplication::grabKeyboard(); // EVIL |
36 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 32 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
37 | 33 | ||
38 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 34 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
39 | 35 | ||
40 | // What is pauseCheck good for? (Simon) | 36 | // What is pauseCheck good for? (Simon) |
41 | // connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); | 37 | // connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); |
42 | 38 | ||
43 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 39 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
44 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 40 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
45 | connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); | 41 | connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); |
46 | 42 | ||
47 | volControl = new VolumeControl; | 43 | volControl = new VolumeControl; |
48 | Config cfg( "OpiePlayer" ); | 44 | Config cfg( "OpiePlayer" ); |
49 | cfg.setGroup("PlayList"); | 45 | cfg.setGroup("PlayList"); |
50 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 46 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
51 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 47 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
52 | 48 | ||
53 | m_skinLoader = new SkinLoader; | 49 | m_skinLoader = new SkinLoader; |
54 | m_skinLoader->schedule( AudioWidget::guiInfo() ); | 50 | m_skinLoader->schedule( AudioWidget::guiInfo() ); |
55 | m_skinLoader->schedule( VideoWidget::guiInfo() ); | 51 | m_skinLoader->schedule( VideoWidget::guiInfo() ); |
56 | m_skinLoader->start(); | 52 | m_skinLoader->start(); |
57 | } | 53 | } |
58 | 54 | ||
59 | MediaPlayer::~MediaPlayer() { | 55 | MediaPlayer::~MediaPlayer() { |
60 | // this shold never happen, but one never knows... | 56 | // this shold never happen, but one never knows... |
61 | if ( xine ) { | 57 | if ( xine ) { |
62 | xine->ensureInitialized(); | 58 | xine->ensureInitialized(); |
63 | delete xine; | 59 | delete xine; |
64 | } | 60 | } |
65 | delete m_xineControl; | 61 | delete m_xineControl; |
66 | delete m_audioUI; | 62 | delete m_audioUI; |
67 | delete m_videoUI; | 63 | delete m_videoUI; |
68 | delete volControl; | 64 | delete volControl; |
69 | } | 65 | } |
70 | 66 | ||
71 | void MediaPlayer::pauseCheck( bool b ) { | 67 | void MediaPlayer::pauseCheck( bool b ) { |
72 | if ( b && !mediaPlayerState.isPlaying() ) { | 68 | if ( b && !mediaPlayerState.isPlaying() ) { |
73 | mediaPlayerState.setPaused( FALSE ); | 69 | mediaPlayerState.setPaused( FALSE ); |
74 | } | 70 | } |
75 | } | 71 | } |
76 | 72 | ||
77 | void MediaPlayer::play() { | 73 | void MediaPlayer::play() { |
78 | mediaPlayerState.setPlaying( FALSE ); | 74 | mediaPlayerState.setPlaying( FALSE ); |
79 | mediaPlayerState.setPlaying( TRUE ); | 75 | mediaPlayerState.setPlaying( TRUE ); |
80 | } | 76 | } |
81 | 77 | ||
82 | void MediaPlayer::setPlaying( bool play ) { | 78 | void MediaPlayer::setPlaying( bool play ) { |
83 | if ( !play ) { | 79 | if ( !play ) { |
84 | return; | 80 | return; |
85 | } | 81 | } |
86 | 82 | ||
87 | if ( mediaPlayerState.isPaused() ) { | 83 | if ( mediaPlayerState.isPaused() ) { |
88 | mediaPlayerState.setPaused( FALSE ); | 84 | mediaPlayerState.setPaused( FALSE ); |
89 | return; | 85 | return; |
90 | } | 86 | } |
91 | 87 | ||
92 | QString tickerText, time, fileName; | 88 | QString tickerText, time, fileName; |
93 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 89 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
94 | //if playing in file list.. play in a different way | 90 | //if playing in file list.. play in a different way |
95 | // random and looping settings enabled causes problems here, | 91 | // random and looping settings enabled causes problems here, |
96 | // since there is no selected file in the playlist, but a selected file in the file list, | 92 | // since there is no selected file in the playlist, but a selected file in the file list, |
97 | // so we remember and shutoff | 93 | // so we remember and shutoff |
98 | l = mediaPlayerState.isLooping(); | 94 | l = mediaPlayerState.isLooping(); |
99 | if(l) { | 95 | if(l) { |
100 | mediaPlayerState.setLooping( false ); | 96 | mediaPlayerState.setLooping( false ); |
101 | } | 97 | } |
102 | r = mediaPlayerState.isShuffled(); | 98 | r = mediaPlayerState.isShuffled(); |
103 | mediaPlayerState.setShuffled( false ); | 99 | mediaPlayerState.setShuffled( false ); |
104 | } | 100 | } |
105 | 101 | ||
106 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 102 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
107 | fileName = playListEntry.name; | 103 | fileName = playListEntry.name; |
108 | xineControl()->play( playListEntry.file ); | 104 | xineControl()->play( playListEntry.file ); |
109 | 105 | ||
110 | long seconds = mediaPlayerState.length(); | 106 | long seconds = mediaPlayerState.length(); |
111 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 107 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
112 | 108 | ||
113 | if( fileName.left(4) == "http" ) { | 109 | if( fileName.left(4) == "http" ) { |
114 | fileName = QFileInfo( fileName ).baseName(); | 110 | fileName = QFileInfo( fileName ).baseName(); |
115 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 111 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
116 | tickerText = tr( " File: " ) + fileName; | 112 | tickerText = tr( " File: " ) + fileName; |
117 | } else { | 113 | } else { |
118 | tickerText = xineControl()->getMetaInfo(); | 114 | tickerText = xineControl()->getMetaInfo(); |
119 | } | 115 | } |
120 | } else { | 116 | } else { |
121 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 117 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
122 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 118 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
123 | } else { | 119 | } else { |
124 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; | 120 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; |
125 | } | 121 | } |
126 | } | 122 | } |
127 | audioUI()->setTickerText( tickerText ); | 123 | audioUI()->setTickerText( tickerText ); |
128 | } | 124 | } |
129 | 125 | ||
130 | 126 | ||
131 | void MediaPlayer::prev() { | 127 | void MediaPlayer::prev() { |
132 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 128 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
133 | if ( playList.prev() ) { | 129 | if ( playList.prev() ) { |
134 | play(); | 130 | play(); |
135 | } else if ( mediaPlayerState.isLooping() ) { | 131 | } else if ( mediaPlayerState.isLooping() ) { |
136 | if ( playList.last() ) { | 132 | if ( playList.last() ) { |
137 | play(); | 133 | play(); |
138 | } | 134 | } |
139 | } else { | 135 | } else { |
140 | mediaPlayerState.setList(); | 136 | mediaPlayerState.setList(); |
141 | } | 137 | } |
142 | } | 138 | } |
143 | } | 139 | } |
144 | 140 | ||
145 | 141 | ||
146 | void MediaPlayer::next() { | 142 | void MediaPlayer::next() { |
147 | 143 | ||
148 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 144 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
149 | if ( playList.next() ) { | 145 | if ( playList.next() ) { |
150 | play(); | 146 | play(); |
151 | } else if ( mediaPlayerState.isLooping() ) { | 147 | } else if ( mediaPlayerState.isLooping() ) { |
152 | if ( playList.first() ) { | 148 | if ( playList.first() ) { |
153 | play(); | 149 | play(); |
154 | } | 150 | } |
155 | } else { | 151 | } else { |
156 | mediaPlayerState.setList(); | 152 | mediaPlayerState.setList(); |
157 | } | 153 | } |
158 | } else { //if playing from file list, let's just stop | 154 | } else { //if playing from file list, let's just stop |
159 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 155 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
160 | mediaPlayerState.setPlaying(false); | 156 | mediaPlayerState.setPlaying(false); |
161 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 157 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
162 | if(l) mediaPlayerState.setLooping(l); | 158 | if(l) mediaPlayerState.setLooping(l); |
163 | if(r) mediaPlayerState.setShuffled(r); | 159 | if(r) mediaPlayerState.setShuffled(r); |
164 | } | 160 | } |
165 | qApp->processEvents(); | 161 | qApp->processEvents(); |
166 | } | 162 | } |
167 | 163 | ||
168 | 164 | ||
169 | void MediaPlayer::startDecreasingVolume() { | 165 | void MediaPlayer::startDecreasingVolume() { |
170 | volumeDirection = -1; | 166 | volumeDirection = -1; |
171 | startTimer( 100 ); | 167 | startTimer( 100 ); |
172 | volControl->decVol(2); | 168 | volControl->decVol(2); |
173 | } | 169 | } |
174 | 170 | ||
175 | 171 | ||
176 | void MediaPlayer::startIncreasingVolume() { | 172 | void MediaPlayer::startIncreasingVolume() { |
177 | volumeDirection = +1; | 173 | volumeDirection = +1; |
178 | startTimer( 100 ); | 174 | startTimer( 100 ); |
179 | volControl->incVol(2); | 175 | volControl->incVol(2); |
180 | } | 176 | } |
181 | 177 | ||
182 | 178 | ||
183 | bool drawnOnScreenDisplay = FALSE; | 179 | bool drawnOnScreenDisplay = FALSE; |
184 | unsigned int onScreenDisplayVolume = 0; | 180 | unsigned int onScreenDisplayVolume = 0; |
185 | const int yoff = 110; | 181 | const int yoff = 110; |
186 | 182 | ||
187 | void MediaPlayer::stopChangingVolume() { | 183 | void MediaPlayer::stopChangingVolume() { |
188 | killTimers(); | 184 | killTimers(); |
189 | // Get rid of the on-screen display stuff | 185 | // Get rid of the on-screen display stuff |
190 | drawnOnScreenDisplay = FALSE; | 186 | drawnOnScreenDisplay = FALSE; |
191 | onScreenDisplayVolume = 0; | 187 | onScreenDisplayVolume = 0; |
192 | int w=0; | 188 | int w=0; |
193 | int h=0; | 189 | int h=0; |
194 | if( !xineControl()->hasVideo() ) { | 190 | if( !xineControl()->hasVideo() ) { |
195 | w = audioUI()->width(); | 191 | w = audioUI()->width(); |
196 | h = audioUI()->height(); | 192 | h = audioUI()->height(); |
197 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 193 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
198 | } else { | 194 | } else { |
199 | w = videoUI()->width(); | 195 | w = videoUI()->width(); |
200 | h = videoUI()->height(); | 196 | h = videoUI()->height(); |
201 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 197 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
202 | } | 198 | } |
203 | } | 199 | } |
204 | 200 | ||
205 | 201 | ||
206 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 202 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
207 | if ( volumeDirection == +1 ) { | 203 | if ( volumeDirection == +1 ) { |
208 | volControl->incVol( 2 ); | 204 | volControl->incVol( 2 ); |
209 | } else if ( volumeDirection == -1 ) { | 205 | } else if ( volumeDirection == -1 ) { |
210 | volControl->decVol( 2 ); | 206 | volControl->decVol( 2 ); |
211 | } | 207 | } |
212 | 208 | ||
213 | 209 | ||
214 | // TODO FIXME | 210 | // TODO FIXME |
215 | // huh?? | 211 | // huh?? |
216 | unsigned int v= 0; | 212 | unsigned int v= 0; |
217 | v = volControl->volume(); | 213 | v = volControl->volume(); |
218 | v = v / 10; | 214 | v = v / 10; |
219 | 215 | ||
220 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 216 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
221 | return; | 217 | return; |
222 | } | 218 | } |
223 | 219 | ||
224 | int w=0; int h=0; | 220 | int w=0; int h=0; |
225 | if( !xineControl()->hasVideo() ) { | 221 | if( !xineControl()->hasVideo() ) { |
226 | w = audioUI()->width(); | 222 | w = audioUI()->width(); |
227 | h = audioUI()->height(); | 223 | h = audioUI()->height(); |
228 | 224 | ||
229 | if ( drawnOnScreenDisplay ) { | 225 | if ( drawnOnScreenDisplay ) { |
230 | if ( onScreenDisplayVolume > v ) { | 226 | if ( onScreenDisplayVolume > v ) { |
231 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 227 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
232 | } | 228 | } |
233 | } | 229 | } |
234 | drawnOnScreenDisplay = TRUE; | 230 | drawnOnScreenDisplay = TRUE; |
235 | onScreenDisplayVolume = v; | 231 | onScreenDisplayVolume = v; |
236 | QPainter p( audioUI() ); | 232 | QPainter p( audioUI() ); |
237 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 233 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
238 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 234 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
239 | 235 | ||
240 | QFont f; | 236 | QFont f; |
241 | f.setPixelSize( 20 ); | 237 | f.setPixelSize( 20 ); |
242 | f.setBold( TRUE ); | 238 | f.setBold( TRUE ); |
243 | p.setFont( f ); | 239 | p.setFont( f ); |
244 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 240 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
245 | 241 | ||
246 | for ( unsigned int i = 0; i < 10; i++ ) { | 242 | for ( unsigned int i = 0; i < 10; i++ ) { |
247 | if ( v > i ) { | 243 | if ( v > i ) { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 244 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
249 | } else { | 245 | } else { |
250 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
251 | } | 247 | } |
252 | } | 248 | } |
253 | } else { | 249 | } else { |
254 | w = videoUI()->width(); | 250 | w = videoUI()->width(); |
255 | h = videoUI()->height(); | 251 | h = videoUI()->height(); |
256 | 252 | ||
257 | if ( drawnOnScreenDisplay ) { | 253 | if ( drawnOnScreenDisplay ) { |
258 | if ( onScreenDisplayVolume > v ) { | 254 | if ( onScreenDisplayVolume > v ) { |
259 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 255 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
260 | } | 256 | } |
261 | } | 257 | } |
262 | drawnOnScreenDisplay = TRUE; | 258 | drawnOnScreenDisplay = TRUE; |
263 | onScreenDisplayVolume = v; | 259 | onScreenDisplayVolume = v; |
264 | QPainter p( videoUI() ); | 260 | QPainter p( videoUI() ); |
265 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 261 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
266 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 262 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
267 | 263 | ||
268 | QFont f; | 264 | QFont f; |
269 | f.setPixelSize( 20 ); | 265 | f.setPixelSize( 20 ); |
270 | f.setBold( TRUE ); | 266 | f.setBold( TRUE ); |
271 | p.setFont( f ); | 267 | p.setFont( f ); |
272 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 268 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
273 | 269 | ||
274 | for ( unsigned int i = 0; i < 10; i++ ) { | 270 | for ( unsigned int i = 0; i < 10; i++ ) { |
275 | if ( v > i ) { | 271 | if ( v > i ) { |
276 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 272 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
277 | } else { | 273 | } else { |
278 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 274 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
279 | } | 275 | } |
280 | } | 276 | } |
281 | } | 277 | } |
282 | } | 278 | } |
283 | 279 | ||
284 | 280 | ||
285 | void MediaPlayer::blank( bool b ) { | 281 | void MediaPlayer::blank( bool b ) { |
286 | fd=open("/dev/fb0",O_RDWR); | 282 | fd=open("/dev/fb0",O_RDWR); |
287 | #ifdef QT_QWS_SL5XXX | 283 | #ifdef QT_QWS_SL5XXX |
288 | fl= open( "/dev/fl", O_RDWR ); | 284 | fl= open( "/dev/fl", O_RDWR ); |
289 | #endif | 285 | #endif |
290 | if (fd != -1) { | 286 | if (fd != -1) { |
291 | if ( b ) { | 287 | if ( b ) { |
292 | qDebug("do blanking"); | 288 | qDebug("do blanking"); |
293 | #ifdef QT_QWS_SL5XXX | 289 | #ifdef QT_QWS_SL5XXX |
294 | ioctl( fd, FBIOBLANK, 1 ); | 290 | ioctl( fd, FBIOBLANK, 1 ); |
295 | if(fl !=-1) { | 291 | if(fl !=-1) { |
296 | ioctl( fl, 2 ); | 292 | ioctl( fl, 2 ); |
297 | ::close(fl); | 293 | ::close(fl); |
298 | } | 294 | } |
299 | #else | 295 | #else |
300 | ioctl( fd, FBIOBLANK, 3 ); | 296 | ioctl( fd, FBIOBLANK, 3 ); |
301 | #endif | 297 | #endif |
302 | isBlanked = TRUE; | 298 | isBlanked = TRUE; |
303 | } else { | 299 | } else { |
304 | qDebug("do unblanking"); | 300 | qDebug("do unblanking"); |
305 | ioctl( fd, FBIOBLANK, 0); | 301 | ioctl( fd, FBIOBLANK, 0); |
306 | #ifdef QT_QWS_SL5XXX | 302 | #ifdef QT_QWS_SL5XXX |
307 | if(fl != -1) { | 303 | if(fl != -1) { |
308 | ioctl( fl, 1); | 304 | ioctl( fl, 1); |
309 | ::close(fl); | 305 | ::close(fl); |
310 | } | 306 | } |
311 | #endif | 307 | #endif |
312 | isBlanked = FALSE; | 308 | isBlanked = FALSE; |
313 | } | 309 | } |
314 | close( fd ); | 310 | close( fd ); |
315 | } else { | 311 | } else { |
316 | qDebug("<< /dev/fb0 could not be opened >>"); | 312 | qDebug("<< /dev/fb0 could not be opened >>"); |
317 | } | 313 | } |
318 | } | 314 | } |
319 | 315 | ||
320 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 316 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
321 | switch ( e->key() ) { | 317 | switch ( e->key() ) { |
322 | ////////////////////////////// Zaurus keys | 318 | ////////////////////////////// Zaurus keys |
323 | case Key_Home: | 319 | case Key_Home: |
324 | break; | 320 | break; |
325 | case Key_F9: //activity | 321 | case Key_F9: //activity |
326 | break; | 322 | break; |
327 | case Key_F10: //contacts | 323 | case Key_F10: //contacts |
328 | break; | 324 | break; |
329 | case Key_F11: //menu | 325 | case Key_F11: //menu |
330 | break; | 326 | break; |
331 | case Key_F12: //home | 327 | case Key_F12: //home |
332 | qDebug("Blank here"); | 328 | qDebug("Blank here"); |
333 | // mediaPlayerState->toggleBlank(); | 329 | // mediaPlayerState->toggleBlank(); |
334 | break; | 330 | break; |
335 | case Key_F13: //mail | 331 | case Key_F13: //mail |
336 | qDebug("Blank here"); | 332 | qDebug("Blank here"); |
337 | // mediaPlayerState->toggleBlank(); | 333 | // mediaPlayerState->toggleBlank(); |
338 | break; | 334 | break; |
339 | } | 335 | } |
340 | } | 336 | } |
341 | 337 | ||
342 | void MediaPlayer::cleanUp() {// this happens on closing | 338 | void MediaPlayer::cleanUp() {// this happens on closing |
343 | Config cfg( "OpiePlayer" ); | 339 | Config cfg( "OpiePlayer" ); |
344 | mediaPlayerState.writeConfig( cfg ); | 340 | mediaPlayerState.writeConfig( cfg ); |
345 | playList.writeDefaultPlaylist( ); | 341 | playList.writeDefaultPlaylist( ); |
346 | 342 | ||
347 | // QPEApplication::grabKeyboard(); | 343 | // QPEApplication::grabKeyboard(); |
348 | // QPEApplication::ungrabKeyboard(); | 344 | // QPEApplication::ungrabKeyboard(); |
349 | } | 345 | } |
350 | 346 | ||
351 | void MediaPlayer::recreateAudioAndVideoWidgets() const | 347 | void MediaPlayer::recreateAudioAndVideoWidgets() const |
352 | { | 348 | { |
353 | delete m_skinLoader; | 349 | delete m_skinLoader; |
354 | 350 | ||
355 | delete m_xineControl; | 351 | delete m_xineControl; |
356 | delete m_audioUI; | 352 | delete m_audioUI; |
357 | delete m_videoUI; | 353 | delete m_videoUI; |
358 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 354 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
359 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 355 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
360 | 356 | ||
361 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 357 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
362 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 358 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
363 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 359 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
364 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 360 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | 361 | ||
366 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 362 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
367 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 363 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
368 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
369 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 365 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
370 | 366 | ||
371 | if ( !xine ) | 367 | if ( !xine ) |
372 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); | 368 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); |
373 | 369 | ||
374 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); | 370 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); |
375 | 371 | ||
376 | xine = 0; | 372 | xine = 0; |
377 | } | 373 | } |
378 | 374 | ||
379 | AudioWidget *MediaPlayer::audioUI() const | 375 | AudioWidget *MediaPlayer::audioUI() const |
380 | { | 376 | { |
381 | if ( !m_audioUI ) | 377 | if ( !m_audioUI ) |
382 | recreateAudioAndVideoWidgets(); | 378 | recreateAudioAndVideoWidgets(); |
383 | return m_audioUI; | 379 | return m_audioUI; |
384 | } | 380 | } |
385 | 381 | ||
386 | VideoWidget *MediaPlayer::videoUI() const | 382 | VideoWidget *MediaPlayer::videoUI() const |
387 | { | 383 | { |
388 | if ( !m_videoUI ) | 384 | if ( !m_videoUI ) |
389 | recreateAudioAndVideoWidgets(); | 385 | recreateAudioAndVideoWidgets(); |
390 | return m_videoUI; | 386 | return m_videoUI; |
391 | } | 387 | } |
392 | 388 | ||
393 | XineControl *MediaPlayer::xineControl() const | 389 | XineControl *MediaPlayer::xineControl() const |
394 | { | 390 | { |
395 | if ( !m_xineControl ) | 391 | if ( !m_xineControl ) |
396 | recreateAudioAndVideoWidgets(); | 392 | recreateAudioAndVideoWidgets(); |
397 | return m_xineControl; | 393 | return m_xineControl; |
398 | } | 394 | } |
399 | 395 | ||
400 | void MediaPlayer::reloadSkins() | 396 | void MediaPlayer::reloadSkins() |
401 | { | 397 | { |
402 | audioUI()->loadSkin(); | 398 | audioUI()->loadSkin(); |
403 | videoUI()->loadSkin(); | 399 | videoUI()->loadSkin(); |
404 | } | 400 | } |
405 | 401 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 40fa1a4..203ff91 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,264 +1,259 @@ | |||
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 | ..}^=.= = ; 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 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #include <qpe/qpeapplication.h> | ||
37 | #include <qpe/qlibrary.h> | ||
38 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
39 | #include <qvaluelist.h> | ||
40 | #include <qobject.h> | ||
41 | #include <qdir.h> | ||
42 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
43 | 38 | ||
44 | #include <assert.h> | 39 | #include <assert.h> |
45 | 40 | ||
46 | //#define MediaPlayerDebug(x) qDebug x | 41 | //#define MediaPlayerDebug(x) qDebug x |
47 | #define MediaPlayerDebug(x) | 42 | #define MediaPlayerDebug(x) |
48 | 43 | ||
49 | 44 | ||
50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 45 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
51 | : QObject( parent, name ) { | 46 | : QObject( parent, name ) { |
52 | Config cfg( "OpiePlayer" ); | 47 | Config cfg( "OpiePlayer" ); |
53 | readConfig( cfg ); | 48 | readConfig( cfg ); |
54 | streaming = false; | 49 | streaming = false; |
55 | seekable = true; | 50 | seekable = true; |
56 | } | 51 | } |
57 | 52 | ||
58 | 53 | ||
59 | MediaPlayerState::~MediaPlayerState() { | 54 | MediaPlayerState::~MediaPlayerState() { |
60 | } | 55 | } |
61 | 56 | ||
62 | 57 | ||
63 | void MediaPlayerState::readConfig( Config& cfg ) { | 58 | void MediaPlayerState::readConfig( Config& cfg ) { |
64 | cfg.setGroup("Options"); | 59 | cfg.setGroup("Options"); |
65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 60 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
66 | scaled = cfg.readBoolEntry( "Scaling" ); | 61 | scaled = cfg.readBoolEntry( "Scaling" ); |
67 | looping = cfg.readBoolEntry( "Looping" ); | 62 | looping = cfg.readBoolEntry( "Looping" ); |
68 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 63 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 64 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
70 | playing = FALSE; | 65 | playing = FALSE; |
71 | streaming = FALSE; | 66 | streaming = FALSE; |
72 | paused = FALSE; | 67 | paused = FALSE; |
73 | curPosition = 0; | 68 | curPosition = 0; |
74 | curLength = 0; | 69 | curLength = 0; |
75 | m_displayType = MediaSelection; | 70 | m_displayType = MediaSelection; |
76 | } | 71 | } |
77 | 72 | ||
78 | 73 | ||
79 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 74 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
80 | cfg.setGroup( "Options" ); | 75 | cfg.setGroup( "Options" ); |
81 | cfg.writeEntry( "FullScreen", fullscreen ); | 76 | cfg.writeEntry( "FullScreen", fullscreen ); |
82 | cfg.writeEntry( "Scaling", scaled ); | 77 | cfg.writeEntry( "Scaling", scaled ); |
83 | cfg.writeEntry( "Looping", looping ); | 78 | cfg.writeEntry( "Looping", looping ); |
84 | cfg.writeEntry( "Shuffle", shuffled ); | 79 | cfg.writeEntry( "Shuffle", shuffled ); |
85 | cfg.writeEntry( "VideoGamma", videoGamma ); | 80 | cfg.writeEntry( "VideoGamma", videoGamma ); |
86 | } | 81 | } |
87 | 82 | ||
88 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const | 83 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const |
89 | { | 84 | { |
90 | return m_displayType; | 85 | return m_displayType; |
91 | } | 86 | } |
92 | 87 | ||
93 | // slots | 88 | // slots |
94 | void MediaPlayerState::setIsStreaming( bool b ) { | 89 | void MediaPlayerState::setIsStreaming( bool b ) { |
95 | streaming = b; | 90 | streaming = b; |
96 | } | 91 | } |
97 | 92 | ||
98 | void MediaPlayerState::setIsSeekable( bool b ) { | 93 | void MediaPlayerState::setIsSeekable( bool b ) { |
99 | seekable = b; | 94 | seekable = b; |
100 | emit isSeekableToggled(b); | 95 | emit isSeekableToggled(b); |
101 | } | 96 | } |
102 | 97 | ||
103 | 98 | ||
104 | void MediaPlayerState::setFullscreen( bool b ) { | 99 | void MediaPlayerState::setFullscreen( bool b ) { |
105 | if ( fullscreen == b ) { | 100 | if ( fullscreen == b ) { |
106 | return; | 101 | return; |
107 | } | 102 | } |
108 | fullscreen = b; | 103 | fullscreen = b; |
109 | emit fullscreenToggled(b); | 104 | emit fullscreenToggled(b); |
110 | } | 105 | } |
111 | 106 | ||
112 | 107 | ||
113 | void MediaPlayerState::setBlanked( bool b ) { | 108 | void MediaPlayerState::setBlanked( bool b ) { |
114 | if ( blanked == b ) { | 109 | if ( blanked == b ) { |
115 | return; | 110 | return; |
116 | } | 111 | } |
117 | blanked = b; | 112 | blanked = b; |
118 | emit blankToggled(b); | 113 | emit blankToggled(b); |
119 | } | 114 | } |
120 | 115 | ||
121 | 116 | ||
122 | void MediaPlayerState::setScaled( bool b ) { | 117 | void MediaPlayerState::setScaled( bool b ) { |
123 | if ( scaled == b ) { | 118 | if ( scaled == b ) { |
124 | return; | 119 | return; |
125 | } | 120 | } |
126 | scaled = b; | 121 | scaled = b; |
127 | emit scaledToggled(b); | 122 | emit scaledToggled(b); |
128 | } | 123 | } |
129 | 124 | ||
130 | void MediaPlayerState::setLooping( bool b ) { | 125 | void MediaPlayerState::setLooping( bool b ) { |
131 | if ( looping == b ) { | 126 | if ( looping == b ) { |
132 | return; | 127 | return; |
133 | } | 128 | } |
134 | looping = b; | 129 | looping = b; |
135 | emit loopingToggled(b); | 130 | emit loopingToggled(b); |
136 | } | 131 | } |
137 | 132 | ||
138 | void MediaPlayerState::setShuffled( bool b ) { | 133 | void MediaPlayerState::setShuffled( bool b ) { |
139 | if ( shuffled == b ) { | 134 | if ( shuffled == b ) { |
140 | return; | 135 | return; |
141 | } | 136 | } |
142 | shuffled = b; | 137 | shuffled = b; |
143 | emit shuffledToggled(b); | 138 | emit shuffledToggled(b); |
144 | } | 139 | } |
145 | 140 | ||
146 | void MediaPlayerState::setPaused( bool b ) { | 141 | void MediaPlayerState::setPaused( bool b ) { |
147 | if ( paused == b ) { | 142 | if ( paused == b ) { |
148 | paused = FALSE; | 143 | paused = FALSE; |
149 | emit pausedToggled(FALSE); | 144 | emit pausedToggled(FALSE); |
150 | return; | 145 | return; |
151 | } | 146 | } |
152 | paused = b; | 147 | paused = b; |
153 | emit pausedToggled(b); | 148 | emit pausedToggled(b); |
154 | } | 149 | } |
155 | 150 | ||
156 | void MediaPlayerState::setPlaying( bool b ) { | 151 | void MediaPlayerState::setPlaying( bool b ) { |
157 | if ( playing == b ) { | 152 | if ( playing == b ) { |
158 | return; | 153 | return; |
159 | } | 154 | } |
160 | playing = b; | 155 | playing = b; |
161 | stopped = !b; | 156 | stopped = !b; |
162 | emit playingToggled(b); | 157 | emit playingToggled(b); |
163 | } | 158 | } |
164 | 159 | ||
165 | void MediaPlayerState::setStopped( bool b ) { | 160 | void MediaPlayerState::setStopped( bool b ) { |
166 | if ( stopped == b ) { | 161 | if ( stopped == b ) { |
167 | return; | 162 | return; |
168 | } | 163 | } |
169 | stopped = b; | 164 | stopped = b; |
170 | emit stopToggled(b); | 165 | emit stopToggled(b); |
171 | } | 166 | } |
172 | 167 | ||
173 | void MediaPlayerState::setPosition( long p ) { | 168 | void MediaPlayerState::setPosition( long p ) { |
174 | if ( curPosition == p ) { | 169 | if ( curPosition == p ) { |
175 | return; | 170 | return; |
176 | } | 171 | } |
177 | curPosition = p; | 172 | curPosition = p; |
178 | emit positionChanged(p); | 173 | emit positionChanged(p); |
179 | } | 174 | } |
180 | 175 | ||
181 | void MediaPlayerState::updatePosition( long p ){ | 176 | void MediaPlayerState::updatePosition( long p ){ |
182 | if ( curPosition == p ) { | 177 | if ( curPosition == p ) { |
183 | return; | 178 | return; |
184 | } | 179 | } |
185 | curPosition = p; | 180 | curPosition = p; |
186 | emit positionUpdated(p); | 181 | emit positionUpdated(p); |
187 | } | 182 | } |
188 | 183 | ||
189 | void MediaPlayerState::setVideoGamma( int v ){ | 184 | void MediaPlayerState::setVideoGamma( int v ){ |
190 | if ( videoGamma == v ) { | 185 | if ( videoGamma == v ) { |
191 | return; | 186 | return; |
192 | } | 187 | } |
193 | videoGamma = v; | 188 | videoGamma = v; |
194 | emit videoGammaChanged( v ); | 189 | emit videoGammaChanged( v ); |
195 | } | 190 | } |
196 | 191 | ||
197 | void MediaPlayerState::setLength( long l ) { | 192 | void MediaPlayerState::setLength( long l ) { |
198 | if ( curLength == l ) { | 193 | if ( curLength == l ) { |
199 | return; | 194 | return; |
200 | } | 195 | } |
201 | curLength = l; | 196 | curLength = l; |
202 | emit lengthChanged(l); | 197 | emit lengthChanged(l); |
203 | } | 198 | } |
204 | 199 | ||
205 | void MediaPlayerState::setDisplayType( DisplayType displayType ) | 200 | void MediaPlayerState::setDisplayType( DisplayType displayType ) |
206 | { | 201 | { |
207 | if ( m_displayType == displayType ) | 202 | if ( m_displayType == displayType ) |
208 | return; | 203 | return; |
209 | 204 | ||
210 | m_displayType = displayType; | 205 | m_displayType = displayType; |
211 | emit displayTypeChanged( m_displayType ); | 206 | emit displayTypeChanged( m_displayType ); |
212 | } | 207 | } |
213 | 208 | ||
214 | void MediaPlayerState::setPrev(){ | 209 | void MediaPlayerState::setPrev(){ |
215 | emit prev(); | 210 | emit prev(); |
216 | } | 211 | } |
217 | 212 | ||
218 | void MediaPlayerState::setNext() { | 213 | void MediaPlayerState::setNext() { |
219 | emit next(); | 214 | emit next(); |
220 | } | 215 | } |
221 | 216 | ||
222 | void MediaPlayerState::setList() { | 217 | void MediaPlayerState::setList() { |
223 | setPlaying( FALSE ); | 218 | setPlaying( FALSE ); |
224 | setDisplayType( MediaSelection ); | 219 | setDisplayType( MediaSelection ); |
225 | } | 220 | } |
226 | 221 | ||
227 | void MediaPlayerState::setVideo() { | 222 | void MediaPlayerState::setVideo() { |
228 | setDisplayType( Video ); | 223 | setDisplayType( Video ); |
229 | } | 224 | } |
230 | 225 | ||
231 | void MediaPlayerState::setAudio() { | 226 | void MediaPlayerState::setAudio() { |
232 | setDisplayType( Audio ); | 227 | setDisplayType( Audio ); |
233 | } | 228 | } |
234 | 229 | ||
235 | void MediaPlayerState::toggleFullscreen() { | 230 | void MediaPlayerState::toggleFullscreen() { |
236 | setFullscreen( !fullscreen ); | 231 | setFullscreen( !fullscreen ); |
237 | } | 232 | } |
238 | 233 | ||
239 | void MediaPlayerState::toggleScaled() { | 234 | void MediaPlayerState::toggleScaled() { |
240 | setScaled( !scaled); | 235 | setScaled( !scaled); |
241 | } | 236 | } |
242 | 237 | ||
243 | void MediaPlayerState::toggleLooping() { | 238 | void MediaPlayerState::toggleLooping() { |
244 | setLooping( !looping); | 239 | setLooping( !looping); |
245 | } | 240 | } |
246 | 241 | ||
247 | void MediaPlayerState::toggleShuffled() { | 242 | void MediaPlayerState::toggleShuffled() { |
248 | setShuffled( !shuffled); | 243 | setShuffled( !shuffled); |
249 | } | 244 | } |
250 | 245 | ||
251 | void MediaPlayerState::togglePaused() { | 246 | void MediaPlayerState::togglePaused() { |
252 | setPaused( !paused); | 247 | setPaused( !paused); |
253 | } | 248 | } |
254 | 249 | ||
255 | void MediaPlayerState::togglePlaying() { | 250 | void MediaPlayerState::togglePlaying() { |
256 | setPlaying( !playing); | 251 | setPlaying( !playing); |
257 | } | 252 | } |
258 | 253 | ||
259 | void MediaPlayerState::toggleBlank() { | 254 | void MediaPlayerState::toggleBlank() { |
260 | setBlanked( !blanked); | 255 | setBlanked( !blanked); |
261 | } | 256 | } |
262 | 257 | ||
263 | 258 | ||
264 | 259 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 08c62a2..563ccf5 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,263 +1,262 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> | 2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or | 7 | This program is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU General Public | 8 | modify it under the terms of the GNU General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | General Public License for more details. | 15 | General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; see the file COPYING. If not, write to | 18 | along with this program; see the file COPYING. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <assert.h> | 23 | #include <assert.h> |
24 | 24 | ||
25 | #include "mediawidget.h" | 25 | #include "mediawidget.h" |
26 | #include "playlistwidget.h" | ||
27 | #include "skin.h" | 26 | #include "skin.h" |
28 | 27 | ||
29 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 28 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
30 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) | 29 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) |
31 | { | 30 | { |
32 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), | 31 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), |
33 | this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); | 32 | this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); |
34 | connect( &mediaPlayerState, SIGNAL( lengthChanged(long) ), | 33 | connect( &mediaPlayerState, SIGNAL( lengthChanged(long) ), |
35 | this, SLOT( setLength(long) ) ); | 34 | this, SLOT( setLength(long) ) ); |
36 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), | 35 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), |
37 | this, SLOT( setPlaying(bool) ) ); | 36 | this, SLOT( setPlaying(bool) ) ); |
38 | 37 | ||
39 | setBackgroundMode( NoBackground ); | 38 | setBackgroundMode( NoBackground ); |
40 | } | 39 | } |
41 | 40 | ||
42 | MediaWidget::~MediaWidget() | 41 | MediaWidget::~MediaWidget() |
43 | { | 42 | { |
44 | } | 43 | } |
45 | 44 | ||
46 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | 45 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, |
47 | const Skin &skin ) | 46 | const Skin &skin ) |
48 | { | 47 | { |
49 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); | 48 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); |
50 | 49 | ||
51 | buttons.clear(); | 50 | buttons.clear(); |
52 | buttons.reserve( buttonCount ); | 51 | buttons.reserve( buttonCount ); |
53 | 52 | ||
54 | for ( uint i = 0; i < buttonCount; ++i ) { | 53 | for ( uint i = 0; i < buttonCount; ++i ) { |
55 | Button button = setupButton( skinInfo[ i ], skin ); | 54 | Button button = setupButton( skinInfo[ i ], skin ); |
56 | buttons.push_back( button ); | 55 | buttons.push_back( button ); |
57 | } | 56 | } |
58 | } | 57 | } |
59 | 58 | ||
60 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) | 59 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) |
61 | { | 60 | { |
62 | Button button; | 61 | Button button; |
63 | button.command = buttonInfo.command; | 62 | button.command = buttonInfo.command; |
64 | button.type = buttonInfo.type; | 63 | button.type = buttonInfo.type; |
65 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); | 64 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); |
66 | 65 | ||
67 | return button; | 66 | return button; |
68 | } | 67 | } |
69 | 68 | ||
70 | void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) | 69 | void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) |
71 | { | 70 | { |
72 | Skin skin( guiInfo.fileNameInfix ); | 71 | Skin skin( guiInfo.fileNameInfix ); |
73 | skin.setCachable( false ); | 72 | skin.setCachable( false ); |
74 | loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); | 73 | loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); |
75 | } | 74 | } |
76 | 75 | ||
77 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) | 76 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) |
78 | { | 77 | { |
79 | backgroundPixmap = skin.backgroundPixmap(); | 78 | backgroundPixmap = skin.backgroundPixmap(); |
80 | buttonUpImage = skin.buttonUpImage(); | 79 | buttonUpImage = skin.buttonUpImage(); |
81 | buttonDownImage = skin.buttonDownImage(); | 80 | buttonDownImage = skin.buttonDownImage(); |
82 | 81 | ||
83 | setupButtons( skinInfo, buttonCount, skin ); | 82 | setupButtons( skinInfo, buttonCount, skin ); |
84 | } | 83 | } |
85 | 84 | ||
86 | void MediaWidget::closeEvent( QCloseEvent * ) | 85 | void MediaWidget::closeEvent( QCloseEvent * ) |
87 | { | 86 | { |
88 | mediaPlayerState.setList(); | 87 | mediaPlayerState.setList(); |
89 | } | 88 | } |
90 | 89 | ||
91 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 90 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
92 | { | 91 | { |
93 | QPainter p( this ); | 92 | QPainter p( this ); |
94 | 93 | ||
95 | if ( mediaPlayerState.isFullscreen() ) { | 94 | if ( mediaPlayerState.isFullscreen() ) { |
96 | // Clear the background | 95 | // Clear the background |
97 | p.setBrush( QBrush( Qt::black ) ); | 96 | p.setBrush( QBrush( Qt::black ) ); |
98 | return; | 97 | return; |
99 | } | 98 | } |
100 | 99 | ||
101 | QPixmap buffer( size() ); | 100 | QPixmap buffer( size() ); |
102 | QPainter bufferedPainter( &buffer ); | 101 | QPainter bufferedPainter( &buffer ); |
103 | bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); | 102 | bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); |
104 | paintAllButtons( bufferedPainter ); | 103 | paintAllButtons( bufferedPainter ); |
105 | p.drawPixmap( 0, 0, buffer ); | 104 | p.drawPixmap( 0, 0, buffer ); |
106 | } | 105 | } |
107 | 106 | ||
108 | void MediaWidget::resizeEvent( QResizeEvent *e ) | 107 | void MediaWidget::resizeEvent( QResizeEvent *e ) |
109 | { | 108 | { |
110 | QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); | 109 | QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); |
111 | QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); | 110 | QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); |
112 | 111 | ||
113 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | 112 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { |
114 | Button &button = *it; | 113 | Button &button = *it; |
115 | 114 | ||
116 | if ( button.mask.isNull() ) | 115 | if ( button.mask.isNull() ) |
117 | continue; | 116 | continue; |
118 | button.pixUp = addMaskToPixmap( pixUp, button.mask ); | 117 | button.pixUp = addMaskToPixmap( pixUp, button.mask ); |
119 | button.pixDown = addMaskToPixmap( pixDn, button.mask ); | 118 | button.pixDown = addMaskToPixmap( pixDn, button.mask ); |
120 | } | 119 | } |
121 | 120 | ||
122 | QWidget::resizeEvent( e ); | 121 | QWidget::resizeEvent( e ); |
123 | } | 122 | } |
124 | 123 | ||
125 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) | 124 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) |
126 | { | 125 | { |
127 | if ( position.x() <= 0 || position.y() <= 0 || | 126 | if ( position.x() <= 0 || position.y() <= 0 || |
128 | position.x() >= buttonMask.width() || | 127 | position.x() >= buttonMask.width() || |
129 | position.y() >= buttonMask.height() ) | 128 | position.y() >= buttonMask.height() ) |
130 | return 0; | 129 | return 0; |
131 | 130 | ||
132 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); | 131 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); |
133 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 132 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
134 | if ( it->command + 1 == pixelIdx ) | 133 | if ( it->command + 1 == pixelIdx ) |
135 | return &( *it ); | 134 | return &( *it ); |
136 | 135 | ||
137 | return 0; | 136 | return 0; |
138 | } | 137 | } |
139 | 138 | ||
140 | void MediaWidget::mousePressEvent( QMouseEvent *event ) | 139 | void MediaWidget::mousePressEvent( QMouseEvent *event ) |
141 | { | 140 | { |
142 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 141 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
143 | 142 | ||
144 | if ( !button ) { | 143 | if ( !button ) { |
145 | QWidget::mousePressEvent( event ); | 144 | QWidget::mousePressEvent( event ); |
146 | return; | 145 | return; |
147 | } | 146 | } |
148 | 147 | ||
149 | switch ( button->command ) { | 148 | switch ( button->command ) { |
150 | case VolumeUp: emit moreClicked(); return; | 149 | case VolumeUp: emit moreClicked(); return; |
151 | case VolumeDown: emit lessClicked(); return; | 150 | case VolumeDown: emit lessClicked(); return; |
152 | case Back: emit backClicked(); return; | 151 | case Back: emit backClicked(); return; |
153 | case Forward: emit forwardClicked(); return; | 152 | case Forward: emit forwardClicked(); return; |
154 | default: break; | 153 | default: break; |
155 | } | 154 | } |
156 | } | 155 | } |
157 | 156 | ||
158 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) | 157 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) |
159 | { | 158 | { |
160 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 159 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
161 | 160 | ||
162 | if ( !button ) { | 161 | if ( !button ) { |
163 | QWidget::mouseReleaseEvent( event ); | 162 | QWidget::mouseReleaseEvent( event ); |
164 | return; | 163 | return; |
165 | } | 164 | } |
166 | 165 | ||
167 | if ( button->type == ToggleButton ) | 166 | if ( button->type == ToggleButton ) |
168 | toggleButton( *button ); | 167 | toggleButton( *button ); |
169 | 168 | ||
170 | handleCommand( button->command, button->isDown ); | 169 | handleCommand( button->command, button->isDown ); |
171 | } | 170 | } |
172 | 171 | ||
173 | void MediaWidget::makeVisible() | 172 | void MediaWidget::makeVisible() |
174 | { | 173 | { |
175 | } | 174 | } |
176 | 175 | ||
177 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 176 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
178 | { | 177 | { |
179 | switch ( command ) { | 178 | switch ( command ) { |
180 | case Play: mediaPlayerState.togglePaused(); return; | 179 | case Play: mediaPlayerState.togglePaused(); return; |
181 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 180 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
182 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 181 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
183 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 182 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
184 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 183 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
185 | case VolumeUp: emit moreReleased(); return; | 184 | case VolumeUp: emit moreReleased(); return; |
186 | case VolumeDown: emit lessReleased(); return; | 185 | case VolumeDown: emit lessReleased(); return; |
187 | case PlayList: mediaPlayerState.setList(); return; | 186 | case PlayList: mediaPlayerState.setList(); return; |
188 | case Forward: emit forwardReleased(); return; | 187 | case Forward: emit forwardReleased(); return; |
189 | case Back: emit backReleased(); return; | 188 | case Back: emit backReleased(); return; |
190 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; | 189 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; |
191 | default: assert( false ); | 190 | default: assert( false ); |
192 | } | 191 | } |
193 | } | 192 | } |
194 | 193 | ||
195 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 194 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
196 | { | 195 | { |
197 | return ( position.x() > 0 && position.y() > 0 && | 196 | return ( position.x() > 0 && position.y() > 0 && |
198 | position.x() < buttonMask.width() && | 197 | position.x() < buttonMask.width() && |
199 | position.y() < buttonMask.height() && | 198 | position.y() < buttonMask.height() && |
200 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 199 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
201 | } | 200 | } |
202 | 201 | ||
203 | void MediaWidget::paintAllButtons( QPainter &p ) | 202 | void MediaWidget::paintAllButtons( QPainter &p ) |
204 | { | 203 | { |
205 | for ( ButtonVector::const_iterator it = buttons.begin(); | 204 | for ( ButtonVector::const_iterator it = buttons.begin(); |
206 | it != buttons.end(); ++it ) | 205 | it != buttons.end(); ++it ) |
207 | paintButton( p, *it ); | 206 | paintButton( p, *it ); |
208 | } | 207 | } |
209 | 208 | ||
210 | void MediaWidget::paintButton( const Button &button ) | 209 | void MediaWidget::paintButton( const Button &button ) |
211 | { | 210 | { |
212 | QPainter p( this ); | 211 | QPainter p( this ); |
213 | paintButton( p, button ); | 212 | paintButton( p, button ); |
214 | } | 213 | } |
215 | 214 | ||
216 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 215 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
217 | { | 216 | { |
218 | if ( button.isDown ) | 217 | if ( button.isDown ) |
219 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 218 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
220 | else | 219 | else |
221 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 220 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
222 | } | 221 | } |
223 | 222 | ||
224 | void MediaWidget::setToggleButton( Command command, bool down ) | 223 | void MediaWidget::setToggleButton( Command command, bool down ) |
225 | { | 224 | { |
226 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 225 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
227 | if ( it->command == command ) { | 226 | if ( it->command == command ) { |
228 | setToggleButton( *it, down ); | 227 | setToggleButton( *it, down ); |
229 | return; | 228 | return; |
230 | } | 229 | } |
231 | } | 230 | } |
232 | 231 | ||
233 | void MediaWidget::setToggleButton( Button &button, bool down ) | 232 | void MediaWidget::setToggleButton( Button &button, bool down ) |
234 | { | 233 | { |
235 | if ( down != button.isDown ) | 234 | if ( down != button.isDown ) |
236 | toggleButton( button ); | 235 | toggleButton( button ); |
237 | } | 236 | } |
238 | 237 | ||
239 | void MediaWidget::toggleButton( Button &button ) | 238 | void MediaWidget::toggleButton( Button &button ) |
240 | { | 239 | { |
241 | button.isDown = !button.isDown; | 240 | button.isDown = !button.isDown; |
242 | 241 | ||
243 | paintButton( button ); | 242 | paintButton( button ); |
244 | } | 243 | } |
245 | 244 | ||
246 | QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) | 245 | QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) |
247 | { | 246 | { |
248 | QPixmap pix( image.size() ); | 247 | QPixmap pix( image.size() ); |
249 | QPainter p( &pix ); | 248 | QPainter p( &pix ); |
250 | p.drawTiledPixmap( pix.rect(), background, offset ); | 249 | p.drawTiledPixmap( pix.rect(), background, offset ); |
251 | p.drawImage( 0, 0, image ); | 250 | p.drawImage( 0, 0, image ); |
252 | return pix; | 251 | return pix; |
253 | } | 252 | } |
254 | 253 | ||
255 | QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) | 254 | QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) |
256 | { | 255 | { |
257 | QPixmap result( pix ); | 256 | QPixmap result( pix ); |
258 | result.setMask( mask ); | 257 | result.setMask( mask ); |
259 | return result; | 258 | return result; |
260 | } | 259 | } |
261 | 260 | ||
262 | /* vim: et sw=4 ts=4 | 261 | /* vim: et sw=4 ts=4 |
263 | */ | 262 | */ |
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 69e87e7..26d5e15 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -1,163 +1,150 @@ | |||
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 L. Potter <ljp@llornkcor.com> | 4 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; General Public License for more | 20 | ..}^=.= = ; General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = General Public License along with | 24 | -_. . . )=. = General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "playlistwidget.h" | ||
33 | #include "om3u.h" | 32 | #include "om3u.h" |
34 | 33 | ||
35 | #include <qpe/applnk.h> | 34 | |
36 | #include <qpe/qpeapplication.h> | ||
37 | #include <qpe/storage.h> | ||
38 | #include <qpe/mimetype.h> | ||
39 | #include <qpe/global.h> | ||
40 | #include <qpe/resource.h> | ||
41 | |||
42 | #include <qdir.h> | ||
43 | #include <qregexp.h> | ||
44 | #include <qstring.h> | ||
45 | #include <qtextstream.h> | ||
46 | #include <qstringlist.h> | ||
47 | #include <qcstring.h> | ||
48 | 35 | ||
49 | //extern PlayListWidget *playList; | 36 | //extern PlayListWidget *playList; |
50 | 37 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 38 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 39 | : QStringList (){ |
53 | qDebug("<<<<<<<new m3u "+filePath); | 40 | qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 41 | f.setName(filePath); |
55 | f.open(mode); | 42 | f.open(mode); |
56 | } | 43 | } |
57 | 44 | ||
58 | Om3u::~Om3u(){} | 45 | Om3u::~Om3u(){} |
59 | 46 | ||
60 | void Om3u::readM3u() { | 47 | void Om3u::readM3u() { |
61 | // qDebug("<<<<<<reading m3u "+f.name()); | 48 | // qDebug("<<<<<<reading m3u "+f.name()); |
62 | QTextStream t(&f); | 49 | QTextStream t(&f); |
63 | t.setEncoding(QTextStream::UnicodeUTF8); | 50 | t.setEncoding(QTextStream::UnicodeUTF8); |
64 | QString s; | 51 | QString s; |
65 | while ( !t.atEnd() ) { | 52 | while ( !t.atEnd() ) { |
66 | s=t.readLine(); | 53 | s=t.readLine(); |
67 | // qDebug(s); | 54 | // qDebug(s); |
68 | if( s.find( "#", 0, TRUE) == -1 ) { | 55 | if( s.find( "#", 0, TRUE) == -1 ) { |
69 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 56 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
70 | s = s.right( s.length() -2 ); | 57 | s = s.right( s.length() -2 ); |
71 | QFileInfo f( s ); | 58 | QFileInfo f( s ); |
72 | QString name = f.baseName(); | 59 | QString name = f.baseName(); |
73 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 60 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
74 | s=s.replace( QRegExp( "\\" ), "/" ); | 61 | s=s.replace( QRegExp( "\\" ), "/" ); |
75 | append(s); | 62 | append(s); |
76 | // qDebug(s); | 63 | // qDebug(s); |
77 | } else { // is url | 64 | } else { // is url |
78 | QString name; | 65 | QString name; |
79 | name = s; | 66 | name = s; |
80 | append(name); | 67 | append(name); |
81 | } | 68 | } |
82 | } | 69 | } |
83 | } | 70 | } |
84 | } | 71 | } |
85 | 72 | ||
86 | void Om3u::readPls() { //it's a pls file | 73 | void Om3u::readPls() { //it's a pls file |
87 | QTextStream t( &f ); | 74 | QTextStream t( &f ); |
88 | t.setEncoding(QTextStream::UnicodeUTF8); | 75 | t.setEncoding(QTextStream::UnicodeUTF8); |
89 | QString s; | 76 | QString s; |
90 | while ( !t.atEnd() ) { | 77 | while ( !t.atEnd() ) { |
91 | s = t.readLine(); | 78 | s = t.readLine(); |
92 | if( s.left(4) == "File" ) { | 79 | if( s.left(4) == "File" ) { |
93 | s = s.right( s.length() - s.find("=",0,true)-1 ); | 80 | s = s.right( s.length() - s.find("=",0,true)-1 ); |
94 | s = s.stripWhiteSpace(); | 81 | s = s.stripWhiteSpace(); |
95 | s.replace( QRegExp( "%20" )," "); | 82 | s.replace( QRegExp( "%20" )," "); |
96 | // qDebug( "adding " + s + " to playlist" ); | 83 | // qDebug( "adding " + s + " to playlist" ); |
97 | // numberofentries=2 | 84 | // numberofentries=2 |
98 | // File1=http | 85 | // File1=http |
99 | // Title | 86 | // Title |
100 | // Length | 87 | // Length |
101 | // Version | 88 | // Version |
102 | // File2=http | 89 | // File2=http |
103 | s = s.replace( QRegExp( "\\" ), "/" ); | 90 | s = s.replace( QRegExp( "\\" ), "/" ); |
104 | QFileInfo f( s ); | 91 | QFileInfo f( s ); |
105 | QString name = f.baseName(); | 92 | QString name = f.baseName(); |
106 | if( name.left( 4 ) == "http" ) { | 93 | if( name.left( 4 ) == "http" ) { |
107 | name = s.right( s.length() - 7); | 94 | name = s.right( s.length() - 7); |
108 | } else { | 95 | } else { |
109 | name = s; | 96 | name = s; |
110 | } | 97 | } |
111 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 98 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
112 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 99 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
113 | append(s); | 100 | append(s); |
114 | else { //if its a url | 101 | else { //if its a url |
115 | // if( name.right( 1 ).find( '/' ) == -1) { | 102 | // if( name.right( 1 ).find( '/' ) == -1) { |
116 | // s += "/"; | 103 | // s += "/"; |
117 | // } | 104 | // } |
118 | append(s); | 105 | append(s); |
119 | } | 106 | } |
120 | } | 107 | } |
121 | } | 108 | } |
122 | } | 109 | } |
123 | 110 | ||
124 | void Om3u::write() { //writes list to m3u file | 111 | void Om3u::write() { //writes list to m3u file |
125 | QString list; | 112 | QString list; |
126 | QTextStream t(&f); | 113 | QTextStream t(&f); |
127 | t.setEncoding(QTextStream::UnicodeUTF8); | 114 | t.setEncoding(QTextStream::UnicodeUTF8); |
128 | if(count()>0) { | 115 | if(count()>0) { |
129 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 116 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
130 | // qDebug(*it); | 117 | // qDebug(*it); |
131 | t << *it << "\n"; | 118 | t << *it << "\n"; |
132 | } | 119 | } |
133 | } | 120 | } |
134 | // f.close(); | 121 | // f.close(); |
135 | } | 122 | } |
136 | 123 | ||
137 | void Om3u::add(const QString &filePath) { //adds to m3u file | 124 | void Om3u::add(const QString &filePath) { //adds to m3u file |
138 | append(filePath); | 125 | append(filePath); |
139 | } | 126 | } |
140 | 127 | ||
141 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 128 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
142 | QString list, currentFile; | 129 | QString list, currentFile; |
143 | if(count()>0) { | 130 | if(count()>0) { |
144 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 131 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
145 | currentFile=*it; | 132 | currentFile=*it; |
146 | // qDebug(*it); | 133 | // qDebug(*it); |
147 | 134 | ||
148 | if( filePath != currentFile) | 135 | if( filePath != currentFile) |
149 | list += currentFile+"\n"; | 136 | list += currentFile+"\n"; |
150 | } | 137 | } |
151 | f.writeBlock( list, list.length() ); | 138 | f.writeBlock( list, list.length() ); |
152 | } | 139 | } |
153 | } | 140 | } |
154 | 141 | ||
155 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file | 142 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file |
156 | f.close(); | 143 | f.close(); |
157 | f.remove(); | 144 | f.remove(); |
158 | 145 | ||
159 | } | 146 | } |
160 | 147 | ||
161 | void Om3u::close() { //closes m3u file | 148 | void Om3u::close() { //closes m3u file |
162 | f.close(); | 149 | f.close(); |
163 | } | 150 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 2019b3a..015896f 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp | |||
@@ -1,214 +1,206 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #include <qpe/applnk.h> | ||
21 | #include <qpe/resource.h> | ||
22 | #include <qpe/config.h> | ||
23 | 20 | ||
24 | #include <qpainter.h> | ||
25 | #include <qimage.h> | ||
26 | #include <qheader.h> | 21 | #include <qheader.h> |
27 | #include <qlistview.h> | ||
28 | #include <qlist.h> | ||
29 | #include <qpixmap.h> | ||
30 | 22 | ||
31 | #include "playlistselection.h" | 23 | #include "playlistselection.h" |
32 | 24 | ||
33 | #include <stdlib.h> | 25 | #include <stdlib.h> |
34 | 26 | ||
35 | class PlayListSelectionItem : public QListViewItem { | 27 | class PlayListSelectionItem : public QListViewItem { |
36 | public: | 28 | public: |
37 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 29 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
38 | setText( 0, f->name() ); | 30 | setText( 0, f->name() ); |
39 | setPixmap( 0, f->pixmap() ); | 31 | setPixmap( 0, f->pixmap() ); |
40 | } | 32 | } |
41 | 33 | ||
42 | ~PlayListSelectionItem() { | 34 | ~PlayListSelectionItem() { |
43 | }; | 35 | }; |
44 | 36 | ||
45 | const DocLnk *file() const { return fl; } | 37 | const DocLnk *file() const { return fl; } |
46 | 38 | ||
47 | private: | 39 | private: |
48 | const DocLnk *fl; | 40 | const DocLnk *fl; |
49 | }; | 41 | }; |
50 | 42 | ||
51 | 43 | ||
52 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 44 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
53 | : QListView( parent, name ) | 45 | : QListView( parent, name ) |
54 | { | 46 | { |
55 | // qDebug("starting playlistselector"); | 47 | // qDebug("starting playlistselector"); |
56 | // #ifdef USE_PLAYLIST_BACKGROUND | 48 | // #ifdef USE_PLAYLIST_BACKGROUND |
57 | // setStaticBackground( TRUE ); | 49 | // setStaticBackground( TRUE ); |
58 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 50 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
59 | 51 | ||
60 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 52 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
61 | // #endif | 53 | // #endif |
62 | // addColumn("Title",236); | 54 | // addColumn("Title",236); |
63 | // setAllColumnsShowFocus( TRUE ); | 55 | // setAllColumnsShowFocus( TRUE ); |
64 | addColumn( tr( "Playlist Selection" ) ); | 56 | addColumn( tr( "Playlist Selection" ) ); |
65 | header()->hide(); | 57 | header()->hide(); |
66 | setSorting( -1, FALSE ); | 58 | setSorting( -1, FALSE ); |
67 | } | 59 | } |
68 | 60 | ||
69 | 61 | ||
70 | PlayListSelection::~PlayListSelection() { | 62 | PlayListSelection::~PlayListSelection() { |
71 | } | 63 | } |
72 | 64 | ||
73 | 65 | ||
74 | // #ifdef USE_PLAYLIST_BACKGROUND | 66 | // #ifdef USE_PLAYLIST_BACKGROUND |
75 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 67 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
76 | // qDebug("drawBackground"); | 68 | // qDebug("drawBackground"); |
77 | p->fillRect( r, QBrush( white ) ); | 69 | p->fillRect( r, QBrush( white ) ); |
78 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 70 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
79 | // if ( !logo.isNull() ) | 71 | // if ( !logo.isNull() ) |
80 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 72 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
81 | } | 73 | } |
82 | // #endif | 74 | // #endif |
83 | 75 | ||
84 | 76 | ||
85 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 77 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
86 | if ( event->state() == QMouseEvent::LeftButton ) { | 78 | if ( event->state() == QMouseEvent::LeftButton ) { |
87 | QListViewItem *currentItem = selectedItem(); | 79 | QListViewItem *currentItem = selectedItem(); |
88 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 80 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
89 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 81 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
90 | moveSelectedUp(); | 82 | moveSelectedUp(); |
91 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 83 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
92 | moveSelectedDown(); | 84 | moveSelectedDown(); |
93 | } | 85 | } |
94 | } | 86 | } |
95 | 87 | ||
96 | 88 | ||
97 | const DocLnk *PlayListSelection::current() { | 89 | const DocLnk *PlayListSelection::current() { |
98 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 90 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
99 | if ( item ) | 91 | if ( item ) |
100 | return item->file(); | 92 | return item->file(); |
101 | return NULL; | 93 | return NULL; |
102 | } | 94 | } |
103 | 95 | ||
104 | 96 | ||
105 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 97 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
106 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 98 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
107 | QListViewItem *current = selectedItem(); | 99 | QListViewItem *current = selectedItem(); |
108 | if ( current ) | 100 | if ( current ) |
109 | item->moveItem( current ); | 101 | item->moveItem( current ); |
110 | setSelected( item, TRUE ); | 102 | setSelected( item, TRUE ); |
111 | ensureItemVisible( selectedItem() ); | 103 | ensureItemVisible( selectedItem() ); |
112 | } | 104 | } |
113 | 105 | ||
114 | 106 | ||
115 | void PlayListSelection::removeSelected() { | 107 | void PlayListSelection::removeSelected() { |
116 | QListViewItem *item = selectedItem(); | 108 | QListViewItem *item = selectedItem(); |
117 | delete item; | 109 | delete item; |
118 | setSelected( currentItem(), TRUE ); | 110 | setSelected( currentItem(), TRUE ); |
119 | ensureItemVisible( selectedItem() ); | 111 | ensureItemVisible( selectedItem() ); |
120 | } | 112 | } |
121 | 113 | ||
122 | 114 | ||
123 | void PlayListSelection::moveSelectedUp() { | 115 | void PlayListSelection::moveSelectedUp() { |
124 | QListViewItem *item = selectedItem(); | 116 | QListViewItem *item = selectedItem(); |
125 | if ( item && item->itemAbove() ) | 117 | if ( item && item->itemAbove() ) |
126 | item->itemAbove()->moveItem( item ); | 118 | item->itemAbove()->moveItem( item ); |
127 | ensureItemVisible( selectedItem() ); | 119 | ensureItemVisible( selectedItem() ); |
128 | } | 120 | } |
129 | 121 | ||
130 | 122 | ||
131 | void PlayListSelection::moveSelectedDown() { | 123 | void PlayListSelection::moveSelectedDown() { |
132 | QListViewItem *item = selectedItem(); | 124 | QListViewItem *item = selectedItem(); |
133 | if ( item && item->itemBelow() ) | 125 | if ( item && item->itemBelow() ) |
134 | item->moveItem( item->itemBelow() ); | 126 | item->moveItem( item->itemBelow() ); |
135 | ensureItemVisible( selectedItem() ); | 127 | ensureItemVisible( selectedItem() ); |
136 | } | 128 | } |
137 | 129 | ||
138 | 130 | ||
139 | bool PlayListSelection::prev() { | 131 | bool PlayListSelection::prev() { |
140 | QListViewItem *item = selectedItem(); | 132 | QListViewItem *item = selectedItem(); |
141 | if ( item && item->itemAbove() ) | 133 | if ( item && item->itemAbove() ) |
142 | setSelected( item->itemAbove(), TRUE ); | 134 | setSelected( item->itemAbove(), TRUE ); |
143 | else | 135 | else |
144 | return FALSE; | 136 | return FALSE; |
145 | ensureItemVisible( selectedItem() ); | 137 | ensureItemVisible( selectedItem() ); |
146 | return TRUE; | 138 | return TRUE; |
147 | } | 139 | } |
148 | 140 | ||
149 | bool PlayListSelection::next() { | 141 | bool PlayListSelection::next() { |
150 | QListViewItem *item = selectedItem(); | 142 | QListViewItem *item = selectedItem(); |
151 | if ( item && item->itemBelow() ) | 143 | if ( item && item->itemBelow() ) |
152 | setSelected( item->itemBelow(), TRUE ); | 144 | setSelected( item->itemBelow(), TRUE ); |
153 | else | 145 | else |
154 | return FALSE; | 146 | return FALSE; |
155 | ensureItemVisible( selectedItem() ); | 147 | ensureItemVisible( selectedItem() ); |
156 | return TRUE; | 148 | return TRUE; |
157 | } | 149 | } |
158 | 150 | ||
159 | 151 | ||
160 | bool PlayListSelection::first() { | 152 | bool PlayListSelection::first() { |
161 | QListViewItem *item = firstChild(); | 153 | QListViewItem *item = firstChild(); |
162 | if ( item ) | 154 | if ( item ) |
163 | setSelected( item, TRUE ); | 155 | setSelected( item, TRUE ); |
164 | else | 156 | else |
165 | return FALSE; | 157 | return FALSE; |
166 | ensureItemVisible( selectedItem() ); | 158 | ensureItemVisible( selectedItem() ); |
167 | return TRUE; | 159 | return TRUE; |
168 | } | 160 | } |
169 | 161 | ||
170 | 162 | ||
171 | bool PlayListSelection::last() { | 163 | bool PlayListSelection::last() { |
172 | QListViewItem *prevItem = NULL; | 164 | QListViewItem *prevItem = NULL; |
173 | QListViewItem *item = firstChild(); | 165 | QListViewItem *item = firstChild(); |
174 | while ( ( item = item->nextSibling() ) ) | 166 | while ( ( item = item->nextSibling() ) ) |
175 | prevItem = item; | 167 | prevItem = item; |
176 | if ( prevItem ) | 168 | if ( prevItem ) |
177 | setSelected( prevItem, TRUE ); | 169 | setSelected( prevItem, TRUE ); |
178 | else | 170 | else |
179 | return FALSE; | 171 | return FALSE; |
180 | ensureItemVisible( selectedItem() ); | 172 | ensureItemVisible( selectedItem() ); |
181 | return TRUE; | 173 | return TRUE; |
182 | } | 174 | } |
183 | 175 | ||
184 | void PlayListSelection::unSelect() | 176 | void PlayListSelection::unSelect() |
185 | { | 177 | { |
186 | //QListViewItem *item = selectedItem(); | 178 | //QListViewItem *item = selectedItem(); |
187 | setSelected( currentItem(), FALSE); | 179 | setSelected( currentItem(), FALSE); |
188 | } | 180 | } |
189 | 181 | ||
190 | void PlayListSelection::writeCurrent( Config& cfg ) { | 182 | void PlayListSelection::writeCurrent( Config& cfg ) { |
191 | cfg.setGroup("PlayList"); | 183 | cfg.setGroup("PlayList"); |
192 | QListViewItem *item = selectedItem(); | 184 | QListViewItem *item = selectedItem(); |
193 | if ( item ) | 185 | if ( item ) |
194 | cfg.writeEntry("current", item->text(0) ); | 186 | cfg.writeEntry("current", item->text(0) ); |
195 | qDebug(item->text(0)); | 187 | qDebug(item->text(0)); |
196 | 188 | ||
197 | } | 189 | } |
198 | 190 | ||
199 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 191 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
200 | 192 | ||
201 | unSelect(); | 193 | unSelect(); |
202 | QListViewItemIterator it( this ); | 194 | QListViewItemIterator it( this ); |
203 | for ( ; it.current(); ++it ) { | 195 | for ( ; it.current(); ++it ) { |
204 | // qDebug( it.current()->text(0)); | 196 | // qDebug( it.current()->text(0)); |
205 | if( strk == it.current()->text(0)) { | 197 | if( strk == it.current()->text(0)) { |
206 | // qDebug( "We have a match "+strk); | 198 | // qDebug( "We have a match "+strk); |
207 | setSelected( it.current(), TRUE); | 199 | setSelected( it.current(), TRUE); |
208 | ensureItemVisible( it.current() ); | 200 | ensureItemVisible( it.current() ); |
209 | return; | 201 | return; |
210 | } | 202 | } |
211 | } | 203 | } |
212 | // setSelected( item, TRUE ); | 204 | // setSelected( item, TRUE ); |
213 | // ensureItemVisible( selectedItem() ); | 205 | // ensureItemVisible( selectedItem() ); |
214 | } | 206 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 0a84268..84aba55 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1043 +1,1042 @@ | |||
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 <opie/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 "mediaplayerstate.h" | ||
44 | #include "inputDialog.h" | 43 | #include "inputDialog.h" |
45 | #include "om3u.h" | 44 | #include "om3u.h" |
46 | #include "playlistfileview.h" | 45 | #include "playlistfileview.h" |
47 | 46 | ||
48 | //only needed for the random play | 47 | //only needed for the random play |
49 | #include <assert.h> | 48 | #include <assert.h> |
50 | 49 | ||
51 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 50 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
52 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 51 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
53 | { | 52 | { |
54 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 53 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
55 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 54 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
56 | 55 | ||
57 | 56 | ||
58 | 57 | ||
59 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 58 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
60 | "opieplayer2/add_to_playlist", | 59 | "opieplayer2/add_to_playlist", |
61 | this , SLOT(addSelected() ) ); | 60 | this , SLOT(addSelected() ) ); |
62 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 61 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
63 | "opieplayer2/remove_from_playlist", | 62 | "opieplayer2/remove_from_playlist", |
64 | this , SLOT(removeSelected() ) ); | 63 | this , SLOT(removeSelected() ) ); |
65 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 64 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
66 | this , SLOT( btnPlay(bool) ), TRUE ); | 65 | this , SLOT( btnPlay(bool) ), TRUE ); |
67 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 66 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
68 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); | 67 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); |
69 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 68 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
70 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); | 69 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); |
71 | 70 | ||
72 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 71 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
73 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 72 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
74 | this, SLOT( addAllMusicToList() ) ); | 73 | this, SLOT( addAllMusicToList() ) ); |
75 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 74 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
76 | this, SLOT( addAllVideoToList() ) ); | 75 | this, SLOT( addAllVideoToList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 76 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
78 | this, SLOT( addAllToList() ) ); | 77 | this, SLOT( addAllToList() ) ); |
79 | pmPlayList->insertSeparator(-1); | 78 | pmPlayList->insertSeparator(-1); |
80 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 79 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
81 | this,SLOT( openFile() ) ); | 80 | this,SLOT( openFile() ) ); |
82 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 81 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
83 | this,SLOT( openURL() ) ); | 82 | this,SLOT( openURL() ) ); |
84 | pmPlayList->insertSeparator(-1); | 83 | pmPlayList->insertSeparator(-1); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 85 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 86 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 87 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
89 | audioView, SLOT( scanFiles() ) ); | 88 | audioView, SLOT( scanFiles() ) ); |
90 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 89 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
91 | videoView, SLOT( scanFiles() ) ); | 90 | videoView, SLOT( scanFiles() ) ); |
92 | 91 | ||
93 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 92 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
94 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 93 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
95 | 94 | ||
96 | Config cfg( "OpiePlayer" ); | 95 | Config cfg( "OpiePlayer" ); |
97 | bool b= cfg.readBoolEntry("FullScreen", 0); | 96 | bool b= cfg.readBoolEntry("FullScreen", 0); |
98 | mediaPlayerState->setFullscreen( b ); | 97 | mediaPlayerState->setFullscreen( b ); |
99 | pmView->setItemChecked( -16, b ); | 98 | pmView->setItemChecked( -16, b ); |
100 | 99 | ||
101 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 100 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
102 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 101 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
103 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 102 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
104 | d->selectedFiles, SLOT(removeSelected() ) ); | 103 | d->selectedFiles, SLOT(removeSelected() ) ); |
105 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 104 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
106 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 105 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
107 | QVBox *stretch2 = new QVBox( vbox1 ); | 106 | QVBox *stretch2 = new QVBox( vbox1 ); |
108 | 107 | ||
109 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 108 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
110 | SLOT( deletePlaylist() ) ); | 109 | SLOT( deletePlaylist() ) ); |
111 | connect( pmView, SIGNAL( activated(int) ), | 110 | connect( pmView, SIGNAL( activated(int) ), |
112 | this, SLOT( pmViewActivated(int) ) ); | 111 | this, SLOT( pmViewActivated(int) ) ); |
113 | connect( skinsMenu, SIGNAL( activated(int) ) , | 112 | connect( skinsMenu, SIGNAL( activated(int) ) , |
114 | this, SLOT( skinsMenuActivated(int) ) ); | 113 | this, SLOT( skinsMenuActivated(int) ) ); |
115 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 114 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
116 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 115 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
117 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 116 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
118 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 117 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
119 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), | 118 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), |
120 | this,SLOT( playIt(QListViewItem*) ) ); | 119 | this,SLOT( playIt(QListViewItem*) ) ); |
121 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), | 120 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), |
122 | this, SLOT( addToSelection(QListViewItem*) ) ); | 121 | this, SLOT( addToSelection(QListViewItem*) ) ); |
123 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 122 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
124 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 123 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
125 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), | 124 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), |
126 | this,SLOT( playIt(QListViewItem*) ) ); | 125 | this,SLOT( playIt(QListViewItem*) ) ); |
127 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), | 126 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), |
128 | this, SLOT( addToSelection(QListViewItem*) ) ); | 127 | this, SLOT( addToSelection(QListViewItem*) ) ); |
129 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), | 128 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), |
130 | this, SLOT( loadList(const DocLnk&) ) ); | 129 | this, SLOT( loadList(const DocLnk&) ) ); |
131 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 130 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
132 | this, SLOT( tabChanged(QWidget*) ) ); | 131 | this, SLOT( tabChanged(QWidget*) ) ); |
133 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), | 132 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), |
134 | d->tbPlay, SLOT( setOn(bool) ) ); | 133 | d->tbPlay, SLOT( setOn(bool) ) ); |
135 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), | 134 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
136 | d->tbLoop, SLOT( setOn(bool) ) ); | 135 | d->tbLoop, SLOT( setOn(bool) ) ); |
137 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), | 136 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
138 | d->tbShuffle, SLOT( setOn(bool) ) ); | 137 | d->tbShuffle, SLOT( setOn(bool) ) ); |
139 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), | 138 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
140 | this, SLOT( playIt(QListViewItem*) ) ); | 139 | this, SLOT( playIt(QListViewItem*) ) ); |
141 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), | 140 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
142 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); | 141 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
143 | 142 | ||
144 | connect( this, SIGNAL(skinSelected() ), | 143 | connect( this, SIGNAL(skinSelected() ), |
145 | m_mp, SLOT( reloadSkins() ) ); | 144 | m_mp, SLOT( reloadSkins() ) ); |
146 | 145 | ||
147 | // see which skins are installed | 146 | // see which skins are installed |
148 | populateSkinsMenu(); | 147 | populateSkinsMenu(); |
149 | initializeStates(); | 148 | initializeStates(); |
150 | 149 | ||
151 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); | 150 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); |
152 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 151 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
153 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 152 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
154 | 153 | ||
155 | 154 | ||
156 | cfg.setGroup("PlayList"); | 155 | cfg.setGroup("PlayList"); |
157 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 156 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
158 | loadList(DocLnk( currentPlaylist ) ); | 157 | loadList(DocLnk( currentPlaylist ) ); |
159 | 158 | ||
160 | tabWidget->showPage( playListTab ); | 159 | tabWidget->showPage( playListTab ); |
161 | } | 160 | } |
162 | 161 | ||
163 | 162 | ||
164 | PlayListWidget::~PlayListWidget() { | 163 | PlayListWidget::~PlayListWidget() { |
165 | delete d; | 164 | delete d; |
166 | delete m_mp; | 165 | delete m_mp; |
167 | } | 166 | } |
168 | 167 | ||
169 | 168 | ||
170 | void PlayListWidget::initializeStates() { | 169 | void PlayListWidget::initializeStates() { |
171 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 170 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
172 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 171 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
173 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 172 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
174 | d->playListFrame->show(); | 173 | d->playListFrame->show(); |
175 | } | 174 | } |
176 | 175 | ||
177 | void PlayListWidget::writeDefaultPlaylist() { | 176 | void PlayListWidget::writeDefaultPlaylist() { |
178 | 177 | ||
179 | Config config( "OpiePlayer" ); | 178 | Config config( "OpiePlayer" ); |
180 | config.setGroup( "PlayList" ); | 179 | config.setGroup( "PlayList" ); |
181 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 180 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
182 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 181 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
183 | if( currentString == filename) { | 182 | if( currentString == filename) { |
184 | Om3u *m3uList; | 183 | Om3u *m3uList; |
185 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 184 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
186 | if( d->selectedFiles->first() ) { | 185 | if( d->selectedFiles->first() ) { |
187 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 186 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
188 | do { | 187 | do { |
189 | // qDebug(d->selectedFiles->current()->file()); | 188 | // qDebug(d->selectedFiles->current()->file()); |
190 | m3uList->add( d->selectedFiles->current()->file() ); | 189 | m3uList->add( d->selectedFiles->current()->file() ); |
191 | } | 190 | } |
192 | while ( d->selectedFiles->next() ); | 191 | while ( d->selectedFiles->next() ); |
193 | 192 | ||
194 | m3uList->write(); | 193 | m3uList->write(); |
195 | m3uList->close(); | 194 | m3uList->close(); |
196 | delete m3uList; | 195 | delete m3uList; |
197 | 196 | ||
198 | } | 197 | } |
199 | } | 198 | } |
200 | } | 199 | } |
201 | 200 | ||
202 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 201 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
203 | d->setDocumentUsed = FALSE; | 202 | d->setDocumentUsed = FALSE; |
204 | if( QFileInfo( lnk.file() ).exists() || | 203 | if( QFileInfo( lnk.file() ).exists() || |
205 | lnk.file().left(4) == "http" ) { | 204 | lnk.file().left(4) == "http" ) { |
206 | d->selectedFiles->addToSelection( lnk ); | 205 | d->selectedFiles->addToSelection( lnk ); |
207 | } | 206 | } |
208 | // writeCurrentM3u(); | 207 | // writeCurrentM3u(); |
209 | } | 208 | } |
210 | 209 | ||
211 | 210 | ||
212 | void PlayListWidget::clearList() { | 211 | void PlayListWidget::clearList() { |
213 | while ( first() ) { | 212 | while ( first() ) { |
214 | d->selectedFiles->removeSelected(); | 213 | d->selectedFiles->removeSelected(); |
215 | } | 214 | } |
216 | Config cfg( "OpiePlayer" ); | 215 | Config cfg( "OpiePlayer" ); |
217 | cfg.setGroup("PlayList"); | 216 | cfg.setGroup("PlayList"); |
218 | cfg.writeEntry("CurrentPlaylist","default"); | 217 | cfg.writeEntry("CurrentPlaylist","default"); |
219 | setCaption("OpiePlayer"); | 218 | setCaption("OpiePlayer"); |
220 | } | 219 | } |
221 | 220 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 221 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 222 | switch (mouse) { |
224 | case LeftButton: | 223 | case LeftButton: |
225 | break; | 224 | break; |
226 | case RightButton: | 225 | case RightButton: |
227 | { | 226 | { |
228 | QPopupMenu m; | 227 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 228 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 229 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 230 | m.exec( QCursor::pos() ); |
232 | } | 231 | } |
233 | break; | 232 | break; |
234 | } | 233 | } |
235 | } | 234 | } |
236 | 235 | ||
237 | 236 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 237 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 238 | switch (mouse) { |
240 | case LeftButton: | 239 | case LeftButton: |
241 | break; | 240 | break; |
242 | case RightButton: | 241 | case RightButton: |
243 | { | 242 | { |
244 | QPopupMenu m; | 243 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 244 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 245 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 246 | m.exec( QCursor::pos() ); |
248 | } | 247 | } |
249 | break; | 248 | break; |
250 | } | 249 | } |
251 | } | 250 | } |
252 | 251 | ||
253 | 252 | ||
254 | void PlayListWidget::addAllToList() { | 253 | void PlayListWidget::addAllToList() { |
255 | 254 | ||
256 | 255 | ||
257 | audioView->populateView(); | 256 | audioView->populateView(); |
258 | 257 | ||
259 | QListViewItemIterator audioIt( audioView ); | 258 | QListViewItemIterator audioIt( audioView ); |
260 | DocLnk lnk; | 259 | DocLnk lnk; |
261 | QString filename; | 260 | QString filename; |
262 | // iterate through all items of the listview | 261 | // iterate through all items of the listview |
263 | for ( ; audioIt.current(); ++audioIt ) { | 262 | for ( ; audioIt.current(); ++audioIt ) { |
264 | filename = audioIt.current()->text(3); | 263 | filename = audioIt.current()->text(3); |
265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 264 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
266 | lnk.setFile( filename ); //sets file name | 265 | lnk.setFile( filename ); //sets file name |
267 | d->selectedFiles->addToSelection( lnk); | 266 | d->selectedFiles->addToSelection( lnk); |
268 | } | 267 | } |
269 | 268 | ||
270 | videoView->populateView(); | 269 | videoView->populateView(); |
271 | 270 | ||
272 | QListViewItemIterator videoIt( videoView ); | 271 | QListViewItemIterator videoIt( videoView ); |
273 | for ( ; videoIt.current(); ++videoIt ) { | 272 | for ( ; videoIt.current(); ++videoIt ) { |
274 | filename = videoIt.current()->text(3); | 273 | filename = videoIt.current()->text(3); |
275 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 274 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
276 | lnk.setFile( filename ); //sets file name | 275 | lnk.setFile( filename ); //sets file name |
277 | d->selectedFiles->addToSelection( lnk); | 276 | d->selectedFiles->addToSelection( lnk); |
278 | } | 277 | } |
279 | 278 | ||
280 | tabWidget->setCurrentPage(0); | 279 | tabWidget->setCurrentPage(0); |
281 | 280 | ||
282 | writeCurrentM3u(); | 281 | writeCurrentM3u(); |
283 | d->selectedFiles->first(); | 282 | d->selectedFiles->first(); |
284 | } | 283 | } |
285 | 284 | ||
286 | 285 | ||
287 | void PlayListWidget::addAllMusicToList() { | 286 | void PlayListWidget::addAllMusicToList() { |
288 | 287 | ||
289 | audioView->populateView(); | 288 | audioView->populateView(); |
290 | 289 | ||
291 | QListViewItemIterator audioIt( audioView ); | 290 | QListViewItemIterator audioIt( audioView ); |
292 | DocLnk lnk; | 291 | DocLnk lnk; |
293 | QString filename; | 292 | QString filename; |
294 | // iterate through all items of the listview | 293 | // iterate through all items of the listview |
295 | for ( ; audioIt.current(); ++audioIt ) { | 294 | for ( ; audioIt.current(); ++audioIt ) { |
296 | filename = audioIt.current()->text(3); | 295 | filename = audioIt.current()->text(3); |
297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 296 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
298 | lnk.setFile( filename ); //sets file name | 297 | lnk.setFile( filename ); //sets file name |
299 | d->selectedFiles->addToSelection( lnk); | 298 | d->selectedFiles->addToSelection( lnk); |
300 | } | 299 | } |
301 | 300 | ||
302 | tabWidget->setCurrentPage(0); | 301 | tabWidget->setCurrentPage(0); |
303 | writeCurrentM3u(); | 302 | writeCurrentM3u(); |
304 | d->selectedFiles->first(); | 303 | d->selectedFiles->first(); |
305 | } | 304 | } |
306 | 305 | ||
307 | 306 | ||
308 | void PlayListWidget::addAllVideoToList() { | 307 | void PlayListWidget::addAllVideoToList() { |
309 | 308 | ||
310 | videoView->populateView(); | 309 | videoView->populateView(); |
311 | 310 | ||
312 | QListViewItemIterator videoIt( videoView ); | 311 | QListViewItemIterator videoIt( videoView ); |
313 | DocLnk lnk; | 312 | DocLnk lnk; |
314 | QString filename; | 313 | QString filename; |
315 | for ( ; videoIt.current(); ++videoIt ) { | 314 | for ( ; videoIt.current(); ++videoIt ) { |
316 | filename = videoIt.current()->text(3); | 315 | filename = videoIt.current()->text(3); |
317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 316 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
318 | lnk.setFile( filename ); //sets file name | 317 | lnk.setFile( filename ); //sets file name |
319 | d->selectedFiles->addToSelection( lnk); | 318 | d->selectedFiles->addToSelection( lnk); |
320 | } | 319 | } |
321 | tabWidget->setCurrentPage(0); | 320 | tabWidget->setCurrentPage(0); |
322 | writeCurrentM3u(); | 321 | writeCurrentM3u(); |
323 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
324 | } | 323 | } |
325 | 324 | ||
326 | 325 | ||
327 | void PlayListWidget::setDocument( const QString& fileref ) { | 326 | void PlayListWidget::setDocument( const QString& fileref ) { |
328 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 327 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
329 | fromSetDocument = TRUE; | 328 | fromSetDocument = TRUE; |
330 | QFileInfo fileInfo(fileref); | 329 | QFileInfo fileInfo(fileref); |
331 | 330 | ||
332 | if ( !fileInfo.exists() ) { | 331 | if ( !fileInfo.exists() ) { |
333 | QMessageBox::warning( this, tr( "Invalid File" ), | 332 | QMessageBox::warning( this, tr( "Invalid File" ), |
334 | tr( "There was a problem in getting the file." ) ); | 333 | tr( "There was a problem in getting the file." ) ); |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | 336 | ||
338 | clearList(); | 337 | clearList(); |
339 | QString extension = fileInfo.extension(false); | 338 | QString extension = fileInfo.extension(false); |
340 | 339 | ||
341 | if( extension.find( "m3u", 0, false) != -1 | 340 | if( extension.find( "m3u", 0, false) != -1 |
342 | || extension.find( "pls", 0, false) != -1 ) { | 341 | || extension.find( "pls", 0, false) != -1 ) { |
343 | readListFromFile( fileref ); | 342 | readListFromFile( fileref ); |
344 | } else { | 343 | } else { |
345 | clearList(); | 344 | clearList(); |
346 | DocLnk lnk; | 345 | DocLnk lnk; |
347 | lnk.setName( fileInfo.baseName() ); //sets name | 346 | lnk.setName( fileInfo.baseName() ); //sets name |
348 | lnk.setFile( fileref ); //sets file name | 347 | lnk.setFile( fileref ); //sets file name |
349 | addToSelection( lnk ); | 348 | addToSelection( lnk ); |
350 | writeCurrentM3u(); | 349 | writeCurrentM3u(); |
351 | 350 | ||
352 | d->setDocumentUsed = TRUE; | 351 | d->setDocumentUsed = TRUE; |
353 | mediaPlayerState->setPlaying( FALSE ); | 352 | mediaPlayerState->setPlaying( FALSE ); |
354 | mediaPlayerState->setPlaying( TRUE ); | 353 | mediaPlayerState->setPlaying( TRUE ); |
355 | } | 354 | } |
356 | } | 355 | } |
357 | 356 | ||
358 | 357 | ||
359 | void PlayListWidget::useSelectedDocument() { | 358 | void PlayListWidget::useSelectedDocument() { |
360 | d->setDocumentUsed = FALSE; | 359 | d->setDocumentUsed = FALSE; |
361 | } | 360 | } |
362 | 361 | ||
363 | 362 | ||
364 | const DocLnk *PlayListWidget::current() const { // this is fugly | 363 | const DocLnk *PlayListWidget::current() const { // this is fugly |
365 | assert( currentTab() == CurrentPlayList ); | 364 | assert( currentTab() == CurrentPlayList ); |
366 | 365 | ||
367 | const DocLnk *lnk = d->selectedFiles->current(); | 366 | const DocLnk *lnk = d->selectedFiles->current(); |
368 | if ( !lnk ) { | 367 | if ( !lnk ) { |
369 | d->selectedFiles->first(); | 368 | d->selectedFiles->first(); |
370 | lnk = d->selectedFiles->current(); | 369 | lnk = d->selectedFiles->current(); |
371 | } | 370 | } |
372 | assert( lnk ); | 371 | assert( lnk ); |
373 | return lnk; | 372 | return lnk; |
374 | } | 373 | } |
375 | 374 | ||
376 | 375 | ||
377 | bool PlayListWidget::prev() { | 376 | bool PlayListWidget::prev() { |
378 | if ( mediaPlayerState->isShuffled() ) { | 377 | if ( mediaPlayerState->isShuffled() ) { |
379 | const DocLnk *cur = current(); | 378 | const DocLnk *cur = current(); |
380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 379 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
381 | for ( int i = 0; i < j; i++ ) { | 380 | for ( int i = 0; i < j; i++ ) { |
382 | if ( !d->selectedFiles->next() ) | 381 | if ( !d->selectedFiles->next() ) |
383 | d->selectedFiles->first(); | 382 | d->selectedFiles->first(); |
384 | } | 383 | } |
385 | if ( cur == current() ) | 384 | if ( cur == current() ) |
386 | if ( !d->selectedFiles->next() ) { | 385 | if ( !d->selectedFiles->next() ) { |
387 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
388 | } | 387 | } |
389 | return TRUE; | 388 | return TRUE; |
390 | } else { | 389 | } else { |
391 | if ( !d->selectedFiles->prev() ) { | 390 | if ( !d->selectedFiles->prev() ) { |
392 | if ( mediaPlayerState->isLooping() ) { | 391 | if ( mediaPlayerState->isLooping() ) { |
393 | return d->selectedFiles->last(); | 392 | return d->selectedFiles->last(); |
394 | } else { | 393 | } else { |
395 | return FALSE; | 394 | return FALSE; |
396 | } | 395 | } |
397 | } | 396 | } |
398 | return TRUE; | 397 | return TRUE; |
399 | } | 398 | } |
400 | } | 399 | } |
401 | 400 | ||
402 | 401 | ||
403 | bool PlayListWidget::next() { | 402 | bool PlayListWidget::next() { |
404 | //qDebug("<<<<<<<<<<<<next()"); | 403 | //qDebug("<<<<<<<<<<<<next()"); |
405 | if ( mediaPlayerState->isShuffled() ) { | 404 | if ( mediaPlayerState->isShuffled() ) { |
406 | return prev(); | 405 | return prev(); |
407 | } else { | 406 | } else { |
408 | if ( !d->selectedFiles->next() ) { | 407 | if ( !d->selectedFiles->next() ) { |
409 | if ( mediaPlayerState->isLooping() ) { | 408 | if ( mediaPlayerState->isLooping() ) { |
410 | return d->selectedFiles->first(); | 409 | return d->selectedFiles->first(); |
411 | } else { | 410 | } else { |
412 | return FALSE; | 411 | return FALSE; |
413 | } | 412 | } |
414 | } | 413 | } |
415 | return TRUE; | 414 | return TRUE; |
416 | } | 415 | } |
417 | } | 416 | } |
418 | 417 | ||
419 | 418 | ||
420 | bool PlayListWidget::first() { | 419 | bool PlayListWidget::first() { |
421 | return d->selectedFiles->first(); | 420 | return d->selectedFiles->first(); |
422 | } | 421 | } |
423 | 422 | ||
424 | 423 | ||
425 | bool PlayListWidget::last() { | 424 | bool PlayListWidget::last() { |
426 | return d->selectedFiles->last(); | 425 | return d->selectedFiles->last(); |
427 | } | 426 | } |
428 | 427 | ||
429 | 428 | ||
430 | void PlayListWidget::saveList() { | 429 | void PlayListWidget::saveList() { |
431 | writem3u(); | 430 | writem3u(); |
432 | } | 431 | } |
433 | 432 | ||
434 | 433 | ||
435 | void PlayListWidget::loadList( const DocLnk & lnk) { | 434 | void PlayListWidget::loadList( const DocLnk & lnk) { |
436 | QString name = lnk.name(); | 435 | QString name = lnk.name(); |
437 | 436 | ||
438 | if( name.length()>0) { | 437 | if( name.length()>0) { |
439 | setCaption("OpiePlayer: "+name); | 438 | setCaption("OpiePlayer: "+name); |
440 | clearList(); | 439 | clearList(); |
441 | readListFromFile(lnk.file()); | 440 | readListFromFile(lnk.file()); |
442 | tabWidget->setCurrentPage(0); | 441 | tabWidget->setCurrentPage(0); |
443 | } | 442 | } |
444 | } | 443 | } |
445 | 444 | ||
446 | void PlayListWidget::addSelected() { | 445 | void PlayListWidget::addSelected() { |
447 | assert( inFileListMode() ); | 446 | assert( inFileListMode() ); |
448 | 447 | ||
449 | QListViewItemIterator it( currentFileListView ); | 448 | QListViewItemIterator it( currentFileListView ); |
450 | for ( ; it.current(); ++it ) | 449 | for ( ; it.current(); ++it ) |
451 | if ( it.current()->isSelected() ) { | 450 | if ( it.current()->isSelected() ) { |
452 | QString filename = it.current()->text(3); | 451 | QString filename = it.current()->text(3); |
453 | 452 | ||
454 | DocLnk lnk; | 453 | DocLnk lnk; |
455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 454 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
456 | lnk.setFile( filename ); //sets file name | 455 | lnk.setFile( filename ); //sets file name |
457 | 456 | ||
458 | d->selectedFiles->addToSelection( lnk ); | 457 | d->selectedFiles->addToSelection( lnk ); |
459 | } | 458 | } |
460 | 459 | ||
461 | currentFileListView->clearSelection(); | 460 | currentFileListView->clearSelection(); |
462 | 461 | ||
463 | writeCurrentM3u(); | 462 | writeCurrentM3u(); |
464 | } | 463 | } |
465 | 464 | ||
466 | 465 | ||
467 | void PlayListWidget::removeSelected() { | 466 | void PlayListWidget::removeSelected() { |
468 | d->selectedFiles->removeSelected( ); | 467 | d->selectedFiles->removeSelected( ); |
469 | writeCurrentM3u(); | 468 | writeCurrentM3u(); |
470 | } | 469 | } |
471 | 470 | ||
472 | 471 | ||
473 | void PlayListWidget::playIt( QListViewItem *it) { | 472 | void PlayListWidget::playIt( QListViewItem *it) { |
474 | if(!it) return; | 473 | if(!it) return; |
475 | mediaPlayerState->setPlaying(FALSE); | 474 | mediaPlayerState->setPlaying(FALSE); |
476 | mediaPlayerState->setPlaying(TRUE); | 475 | mediaPlayerState->setPlaying(TRUE); |
477 | d->selectedFiles->unSelect(); | 476 | d->selectedFiles->unSelect(); |
478 | } | 477 | } |
479 | 478 | ||
480 | 479 | ||
481 | void PlayListWidget::addToSelection( QListViewItem *it) { | 480 | void PlayListWidget::addToSelection( QListViewItem *it) { |
482 | d->setDocumentUsed = FALSE; | 481 | d->setDocumentUsed = FALSE; |
483 | 482 | ||
484 | if(it) { | 483 | if(it) { |
485 | if ( currentTab() == CurrentPlayList ) | 484 | if ( currentTab() == CurrentPlayList ) |
486 | return; | 485 | return; |
487 | DocLnk lnk; | 486 | DocLnk lnk; |
488 | QString filename; | 487 | QString filename; |
489 | 488 | ||
490 | filename=it->text(3); | 489 | filename=it->text(3); |
491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 490 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
492 | lnk.setFile( filename ); //sets file name | 491 | lnk.setFile( filename ); //sets file name |
493 | d->selectedFiles->addToSelection( lnk); | 492 | d->selectedFiles->addToSelection( lnk); |
494 | 493 | ||
495 | writeCurrentM3u(); | 494 | writeCurrentM3u(); |
496 | // tabWidget->setCurrentPage(0); | 495 | // tabWidget->setCurrentPage(0); |
497 | 496 | ||
498 | } | 497 | } |
499 | } | 498 | } |
500 | 499 | ||
501 | 500 | ||
502 | void PlayListWidget::tabChanged(QWidget *) { | 501 | void PlayListWidget::tabChanged(QWidget *) { |
503 | 502 | ||
504 | d->tbPlay->setEnabled( true ); | 503 | d->tbPlay->setEnabled( true ); |
505 | 504 | ||
506 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 505 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
507 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 506 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
508 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 507 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
509 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 508 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
510 | 509 | ||
511 | currentFileListView = 0; | 510 | currentFileListView = 0; |
512 | 511 | ||
513 | switch ( currentTab() ) { | 512 | switch ( currentTab() ) { |
514 | case CurrentPlayList: | 513 | case CurrentPlayList: |
515 | { | 514 | { |
516 | if( !tbDeletePlaylist->isHidden() ) { | 515 | if( !tbDeletePlaylist->isHidden() ) { |
517 | tbDeletePlaylist->hide(); | 516 | tbDeletePlaylist->hide(); |
518 | } | 517 | } |
519 | d->tbRemoveFromList->setEnabled(TRUE); | 518 | d->tbRemoveFromList->setEnabled(TRUE); |
520 | d->tbAddToList->setEnabled(FALSE); | 519 | d->tbAddToList->setEnabled(FALSE); |
521 | 520 | ||
522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 521 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
523 | } | 522 | } |
524 | break; | 523 | break; |
525 | case AudioFiles: | 524 | case AudioFiles: |
526 | { | 525 | { |
527 | audioView->populateView(); | 526 | audioView->populateView(); |
528 | 527 | ||
529 | if( !tbDeletePlaylist->isHidden() ) { | 528 | if( !tbDeletePlaylist->isHidden() ) { |
530 | tbDeletePlaylist->hide(); | 529 | tbDeletePlaylist->hide(); |
531 | } | 530 | } |
532 | d->tbRemoveFromList->setEnabled(FALSE); | 531 | d->tbRemoveFromList->setEnabled(FALSE); |
533 | d->tbAddToList->setEnabled(TRUE); | 532 | d->tbAddToList->setEnabled(TRUE); |
534 | 533 | ||
535 | connect( audioView, SIGNAL( itemsSelected(bool) ), | 534 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
536 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 535 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
537 | 536 | ||
538 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 537 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
539 | 538 | ||
540 | currentFileListView = audioView; | 539 | currentFileListView = audioView; |
541 | } | 540 | } |
542 | break; | 541 | break; |
543 | case VideoFiles: | 542 | case VideoFiles: |
544 | { | 543 | { |
545 | videoView->populateView(); | 544 | videoView->populateView(); |
546 | if( !tbDeletePlaylist->isHidden() ) { | 545 | if( !tbDeletePlaylist->isHidden() ) { |
547 | tbDeletePlaylist->hide(); | 546 | tbDeletePlaylist->hide(); |
548 | } | 547 | } |
549 | d->tbRemoveFromList->setEnabled(FALSE); | 548 | d->tbRemoveFromList->setEnabled(FALSE); |
550 | d->tbAddToList->setEnabled(TRUE); | 549 | d->tbAddToList->setEnabled(TRUE); |
551 | 550 | ||
552 | connect( videoView, SIGNAL( itemsSelected(bool) ), | 551 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
553 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 552 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
554 | 553 | ||
555 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 554 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
556 | 555 | ||
557 | currentFileListView = videoView; | 556 | currentFileListView = videoView; |
558 | } | 557 | } |
559 | break; | 558 | break; |
560 | case PlayLists: | 559 | case PlayLists: |
561 | { | 560 | { |
562 | if( tbDeletePlaylist->isHidden() ) { | 561 | if( tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->show(); | 562 | tbDeletePlaylist->show(); |
564 | } | 563 | } |
565 | playLists->reread(); | 564 | playLists->reread(); |
566 | d->tbAddToList->setEnabled(FALSE); | 565 | d->tbAddToList->setEnabled(FALSE); |
567 | 566 | ||
568 | d->tbPlay->setEnabled( false ); | 567 | d->tbPlay->setEnabled( false ); |
569 | } | 568 | } |
570 | break; | 569 | break; |
571 | }; | 570 | }; |
572 | } | 571 | } |
573 | 572 | ||
574 | 573 | ||
575 | void PlayListWidget::btnPlay(bool b) { | 574 | void PlayListWidget::btnPlay(bool b) { |
576 | // mediaPlayerState->setPlaying(false); | 575 | // mediaPlayerState->setPlaying(false); |
577 | mediaPlayerState->setPlaying(b); | 576 | mediaPlayerState->setPlaying(b); |
578 | insanityBool=FALSE; | 577 | insanityBool=FALSE; |
579 | } | 578 | } |
580 | 579 | ||
581 | void PlayListWidget::deletePlaylist() { | 580 | void PlayListWidget::deletePlaylist() { |
582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 581 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
583 | (tr("You really want to delete\nthis playlist?")), | 582 | (tr("You really want to delete\nthis playlist?")), |
584 | (tr("Yes")), (tr("No")), 0 )){ | 583 | (tr("Yes")), (tr("No")), 0 )){ |
585 | case 0: // Yes clicked, | 584 | case 0: // Yes clicked, |
586 | QFile().remove(playLists->selectedDocument().file()); | 585 | QFile().remove(playLists->selectedDocument().file()); |
587 | QFile().remove(playLists->selectedDocument().linkFile()); | 586 | QFile().remove(playLists->selectedDocument().linkFile()); |
588 | playLists->reread(); | 587 | playLists->reread(); |
589 | break; | 588 | break; |
590 | case 1: // Cancel | 589 | case 1: // Cancel |
591 | break; | 590 | break; |
592 | }; | 591 | }; |
593 | } | 592 | } |
594 | 593 | ||
595 | 594 | ||
596 | void PlayListWidget::playSelected() { | 595 | void PlayListWidget::playSelected() { |
597 | btnPlay( TRUE); | 596 | btnPlay( TRUE); |
598 | } | 597 | } |
599 | 598 | ||
600 | bool PlayListWidget::inFileListMode() const | 599 | bool PlayListWidget::inFileListMode() const |
601 | { | 600 | { |
602 | TabType tab = currentTab(); | 601 | TabType tab = currentTab(); |
603 | return tab == AudioFiles || tab == VideoFiles; | 602 | return tab == AudioFiles || tab == VideoFiles; |
604 | } | 603 | } |
605 | 604 | ||
606 | void PlayListWidget::openURL() { | 605 | void PlayListWidget::openURL() { |
607 | // http://66.28.164.33:2080 | 606 | // http://66.28.164.33:2080 |
608 | // http://somafm.com/star0242.m3u | 607 | // http://somafm.com/star0242.m3u |
609 | QString filename, name; | 608 | QString filename, name; |
610 | InputDialog *fileDlg; | 609 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 610 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
612 | fileDlg->exec(); | 611 | fileDlg->exec(); |
613 | if( fileDlg->result() == 1 ) { | 612 | if( fileDlg->result() == 1 ) { |
614 | filename = fileDlg->text(); | 613 | filename = fileDlg->text(); |
615 | qDebug( "Selected filename is " + filename ); | 614 | qDebug( "Selected filename is " + filename ); |
616 | // Om3u *m3uList; | 615 | // Om3u *m3uList; |
617 | DocLnk lnk; | 616 | DocLnk lnk; |
618 | Config cfg( "OpiePlayer" ); | 617 | Config cfg( "OpiePlayer" ); |
619 | cfg.setGroup("PlayList"); | 618 | cfg.setGroup("PlayList"); |
620 | 619 | ||
621 | if(filename.left(4) == "http") { | 620 | if(filename.left(4) == "http") { |
622 | QString m3uFile, m3uFilePath; | 621 | QString m3uFile, m3uFilePath; |
623 | if(filename.find(":",8,TRUE) != -1) { //found a port | 622 | if(filename.find(":",8,TRUE) != -1) { //found a port |
624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 623 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
625 | m3uFile = m3uFile.right( 7); | 624 | m3uFile = m3uFile.right( 7); |
626 | } else if(filename.left(4) == "http"){ | 625 | } else if(filename.left(4) == "http"){ |
627 | m3uFile=filename; | 626 | m3uFile=filename; |
628 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 627 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
629 | } else{ | 628 | } else{ |
630 | m3uFile=filename; | 629 | m3uFile=filename; |
631 | } | 630 | } |
632 | 631 | ||
633 | lnk.setName( filename ); //sets name | 632 | lnk.setName( filename ); //sets name |
634 | lnk.setFile( filename ); //sets file name | 633 | lnk.setFile( filename ); //sets file name |
635 | 634 | ||
636 | // lnk.setIcon("opieplayer2/musicfile"); | 635 | // lnk.setIcon("opieplayer2/musicfile"); |
637 | 636 | ||
638 | d->selectedFiles->addToSelection( lnk ); | 637 | d->selectedFiles->addToSelection( lnk ); |
639 | writeCurrentM3u(); | 638 | writeCurrentM3u(); |
640 | d->selectedFiles->setSelectedItem( lnk.name()); | 639 | d->selectedFiles->setSelectedItem( lnk.name()); |
641 | } | 640 | } |
642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 641 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
643 | readListFromFile( filename ); | 642 | readListFromFile( filename ); |
644 | } else { | 643 | } else { |
645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 644 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
646 | lnk.setFile( filename ); //sets file name | 645 | lnk.setFile( filename ); //sets file name |
647 | d->selectedFiles->addToSelection( lnk); | 646 | d->selectedFiles->addToSelection( lnk); |
648 | writeCurrentM3u(); | 647 | writeCurrentM3u(); |
649 | d->selectedFiles->setSelectedItem( lnk.name()); | 648 | d->selectedFiles->setSelectedItem( lnk.name()); |
650 | } | 649 | } |
651 | } | 650 | } |
652 | 651 | ||
653 | 652 | ||
654 | delete fileDlg; | 653 | delete fileDlg; |
655 | } | 654 | } |
656 | 655 | ||
657 | 656 | ||
658 | void PlayListWidget::openFile() { | 657 | void PlayListWidget::openFile() { |
659 | 658 | ||
660 | QString filename, name; | 659 | QString filename, name; |
661 | 660 | ||
662 | Config cfg( "OpiePlayer" ); | 661 | Config cfg( "OpiePlayer" ); |
663 | cfg.setGroup("Dialog"); | 662 | cfg.setGroup("Dialog"); |
664 | MimeTypes types; | 663 | MimeTypes types; |
665 | QStringList audio, video, all; | 664 | QStringList audio, video, all; |
666 | audio << "audio/*"; | 665 | audio << "audio/*"; |
667 | audio << "playlist/plain"; | 666 | audio << "playlist/plain"; |
668 | audio << "application/ogg"; | 667 | audio << "application/ogg"; |
669 | audio << "audio/x-mpegurl"; | 668 | audio << "audio/x-mpegurl"; |
670 | 669 | ||
671 | video << "video/*"; | 670 | video << "video/*"; |
672 | video << "playlist/plain"; | 671 | video << "playlist/plain"; |
673 | 672 | ||
674 | all += audio; | 673 | all += audio; |
675 | all += video; | 674 | all += video; |
676 | types.insert("All Media Files", all ); | 675 | types.insert("All Media Files", all ); |
677 | types.insert("Audio", audio ); | 676 | types.insert("Audio", audio ); |
678 | types.insert("Video", video ); | 677 | types.insert("Video", video ); |
679 | 678 | ||
680 | QString str = OFileDialog::getOpenFileName( 1, | 679 | QString str = OFileDialog::getOpenFileName( 1, |
681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 680 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
682 | types, 0 ); | 681 | types, 0 ); |
683 | 682 | ||
684 | if(str.left(2) == "//") { | 683 | if(str.left(2) == "//") { |
685 | str=str.right(str.length()-1); | 684 | str=str.right(str.length()-1); |
686 | } | 685 | } |
687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 686 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
688 | 687 | ||
689 | if( !str.isEmpty() ) { | 688 | if( !str.isEmpty() ) { |
690 | 689 | ||
691 | qDebug( "Selected filename is " + str ); | 690 | qDebug( "Selected filename is " + str ); |
692 | filename = str; | 691 | filename = str; |
693 | DocLnk lnk; | 692 | DocLnk lnk; |
694 | 693 | ||
695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 694 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
696 | readListFromFile( filename ); | 695 | readListFromFile( filename ); |
697 | } else { | 696 | } else { |
698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 697 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
699 | lnk.setFile( filename ); //sets file name | 698 | lnk.setFile( filename ); //sets file name |
700 | d->selectedFiles->addToSelection( lnk ); | 699 | d->selectedFiles->addToSelection( lnk ); |
701 | writeCurrentM3u(); | 700 | writeCurrentM3u(); |
702 | d->selectedFiles->setSelectedItem( lnk.name() ); | 701 | d->selectedFiles->setSelectedItem( lnk.name() ); |
703 | } | 702 | } |
704 | } | 703 | } |
705 | } | 704 | } |
706 | 705 | ||
707 | 706 | ||
708 | void PlayListWidget::readListFromFile( const QString &filename ) { | 707 | void PlayListWidget::readListFromFile( const QString &filename ) { |
709 | qDebug( "read list filename " + filename ); | 708 | qDebug( "read list filename " + filename ); |
710 | QFileInfo fi(filename); | 709 | QFileInfo fi(filename); |
711 | Om3u *m3uList; | 710 | Om3u *m3uList; |
712 | QString s, name; | 711 | QString s, name; |
713 | m3uList = new Om3u( filename, IO_ReadOnly ); | 712 | m3uList = new Om3u( filename, IO_ReadOnly ); |
714 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 713 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
715 | m3uList->readM3u(); | 714 | m3uList->readM3u(); |
716 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 715 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
717 | m3uList->readPls(); | 716 | m3uList->readPls(); |
718 | 717 | ||
719 | DocLnk lnk; | 718 | DocLnk lnk; |
720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 719 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
721 | s = *it; | 720 | s = *it; |
722 | // qDebug(s); | 721 | // qDebug(s); |
723 | if(s.left(4)=="http") { | 722 | if(s.left(4)=="http") { |
724 | lnk.setName( s ); //sets file name | 723 | lnk.setName( s ); //sets file name |
725 | lnk.setIcon("opieplayer2/musicfile"); | 724 | lnk.setIcon("opieplayer2/musicfile"); |
726 | lnk.setFile( s ); //sets file name | 725 | lnk.setFile( s ); //sets file name |
727 | 726 | ||
728 | } else { //is file | 727 | } else { //is file |
729 | lnk.setName( QFileInfo(s).baseName()); | 728 | lnk.setName( QFileInfo(s).baseName()); |
730 | if(s.left(1) != "/") { | 729 | if(s.left(1) != "/") { |
731 | 730 | ||
732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 731 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
733 | } else { | 732 | } else { |
734 | lnk.setFile( s); | 733 | lnk.setFile( s); |
735 | } | 734 | } |
736 | } | 735 | } |
737 | d->selectedFiles->addToSelection( lnk ); | 736 | d->selectedFiles->addToSelection( lnk ); |
738 | } | 737 | } |
739 | Config config( "OpiePlayer" ); | 738 | Config config( "OpiePlayer" ); |
740 | config.setGroup( "PlayList" ); | 739 | config.setGroup( "PlayList" ); |
741 | 740 | ||
742 | config.writeEntry("CurrentPlaylist",filename); | 741 | config.writeEntry("CurrentPlaylist",filename); |
743 | config.write(); | 742 | config.write(); |
744 | currentPlayList=filename; | 743 | currentPlayList=filename; |
745 | 744 | ||
746 | m3uList->close(); | 745 | m3uList->close(); |
747 | delete m3uList; | 746 | delete m3uList; |
748 | 747 | ||
749 | d->selectedFiles->setSelectedItem( s); | 748 | d->selectedFiles->setSelectedItem( s); |
750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 749 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
751 | 750 | ||
752 | } | 751 | } |
753 | 752 | ||
754 | // writes current playlist to current m3u file */ | 753 | // writes current playlist to current m3u file */ |
755 | void PlayListWidget::writeCurrentM3u() { | 754 | void PlayListWidget::writeCurrentM3u() { |
756 | qDebug("writing to current m3u"); | 755 | qDebug("writing to current m3u"); |
757 | Config cfg( "OpiePlayer" ); | 756 | Config cfg( "OpiePlayer" ); |
758 | cfg.setGroup("PlayList"); | 757 | cfg.setGroup("PlayList"); |
759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 758 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
760 | 759 | ||
761 | Om3u *m3uList; | 760 | Om3u *m3uList; |
762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 761 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
763 | if( d->selectedFiles->first()) { | 762 | if( d->selectedFiles->first()) { |
764 | 763 | ||
765 | do { | 764 | do { |
766 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 765 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
767 | m3uList->add( d->selectedFiles->current()->file() ); | 766 | m3uList->add( d->selectedFiles->current()->file() ); |
768 | } | 767 | } |
769 | while ( d->selectedFiles->next() ); | 768 | while ( d->selectedFiles->next() ); |
770 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 769 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
771 | m3uList->write(); | 770 | m3uList->write(); |
772 | m3uList->close(); | 771 | m3uList->close(); |
773 | } | 772 | } |
774 | delete m3uList; | 773 | delete m3uList; |
775 | 774 | ||
776 | } | 775 | } |
777 | 776 | ||
778 | /* | 777 | /* |
779 | writes current playlist to m3u file */ | 778 | writes current playlist to m3u file */ |
780 | void PlayListWidget::writem3u() { | 779 | void PlayListWidget::writem3u() { |
781 | //InputDilog *fileDlg; | 780 | //InputDilog *fileDlg; |
782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 781 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
783 | //fileDlg->exec(); | 782 | //fileDlg->exec(); |
784 | 783 | ||
785 | Config cfg( "OpiePlayer" ); | 784 | Config cfg( "OpiePlayer" ); |
786 | cfg.setGroup("Dialog"); | 785 | cfg.setGroup("Dialog"); |
787 | MimeTypes types; | 786 | MimeTypes types; |
788 | QStringList audio, video, all; | 787 | QStringList audio, video, all; |
789 | audio << "audio/*"; | 788 | audio << "audio/*"; |
790 | audio << "playlist/plain"; | 789 | audio << "playlist/plain"; |
791 | audio << "audio/x-mpegurl"; | 790 | audio << "audio/x-mpegurl"; |
792 | 791 | ||
793 | video << "video/*"; | 792 | video << "video/*"; |
794 | video << "playlist/plain"; | 793 | video << "playlist/plain"; |
795 | 794 | ||
796 | all += audio; | 795 | all += audio; |
797 | all += video; | 796 | all += video; |
798 | types.insert("All Media Files", all ); | 797 | types.insert("All Media Files", all ); |
799 | types.insert("Audio", audio ); | 798 | types.insert("Audio", audio ); |
800 | types.insert("Video", video ); | 799 | types.insert("Video", video ); |
801 | 800 | ||
802 | QString str = OFileDialog::getOpenFileName( 1, | 801 | QString str = OFileDialog::getOpenFileName( 1, |
803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 802 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
804 | types, 0 ); | 803 | types, 0 ); |
805 | if(str.left(2) == "//") str=str.right(str.length()-1); | 804 | if(str.left(2) == "//") str=str.right(str.length()-1); |
806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 805 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
807 | 806 | ||
808 | 807 | ||
809 | QString name, filename, list; | 808 | QString name, filename, list; |
810 | Om3u *m3uList; | 809 | Om3u *m3uList; |
811 | 810 | ||
812 | if( !str.isEmpty() ) { | 811 | if( !str.isEmpty() ) { |
813 | name = str; | 812 | name = str; |
814 | // name = fileDlg->text(); | 813 | // name = fileDlg->text(); |
815 | // qDebug( filename ); | 814 | // qDebug( filename ); |
816 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 815 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
817 | filename = name; | 816 | filename = name; |
818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 817 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
819 | } | 818 | } |
820 | else //otherwise dump it somewhere noticable | 819 | else //otherwise dump it somewhere noticable |
821 | filename = QPEApplication::documentDir() + "/" + name; | 820 | filename = QPEApplication::documentDir() + "/" + name; |
822 | 821 | ||
823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 822 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
824 | filename += ".m3u"; | 823 | filename += ".m3u"; |
825 | 824 | ||
826 | if( d->selectedFiles->first()) { //ramble through playlist view | 825 | if( d->selectedFiles->first()) { //ramble through playlist view |
827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 826 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
828 | 827 | ||
829 | do { | 828 | do { |
830 | m3uList->add( d->selectedFiles->current()->file()); | 829 | m3uList->add( d->selectedFiles->current()->file()); |
831 | } | 830 | } |
832 | while ( d->selectedFiles->next() ); | 831 | while ( d->selectedFiles->next() ); |
833 | // qDebug( list ); | 832 | // qDebug( list ); |
834 | m3uList->write(); | 833 | m3uList->write(); |
835 | m3uList->close(); | 834 | m3uList->close(); |
836 | delete m3uList; | 835 | delete m3uList; |
837 | 836 | ||
838 | //delete fileDlg; | 837 | //delete fileDlg; |
839 | 838 | ||
840 | DocLnk lnk; | 839 | DocLnk lnk; |
841 | lnk.setFile( filename); | 840 | lnk.setFile( filename); |
842 | lnk.setIcon("opieplayer2/playlist2"); | 841 | lnk.setIcon("opieplayer2/playlist2"); |
843 | lnk.setName( name); //sets file name | 842 | lnk.setName( name); //sets file name |
844 | 843 | ||
845 | // qDebug(filename); | 844 | // qDebug(filename); |
846 | Config config( "OpiePlayer" ); | 845 | Config config( "OpiePlayer" ); |
847 | config.setGroup( "PlayList" ); | 846 | config.setGroup( "PlayList" ); |
848 | 847 | ||
849 | config.writeEntry("CurrentPlaylist",filename); | 848 | config.writeEntry("CurrentPlaylist",filename); |
850 | currentPlayList=filename; | 849 | currentPlayList=filename; |
851 | 850 | ||
852 | if(!lnk.writeLink()) { | 851 | if(!lnk.writeLink()) { |
853 | qDebug("Writing doclink did not work"); | 852 | qDebug("Writing doclink did not work"); |
854 | } | 853 | } |
855 | 854 | ||
856 | setCaption(tr("OpiePlayer: ") + name); | 855 | setCaption(tr("OpiePlayer: ") + name); |
857 | } | 856 | } |
858 | } | 857 | } |
859 | } | 858 | } |
860 | 859 | ||
861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 860 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
862 | switch ( e->key() ) { | 861 | switch ( e->key() ) { |
863 | ////////////////////////////// Zaurus keys | 862 | ////////////////////////////// Zaurus keys |
864 | case Key_F9: //activity | 863 | case Key_F9: //activity |
865 | // if(audioUI->isHidden()) | 864 | // if(audioUI->isHidden()) |
866 | // audioUI->showMaximized(); | 865 | // audioUI->showMaximized(); |
867 | break; | 866 | break; |
868 | case Key_F10: //contacts | 867 | case Key_F10: //contacts |
869 | // if( videoUI->isHidden()) | 868 | // if( videoUI->isHidden()) |
870 | // videoUI->showMaximized(); | 869 | // videoUI->showMaximized(); |
871 | break; | 870 | break; |
872 | case Key_F11: //menu | 871 | case Key_F11: //menu |
873 | break; | 872 | break; |
874 | case Key_F12: //home | 873 | case Key_F12: //home |
875 | // doBlank(); | 874 | // doBlank(); |
876 | break; | 875 | break; |
877 | case Key_F13: //mail | 876 | case Key_F13: //mail |
878 | // doUnblank(); | 877 | // doUnblank(); |
879 | break; | 878 | break; |
880 | case Key_Q: //add to playlist | 879 | case Key_Q: //add to playlist |
881 | addSelected(); | 880 | addSelected(); |
882 | break; | 881 | break; |
883 | case Key_R: //remove from playlist | 882 | case Key_R: //remove from playlist |
884 | removeSelected(); | 883 | removeSelected(); |
885 | break; | 884 | break; |
886 | // case Key_P: //play | 885 | // case Key_P: //play |
887 | // qDebug("Play"); | 886 | // qDebug("Play"); |
888 | // playSelected(); | 887 | // playSelected(); |
889 | // break; | 888 | // break; |
890 | case Key_Space: | 889 | case Key_Space: |
891 | // playSelected(); puh | 890 | // playSelected(); puh |
892 | break; | 891 | break; |
893 | case Key_1: | 892 | case Key_1: |
894 | tabWidget->setCurrentPage( 0 ); | 893 | tabWidget->setCurrentPage( 0 ); |
895 | break; | 894 | break; |
896 | case Key_2: | 895 | case Key_2: |
897 | tabWidget->setCurrentPage( 1 ); | 896 | tabWidget->setCurrentPage( 1 ); |
898 | break; | 897 | break; |
899 | case Key_3: | 898 | case Key_3: |
900 | tabWidget->setCurrentPage( 2 ); | 899 | tabWidget->setCurrentPage( 2 ); |
901 | break; | 900 | break; |
902 | case Key_4: | 901 | case Key_4: |
903 | tabWidget->setCurrentPage( 3 ); | 902 | tabWidget->setCurrentPage( 3 ); |
904 | break; | 903 | break; |
905 | case Key_Down: | 904 | case Key_Down: |
906 | if ( !d->selectedFiles->next() ) | 905 | if ( !d->selectedFiles->next() ) |
907 | d->selectedFiles->first(); | 906 | d->selectedFiles->first(); |
908 | break; | 907 | break; |
909 | case Key_Up: | 908 | case Key_Up: |
910 | if ( !d->selectedFiles->prev() ) | 909 | if ( !d->selectedFiles->prev() ) |
911 | // d->selectedFiles->last(); | 910 | // d->selectedFiles->last(); |
912 | break; | 911 | break; |
913 | } | 912 | } |
914 | } | 913 | } |
915 | 914 | ||
916 | void PlayListWidget::pmViewActivated(int index) { | 915 | void PlayListWidget::pmViewActivated(int index) { |
917 | // qDebug("%d", index); | 916 | // qDebug("%d", index); |
918 | switch(index) { | 917 | switch(index) { |
919 | case -16: | 918 | case -16: |
920 | { | 919 | { |
921 | mediaPlayerState->toggleFullscreen(); | 920 | mediaPlayerState->toggleFullscreen(); |
922 | bool b=mediaPlayerState->isFullscreen(); | 921 | bool b=mediaPlayerState->isFullscreen(); |
923 | pmView->setItemChecked( index, b); | 922 | pmView->setItemChecked( index, b); |
924 | Config cfg( "OpiePlayer" ); | 923 | Config cfg( "OpiePlayer" ); |
925 | cfg.writeEntry( "FullScreen", b ); | 924 | cfg.writeEntry( "FullScreen", b ); |
926 | } | 925 | } |
927 | break; | 926 | break; |
928 | }; | 927 | }; |
929 | } | 928 | } |
930 | 929 | ||
931 | void PlayListWidget::populateSkinsMenu() { | 930 | void PlayListWidget::populateSkinsMenu() { |
932 | int item = 0; | 931 | int item = 0; |
933 | defaultSkinIndex = 0; | 932 | defaultSkinIndex = 0; |
934 | QString skinName; | 933 | QString skinName; |
935 | Config cfg( "OpiePlayer" ); | 934 | Config cfg( "OpiePlayer" ); |
936 | cfg.setGroup("Options" ); | 935 | cfg.setGroup("Options" ); |
937 | QString skin = cfg.readEntry( "Skin", "default" ); | 936 | QString skin = cfg.readEntry( "Skin", "default" ); |
938 | 937 | ||
939 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 938 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
940 | skinsDir.setFilter( QDir::Dirs ); | 939 | skinsDir.setFilter( QDir::Dirs ); |
941 | skinsDir.setSorting(QDir::Name ); | 940 | skinsDir.setSorting(QDir::Name ); |
942 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 941 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
943 | QFileInfoListIterator it( *skinslist ); | 942 | QFileInfoListIterator it( *skinslist ); |
944 | QFileInfo *fi; | 943 | QFileInfo *fi; |
945 | while ( ( fi = it.current() ) ) { | 944 | while ( ( fi = it.current() ) ) { |
946 | skinName = fi->fileName(); | 945 | skinName = fi->fileName(); |
947 | // qDebug( fi->fileName() ); | 946 | // qDebug( fi->fileName() ); |
948 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 947 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
949 | item = skinsMenu->insertItem( fi->fileName() ) ; | 948 | item = skinsMenu->insertItem( fi->fileName() ) ; |
950 | } | 949 | } |
951 | if( skinName == "default" ) { | 950 | if( skinName == "default" ) { |
952 | defaultSkinIndex = item; | 951 | defaultSkinIndex = item; |
953 | } | 952 | } |
954 | if( skinName == skin ) { | 953 | if( skinName == skin ) { |
955 | skinsMenu->setItemChecked( item, TRUE ); | 954 | skinsMenu->setItemChecked( item, TRUE ); |
956 | } | 955 | } |
957 | ++it; | 956 | ++it; |
958 | } | 957 | } |
959 | } | 958 | } |
960 | 959 | ||
961 | void PlayListWidget::skinsMenuActivated( int item ) { | 960 | void PlayListWidget::skinsMenuActivated( int item ) { |
962 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 961 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
963 | skinsMenu->setItemChecked( i, FALSE ); | 962 | skinsMenu->setItemChecked( i, FALSE ); |
964 | } | 963 | } |
965 | skinsMenu->setItemChecked( item, TRUE ); | 964 | skinsMenu->setItemChecked( item, TRUE ); |
966 | 965 | ||
967 | { | 966 | { |
968 | Config cfg( "OpiePlayer" ); | 967 | Config cfg( "OpiePlayer" ); |
969 | cfg.setGroup("Options"); | 968 | cfg.setGroup("Options"); |
970 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 969 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
971 | } | 970 | } |
972 | 971 | ||
973 | emit skinSelected(); | 972 | emit skinSelected(); |
974 | } | 973 | } |
975 | 974 | ||
976 | PlayListWidget::TabType PlayListWidget::currentTab() const | 975 | PlayListWidget::TabType PlayListWidget::currentTab() const |
977 | { | 976 | { |
978 | static const TabType indexToTabType[ TabTypeCount ] = | 977 | static const TabType indexToTabType[ TabTypeCount ] = |
979 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 978 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
980 | 979 | ||
981 | int index = tabWidget->currentPageIndex(); | 980 | int index = tabWidget->currentPageIndex(); |
982 | assert( index < TabTypeCount && index >= 0 ); | 981 | assert( index < TabTypeCount && index >= 0 ); |
983 | 982 | ||
984 | return indexToTabType[ index ]; | 983 | return indexToTabType[ index ]; |
985 | } | 984 | } |
986 | 985 | ||
987 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 986 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
988 | { | 987 | { |
989 | if ( currentTab() == CurrentPlayList ) { | 988 | if ( currentTab() == CurrentPlayList ) { |
990 | const DocLnk *lnk = current(); | 989 | const DocLnk *lnk = current(); |
991 | return Entry( lnk->name(), lnk->file() ); | 990 | return Entry( lnk->name(), lnk->file() ); |
992 | } | 991 | } |
993 | 992 | ||
994 | return Entry( currentFileListPathName() ); | 993 | return Entry( currentFileListPathName() ); |
995 | } | 994 | } |
996 | 995 | ||
997 | QString PlayListWidget::currentFileListPathName() const { | 996 | QString PlayListWidget::currentFileListPathName() const { |
998 | return currentFileListView->currentItem()->text( 3 ); | 997 | return currentFileListView->currentItem()->text( 3 ); |
999 | } | 998 | } |
1000 | 999 | ||
1001 | 1000 | ||
1002 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1001 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1003 | qDebug("qcop message "+msg ); | 1002 | qDebug("qcop message "+msg ); |
1004 | QDataStream stream ( data, IO_ReadOnly ); | 1003 | QDataStream stream ( data, IO_ReadOnly ); |
1005 | if ( msg == "play()" ) { //plays current selection | 1004 | if ( msg == "play()" ) { //plays current selection |
1006 | btnPlay( true); | 1005 | btnPlay( true); |
1007 | } else if ( msg == "stop()" ) { | 1006 | } else if ( msg == "stop()" ) { |
1008 | mediaPlayerState->setPlaying( false); | 1007 | mediaPlayerState->setPlaying( false); |
1009 | } else if ( msg == "togglePause()" ) { | 1008 | } else if ( msg == "togglePause()" ) { |
1010 | mediaPlayerState->togglePaused(); | 1009 | mediaPlayerState->togglePaused(); |
1011 | } else if ( msg == "next()" ) { //select next in list | 1010 | } else if ( msg == "next()" ) { //select next in list |
1012 | mediaPlayerState->setNext(); | 1011 | mediaPlayerState->setNext(); |
1013 | } else if ( msg == "prev()" ) { //select previous in list | 1012 | } else if ( msg == "prev()" ) { //select previous in list |
1014 | mediaPlayerState->setPrev(); | 1013 | mediaPlayerState->setPrev(); |
1015 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1014 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1016 | mediaPlayerState->toggleLooping(); | 1015 | mediaPlayerState->toggleLooping(); |
1017 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1016 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1018 | mediaPlayerState->toggleShuffled(); | 1017 | mediaPlayerState->toggleShuffled(); |
1019 | } else if ( msg == "volUp()" ) { //volume more | 1018 | } else if ( msg == "volUp()" ) { //volume more |
1020 | // emit moreClicked(); | 1019 | // emit moreClicked(); |
1021 | // emit moreReleased(); | 1020 | // emit moreReleased(); |
1022 | } else if ( msg == "volDown()" ) { //volume less | 1021 | } else if ( msg == "volDown()" ) { //volume less |
1023 | // emit lessClicked(); | 1022 | // emit lessClicked(); |
1024 | // emit lessReleased(); | 1023 | // emit lessReleased(); |
1025 | } else if ( msg == "play(QString)" ) { //play this now | 1024 | } else if ( msg == "play(QString)" ) { //play this now |
1026 | QString file; | 1025 | QString file; |
1027 | stream >> file; | 1026 | stream >> file; |
1028 | setDocument( (const QString &) file); | 1027 | setDocument( (const QString &) file); |
1029 | } else if ( msg == "add(QString)" ) { //add to playlist | 1028 | } else if ( msg == "add(QString)" ) { //add to playlist |
1030 | QString file; | 1029 | QString file; |
1031 | stream >> file; | 1030 | stream >> file; |
1032 | QFileInfo fileInfo(file); | 1031 | QFileInfo fileInfo(file); |
1033 | DocLnk lnk; | 1032 | DocLnk lnk; |
1034 | lnk.setName( fileInfo.baseName() ); //sets name | 1033 | lnk.setName( fileInfo.baseName() ); //sets name |
1035 | lnk.setFile( file ); //sets file name | 1034 | lnk.setFile( file ); //sets file name |
1036 | addToSelection( lnk ); | 1035 | addToSelection( lnk ); |
1037 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1036 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1038 | QString file; | 1037 | QString file; |
1039 | stream >> file; | 1038 | stream >> file; |
1040 | 1039 | ||
1041 | } | 1040 | } |
1042 | 1041 | ||
1043 | } | 1042 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index 33fe188..2ff190d 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,194 +1,193 @@ | |||
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 | ..}^=.= = ; 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 | 34 | ||
35 | #include <qtoolbar.h> | 35 | #include <qtoolbar.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | 37 | ||
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qmenubar.h> | 39 | #include <qmenubar.h> |
40 | 40 | ||
41 | #include "playlistselection.h" | 41 | #include "playlistselection.h" |
42 | #include "playlistwidget.h" | 42 | #include "playlistwidget.h" |
43 | #include "mediaplayerstate.h" | 43 | #include "mediaplayerstate.h" |
44 | #include "inputDialog.h" | 44 | #include "inputDialog.h" |
45 | #include "playlistfileview.h" | 45 | #include "playlistfileview.h" |
46 | 46 | ||
47 | #include "mediaplayerstate.h" | ||
48 | 47 | ||
49 | PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) | 48 | PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) |
50 | : QMainWindow( parent, name ) { | 49 | : QMainWindow( parent, name ) { |
51 | 50 | ||
52 | d = new PlayListWidgetPrivate; | 51 | d = new PlayListWidgetPrivate; |
53 | d->setDocumentUsed = FALSE; | 52 | d->setDocumentUsed = FALSE; |
54 | 53 | ||
55 | setBackgroundMode( PaletteButton ); | 54 | setBackgroundMode( PaletteButton ); |
56 | setToolBarsMovable( FALSE ); | 55 | setToolBarsMovable( FALSE ); |
57 | 56 | ||
58 | // Create Toolbar | 57 | // Create Toolbar |
59 | QToolBar *toolbar = new QToolBar( this ); | 58 | QToolBar *toolbar = new QToolBar( this ); |
60 | toolbar->setHorizontalStretchable( TRUE ); | 59 | toolbar->setHorizontalStretchable( TRUE ); |
61 | 60 | ||
62 | // Create Menubar | 61 | // Create Menubar |
63 | QMenuBar *menu = new QMenuBar( toolbar ); | 62 | QMenuBar *menu = new QMenuBar( toolbar ); |
64 | menu->setMargin( 0 ); | 63 | menu->setMargin( 0 ); |
65 | 64 | ||
66 | bar = new QToolBar( this ); | 65 | bar = new QToolBar( this ); |
67 | bar->setLabel( tr( "Play Operations" ) ); | 66 | bar->setLabel( tr( "Play Operations" ) ); |
68 | 67 | ||
69 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 68 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
70 | tbDeletePlaylist->setFlat( TRUE ); | 69 | tbDeletePlaylist->setFlat( TRUE ); |
71 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 70 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
72 | 71 | ||
73 | tbDeletePlaylist->hide(); | 72 | tbDeletePlaylist->hide(); |
74 | 73 | ||
75 | pmPlayList = new QPopupMenu( this ); | 74 | pmPlayList = new QPopupMenu( this ); |
76 | menu->insertItem( tr( "File" ), pmPlayList ); | 75 | menu->insertItem( tr( "File" ), pmPlayList ); |
77 | 76 | ||
78 | pmView = new QPopupMenu( this ); | 77 | pmView = new QPopupMenu( this ); |
79 | menu->insertItem( tr( "View" ), pmView ); | 78 | menu->insertItem( tr( "View" ), pmView ); |
80 | pmView->isCheckable(); | 79 | pmView->isCheckable(); |
81 | 80 | ||
82 | skinsMenu = new QPopupMenu( this ); | 81 | skinsMenu = new QPopupMenu( this ); |
83 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 82 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
84 | skinsMenu->isCheckable(); | 83 | skinsMenu->isCheckable(); |
85 | 84 | ||
86 | gammaMenu = new QPopupMenu( this ); | 85 | gammaMenu = new QPopupMenu( this ); |
87 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); | 86 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
88 | 87 | ||
89 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 88 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
90 | gammaSlider->setRange( -40, 40 ); | 89 | gammaSlider->setRange( -40, 40 ); |
91 | gammaSlider->setTickmarks( QSlider::Left ); | 90 | gammaSlider->setTickmarks( QSlider::Left ); |
92 | gammaSlider->setTickInterval( 20 ); | 91 | gammaSlider->setTickInterval( 20 ); |
93 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); | 92 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); |
94 | gammaSlider->setValue( 0 ); | 93 | gammaSlider->setValue( 0 ); |
95 | gammaSlider->setMinimumHeight( 50 ); | 94 | gammaSlider->setMinimumHeight( 50 ); |
96 | 95 | ||
97 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 96 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
98 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); | 97 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); |
99 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); | 98 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); |
100 | 99 | ||
101 | gammaMenu->insertItem( gammaSlider ); | 100 | gammaMenu->insertItem( gammaSlider ); |
102 | gammaMenu->insertItem( gammaLCD ); | 101 | gammaMenu->insertItem( gammaLCD ); |
103 | 102 | ||
104 | connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) ); | 103 | connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) ); |
105 | 104 | ||
106 | vbox5 = new QVBox( this ); | 105 | vbox5 = new QVBox( this ); |
107 | QVBox *vbox4 = new QVBox( vbox5 ); | 106 | QVBox *vbox4 = new QVBox( vbox5 ); |
108 | QHBox *hbox6 = new QHBox( vbox4 ); | 107 | QHBox *hbox6 = new QHBox( vbox4 ); |
109 | 108 | ||
110 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 109 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
111 | 110 | ||
112 | playListTab = new QWidget( tabWidget, "PlayListTab" ); | 111 | playListTab = new QWidget( tabWidget, "PlayListTab" ); |
113 | tabWidget->insertTab( playListTab, "Playlist"); | 112 | tabWidget->insertTab( playListTab, "Playlist"); |
114 | 113 | ||
115 | QGridLayout *Playout = new QGridLayout( playListTab ); | 114 | QGridLayout *Playout = new QGridLayout( playListTab ); |
116 | Playout->setSpacing( 2); | 115 | Playout->setSpacing( 2); |
117 | Playout->setMargin( 2); | 116 | Playout->setMargin( 2); |
118 | 117 | ||
119 | // Add the playlist area | 118 | // Add the playlist area |
120 | QVBox *vbox3 = new QVBox( playListTab ); | 119 | QVBox *vbox3 = new QVBox( playListTab ); |
121 | d->playListFrame = vbox3; | 120 | d->playListFrame = vbox3; |
122 | 121 | ||
123 | QHBox *hbox2 = new QHBox( vbox3 ); | 122 | QHBox *hbox2 = new QHBox( vbox3 ); |
124 | d->selectedFiles = new PlayListSelection( hbox2 ); | 123 | d->selectedFiles = new PlayListSelection( hbox2 ); |
125 | 124 | ||
126 | vbox1 = new QVBox( hbox2 ); | 125 | vbox1 = new QVBox( hbox2 ); |
127 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 126 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
128 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 127 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
129 | 128 | ||
130 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 129 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
131 | 130 | ||
132 | QWidget *aTab; | 131 | QWidget *aTab; |
133 | aTab = new QWidget( tabWidget, "aTab" ); | 132 | aTab = new QWidget( tabWidget, "aTab" ); |
134 | 133 | ||
135 | QGridLayout *Alayout = new QGridLayout( aTab ); | 134 | QGridLayout *Alayout = new QGridLayout( aTab ); |
136 | Alayout->setSpacing( 2 ); | 135 | Alayout->setSpacing( 2 ); |
137 | Alayout->setMargin( 2 ); | 136 | Alayout->setMargin( 2 ); |
138 | // no m3u's here please | 137 | // no m3u's here please |
139 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" ); | 138 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" ); |
140 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 139 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
141 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 140 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
142 | 141 | ||
143 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 142 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
144 | 143 | ||
145 | QWidget *vTab; | 144 | QWidget *vTab; |
146 | vTab = new QWidget( tabWidget, "vTab" ); | 145 | vTab = new QWidget( tabWidget, "vTab" ); |
147 | 146 | ||
148 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 147 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
149 | Vlayout->setSpacing( 2 ); | 148 | Vlayout->setSpacing( 2 ); |
150 | Vlayout->setMargin( 2 ); | 149 | Vlayout->setMargin( 2 ); |
151 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); | 150 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); |
152 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 151 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
153 | 152 | ||
154 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 153 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
155 | 154 | ||
156 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 155 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
157 | 156 | ||
158 | //playlists list | 157 | //playlists list |
159 | QWidget *LTab; | 158 | QWidget *LTab; |
160 | LTab = new QWidget( tabWidget, "LTab" ); | 159 | LTab = new QWidget( tabWidget, "LTab" ); |
161 | QGridLayout *Llayout = new QGridLayout( LTab ); | 160 | QGridLayout *Llayout = new QGridLayout( LTab ); |
162 | Llayout->setSpacing( 2 ); | 161 | Llayout->setSpacing( 2 ); |
163 | Llayout->setMargin( 2 ); | 162 | Llayout->setMargin( 2 ); |
164 | 163 | ||
165 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 164 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
166 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 165 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
167 | 166 | ||
168 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 167 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
169 | 168 | ||
170 | setCentralWidget( vbox5 ); | 169 | setCentralWidget( vbox5 ); |
171 | } | 170 | } |
172 | 171 | ||
173 | 172 | ||
174 | 173 | ||
175 | PlayListWidgetGui::~PlayListWidgetGui() { | 174 | PlayListWidgetGui::~PlayListWidgetGui() { |
176 | } | 175 | } |
177 | 176 | ||
178 | void PlayListWidgetGui::setView( char view ) { | 177 | void PlayListWidgetGui::setView( char view ) { |
179 | if ( view == 'l' ) | 178 | if ( view == 'l' ) |
180 | showMaximized(); | 179 | showMaximized(); |
181 | else | 180 | else |
182 | hide(); | 181 | hide(); |
183 | } | 182 | } |
184 | 183 | ||
185 | 184 | ||
186 | void PlayListWidgetGui::setActiveWindow() { | 185 | void PlayListWidgetGui::setActiveWindow() { |
187 | // qDebug("SETTING active window"); | 186 | // qDebug("SETTING active window"); |
188 | // When we get raised we need to ensure that it switches views | 187 | // When we get raised we need to ensure that it switches views |
189 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); | 188 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); |
190 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate | 189 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate |
191 | mediaPlayerState->setDisplayType( origDisplayType ); // now switch back | 190 | mediaPlayerState->setDisplayType( origDisplayType ); // now switch back |
192 | } | 191 | } |
193 | 192 | ||
194 | 193 | ||
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index 742e495..7c38983 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp | |||
@@ -1,324 +1,322 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> | 2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or | 7 | This program is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU General Public | 8 | modify it under the terms of the GNU General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | General Public License for more details. | 15 | General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; see the file COPYING. If not, write to | 18 | along with this program; see the file COPYING. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include "skin.h" | 23 | #include "skin.h" |
24 | #include "singleton.h" | 24 | #include "singleton.h" |
25 | 25 | ||
26 | #include <qcache.h> | 26 | #include <qcache.h> |
27 | #include <qmap.h> | ||
28 | #include <qtimer.h> | 27 | #include <qtimer.h> |
29 | 28 | ||
30 | #include <qpe/resource.h> | ||
31 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
32 | 30 | ||
33 | #include <assert.h> | 31 | #include <assert.h> |
34 | 32 | ||
35 | struct SkinData | 33 | struct SkinData |
36 | { | 34 | { |
37 | typedef QMap<QString, QImage> ButtonMaskImageMap; | 35 | typedef QMap<QString, QImage> ButtonMaskImageMap; |
38 | 36 | ||
39 | QPixmap backgroundPixmap; | 37 | QPixmap backgroundPixmap; |
40 | QImage buttonUpImage; | 38 | QImage buttonUpImage; |
41 | QImage buttonDownImage; | 39 | QImage buttonDownImage; |
42 | QImage buttonMask; | 40 | QImage buttonMask; |
43 | ButtonMaskImageMap buttonMasks; | 41 | ButtonMaskImageMap buttonMasks; |
44 | }; | 42 | }; |
45 | 43 | ||
46 | class SkinCache : public Singleton<SkinCache> | 44 | class SkinCache : public Singleton<SkinCache> |
47 | { | 45 | { |
48 | public: | 46 | public: |
49 | SkinCache(); | 47 | SkinCache(); |
50 | 48 | ||
51 | SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix ); | 49 | SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix ); |
52 | 50 | ||
53 | void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ); | 51 | void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ); |
54 | 52 | ||
55 | private: | 53 | private: |
56 | typedef QCache<SkinData> DataCache; | 54 | typedef QCache<SkinData> DataCache; |
57 | typedef QCache<QPixmap> BackgroundPixmapCache; | 55 | typedef QCache<QPixmap> BackgroundPixmapCache; |
58 | 56 | ||
59 | template <class CacheType> | 57 | template <class CacheType> |
60 | void store( const QCache<CacheType> &cache, const QString &key, CacheType *data ); | 58 | void store( const QCache<CacheType> &cache, const QString &key, CacheType *data ); |
61 | 59 | ||
62 | DataCache m_cache; | 60 | DataCache m_cache; |
63 | BackgroundPixmapCache m_backgroundPixmapCache; | 61 | BackgroundPixmapCache m_backgroundPixmapCache; |
64 | }; | 62 | }; |
65 | 63 | ||
66 | Skin::Skin( const QString &name, const QString &fileNameInfix ) | 64 | Skin::Skin( const QString &name, const QString &fileNameInfix ) |
67 | : m_fileNameInfix( fileNameInfix ) | 65 | : m_fileNameInfix( fileNameInfix ) |
68 | { | 66 | { |
69 | init( name ); | 67 | init( name ); |
70 | } | 68 | } |
71 | 69 | ||
72 | Skin::Skin( const QString &fileNameInfix ) | 70 | Skin::Skin( const QString &fileNameInfix ) |
73 | : m_fileNameInfix( fileNameInfix ) | 71 | : m_fileNameInfix( fileNameInfix ) |
74 | { | 72 | { |
75 | init( defaultSkinName() ); | 73 | init( defaultSkinName() ); |
76 | } | 74 | } |
77 | 75 | ||
78 | Skin::~Skin() | 76 | Skin::~Skin() |
79 | { | 77 | { |
80 | if ( m_isCachable ) | 78 | if ( m_isCachable ) |
81 | SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); | 79 | SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); |
82 | else | 80 | else |
83 | delete d; | 81 | delete d; |
84 | } | 82 | } |
85 | 83 | ||
86 | void Skin::init( const QString &name ) | 84 | void Skin::init( const QString &name ) |
87 | { | 85 | { |
88 | m_isCachable = true; | 86 | m_isCachable = true; |
89 | m_skinPath = "opieplayer2/skins/" + name; | 87 | m_skinPath = "opieplayer2/skins/" + name; |
90 | d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); | 88 | d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); |
91 | } | 89 | } |
92 | 90 | ||
93 | QPixmap Skin::backgroundPixmap() const | 91 | QPixmap Skin::backgroundPixmap() const |
94 | { | 92 | { |
95 | if ( d->backgroundPixmap.isNull() ) | 93 | if ( d->backgroundPixmap.isNull() ) |
96 | d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) ); | 94 | d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) ); |
97 | return d->backgroundPixmap; | 95 | return d->backgroundPixmap; |
98 | } | 96 | } |
99 | 97 | ||
100 | QImage Skin::buttonUpImage() const | 98 | QImage Skin::buttonUpImage() const |
101 | { | 99 | { |
102 | if ( d->buttonUpImage.isNull() ) | 100 | if ( d->buttonUpImage.isNull() ) |
103 | d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); | 101 | d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); |
104 | return d->buttonUpImage; | 102 | return d->buttonUpImage; |
105 | } | 103 | } |
106 | 104 | ||
107 | QImage Skin::buttonDownImage() const | 105 | QImage Skin::buttonDownImage() const |
108 | { | 106 | { |
109 | if ( d->buttonDownImage.isNull() ) | 107 | if ( d->buttonDownImage.isNull() ) |
110 | d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); | 108 | d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); |
111 | return d->buttonDownImage; | 109 | return d->buttonDownImage; |
112 | } | 110 | } |
113 | 111 | ||
114 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const | 112 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const |
115 | { | 113 | { |
116 | if ( !d->buttonMask.isNull() ) | 114 | if ( !d->buttonMask.isNull() ) |
117 | return d->buttonMask; | 115 | return d->buttonMask; |
118 | 116 | ||
119 | QSize buttonAreaSize = buttonUpImage().size(); | 117 | QSize buttonAreaSize = buttonUpImage().size(); |
120 | 118 | ||
121 | d->buttonMask = QImage( buttonAreaSize, 8, 255 ); | 119 | d->buttonMask = QImage( buttonAreaSize, 8, 255 ); |
122 | d->buttonMask.fill( 0 ); | 120 | d->buttonMask.fill( 0 ); |
123 | 121 | ||
124 | for ( uint i = 0; i < buttonCount; ++i ) | 122 | for ( uint i = 0; i < buttonCount; ++i ) |
125 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); | 123 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); |
126 | 124 | ||
127 | return d->buttonMask; | 125 | return d->buttonMask; |
128 | } | 126 | } |
129 | 127 | ||
130 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const | 128 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const |
131 | { | 129 | { |
132 | if ( maskImage.isNull() ) | 130 | if ( maskImage.isNull() ) |
133 | return; | 131 | return; |
134 | 132 | ||
135 | uchar **dest = d->buttonMask.jumpTable(); | 133 | uchar **dest = d->buttonMask.jumpTable(); |
136 | for ( int y = 0; y < d->buttonMask.height(); y++ ) { | 134 | for ( int y = 0; y < d->buttonMask.height(); y++ ) { |
137 | uchar *line = dest[y]; | 135 | uchar *line = dest[y]; |
138 | for ( int x = 0; x < d->buttonMask.width(); x++ ) | 136 | for ( int x = 0; x < d->buttonMask.width(); x++ ) |
139 | if ( !qRed( maskImage.pixel( x, y ) ) ) | 137 | if ( !qRed( maskImage.pixel( x, y ) ) ) |
140 | line[x] = tag; | 138 | line[x] = tag; |
141 | } | 139 | } |
142 | } | 140 | } |
143 | 141 | ||
144 | QImage Skin::buttonMaskImage( const QString &fileName ) const | 142 | QImage Skin::buttonMaskImage( const QString &fileName ) const |
145 | { | 143 | { |
146 | SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); | 144 | SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); |
147 | if ( it == d->buttonMasks.end() ) { | 145 | if ( it == d->buttonMasks.end() ) { |
148 | QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); | 146 | QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); |
149 | QString path = prefix + fileName; | 147 | QString path = prefix + fileName; |
150 | it = d->buttonMasks.insert( fileName, loadImage( path ) ); | 148 | it = d->buttonMasks.insert( fileName, loadImage( path ) ); |
151 | } | 149 | } |
152 | return *it; | 150 | return *it; |
153 | } | 151 | } |
154 | 152 | ||
155 | QString Skin::defaultSkinName() | 153 | QString Skin::defaultSkinName() |
156 | { | 154 | { |
157 | Config cfg( "OpiePlayer" ); | 155 | Config cfg( "OpiePlayer" ); |
158 | cfg.setGroup( "Options" ); | 156 | cfg.setGroup( "Options" ); |
159 | return cfg.readEntry( "Skin", "default" ); | 157 | return cfg.readEntry( "Skin", "default" ); |
160 | } | 158 | } |
161 | 159 | ||
162 | QImage Skin::loadImage( const QString &fileName ) | 160 | QImage Skin::loadImage( const QString &fileName ) |
163 | { | 161 | { |
164 | return QImage( Resource::findPixmap( fileName ) ); | 162 | return QImage( Resource::findPixmap( fileName ) ); |
165 | } | 163 | } |
166 | 164 | ||
167 | SkinCache::SkinCache() | 165 | SkinCache::SkinCache() |
168 | { | 166 | { |
169 | // let's say we cache two skins (audio+video) at maximum | 167 | // let's say we cache two skins (audio+video) at maximum |
170 | m_cache.setMaxCost( 2 ); | 168 | m_cache.setMaxCost( 2 ); |
171 | // ... and one background pixmap | 169 | // ... and one background pixmap |
172 | m_backgroundPixmapCache.setMaxCost( 1 ); | 170 | m_backgroundPixmapCache.setMaxCost( 1 ); |
173 | } | 171 | } |
174 | 172 | ||
175 | SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) | 173 | SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) |
176 | { | 174 | { |
177 | QString key = skinPath + fileNameInfix; | 175 | QString key = skinPath + fileNameInfix; |
178 | 176 | ||
179 | SkinData *data = m_cache.take( key ); | 177 | SkinData *data = m_cache.take( key ); |
180 | if ( !data ) | 178 | if ( !data ) |
181 | data = new SkinData; | 179 | data = new SkinData; |
182 | else | 180 | else |
183 | qDebug( "SkinCache: hit" ); | 181 | qDebug( "SkinCache: hit" ); |
184 | 182 | ||
185 | QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); | 183 | QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); |
186 | if ( bgPixmap ) { | 184 | if ( bgPixmap ) { |
187 | qDebug( "SkinCache: hit on bgpixmap" ); | 185 | qDebug( "SkinCache: hit on bgpixmap" ); |
188 | data->backgroundPixmap = *bgPixmap; | 186 | data->backgroundPixmap = *bgPixmap; |
189 | } | 187 | } |
190 | else | 188 | else |
191 | data->backgroundPixmap = QPixmap(); | 189 | data->backgroundPixmap = QPixmap(); |
192 | 190 | ||
193 | return data; | 191 | return data; |
194 | } | 192 | } |
195 | 193 | ||
196 | void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) | 194 | void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) |
197 | { | 195 | { |
198 | QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); | 196 | QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); |
199 | 197 | ||
200 | data->backgroundPixmap = QPixmap(); | 198 | data->backgroundPixmap = QPixmap(); |
201 | 199 | ||
202 | QString key = skinPath + fileNameInfix; | 200 | QString key = skinPath + fileNameInfix; |
203 | 201 | ||
204 | if ( m_cache.find( key, false /*ref*/ ) != 0 || | 202 | if ( m_cache.find( key, false /*ref*/ ) != 0 || |
205 | !m_cache.insert( key, data ) ) | 203 | !m_cache.insert( key, data ) ) |
206 | delete data; | 204 | delete data; |
207 | 205 | ||
208 | if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || | 206 | if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || |
209 | !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) | 207 | !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) |
210 | delete backgroundPixmap; | 208 | delete backgroundPixmap; |
211 | } | 209 | } |
212 | 210 | ||
213 | SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) | 211 | SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) |
214 | : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) | 212 | : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) |
215 | { | 213 | { |
216 | m_currentState = LoadBackgroundPixmap; | 214 | m_currentState = LoadBackgroundPixmap; |
217 | } | 215 | } |
218 | 216 | ||
219 | SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() | 217 | SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() |
220 | { | 218 | { |
221 | switch ( m_currentState ) { | 219 | switch ( m_currentState ) { |
222 | case LoadBackgroundPixmap: | 220 | case LoadBackgroundPixmap: |
223 | qDebug( "load bgpixmap" ); | 221 | qDebug( "load bgpixmap" ); |
224 | m_skin.backgroundPixmap(); | 222 | m_skin.backgroundPixmap(); |
225 | m_currentState = LoadButtonUpImage; | 223 | m_currentState = LoadButtonUpImage; |
226 | break; | 224 | break; |
227 | case LoadButtonUpImage: | 225 | case LoadButtonUpImage: |
228 | qDebug( "load upimage" ); | 226 | qDebug( "load upimage" ); |
229 | m_skin.buttonUpImage(); | 227 | m_skin.buttonUpImage(); |
230 | m_currentState = LoadButtonDownImage; | 228 | m_currentState = LoadButtonDownImage; |
231 | break; | 229 | break; |
232 | case LoadButtonDownImage: | 230 | case LoadButtonDownImage: |
233 | qDebug( "load downimage" ); | 231 | qDebug( "load downimage" ); |
234 | m_skin.buttonDownImage(); | 232 | m_skin.buttonDownImage(); |
235 | m_currentState = LoadButtonMasks; | 233 | m_currentState = LoadButtonMasks; |
236 | m_currentButton = 0; | 234 | m_currentButton = 0; |
237 | break; | 235 | break; |
238 | case LoadButtonMasks: | 236 | case LoadButtonMasks: |
239 | qDebug( "load button masks %i", m_currentButton ); | 237 | qDebug( "load button masks %i", m_currentButton ); |
240 | m_skin.buttonMaskImage( m_info.buttonInfo[ m_currentButton ].fileName ); | 238 | m_skin.buttonMaskImage( m_info.buttonInfo[ m_currentButton ].fileName ); |
241 | 239 | ||
242 | m_currentButton++; | 240 | m_currentButton++; |
243 | if ( m_currentButton >= m_info.buttonCount ) | 241 | if ( m_currentButton >= m_info.buttonCount ) |
244 | m_currentState = LoadButtonMask; | 242 | m_currentState = LoadButtonMask; |
245 | 243 | ||
246 | break; | 244 | break; |
247 | case LoadButtonMask: | 245 | case LoadButtonMask: |
248 | qDebug( "load whole mask" ); | 246 | qDebug( "load whole mask" ); |
249 | m_skin.buttonMask( m_info.buttonInfo, m_info.buttonCount ); | 247 | m_skin.buttonMask( m_info.buttonInfo, m_info.buttonCount ); |
250 | return LoadingCompleted; | 248 | return LoadingCompleted; |
251 | } | 249 | } |
252 | 250 | ||
253 | return MoreToCome; | 251 | return MoreToCome; |
254 | } | 252 | } |
255 | 253 | ||
256 | SkinLoader::SkinLoader() | 254 | SkinLoader::SkinLoader() |
257 | : m_currentLoader( 0 ), m_timerId( -1 ) | 255 | : m_currentLoader( 0 ), m_timerId( -1 ) |
258 | { | 256 | { |
259 | } | 257 | } |
260 | 258 | ||
261 | SkinLoader::~SkinLoader() | 259 | SkinLoader::~SkinLoader() |
262 | { | 260 | { |
263 | qDebug( "SkinLoader::~SkinLoader()" ); | 261 | qDebug( "SkinLoader::~SkinLoader()" ); |
264 | killTimers(); | 262 | killTimers(); |
265 | delete m_currentLoader; | 263 | delete m_currentLoader; |
266 | } | 264 | } |
267 | 265 | ||
268 | void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) | 266 | void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) |
269 | { | 267 | { |
270 | schedule( Skin::defaultSkinName(), guiInfo ); | 268 | schedule( Skin::defaultSkinName(), guiInfo ); |
271 | } | 269 | } |
272 | 270 | ||
273 | void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) | 271 | void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) |
274 | { | 272 | { |
275 | pendingSkins << Info( skinName, guiInfo ); | 273 | pendingSkins << Info( skinName, guiInfo ); |
276 | } | 274 | } |
277 | 275 | ||
278 | void SkinLoader::start() | 276 | void SkinLoader::start() |
279 | { | 277 | { |
280 | assert( m_timerId == -1 ); | 278 | assert( m_timerId == -1 ); |
281 | m_timerId = startTimer( 100 /* ms */ ); | 279 | m_timerId = startTimer( 100 /* ms */ ); |
282 | qDebug( "SkinLoader::start() %d jobs", pendingSkins.count() ); | 280 | qDebug( "SkinLoader::start() %d jobs", pendingSkins.count() ); |
283 | } | 281 | } |
284 | 282 | ||
285 | void SkinLoader::timerEvent( QTimerEvent *ev ) | 283 | void SkinLoader::timerEvent( QTimerEvent *ev ) |
286 | { | 284 | { |
287 | if ( ev->timerId() != m_timerId ) { | 285 | if ( ev->timerId() != m_timerId ) { |
288 | QObject::timerEvent( ev ); | 286 | QObject::timerEvent( ev ); |
289 | return; | 287 | return; |
290 | } | 288 | } |
291 | 289 | ||
292 | if ( !m_currentLoader ) { | 290 | if ( !m_currentLoader ) { |
293 | 291 | ||
294 | if ( pendingSkins.isEmpty() ) { | 292 | if ( pendingSkins.isEmpty() ) { |
295 | qDebug( "all jobs done" ); | 293 | qDebug( "all jobs done" ); |
296 | killTimer( m_timerId ); | 294 | killTimer( m_timerId ); |
297 | m_timerId = -1; | 295 | m_timerId = -1; |
298 | // ### qt3: use deleteLater(); | 296 | // ### qt3: use deleteLater(); |
299 | QTimer::singleShot( 0, this, SLOT( deleteMe() ) ); | 297 | QTimer::singleShot( 0, this, SLOT( deleteMe() ) ); |
300 | return; | 298 | return; |
301 | } | 299 | } |
302 | 300 | ||
303 | Info nfo = *pendingSkins.begin(); | 301 | Info nfo = *pendingSkins.begin(); |
304 | pendingSkins.remove( pendingSkins.begin() ); | 302 | pendingSkins.remove( pendingSkins.begin() ); |
305 | 303 | ||
306 | m_currentLoader = new IncrementalLoader( nfo ); | 304 | m_currentLoader = new IncrementalLoader( nfo ); |
307 | qDebug( "new loader %i jobs left", pendingSkins.count() ); | 305 | qDebug( "new loader %i jobs left", pendingSkins.count() ); |
308 | } | 306 | } |
309 | 307 | ||
310 | if ( m_currentLoader->loadStep() == IncrementalLoader::LoadingCompleted ) { | 308 | if ( m_currentLoader->loadStep() == IncrementalLoader::LoadingCompleted ) { |
311 | delete m_currentLoader; | 309 | delete m_currentLoader; |
312 | m_currentLoader = 0; | 310 | m_currentLoader = 0; |
313 | } | 311 | } |
314 | 312 | ||
315 | qDebug( "finished step" ); | 313 | qDebug( "finished step" ); |
316 | } | 314 | } |
317 | 315 | ||
318 | void SkinLoader::deleteMe() | 316 | void SkinLoader::deleteMe() |
319 | { | 317 | { |
320 | delete this; | 318 | delete this; |
321 | } | 319 | } |
322 | 320 | ||
323 | /* vim: et sw=4 ts=4 | 321 | /* vim: et sw=4 ts=4 |
324 | */ | 322 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index a4d09f5..0625376 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,303 +1,301 @@ | |||
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 | #include "videowidget.h" | 34 | #include "videowidget.h" |
35 | #include "mediaplayerstate.h" | ||
36 | #include "playlistwidget.h" | ||
37 | 35 | ||
38 | 36 | ||
39 | #ifdef Q_WS_QWS | 37 | #ifdef Q_WS_QWS |
40 | # define USE_DIRECT_PAINTER | 38 | # define USE_DIRECT_PAINTER |
41 | # include <qdirectpainter_qws.h> | 39 | # include <qdirectpainter_qws.h> |
42 | # include <qgfxraster_qws.h> | 40 | # include <qgfxraster_qws.h> |
43 | #endif | 41 | #endif |
44 | 42 | ||
45 | 43 | ||
46 | namespace | 44 | namespace |
47 | { | 45 | { |
48 | 46 | ||
49 | const int xo = 2; // movable x offset | 47 | const int xo = 2; // movable x offset |
50 | const int yo = 0; // movable y offset | 48 | const int yo = 0; // movable y offset |
51 | 49 | ||
52 | const MediaWidget::SkinButtonInfo skinInfo[] = | 50 | const MediaWidget::SkinButtonInfo skinInfo[] = |
53 | { | 51 | { |
54 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 52 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
55 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 53 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
56 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, | 54 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, |
57 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, | 55 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, |
58 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 56 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
59 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 57 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
60 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } | 58 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } |
61 | }; | 59 | }; |
62 | 60 | ||
63 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 61 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
64 | 62 | ||
65 | } | 63 | } |
66 | 64 | ||
67 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 65 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
68 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) | 66 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) |
69 | { | 67 | { |
70 | setCaption( tr("OpiePlayer - Video") ); | 68 | setCaption( tr("OpiePlayer - Video") ); |
71 | 69 | ||
72 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 70 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
73 | 71 | ||
74 | connect ( videoFrame, SIGNAL( videoResized(const QSize&)), this, SIGNAL( videoResized(const QSize&))); | 72 | connect ( videoFrame, SIGNAL( videoResized(const QSize&)), this, SIGNAL( videoResized(const QSize&))); |
75 | connect ( videoFrame, SIGNAL( clicked() ), this, SLOT ( backToNormal() ) ); | 73 | connect ( videoFrame, SIGNAL( clicked() ), this, SLOT ( backToNormal() ) ); |
76 | 74 | ||
77 | slider = 0; | 75 | slider = 0; |
78 | 76 | ||
79 | loadSkin(); | 77 | loadSkin(); |
80 | 78 | ||
81 | setLength( mediaPlayerState.length() ); | 79 | setLength( mediaPlayerState.length() ); |
82 | setPosition( mediaPlayerState.position() ); | 80 | setPosition( mediaPlayerState.position() ); |
83 | setFullscreen( mediaPlayerState.isFullscreen() ); | 81 | setFullscreen( mediaPlayerState.isFullscreen() ); |
84 | setPlaying( mediaPlayerState.isPlaying() ); | 82 | setPlaying( mediaPlayerState.isPlaying() ); |
85 | } | 83 | } |
86 | 84 | ||
87 | 85 | ||
88 | VideoWidget::~VideoWidget() | 86 | VideoWidget::~VideoWidget() |
89 | { | 87 | { |
90 | } | 88 | } |
91 | 89 | ||
92 | MediaWidget::GUIInfo VideoWidget::guiInfo() | 90 | MediaWidget::GUIInfo VideoWidget::guiInfo() |
93 | { | 91 | { |
94 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); | 92 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); |
95 | } | 93 | } |
96 | 94 | ||
97 | void VideoWidget::resizeEvent( QResizeEvent *e ) { | 95 | void VideoWidget::resizeEvent( QResizeEvent *e ) { |
98 | int h = height(); | 96 | int h = height(); |
99 | int w = width(); | 97 | int w = width(); |
100 | //int Vh = 160; | 98 | //int Vh = 160; |
101 | //int Vw = 220; | 99 | //int Vw = 220; |
102 | 100 | ||
103 | slider->setFixedWidth( w - 20 ); | 101 | slider->setFixedWidth( w - 20 ); |
104 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 102 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
105 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 103 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
106 | slider->setFocusPolicy( QWidget::NoFocus ); | 104 | slider->setFocusPolicy( QWidget::NoFocus ); |
107 | slider->setBackgroundPixmap( backgroundPixmap ); | 105 | slider->setBackgroundPixmap( backgroundPixmap ); |
108 | 106 | ||
109 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 107 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
110 | if(w>h) | 108 | if(w>h) |
111 | upperLeftOfButtonMask.ry() = 0; | 109 | upperLeftOfButtonMask.ry() = 0; |
112 | else | 110 | else |
113 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 111 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
114 | 112 | ||
115 | MediaWidget::resizeEvent( e ); | 113 | MediaWidget::resizeEvent( e ); |
116 | } | 114 | } |
117 | 115 | ||
118 | void VideoWidget::sliderPressed() { | 116 | void VideoWidget::sliderPressed() { |
119 | videoSliderBeingMoved = TRUE; | 117 | videoSliderBeingMoved = TRUE; |
120 | } | 118 | } |
121 | 119 | ||
122 | void VideoWidget::sliderReleased() { | 120 | void VideoWidget::sliderReleased() { |
123 | videoSliderBeingMoved = FALSE; | 121 | videoSliderBeingMoved = FALSE; |
124 | if ( slider->width() == 0 ) { | 122 | if ( slider->width() == 0 ) { |
125 | return; | 123 | return; |
126 | } | 124 | } |
127 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 125 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
128 | mediaPlayerState.setPosition( val ); | 126 | mediaPlayerState.setPosition( val ); |
129 | } | 127 | } |
130 | 128 | ||
131 | void VideoWidget::setPosition( long i ) { | 129 | void VideoWidget::setPosition( long i ) { |
132 | updateSlider( i, mediaPlayerState.length() ); | 130 | updateSlider( i, mediaPlayerState.length() ); |
133 | } | 131 | } |
134 | 132 | ||
135 | 133 | ||
136 | void VideoWidget::setLength( long max ) { | 134 | void VideoWidget::setLength( long max ) { |
137 | updateSlider( mediaPlayerState.position(), max ); | 135 | updateSlider( mediaPlayerState.position(), max ); |
138 | } | 136 | } |
139 | 137 | ||
140 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 138 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
141 | { | 139 | { |
142 | if ( displayType == MediaPlayerState::Video ) { | 140 | if ( displayType == MediaPlayerState::Video ) { |
143 | makeVisible(); | 141 | makeVisible(); |
144 | return; | 142 | return; |
145 | } | 143 | } |
146 | 144 | ||
147 | // Effectively blank the view next time we show it so it looks nicer | 145 | // Effectively blank the view next time we show it so it looks nicer |
148 | scaledWidth = 0; | 146 | scaledWidth = 0; |
149 | scaledHeight = 0; | 147 | scaledHeight = 0; |
150 | hide(); | 148 | hide(); |
151 | } | 149 | } |
152 | 150 | ||
153 | void VideoWidget::loadSkin() | 151 | void VideoWidget::loadSkin() |
154 | { | 152 | { |
155 | loadDefaultSkin( guiInfo() ); | 153 | loadDefaultSkin( guiInfo() ); |
156 | 154 | ||
157 | delete slider; | 155 | delete slider; |
158 | slider = new QSlider( Qt::Horizontal, this ); | 156 | slider = new QSlider( Qt::Horizontal, this ); |
159 | slider->setMinValue( 0 ); | 157 | slider->setMinValue( 0 ); |
160 | slider->setMaxValue( 1 ); | 158 | slider->setMaxValue( 1 ); |
161 | slider->setBackgroundPixmap( backgroundPixmap ); | 159 | slider->setBackgroundPixmap( backgroundPixmap ); |
162 | //slider->setFocusPolicy( QWidget::NoFocus ); | 160 | //slider->setFocusPolicy( QWidget::NoFocus ); |
163 | 161 | ||
164 | resizeEvent( 0 ); | 162 | resizeEvent( 0 ); |
165 | } | 163 | } |
166 | 164 | ||
167 | void VideoWidget::updateSlider( long i, long max ) { | 165 | void VideoWidget::updateSlider( long i, long max ) { |
168 | // Will flicker too much if we don't do this | 166 | // Will flicker too much if we don't do this |
169 | if ( max == 0 ) { | 167 | if ( max == 0 ) { |
170 | return; | 168 | return; |
171 | } | 169 | } |
172 | int width = slider->width(); | 170 | int width = slider->width(); |
173 | int val = int((double)i * width / max); | 171 | int val = int((double)i * width / max); |
174 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 172 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
175 | if ( slider->value() != val ) { | 173 | if ( slider->value() != val ) { |
176 | slider->setValue( val ); | 174 | slider->setValue( val ); |
177 | } | 175 | } |
178 | if ( slider->maxValue() != width ) { | 176 | if ( slider->maxValue() != width ) { |
179 | slider->setMaxValue( width ); | 177 | slider->setMaxValue( width ); |
180 | } | 178 | } |
181 | } | 179 | } |
182 | } | 180 | } |
183 | 181 | ||
184 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 182 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
185 | if ( mediaPlayerState.isFullscreen() ) { | 183 | if ( mediaPlayerState.isFullscreen() ) { |
186 | mediaPlayerState.setFullscreen( FALSE ); | 184 | mediaPlayerState.setFullscreen( FALSE ); |
187 | makeVisible(); | 185 | makeVisible(); |
188 | } | 186 | } |
189 | MediaWidget::mouseReleaseEvent( event ); | 187 | MediaWidget::mouseReleaseEvent( event ); |
190 | } | 188 | } |
191 | 189 | ||
192 | void VideoWidget::backToNormal() { | 190 | void VideoWidget::backToNormal() { |
193 | mediaPlayerState.setFullscreen( FALSE ); | 191 | mediaPlayerState.setFullscreen( FALSE ); |
194 | makeVisible(); | 192 | makeVisible(); |
195 | setToggleButton( FullScreen, false ); | 193 | setToggleButton( FullScreen, false ); |
196 | } | 194 | } |
197 | 195 | ||
198 | void VideoWidget::makeVisible() { | 196 | void VideoWidget::makeVisible() { |
199 | if ( mediaPlayerState.isFullscreen() ) { | 197 | if ( mediaPlayerState.isFullscreen() ) { |
200 | showFullScreen(); | 198 | showFullScreen(); |
201 | resize( qApp->desktop()->size() ); | 199 | resize( qApp->desktop()->size() ); |
202 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 200 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
203 | 201 | ||
204 | slider->hide(); | 202 | slider->hide(); |
205 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 203 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
206 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 204 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
207 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 205 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
208 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 206 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
209 | 207 | ||
210 | } else { | 208 | } else { |
211 | showNormal(); | 209 | showNormal(); |
212 | showMaximized(); | 210 | showMaximized(); |
213 | QWidget *d = QApplication::desktop(); | 211 | QWidget *d = QApplication::desktop(); |
214 | int w = d->width(); | 212 | int w = d->width(); |
215 | int h = d->height(); | 213 | int h = d->height(); |
216 | 214 | ||
217 | if(w>h) { | 215 | if(w>h) { |
218 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 216 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
219 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 217 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
220 | } else { | 218 | } else { |
221 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 219 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
222 | } | 220 | } |
223 | 221 | ||
224 | if ( !mediaPlayerState.isSeekable() ) { | 222 | if ( !mediaPlayerState.isSeekable() ) { |
225 | if( !slider->isHidden()) { | 223 | if( !slider->isHidden()) { |
226 | slider->hide(); | 224 | slider->hide(); |
227 | } | 225 | } |
228 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 226 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
229 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 227 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
230 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 228 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
231 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 229 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
232 | } else { | 230 | } else { |
233 | slider->show(); | 231 | slider->show(); |
234 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 232 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
235 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 233 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
236 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 234 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
237 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 235 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
238 | } | 236 | } |
239 | } | 237 | } |
240 | } | 238 | } |
241 | 239 | ||
242 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 240 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
243 | switch ( e->key() ) { | 241 | switch ( e->key() ) { |
244 | ////////////////////////////// Zaurus keys | 242 | ////////////////////////////// Zaurus keys |
245 | case Key_Home: | 243 | case Key_Home: |
246 | break; | 244 | break; |
247 | case Key_F9: //activity | 245 | case Key_F9: //activity |
248 | break; | 246 | break; |
249 | case Key_F10: //contacts | 247 | case Key_F10: //contacts |
250 | // hide(); | 248 | // hide(); |
251 | break; | 249 | break; |
252 | case Key_F11: //menu | 250 | case Key_F11: //menu |
253 | break; | 251 | break; |
254 | case Key_F12: //home | 252 | case Key_F12: //home |
255 | break; | 253 | break; |
256 | case Key_F13: //mail | 254 | case Key_F13: //mail |
257 | break; | 255 | break; |
258 | case Key_Space: { | 256 | case Key_Space: { |
259 | if(mediaPlayerState.isPlaying()) { | 257 | if(mediaPlayerState.isPlaying()) { |
260 | mediaPlayerState.setPlaying(FALSE); | 258 | mediaPlayerState.setPlaying(FALSE); |
261 | } else { | 259 | } else { |
262 | mediaPlayerState.setPlaying(TRUE); | 260 | mediaPlayerState.setPlaying(TRUE); |
263 | } | 261 | } |
264 | } | 262 | } |
265 | break; | 263 | break; |
266 | case Key_Down: | 264 | case Key_Down: |
267 | // toggleButton(6); | 265 | // toggleButton(6); |
268 | emit lessClicked(); | 266 | emit lessClicked(); |
269 | emit lessReleased(); | 267 | emit lessReleased(); |
270 | // toggleButton(6); | 268 | // toggleButton(6); |
271 | break; | 269 | break; |
272 | case Key_Up: | 270 | case Key_Up: |
273 | // toggleButton(5); | 271 | // toggleButton(5); |
274 | emit moreClicked(); | 272 | emit moreClicked(); |
275 | emit moreReleased(); | 273 | emit moreReleased(); |
276 | // toggleButton(5); | 274 | // toggleButton(5); |
277 | break; | 275 | break; |
278 | case Key_Right: | 276 | case Key_Right: |
279 | mediaPlayerState.setNext(); | 277 | mediaPlayerState.setNext(); |
280 | break; | 278 | break; |
281 | case Key_Left: | 279 | case Key_Left: |
282 | mediaPlayerState.setPrev(); | 280 | mediaPlayerState.setPrev(); |
283 | break; | 281 | break; |
284 | case Key_Escape: | 282 | case Key_Escape: |
285 | break; | 283 | break; |
286 | 284 | ||
287 | }; | 285 | }; |
288 | } | 286 | } |
289 | 287 | ||
290 | XineVideoWidget* VideoWidget::vidWidget() { | 288 | XineVideoWidget* VideoWidget::vidWidget() { |
291 | return videoFrame; | 289 | return videoFrame; |
292 | } | 290 | } |
293 | 291 | ||
294 | 292 | ||
295 | void VideoWidget::setFullscreen ( bool b ) { | 293 | void VideoWidget::setFullscreen ( bool b ) { |
296 | setToggleButton( FullScreen, b ); | 294 | setToggleButton( FullScreen, b ); |
297 | } | 295 | } |
298 | 296 | ||
299 | 297 | ||
300 | void VideoWidget::setPlaying( bool b) { | 298 | void VideoWidget::setPlaying( bool b) { |
301 | setToggleButton( Play, b ); | 299 | setToggleButton( Play, b ); |
302 | } | 300 | } |
303 | 301 | ||
diff --git a/noncore/multimedia/opieplayer2/volumecontrol.cpp b/noncore/multimedia/opieplayer2/volumecontrol.cpp index 271b84e..b3f5f8d 100644 --- a/noncore/multimedia/opieplayer2/volumecontrol.cpp +++ b/noncore/multimedia/opieplayer2/volumecontrol.cpp | |||
@@ -1,61 +1,59 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | ||
3 | #include <qpe/config.h> | 2 | #include <qpe/config.h> |
4 | #include "qpe/qcopenvelope_qws.h" | 3 | #include "qpe/qcopenvelope_qws.h" |
5 | #include <qmessagebox.h> | ||
6 | 4 | ||
7 | #include "volumecontrol.h" | 5 | #include "volumecontrol.h" |
8 | 6 | ||
9 | int VolumeControl::volume() { | 7 | int VolumeControl::volume() { |
10 | Config cfg( "qpe" ); | 8 | Config cfg( "qpe" ); |
11 | cfg. setGroup( "Volume" ); | 9 | cfg. setGroup( "Volume" ); |
12 | m_volumePerc = cfg. readNumEntry( "VolumePercent", 50 ); | 10 | m_volumePerc = cfg. readNumEntry( "VolumePercent", 50 ); |
13 | 11 | ||
14 | return m_volumePerc; | 12 | return m_volumePerc; |
15 | } | 13 | } |
16 | 14 | ||
17 | 15 | ||
18 | void VolumeControl::setVolume( int volumePerc ) { | 16 | void VolumeControl::setVolume( int volumePerc ) { |
19 | Config cfg("qpe"); | 17 | Config cfg("qpe"); |
20 | cfg.setGroup("Volume"); | 18 | cfg.setGroup("Volume"); |
21 | 19 | ||
22 | if ( volumePerc > 100 ) { | 20 | if ( volumePerc > 100 ) { |
23 | volumePerc = 100; | 21 | volumePerc = 100; |
24 | } | 22 | } |
25 | if ( volumePerc < 0 ) { | 23 | if ( volumePerc < 0 ) { |
26 | volumePerc = 0; | 24 | volumePerc = 0; |
27 | } | 25 | } |
28 | 26 | ||
29 | m_volumePerc = volumePerc; | 27 | m_volumePerc = volumePerc; |
30 | cfg.writeEntry("VolumePercent", volumePerc ); | 28 | cfg.writeEntry("VolumePercent", volumePerc ); |
31 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 29 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
32 | // QCopEnvelope( "QPE/System", "setVolume(int,int)" ) << 0, volumePerc; | 30 | // QCopEnvelope( "QPE/System", "setVolume(int,int)" ) << 0, volumePerc; |
33 | } | 31 | } |
34 | 32 | ||
35 | 33 | ||
36 | void VolumeControl::incVol( int ammount ) { | 34 | void VolumeControl::incVol( int ammount ) { |
37 | int oldVol = volume(); | 35 | int oldVol = volume(); |
38 | setVolume( oldVol + ammount); | 36 | setVolume( oldVol + ammount); |
39 | } | 37 | } |
40 | 38 | ||
41 | void VolumeControl::decVol( int ammount ) { | 39 | void VolumeControl::decVol( int ammount ) { |
42 | int oldVol = volume(); | 40 | int oldVol = volume(); |
43 | setVolume( oldVol - ammount); | 41 | setVolume( oldVol - ammount); |
44 | } | 42 | } |
45 | 43 | ||
46 | 44 | ||
47 | VolumeControl::VolumeControl( ) { | 45 | VolumeControl::VolumeControl( ) { |
48 | volume(); | 46 | volume(); |
49 | } | 47 | } |
50 | 48 | ||
51 | VolumeControl::~VolumeControl() { | 49 | VolumeControl::~VolumeControl() { |
52 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 50 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
53 | } | 51 | } |
54 | 52 | ||
55 | void VolumeControl::setMute(bool on) { | 53 | void VolumeControl::setMute(bool on) { |
56 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << on; | 54 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << on; |
57 | } | 55 | } |
58 | 56 | ||
59 | 57 | ||
60 | 58 | ||
61 | 59 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 70f2ffd..8f11b2e 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,272 +1,271 @@ | |||
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 | ..}^=.= = ; 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 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | 39 | ||
40 | #include "xinecontrol.h" | 40 | #include "xinecontrol.h" |
41 | #include "mediaplayerstate.h" | ||
42 | #include "xinevideowidget.h" | 41 | #include "xinevideowidget.h" |
43 | 42 | ||
44 | XineControl::XineControl( XineVideoWidget *xineWidget, | 43 | XineControl::XineControl( XineVideoWidget *xineWidget, |
45 | MediaPlayerState &_mediaPlayerState, | 44 | MediaPlayerState &_mediaPlayerState, |
46 | QObject *parent, const char *name ) | 45 | QObject *parent, const char *name ) |
47 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 46 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
48 | { | 47 | { |
49 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); | 48 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); |
50 | 49 | ||
51 | init(); | 50 | init(); |
52 | } | 51 | } |
53 | 52 | ||
54 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 53 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
55 | MediaPlayerState &_mediaPlayerState, | 54 | MediaPlayerState &_mediaPlayerState, |
56 | QObject *parent, const char *name ) | 55 | QObject *parent, const char *name ) |
57 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 56 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
58 | { | 57 | { |
59 | xine->ensureInitialized(); | 58 | xine->ensureInitialized(); |
60 | 59 | ||
61 | xine->setWidget( xineWidget ); | 60 | xine->setWidget( xineWidget ); |
62 | 61 | ||
63 | init(); | 62 | init(); |
64 | } | 63 | } |
65 | 64 | ||
66 | void XineControl::init() | 65 | void XineControl::init() |
67 | { | 66 | { |
68 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 67 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
69 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); | 68 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); |
70 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); | 69 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); |
71 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); | 70 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); |
72 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); | 71 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); |
73 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); | 72 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); |
74 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 73 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
75 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); | 74 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); |
76 | 75 | ||
77 | disabledSuspendScreenSaver = FALSE; | 76 | disabledSuspendScreenSaver = FALSE; |
78 | } | 77 | } |
79 | 78 | ||
80 | XineControl::~XineControl() { | 79 | XineControl::~XineControl() { |
81 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 80 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
82 | if ( disabledSuspendScreenSaver ) { | 81 | if ( disabledSuspendScreenSaver ) { |
83 | disabledSuspendScreenSaver = FALSE; | 82 | disabledSuspendScreenSaver = FALSE; |
84 | // Re-enable the suspend mode | 83 | // Re-enable the suspend mode |
85 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 84 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
86 | } | 85 | } |
87 | #endif | 86 | #endif |
88 | delete libXine; | 87 | delete libXine; |
89 | } | 88 | } |
90 | 89 | ||
91 | void XineControl::play( const QString& fileName ) { | 90 | void XineControl::play( const QString& fileName ) { |
92 | 91 | ||
93 | hasVideoChannel = FALSE; | 92 | hasVideoChannel = FALSE; |
94 | hasAudioChannel = FALSE; | 93 | hasAudioChannel = FALSE; |
95 | m_fileName = fileName; | 94 | m_fileName = fileName; |
96 | 95 | ||
97 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 96 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
98 | 97 | ||
99 | if ( !libXine->play( fileName, 0, 0 ) ) { | 98 | if ( !libXine->play( fileName, 0, 0 ) ) { |
100 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 99 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
101 | // toggle stop so the the play button is reset | 100 | // toggle stop so the the play button is reset |
102 | mediaPlayerState.setPlaying( false ); | 101 | mediaPlayerState.setPlaying( false ); |
103 | return; | 102 | return; |
104 | } | 103 | } |
105 | mediaPlayerState.setPlaying( true ); | 104 | mediaPlayerState.setPlaying( true ); |
106 | 105 | ||
107 | MediaPlayerState::DisplayType displayType; | 106 | MediaPlayerState::DisplayType displayType; |
108 | if ( !libXine->hasVideo() ) { | 107 | if ( !libXine->hasVideo() ) { |
109 | displayType = MediaPlayerState::Audio; | 108 | displayType = MediaPlayerState::Audio; |
110 | qDebug("HAS AUDIO"); | 109 | qDebug("HAS AUDIO"); |
111 | libXine->setShowVideo( false ); | 110 | libXine->setShowVideo( false ); |
112 | hasAudioChannel = TRUE; | 111 | hasAudioChannel = TRUE; |
113 | } else { | 112 | } else { |
114 | displayType = MediaPlayerState::Video; | 113 | displayType = MediaPlayerState::Video; |
115 | qDebug("HAS VIDEO"); | 114 | qDebug("HAS VIDEO"); |
116 | libXine->setShowVideo( true ); | 115 | libXine->setShowVideo( true ); |
117 | hasVideoChannel = TRUE; | 116 | hasVideoChannel = TRUE; |
118 | } | 117 | } |
119 | // determine if slider is shown | 118 | // determine if slider is shown |
120 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 119 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
121 | 120 | ||
122 | // which gui (video / audio) | 121 | // which gui (video / audio) |
123 | mediaPlayerState.setDisplayType( displayType ); | 122 | mediaPlayerState.setDisplayType( displayType ); |
124 | 123 | ||
125 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 124 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
126 | if ( !disabledSuspendScreenSaver ) { | 125 | if ( !disabledSuspendScreenSaver ) { |
127 | disabledSuspendScreenSaver = TRUE; | 126 | disabledSuspendScreenSaver = TRUE; |
128 | // Stop the screen from blanking and power saving state | 127 | // Stop the screen from blanking and power saving state |
129 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 128 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
130 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 129 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
131 | } | 130 | } |
132 | #endif | 131 | #endif |
133 | 132 | ||
134 | length(); | 133 | length(); |
135 | position(); | 134 | position(); |
136 | } | 135 | } |
137 | 136 | ||
138 | void XineControl::nextMedia() { | 137 | void XineControl::nextMedia() { |
139 | mediaPlayerState.setNext(); | 138 | mediaPlayerState.setNext(); |
140 | } | 139 | } |
141 | 140 | ||
142 | void XineControl::setGamma( int value ) { | 141 | void XineControl::setGamma( int value ) { |
143 | libXine->setGamma( value ); | 142 | libXine->setGamma( value ); |
144 | } | 143 | } |
145 | 144 | ||
146 | void XineControl::stop( bool isSet ) { | 145 | void XineControl::stop( bool isSet ) { |
147 | if ( !isSet ) { | 146 | if ( !isSet ) { |
148 | libXine->stop(); | 147 | libXine->stop(); |
149 | 148 | ||
150 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 149 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
151 | if ( disabledSuspendScreenSaver ) { | 150 | if ( disabledSuspendScreenSaver ) { |
152 | disabledSuspendScreenSaver = FALSE; | 151 | disabledSuspendScreenSaver = FALSE; |
153 | // Re-enable the suspend mode | 152 | // Re-enable the suspend mode |
154 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 153 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
155 | } | 154 | } |
156 | #endif | 155 | #endif |
157 | } | 156 | } |
158 | } | 157 | } |
159 | 158 | ||
160 | /** | 159 | /** |
161 | * Pause playback | 160 | * Pause playback |
162 | * @isSet | 161 | * @isSet |
163 | */ | 162 | */ |
164 | void XineControl::pause( bool isSet) { | 163 | void XineControl::pause( bool isSet) { |
165 | libXine->pause( isSet ); | 164 | libXine->pause( isSet ); |
166 | } | 165 | } |
167 | 166 | ||
168 | 167 | ||
169 | /** | 168 | /** |
170 | * get current time in playback | 169 | * get current time in playback |
171 | */ | 170 | */ |
172 | long XineControl::currentTime() { | 171 | long XineControl::currentTime() { |
173 | // todo: jede sekunde überprüfen | 172 | // todo: jede sekunde überprüfen |
174 | m_currentTime = libXine->currentTime(); | 173 | m_currentTime = libXine->currentTime(); |
175 | return m_currentTime; | 174 | return m_currentTime; |
176 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 175 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
177 | } | 176 | } |
178 | 177 | ||
179 | /** | 178 | /** |
180 | * Set the length of the media file | 179 | * Set the length of the media file |
181 | */ | 180 | */ |
182 | void XineControl::length() { | 181 | void XineControl::length() { |
183 | m_length = libXine->length(); | 182 | m_length = libXine->length(); |
184 | mediaPlayerState.setLength( m_length ); | 183 | mediaPlayerState.setLength( m_length ); |
185 | } | 184 | } |
186 | 185 | ||
187 | 186 | ||
188 | /** | 187 | /** |
189 | * Reports the position the xine backend is at right now | 188 | * Reports the position the xine backend is at right now |
190 | * @return long the postion in seconds | 189 | * @return long the postion in seconds |
191 | */ | 190 | */ |
192 | long XineControl::position() { | 191 | long XineControl::position() { |
193 | m_position = ( currentTime() ); | 192 | m_position = ( currentTime() ); |
194 | mediaPlayerState.updatePosition( m_position ); | 193 | mediaPlayerState.updatePosition( m_position ); |
195 | long emitPos = (long)m_position; | 194 | long emitPos = (long)m_position; |
196 | emit positionChanged( emitPos ); | 195 | emit positionChanged( emitPos ); |
197 | if( mediaPlayerState.isPlaying() ) { | 196 | if( mediaPlayerState.isPlaying() ) { |
198 | // needs to be stopped the media is stopped | 197 | // needs to be stopped the media is stopped |
199 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 198 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
200 | } | 199 | } |
201 | return m_position; | 200 | return m_position; |
202 | } | 201 | } |
203 | 202 | ||
204 | /** | 203 | /** |
205 | * Set videoplayback to fullscreen | 204 | * Set videoplayback to fullscreen |
206 | * @param isSet | 205 | * @param isSet |
207 | */ | 206 | */ |
208 | void XineControl::setFullscreen( bool isSet ) { | 207 | void XineControl::setFullscreen( bool isSet ) { |
209 | libXine->showVideoFullScreen( isSet ); | 208 | libXine->showVideoFullScreen( isSet ); |
210 | } | 209 | } |
211 | 210 | ||
212 | 211 | ||
213 | QString XineControl::getMetaInfo() { | 212 | QString XineControl::getMetaInfo() { |
214 | 213 | ||
215 | QString returnString; | 214 | QString returnString; |
216 | 215 | ||
217 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 216 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
218 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 217 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
219 | } | 218 | } |
220 | 219 | ||
221 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 220 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
222 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 221 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
223 | } | 222 | } |
224 | 223 | ||
225 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 224 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
226 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 225 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
227 | } | 226 | } |
228 | 227 | ||
229 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 228 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
230 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 229 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
231 | } | 230 | } |
232 | 231 | ||
233 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 232 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
234 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 233 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
235 | } | 234 | } |
236 | 235 | ||
237 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 236 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
238 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 237 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
239 | } | 238 | } |
240 | return returnString; | 239 | return returnString; |
241 | } | 240 | } |
242 | 241 | ||
243 | QString XineControl::getErrorCode() { | 242 | QString XineControl::getErrorCode() { |
244 | 243 | ||
245 | int errorCode = libXine->error(); | 244 | int errorCode = libXine->error(); |
246 | 245 | ||
247 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); | 246 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); |
248 | 247 | ||
249 | if ( errorCode == 1 ) { | 248 | if ( errorCode == 1 ) { |
250 | return tr( "No input plugin found for this media type" ); | 249 | return tr( "No input plugin found for this media type" ); |
251 | } else if ( errorCode == 2 ) { | 250 | } else if ( errorCode == 2 ) { |
252 | return tr( "No demux plugin found for this media type" ); | 251 | return tr( "No demux plugin found for this media type" ); |
253 | } else if ( errorCode == 3 ) { | 252 | } else if ( errorCode == 3 ) { |
254 | return tr( "Demuxing failed for this media type" ); | 253 | return tr( "Demuxing failed for this media type" ); |
255 | } else if ( errorCode == 4 ) { | 254 | } else if ( errorCode == 4 ) { |
256 | return tr( "Malformed MRL" ); | 255 | return tr( "Malformed MRL" ); |
257 | } else { | 256 | } else { |
258 | return tr( "Some other error" ); | 257 | return tr( "Some other error" ); |
259 | } | 258 | } |
260 | } | 259 | } |
261 | 260 | ||
262 | /** | 261 | /** |
263 | * Seek to a position in the track | 262 | * Seek to a position in the track |
264 | * @param second the second to jump to | 263 | * @param second the second to jump to |
265 | */ | 264 | */ |
266 | void XineControl::seekTo( long second ) { | 265 | void XineControl::seekTo( long second ) { |
267 | libXine->seekTo( (int)second ); | 266 | libXine->seekTo( (int)second ); |
268 | } | 267 | } |
269 | 268 | ||
270 | void XineControl::videoResized ( const QSize &s ) { | 269 | void XineControl::videoResized ( const QSize &s ) { |
271 | libXine->resize( s ); | 270 | libXine->resize( s ); |
272 | } | 271 | } |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 0833784..b55750a 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -1,278 +1,275 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | This file is part of the Opie Project | 3 | This file is part of the Opie Project |
4 | 4 | ||
5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
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 | #include <qimage.h> | 34 | #include <qimage.h> |
35 | #include <qpainter.h> | ||
36 | #include <qgfx_qws.h> | ||
37 | #include <qdirectpainter_qws.h> | 35 | #include <qdirectpainter_qws.h> |
38 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
39 | #include <qsize.h> | 37 | #include <qsize.h> |
40 | #include <qapplication.h> | 38 | #include <qapplication.h> |
41 | #include <qpainter.h> | ||
42 | 39 | ||
43 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
44 | 41 | ||
45 | #include "xinevideowidget.h" | 42 | #include "xinevideowidget.h" |
46 | 43 | ||
47 | 44 | ||
48 | // 0 deg rot: copy a line from src to dst (use libc memcpy) | 45 | // 0 deg rot: copy a line from src to dst (use libc memcpy) |
49 | 46 | ||
50 | // 180 deg rot: copy a line from src to dst reversed | 47 | // 180 deg rot: copy a line from src to dst reversed |
51 | 48 | ||
52 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) | 49 | static inline void memcpy_rev ( void *dst, void *src, size_t len ) |
53 | { | 50 | { |
54 | len >>= 1; | 51 | len >>= 1; |
55 | 52 | ||
56 | ((char *) src ) += ( len << 1 ); | 53 | ((char *) src ) += ( len << 1 ); |
57 | 54 | ||
58 | while ( len-- ) | 55 | while ( len-- ) |
59 | *((short int *) dst )++ = *--((short int *) src ); | 56 | *((short int *) dst )++ = *--((short int *) src ); |
60 | } | 57 | } |
61 | 58 | ||
62 | // 90 deg rot: copy a column from src to dst | 59 | // 90 deg rot: copy a column from src to dst |
63 | 60 | ||
64 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 61 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) |
65 | { | 62 | { |
66 | len >>= 1; | 63 | len >>= 1; |
67 | while ( len-- ) { | 64 | while ( len-- ) { |
68 | *((short int *) dst )++ = *((short int *) src ); | 65 | *((short int *) dst )++ = *((short int *) src ); |
69 | ((char *) src ) += step; | 66 | ((char *) src ) += step; |
70 | } | 67 | } |
71 | } | 68 | } |
72 | 69 | ||
73 | // 270 deg rot: copy a column from src to dst reversed | 70 | // 270 deg rot: copy a column from src to dst reversed |
74 | 71 | ||
75 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 72 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) |
76 | { | 73 | { |
77 | len >>= 1; | 74 | len >>= 1; |
78 | 75 | ||
79 | ((char *) src ) += ( len * step ); | 76 | ((char *) src ) += ( len * step ); |
80 | 77 | ||
81 | while ( len-- ) { | 78 | while ( len-- ) { |
82 | ((char *) src ) -= step; | 79 | ((char *) src ) -= step; |
83 | *((short int *) dst )++ = *((short int *) src ); | 80 | *((short int *) dst )++ = *((short int *) src ); |
84 | } | 81 | } |
85 | } | 82 | } |
86 | 83 | ||
87 | 84 | ||
88 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 85 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
89 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 86 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
90 | { | 87 | { |
91 | setBackgroundMode ( NoBackground ); | 88 | setBackgroundMode ( NoBackground ); |
92 | 89 | ||
93 | m_logo = 0; | 90 | m_logo = 0; |
94 | m_buff = 0; | 91 | m_buff = 0; |
95 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 92 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
96 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 93 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
97 | m_rotation = 0; | 94 | m_rotation = 0; |
98 | } | 95 | } |
99 | 96 | ||
100 | 97 | ||
101 | XineVideoWidget::~XineVideoWidget ( ) | 98 | XineVideoWidget::~XineVideoWidget ( ) |
102 | { | 99 | { |
103 | delete m_logo; | 100 | delete m_logo; |
104 | } | 101 | } |
105 | 102 | ||
106 | void XineVideoWidget::clear ( ) | 103 | void XineVideoWidget::clear ( ) |
107 | { | 104 | { |
108 | m_buff = 0; | 105 | m_buff = 0; |
109 | repaint ( false ); | 106 | repaint ( false ); |
110 | } | 107 | } |
111 | 108 | ||
112 | QSize XineVideoWidget::videoSize() const | 109 | QSize XineVideoWidget::videoSize() const |
113 | { | 110 | { |
114 | QSize s = size(); | 111 | QSize s = size(); |
115 | bool fs = ( s == qApp->desktop()->size() ); | 112 | bool fs = ( s == qApp->desktop()->size() ); |
116 | 113 | ||
117 | // if we are in fullscreen mode, do not rotate the video | 114 | // if we are in fullscreen mode, do not rotate the video |
118 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | 115 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) |
119 | m_rotation = fs ? - qt_screen->transformOrientation() : 0; | 116 | m_rotation = fs ? - qt_screen->transformOrientation() : 0; |
120 | 117 | ||
121 | if ( fs && qt_screen->isTransformed() ) | 118 | if ( fs && qt_screen->isTransformed() ) |
122 | s = qt_screen->mapToDevice( s ); | 119 | s = qt_screen->mapToDevice( s ); |
123 | 120 | ||
124 | return s; | 121 | return s; |
125 | } | 122 | } |
126 | 123 | ||
127 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 124 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
128 | { | 125 | { |
129 | if ( m_buff == 0 ) { | 126 | if ( m_buff == 0 ) { |
130 | QPainter p ( this ); | 127 | QPainter p ( this ); |
131 | p. fillRect ( rect ( ), black ); | 128 | p. fillRect ( rect ( ), black ); |
132 | if ( m_logo ) | 129 | if ( m_logo ) |
133 | p. drawImage ( 0, 0, *m_logo ); | 130 | p. drawImage ( 0, 0, *m_logo ); |
134 | } | 131 | } |
135 | else { | 132 | else { |
136 | // Qt needs to be notified which areas were really updated .. strange | 133 | // Qt needs to be notified which areas were really updated .. strange |
137 | QArray <QRect> qt_bug_workaround_clip_rects; | 134 | QArray <QRect> qt_bug_workaround_clip_rects; |
138 | 135 | ||
139 | { | 136 | { |
140 | QDirectPainter dp ( this ); | 137 | QDirectPainter dp ( this ); |
141 | 138 | ||
142 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation | 139 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
143 | 140 | ||
144 | uchar *fb = dp. frameBuffer ( ); | 141 | uchar *fb = dp. frameBuffer ( ); |
145 | uchar *frame = m_buff; | 142 | uchar *frame = m_buff; |
146 | 143 | ||
147 | // where is the video frame in fb coordinates | 144 | // where is the video frame in fb coordinates |
148 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 145 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
149 | 146 | ||
150 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 147 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
151 | 148 | ||
152 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { | 149 | for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { |
153 | const QRect &clip = dp. rect ( i ); | 150 | const QRect &clip = dp. rect ( i ); |
154 | 151 | ||
155 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 152 | qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
156 | 153 | ||
157 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb | 154 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb |
158 | uchar *src = frame; | 155 | uchar *src = frame; |
159 | 156 | ||
160 | // Adjust the start the source data based on the rotation (xine frame) | 157 | // Adjust the start the source data based on the rotation (xine frame) |
161 | switch ( rot ) { | 158 | switch ( rot ) { |
162 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; | 159 | case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; |
163 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; | 160 | case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; |
164 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; | 161 | case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; |
165 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; | 162 | case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; |
166 | default: break; | 163 | default: break; |
167 | } | 164 | } |
168 | 165 | ||
169 | // all of the following widths/heights are fb relative (0deg rotation) | 166 | // all of the following widths/heights are fb relative (0deg rotation) |
170 | 167 | ||
171 | uint leftfill = 0; // black border on the "left" side of the video frame | 168 | uint leftfill = 0; // black border on the "left" side of the video frame |
172 | uint framefill = 0; // "width" of the video frame | 169 | uint framefill = 0; // "width" of the video frame |
173 | uint rightfill = 0; // black border on the "right" side of the video frame | 170 | uint rightfill = 0; // black border on the "right" side of the video frame |
174 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | 171 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect |
175 | 172 | ||
176 | if ( clip. left ( ) < framerect. left ( )) | 173 | if ( clip. left ( ) < framerect. left ( )) |
177 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 174 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
178 | if ( clip. right ( ) > framerect. right ( )) | 175 | if ( clip. right ( ) > framerect. right ( )) |
179 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 176 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
180 | 177 | ||
181 | framefill = clipwidth - ( leftfill + rightfill ); | 178 | framefill = clipwidth - ( leftfill + rightfill ); |
182 | 179 | ||
183 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 180 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
184 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 181 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
185 | // "above" or "below" the video -> black | 182 | // "above" or "below" the video -> black |
186 | memset ( dst, 0, clipwidth ); | 183 | memset ( dst, 0, clipwidth ); |
187 | } | 184 | } |
188 | else { | 185 | else { |
189 | if ( leftfill ) | 186 | if ( leftfill ) |
190 | memset ( dst, 0, leftfill ); // "left" border -> black | 187 | memset ( dst, 0, leftfill ); // "left" border -> black |
191 | 188 | ||
192 | if ( framefill ) { // blit in the video frame | 189 | if ( framefill ) { // blit in the video frame |
193 | // see above for an explanation of the different memcpys | 190 | // see above for an explanation of the different memcpys |
194 | 191 | ||
195 | switch ( rot ) { | 192 | switch ( rot ) { |
196 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; | 193 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; |
197 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 194 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
198 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 195 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
199 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 196 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
200 | default: break; | 197 | default: break; |
201 | } | 198 | } |
202 | } | 199 | } |
203 | if ( rightfill ) | 200 | if ( rightfill ) |
204 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | 201 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black |
205 | } | 202 | } |
206 | 203 | ||
207 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | 204 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
208 | 205 | ||
209 | // advance one "line" in the xine frame data | 206 | // advance one "line" in the xine frame data |
210 | switch ( rot ) { | 207 | switch ( rot ) { |
211 | case 0: src += m_bytes_per_line_frame;break; | 208 | case 0: src += m_bytes_per_line_frame;break; |
212 | case 1: src -= m_bytes_per_pixel; break; | 209 | case 1: src -= m_bytes_per_pixel; break; |
213 | case 2: src -= m_bytes_per_line_frame; break; | 210 | case 2: src -= m_bytes_per_line_frame; break; |
214 | case 3: src += m_bytes_per_pixel; break; | 211 | case 3: src += m_bytes_per_pixel; break; |
215 | default: break; | 212 | default: break; |
216 | } | 213 | } |
217 | } | 214 | } |
218 | } | 215 | } |
219 | } | 216 | } |
220 | 217 | ||
221 | { | 218 | { |
222 | // QVFB hack by Martin Jones | 219 | // QVFB hack by Martin Jones |
223 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 220 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
224 | 221 | ||
225 | QPainter p ( this ); | 222 | QPainter p ( this ); |
226 | 223 | ||
227 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 224 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
228 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | 225 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); |
229 | } | 226 | } |
230 | } | 227 | } |
231 | } | 228 | } |
232 | } | 229 | } |
233 | 230 | ||
234 | 231 | ||
235 | QImage *XineVideoWidget::logo ( ) const | 232 | QImage *XineVideoWidget::logo ( ) const |
236 | { | 233 | { |
237 | return m_logo; | 234 | return m_logo; |
238 | } | 235 | } |
239 | 236 | ||
240 | 237 | ||
241 | void XineVideoWidget::setLogo ( QImage* logo ) | 238 | void XineVideoWidget::setLogo ( QImage* logo ) |
242 | { | 239 | { |
243 | delete m_logo; | 240 | delete m_logo; |
244 | m_logo = logo; | 241 | m_logo = logo; |
245 | } | 242 | } |
246 | 243 | ||
247 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) | 244 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
248 | { | 245 | { |
249 | bool rot90 = (( -m_rotation ) & 1 ); | 246 | bool rot90 = (( -m_rotation ) & 1 ); |
250 | 247 | ||
251 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 248 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
252 | int d = w; | 249 | int d = w; |
253 | w = h; | 250 | w = h; |
254 | h = d; | 251 | h = d; |
255 | } | 252 | } |
256 | 253 | ||
257 | m_lastframe = m_thisframe; | 254 | m_lastframe = m_thisframe; |
258 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 255 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
259 | 256 | ||
260 | m_buff = img; | 257 | m_buff = img; |
261 | m_bytes_per_line_frame = bpl; | 258 | m_bytes_per_line_frame = bpl; |
262 | 259 | ||
263 | // only repaint the area that *really* needs to be repainted | 260 | // only repaint the area that *really* needs to be repainted |
264 | 261 | ||
265 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 262 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
266 | } | 263 | } |
267 | 264 | ||
268 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 265 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
269 | { | 266 | { |
270 | emit videoResized( videoSize() ); | 267 | emit videoResized( videoSize() ); |
271 | } | 268 | } |
272 | 269 | ||
273 | 270 | ||
274 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 271 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
275 | { | 272 | { |
276 | emit clicked(); | 273 | emit clicked(); |
277 | } | 274 | } |
278 | 275 | ||
diff --git a/noncore/multimedia/opierec/main.cpp b/noncore/multimedia/opierec/main.cpp index 714907c..74a175b 100644 --- a/noncore/multimedia/opierec/main.cpp +++ b/noncore/multimedia/opierec/main.cpp | |||
@@ -1,30 +1,29 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | main.cpp - main routine | 2 | main.cpp - main routine |
3 | ***************************************************************************/ | 3 | ***************************************************************************/ |
4 | //// main.cpp | 4 | //// main.cpp |
5 | //// copyright 2001, 2002, by L. J. Potter <ljp@llornkcor.com> | 5 | //// copyright 2001, 2002, by L. J. Potter <ljp@llornkcor.com> |
6 | /*************************************************************************** | 6 | /*************************************************************************** |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "qtrec.h" | 12 | #include "qtrec.h" |
13 | #include <qpe/qpeapplication.h> | ||
14 | 13 | ||
15 | #ifdef PDAUDIO | 14 | #ifdef PDAUDIO |
16 | int main(int argc, char* argv[]) { | 15 | int main(int argc, char* argv[]) { |
17 | QPEApplication a(argc, argv); | 16 | QPEApplication a(argc, argv); |
18 | QtRec qtrec; | 17 | QtRec qtrec; |
19 | a.showMainWidget( &qtrec); | 18 | a.showMainWidget( &qtrec); |
20 | return a.exec(); | 19 | return a.exec(); |
21 | } | 20 | } |
22 | 21 | ||
23 | 22 | ||
24 | #else | 23 | #else |
25 | #include <opie/oapplicationfactory.h> | 24 | #include <opie/oapplicationfactory.h> |
26 | OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) | 25 | OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) |
27 | 26 | ||
28 | #endif | 27 | #endif |
29 | 28 | ||
30 | 29 | ||
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index f2035ef..1c64ab1 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -1,2133 +1,2132 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | // qtrec.cpp | 2 | // qtrec.cpp |
3 | Created: Thu Jan 17 11:19:58 2002 | 3 | Created: Thu Jan 17 11:19:58 2002 |
4 | copyright 2002 by L.J. Potter <ljp@llornkcor.com> | 4 | copyright 2002 by L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | #define DEV_VERSION | 6 | #define DEV_VERSION |
7 | 7 | ||
8 | #include "pixmaps.h" | 8 | #include "pixmaps.h" |
9 | #include "qtrec.h" | 9 | #include "qtrec.h" |
10 | #include "waveform.h" | 10 | #include "waveform.h" |
11 | #include "device.h" | ||
12 | 11 | ||
13 | #include <pthread.h> | 12 | #include <pthread.h> |
14 | 13 | ||
15 | extern "C" { | 14 | extern "C" { |
16 | #include "adpcm.h" | 15 | #include "adpcm.h" |
17 | } | 16 | } |
18 | 17 | ||
19 | #include <sys/soundcard.h> | 18 | #include <sys/soundcard.h> |
20 | 19 | ||
21 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
25 | #include <qpe/storage.h> | 24 | #include <qpe/storage.h> |
26 | 25 | ||
27 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
28 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
29 | //#include <qdatetime.h> | 28 | //#include <qdatetime.h> |
30 | #include <qdir.h> | 29 | #include <qdir.h> |
31 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
32 | #include <qlabel.h> | 31 | #include <qlabel.h> |
33 | #include <qlayout.h> | 32 | #include <qlayout.h> |
34 | #include <qlistview.h> | 33 | #include <qlistview.h> |
35 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
36 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
37 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
38 | #include <qslider.h> | 37 | #include <qslider.h> |
39 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
40 | #include <qtimer.h> | 39 | #include <qtimer.h> |
41 | 40 | ||
42 | #include <errno.h> | 41 | #include <errno.h> |
43 | #include <fcntl.h> | 42 | #include <fcntl.h> |
44 | #include <math.h> | 43 | #include <math.h> |
45 | #include <mntent.h> | 44 | #include <mntent.h> |
46 | #include <stdio.h> | 45 | #include <stdio.h> |
47 | #include <stdlib.h> | 46 | #include <stdlib.h> |
48 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
49 | #include <sys/soundcard.h> | 48 | #include <sys/soundcard.h> |
50 | #include <sys/stat.h> | 49 | #include <sys/stat.h> |
51 | #include <sys/time.h> | 50 | #include <sys/time.h> |
52 | #include <sys/types.h> | 51 | #include <sys/types.h> |
53 | #include <sys/vfs.h> | 52 | #include <sys/vfs.h> |
54 | #include <unistd.h> | 53 | #include <unistd.h> |
55 | #include <sys/wait.h> | 54 | #include <sys/wait.h> |
56 | #include <sys/signal.h> | 55 | #include <sys/signal.h> |
57 | 56 | ||
58 | 57 | ||
59 | #ifdef PDAUDIO //ALSA | 58 | #ifdef PDAUDIO //ALSA |
60 | #include <alsa/asoundlib.h> | 59 | #include <alsa/asoundlib.h> |
61 | static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; | 60 | static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; |
62 | static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; | 61 | static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; |
63 | #else //OSS | 62 | #else //OSS |
64 | static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; | 63 | static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; |
65 | static int deviceBitRates[] = { 8, 16, -1 }; | 64 | static int deviceBitRates[] = { 8, 16, -1 }; |
66 | #endif | 65 | #endif |
67 | 66 | ||
68 | #if defined(QT_QWS_SL5XXX) | 67 | #if defined(QT_QWS_SL5XXX) |
69 | ///#if defined(QT_QWS_EBX) | 68 | ///#if defined(QT_QWS_EBX) |
70 | 69 | ||
71 | #define DSPSTROUT "/dev/dsp" | 70 | #define DSPSTROUT "/dev/dsp" |
72 | #define DSPSTRIN "/dev/dsp1" | 71 | #define DSPSTRIN "/dev/dsp1" |
73 | #define DSPSTRMIXEROUT "/dev/mixer" | 72 | #define DSPSTRMIXEROUT "/dev/mixer" |
74 | #define DSPSTRMIXERIN "/dev/mixer1" | 73 | #define DSPSTRMIXERIN "/dev/mixer1" |
75 | 74 | ||
76 | #else | 75 | #else |
77 | 76 | ||
78 | #define DSPSTROUT "/dev/dsp" | 77 | #define DSPSTROUT "/dev/dsp" |
79 | #define DSPSTRIN "/dev/dsp" | 78 | #define DSPSTRIN "/dev/dsp" |
80 | #define DSPSTRMIXERIN "/dev/mixer" | 79 | #define DSPSTRMIXERIN "/dev/mixer" |
81 | #define DSPSTRMIXEROUT "/dev/mixer" | 80 | #define DSPSTRMIXEROUT "/dev/mixer" |
82 | 81 | ||
83 | #endif | 82 | #endif |
84 | 83 | ||
85 | //#define ZAURUS 0 | 84 | //#define ZAURUS 0 |
86 | struct adpcm_state encoder_state; | 85 | struct adpcm_state encoder_state; |
87 | struct adpcm_state decoder_state; | 86 | struct adpcm_state decoder_state; |
88 | 87 | ||
89 | typedef struct { | 88 | typedef struct { |
90 | int sampleRate; | 89 | int sampleRate; |
91 | /* int fragSize; */ | 90 | /* int fragSize; */ |
92 | /* int blockSize; */ | 91 | /* int blockSize; */ |
93 | int resolution; //bitrate | 92 | int resolution; //bitrate |
94 | int channels; //number of channels | 93 | int channels; //number of channels |
95 | int fd; //file descriptor | 94 | int fd; //file descriptor |
96 | int sd; //sound device descriptor | 95 | int sd; //sound device descriptor |
97 | int numberSamples; //total number of samples | 96 | int numberSamples; //total number of samples |
98 | int SecondsToRecord; // number of seconds that should be recorded | 97 | int SecondsToRecord; // number of seconds that should be recorded |
99 | float numberOfRecordedSeconds; //total number of samples recorded | 98 | float numberOfRecordedSeconds; //total number of samples recorded |
100 | int samplesToRecord; //number of samples to be recorded | 99 | int samplesToRecord; //number of samples to be recorded |
101 | int inVol; //input volume | 100 | int inVol; //input volume |
102 | int outVol; //output volume | 101 | int outVol; //output volume |
103 | int format; //wavfile format PCM.. ADPCM | 102 | int format; //wavfile format PCM.. ADPCM |
104 | const char *fileName; //name of fiel to be played/recorded | 103 | const char *fileName; //name of fiel to be played/recorded |
105 | } fileParameters; | 104 | } fileParameters; |
106 | 105 | ||
107 | fileParameters filePara; | 106 | fileParameters filePara; |
108 | 107 | ||
109 | bool monitoring, recording, playing; | 108 | bool monitoring, recording, playing; |
110 | bool stopped; | 109 | bool stopped; |
111 | QLabel *timeLabel; | 110 | QLabel *timeLabel; |
112 | QSlider *timeSlider; | 111 | QSlider *timeSlider; |
113 | int sd; | 112 | int sd; |
114 | 113 | ||
115 | Waveform* waveform; | 114 | Waveform* waveform; |
116 | Device *soundDevice; | 115 | Device *soundDevice; |
117 | 116 | ||
118 | 117 | ||
119 | #ifdef THREADED | 118 | #ifdef THREADED |
120 | void quickRec() | 119 | void quickRec() |
121 | #else | 120 | #else |
122 | void QtRec::quickRec() | 121 | void QtRec::quickRec() |
123 | #endif | 122 | #endif |
124 | { | 123 | { |
125 | 124 | ||
126 | qDebug("%d", | 125 | qDebug("%d", |
127 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | 126 | filePara.numberSamples/filePara.sampleRate * filePara.channels); |
128 | qDebug("samples %d, rate %d, channels %d", | 127 | qDebug("samples %d, rate %d, channels %d", |
129 | filePara.numberSamples, filePara.sampleRate, filePara.channels); | 128 | filePara.numberSamples, filePara.sampleRate, filePara.channels); |
130 | 129 | ||
131 | int total = 0; // Total number of bytes read in so far. | 130 | int total = 0; // Total number of bytes read in so far. |
132 | int bytesWritten, number; | 131 | int bytesWritten, number; |
133 | 132 | ||
134 | bytesWritten = 0; | 133 | bytesWritten = 0; |
135 | number = 0; | 134 | number = 0; |
136 | QString num; | 135 | QString num; |
137 | int level = 0; | 136 | int level = 0; |
138 | int threshold = 0; | 137 | int threshold = 0; |
139 | // int bits = filePara.resolution; | 138 | // int bits = filePara.resolution; |
140 | // qDebug("bits %d", bits); | 139 | // qDebug("bits %d", bits); |
141 | 140 | ||
142 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 141 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
143 | // qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); | 142 | // qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); |
144 | // qDebug("samples to record %d", filePara.samplesToRecord); | 143 | // qDebug("samples to record %d", filePara.samplesToRecord); |
145 | // qDebug("%d", filePara.sd); | 144 | // qDebug("%d", filePara.sd); |
146 | level = 7; | 145 | level = 7; |
147 | threshold = 0; | 146 | threshold = 0; |
148 | 147 | ||
149 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 148 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
150 | // qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); | 149 | // qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); |
151 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 150 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
152 | char abuf[ BUFSIZE/2 ]; | 151 | char abuf[ BUFSIZE/2 ]; |
153 | short sbuf[ BUFSIZE ]; | 152 | short sbuf[ BUFSIZE ]; |
154 | short sbuf2[ BUFSIZE ]; | 153 | short sbuf2[ BUFSIZE ]; |
155 | memset( abuf, 0, BUFSIZE/2); | 154 | memset( abuf, 0, BUFSIZE/2); |
156 | memset( sbuf, 0, BUFSIZE); | 155 | memset( sbuf, 0, BUFSIZE); |
157 | memset( sbuf2, 0, BUFSIZE); | 156 | memset( sbuf2, 0, BUFSIZE); |
158 | 157 | ||
159 | for(;;) { | 158 | for(;;) { |
160 | if ( stopped) { | 159 | if ( stopped) { |
161 | // qDebug("quickRec:: stopped"); | 160 | // qDebug("quickRec:: stopped"); |
162 | break; | 161 | break; |
163 | } | 162 | } |
164 | 163 | ||
165 | // number=::read( filePara.sd, sbuf, BUFSIZE); | 164 | // number=::read( filePara.sd, sbuf, BUFSIZE); |
166 | number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); | 165 | number = soundDevice ->devRead( filePara.sd, sbuf, BUFSIZE); |
167 | 166 | ||
168 | if(number <= 0) { | 167 | if(number <= 0) { |
169 | perror("recording error "); | 168 | perror("recording error "); |
170 | qDebug( "%s %d", filePara.fileName, number); | 169 | qDebug( "%s %d", filePara.fileName, number); |
171 | stopped = true; | 170 | stopped = true; |
172 | return; | 171 | return; |
173 | } | 172 | } |
174 | //if(stereo == 2) { | 173 | //if(stereo == 2) { |
175 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 174 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
176 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 175 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
177 | 176 | ||
178 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); | 177 | bytesWritten = ::write( filePara.fd , (short *)abuf, number/4); |
179 | 178 | ||
180 | waveform->newSamples( (const short *)abuf, bytesWritten ); | 179 | waveform->newSamples( (const short *)abuf, bytesWritten ); |
181 | 180 | ||
182 | total += bytesWritten; | 181 | total += bytesWritten; |
183 | filePara.numberSamples = total; | 182 | filePara.numberSamples = total; |
184 | timeSlider->setValue( total); | 183 | timeSlider->setValue( total); |
185 | 184 | ||
186 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; | 185 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2 / filePara.channels; |
187 | 186 | ||
188 | qApp->processEvents(); | 187 | qApp->processEvents(); |
189 | if( total >= filePara.samplesToRecord) { | 188 | if( total >= filePara.samplesToRecord) { |
190 | stopped = true; | 189 | stopped = true; |
191 | break; | 190 | break; |
192 | } | 191 | } |
193 | } | 192 | } |
194 | } else { | 193 | } else { |
195 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 194 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> |
196 | qDebug("start recording WAVE_FORMAT_PCM"); | 195 | qDebug("start recording WAVE_FORMAT_PCM"); |
197 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; | 196 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; |
198 | memset( inbuffer, 0, BUFSIZE); | 197 | memset( inbuffer, 0, BUFSIZE); |
199 | memset( outbuffer, 0, BUFSIZE); | 198 | memset( outbuffer, 0, BUFSIZE); |
200 | 199 | ||
201 | for(;;) { | 200 | for(;;) { |
202 | if ( stopped) { | 201 | if ( stopped) { |
203 | qDebug("quickRec:: stopped"); | 202 | qDebug("quickRec:: stopped"); |
204 | stopped = true; | 203 | stopped = true; |
205 | break; // stop if playing was set to false | 204 | break; // stop if playing was set to false |
206 | return; | 205 | return; |
207 | } | 206 | } |
208 | 207 | ||
209 | number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); | 208 | number = soundDevice->devRead( filePara.sd, (short *)inbuffer, BUFSIZE); |
210 | waveform->newSamples( inbuffer, number ); | 209 | waveform->newSamples( inbuffer, number ); |
211 | 210 | ||
212 | if( number <= 0) { | 211 | if( number <= 0) { |
213 | perror( "recording error "); | 212 | perror( "recording error "); |
214 | qDebug( filePara.fileName); | 213 | qDebug( filePara.fileName); |
215 | stopped = true; | 214 | stopped = true; |
216 | return; | 215 | return; |
217 | } | 216 | } |
218 | 217 | ||
219 | bytesWritten = ::write( filePara.fd , inbuffer, number); | 218 | bytesWritten = ::write( filePara.fd , inbuffer, number); |
220 | 219 | ||
221 | if( bytesWritten < 0) { | 220 | if( bytesWritten < 0) { |
222 | perror("File writing error "); | 221 | perror("File writing error "); |
223 | stopped = true; | 222 | stopped = true; |
224 | return; | 223 | return; |
225 | } | 224 | } |
226 | 225 | ||
227 | total += bytesWritten; | 226 | total += bytesWritten; |
228 | 227 | ||
229 | filePara.numberSamples = total; | 228 | filePara.numberSamples = total; |
230 | 229 | ||
231 | if( filePara.SecondsToRecord != 0) | 230 | if( filePara.SecondsToRecord != 0) |
232 | timeSlider->setValue( total); | 231 | timeSlider->setValue( total); |
233 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); | 232 | // printf("Writing number %d, bytes %d,total %d\r",number, bytesWritten , total); |
234 | // fflush(stdout); | 233 | // fflush(stdout); |
235 | 234 | ||
236 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; | 235 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2/filePara.channels; |
237 | qApp->processEvents(); | 236 | qApp->processEvents(); |
238 | 237 | ||
239 | if( total >= filePara.samplesToRecord) { | 238 | if( total >= filePara.samplesToRecord) { |
240 | stopped = true; | 239 | stopped = true; |
241 | break; | 240 | break; |
242 | } | 241 | } |
243 | } | 242 | } |
244 | } //end main loop | 243 | } //end main loop |
245 | 244 | ||
246 | } else { | 245 | } else { |
247 | // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; | 246 | // <<<<<<<<<<<<<<<<<<<<<<< format = AFMT_U8; |
248 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; | 247 | unsigned char unsigned_inbuffer[ BUFSIZE ], unsigned_outbuffer[ BUFSIZE ]; |
249 | memset( unsigned_inbuffer, 0, BUFSIZE); | 248 | memset( unsigned_inbuffer, 0, BUFSIZE); |
250 | memset( unsigned_outbuffer, 0, BUFSIZE); | 249 | memset( unsigned_outbuffer, 0, BUFSIZE); |
251 | 250 | ||
252 | for(;;) { | 251 | for(;;) { |
253 | if ( stopped) { | 252 | if ( stopped) { |
254 | qDebug("quickRec:: stopped"); | 253 | qDebug("quickRec:: stopped"); |
255 | break; // stop if playing was set to false | 254 | break; // stop if playing was set to false |
256 | } | 255 | } |
257 | 256 | ||
258 | number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); | 257 | number = ::read( filePara.sd, unsigned_inbuffer, BUFSIZE); |
259 | bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); | 258 | bytesWritten = ::write( filePara.fd , unsigned_inbuffer, number); |
260 | 259 | ||
261 | if(bytesWritten < 0) { | 260 | if(bytesWritten < 0) { |
262 | stopped = true; | 261 | stopped = true; |
263 | QMessageBox::message("Note","There was a problem\nwriting to the file"); | 262 | QMessageBox::message("Note","There was a problem\nwriting to the file"); |
264 | perror("File writing error "); | 263 | perror("File writing error "); |
265 | return; | 264 | return; |
266 | } | 265 | } |
267 | 266 | ||
268 | total += bytesWritten; | 267 | total += bytesWritten; |
269 | filePara.numberSamples = total; | 268 | filePara.numberSamples = total; |
270 | // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); | 269 | // printf("\nWriting number %d, bytes %d,total %d \r",number, bytesWritten , total); |
271 | // fflush(stdout); | 270 | // fflush(stdout); |
272 | if( filePara.SecondsToRecord !=0) | 271 | if( filePara.SecondsToRecord !=0) |
273 | timeSlider->setValue( total); | 272 | timeSlider->setValue( total); |
274 | 273 | ||
275 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; | 274 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; |
276 | 275 | ||
277 | qApp->processEvents(); | 276 | qApp->processEvents(); |
278 | if( total >= filePara.samplesToRecord) { | 277 | if( total >= filePara.samplesToRecord) { |
279 | stopped = true; | 278 | stopped = true; |
280 | break; | 279 | break; |
281 | } | 280 | } |
282 | } //end main loop | 281 | } //end main loop |
283 | } | 282 | } |
284 | } /// END quickRec() | 283 | } /// END quickRec() |
285 | 284 | ||
286 | 285 | ||
287 | #ifdef THREADED | 286 | #ifdef THREADED |
288 | void playIt() | 287 | void playIt() |
289 | #else | 288 | #else |
290 | void QtRec::playIt() | 289 | void QtRec::playIt() |
291 | #endif | 290 | #endif |
292 | { | 291 | { |
293 | int bytesWritten = 0; | 292 | int bytesWritten = 0; |
294 | int number = 0; | 293 | int number = 0; |
295 | int total = 0; // Total number of bytes read in so far. | 294 | int total = 0; // Total number of bytes read in so far. |
296 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { | 295 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { |
297 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { | 296 | if( filePara.format == WAVE_FORMAT_DVI_ADPCM) { |
298 | char abuf[ BUFSIZE / 2 ]; | 297 | char abuf[ BUFSIZE / 2 ]; |
299 | short sbuf[ BUFSIZE ]; | 298 | short sbuf[ BUFSIZE ]; |
300 | short sbuf2[ BUFSIZE * 2 ]; | 299 | short sbuf2[ BUFSIZE * 2 ]; |
301 | memset( abuf, 0, BUFSIZE / 2); | 300 | memset( abuf, 0, BUFSIZE / 2); |
302 | memset( sbuf, 0, BUFSIZE); | 301 | memset( sbuf, 0, BUFSIZE); |
303 | memset( sbuf2, 0, BUFSIZE * 2); | 302 | memset( sbuf2, 0, BUFSIZE * 2); |
304 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 303 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
305 | for(;;) { // play loop | 304 | for(;;) { // play loop |
306 | if ( stopped) { | 305 | if ( stopped) { |
307 | break; | 306 | break; |
308 | return; | 307 | return; |
309 | }// stop if playing was set to false | 308 | }// stop if playing was set to false |
310 | 309 | ||
311 | number = ::read( filePara.fd, abuf, BUFSIZE / 2); | 310 | number = ::read( filePara.fd, abuf, BUFSIZE / 2); |
312 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); | 311 | adpcm_decoder( abuf, sbuf, number * 2, &decoder_state); |
313 | 312 | ||
314 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 313 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
315 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; | 314 | // sbuf2[i+1]=sbuf2[i]=sbuf[i]; |
316 | // } | 315 | // } |
317 | bytesWritten = write ( filePara.sd, sbuf, number * 4); | 316 | bytesWritten = write ( filePara.sd, sbuf, number * 4); |
318 | waveform->newSamples( (const short *)sbuf, number ); | 317 | waveform->newSamples( (const short *)sbuf, number ); |
319 | // if(filePara.channels==1) | 318 | // if(filePara.channels==1) |
320 | // total += bytesWritten/2; //mono | 319 | // total += bytesWritten/2; //mono |
321 | // else | 320 | // else |
322 | total += bytesWritten; | 321 | total += bytesWritten; |
323 | filePara.numberSamples = total/4; | 322 | filePara.numberSamples = total/4; |
324 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; | 323 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / 2; |
325 | 324 | ||
326 | timeSlider->setValue( total/4); | 325 | timeSlider->setValue( total/4); |
327 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 326 | // timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
328 | // if(filePara.numberOfRecordedSeconds>1) | 327 | // if(filePara.numberOfRecordedSeconds>1) |
329 | // timeLabel->setText( timeString+ tr(" seconds")); | 328 | // timeLabel->setText( timeString+ tr(" seconds")); |
330 | // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); | 329 | // printf("playing number %d, bytes %d, total %d\n",number, bytesWritten, total/4); |
331 | // fflush(stdout); | 330 | // fflush(stdout); |
332 | 331 | ||
333 | qApp->processEvents(); | 332 | qApp->processEvents(); |
334 | 333 | ||
335 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 334 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
336 | // if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { | 335 | // if( total >= filePara.numberSamples ){//|| secCount > filePara.numberOfRecordedSeconds ) { |
337 | stopped = true; | 336 | stopped = true; |
338 | break; | 337 | break; |
339 | } | 338 | } |
340 | } | 339 | } |
341 | } else { | 340 | } else { |
342 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 341 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> |
343 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; | 342 | short inbuffer[ BUFSIZE ], outbuffer[ BUFSIZE ]; |
344 | memset( inbuffer, 0, BUFSIZE); | 343 | memset( inbuffer, 0, BUFSIZE); |
345 | memset( outbuffer, 0, BUFSIZE); | 344 | memset( outbuffer, 0, BUFSIZE); |
346 | 345 | ||
347 | for(;;) { // play loop | 346 | for(;;) { // play loop |
348 | if ( stopped) { | 347 | if ( stopped) { |
349 | break; | 348 | break; |
350 | return; | 349 | return; |
351 | } | 350 | } |
352 | // stop if playing was set to false | 351 | // stop if playing was set to false |
353 | number = ::read( filePara.fd, inbuffer, BUFSIZE); | 352 | number = ::read( filePara.fd, inbuffer, BUFSIZE); |
354 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel | 353 | // for (int i=0;i< number * 2; 2 * i++) { //2*i is left channel |
355 | // // for (int i=0;i< number ; i++) { //2*i is left channel | 354 | // // for (int i=0;i< number ; i++) { //2*i is left channel |
356 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; | 355 | // outbuffer[i+1]= outbuffer[i]=inbuffer[i]; |
357 | // } | 356 | // } |
358 | bytesWritten = ::write( filePara.sd, inbuffer, number); | 357 | bytesWritten = ::write( filePara.sd, inbuffer, number); |
359 | waveform->newSamples( inbuffer, bytesWritten ); | 358 | waveform->newSamples( inbuffer, bytesWritten ); |
360 | //-------------->>>> out to device | 359 | //-------------->>>> out to device |
361 | // total+=bytesWritten; | 360 | // total+=bytesWritten; |
362 | // if(filePara.channels==1) | 361 | // if(filePara.channels==1) |
363 | // total += bytesWritten/2; //mono | 362 | // total += bytesWritten/2; //mono |
364 | // else | 363 | // else |
365 | total += bytesWritten; | 364 | total += bytesWritten; |
366 | timeSlider->setValue( total); | 365 | timeSlider->setValue( total); |
367 | 366 | ||
368 | filePara.numberSamples = total; | 367 | filePara.numberSamples = total; |
369 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; | 368 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; |
370 | 369 | ||
371 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); | 370 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); |
372 | // timeLabel->setText( timeString + tr(" seconds")); | 371 | // timeLabel->setText( timeString + tr(" seconds")); |
373 | 372 | ||
374 | qApp->processEvents(); | 373 | qApp->processEvents(); |
375 | 374 | ||
376 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 375 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
377 | qWarning("Jane! Stop this crazy thing!"); | 376 | qWarning("Jane! Stop this crazy thing!"); |
378 | stopped = true; | 377 | stopped = true; |
379 | // playing = false; | 378 | // playing = false; |
380 | break; | 379 | break; |
381 | } | 380 | } |
382 | } | 381 | } |
383 | printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); | 382 | printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); |
384 | fflush(stdout); | 383 | fflush(stdout); |
385 | } //end loop | 384 | } //end loop |
386 | } else { | 385 | } else { |
387 | /////////////////////////////// format = AFMT_U8; | 386 | /////////////////////////////// format = AFMT_U8; |
388 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; | 387 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; |
389 | memset( unsigned_inbuffer, 0, BUFSIZE); | 388 | memset( unsigned_inbuffer, 0, BUFSIZE); |
390 | for(;;) { | 389 | for(;;) { |
391 | // main loop | 390 | // main loop |
392 | if (stopped) { | 391 | if (stopped) { |
393 | break; // stop if playing was set to false | 392 | break; // stop if playing was set to false |
394 | return; | 393 | return; |
395 | } | 394 | } |
396 | number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); | 395 | number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); |
397 | //data = (val >> 8) ^ 0x80; | 396 | //data = (val >> 8) ^ 0x80; |
398 | // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; | 397 | // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; |
399 | bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); | 398 | bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); |
400 | waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); | 399 | waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); |
401 | total += bytesWritten; | 400 | total += bytesWritten; |
402 | 401 | ||
403 | timeSlider->setValue( total); | 402 | timeSlider->setValue( total); |
404 | filePara.numberSamples = total; | 403 | filePara.numberSamples = total; |
405 | 404 | ||
406 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; | 405 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; |
407 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); | 406 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); |
408 | // timeLabel->setText( timeString + tr(" seconds")); | 407 | // timeLabel->setText( timeString + tr(" seconds")); |
409 | qApp->processEvents(); | 408 | qApp->processEvents(); |
410 | 409 | ||
411 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 410 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
412 | // if( total >= filePara.numberSamples ) { | 411 | // if( total >= filePara.numberSamples ) { |
413 | stopped = true; | 412 | stopped = true; |
414 | break; | 413 | break; |
415 | } | 414 | } |
416 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); | 415 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); |
417 | // fflush(stdout); | 416 | // fflush(stdout); |
418 | } | 417 | } |
419 | } | 418 | } |
420 | } | 419 | } |
421 | 420 | ||
422 | 421 | ||
423 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | 422 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) |
424 | : QWidget( parent, name, fl ) | 423 | : QWidget( parent, name, fl ) |
425 | { | 424 | { |
426 | if ( !name ) | 425 | if ( !name ) |
427 | setName( "OpieRec" ); | 426 | setName( "OpieRec" ); |
428 | init(); | 427 | init(); |
429 | initConfig(); | 428 | initConfig(); |
430 | initConnections(); | 429 | initConnections(); |
431 | renameBox = 0; | 430 | renameBox = 0; |
432 | 431 | ||
433 | // open sound device to get volumes | 432 | // open sound device to get volumes |
434 | Config hwcfg("OpieRec"); | 433 | Config hwcfg("OpieRec"); |
435 | hwcfg.setGroup("Hardware"); | 434 | hwcfg.setGroup("Hardware"); |
436 | 435 | ||
437 | 436 | ||
438 | soundDevice = new Device( this, | 437 | soundDevice = new Device( this, |
439 | hwcfg.readEntry( "Audio",DSPSTROUT), | 438 | hwcfg.readEntry( "Audio",DSPSTROUT), |
440 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); | 439 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); |
441 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); | 440 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); |
442 | 441 | ||
443 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | 442 | // soundDevice->setDeviceFormat(AFMT_S16_LE); |
444 | // soundDevice->setDeviceChannels(1); | 443 | // soundDevice->setDeviceChannels(1); |
445 | // soundDevice->setDeviceRate( 22050); | 444 | // soundDevice->setDeviceRate( 22050); |
446 | 445 | ||
447 | getInVol(); | 446 | getInVol(); |
448 | getOutVol(); | 447 | getOutVol(); |
449 | 448 | ||
450 | soundDevice->closeDevice( true); | 449 | soundDevice->closeDevice( true); |
451 | soundDevice->sd = -1; | 450 | soundDevice->sd = -1; |
452 | soundDevice = 0; | 451 | soundDevice = 0; |
453 | wavFile = 0; | 452 | wavFile = 0; |
454 | 453 | ||
455 | if( soundDevice) delete soundDevice; | 454 | if( soundDevice) delete soundDevice; |
456 | 455 | ||
457 | initIconView(); | 456 | initIconView(); |
458 | 457 | ||
459 | if( autoMute) | 458 | if( autoMute) |
460 | doMute( true); | 459 | doMute( true); |
461 | ListView1->setFocus(); | 460 | ListView1->setFocus(); |
462 | playing = false; | 461 | playing = false; |
463 | } | 462 | } |
464 | 463 | ||
465 | QtRec::~QtRec() { | 464 | QtRec::~QtRec() { |
466 | 465 | ||
467 | } | 466 | } |
468 | 467 | ||
469 | void QtRec::cleanUp() { | 468 | void QtRec::cleanUp() { |
470 | 469 | ||
471 | if( !stopped) { | 470 | if( !stopped) { |
472 | stopped = true; | 471 | stopped = true; |
473 | endRecording(); | 472 | endRecording(); |
474 | } | 473 | } |
475 | 474 | ||
476 | ListView1->clear(); | 475 | ListView1->clear(); |
477 | 476 | ||
478 | if( autoMute) | 477 | if( autoMute) |
479 | doMute(false); | 478 | doMute(false); |
480 | 479 | ||
481 | if( wavFile) delete wavFile; | 480 | if( wavFile) delete wavFile; |
482 | // if(soundDevice) delete soundDevice; | 481 | // if(soundDevice) delete soundDevice; |
483 | } | 482 | } |
484 | 483 | ||
485 | void QtRec::init() { | 484 | void QtRec::init() { |
486 | 485 | ||
487 | needsStereoOut = false; | 486 | needsStereoOut = false; |
488 | QPixmap image3( ( const char** ) image3_data ); | 487 | QPixmap image3( ( const char** ) image3_data ); |
489 | QPixmap image4( ( const char** ) image4_data ); | 488 | QPixmap image4( ( const char** ) image4_data ); |
490 | QPixmap image6( ( const char** ) image6_data ); | 489 | QPixmap image6( ( const char** ) image6_data ); |
491 | 490 | ||
492 | stopped = true; | 491 | stopped = true; |
493 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 492 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
494 | QGridLayout *layout = new QGridLayout( this ); | 493 | QGridLayout *layout = new QGridLayout( this ); |
495 | layout->setSpacing( 2); | 494 | layout->setSpacing( 2); |
496 | layout->setMargin( 2); | 495 | layout->setMargin( 2); |
497 | 496 | ||
498 | TabWidget = new QTabWidget( this, "TabWidget" ); | 497 | TabWidget = new QTabWidget( this, "TabWidget" ); |
499 | layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); | 498 | layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); |
500 | // TabWidget->setTabShape(QTabWidget::Triangular); | 499 | // TabWidget->setTabShape(QTabWidget::Triangular); |
501 | 500 | ||
502 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 501 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
503 | tab = new QWidget( TabWidget, "tab" ); | 502 | tab = new QWidget( TabWidget, "tab" ); |
504 | 503 | ||
505 | QGridLayout *layout1 = new QGridLayout( tab); | 504 | QGridLayout *layout1 = new QGridLayout( tab); |
506 | layout1->setSpacing( 2); | 505 | layout1->setSpacing( 2); |
507 | layout1->setMargin( 2); | 506 | layout1->setMargin( 2); |
508 | 507 | ||
509 | timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); | 508 | timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); |
510 | layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); | 509 | layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); |
511 | 510 | ||
512 | timeLabel = new QLabel( tab, "TimeLabel" ); | 511 | timeLabel = new QLabel( tab, "TimeLabel" ); |
513 | layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); | 512 | layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); |
514 | 513 | ||
515 | playLabel2 = new QLabel(tab, "PlayLabel2" ); | 514 | playLabel2 = new QLabel(tab, "PlayLabel2" ); |
516 | playLabel2->setText(tr("Play") ); | 515 | playLabel2->setText(tr("Play") ); |
517 | playLabel2->setFixedHeight( 18); | 516 | playLabel2->setFixedHeight( 18); |
518 | layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); | 517 | layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); |
519 | 518 | ||
520 | Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); | 519 | Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); |
521 | layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); | 520 | layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); |
522 | Stop_PushButton->setFixedSize( 22, 22); | 521 | Stop_PushButton->setFixedSize( 22, 22); |
523 | Stop_PushButton->setPixmap( image4 ); | 522 | Stop_PushButton->setPixmap( image4 ); |
524 | 523 | ||
525 | toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); | 524 | toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); |
526 | layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); | 525 | layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); |
527 | toBeginningButton->setFixedSize( 22, 22); | 526 | toBeginningButton->setFixedSize( 22, 22); |
528 | toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); | 527 | toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); |
529 | 528 | ||
530 | toEndButton = new QPushButton( tab, "End_PushButton" ); | 529 | toEndButton = new QPushButton( tab, "End_PushButton" ); |
531 | layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); | 530 | layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); |
532 | toEndButton->setFixedSize( 22, 22); | 531 | toEndButton->setFixedSize( 22, 22); |
533 | toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); | 532 | toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); |
534 | 533 | ||
535 | QLabel *recLabel2; | 534 | QLabel *recLabel2; |
536 | recLabel2 = new QLabel( tab, "recLabel2" ); | 535 | recLabel2 = new QLabel( tab, "recLabel2" ); |
537 | recLabel2->setText(tr("Rec")); | 536 | recLabel2->setText(tr("Rec")); |
538 | recLabel2->setFixedHeight( 18); | 537 | recLabel2->setFixedHeight( 18); |
539 | layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); | 538 | layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); |
540 | 539 | ||
541 | Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); | 540 | Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); |
542 | layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); | 541 | layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); |
543 | Rec_PushButton->setFixedSize( 22, 22); | 542 | Rec_PushButton->setFixedSize( 22, 22); |
544 | Rec_PushButton->setPixmap( image6 ); | 543 | Rec_PushButton->setPixmap( image6 ); |
545 | 544 | ||
546 | t = new QTimer( this ); | 545 | t = new QTimer( this ); |
547 | connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 546 | connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
548 | 547 | ||
549 | rewindTimer = new QTimer( this ); | 548 | rewindTimer = new QTimer( this ); |
550 | connect( rewindTimer, SIGNAL( timeout() ), | 549 | connect( rewindTimer, SIGNAL( timeout() ), |
551 | this, SLOT( rewindTimerTimeout() ) ); | 550 | this, SLOT( rewindTimerTimeout() ) ); |
552 | 551 | ||
553 | forwardTimer = new QTimer( this ); | 552 | forwardTimer = new QTimer( this ); |
554 | connect( forwardTimer, SIGNAL( timeout() ), | 553 | connect( forwardTimer, SIGNAL( timeout() ), |
555 | this, SLOT( forwardTimerTimeout() ) ); | 554 | this, SLOT( forwardTimerTimeout() ) ); |
556 | 555 | ||
557 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); | 556 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); |
558 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); | 557 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); |
559 | deleteSoundButton->setText( tr( "Delete" ) ); | 558 | deleteSoundButton->setText( tr( "Delete" ) ); |
560 | 559 | ||
561 | ListView1 = new QListView( tab, "IconView1" ); | 560 | ListView1 = new QListView( tab, "IconView1" ); |
562 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); | 561 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); |
563 | 562 | ||
564 | ListView1->addColumn( tr( "Name" ) ); | 563 | ListView1->addColumn( tr( "Name" ) ); |
565 | ListView1->setColumnWidth( 0, 140); | 564 | ListView1->setColumnWidth( 0, 140); |
566 | ListView1->setSorting( 1, false); | 565 | ListView1->setSorting( 1, false); |
567 | ListView1->addColumn( tr( "Time" ) ); //in seconds | 566 | ListView1->addColumn( tr( "Time" ) ); //in seconds |
568 | ListView1->setColumnWidth( 1, 50); | 567 | ListView1->setColumnWidth( 1, 50); |
569 | ListView1->addColumn( tr("Location") ); | 568 | ListView1->addColumn( tr("Location") ); |
570 | ListView1->setColumnWidth( 2, 50); | 569 | ListView1->setColumnWidth( 2, 50); |
571 | ListView1->addColumn( tr("Date") ); | 570 | ListView1->addColumn( tr("Date") ); |
572 | ListView1->setColumnWidth( 3, 63); | 571 | ListView1->setColumnWidth( 3, 63); |
573 | 572 | ||
574 | ListView1->setColumnWidthMode( 0, QListView::Manual); | 573 | ListView1->setColumnWidthMode( 0, QListView::Manual); |
575 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); | 574 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); |
576 | ListView1->setColumnAlignment( 2, QListView::AlignRight); | 575 | ListView1->setColumnAlignment( 2, QListView::AlignRight); |
577 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); | 576 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); |
578 | ListView1->setAllColumnsShowFocus( true ); | 577 | ListView1->setAllColumnsShowFocus( true ); |
579 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); | 578 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); |
580 | 579 | ||
581 | TabWidget->insertTab( tab, tr( "Files" ) ); | 580 | TabWidget->insertTab( tab, tr( "Files" ) ); |
582 | 581 | ||
583 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 582 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
584 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 583 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
585 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); | 584 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); |
586 | glayout3->setSpacing( 2); | 585 | glayout3->setSpacing( 2); |
587 | glayout3->setMargin( 2); | 586 | glayout3->setMargin( 2); |
588 | //////////////////////////////////// | 587 | //////////////////////////////////// |
589 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 588 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
590 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 589 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
591 | sampleGroup->setFixedSize( 95,50); | 590 | sampleGroup->setFixedSize( 95,50); |
592 | 591 | ||
593 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 592 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
594 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 593 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
595 | //#ifndef QT_QWS_EBX | 594 | //#ifndef QT_QWS_EBX |
596 | QString s; | 595 | QString s; |
597 | int z = 0; | 596 | int z = 0; |
598 | while( deviceSampleRates[z] != -1) { | 597 | while( deviceSampleRates[z] != -1) { |
599 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); | 598 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); |
600 | z++; | 599 | z++; |
601 | } | 600 | } |
602 | 601 | ||
603 | 602 | ||
604 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); | 603 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); |
605 | 604 | ||
606 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 605 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
607 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 606 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
608 | sizeGroup->setFixedSize( 80, 50); | 607 | sizeGroup->setFixedSize( 80, 50); |
609 | 608 | ||
610 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 609 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
611 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); | 610 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); |
612 | sizeLimitCombo->insertItem(tr("Unlimited")); | 611 | sizeLimitCombo->insertItem(tr("Unlimited")); |
613 | 612 | ||
614 | for(int i=1;i<13; i++) { | 613 | for(int i=1;i<13; i++) { |
615 | sizeLimitCombo->insertItem( QString::number( i * 5)); | 614 | sizeLimitCombo->insertItem( QString::number( i * 5)); |
616 | } | 615 | } |
617 | 616 | ||
618 | 617 | ||
619 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); | 618 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); |
620 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); | 619 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); |
621 | dirGroup->setTitle( tr( "File Directory" ) ); | 620 | dirGroup->setTitle( tr( "File Directory" ) ); |
622 | dirGroup->setFixedSize( 130, 50); | 621 | dirGroup->setFixedSize( 130, 50); |
623 | 622 | ||
624 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); | 623 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); |
625 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); | 624 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); |
626 | 625 | ||
627 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); | 626 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); |
628 | 627 | ||
629 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); | 628 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); |
630 | bitGroup->setTitle( tr( "Bit Depth" ) ); | 629 | bitGroup->setTitle( tr( "Bit Depth" ) ); |
631 | bitGroup->setFixedSize( 65, 50); | 630 | bitGroup->setFixedSize( 65, 50); |
632 | 631 | ||
633 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); | 632 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); |
634 | 633 | ||
635 | z = 0; | 634 | z = 0; |
636 | while( deviceBitRates[z] != -1) { | 635 | while( deviceBitRates[z] != -1) { |
637 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); | 636 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); |
638 | z++; | 637 | z++; |
639 | } | 638 | } |
640 | 639 | ||
641 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | 640 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); |
642 | 641 | ||
643 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); | 642 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); |
644 | 643 | ||
645 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); | 644 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); |
646 | 645 | ||
647 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); | 646 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); |
648 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); | 647 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); |
649 | 648 | ||
650 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); | 649 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); |
651 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); | 650 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); |
652 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); | 651 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); |
653 | 652 | ||
654 | tab_5 = new QWidget( TabWidget, "tab_5" ); | 653 | tab_5 = new QWidget( TabWidget, "tab_5" ); |
655 | 654 | ||
656 | QHBoxLayout *Layout19a; | 655 | QHBoxLayout *Layout19a; |
657 | Layout19a = new QHBoxLayout( tab_5); | 656 | Layout19a = new QHBoxLayout( tab_5); |
658 | Layout19a->setSpacing( 2 ); | 657 | Layout19a->setSpacing( 2 ); |
659 | Layout19a->setMargin( 0 ); | 658 | Layout19a->setMargin( 0 ); |
660 | 659 | ||
661 | Layout15 = new QVBoxLayout( this); | 660 | Layout15 = new QVBoxLayout( this); |
662 | Layout15->setSpacing( 2 ); | 661 | Layout15->setSpacing( 2 ); |
663 | Layout15->setMargin( 0 ); | 662 | Layout15->setMargin( 0 ); |
664 | 663 | ||
665 | Layout15b = new QVBoxLayout( this); | 664 | Layout15b = new QVBoxLayout( this); |
666 | Layout15b->setSpacing( 2 ); | 665 | Layout15b->setSpacing( 2 ); |
667 | Layout15b->setMargin( 0 ); | 666 | Layout15b->setMargin( 0 ); |
668 | 667 | ||
669 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); | 668 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); |
670 | TextLabel2->setText( tr( "In")); | 669 | TextLabel2->setText( tr( "In")); |
671 | TextLabel2->setFixedWidth( 35); | 670 | TextLabel2->setFixedWidth( 35); |
672 | Layout15->addWidget( TextLabel2 ); | 671 | Layout15->addWidget( TextLabel2 ); |
673 | 672 | ||
674 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); | 673 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); |
675 | TextLabel3->setText( tr( "Out" ) ); | 674 | TextLabel3->setText( tr( "Out" ) ); |
676 | Layout15b->addWidget( TextLabel3 ); | 675 | Layout15b->addWidget( TextLabel3 ); |
677 | 676 | ||
678 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); | 677 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); |
679 | InputSlider->setTickmarks( QSlider::Both); | 678 | InputSlider->setTickmarks( QSlider::Both); |
680 | Layout15->addWidget( InputSlider); | 679 | Layout15->addWidget( InputSlider); |
681 | 680 | ||
682 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); | 681 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); |
683 | OutputSlider->setTickmarks( QSlider::Both); | 682 | OutputSlider->setTickmarks( QSlider::Both); |
684 | 683 | ||
685 | Layout15b->addWidget( OutputSlider ); | 684 | Layout15b->addWidget( OutputSlider ); |
686 | 685 | ||
687 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 686 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
688 | Layout15->addWidget( outMuteCheckBox ); | 687 | Layout15->addWidget( outMuteCheckBox ); |
689 | 688 | ||
690 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 689 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
691 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | 690 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); |
692 | Layout15b->addWidget( inMuteCheckBox ); | 691 | Layout15b->addWidget( inMuteCheckBox ); |
693 | 692 | ||
694 | 693 | ||
695 | Layout19a->addLayout( Layout15 ); | 694 | Layout19a->addLayout( Layout15 ); |
696 | Layout19a->addLayout( Layout15b ); | 695 | Layout19a->addLayout( Layout15b ); |
697 | 696 | ||
698 | fillDirectoryCombo(); | 697 | fillDirectoryCombo(); |
699 | 698 | ||
700 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | 699 | TabWidget->insertTab( tab_3, tr( "Options" ) ); |
701 | 700 | ||
702 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 701 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
703 | 702 | ||
704 | 703 | ||
705 | waveform = new Waveform( this, "waveform" ); | 704 | waveform = new Waveform( this, "waveform" ); |
706 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); | 705 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); |
707 | waveform->setMinimumSize( QSize( 0, 50 ) ); | 706 | waveform->setMinimumSize( QSize( 0, 50 ) ); |
708 | 707 | ||
709 | layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); | 708 | layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); |
710 | waveform->setBackgroundColor ( black ); | 709 | waveform->setBackgroundColor ( black ); |
711 | } | 710 | } |
712 | 711 | ||
713 | void QtRec::initIconView() { | 712 | void QtRec::initIconView() { |
714 | 713 | ||
715 | ListView1->clear(); | 714 | ListView1->clear(); |
716 | Config cfg("OpieRec"); | 715 | Config cfg("OpieRec"); |
717 | cfg.setGroup("Sounds"); | 716 | cfg.setGroup("Sounds"); |
718 | QString temp; | 717 | QString temp; |
719 | QPixmap image0( ( const char** ) image0_data ); | 718 | QPixmap image0( ( const char** ) image0_data ); |
720 | 719 | ||
721 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 720 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
722 | // qDebug("init number of files %d", nFiles); | 721 | // qDebug("init number of files %d", nFiles); |
723 | 722 | ||
724 | for(int i=1;i<= nFiles;i++) { | 723 | for(int i=1;i<= nFiles;i++) { |
725 | 724 | ||
726 | QListViewItem * item; | 725 | QListViewItem * item; |
727 | QString fileS, mediaLocation, fileDate, filePath; | 726 | QString fileS, mediaLocation, fileDate, filePath; |
728 | 727 | ||
729 | temp.sprintf( "%d",i); | 728 | temp.sprintf( "%d",i); |
730 | temp = cfg.readEntry( temp,""); //reads currentFile | 729 | temp = cfg.readEntry( temp,""); //reads currentFile |
731 | filePath = cfg.readEntry( temp,""); //currentFileName | 730 | filePath = cfg.readEntry( temp,""); //currentFileName |
732 | 731 | ||
733 | QFileInfo info(filePath); | 732 | QFileInfo info(filePath); |
734 | fileDate = info.lastModified().toString(); | 733 | fileDate = info.lastModified().toString(); |
735 | 734 | ||
736 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds | 735 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds |
737 | mediaLocation = getStorage( filePath); | 736 | mediaLocation = getStorage( filePath); |
738 | if( info.exists()) { | 737 | if( info.exists()) { |
739 | item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); | 738 | item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); |
740 | item->setPixmap( 0, image0); | 739 | item->setPixmap( 0, image0); |
741 | if( currentFileName == filePath) | 740 | if( currentFileName == filePath) |
742 | ListView1->setSelected( item, true); | 741 | ListView1->setSelected( item, true); |
743 | } | 742 | } |
744 | } | 743 | } |
745 | } | 744 | } |
746 | 745 | ||
747 | void QtRec::initConnections() { | 746 | void QtRec::initConnections() { |
748 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 747 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
749 | 748 | ||
750 | connect( toBeginningButton, SIGNAL( pressed()), | 749 | connect( toBeginningButton, SIGNAL( pressed()), |
751 | this, SLOT( rewindPressed() )); | 750 | this, SLOT( rewindPressed() )); |
752 | connect( toBeginningButton, SIGNAL( released()), | 751 | connect( toBeginningButton, SIGNAL( released()), |
753 | this, SLOT( rewindReleased() )); | 752 | this, SLOT( rewindReleased() )); |
754 | connect( toEndButton, SIGNAL( pressed()), | 753 | connect( toEndButton, SIGNAL( pressed()), |
755 | this, SLOT( FastforwardPressed() )); | 754 | this, SLOT( FastforwardPressed() )); |
756 | connect( toEndButton, SIGNAL( released()), | 755 | connect( toEndButton, SIGNAL( released()), |
757 | this, SLOT( FastforwardReleased() )); | 756 | this, SLOT( FastforwardReleased() )); |
758 | connect( deleteSoundButton, SIGNAL(released()), | 757 | connect( deleteSoundButton, SIGNAL(released()), |
759 | this, SLOT( deleteSound() )); | 758 | this, SLOT( deleteSound() )); |
760 | connect( Stop_PushButton, SIGNAL(released()), | 759 | connect( Stop_PushButton, SIGNAL(released()), |
761 | this, SLOT( doPlayBtn() )); | 760 | this, SLOT( doPlayBtn() )); |
762 | connect( Rec_PushButton, SIGNAL(released()), | 761 | connect( Rec_PushButton, SIGNAL(released()), |
763 | this, SLOT( newSound() ) ); | 762 | this, SLOT( newSound() ) ); |
764 | connect( TabWidget, SIGNAL( currentChanged(QWidget*)), | 763 | connect( TabWidget, SIGNAL( currentChanged(QWidget*)), |
765 | this, SLOT(thisTab(QWidget*) )); | 764 | this, SLOT(thisTab(QWidget*) )); |
766 | connect( OutputSlider, SIGNAL(sliderReleased()), | 765 | connect( OutputSlider, SIGNAL(sliderReleased()), |
767 | this, SLOT( changedOutVolume()) ); | 766 | this, SLOT( changedOutVolume()) ); |
768 | connect( InputSlider, SIGNAL(sliderReleased()), | 767 | connect( InputSlider, SIGNAL(sliderReleased()), |
769 | this, SLOT( changedInVolume()) ); | 768 | this, SLOT( changedInVolume()) ); |
770 | 769 | ||
771 | connect( sampleRateComboBox, SIGNAL(activated(int)), | 770 | connect( sampleRateComboBox, SIGNAL(activated(int)), |
772 | this, SLOT( changesamplerateCombo(int)) ); | 771 | this, SLOT( changesamplerateCombo(int)) ); |
773 | connect( bitRateComboBox, SIGNAL(activated(int)), | 772 | connect( bitRateComboBox, SIGNAL(activated(int)), |
774 | this, SLOT( changebitrateCombo(int)) ); | 773 | this, SLOT( changebitrateCombo(int)) ); |
775 | 774 | ||
776 | connect( directoryComboBox, SIGNAL(activated(int)), | 775 | connect( directoryComboBox, SIGNAL(activated(int)), |
777 | this, SLOT( changeDirCombo(int)) ); | 776 | this, SLOT( changeDirCombo(int)) ); |
778 | connect( sizeLimitCombo, SIGNAL(activated(int)), | 777 | connect( sizeLimitCombo, SIGNAL(activated(int)), |
779 | this, SLOT( changeSizeLimitCombo(int)) ); | 778 | this, SLOT( changeSizeLimitCombo(int)) ); |
780 | 779 | ||
781 | connect( stereoCheckBox, SIGNAL(toggled(bool)), | 780 | connect( stereoCheckBox, SIGNAL(toggled(bool)), |
782 | this, SLOT( changeStereoCheck(bool)) ); | 781 | this, SLOT( changeStereoCheck(bool)) ); |
783 | 782 | ||
784 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), | 783 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), |
785 | this, SLOT( doVolMuting(bool)) ); | 784 | this, SLOT( doVolMuting(bool)) ); |
786 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), | 785 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), |
787 | this, SLOT( doMicMuting(bool)) ); | 786 | this, SLOT( doMicMuting(bool)) ); |
788 | 787 | ||
789 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), | 788 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), |
790 | this,SLOT( itClick(QListViewItem*))); | 789 | this,SLOT( itClick(QListViewItem*))); |
791 | connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 790 | connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
792 | this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); | 791 | this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); |
793 | connect( timeSlider, SIGNAL( sliderMoved(int)), | 792 | connect( timeSlider, SIGNAL( sliderMoved(int)), |
794 | this, SLOT( changeTimeSlider(int) )); | 793 | this, SLOT( changeTimeSlider(int) )); |
795 | connect( timeSlider, SIGNAL( sliderPressed()), | 794 | connect( timeSlider, SIGNAL( sliderPressed()), |
796 | this, SLOT( timeSliderPressed() )); | 795 | this, SLOT( timeSliderPressed() )); |
797 | connect( timeSlider, SIGNAL( sliderReleased()), | 796 | connect( timeSlider, SIGNAL( sliderReleased()), |
798 | this, SLOT( timeSliderReleased() )); | 797 | this, SLOT( timeSliderReleased() )); |
799 | connect( compressionCheckBox, SIGNAL( toggled(bool)), | 798 | connect( compressionCheckBox, SIGNAL( toggled(bool)), |
800 | this, SLOT( compressionSelected(bool))); | 799 | this, SLOT( compressionSelected(bool))); |
801 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), | 800 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), |
802 | this, SLOT( slotAutoMute(bool))); | 801 | this, SLOT( slotAutoMute(bool))); |
803 | } | 802 | } |
804 | 803 | ||
805 | void QtRec::initConfig() { | 804 | void QtRec::initConfig() { |
806 | int index, fred, i; | 805 | int index, fred, i; |
807 | Config cfg("OpieRec"); | 806 | Config cfg("OpieRec"); |
808 | cfg.setGroup("Settings"); | 807 | cfg.setGroup("Settings"); |
809 | 808 | ||
810 | index = cfg.readNumEntry("samplerate",22050); | 809 | index = cfg.readNumEntry("samplerate",22050); |
811 | bool ok; | 810 | bool ok; |
812 | 811 | ||
813 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { | 812 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { |
814 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 813 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
815 | if( index == fred) { | 814 | if( index == fred) { |
816 | filePara.sampleRate = fred; | 815 | filePara.sampleRate = fred; |
817 | sampleRateComboBox->setCurrentItem(ws); | 816 | sampleRateComboBox->setCurrentItem(ws); |
818 | } | 817 | } |
819 | } | 818 | } |
820 | 819 | ||
821 | i = cfg.readNumEntry("bitrate",16); | 820 | i = cfg.readNumEntry("bitrate",16); |
822 | if(i == 16) | 821 | if(i == 16) |
823 | bitRateComboBox->setCurrentItem( 1); | 822 | bitRateComboBox->setCurrentItem( 1); |
824 | elseif(i == 24) | 823 | elseif(i == 24) |
825 | bitRateComboBox->setCurrentItem( 2); | 824 | bitRateComboBox->setCurrentItem( 2); |
826 | elseif(i == 32) | 825 | elseif(i == 32) |
827 | bitRateComboBox->setCurrentItem( 3); | 826 | bitRateComboBox->setCurrentItem( 3); |
828 | else | 827 | else |
829 | bitRateComboBox->setCurrentItem( 0); | 828 | bitRateComboBox->setCurrentItem( 0); |
830 | 829 | ||
831 | filePara.resolution = i; | 830 | filePara.resolution = i; |
832 | 831 | ||
833 | i = cfg.readNumEntry("sizeLimit", 5 ); | 832 | i = cfg.readNumEntry("sizeLimit", 5 ); |
834 | QString temp; | 833 | QString temp; |
835 | sizeLimitCombo->setCurrentItem((i/5)); | 834 | sizeLimitCombo->setCurrentItem((i/5)); |
836 | 835 | ||
837 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 836 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
838 | if( stereoCheckBox->isChecked()) { | 837 | if( stereoCheckBox->isChecked()) { |
839 | filePara.channels = 2; | 838 | filePara.channels = 2; |
840 | } else { | 839 | } else { |
841 | filePara.channels = 1; | 840 | filePara.channels = 1; |
842 | } | 841 | } |
843 | 842 | ||
844 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 843 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
845 | if( compressionCheckBox->isChecked()) { | 844 | if( compressionCheckBox->isChecked()) { |
846 | bitRateComboBox->setEnabled(false); | 845 | bitRateComboBox->setEnabled(false); |
847 | bitRateComboBox->setCurrentItem(0); | 846 | bitRateComboBox->setCurrentItem(0); |
848 | filePara.resolution=16; | 847 | filePara.resolution=16; |
849 | } | 848 | } |
850 | 849 | ||
851 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 850 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
852 | if( autoMuteCheckBox->isChecked()) | 851 | if( autoMuteCheckBox->isChecked()) |
853 | slotAutoMute(true); | 852 | slotAutoMute(true); |
854 | else | 853 | else |
855 | slotAutoMute(false); | 854 | slotAutoMute(false); |
856 | 855 | ||
857 | Config cofg( "qpe"); | 856 | Config cofg( "qpe"); |
858 | cofg.setGroup( "Volume"); | 857 | cofg.setGroup( "Volume"); |
859 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 858 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
860 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 859 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
861 | } | 860 | } |
862 | 861 | ||
863 | void QtRec::stop() { | 862 | void QtRec::stop() { |
864 | qWarning("STOP"); | 863 | qWarning("STOP"); |
865 | setRecordButton(false); | 864 | setRecordButton(false); |
866 | 865 | ||
867 | if( !recording) | 866 | if( !recording) |
868 | endPlaying(); | 867 | endPlaying(); |
869 | else | 868 | else |
870 | endRecording(); | 869 | endRecording(); |
871 | timeSlider->setValue(0); | 870 | timeSlider->setValue(0); |
872 | } | 871 | } |
873 | 872 | ||
874 | void QtRec::doPlayBtn() { | 873 | void QtRec::doPlayBtn() { |
875 | 874 | ||
876 | if(!stopped) { | 875 | if(!stopped) { |
877 | playLabel2->setText(tr("Play")); | 876 | playLabel2->setText(tr("Play")); |
878 | stop(); | 877 | stop(); |
879 | } else { | 878 | } else { |
880 | if(ListView1->currentItem() == 0) return; | 879 | if(ListView1->currentItem() == 0) return; |
881 | playLabel2->setText(tr("Stop")); | 880 | playLabel2->setText(tr("Stop")); |
882 | currentFile = ListView1->currentItem()->text(0); | 881 | currentFile = ListView1->currentItem()->text(0); |
883 | start(); | 882 | start(); |
884 | } | 883 | } |
885 | } | 884 | } |
886 | 885 | ||
887 | void QtRec::start() { //play | 886 | void QtRec::start() { //play |
888 | if( stopped) { | 887 | if( stopped) { |
889 | QPixmap image3( ( const char** ) image3_data ); | 888 | QPixmap image3( ( const char** ) image3_data ); |
890 | Stop_PushButton->setPixmap( image3 ); | 889 | Stop_PushButton->setPixmap( image3 ); |
891 | Stop_PushButton->setDown( true); | 890 | Stop_PushButton->setDown( true); |
892 | stopped = false; | 891 | stopped = false; |
893 | paused = false; | 892 | paused = false; |
894 | secCount = 1; | 893 | secCount = 1; |
895 | 894 | ||
896 | if( openPlayFile()) | 895 | if( openPlayFile()) |
897 | if( setupAudio( false)) //recording is false | 896 | if( setupAudio( false)) //recording is false |
898 | doPlay(); | 897 | doPlay(); |
899 | } | 898 | } |
900 | } | 899 | } |
901 | 900 | ||
902 | bool QtRec::rec() { //record | 901 | bool QtRec::rec() { //record |
903 | QString timeString; | 902 | QString timeString; |
904 | timeString.sprintf("%.0f", 0.0); | 903 | timeString.sprintf("%.0f", 0.0); |
905 | timeLabel->setText( timeString+ " seconds"); | 904 | timeLabel->setText( timeString+ " seconds"); |
906 | if(!stopped) { | 905 | if(!stopped) { |
907 | monitoring = true; | 906 | monitoring = true; |
908 | return false; | 907 | return false; |
909 | } else { | 908 | } else { |
910 | secCount = 1; | 909 | secCount = 1; |
911 | playLabel2->setText(tr("Stop")); | 910 | playLabel2->setText(tr("Stop")); |
912 | monitoring = false; | 911 | monitoring = false; |
913 | setRecordButton( true); | 912 | setRecordButton( true); |
914 | 913 | ||
915 | if( setupAudio( true)) | 914 | if( setupAudio( true)) |
916 | if(setUpFile()) { | 915 | if(setUpFile()) { |
917 | int fileSize = 0; | 916 | int fileSize = 0; |
918 | Config cfg("OpieRec"); | 917 | Config cfg("OpieRec"); |
919 | cfg.setGroup("Settings"); | 918 | cfg.setGroup("Settings"); |
920 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", | 919 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", |
921 | // soundDevice->getDeviceBits(), | 920 | // soundDevice->getDeviceBits(), |
922 | // soundDevice->getDeviceRate(), | 921 | // soundDevice->getDeviceRate(), |
923 | // soundDevice->getDeviceChannels()); | 922 | // soundDevice->getDeviceChannels()); |
924 | 923 | ||
925 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 924 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
926 | // qDebug("sample rate is %d", filePara.sampleRate); | 925 | // qDebug("sample rate is %d", filePara.sampleRate); |
927 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 926 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
928 | 927 | ||
929 | // qDebug("size limit %d sec", filePara.SecondsToRecord); | 928 | // qDebug("size limit %d sec", filePara.SecondsToRecord); |
930 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 929 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
931 | 930 | ||
932 | if( filePara.SecondsToRecord == 0) { | 931 | if( filePara.SecondsToRecord == 0) { |
933 | fileSize = diskSize; | 932 | fileSize = diskSize; |
934 | } else if( filePara.format == WAVE_FORMAT_PCM) { | 933 | } else if( filePara.format == WAVE_FORMAT_PCM) { |
935 | // qDebug("WAVE_FORMAT_PCM"); | 934 | // qDebug("WAVE_FORMAT_PCM"); |
936 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 935 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
937 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; | 936 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; |
938 | } else { | 937 | } else { |
939 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 938 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
940 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 939 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
941 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; | 940 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; |
942 | } | 941 | } |
943 | 942 | ||
944 | filePara.samplesToRecord = fileSize; | 943 | filePara.samplesToRecord = fileSize; |
945 | qDebug("filesize should be %d, bits %d, rate %d", | 944 | qDebug("filesize should be %d, bits %d, rate %d", |
946 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); | 945 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); |
947 | if( paused) { | 946 | if( paused) { |
948 | paused = false; | 947 | paused = false; |
949 | } | 948 | } |
950 | // else { | 949 | // else { |
951 | qDebug("Setting timeslider %d", filePara.samplesToRecord); | 950 | qDebug("Setting timeslider %d", filePara.samplesToRecord); |
952 | // if(fileSize != 0) | 951 | // if(fileSize != 0) |
953 | timeSlider->setRange(0, filePara.samplesToRecord); | 952 | timeSlider->setRange(0, filePara.samplesToRecord); |
954 | // } | 953 | // } |
955 | 954 | ||
956 | if( diskSize < fileSize/1024) { | 955 | if( diskSize < fileSize/1024) { |
957 | QMessageBox::warning(this, | 956 | QMessageBox::warning(this, |
958 | tr("Low Disk Space"), | 957 | tr("Low Disk Space"), |
959 | tr("You are running low of\nrecording space\n" | 958 | tr("You are running low of\nrecording space\n" |
960 | "or a card isn't being recognized")); | 959 | "or a card isn't being recognized")); |
961 | stopped = true; //we need to be stopped | 960 | stopped = true; //we need to be stopped |
962 | stop(); | 961 | stop(); |
963 | } else { | 962 | } else { |
964 | QString msg; | 963 | QString msg; |
965 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 964 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
966 | #ifdef DEV_VERSION | 965 | #ifdef DEV_VERSION |
967 | setCaption( msg); | 966 | setCaption( msg); |
968 | #endif | 967 | #endif |
969 | filePara.fileName=currentFile.latin1(); | 968 | filePara.fileName=currentFile.latin1(); |
970 | qDebug("Start recording thread"); | 969 | qDebug("Start recording thread"); |
971 | stopped = false; | 970 | stopped = false; |
972 | 971 | ||
973 | #ifdef THREADED | 972 | #ifdef THREADED |
974 | pthread_t thread1; | 973 | pthread_t thread1; |
975 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 974 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
976 | #endif | 975 | #endif |
977 | toBeginningButton->setEnabled( false); | 976 | toBeginningButton->setEnabled( false); |
978 | toEndButton->setEnabled( false); | 977 | toEndButton->setEnabled( false); |
979 | 978 | ||
980 | startTimer(1000); | 979 | startTimer(1000); |
981 | #ifndef THREADED | 980 | #ifndef THREADED |
982 | quickRec(); | 981 | quickRec(); |
983 | #endif | 982 | #endif |
984 | } | 983 | } |
985 | } //end setUpFile | 984 | } //end setUpFile |
986 | } //end setupAudio | 985 | } //end setupAudio |
987 | return true; | 986 | return true; |
988 | } | 987 | } |
989 | /* | 988 | /* |
990 | This happens when a tab is selected*/ | 989 | This happens when a tab is selected*/ |
991 | void QtRec::thisTab(QWidget* widg) { | 990 | void QtRec::thisTab(QWidget* widg) { |
992 | if(widg != NULL) { | 991 | if(widg != NULL) { |
993 | int index = TabWidget->currentPageIndex(); | 992 | int index = TabWidget->currentPageIndex(); |
994 | 993 | ||
995 | if(index == 0) { //file page | 994 | if(index == 0) { //file page |
996 | } | 995 | } |
997 | 996 | ||
998 | if(index == 1) { //control page | 997 | if(index == 1) { //control page |
999 | fillDirectoryCombo(); | 998 | fillDirectoryCombo(); |
1000 | // soundDevice->getOutVol(); | 999 | // soundDevice->getOutVol(); |
1001 | // soundDevice->getInVol(); | 1000 | // soundDevice->getInVol(); |
1002 | } | 1001 | } |
1003 | 1002 | ||
1004 | if( index==2) { //help page | 1003 | if( index==2) { //help page |
1005 | } | 1004 | } |
1006 | 1005 | ||
1007 | qApp->processEvents(); | 1006 | qApp->processEvents(); |
1008 | update(); | 1007 | update(); |
1009 | } | 1008 | } |
1010 | } | 1009 | } |
1011 | 1010 | ||
1012 | void QtRec::getOutVol( ) { | 1011 | void QtRec::getOutVol( ) { |
1013 | filePara.outVol = soundDevice->getOutVolume(); | 1012 | filePara.outVol = soundDevice->getOutVolume(); |
1014 | // qDebug("out vol %d", filePara.outVol); | 1013 | // qDebug("out vol %d", filePara.outVol); |
1015 | OutputSlider->setValue( -filePara.outVol); | 1014 | OutputSlider->setValue( -filePara.outVol); |
1016 | } | 1015 | } |
1017 | 1016 | ||
1018 | void QtRec::getInVol() { | 1017 | void QtRec::getInVol() { |
1019 | filePara.inVol = soundDevice->getInVolume(); | 1018 | filePara.inVol = soundDevice->getInVolume(); |
1020 | // qDebug("in vol %d", filePara.inVol); | 1019 | // qDebug("in vol %d", filePara.inVol); |
1021 | InputSlider->setValue( -filePara.inVol); | 1020 | InputSlider->setValue( -filePara.inVol); |
1022 | } | 1021 | } |
1023 | 1022 | ||
1024 | void QtRec::changedOutVolume() { | 1023 | void QtRec::changedOutVolume() { |
1025 | soundDevice->changedOutVolume( -OutputSlider->value()); | 1024 | soundDevice->changedOutVolume( -OutputSlider->value()); |
1026 | } | 1025 | } |
1027 | 1026 | ||
1028 | void QtRec::changedInVolume( ) { | 1027 | void QtRec::changedInVolume( ) { |
1029 | soundDevice->changedInVolume( -InputSlider->value()); | 1028 | soundDevice->changedInVolume( -InputSlider->value()); |
1030 | } | 1029 | } |
1031 | 1030 | ||
1032 | 1031 | ||
1033 | bool QtRec::setupAudio( bool b) { | 1032 | bool QtRec::setupAudio( bool b) { |
1034 | bool ok; | 1033 | bool ok; |
1035 | int sampleformat, stereo, flags; | 1034 | int sampleformat, stereo, flags; |
1036 | QString dspString, mixerString; | 1035 | QString dspString, mixerString; |
1037 | 1036 | ||
1038 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 | 1037 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 |
1039 | 1038 | ||
1040 | if( !b) { | 1039 | if( !b) { |
1041 | // we want to play | 1040 | // we want to play |
1042 | #ifdef PDAUDIO //ALSA | 1041 | #ifdef PDAUDIO //ALSA |
1043 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1042 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1044 | sampleformat = SND_PCM_FORMAT_S16; | 1043 | sampleformat = SND_PCM_FORMAT_S16; |
1045 | filePara.resolution = 16; | 1044 | filePara.resolution = 16; |
1046 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { | 1045 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { |
1047 | sampleformat = SND_PCM_FORMAT_S24; | 1046 | sampleformat = SND_PCM_FORMAT_S24; |
1048 | filePara.resolution = 24; | 1047 | filePara.resolution = 24; |
1049 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { | 1048 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { |
1050 | sampleformat = SND_PCM_FORMAT_S32; | 1049 | sampleformat = SND_PCM_FORMAT_S32; |
1051 | filePara.resolution = 32; | 1050 | filePara.resolution = 32; |
1052 | } else { | 1051 | } else { |
1053 | sampleformat = SND_PCM_FORMAT_U8; | 1052 | sampleformat = SND_PCM_FORMAT_U8; |
1054 | filePara.resolution = 8; | 1053 | filePara.resolution = 8; |
1055 | } | 1054 | } |
1056 | #else | 1055 | #else |
1057 | // we want to play | 1056 | // we want to play |
1058 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1057 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1059 | sampleformat = AFMT_S16_LE; | 1058 | sampleformat = AFMT_S16_LE; |
1060 | filePara.resolution = 16; | 1059 | filePara.resolution = 16; |
1061 | } else { | 1060 | } else { |
1062 | sampleformat = AFMT_U8; | 1061 | sampleformat = AFMT_U8; |
1063 | filePara.resolution = 8; | 1062 | filePara.resolution = 8; |
1064 | } | 1063 | } |
1065 | #endif | 1064 | #endif |
1066 | 1065 | ||
1067 | stereo = filePara.channels; | 1066 | stereo = filePara.channels; |
1068 | flags = O_WRONLY; | 1067 | flags = O_WRONLY; |
1069 | Config hwcfg("OpieRec"); | 1068 | Config hwcfg("OpieRec"); |
1070 | hwcfg.setGroup("Hardware"); | 1069 | hwcfg.setGroup("Hardware"); |
1071 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); | 1070 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); |
1072 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); | 1071 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); |
1073 | recording = false; | 1072 | recording = false; |
1074 | } else { // we want to record | 1073 | } else { // we want to record |
1075 | 1074 | ||
1076 | #ifdef PDAUDIO //ALSA | 1075 | #ifdef PDAUDIO //ALSA |
1077 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1076 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
1078 | sampleformat = SND_PCM_FORMAT_S16; | 1077 | sampleformat = SND_PCM_FORMAT_S16; |
1079 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") | 1078 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") |
1080 | sampleformat = SND_PCM_FORMAT_S24; | 1079 | sampleformat = SND_PCM_FORMAT_S24; |
1081 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") | 1080 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") |
1082 | sampleformat = SND_PCM_FORMAT_S32; | 1081 | sampleformat = SND_PCM_FORMAT_S32; |
1083 | else | 1082 | else |
1084 | sampleformat = SND_PCM_FORMAT_U8; | 1083 | sampleformat = SND_PCM_FORMAT_U8; |
1085 | 1084 | ||
1086 | #else | 1085 | #else |
1087 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1086 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
1088 | sampleformat = AFMT_S16_LE; | 1087 | sampleformat = AFMT_S16_LE; |
1089 | else | 1088 | else |
1090 | sampleformat = AFMT_U8; | 1089 | sampleformat = AFMT_U8; |
1091 | 1090 | ||
1092 | if( !compressionCheckBox->isChecked()) { | 1091 | if( !compressionCheckBox->isChecked()) { |
1093 | filePara.format = WAVE_FORMAT_PCM; | 1092 | filePara.format = WAVE_FORMAT_PCM; |
1094 | // qDebug("WAVE_FORMAT_PCM"); | 1093 | // qDebug("WAVE_FORMAT_PCM"); |
1095 | } else { | 1094 | } else { |
1096 | filePara.format = WAVE_FORMAT_DVI_ADPCM; | 1095 | filePara.format = WAVE_FORMAT_DVI_ADPCM; |
1097 | sampleformat = AFMT_S16_LE; | 1096 | sampleformat = AFMT_S16_LE; |
1098 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 1097 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
1099 | } | 1098 | } |
1100 | #endif | 1099 | #endif |
1101 | 1100 | ||
1102 | stereo = filePara.channels; | 1101 | stereo = filePara.channels; |
1103 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1102 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1104 | flags= O_RDWR; | 1103 | flags= O_RDWR; |
1105 | // flags= O_RDONLY; | 1104 | // flags= O_RDONLY; |
1106 | Config hwcfg("OpieRec"); | 1105 | Config hwcfg("OpieRec"); |
1107 | hwcfg.setGroup("Hardware"); | 1106 | hwcfg.setGroup("Hardware"); |
1108 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); | 1107 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); |
1109 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); | 1108 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); |
1110 | recording = true; | 1109 | recording = true; |
1111 | } | 1110 | } |
1112 | 1111 | ||
1113 | // if(soundDevice) delete soundDevice; | 1112 | // if(soundDevice) delete soundDevice; |
1114 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); | 1113 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); |
1115 | qWarning("change waveform settings"); | 1114 | qWarning("change waveform settings"); |
1116 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1115 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1117 | 1116 | ||
1118 | soundDevice = new Device( this, dspString, mixerString, b); | 1117 | soundDevice = new Device( this, dspString, mixerString, b); |
1119 | // soundDevice->openDsp(); | 1118 | // soundDevice->openDsp(); |
1120 | soundDevice->reset(); | 1119 | soundDevice->reset(); |
1121 | 1120 | ||
1122 | qDebug("device has been made %d", soundDevice->sd); | 1121 | qDebug("device has been made %d", soundDevice->sd); |
1123 | 1122 | ||
1124 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | 1123 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> |
1125 | soundDevice->setDeviceFormat( sampleformat); | 1124 | soundDevice->setDeviceFormat( sampleformat); |
1126 | soundDevice->setDeviceChannels( filePara.channels); | 1125 | soundDevice->setDeviceChannels( filePara.channels); |
1127 | soundDevice->setDeviceRate( filePara.sampleRate); | 1126 | soundDevice->setDeviceRate( filePara.sampleRate); |
1128 | soundDevice->getDeviceFragSize(); | 1127 | soundDevice->getDeviceFragSize(); |
1129 | #ifdef QT_QWS_EBX | 1128 | #ifdef QT_QWS_EBX |
1130 | int frag = FRAGSIZE; | 1129 | int frag = FRAGSIZE; |
1131 | soundDevice->setFragSize( frag); | 1130 | soundDevice->setFragSize( frag); |
1132 | soundDevice->getDeviceFragSize(); | 1131 | soundDevice->getDeviceFragSize(); |
1133 | #endif | 1132 | #endif |
1134 | ///////////////// | 1133 | ///////////////// |
1135 | filePara.sd = soundDevice->sd; | 1134 | filePara.sd = soundDevice->sd; |
1136 | 1135 | ||
1137 | if ( filePara.sd == -1) { | 1136 | if ( filePara.sd == -1) { |
1138 | 1137 | ||
1139 | monitoring = false; | 1138 | monitoring = false; |
1140 | stopped = true; | 1139 | stopped = true; |
1141 | update(); | 1140 | update(); |
1142 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); | 1141 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); |
1143 | return false; | 1142 | return false; |
1144 | } | 1143 | } |
1145 | if(autoMute) | 1144 | if(autoMute) |
1146 | doMute(false); | 1145 | doMute(false); |
1147 | 1146 | ||
1148 | return true; | 1147 | return true; |
1149 | } | 1148 | } |
1150 | 1149 | ||
1151 | 1150 | ||
1152 | bool QtRec::setUpFile() { //setup file for recording | 1151 | bool QtRec::setUpFile() { //setup file for recording |
1153 | // qDebug("Setting up wavfile"); | 1152 | // qDebug("Setting up wavfile"); |
1154 | // if(wavFile) delete wavFile; | 1153 | // if(wavFile) delete wavFile; |
1155 | wavFile = new WavFile( this, (const QString &)"", | 1154 | wavFile = new WavFile( this, (const QString &)"", |
1156 | true, | 1155 | true, |
1157 | filePara.sampleRate, | 1156 | filePara.sampleRate, |
1158 | filePara.channels, | 1157 | filePara.channels, |
1159 | filePara.resolution, | 1158 | filePara.resolution, |
1160 | filePara.format); | 1159 | filePara.format); |
1161 | 1160 | ||
1162 | filePara.fd = wavFile->wavHandle(); | 1161 | filePara.fd = wavFile->wavHandle(); |
1163 | if(filePara.fd == -1) { | 1162 | if(filePara.fd == -1) { |
1164 | return false; | 1163 | return false; |
1165 | } else { | 1164 | } else { |
1166 | // filePara.channels=1; | 1165 | // filePara.channels=1; |
1167 | } | 1166 | } |
1168 | return true; | 1167 | return true; |
1169 | } | 1168 | } |
1170 | 1169 | ||
1171 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> | 1170 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> |
1172 | bool QtRec::doPlay() { | 1171 | bool QtRec::doPlay() { |
1173 | 1172 | ||
1174 | if( !paused) { | 1173 | if( !paused) { |
1175 | total = 0; | 1174 | total = 0; |
1176 | filePara.numberOfRecordedSeconds = 0; | 1175 | filePara.numberOfRecordedSeconds = 0; |
1177 | } else { | 1176 | } else { |
1178 | paused = false; | 1177 | paused = false; |
1179 | secCount = (int)filePara.numberOfRecordedSeconds; | 1178 | secCount = (int)filePara.numberOfRecordedSeconds; |
1180 | } | 1179 | } |
1181 | playing = true; | 1180 | playing = true; |
1182 | stopped = false; | 1181 | stopped = false; |
1183 | recording = false; | 1182 | recording = false; |
1184 | 1183 | ||
1185 | QString num; | 1184 | QString num; |
1186 | qDebug( "Play number of samples %d", filePara.numberSamples); | 1185 | qDebug( "Play number of samples %d", filePara.numberSamples); |
1187 | 1186 | ||
1188 | // timeSlider->setRange( 0, filePara.numberSamples); | 1187 | // timeSlider->setRange( 0, filePara.numberSamples); |
1189 | 1188 | ||
1190 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); | 1189 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); |
1191 | timeLabel->setText( timeString+ tr(" seconds")); | 1190 | timeLabel->setText( timeString+ tr(" seconds")); |
1192 | 1191 | ||
1193 | QString msg; | 1192 | QString msg; |
1194 | msg.sprintf("%d, %d, %d", | 1193 | msg.sprintf("%d, %d, %d", |
1195 | filePara.sampleRate, | 1194 | filePara.sampleRate, |
1196 | filePara.channels, | 1195 | filePara.channels, |
1197 | filePara.resolution); | 1196 | filePara.resolution); |
1198 | #ifdef DEV_VERSION | 1197 | #ifdef DEV_VERSION |
1199 | setCaption( msg); | 1198 | setCaption( msg); |
1200 | #endif | 1199 | #endif |
1201 | 1200 | ||
1202 | startTimer( 1000); | 1201 | startTimer( 1000); |
1203 | #ifdef THREADED | 1202 | #ifdef THREADED |
1204 | pthread_t thread2; | 1203 | pthread_t thread2; |
1205 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | 1204 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); |
1206 | #endif | 1205 | #endif |
1207 | 1206 | ||
1208 | toBeginningButton->setEnabled( false); | 1207 | toBeginningButton->setEnabled( false); |
1209 | toEndButton->setEnabled( false); | 1208 | toEndButton->setEnabled( false); |
1210 | #ifndef THREADED | 1209 | #ifndef THREADED |
1211 | playIt(); | 1210 | playIt(); |
1212 | #endif | 1211 | #endif |
1213 | return true; | 1212 | return true; |
1214 | } | 1213 | } |
1215 | 1214 | ||
1216 | 1215 | ||
1217 | void QtRec::changebitrateCombo(int i) { | 1216 | void QtRec::changebitrateCombo(int i) { |
1218 | Config cfg("OpieRec"); | 1217 | Config cfg("OpieRec"); |
1219 | cfg.setGroup("Settings"); | 1218 | cfg.setGroup("Settings"); |
1220 | int bits = 0; | 1219 | int bits = 0; |
1221 | if( i == 1) { bits = 16; } | 1220 | if( i == 1) { bits = 16; } |
1222 | else if( i == 2) { bits = 24; } | 1221 | else if( i == 2) { bits = 24; } |
1223 | else if( i == 3) { bits = 32; } | 1222 | else if( i == 3) { bits = 32; } |
1224 | else { bits=8; } | 1223 | else { bits=8; } |
1225 | cfg.writeEntry("bitrate", bits); | 1224 | cfg.writeEntry("bitrate", bits); |
1226 | filePara.resolution = bits; | 1225 | filePara.resolution = bits; |
1227 | cfg.write(); | 1226 | cfg.write(); |
1228 | } | 1227 | } |
1229 | 1228 | ||
1230 | void QtRec::changesamplerateCombo(int i) { | 1229 | void QtRec::changesamplerateCombo(int i) { |
1231 | Config cfg("OpieRec"); | 1230 | Config cfg("OpieRec"); |
1232 | cfg.setGroup("Settings"); | 1231 | cfg.setGroup("Settings"); |
1233 | int rate=0; | 1232 | int rate=0; |
1234 | bool ok; | 1233 | bool ok; |
1235 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); | 1234 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); |
1236 | cfg.writeEntry( "samplerate",rate); | 1235 | cfg.writeEntry( "samplerate",rate); |
1237 | filePara.sampleRate=rate; | 1236 | filePara.sampleRate=rate; |
1238 | qDebug( "Change sample rate %d", rate); | 1237 | qDebug( "Change sample rate %d", rate); |
1239 | cfg.write(); | 1238 | cfg.write(); |
1240 | } | 1239 | } |
1241 | 1240 | ||
1242 | 1241 | ||
1243 | void QtRec::changeDirCombo(int index) { | 1242 | void QtRec::changeDirCombo(int index) { |
1244 | Config cfg("OpieRec"); | 1243 | Config cfg("OpieRec"); |
1245 | cfg.setGroup("Settings"); | 1244 | cfg.setGroup("Settings"); |
1246 | QString sName = directoryComboBox->text(index); | 1245 | QString sName = directoryComboBox->text(index); |
1247 | 1246 | ||
1248 | StorageInfo storageInfo; | 1247 | StorageInfo storageInfo; |
1249 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1248 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1250 | QListIterator<FileSystem> it ( fs ); | 1249 | QListIterator<FileSystem> it ( fs ); |
1251 | QString storage; | 1250 | QString storage; |
1252 | for( ; it.current(); ++it ){ | 1251 | for( ; it.current(); ++it ){ |
1253 | if( sName == (*it)->name()+" "+ (*it)->path() || | 1252 | if( sName == (*it)->name()+" "+ (*it)->path() || |
1254 | (*it)->name() == sName ) { | 1253 | (*it)->name() == sName ) { |
1255 | const QString path = (*it)->path(); | 1254 | const QString path = (*it)->path(); |
1256 | recDir = path; | 1255 | recDir = path; |
1257 | cfg.writeEntry("directory", recDir); | 1256 | cfg.writeEntry("directory", recDir); |
1258 | qDebug("new rec dir "+recDir); | 1257 | qDebug("new rec dir "+recDir); |
1259 | } | 1258 | } |
1260 | } | 1259 | } |
1261 | cfg.write(); | 1260 | cfg.write(); |
1262 | } | 1261 | } |
1263 | 1262 | ||
1264 | 1263 | ||
1265 | void QtRec::changeSizeLimitCombo(int) { | 1264 | void QtRec::changeSizeLimitCombo(int) { |
1266 | Config cfg("OpieRec"); | 1265 | Config cfg("OpieRec"); |
1267 | cfg.setGroup("Settings"); | 1266 | cfg.setGroup("Settings"); |
1268 | cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); | 1267 | cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); |
1269 | cfg.write(); | 1268 | cfg.write(); |
1270 | } | 1269 | } |
1271 | 1270 | ||
1272 | void QtRec::newSound() { | 1271 | void QtRec::newSound() { |
1273 | if( !rec()) { | 1272 | if( !rec()) { |
1274 | endRecording(); | 1273 | endRecording(); |
1275 | deleteSound(); | 1274 | deleteSound(); |
1276 | } | 1275 | } |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | void QtRec::itClick(QListViewItem *item) { | 1278 | void QtRec::itClick(QListViewItem *item) { |
1280 | currentFile = item->text(0); | 1279 | currentFile = item->text(0); |
1281 | setCaption("OpieRecord "+currentFile); | 1280 | setCaption("OpieRecord "+currentFile); |
1282 | } | 1281 | } |
1283 | 1282 | ||
1284 | void QtRec::deleteSound() { | 1283 | void QtRec::deleteSound() { |
1285 | Config cfg("OpieRec"); | 1284 | Config cfg("OpieRec"); |
1286 | cfg.setGroup("Sounds"); | 1285 | cfg.setGroup("Sounds"); |
1287 | if( ListView1->currentItem() == NULL) | 1286 | if( ListView1->currentItem() == NULL) |
1288 | return; | 1287 | return; |
1289 | #ifndef DEV_VERSION | 1288 | #ifndef DEV_VERSION |
1290 | switch ( QMessageBox::warning(this,tr("Delete"), | 1289 | switch ( QMessageBox::warning(this,tr("Delete"), |
1291 | tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), | 1290 | tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), |
1292 | tr("Yes"),tr("No"),0,1,1) ) { | 1291 | tr("Yes"),tr("No"),0,1,1) ) { |
1293 | case 0: | 1292 | case 0: |
1294 | #endif | 1293 | #endif |
1295 | { | 1294 | { |
1296 | QString file = ListView1->currentItem()->text(0); | 1295 | QString file = ListView1->currentItem()->text(0); |
1297 | QString fileName; | 1296 | QString fileName; |
1298 | fileName = cfg.readEntry( file, ""); | 1297 | fileName = cfg.readEntry( file, ""); |
1299 | QFile f( fileName); | 1298 | QFile f( fileName); |
1300 | if( f.exists()) | 1299 | if( f.exists()) |
1301 | if( !f.remove()) | 1300 | if( !f.remove()) |
1302 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); | 1301 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); |
1303 | 1302 | ||
1304 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1303 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1305 | bool found = false; | 1304 | bool found = false; |
1306 | for(int i=0;i<nFiles+1;i++) { | 1305 | for(int i=0;i<nFiles+1;i++) { |
1307 | 1306 | ||
1308 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { | 1307 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { |
1309 | found = true; | 1308 | found = true; |
1310 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1309 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1311 | } | 1310 | } |
1312 | if(found) | 1311 | if(found) |
1313 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1312 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1314 | } | 1313 | } |
1315 | 1314 | ||
1316 | cfg.removeEntry( cfg.readEntry( file)); | 1315 | cfg.removeEntry( cfg.readEntry( file)); |
1317 | cfg.removeEntry( file); | 1316 | cfg.removeEntry( file); |
1318 | cfg.writeEntry( "NumberofFiles", nFiles-1); | 1317 | cfg.writeEntry( "NumberofFiles", nFiles-1); |
1319 | cfg.write(); | 1318 | cfg.write(); |
1320 | 1319 | ||
1321 | ListView1->takeItem( ListView1->currentItem() ); | 1320 | ListView1->takeItem( ListView1->currentItem() ); |
1322 | delete ListView1->currentItem(); | 1321 | delete ListView1->currentItem(); |
1323 | 1322 | ||
1324 | ListView1->clear(); | 1323 | ListView1->clear(); |
1325 | ListView1->setSelected( ListView1->firstChild(), true); | 1324 | ListView1->setSelected( ListView1->firstChild(), true); |
1326 | initIconView(); | 1325 | initIconView(); |
1327 | update(); | 1326 | update(); |
1328 | } | 1327 | } |
1329 | #ifndef DEV_VERSION | 1328 | #ifndef DEV_VERSION |
1330 | }; | 1329 | }; |
1331 | #endif | 1330 | #endif |
1332 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1331 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
1333 | 1332 | ||
1334 | } | 1333 | } |
1335 | 1334 | ||
1336 | void QtRec::keyPressEvent( QKeyEvent *e) { | 1335 | void QtRec::keyPressEvent( QKeyEvent *e) { |
1337 | 1336 | ||
1338 | switch ( e->key() ) { | 1337 | switch ( e->key() ) { |
1339 | // case Key_F1: | 1338 | // case Key_F1: |
1340 | // if(stopped && !recording) | 1339 | // if(stopped && !recording) |
1341 | // newSound(); | 1340 | // newSound(); |
1342 | // else | 1341 | // else |
1343 | // stop(); | 1342 | // stop(); |
1344 | // break; | 1343 | // break; |
1345 | // case Key_F2: { | 1344 | // case Key_F2: { |
1346 | // if( !e->isAutoRepeat()) | 1345 | // if( !e->isAutoRepeat()) |
1347 | // rewindPressed(); | 1346 | // rewindPressed(); |
1348 | // } | 1347 | // } |
1349 | // break; | 1348 | // break; |
1350 | // case Key_F3: { | 1349 | // case Key_F3: { |
1351 | // if( !e->isAutoRepeat()) | 1350 | // if( !e->isAutoRepeat()) |
1352 | // FastforwardPressed(); | 1351 | // FastforwardPressed(); |
1353 | // } | 1352 | // } |
1354 | // break; | 1353 | // break; |
1355 | 1354 | ||
1356 | ////////////////////////////// Zaurus keys | 1355 | ////////////////////////////// Zaurus keys |
1357 | case Key_F9: //activity | 1356 | case Key_F9: //activity |
1358 | break; | 1357 | break; |
1359 | case Key_F10: //contacts | 1358 | case Key_F10: //contacts |
1360 | break; | 1359 | break; |
1361 | case Key_F11: //menu | 1360 | case Key_F11: //menu |
1362 | break; | 1361 | break; |
1363 | case Key_F12: //home | 1362 | case Key_F12: //home |
1364 | break; | 1363 | break; |
1365 | case Key_F13: //mail | 1364 | case Key_F13: //mail |
1366 | break; | 1365 | break; |
1367 | case Key_Space: | 1366 | case Key_Space: |
1368 | break; | 1367 | break; |
1369 | case Key_Delete: | 1368 | case Key_Delete: |
1370 | break; | 1369 | break; |
1371 | case Key_Up: | 1370 | case Key_Up: |
1372 | // stop(); | 1371 | // stop(); |
1373 | break; | 1372 | break; |
1374 | case Key_Down: | 1373 | case Key_Down: |
1375 | // newSound(); | 1374 | // newSound(); |
1376 | break; | 1375 | break; |
1377 | case Key_Left: { | 1376 | case Key_Left: { |
1378 | qDebug("rewinding"); | 1377 | qDebug("rewinding"); |
1379 | if( !e->isAutoRepeat()) | 1378 | if( !e->isAutoRepeat()) |
1380 | rewindPressed(); | 1379 | rewindPressed(); |
1381 | } | 1380 | } |
1382 | break; | 1381 | break; |
1383 | case Key_Right: { | 1382 | case Key_Right: { |
1384 | if( !e->isAutoRepeat()) | 1383 | if( !e->isAutoRepeat()) |
1385 | FastforwardPressed(); | 1384 | FastforwardPressed(); |
1386 | } | 1385 | } |
1387 | break; | 1386 | break; |
1388 | } | 1387 | } |
1389 | } | 1388 | } |
1390 | 1389 | ||
1391 | void QtRec::keyReleaseEvent( QKeyEvent *e) { | 1390 | void QtRec::keyReleaseEvent( QKeyEvent *e) { |
1392 | switch ( e->key() ) { | 1391 | switch ( e->key() ) { |
1393 | // case Key_F1: | 1392 | // case Key_F1: |
1394 | // if(stopped && !recording) | 1393 | // if(stopped && !recording) |
1395 | // newSound(); | 1394 | // newSound(); |
1396 | // else | 1395 | // else |
1397 | // stop(); | 1396 | // stop(); |
1398 | // break; | 1397 | // break; |
1399 | // case Key_F2: | 1398 | // case Key_F2: |
1400 | // rewindReleased(); | 1399 | // rewindReleased(); |
1401 | // break; | 1400 | // break; |
1402 | // case Key_F3: | 1401 | // case Key_F3: |
1403 | // FastforwardReleased(); | 1402 | // FastforwardReleased(); |
1404 | // break; | 1403 | // break; |
1405 | 1404 | ||
1406 | ////////////////////////////// Zaurus keys | 1405 | ////////////////////////////// Zaurus keys |
1407 | case Key_F9: //activity | 1406 | case Key_F9: //activity |
1408 | break; | 1407 | break; |
1409 | case Key_F10: //contacts | 1408 | case Key_F10: //contacts |
1410 | break; | 1409 | break; |
1411 | case Key_F11: //menu | 1410 | case Key_F11: //menu |
1412 | break; | 1411 | break; |
1413 | case Key_F12: //home | 1412 | case Key_F12: //home |
1414 | if(stopped) | 1413 | if(stopped) |
1415 | doPlayBtn(); | 1414 | doPlayBtn(); |
1416 | else | 1415 | else |
1417 | stop(); | 1416 | stop(); |
1418 | break; | 1417 | break; |
1419 | case Key_F13: //mail | 1418 | case Key_F13: //mail |
1420 | break; | 1419 | break; |
1421 | case Key_Space: | 1420 | case Key_Space: |
1422 | if(stopped && !recording) | 1421 | if(stopped && !recording) |
1423 | newSound(); | 1422 | newSound(); |
1424 | else | 1423 | else |
1425 | stop(); | 1424 | stop(); |
1426 | break; | 1425 | break; |
1427 | case Key_Delete: | 1426 | case Key_Delete: |
1428 | deleteSound(); | 1427 | deleteSound(); |
1429 | break; | 1428 | break; |
1430 | case Key_Up: | 1429 | case Key_Up: |
1431 | // stop(); | 1430 | // stop(); |
1432 | qDebug("Up"); | 1431 | qDebug("Up"); |
1433 | break; | 1432 | break; |
1434 | case Key_Down: | 1433 | case Key_Down: |
1435 | // start(); | 1434 | // start(); |
1436 | // qDebug("Down"); | 1435 | // qDebug("Down"); |
1437 | // newSound(); | 1436 | // newSound(); |
1438 | break; | 1437 | break; |
1439 | case Key_Left: | 1438 | case Key_Left: |
1440 | qDebug("Left"); | 1439 | qDebug("Left"); |
1441 | rewindReleased(); | 1440 | rewindReleased(); |
1442 | break; | 1441 | break; |
1443 | case Key_Right: | 1442 | case Key_Right: |
1444 | qDebug("Right"); | 1443 | qDebug("Right"); |
1445 | FastforwardReleased(); | 1444 | FastforwardReleased(); |
1446 | break; | 1445 | break; |
1447 | } | 1446 | } |
1448 | } | 1447 | } |
1449 | 1448 | ||
1450 | void QtRec::endRecording() { | 1449 | void QtRec::endRecording() { |
1451 | monitoring = false; | 1450 | monitoring = false; |
1452 | recording = false; | 1451 | recording = false; |
1453 | stopped = true; | 1452 | stopped = true; |
1454 | waveform->reset(); | 1453 | waveform->reset(); |
1455 | setRecordButton( false); | 1454 | setRecordButton( false); |
1456 | 1455 | ||
1457 | toBeginningButton->setEnabled( true); | 1456 | toBeginningButton->setEnabled( true); |
1458 | toEndButton->setEnabled( true); | 1457 | toEndButton->setEnabled( true); |
1459 | 1458 | ||
1460 | killTimers(); | 1459 | killTimers(); |
1461 | 1460 | ||
1462 | if(autoMute) | 1461 | if(autoMute) |
1463 | doMute( true); | 1462 | doMute( true); |
1464 | 1463 | ||
1465 | soundDevice->closeDevice( true); | 1464 | soundDevice->closeDevice( true); |
1466 | 1465 | ||
1467 | if( wavFile->track.isOpen()) { | 1466 | if( wavFile->track.isOpen()) { |
1468 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); | 1467 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); |
1469 | // soundDevice->sd=-1; | 1468 | // soundDevice->sd=-1; |
1470 | filePara.numberSamples = 0; | 1469 | filePara.numberSamples = 0; |
1471 | // filePara.sd=-1; | 1470 | // filePara.sd=-1; |
1472 | wavFile->closeFile(); | 1471 | wavFile->closeFile(); |
1473 | filePara.fd=0; | 1472 | filePara.fd=0; |
1474 | 1473 | ||
1475 | if( wavFile->isTempFile()) { | 1474 | if( wavFile->isTempFile()) { |
1476 | // move tmp file to regular file | 1475 | // move tmp file to regular file |
1477 | QString cmd; | 1476 | QString cmd; |
1478 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1477 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1479 | // qDebug("moving tmp file to "+currentFileName); | 1478 | // qDebug("moving tmp file to "+currentFileName); |
1480 | system( cmd.latin1()); | 1479 | system( cmd.latin1()); |
1481 | } | 1480 | } |
1482 | 1481 | ||
1483 | qDebug("Just moved " + wavFile->currentFileName); | 1482 | qDebug("Just moved " + wavFile->currentFileName); |
1484 | Config cfg("OpieRec"); | 1483 | Config cfg("OpieRec"); |
1485 | cfg.setGroup("Sounds"); | 1484 | cfg.setGroup("Sounds"); |
1486 | 1485 | ||
1487 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1486 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1488 | 1487 | ||
1489 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); | 1488 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); |
1490 | currentFile = currentFile.left( currentFile.length() - 4); | 1489 | currentFile = currentFile.left( currentFile.length() - 4); |
1491 | 1490 | ||
1492 | cfg.writeEntry( "NumberofFiles", nFiles + 1); | 1491 | cfg.writeEntry( "NumberofFiles", nFiles + 1); |
1493 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); | 1492 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); |
1494 | cfg.writeEntry( currentFile, wavFile->currentFileName); | 1493 | cfg.writeEntry( currentFile, wavFile->currentFileName); |
1495 | 1494 | ||
1496 | QString time; | 1495 | QString time; |
1497 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1496 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1498 | cfg.writeEntry( wavFile->currentFileName, time ); | 1497 | cfg.writeEntry( wavFile->currentFileName, time ); |
1499 | // qDebug("writing config numberOfRecordedSeconds "+time); | 1498 | // qDebug("writing config numberOfRecordedSeconds "+time); |
1500 | 1499 | ||
1501 | cfg.write(); | 1500 | cfg.write(); |
1502 | qDebug("finished recording"); | 1501 | qDebug("finished recording"); |
1503 | timeLabel->setText(""); | 1502 | timeLabel->setText(""); |
1504 | } | 1503 | } |
1505 | 1504 | ||
1506 | if(soundDevice) delete soundDevice; | 1505 | if(soundDevice) delete soundDevice; |
1507 | 1506 | ||
1508 | timeSlider->setValue(0); | 1507 | timeSlider->setValue(0); |
1509 | initIconView(); | 1508 | initIconView(); |
1510 | selectItemByName( currentFile); | 1509 | selectItemByName( currentFile); |
1511 | } | 1510 | } |
1512 | 1511 | ||
1513 | void QtRec::endPlaying() { | 1512 | void QtRec::endPlaying() { |
1514 | monitoring = false; | 1513 | monitoring = false; |
1515 | recording = false; | 1514 | recording = false; |
1516 | playing = false; | 1515 | playing = false; |
1517 | stopped = true; | 1516 | stopped = true; |
1518 | waveform->reset(); | 1517 | waveform->reset(); |
1519 | // errorStop(); | 1518 | // errorStop(); |
1520 | // qDebug("end playing"); | 1519 | // qDebug("end playing"); |
1521 | setRecordButton( false); | 1520 | setRecordButton( false); |
1522 | 1521 | ||
1523 | toBeginningButton->setEnabled( true); | 1522 | toBeginningButton->setEnabled( true); |
1524 | toEndButton->setEnabled( true); | 1523 | toEndButton->setEnabled( true); |
1525 | 1524 | ||
1526 | if(autoMute) | 1525 | if(autoMute) |
1527 | doMute( true); | 1526 | doMute( true); |
1528 | 1527 | ||
1529 | soundDevice->closeDevice( false); | 1528 | soundDevice->closeDevice( false); |
1530 | soundDevice->sd = -1; | 1529 | soundDevice->sd = -1; |
1531 | // if(soundDevice) delete soundDevice; | 1530 | // if(soundDevice) delete soundDevice; |
1532 | // qDebug("file and sound device closed"); | 1531 | // qDebug("file and sound device closed"); |
1533 | timeLabel->setText(""); | 1532 | timeLabel->setText(""); |
1534 | total = 0; | 1533 | total = 0; |
1535 | filePara.numberSamples = 0; | 1534 | filePara.numberSamples = 0; |
1536 | filePara.sd = -1; | 1535 | filePara.sd = -1; |
1537 | // wavFile->closeFile(); | 1536 | // wavFile->closeFile(); |
1538 | filePara.fd = 0; | 1537 | filePara.fd = 0; |
1539 | // if(wavFile) delete wavFile; //this crashes | 1538 | // if(wavFile) delete wavFile; //this crashes |
1540 | 1539 | ||
1541 | // qDebug("track closed"); | 1540 | // qDebug("track closed"); |
1542 | killTimers(); | 1541 | killTimers(); |
1543 | qWarning("reset slider"); | 1542 | qWarning("reset slider"); |
1544 | timeSlider->setValue(0); | 1543 | timeSlider->setValue(0); |
1545 | 1544 | ||
1546 | if(soundDevice) delete soundDevice; | 1545 | if(soundDevice) delete soundDevice; |
1547 | 1546 | ||
1548 | } | 1547 | } |
1549 | 1548 | ||
1550 | bool QtRec::openPlayFile() { | 1549 | bool QtRec::openPlayFile() { |
1551 | 1550 | ||
1552 | qApp->processEvents(); | 1551 | qApp->processEvents(); |
1553 | if( currentFile.isEmpty()) { | 1552 | if( currentFile.isEmpty()) { |
1554 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); | 1553 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); |
1555 | endPlaying(); | 1554 | endPlaying(); |
1556 | return false; | 1555 | return false; |
1557 | } | 1556 | } |
1558 | QString currentFileName; | 1557 | QString currentFileName; |
1559 | Config cfg("OpieRec"); | 1558 | Config cfg("OpieRec"); |
1560 | cfg.setGroup("Sounds"); | 1559 | cfg.setGroup("Sounds"); |
1561 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); | 1560 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); |
1562 | for(int i=0;i<nFiles+1;i++) { //look for file | 1561 | for(int i=0;i<nFiles+1;i++) { //look for file |
1563 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { | 1562 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { |
1564 | currentFileName = cfg.readEntry( currentFile, "" ); | 1563 | currentFileName = cfg.readEntry( currentFile, "" ); |
1565 | qDebug("opening for play: " + currentFileName); | 1564 | qDebug("opening for play: " + currentFileName); |
1566 | } | 1565 | } |
1567 | } | 1566 | } |
1568 | wavFile = new WavFile(this, | 1567 | wavFile = new WavFile(this, |
1569 | currentFileName, | 1568 | currentFileName, |
1570 | false); | 1569 | false); |
1571 | filePara.fd = wavFile->wavHandle(); | 1570 | filePara.fd = wavFile->wavHandle(); |
1572 | if(filePara.fd == -1) { | 1571 | if(filePara.fd == -1) { |
1573 | // if(!track.open(IO_ReadOnly)) { | 1572 | // if(!track.open(IO_ReadOnly)) { |
1574 | QString errorMsg = (QString)strerror(errno); | 1573 | QString errorMsg = (QString)strerror(errno); |
1575 | monitoring = false; | 1574 | monitoring = false; |
1576 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1575 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
1577 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") | 1576 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") |
1578 | + errorMsg + "\n" + currentFile); | 1577 | + errorMsg + "\n" + currentFile); |
1579 | return false; | 1578 | return false; |
1580 | } else { | 1579 | } else { |
1581 | 1580 | ||
1582 | filePara.numberSamples = wavFile->getNumberSamples(); | 1581 | filePara.numberSamples = wavFile->getNumberSamples(); |
1583 | filePara.format = wavFile->getFormat(); | 1582 | filePara.format = wavFile->getFormat(); |
1584 | filePara.sampleRate = wavFile->getSampleRate(); | 1583 | filePara.sampleRate = wavFile->getSampleRate(); |
1585 | filePara.resolution = wavFile->getResolution(); | 1584 | filePara.resolution = wavFile->getResolution(); |
1586 | filePara.channels = wavFile->getChannels(); | 1585 | filePara.channels = wavFile->getChannels(); |
1587 | timeSlider->setPageStep(1); | 1586 | timeSlider->setPageStep(1); |
1588 | monitoring = true; | 1587 | monitoring = true; |
1589 | 1588 | ||
1590 | qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); | 1589 | qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); |
1591 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); | 1590 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); |
1592 | 1591 | ||
1593 | qWarning("seconds %d", sec); | 1592 | qWarning("seconds %d", sec); |
1594 | 1593 | ||
1595 | timeSlider->setRange(0, filePara.numberSamples ); | 1594 | timeSlider->setRange(0, filePara.numberSamples ); |
1596 | } | 1595 | } |
1597 | 1596 | ||
1598 | return true; | 1597 | return true; |
1599 | } | 1598 | } |
1600 | 1599 | ||
1601 | void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { | 1600 | void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { |
1602 | if(item == NULL ) | 1601 | if(item == NULL ) |
1603 | return; | 1602 | return; |
1604 | switch (mouse) { | 1603 | switch (mouse) { |
1605 | case 1: { | 1604 | case 1: { |
1606 | if( renameBox != 0 ) //tricky | 1605 | if( renameBox != 0 ) //tricky |
1607 | cancelRename(); | 1606 | cancelRename(); |
1608 | 1607 | ||
1609 | currentFile = item->text(0); | 1608 | currentFile = item->text(0); |
1610 | setCaption( "OpieRecord " + currentFile); | 1609 | setCaption( "OpieRecord " + currentFile); |
1611 | } | 1610 | } |
1612 | break; | 1611 | break; |
1613 | case 2: | 1612 | case 2: |
1614 | showListMenu(item); | 1613 | showListMenu(item); |
1615 | ListView1->clearSelection(); | 1614 | ListView1->clearSelection(); |
1616 | break; | 1615 | break; |
1617 | }; | 1616 | }; |
1618 | } | 1617 | } |
1619 | 1618 | ||
1620 | void QtRec::showListMenu(QListViewItem * item) { | 1619 | void QtRec::showListMenu(QListViewItem * item) { |
1621 | if(item == NULL) | 1620 | if(item == NULL) |
1622 | return; | 1621 | return; |
1623 | QPopupMenu *m = new QPopupMenu(this); | 1622 | QPopupMenu *m = new QPopupMenu(this); |
1624 | m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); | 1623 | m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); |
1625 | if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); | 1624 | if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); |
1626 | m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); | 1625 | m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); |
1627 | // #if defined (QTOPIA_INTERNAL_FSLP) | 1626 | // #if defined (QTOPIA_INTERNAL_FSLP) |
1628 | // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 1627 | // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1629 | // #endif | 1628 | // #endif |
1630 | m->insertSeparator(); | 1629 | m->insertSeparator(); |
1631 | m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); | 1630 | m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); |
1632 | m->exec( QCursor::pos() ); | 1631 | m->exec( QCursor::pos() ); |
1633 | qApp->processEvents(); | 1632 | qApp->processEvents(); |
1634 | } | 1633 | } |
1635 | 1634 | ||
1636 | void QtRec::fileBeamFinished( Ir *ir) { | 1635 | void QtRec::fileBeamFinished( Ir *ir) { |
1637 | if(ir) | 1636 | if(ir) |
1638 | QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); | 1637 | QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1639 | 1638 | ||
1640 | } | 1639 | } |
1641 | 1640 | ||
1642 | void QtRec::doBeam() { | 1641 | void QtRec::doBeam() { |
1643 | qApp->processEvents(); | 1642 | qApp->processEvents(); |
1644 | if( ListView1->currentItem() == NULL) | 1643 | if( ListView1->currentItem() == NULL) |
1645 | return; | 1644 | return; |
1646 | Ir ir; | 1645 | Ir ir; |
1647 | if( ir.supported()) { | 1646 | if( ir.supported()) { |
1648 | QString file = ListView1->currentItem()->text(0); | 1647 | QString file = ListView1->currentItem()->text(0); |
1649 | Config cfg("OpieRec"); | 1648 | Config cfg("OpieRec"); |
1650 | cfg.setGroup("Sounds"); | 1649 | cfg.setGroup("Sounds"); |
1651 | 1650 | ||
1652 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1651 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1653 | 1652 | ||
1654 | for(int i=0;i<nFiles+1;i++) { | 1653 | for(int i=0;i<nFiles+1;i++) { |
1655 | if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { | 1654 | if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { |
1656 | QString filePath = cfg.readEntry(file,""); | 1655 | QString filePath = cfg.readEntry(file,""); |
1657 | Ir *file = new Ir(this, "IR"); | 1656 | Ir *file = new Ir(this, "IR"); |
1658 | connect( file, SIGNAL( done(Ir*)), | 1657 | connect( file, SIGNAL( done(Ir*)), |
1659 | this, SLOT( fileBeamFinished(Ir*))); | 1658 | this, SLOT( fileBeamFinished(Ir*))); |
1660 | file->send( filePath, "OPieRec audio file\n" + filePath ); | 1659 | file->send( filePath, "OPieRec audio file\n" + filePath ); |
1661 | } | 1660 | } |
1662 | } | 1661 | } |
1663 | } | 1662 | } |
1664 | } | 1663 | } |
1665 | 1664 | ||
1666 | void QtRec::doMenuPlay() { | 1665 | void QtRec::doMenuPlay() { |
1667 | qApp->processEvents(); | 1666 | qApp->processEvents(); |
1668 | currentFile = ListView1->currentItem()->text(0); | 1667 | currentFile = ListView1->currentItem()->text(0); |
1669 | } | 1668 | } |
1670 | 1669 | ||
1671 | void QtRec::doRename() { | 1670 | void QtRec::doRename() { |
1672 | QRect r = ListView1->itemRect( ListView1->currentItem( )); | 1671 | QRect r = ListView1->itemRect( ListView1->currentItem( )); |
1673 | r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); | 1672 | r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); |
1674 | r.setX( ListView1->contentsX() ); | 1673 | r.setX( ListView1->contentsX() ); |
1675 | if ( r.width() > ListView1->visibleWidth() ) | 1674 | if ( r.width() > ListView1->visibleWidth() ) |
1676 | r.setWidth( ListView1->visibleWidth() ); | 1675 | r.setWidth( ListView1->visibleWidth() ); |
1677 | 1676 | ||
1678 | renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); | 1677 | renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); |
1679 | renameBox->setFrame(true); | 1678 | renameBox->setFrame(true); |
1680 | 1679 | ||
1681 | renameBox->setText( ListView1->currentItem()->text(0) ); | 1680 | renameBox->setText( ListView1->currentItem()->text(0) ); |
1682 | 1681 | ||
1683 | renameBox->selectAll(); | 1682 | renameBox->selectAll(); |
1684 | renameBox->installEventFilter( this ); | 1683 | renameBox->installEventFilter( this ); |
1685 | ListView1->addChild( renameBox, r.x(), r.y() ); | 1684 | ListView1->addChild( renameBox, r.x(), r.y() ); |
1686 | renameBox->resize( r.size() ); | 1685 | renameBox->resize( r.size() ); |
1687 | ListView1->viewport()->setFocusProxy( renameBox ); | 1686 | ListView1->viewport()->setFocusProxy( renameBox ); |
1688 | renameBox->setFocus(); | 1687 | renameBox->setFocus(); |
1689 | renameBox->show(); | 1688 | renameBox->show(); |
1690 | 1689 | ||
1691 | } | 1690 | } |
1692 | 1691 | ||
1693 | void QtRec::okRename() { | 1692 | void QtRec::okRename() { |
1694 | qDebug(renameBox->text()); | 1693 | qDebug(renameBox->text()); |
1695 | QString filename = renameBox->text(); | 1694 | QString filename = renameBox->text(); |
1696 | cancelRename(); | 1695 | cancelRename(); |
1697 | 1696 | ||
1698 | if( ListView1->currentItem() == NULL) | 1697 | if( ListView1->currentItem() == NULL) |
1699 | return; | 1698 | return; |
1700 | 1699 | ||
1701 | Config cfg("OpieRec"); | 1700 | Config cfg("OpieRec"); |
1702 | cfg.setGroup("Sounds"); | 1701 | cfg.setGroup("Sounds"); |
1703 | 1702 | ||
1704 | QString file = ListView1->currentItem()->text(0); | 1703 | QString file = ListView1->currentItem()->text(0); |
1705 | 1704 | ||
1706 | qDebug("filename is " + filename); | 1705 | qDebug("filename is " + filename); |
1707 | 1706 | ||
1708 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1707 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1709 | 1708 | ||
1710 | for(int i=0;i<nFiles+1;i++) { //look for file | 1709 | for(int i=0;i<nFiles+1;i++) { //look for file |
1711 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { | 1710 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { |
1712 | 1711 | ||
1713 | QString filePath = cfg.readEntry(file,""); | 1712 | QString filePath = cfg.readEntry(file,""); |
1714 | 1713 | ||
1715 | cfg.writeEntry( QString::number(i), filename ); | 1714 | cfg.writeEntry( QString::number(i), filename ); |
1716 | cfg.writeEntry( filename, filePath ); | 1715 | cfg.writeEntry( filename, filePath ); |
1717 | cfg.removeEntry( file); | 1716 | cfg.removeEntry( file); |
1718 | cfg.write(); | 1717 | cfg.write(); |
1719 | } | 1718 | } |
1720 | } | 1719 | } |
1721 | 1720 | ||
1722 | ListView1->takeItem( ListView1->currentItem() ); | 1721 | ListView1->takeItem( ListView1->currentItem() ); |
1723 | delete ListView1->currentItem(); | 1722 | delete ListView1->currentItem(); |
1724 | ListView1->clear(); | 1723 | ListView1->clear(); |
1725 | initIconView(); | 1724 | initIconView(); |
1726 | update(); | 1725 | update(); |
1727 | } | 1726 | } |
1728 | 1727 | ||
1729 | void QtRec::cancelRename() { | 1728 | void QtRec::cancelRename() { |
1730 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; | 1729 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; |
1731 | delete renameBox; | 1730 | delete renameBox; |
1732 | renameBox = 0; | 1731 | renameBox = 0; |
1733 | if ( resetFocus ) { | 1732 | if ( resetFocus ) { |
1734 | ListView1->viewport()->setFocusProxy( ListView1 ); | 1733 | ListView1->viewport()->setFocusProxy( ListView1 ); |
1735 | ListView1->setFocus(); | 1734 | ListView1->setFocus(); |
1736 | } | 1735 | } |
1737 | } | 1736 | } |
1738 | 1737 | ||
1739 | bool QtRec::eventFilter( QObject * o, QEvent * e ) { | 1738 | bool QtRec::eventFilter( QObject * o, QEvent * e ) { |
1740 | if ( o->inherits( "QLineEdit" ) ) { | 1739 | if ( o->inherits( "QLineEdit" ) ) { |
1741 | if ( e->type() == QEvent::KeyPress ) { | 1740 | if ( e->type() == QEvent::KeyPress ) { |
1742 | QKeyEvent *ke = (QKeyEvent*)e; | 1741 | QKeyEvent *ke = (QKeyEvent*)e; |
1743 | if ( ke->key() == Key_Return || | 1742 | if ( ke->key() == Key_Return || |
1744 | ke->key() == Key_Enter ) { | 1743 | ke->key() == Key_Enter ) { |
1745 | okRename(); | 1744 | okRename(); |
1746 | return true; | 1745 | return true; |
1747 | } else if ( ke->key() == Key_Escape ) { | 1746 | } else if ( ke->key() == Key_Escape ) { |
1748 | cancelRename(); | 1747 | cancelRename(); |
1749 | return true; | 1748 | return true; |
1750 | } | 1749 | } |
1751 | } else if ( e->type() == QEvent::FocusOut ) { | 1750 | } else if ( e->type() == QEvent::FocusOut ) { |
1752 | cancelRename(); | 1751 | cancelRename(); |
1753 | return true; | 1752 | return true; |
1754 | } | 1753 | } |
1755 | } | 1754 | } |
1756 | return QWidget::eventFilter( o, e ); | 1755 | return QWidget::eventFilter( o, e ); |
1757 | } | 1756 | } |
1758 | 1757 | ||
1759 | 1758 | ||
1760 | int QtRec::getCurrentSizeLimit() { | 1759 | int QtRec::getCurrentSizeLimit() { |
1761 | return sizeLimitCombo->currentItem() * 5; | 1760 | return sizeLimitCombo->currentItem() * 5; |
1762 | } | 1761 | } |
1763 | 1762 | ||
1764 | void QtRec::timerBreak() { | 1763 | void QtRec::timerBreak() { |
1765 | endPlaying(); | 1764 | endPlaying(); |
1766 | } | 1765 | } |
1767 | 1766 | ||
1768 | void QtRec::doVolMuting(bool b) { | 1767 | void QtRec::doVolMuting(bool b) { |
1769 | Config cfg( "qpe" ); | 1768 | Config cfg( "qpe" ); |
1770 | cfg. setGroup( "Volume" ); | 1769 | cfg. setGroup( "Volume" ); |
1771 | cfg.writeEntry( "Mute",b); | 1770 | cfg.writeEntry( "Mute",b); |
1772 | cfg.write(); | 1771 | cfg.write(); |
1773 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; | 1772 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; |
1774 | } | 1773 | } |
1775 | 1774 | ||
1776 | void QtRec::doMicMuting(bool b) { | 1775 | void QtRec::doMicMuting(bool b) { |
1777 | // qDebug("mic mute"); | 1776 | // qDebug("mic mute"); |
1778 | Config cfg( "qpe" ); | 1777 | Config cfg( "qpe" ); |
1779 | cfg. setGroup( "Volume" ); | 1778 | cfg. setGroup( "Volume" ); |
1780 | cfg.writeEntry( "MicMute",b); | 1779 | cfg.writeEntry( "MicMute",b); |
1781 | cfg.write(); | 1780 | cfg.write(); |
1782 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; | 1781 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; |
1783 | } | 1782 | } |
1784 | 1783 | ||
1785 | void QtRec::compressionSelected(bool b) { | 1784 | void QtRec::compressionSelected(bool b) { |
1786 | Config cfg("OpieRec"); | 1785 | Config cfg("OpieRec"); |
1787 | cfg.setGroup("Settings"); | 1786 | cfg.setGroup("Settings"); |
1788 | cfg.writeEntry("wavCompression", b); | 1787 | cfg.writeEntry("wavCompression", b); |
1789 | cfg.writeEntry("bitrate", 16); | 1788 | cfg.writeEntry("bitrate", 16); |
1790 | filePara.resolution = 16; | 1789 | filePara.resolution = 16; |
1791 | cfg.write(); | 1790 | cfg.write(); |
1792 | 1791 | ||
1793 | if(b) { | 1792 | if(b) { |
1794 | bitRateComboBox->setEnabled( false); | 1793 | bitRateComboBox->setEnabled( false); |
1795 | bitRateComboBox->setCurrentItem( 0); | 1794 | bitRateComboBox->setCurrentItem( 0); |
1796 | filePara.resolution = 16; | 1795 | filePara.resolution = 16; |
1797 | } else{ | 1796 | } else{ |
1798 | bitRateComboBox->setEnabled( true); | 1797 | bitRateComboBox->setEnabled( true); |
1799 | } | 1798 | } |
1800 | } | 1799 | } |
1801 | 1800 | ||
1802 | long QtRec::checkDiskSpace(const QString &path) { | 1801 | long QtRec::checkDiskSpace(const QString &path) { |
1803 | 1802 | ||
1804 | struct statfs fs; | 1803 | struct statfs fs; |
1805 | 1804 | ||
1806 | if ( !statfs( path.latin1(), &fs ) ) { | 1805 | if ( !statfs( path.latin1(), &fs ) ) { |
1807 | 1806 | ||
1808 | int blkSize = fs.f_bsize; | 1807 | int blkSize = fs.f_bsize; |
1809 | int availBlks = fs.f_bavail; | 1808 | int availBlks = fs.f_bavail; |
1810 | 1809 | ||
1811 | long mult = blkSize / 1024; | 1810 | long mult = blkSize / 1024; |
1812 | long div = 1024 / blkSize; | 1811 | long div = 1024 / blkSize; |
1813 | 1812 | ||
1814 | if ( !mult ) mult = 1; | 1813 | if ( !mult ) mult = 1; |
1815 | if ( !div ) div = 1; | 1814 | if ( !div ) div = 1; |
1816 | 1815 | ||
1817 | return availBlks * mult / div; | 1816 | return availBlks * mult / div; |
1818 | } | 1817 | } |
1819 | return -1; | 1818 | return -1; |
1820 | } | 1819 | } |
1821 | 1820 | ||
1822 | // short f_fstyp; /* File system type */ | 1821 | // short f_fstyp; /* File system type */ |
1823 | // long f_bsize; /* Block size */ | 1822 | // long f_bsize; /* Block size */ |
1824 | // long f_frsize; /* Fragment size */ | 1823 | // long f_frsize; /* Fragment size */ |
1825 | // long f_blocks; /* Total number of blocks*/ | 1824 | // long f_blocks; /* Total number of blocks*/ |
1826 | // long f_bfree; /* Count of free blocks */ | 1825 | // long f_bfree; /* Count of free blocks */ |
1827 | // long f_files; /* Total number of file nodes */ | 1826 | // long f_files; /* Total number of file nodes */ |
1828 | // long f_ffree; /* Count of free file nodes */ | 1827 | // long f_ffree; /* Count of free file nodes */ |
1829 | // char f_fname[6]; /* Volumename */ | 1828 | // char f_fname[6]; /* Volumename */ |
1830 | // char f_fpack[6]; /* Pack name */ | 1829 | // char f_fpack[6]; /* Pack name */ |
1831 | 1830 | ||
1832 | void QtRec::receive( const QCString &msg, const QByteArray & ) { | 1831 | void QtRec::receive( const QCString &msg, const QByteArray & ) { |
1833 | qDebug("Voicerecord received message "+msg); | 1832 | qDebug("Voicerecord received message "+msg); |
1834 | 1833 | ||
1835 | } | 1834 | } |
1836 | 1835 | ||
1837 | 1836 | ||
1838 | ///////////////////////////// timerEvent | 1837 | ///////////////////////////// timerEvent |
1839 | void QtRec::timerEvent( QTimerEvent * ) { | 1838 | void QtRec::timerEvent( QTimerEvent * ) { |
1840 | 1839 | ||
1841 | // if(!recording) | 1840 | // if(!recording) |
1842 | // timeSlider->setValue( secCount); | 1841 | // timeSlider->setValue( secCount); |
1843 | // else | 1842 | // else |
1844 | // timeSlider->setValue( filePara.numberOfRecordedSeconds); | 1843 | // timeSlider->setValue( filePara.numberOfRecordedSeconds); |
1845 | 1844 | ||
1846 | if( stopped && playing) { | 1845 | if( stopped && playing) { |
1847 | stop(); | 1846 | stop(); |
1848 | } | 1847 | } |
1849 | 1848 | ||
1850 | if( stopped && recording ){ | 1849 | if( stopped && recording ){ |
1851 | stop(); | 1850 | stop(); |
1852 | } | 1851 | } |
1853 | 1852 | ||
1854 | if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { | 1853 | if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { |
1855 | stop(); | 1854 | stop(); |
1856 | } | 1855 | } |
1857 | 1856 | ||
1858 | qDebug( "%d", secCount ); | 1857 | qDebug( "%d", secCount ); |
1859 | QString timeString; | 1858 | QString timeString; |
1860 | #ifdef DEV_VERSION | 1859 | #ifdef DEV_VERSION |
1861 | QString msg; | 1860 | QString msg; |
1862 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1861 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
1863 | setCaption( msg +" :: "+QString::number(secCount)); | 1862 | setCaption( msg +" :: "+QString::number(secCount)); |
1864 | #endif | 1863 | #endif |
1865 | 1864 | ||
1866 | timeString.sprintf("%d", secCount); | 1865 | timeString.sprintf("%d", secCount); |
1867 | timeLabel->setText( timeString + " seconds"); | 1866 | timeLabel->setText( timeString + " seconds"); |
1868 | 1867 | ||
1869 | secCount++; | 1868 | secCount++; |
1870 | } | 1869 | } |
1871 | 1870 | ||
1872 | void QtRec::changeTimeSlider(int index) { | 1871 | void QtRec::changeTimeSlider(int index) { |
1873 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; | 1872 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; |
1874 | // qDebug("Slider moved to %d",index); | 1873 | // qDebug("Slider moved to %d",index); |
1875 | paused = true; | 1874 | paused = true; |
1876 | stopped = true; | 1875 | stopped = true; |
1877 | 1876 | ||
1878 | sliderPos=index; | 1877 | sliderPos=index; |
1879 | 1878 | ||
1880 | QString timeString; | 1879 | QString timeString; |
1881 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1880 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1882 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1881 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1883 | secCount = (int)filePara.numberOfRecordedSeconds; | 1882 | secCount = (int)filePara.numberOfRecordedSeconds; |
1884 | timeLabel->setText( timeString + tr(" seconds")); | 1883 | timeLabel->setText( timeString + tr(" seconds")); |
1885 | } | 1884 | } |
1886 | 1885 | ||
1887 | void QtRec::timeSliderPressed() { | 1886 | void QtRec::timeSliderPressed() { |
1888 | if( ListView1->currentItem() == 0) return; | 1887 | if( ListView1->currentItem() == 0) return; |
1889 | // qDebug("slider pressed"); | 1888 | // qDebug("slider pressed"); |
1890 | paused = true; | 1889 | paused = true; |
1891 | stopped = true; | 1890 | stopped = true; |
1892 | } | 1891 | } |
1893 | 1892 | ||
1894 | void QtRec::timeSliderReleased() { | 1893 | void QtRec::timeSliderReleased() { |
1895 | if( ListView1->currentItem() == 0) return; | 1894 | if( ListView1->currentItem() == 0) return; |
1896 | sliderPos = timeSlider->value(); | 1895 | sliderPos = timeSlider->value(); |
1897 | 1896 | ||
1898 | // qDebug("slider released %d", sliderPos); | 1897 | // qDebug("slider released %d", sliderPos); |
1899 | stopped = false; | 1898 | stopped = false; |
1900 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1899 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1901 | total = newPos*4; | 1900 | total = newPos*4; |
1902 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1901 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1903 | 1902 | ||
1904 | doPlay(); | 1903 | doPlay(); |
1905 | } | 1904 | } |
1906 | 1905 | ||
1907 | void QtRec::rewindPressed() { | 1906 | void QtRec::rewindPressed() { |
1908 | if( ListView1->currentItem() == 0) return; | 1907 | if( ListView1->currentItem() == 0) return; |
1909 | if( !wavFile->track.isOpen()) { | 1908 | if( !wavFile->track.isOpen()) { |
1910 | if( !openPlayFile() ) | 1909 | if( !openPlayFile() ) |
1911 | return; | 1910 | return; |
1912 | else | 1911 | else |
1913 | if( !setupAudio( false)) | 1912 | if( !setupAudio( false)) |
1914 | return; | 1913 | return; |
1915 | } else { | 1914 | } else { |
1916 | killTimers(); | 1915 | killTimers(); |
1917 | paused = true; | 1916 | paused = true; |
1918 | stopped = true; | 1917 | stopped = true; |
1919 | rewindTimer->start( 50, false); | 1918 | rewindTimer->start( 50, false); |
1920 | } | 1919 | } |
1921 | } | 1920 | } |
1922 | 1921 | ||
1923 | void QtRec::rewindTimerTimeout() { | 1922 | void QtRec::rewindTimerTimeout() { |
1924 | int sliderValue = timeSlider->value(); | 1923 | int sliderValue = timeSlider->value(); |
1925 | sliderValue = sliderValue - ( filePara.numberSamples / 100); | 1924 | sliderValue = sliderValue - ( filePara.numberSamples / 100); |
1926 | // if(toBeginningButton->isDown()) | 1925 | // if(toBeginningButton->isDown()) |
1927 | timeSlider->setValue( sliderValue ) ; | 1926 | timeSlider->setValue( sliderValue ) ; |
1928 | // qDebug("%d", sliderValue); | 1927 | // qDebug("%d", sliderValue); |
1929 | QString timeString; | 1928 | QString timeString; |
1930 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; | 1929 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; |
1931 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1930 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1932 | timeLabel->setText( timeString+ tr(" seconds")); | 1931 | timeLabel->setText( timeString+ tr(" seconds")); |
1933 | } | 1932 | } |
1934 | 1933 | ||
1935 | void QtRec::rewindReleased() { | 1934 | void QtRec::rewindReleased() { |
1936 | rewindTimer->stop(); | 1935 | rewindTimer->stop(); |
1937 | if( wavFile->track.isOpen()) { | 1936 | if( wavFile->track.isOpen()) { |
1938 | sliderPos=timeSlider->value(); | 1937 | sliderPos=timeSlider->value(); |
1939 | stopped = false; | 1938 | stopped = false; |
1940 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1939 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1941 | total = newPos * 4; | 1940 | total = newPos * 4; |
1942 | // qDebug("rewind released %d", total); | 1941 | // qDebug("rewind released %d", total); |
1943 | startTimer( 1000); | 1942 | startTimer( 1000); |
1944 | doPlay(); | 1943 | doPlay(); |
1945 | } | 1944 | } |
1946 | } | 1945 | } |
1947 | 1946 | ||
1948 | void QtRec::FastforwardPressed() { | 1947 | void QtRec::FastforwardPressed() { |
1949 | if( ListView1->currentItem() == 0) return; | 1948 | if( ListView1->currentItem() == 0) return; |
1950 | if( !wavFile->track.isOpen()) | 1949 | if( !wavFile->track.isOpen()) |
1951 | if( !openPlayFile() ) | 1950 | if( !openPlayFile() ) |
1952 | return; | 1951 | return; |
1953 | else | 1952 | else |
1954 | if( !setupAudio( false)) | 1953 | if( !setupAudio( false)) |
1955 | return; | 1954 | return; |
1956 | killTimers(); | 1955 | killTimers(); |
1957 | 1956 | ||
1958 | paused = true; | 1957 | paused = true; |
1959 | stopped = true; | 1958 | stopped = true; |
1960 | forwardTimer->start(50, false); | 1959 | forwardTimer->start(50, false); |
1961 | } | 1960 | } |
1962 | 1961 | ||
1963 | 1962 | ||
1964 | void QtRec::forwardTimerTimeout() { | 1963 | void QtRec::forwardTimerTimeout() { |
1965 | int sliderValue = timeSlider->value(); | 1964 | int sliderValue = timeSlider->value(); |
1966 | sliderValue = sliderValue + ( filePara.numberSamples / 100); | 1965 | sliderValue = sliderValue + ( filePara.numberSamples / 100); |
1967 | 1966 | ||
1968 | // if(toEndButton->isDown()) | 1967 | // if(toEndButton->isDown()) |
1969 | timeSlider->setValue( sliderValue); | 1968 | timeSlider->setValue( sliderValue); |
1970 | 1969 | ||
1971 | QString timeString; | 1970 | QString timeString; |
1972 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; | 1971 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; |
1973 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1972 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1974 | timeLabel->setText( timeString+ tr(" seconds")); | 1973 | timeLabel->setText( timeString+ tr(" seconds")); |
1975 | } | 1974 | } |
1976 | 1975 | ||
1977 | void QtRec::FastforwardReleased() { | 1976 | void QtRec::FastforwardReleased() { |
1978 | forwardTimer->stop(); | 1977 | forwardTimer->stop(); |
1979 | if( wavFile->track.isOpen()) { | 1978 | if( wavFile->track.isOpen()) { |
1980 | sliderPos=timeSlider->value(); | 1979 | sliderPos=timeSlider->value(); |
1981 | stopped = false; | 1980 | stopped = false; |
1982 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1981 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1983 | total = newPos * 4; | 1982 | total = newPos * 4; |
1984 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1983 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1985 | startTimer( 1000); | 1984 | startTimer( 1000); |
1986 | doPlay(); | 1985 | doPlay(); |
1987 | } | 1986 | } |
1988 | } | 1987 | } |
1989 | 1988 | ||
1990 | 1989 | ||
1991 | QString QtRec::getStorage(const QString &fileName) { | 1990 | QString QtRec::getStorage(const QString &fileName) { |
1992 | 1991 | ||
1993 | StorageInfo storageInfo; | 1992 | StorageInfo storageInfo; |
1994 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1993 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1995 | QListIterator<FileSystem> it ( fs ); | 1994 | QListIterator<FileSystem> it ( fs ); |
1996 | QString storage; | 1995 | QString storage; |
1997 | for( ; it.current(); ++it ){ | 1996 | for( ; it.current(); ++it ){ |
1998 | const QString name = ( *it)->name(); | 1997 | const QString name = ( *it)->name(); |
1999 | const QString path = ( *it)->path(); | 1998 | const QString path = ( *it)->path(); |
2000 | const QString disk = ( *it)->disk(); | 1999 | const QString disk = ( *it)->disk(); |
2001 | if( fileName.find( path,0,true) != -1) | 2000 | if( fileName.find( path,0,true) != -1) |
2002 | storage = name; | 2001 | storage = name; |
2003 | // const QString options = (*it)->options(); | 2002 | // const QString options = (*it)->options(); |
2004 | // if( name.find( tr("Internal"),0,true) == -1) { | 2003 | // if( name.find( tr("Internal"),0,true) == -1) { |
2005 | // storageComboBox->insertItem( name +" -> "+disk); | 2004 | // storageComboBox->insertItem( name +" -> "+disk); |
2006 | // qDebug(name); | 2005 | // qDebug(name); |
2007 | } | 2006 | } |
2008 | return storage; | 2007 | return storage; |
2009 | // struct mntent *me; | 2008 | // struct mntent *me; |
2010 | // // if(fileName == "/etc/mtab") { | 2009 | // // if(fileName == "/etc/mtab") { |
2011 | // FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 2010 | // FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
2012 | // if ( mntfp ) { | 2011 | // if ( mntfp ) { |
2013 | // while ( (me = getmntent( mntfp )) != 0 ) { | 2012 | // while ( (me = getmntent( mntfp )) != 0 ) { |
2014 | // QString filesystemType = me->mnt_type; | 2013 | // QString filesystemType = me->mnt_type; |
2015 | 2014 | ||
2016 | // } | 2015 | // } |
2017 | // } | 2016 | // } |
2018 | // endmntent( mntfp ); | 2017 | // endmntent( mntfp ); |
2019 | } | 2018 | } |
2020 | 2019 | ||
2021 | void QtRec::setRecordButton(bool b) { | 2020 | void QtRec::setRecordButton(bool b) { |
2022 | 2021 | ||
2023 | if(b) { //about to record or play | 2022 | if(b) { //about to record or play |
2024 | 2023 | ||
2025 | Rec_PushButton->setDown( true); | 2024 | Rec_PushButton->setDown( true); |
2026 | QPixmap image3( ( const char** ) image3_data ); | 2025 | QPixmap image3( ( const char** ) image3_data ); |
2027 | Stop_PushButton->setPixmap( image3 ); | 2026 | Stop_PushButton->setPixmap( image3 ); |
2028 | if(Stop_PushButton->isDown()) | 2027 | if(Stop_PushButton->isDown()) |
2029 | Stop_PushButton->setDown( true); | 2028 | Stop_PushButton->setDown( true); |
2030 | playLabel2->setText( tr("Stop") ); | 2029 | playLabel2->setText( tr("Stop") ); |
2031 | 2030 | ||
2032 | } else { //about to stop | 2031 | } else { //about to stop |
2033 | 2032 | ||
2034 | QPixmap image4( ( const char** ) image4_data ); | 2033 | QPixmap image4( ( const char** ) image4_data ); |
2035 | Stop_PushButton->setPixmap( image4); | 2034 | Stop_PushButton->setPixmap( image4); |
2036 | if(Stop_PushButton->isDown()) | 2035 | if(Stop_PushButton->isDown()) |
2037 | Stop_PushButton->setDown( false); | 2036 | Stop_PushButton->setDown( false); |
2038 | playLabel2->setText( tr("Play") ); | 2037 | playLabel2->setText( tr("Play") ); |
2039 | if(Rec_PushButton->isDown()) | 2038 | if(Rec_PushButton->isDown()) |
2040 | Rec_PushButton->setDown( false); | 2039 | Rec_PushButton->setDown( false); |
2041 | } | 2040 | } |
2042 | } | 2041 | } |
2043 | 2042 | ||
2044 | void QtRec::fillDirectoryCombo() { | 2043 | void QtRec::fillDirectoryCombo() { |
2045 | if( directoryComboBox->count() > 0) | 2044 | if( directoryComboBox->count() > 0) |
2046 | directoryComboBox->clear(); | 2045 | directoryComboBox->clear(); |
2047 | int index = 0; | 2046 | int index = 0; |
2048 | Config cfg("OpieRec"); | 2047 | Config cfg("OpieRec"); |
2049 | cfg.setGroup("Settings"); | 2048 | cfg.setGroup("Settings"); |
2050 | QString dir = cfg.readEntry("directory", "/"); | 2049 | QString dir = cfg.readEntry("directory", "/"); |
2051 | StorageInfo storageInfo; | 2050 | StorageInfo storageInfo; |
2052 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 2051 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
2053 | QListIterator<FileSystem> it ( fs ); | 2052 | QListIterator<FileSystem> it ( fs ); |
2054 | QString storage; | 2053 | QString storage; |
2055 | for( ; it.current(); ++it ){ | 2054 | for( ; it.current(); ++it ){ |
2056 | const QString name = ( *it)->name(); | 2055 | const QString name = ( *it)->name(); |
2057 | const QString path = ( *it)->path(); | 2056 | const QString path = ( *it)->path(); |
2058 | // directoryComboBox->insertItem(name+" "+path); | 2057 | // directoryComboBox->insertItem(name+" "+path); |
2059 | directoryComboBox->insertItem(name); | 2058 | directoryComboBox->insertItem(name); |
2060 | if( path == dir) | 2059 | if( path == dir) |
2061 | directoryComboBox->setCurrentItem( index); | 2060 | directoryComboBox->setCurrentItem( index); |
2062 | index++; | 2061 | index++; |
2063 | } | 2062 | } |
2064 | } | 2063 | } |
2065 | 2064 | ||
2066 | void QtRec::errorStop() { | 2065 | void QtRec::errorStop() { |
2067 | stopped = true; | 2066 | stopped = true; |
2068 | wavFile->closeFile(); | 2067 | wavFile->closeFile(); |
2069 | killTimers(); | 2068 | killTimers(); |
2070 | } | 2069 | } |
2071 | 2070 | ||
2072 | void QtRec::doMute(bool b) { | 2071 | void QtRec::doMute(bool b) { |
2073 | doVolMuting( b); | 2072 | doVolMuting( b); |
2074 | doMicMuting( b); | 2073 | doMicMuting( b); |
2075 | } | 2074 | } |
2076 | 2075 | ||
2077 | void QtRec::slotAutoMute(bool b) { | 2076 | void QtRec::slotAutoMute(bool b) { |
2078 | autoMute = b; | 2077 | autoMute = b; |
2079 | Config cfg("OpieRec"); | 2078 | Config cfg("OpieRec"); |
2080 | cfg.setGroup("Settings"); | 2079 | cfg.setGroup("Settings"); |
2081 | cfg.writeEntry("useAutoMute",b); | 2080 | cfg.writeEntry("useAutoMute",b); |
2082 | doMute( b); | 2081 | doMute( b); |
2083 | outMuteCheckBox->setChecked( b); | 2082 | outMuteCheckBox->setChecked( b); |
2084 | inMuteCheckBox->setChecked( b); | 2083 | inMuteCheckBox->setChecked( b); |
2085 | } | 2084 | } |
2086 | 2085 | ||
2087 | void QtRec::selectItemByName(const QString & name) { | 2086 | void QtRec::selectItemByName(const QString & name) { |
2088 | QListViewItemIterator it( ListView1 ); | 2087 | QListViewItemIterator it( ListView1 ); |
2089 | for ( ; it.current(); ++it ) | 2088 | for ( ; it.current(); ++it ) |
2090 | if( name == it.current()->text(0)) | 2089 | if( name == it.current()->text(0)) |
2091 | ListView1->setCurrentItem(it.current()); | 2090 | ListView1->setCurrentItem(it.current()); |
2092 | } | 2091 | } |
2093 | 2092 | ||
2094 | 2093 | ||
2095 | // long findPeak(long input ) { | 2094 | // long findPeak(long input ) { |
2096 | 2095 | ||
2097 | // // halfLife = time in seconds for output to decay to half value after an impulse | 2096 | // // halfLife = time in seconds for output to decay to half value after an impulse |
2098 | // static float output = 0.0; | 2097 | // static float output = 0.0; |
2099 | // float halfLife = .0025; | 2098 | // float halfLife = .0025; |
2100 | // float vsf = .0025; | 2099 | // float vsf = .0025; |
2101 | // float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); | 2100 | // float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); |
2102 | // if( input < 0.0 ) | 2101 | // if( input < 0.0 ) |
2103 | // input = -input; // Absolute value. | 2102 | // input = -input; // Absolute value. |
2104 | // if ( input >= output ) { | 2103 | // if ( input >= output ) { |
2105 | // // When we hit a peak, ride the peak to the top. | 2104 | // // When we hit a peak, ride the peak to the top. |
2106 | // output = input; | 2105 | // output = input; |
2107 | // } else { | 2106 | // } else { |
2108 | // // Exponential decay of output when signal is low. | 2107 | // // Exponential decay of output when signal is low. |
2109 | // output = output * scalar; | 2108 | // output = output * scalar; |
2110 | // // | 2109 | // // |
2111 | // // When current gets close to 0.0, set current to 0.0 to prevent FP underflow | 2110 | // // When current gets close to 0.0, set current to 0.0 to prevent FP underflow |
2112 | // // which can cause a severe performance degradation due to a flood | 2111 | // // which can cause a severe performance degradation due to a flood |
2113 | // // of interrupts. | 2112 | // // of interrupts. |
2114 | // // | 2113 | // // |
2115 | // if( output < vsf ) output = 0.0; | 2114 | // if( output < vsf ) output = 0.0; |
2116 | // } | 2115 | // } |
2117 | 2116 | ||
2118 | // return (long) output; | 2117 | // return (long) output; |
2119 | // } | 2118 | // } |
2120 | 2119 | ||
2121 | void QtRec::changeStereoCheck(bool b) { | 2120 | void QtRec::changeStereoCheck(bool b) { |
2122 | Config cfg("OpieRec"); | 2121 | Config cfg("OpieRec"); |
2123 | cfg.setGroup("Settings"); | 2122 | cfg.setGroup("Settings"); |
2124 | int ch = 0; | 2123 | int ch = 0; |
2125 | if ( !b) { ch = 1;} | 2124 | if ( !b) { ch = 1;} |
2126 | else { ch = 2;} | 2125 | else { ch = 2;} |
2127 | cfg.writeEntry("stereo", b); | 2126 | cfg.writeEntry("stereo", b); |
2128 | filePara.channels = ch; | 2127 | filePara.channels = ch; |
2129 | 2128 | ||
2130 | cfg.write(); | 2129 | cfg.write(); |
2131 | } | 2130 | } |
2132 | 2131 | ||
2133 | 2132 | ||
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index 1d58bb3..35bc14d 100644 --- a/noncore/multimedia/opierec/wavFile.cpp +++ b/noncore/multimedia/opierec/wavFile.cpp | |||
@@ -1,312 +1,311 @@ | |||
1 | //wavFile.cpp | 1 | //wavFile.cpp |
2 | #include "wavFile.h" | 2 | #include "wavFile.h" |
3 | #include "qtrec.h" | 3 | #include "qtrec.h" |
4 | 4 | ||
5 | #include <qmessagebox.h> | 5 | #include <qmessagebox.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | 7 | ||
8 | #include <qpe/timestring.h> | ||
9 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
10 | 9 | ||
11 | #include <errno.h> | 10 | #include <errno.h> |
12 | 11 | ||
13 | #include <sys/time.h> | 12 | #include <sys/time.h> |
14 | #include <sys/types.h> | 13 | #include <sys/types.h> |
15 | #include <sys/vfs.h> | 14 | #include <sys/vfs.h> |
16 | 15 | ||
17 | #include <fcntl.h> | 16 | #include <fcntl.h> |
18 | #include <math.h> | 17 | #include <math.h> |
19 | #include <mntent.h> | 18 | #include <mntent.h> |
20 | #include <stdio.h> | 19 | #include <stdio.h> |
21 | #include <stdlib.h> | 20 | #include <stdlib.h> |
22 | #include <unistd.h> | 21 | #include <unistd.h> |
23 | 22 | ||
24 | WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, | 23 | WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, |
25 | int channels, int resolution, int format ) | 24 | int channels, int resolution, int format ) |
26 | : QObject( parent) | 25 | : QObject( parent) |
27 | { | 26 | { |
28 | //qDebug("new wave file"); | 27 | //qDebug("new wave file"); |
29 | bool b = makeNwFile; | 28 | bool b = makeNwFile; |
30 | wavSampleRate=sampleRate; | 29 | wavSampleRate=sampleRate; |
31 | wavFormat=format; | 30 | wavFormat=format; |
32 | wavChannels=channels; | 31 | wavChannels=channels; |
33 | wavResolution=resolution; | 32 | wavResolution=resolution; |
34 | useTmpFile=false; | 33 | useTmpFile=false; |
35 | if( b) { | 34 | if( b) { |
36 | newFile(); | 35 | newFile(); |
37 | } else { | 36 | } else { |
38 | openFile(fileName); | 37 | openFile(fileName); |
39 | } | 38 | } |
40 | } | 39 | } |
41 | 40 | ||
42 | bool WavFile::newFile() { | 41 | bool WavFile::newFile() { |
43 | 42 | ||
44 | // qDebug("Set up new file"); | 43 | // qDebug("Set up new file"); |
45 | Config cfg("OpieRec"); | 44 | Config cfg("OpieRec"); |
46 | cfg.setGroup("Settings"); | 45 | cfg.setGroup("Settings"); |
47 | 46 | ||
48 | currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); | 47 | currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); |
49 | QString date; | 48 | QString date; |
50 | QDateTime dt = QDateTime::currentDateTime(); | 49 | QDateTime dt = QDateTime::currentDateTime(); |
51 | date = dt.toString();//TimeString::dateString( QDateTime::currentDateTime(),false,true); | 50 | date = dt.toString();//TimeString::dateString( QDateTime::currentDateTime(),false,true); |
52 | date.replace(QRegExp("'"),""); | 51 | date.replace(QRegExp("'"),""); |
53 | date.replace(QRegExp(" "),"_"); | 52 | date.replace(QRegExp(" "),"_"); |
54 | date.replace(QRegExp(":"),"."); | 53 | date.replace(QRegExp(":"),"."); |
55 | date.replace(QRegExp(","),""); | 54 | date.replace(QRegExp(","),""); |
56 | 55 | ||
57 | QString currentFile=date; | 56 | QString currentFile=date; |
58 | if(currentFileName.right(1).find("/",0,true) == -1) | 57 | if(currentFileName.right(1).find("/",0,true) == -1) |
59 | currentFileName += "/" + date; | 58 | currentFileName += "/" + date; |
60 | else | 59 | else |
61 | currentFileName += date; | 60 | currentFileName += date; |
62 | currentFileName+=".wav"; | 61 | currentFileName+=".wav"; |
63 | 62 | ||
64 | // qDebug("set up file for recording: "+currentFileName); | 63 | // qDebug("set up file for recording: "+currentFileName); |
65 | char pointer[] = "/tmp/opierec-XXXXXX"; | 64 | char pointer[] = "/tmp/opierec-XXXXXX"; |
66 | int fd = 0; | 65 | int fd = 0; |
67 | 66 | ||
68 | if( currentFileName.find("/mnt",0,true) == -1 | 67 | if( currentFileName.find("/mnt",0,true) == -1 |
69 | && currentFileName.find("/tmp",0,true) == -1 ) { | 68 | && currentFileName.find("/tmp",0,true) == -1 ) { |
70 | // if destination file is most likely in flash (assuming jffs2) | 69 | // if destination file is most likely in flash (assuming jffs2) |
71 | // we have to write to a different filesystem first | 70 | // we have to write to a different filesystem first |
72 | 71 | ||
73 | useTmpFile = true; | 72 | useTmpFile = true; |
74 | if(( fd = mkstemp( pointer)) < 0 ) { | 73 | if(( fd = mkstemp( pointer)) < 0 ) { |
75 | perror("mkstemp failed"); | 74 | perror("mkstemp failed"); |
76 | return false; | 75 | return false; |
77 | } | 76 | } |
78 | 77 | ||
79 | // qDebug("Opening tmp file %s",pointer); | 78 | // qDebug("Opening tmp file %s",pointer); |
80 | track.setName( pointer); | 79 | track.setName( pointer); |
81 | 80 | ||
82 | } else { //just use regular file.. no moving | 81 | } else { //just use regular file.. no moving |
83 | 82 | ||
84 | useTmpFile = false; | 83 | useTmpFile = false; |
85 | track.setName( currentFileName); | 84 | track.setName( currentFileName); |
86 | } | 85 | } |
87 | if(!track.open( IO_ReadWrite | IO_Truncate)) { | 86 | if(!track.open( IO_ReadWrite | IO_Truncate)) { |
88 | QString errorMsg=(QString)strerror(errno); | 87 | QString errorMsg=(QString)strerror(errno); |
89 | qDebug(errorMsg); | 88 | qDebug(errorMsg); |
90 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 89 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
91 | 90 | ||
92 | return false; | 91 | return false; |
93 | } else { | 92 | } else { |
94 | setWavHeader( track.handle() , &hdr); | 93 | setWavHeader( track.handle() , &hdr); |
95 | } | 94 | } |
96 | return true; | 95 | return true; |
97 | } | 96 | } |
98 | 97 | ||
99 | WavFile::~WavFile() { | 98 | WavFile::~WavFile() { |
100 | 99 | ||
101 | closeFile(); | 100 | closeFile(); |
102 | } | 101 | } |
103 | 102 | ||
104 | void WavFile::closeFile() { | 103 | void WavFile::closeFile() { |
105 | if(track.isOpen()) | 104 | if(track.isOpen()) |
106 | track.close(); | 105 | track.close(); |
107 | } | 106 | } |
108 | 107 | ||
109 | int WavFile::openFile(const QString ¤tFileName) { | 108 | int WavFile::openFile(const QString ¤tFileName) { |
110 | // qDebug("open play file "+currentFileName); | 109 | // qDebug("open play file "+currentFileName); |
111 | closeFile(); | 110 | closeFile(); |
112 | 111 | ||
113 | track.setName(currentFileName); | 112 | track.setName(currentFileName); |
114 | 113 | ||
115 | if(!track.open(IO_ReadOnly)) { | 114 | if(!track.open(IO_ReadOnly)) { |
116 | QString errorMsg=(QString)strerror(errno); | 115 | QString errorMsg=(QString)strerror(errno); |
117 | qDebug("<<<<<<<<<<< "+errorMsg+currentFileName); | 116 | qDebug("<<<<<<<<<<< "+errorMsg+currentFileName); |
118 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 117 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
119 | return -1; | 118 | return -1; |
120 | } else { | 119 | } else { |
121 | parseWavHeader( track.handle()); | 120 | parseWavHeader( track.handle()); |
122 | } | 121 | } |
123 | return track.handle(); | 122 | return track.handle(); |
124 | } | 123 | } |
125 | 124 | ||
126 | bool WavFile::setWavHeader(int fd, wavhdr *hdr) { | 125 | bool WavFile::setWavHeader(int fd, wavhdr *hdr) { |
127 | 126 | ||
128 | strncpy((*hdr).riffID, "RIFF", 4); // RIFF | 127 | strncpy((*hdr).riffID, "RIFF", 4); // RIFF |
129 | strncpy((*hdr).wavID, "WAVE", 4); //WAVE | 128 | strncpy((*hdr).wavID, "WAVE", 4); //WAVE |
130 | strncpy((*hdr).fmtID, "fmt ", 4); // fmt | 129 | strncpy((*hdr).fmtID, "fmt ", 4); // fmt |
131 | (*hdr).fmtLen = 16; // format length = 16 | 130 | (*hdr).fmtLen = 16; // format length = 16 |
132 | 131 | ||
133 | if( wavFormat == WAVE_FORMAT_PCM) { | 132 | if( wavFormat == WAVE_FORMAT_PCM) { |
134 | (*hdr).fmtTag = 1; // PCM | 133 | (*hdr).fmtTag = 1; // PCM |
135 | // qDebug("set header WAVE_FORMAT_PCM"); | 134 | // qDebug("set header WAVE_FORMAT_PCM"); |
136 | } | 135 | } |
137 | else { | 136 | else { |
138 | (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM | 137 | (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM |
139 | // qDebug("set header WAVE_FORMAT_DVI_ADPCM"); | 138 | // qDebug("set header WAVE_FORMAT_DVI_ADPCM"); |
140 | } | 139 | } |
141 | 140 | ||
142 | // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels | 141 | // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels |
143 | (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels | 142 | (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels |
144 | 143 | ||
145 | (*hdr).sampleRate = wavSampleRate; //samples per second | 144 | (*hdr).sampleRate = wavSampleRate; //samples per second |
146 | (*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second | 145 | (*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second |
147 | (*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align | 146 | (*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align |
148 | (*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16 | 147 | (*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16 |
149 | 148 | ||
150 | strncpy((*hdr).dataID, "data", 4); | 149 | strncpy((*hdr).dataID, "data", 4); |
151 | 150 | ||
152 | write( fd,hdr, sizeof(*hdr)); | 151 | write( fd,hdr, sizeof(*hdr)); |
153 | qDebug("writing header: bitrate%d, samplerate %d, channels %d", | 152 | qDebug("writing header: bitrate%d, samplerate %d, channels %d", |
154 | wavResolution, wavSampleRate, wavChannels); | 153 | wavResolution, wavSampleRate, wavChannels); |
155 | return true; | 154 | return true; |
156 | } | 155 | } |
157 | 156 | ||
158 | bool WavFile::adjustHeaders(int fd, int total) { | 157 | bool WavFile::adjustHeaders(int fd, int total) { |
159 | lseek(fd, 4, SEEK_SET); | 158 | lseek(fd, 4, SEEK_SET); |
160 | int i = total + 36; | 159 | int i = total + 36; |
161 | write( fd, &i, sizeof(i)); | 160 | write( fd, &i, sizeof(i)); |
162 | lseek( fd, 40, SEEK_SET); | 161 | lseek( fd, 40, SEEK_SET); |
163 | write( fd, &total, sizeof(total)); | 162 | write( fd, &total, sizeof(total)); |
164 | qDebug("adjusting header %d", total); | 163 | qDebug("adjusting header %d", total); |
165 | return true; | 164 | return true; |
166 | } | 165 | } |
167 | 166 | ||
168 | int WavFile::parseWavHeader(int fd) { | 167 | int WavFile::parseWavHeader(int fd) { |
169 | qDebug("Parsing wav header"); | 168 | qDebug("Parsing wav header"); |
170 | char string[4]; | 169 | char string[4]; |
171 | int found; | 170 | int found; |
172 | short fmt; | 171 | short fmt; |
173 | unsigned short ch, bitrate; | 172 | unsigned short ch, bitrate; |
174 | unsigned long samplerrate, longdata; | 173 | unsigned long samplerrate, longdata; |
175 | 174 | ||
176 | if (read(fd, string, 4) < 4) { | 175 | if (read(fd, string, 4) < 4) { |
177 | qDebug(" Could not read from sound file.\n"); | 176 | qDebug(" Could not read from sound file.\n"); |
178 | return -1; | 177 | return -1; |
179 | } | 178 | } |
180 | if (strncmp(string, "RIFF", 4)) { | 179 | if (strncmp(string, "RIFF", 4)) { |
181 | qDebug(" not a valid WAV file.\n"); | 180 | qDebug(" not a valid WAV file.\n"); |
182 | return -1; | 181 | return -1; |
183 | } | 182 | } |
184 | lseek(fd, 4, SEEK_CUR); | 183 | lseek(fd, 4, SEEK_CUR); |
185 | if (read(fd, string, 4) < 4) { | 184 | if (read(fd, string, 4) < 4) { |
186 | qDebug("Could not read from sound file.\n"); | 185 | qDebug("Could not read from sound file.\n"); |
187 | return -1; | 186 | return -1; |
188 | } | 187 | } |
189 | if (strncmp(string, "WAVE", 4)) { | 188 | if (strncmp(string, "WAVE", 4)) { |
190 | qDebug("not a valid WAV file.\n"); | 189 | qDebug("not a valid WAV file.\n"); |
191 | return -1; | 190 | return -1; |
192 | } | 191 | } |
193 | found = 0; | 192 | found = 0; |
194 | 193 | ||
195 | while (!found) { | 194 | while (!found) { |
196 | if (read(fd, string, 4) < 4) { | 195 | if (read(fd, string, 4) < 4) { |
197 | qDebug("Could not read from sound file.\n"); | 196 | qDebug("Could not read from sound file.\n"); |
198 | return -1; | 197 | return -1; |
199 | } | 198 | } |
200 | if (strncmp(string, "fmt ", 4)) { | 199 | if (strncmp(string, "fmt ", 4)) { |
201 | if (read(fd, &longdata, 4) < 4) { | 200 | if (read(fd, &longdata, 4) < 4) { |
202 | qDebug("Could not read from sound file.\n"); | 201 | qDebug("Could not read from sound file.\n"); |
203 | return -1; | 202 | return -1; |
204 | } | 203 | } |
205 | lseek(fd, longdata, SEEK_CUR); | 204 | lseek(fd, longdata, SEEK_CUR); |
206 | } else { | 205 | } else { |
207 | lseek(fd, 4, SEEK_CUR); | 206 | lseek(fd, 4, SEEK_CUR); |
208 | if (read(fd, &fmt, 2) < 2) { | 207 | if (read(fd, &fmt, 2) < 2) { |
209 | qDebug("Could not read format chunk.\n"); | 208 | qDebug("Could not read format chunk.\n"); |
210 | return -1; | 209 | return -1; |
211 | } | 210 | } |
212 | if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { | 211 | if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { |
213 | qDebug("Wave file contains unknown format." | 212 | qDebug("Wave file contains unknown format." |
214 | " Unable to continue.\n"); | 213 | " Unable to continue.\n"); |
215 | return -1; | 214 | return -1; |
216 | } | 215 | } |
217 | wavFormat = fmt; | 216 | wavFormat = fmt; |
218 | // compressionFormat=fmt; | 217 | // compressionFormat=fmt; |
219 | qDebug("compressionFormat is %d", fmt); | 218 | qDebug("compressionFormat is %d", fmt); |
220 | if (read(fd, &ch, 2) < 2) { | 219 | if (read(fd, &ch, 2) < 2) { |
221 | qDebug("Could not read format chunk.\n"); | 220 | qDebug("Could not read format chunk.\n"); |
222 | return -1; | 221 | return -1; |
223 | } else { | 222 | } else { |
224 | wavChannels = ch; | 223 | wavChannels = ch; |
225 | qDebug("File has %d channels", ch); | 224 | qDebug("File has %d channels", ch); |
226 | } | 225 | } |
227 | if (read(fd, &samplerrate, 4) < 4) { | 226 | if (read(fd, &samplerrate, 4) < 4) { |
228 | qDebug("Could not read from format chunk.\n"); | 227 | qDebug("Could not read from format chunk.\n"); |
229 | return -1; | 228 | return -1; |
230 | } else { | 229 | } else { |
231 | wavSampleRate = samplerrate; | 230 | wavSampleRate = samplerrate; |
232 | // sampleRate = samplerrate; | 231 | // sampleRate = samplerrate; |
233 | qDebug("File has samplerate of %d",(int) samplerrate); | 232 | qDebug("File has samplerate of %d",(int) samplerrate); |
234 | } | 233 | } |
235 | lseek(fd, 6, SEEK_CUR); | 234 | lseek(fd, 6, SEEK_CUR); |
236 | if (read(fd, &bitrate, 2) < 2) { | 235 | if (read(fd, &bitrate, 2) < 2) { |
237 | qDebug("Could not read format chunk.\n"); | 236 | qDebug("Could not read format chunk.\n"); |
238 | return -1; | 237 | return -1; |
239 | } else { | 238 | } else { |
240 | wavResolution=bitrate; | 239 | wavResolution=bitrate; |
241 | // resolution = bitrate; | 240 | // resolution = bitrate; |
242 | qDebug("File has bitrate of %d", bitrate); | 241 | qDebug("File has bitrate of %d", bitrate); |
243 | } | 242 | } |
244 | found++; | 243 | found++; |
245 | } | 244 | } |
246 | } | 245 | } |
247 | found = 0; | 246 | found = 0; |
248 | while (!found) { | 247 | while (!found) { |
249 | if (read(fd, string, 4) < 4) { | 248 | if (read(fd, string, 4) < 4) { |
250 | qDebug("Could not read from sound file.\n"); | 249 | qDebug("Could not read from sound file.\n"); |
251 | return -1; | 250 | return -1; |
252 | } | 251 | } |
253 | 252 | ||
254 | if (strncmp(string, "data", 4)) { | 253 | if (strncmp(string, "data", 4)) { |
255 | if (read(fd, &longdata, 4)<4) { | 254 | if (read(fd, &longdata, 4)<4) { |
256 | qDebug("Could not read from sound file.\n"); | 255 | qDebug("Could not read from sound file.\n"); |
257 | return -1; | 256 | return -1; |
258 | } | 257 | } |
259 | 258 | ||
260 | lseek(fd, longdata, SEEK_CUR); | 259 | lseek(fd, longdata, SEEK_CUR); |
261 | } else { | 260 | } else { |
262 | if (read(fd, &longdata, 4) < 4) { | 261 | if (read(fd, &longdata, 4) < 4) { |
263 | qDebug("Could not read from sound file.\n"); | 262 | qDebug("Could not read from sound file.\n"); |
264 | return -1; | 263 | return -1; |
265 | } else { | 264 | } else { |
266 | wavNumberSamples = longdata; | 265 | wavNumberSamples = longdata; |
267 | qDebug("file has length of %d \nlasting %d seconds", (int)longdata, | 266 | qDebug("file has length of %d \nlasting %d seconds", (int)longdata, |
268 | (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) ); | 267 | (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) ); |
269 | // wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); | 268 | // wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); |
270 | 269 | ||
271 | return longdata; | 270 | return longdata; |
272 | } | 271 | } |
273 | } | 272 | } |
274 | } | 273 | } |
275 | 274 | ||
276 | lseek(fd, 0, SEEK_SET); | 275 | lseek(fd, 0, SEEK_SET); |
277 | 276 | ||
278 | return 0; | 277 | return 0; |
279 | } | 278 | } |
280 | 279 | ||
281 | QString WavFile::trackName() { | 280 | QString WavFile::trackName() { |
282 | return track.name(); | 281 | return track.name(); |
283 | } | 282 | } |
284 | 283 | ||
285 | int WavFile::wavHandle(){ | 284 | int WavFile::wavHandle(){ |
286 | return track.handle(); | 285 | return track.handle(); |
287 | } | 286 | } |
288 | 287 | ||
289 | int WavFile::getFormat() { | 288 | int WavFile::getFormat() { |
290 | return wavFormat; | 289 | return wavFormat; |
291 | } | 290 | } |
292 | 291 | ||
293 | int WavFile::getResolution() { | 292 | int WavFile::getResolution() { |
294 | return wavResolution; | 293 | return wavResolution; |
295 | } | 294 | } |
296 | 295 | ||
297 | int WavFile::getSampleRate() { | 296 | int WavFile::getSampleRate() { |
298 | return wavSampleRate; | 297 | return wavSampleRate; |
299 | } | 298 | } |
300 | 299 | ||
301 | int WavFile::getNumberSamples() { | 300 | int WavFile::getNumberSamples() { |
302 | return wavNumberSamples; | 301 | return wavNumberSamples; |
303 | } | 302 | } |
304 | 303 | ||
305 | bool WavFile::isTempFile() { | 304 | bool WavFile::isTempFile() { |
306 | return useTmpFile; | 305 | return useTmpFile; |
307 | } | 306 | } |
308 | 307 | ||
309 | int WavFile::getChannels() { | 308 | int WavFile::getChannels() { |
310 | 309 | ||
311 | return wavChannels; | 310 | return wavChannels; |
312 | } | 311 | } |
diff --git a/noncore/multimedia/opierec/waveform.cpp b/noncore/multimedia/opierec/waveform.cpp index 05be373..9cc40b4 100644 --- a/noncore/multimedia/opierec/waveform.cpp +++ b/noncore/multimedia/opierec/waveform.cpp | |||
@@ -1,160 +1,159 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #include "waveform.h" | 20 | #include "waveform.h" |
21 | 21 | ||
22 | #include <qlabel.h> | ||
23 | #include <qpainter.h> | 22 | #include <qpainter.h> |
24 | 23 | ||
25 | 24 | ||
26 | Waveform::Waveform( QWidget *parent, const char *name, WFlags fl ) | 25 | Waveform::Waveform( QWidget *parent, const char *name, WFlags fl ) |
27 | : QWidget( parent, name, fl ) | 26 | : QWidget( parent, name, fl ) |
28 | { | 27 | { |
29 | pixmap = 0; | 28 | pixmap = 0; |
30 | windowSize = 100; | 29 | windowSize = 100; |
31 | samplesPerPixel = 8000 / (5 * windowSize); | 30 | samplesPerPixel = 8000 / (5 * windowSize); |
32 | currentValue = 0; | 31 | currentValue = 0; |
33 | numSamples = 0; | 32 | numSamples = 0; |
34 | windowPosn = 0; | 33 | windowPosn = 0; |
35 | window = 0; | 34 | window = 0; |
36 | } | 35 | } |
37 | 36 | ||
38 | 37 | ||
39 | void Waveform::changeSettings( int frequency, int channels ) | 38 | void Waveform::changeSettings( int frequency, int channels ) |
40 | { | 39 | { |
41 | makePixmap(); | 40 | makePixmap(); |
42 | // qWarning("change waveform %d, %d", frequency, channels); | 41 | // qWarning("change waveform %d, %d", frequency, channels); |
43 | samplesPerPixel = frequency * channels / (5 * windowSize); | 42 | samplesPerPixel = frequency * channels / (5 * windowSize); |
44 | qWarning("Waveform::changeSettings %d", samplesPerPixel); | 43 | qWarning("Waveform::changeSettings %d", samplesPerPixel); |
45 | if ( !samplesPerPixel ) | 44 | if ( !samplesPerPixel ) |
46 | samplesPerPixel = 1; | 45 | samplesPerPixel = 1; |
47 | currentValue = 0; | 46 | currentValue = 0; |
48 | numSamples = 0; | 47 | numSamples = 0; |
49 | windowPosn = 0; | 48 | windowPosn = 0; |
50 | draw(); | 49 | draw(); |
51 | } | 50 | } |
52 | 51 | ||
53 | 52 | ||
54 | Waveform::~Waveform() | 53 | Waveform::~Waveform() |
55 | { | 54 | { |
56 | if ( window ) | 55 | if ( window ) |
57 | delete[] window; | 56 | delete[] window; |
58 | if ( pixmap ) | 57 | if ( pixmap ) |
59 | delete pixmap; | 58 | delete pixmap; |
60 | } | 59 | } |
61 | 60 | ||
62 | 61 | ||
63 | void Waveform::reset() | 62 | void Waveform::reset() |
64 | { | 63 | { |
65 | makePixmap(); | 64 | makePixmap(); |
66 | currentValue = 0; | 65 | currentValue = 0; |
67 | numSamples = 0; | 66 | numSamples = 0; |
68 | windowPosn = 0; | 67 | windowPosn = 0; |
69 | draw(); | 68 | draw(); |
70 | } | 69 | } |
71 | 70 | ||
72 | 71 | ||
73 | void Waveform::newSamples( const short *buf, int len ) | 72 | void Waveform::newSamples( const short *buf, int len ) |
74 | { | 73 | { |
75 | // Cache the object values in local variables. | 74 | // Cache the object values in local variables. |
76 | int samplesPerPixel = this->samplesPerPixel; | 75 | int samplesPerPixel = this->samplesPerPixel; |
77 | int currentValue = this->currentValue; | 76 | int currentValue = this->currentValue; |
78 | int numSamples = this->numSamples; | 77 | int numSamples = this->numSamples; |
79 | short *window = this->window; | 78 | short *window = this->window; |
80 | int windowPosn = this->windowPosn; | 79 | int windowPosn = this->windowPosn; |
81 | int windowSize = this->windowSize; | 80 | int windowSize = this->windowSize; |
82 | 81 | ||
83 | // Average the incoming samples to scale them to the window. | 82 | // Average the incoming samples to scale them to the window. |
84 | while ( len > 0 ) { | 83 | while ( len > 0 ) { |
85 | currentValue += *buf++; | 84 | currentValue += *buf++; |
86 | --len; | 85 | --len; |
87 | if ( ++numSamples >= samplesPerPixel ) { | 86 | if ( ++numSamples >= samplesPerPixel ) { |
88 | window[windowPosn++] = (short)(currentValue / numSamples); | 87 | window[windowPosn++] = (short)(currentValue / numSamples); |
89 | if ( windowPosn >= windowSize ) { | 88 | if ( windowPosn >= windowSize ) { |
90 | this->windowPosn = windowPosn; | 89 | this->windowPosn = windowPosn; |
91 | draw(); | 90 | draw(); |
92 | windowPosn = 0; | 91 | windowPosn = 0; |
93 | } | 92 | } |
94 | numSamples = 0; | 93 | numSamples = 0; |
95 | currentValue = 0; | 94 | currentValue = 0; |
96 | } | 95 | } |
97 | } | 96 | } |
98 | 97 | ||
99 | // Copy the final state back to the object. | 98 | // Copy the final state back to the object. |
100 | //qWarning("%d, %d, %d", currentValue, numSamples, windowPosn); | 99 | //qWarning("%d, %d, %d", currentValue, numSamples, windowPosn); |
101 | this->currentValue = currentValue; | 100 | this->currentValue = currentValue; |
102 | this->numSamples = numSamples; | 101 | this->numSamples = numSamples; |
103 | this->windowPosn = windowPosn; | 102 | this->windowPosn = windowPosn; |
104 | } | 103 | } |
105 | 104 | ||
106 | 105 | ||
107 | void Waveform::makePixmap() | 106 | void Waveform::makePixmap() |
108 | { | 107 | { |
109 | if ( !pixmap ) { | 108 | if ( !pixmap ) { |
110 | pixmap = new QPixmap( size() ); | 109 | pixmap = new QPixmap( size() ); |
111 | windowSize = pixmap->width(); | 110 | windowSize = pixmap->width(); |
112 | window = new short [windowSize]; | 111 | window = new short [windowSize]; |
113 | } | 112 | } |
114 | } | 113 | } |
115 | 114 | ||
116 | 115 | ||
117 | void Waveform::draw() | 116 | void Waveform::draw() |
118 | { | 117 | { |
119 | pixmap->fill( Qt::black ); | 118 | pixmap->fill( Qt::black ); |
120 | QPainter painter; | 119 | QPainter painter; |
121 | painter.begin( pixmap ); | 120 | painter.begin( pixmap ); |
122 | painter.setPen( Qt::green ); | 121 | painter.setPen( Qt::green ); |
123 | 122 | ||
124 | int middle = pixmap->height() / 2; | 123 | int middle = pixmap->height() / 2; |
125 | int mag; | 124 | int mag; |
126 | short *window = this->window; | 125 | short *window = this->window; |
127 | int posn; | 126 | int posn; |
128 | int size = windowPosn; | 127 | int size = windowPosn; |
129 | for( posn = 0; posn < size; ++posn ) | 128 | for( posn = 0; posn < size; ++posn ) |
130 | { | 129 | { |
131 | mag = (window[posn] * middle / 32768); | 130 | mag = (window[posn] * middle / 32768); |
132 | painter.drawLine(posn, middle - mag, posn, middle + mag); | 131 | painter.drawLine(posn, middle - mag, posn, middle + mag); |
133 | } | 132 | } |
134 | if ( windowPosn < windowSize ) | 133 | if ( windowPosn < windowSize ) |
135 | { | 134 | { |
136 | painter.drawLine(windowPosn, middle, windowSize, middle); | 135 | painter.drawLine(windowPosn, middle, windowSize, middle); |
137 | } | 136 | } |
138 | 137 | ||
139 | painter.end(); | 138 | painter.end(); |
140 | 139 | ||
141 | paintEvent( 0 ); | 140 | paintEvent( 0 ); |
142 | } | 141 | } |
143 | 142 | ||
144 | 143 | ||
145 | void Waveform::paintEvent( QPaintEvent * ) | 144 | void Waveform::paintEvent( QPaintEvent * ) |
146 | { | 145 | { |
147 | QPainter painter; | 146 | QPainter painter; |
148 | painter.begin( this ); | 147 | painter.begin( this ); |
149 | 148 | ||
150 | if ( pixmap ) { | 149 | if ( pixmap ) { |
151 | painter.drawPixmap( 0, 0, *pixmap ); | 150 | painter.drawPixmap( 0, 0, *pixmap ); |
152 | } else { | 151 | } else { |
153 | painter.setPen( Qt::green ); | 152 | painter.setPen( Qt::green ); |
154 | QSize sz = size(); | 153 | QSize sz = size(); |
155 | painter.drawLine(0, sz.height() / 2, sz.width(), sz.height() / 2); | 154 | painter.drawLine(0, sz.height() / 2, sz.width(), sz.height() / 2); |
156 | } | 155 | } |
157 | 156 | ||
158 | painter.end(); | 157 | painter.end(); |
159 | } | 158 | } |
160 | 159 | ||
diff --git a/noncore/multimedia/powerchord/fretboard.cpp b/noncore/multimedia/powerchord/fretboard.cpp index 0687d00..bf78e4c 100644 --- a/noncore/multimedia/powerchord/fretboard.cpp +++ b/noncore/multimedia/powerchord/fretboard.cpp | |||
@@ -1,234 +1,233 @@ | |||
1 | // | 1 | // |
2 | // FretBoard class to display interface for chord finder application | 2 | // FretBoard class to display interface for chord finder application |
3 | // | 3 | // |
4 | 4 | ||
5 | // Copyright (c) 2001 Camilo Mesias | 5 | // Copyright (c) 2001 Camilo Mesias |
6 | // camilo@mesias.co.uk | 6 | // camilo@mesias.co.uk |
7 | // | 7 | // |
8 | // This program is free software; you can redistribute it and/or | 8 | // This program is free software; you can redistribute it and/or |
9 | // modify it under the terms of the GNU General Public License | 9 | // modify it under the terms of the GNU General Public License |
10 | // as published by the Free Software Foundation; either version 2 | 10 | // as published by the Free Software Foundation; either version 2 |
11 | // of the License, or (at your option) any later version. | 11 | // of the License, or (at your option) any later version. |
12 | // | 12 | // |
13 | // This program is distributed in the hope that it will be useful, | 13 | // This program is distributed in the hope that it will be useful, |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | // GNU General Public License for more details. | 16 | // GNU General Public License for more details. |
17 | // | 17 | // |
18 | // You should have received a copy of the GNU General Public License | 18 | // You should have received a copy of the GNU General Public License |
19 | // along with this program; if not, write to the Free Software | 19 | // along with this program; if not, write to the Free Software |
20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | //#include <FL/Fl.H> | 22 | //#include <FL/Fl.H> |
23 | //#include <FL/Fl_Widget.H> | 23 | //#include <FL/Fl_Widget.H> |
24 | //#include <FL/fl_draw.H> | 24 | //#include <FL/fl_draw.H> |
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include <qpixmap.h> | ||
27 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
28 | #include "fretboard.h" | 27 | #include "fretboard.h" |
29 | #include <qpainter.h> | 28 | #include <qpainter.h> |
30 | 29 | ||
31 | void FretBoard::refresh(){ | 30 | void FretBoard::refresh(){ |
32 | ce.calculate(); | 31 | ce.calculate(); |
33 | 32 | ||
34 | emit nameChanged(QString(ce.label())); | 33 | emit nameChanged(QString(ce.label())); |
35 | 34 | ||
36 | for (int i=0;i<6;i++){ | 35 | for (int i=0;i<6;i++){ |
37 | Finger(i, ce.finger(i)); | 36 | Finger(i, ce.finger(i)); |
38 | // yuk | 37 | // yuk |
39 | switch (i) { | 38 | switch (i) { |
40 | case 0: | 39 | case 0: |
41 | emit s1nameChanged(QString(ce.name(i))); | 40 | emit s1nameChanged(QString(ce.name(i))); |
42 | break; | 41 | break; |
43 | case 1: | 42 | case 1: |
44 | emit s2nameChanged(QString(ce.name(i))); | 43 | emit s2nameChanged(QString(ce.name(i))); |
45 | break; | 44 | break; |
46 | case 2: | 45 | case 2: |
47 | emit s3nameChanged(QString(ce.name(i))); | 46 | emit s3nameChanged(QString(ce.name(i))); |
48 | break; | 47 | break; |
49 | case 3: | 48 | case 3: |
50 | emit s4nameChanged(QString(ce.name(i))); | 49 | emit s4nameChanged(QString(ce.name(i))); |
51 | break; | 50 | break; |
52 | case 4: | 51 | case 4: |
53 | emit s5nameChanged(QString(ce.name(i))); | 52 | emit s5nameChanged(QString(ce.name(i))); |
54 | break; | 53 | break; |
55 | case 5: | 54 | case 5: |
56 | emit s6nameChanged(QString(ce.name(i))); | 55 | emit s6nameChanged(QString(ce.name(i))); |
57 | break; | 56 | break; |
58 | } | 57 | } |
59 | } | 58 | } |
60 | 59 | ||
61 | update(); | 60 | update(); |
62 | } | 61 | } |
63 | 62 | ||
64 | FretBoard::FretBoard(QWidget *parent, const char *name ) | 63 | FretBoard::FretBoard(QWidget *parent, const char *name ) |
65 | : QWidget( parent, name ), ce() | 64 | : QWidget( parent, name ), ce() |
66 | { | 65 | { |
67 | 66 | ||
68 | ce.base(9); | 67 | ce.base(9); |
69 | ce.chord(0); | 68 | ce.chord(0); |
70 | ce.fret(0); | 69 | ce.fret(0); |
71 | ce.span(1); | 70 | ce.span(1); |
72 | ce.vary(7); | 71 | ce.vary(7); |
73 | ce.tune(0); | 72 | ce.tune(0); |
74 | refresh(); | 73 | refresh(); |
75 | 74 | ||
76 | // setPalette( QPalette( QColor( 250, 250, 200) ) ); | 75 | // setPalette( QPalette( QColor( 250, 250, 200) ) ); |
77 | 76 | ||
78 | stringtop_pix = Resource::loadPixmap( "powerchord/stringtop_s"); | 77 | stringtop_pix = Resource::loadPixmap( "powerchord/stringtop_s"); |
79 | string_pix = Resource::loadPixmap( "powerchord/string_s"); | 78 | string_pix = Resource::loadPixmap( "powerchord/string_s"); |
80 | finger_pix = Resource::loadPixmap( "powerchord/justfing_s"); | 79 | finger_pix = Resource::loadPixmap( "powerchord/justfing_s"); |
81 | mute_pix = Resource::loadPixmap( "powerchord/muted_s"); | 80 | mute_pix = Resource::loadPixmap( "powerchord/muted_s"); |
82 | 81 | ||
83 | // box(FL_NO_BOX); | 82 | // box(FL_NO_BOX); |
84 | 83 | ||
85 | // finger[0] = OPEN; | 84 | // finger[0] = OPEN; |
86 | // finger[1] = OPEN; | 85 | // finger[1] = OPEN; |
87 | // finger[2] = OPEN; | 86 | // finger[2] = OPEN; |
88 | // finger[3] = OPEN; | 87 | // finger[3] = OPEN; |
89 | // finger[4] = OPEN; | 88 | // finger[4] = OPEN; |
90 | // finger[5] = OPEN; | 89 | // finger[5] = OPEN; |
91 | 90 | ||
92 | initial_fret = 0; | 91 | initial_fret = 0; |
93 | 92 | ||
94 | // label(FL_NORMAL_LABEL, "Chord"); | 93 | // label(FL_NORMAL_LABEL, "Chord"); |
95 | } | 94 | } |
96 | 95 | ||
97 | // int FretBoard::Finger(int f){ | 96 | // int FretBoard::Finger(int f){ |
98 | // if (f < 0 || f > 5){ | 97 | // if (f < 0 || f > 5){ |
99 | // fprintf(stderr, "Error - finger value was %d\n", f); | 98 | // fprintf(stderr, "Error - finger value was %d\n", f); |
100 | // return 0; | 99 | // return 0; |
101 | // } | 100 | // } |
102 | // return finger[f]; | 101 | // return finger[f]; |
103 | // } | 102 | // } |
104 | 103 | ||
105 | void FretBoard::Finger(int f, int position){ | 104 | void FretBoard::Finger(int f, int position){ |
106 | if (f < 0 || f > 5){ | 105 | if (f < 0 || f > 5){ |
107 | fprintf(stderr, "Error - finger2 value was %d\n", f); | 106 | fprintf(stderr, "Error - finger2 value was %d\n", f); |
108 | return; | 107 | return; |
109 | } | 108 | } |
110 | 109 | ||
111 | finger[f] = position; | 110 | finger[f] = position; |
112 | } | 111 | } |
113 | 112 | ||
114 | // void FretBoard::draw(void) { | 113 | // void FretBoard::draw(void) { |
115 | // draw_box(); | 114 | // draw_box(); |
116 | // draw_label(); | 115 | // draw_label(); |
117 | // } | 116 | // } |
118 | 117 | ||
119 | // void FretBoard::draw_label(void) { | 118 | // void FretBoard::draw_label(void) { |
120 | // align(FL_ALIGN_CENTER | FL_ALIGN_TOP | FL_ALIGN_WRAP); | 119 | // align(FL_ALIGN_CENTER | FL_ALIGN_TOP | FL_ALIGN_WRAP); |
121 | 120 | ||
122 | // this->Fl_Widget::draw_label(); | 121 | // this->Fl_Widget::draw_label(); |
123 | // } | 122 | // } |
124 | 123 | ||
125 | 124 | ||
126 | //void FretBoard::draw_box(void) { | 125 | //void FretBoard::draw_box(void) { |
127 | 126 | ||
128 | void FretBoard::paintEvent(QPaintEvent *){ | 127 | void FretBoard::paintEvent(QPaintEvent *){ |
129 | 128 | ||
130 | // fl_color(FL_WHITE); | 129 | // fl_color(FL_WHITE); |
131 | 130 | ||
132 | // Fl_Widget::draw_box(); | 131 | // Fl_Widget::draw_box(); |
133 | 132 | ||
134 | // fl_color(FL_BLACK); | 133 | // fl_color(FL_BLACK); |
135 | 134 | ||
136 | QPainter p( this ); | 135 | QPainter p( this ); |
137 | 136 | ||
138 | p.setBrush(black); | 137 | p.setBrush(black); |
139 | p.translate(0, 0); | 138 | p.translate(0, 0); |
140 | 139 | ||
141 | // draw each string | 140 | // draw each string |
142 | for (int f=0; f<=5; f++){ | 141 | for (int f=0; f<=5; f++){ |
143 | // draw a string starting from the highest visible fret | 142 | // draw a string starting from the highest visible fret |
144 | for (int pp=0; pp<=6; pp++){ | 143 | for (int pp=0; pp<=6; pp++){ |
145 | int this_fret = initial_fret + pp; | 144 | int this_fret = initial_fret + pp; |
146 | int cx = /* x() + */ 28*f; | 145 | int cx = /* x() + */ 28*f; |
147 | int cy = /* y() + */ pp*30; | 146 | int cy = /* y() + */ pp*30; |
148 | 147 | ||
149 | //fl_color(FL_WHITE); | 148 | //fl_color(FL_WHITE); |
150 | // fl_rectf(cx, cy, 24, 24); | 149 | // fl_rectf(cx, cy, 24, 24); |
151 | // p.setBrush(white); | 150 | // p.setBrush(white); |
152 | // p.setPen(NoPen); | 151 | // p.setPen(NoPen); |
153 | 152 | ||
154 | // p.drawRect( QRect(cx, cy, 24, 24) ); | 153 | // p.drawRect( QRect(cx, cy, 24, 24) ); |
155 | // fl_color(FL_BLACK); | 154 | // fl_color(FL_BLACK); |
156 | // p.setBrush(black); | 155 | // p.setBrush(black); |
157 | 156 | ||
158 | // p.setPen(black); | 157 | // p.setPen(black); |
159 | 158 | ||
160 | // draw the string unless at top | 159 | // draw the string unless at top |
161 | if (this_fret!=0){ | 160 | if (this_fret!=0){ |
162 | //fl_line(cx+12, cy, cx+12, cy+23); | 161 | //fl_line(cx+12, cy, cx+12, cy+23); |
163 | //p.drawLine(cx+12, cy, cx+12, cy+23); | 162 | //p.drawLine(cx+12, cy, cx+12, cy+23); |
164 | } | 163 | } |
165 | 164 | ||
166 | // draw mutes if at top | 165 | // draw mutes if at top |
167 | if (pp == 0 && | 166 | if (pp == 0 && |
168 | finger[f] == MUTED){ | 167 | finger[f] == MUTED){ |
169 | p.drawPixmap(cx,cy,mute_pix); | 168 | p.drawPixmap(cx,cy,mute_pix); |
170 | //fl_line(cx+4, cy+19, cx+19, cy+4); | 169 | //fl_line(cx+4, cy+19, cx+19, cy+4); |
171 | //p.drawLine(cx+4, cy+19, cx+19, cy+4); | 170 | //p.drawLine(cx+4, cy+19, cx+19, cy+4); |
172 | //fl_line(cx+5, cy+19, cx+20, cy+4); | 171 | //fl_line(cx+5, cy+19, cx+20, cy+4); |
173 | //p.drawLine(cx+5, cy+19, cx+20, cy+4); | 172 | //p.drawLine(cx+5, cy+19, cx+20, cy+4); |
174 | //fl_line(cx+4, cy+4, cx+19, cy+19); | 173 | //fl_line(cx+4, cy+4, cx+19, cy+19); |
175 | //p.drawLine(cx+4, cy+4, cx+19, cy+19); | 174 | //p.drawLine(cx+4, cy+4, cx+19, cy+19); |
176 | //fl_line(cx+5, cy+4, cx+20, cy+19); | 175 | //fl_line(cx+5, cy+4, cx+20, cy+19); |
177 | //p.drawLine(cx+5, cy+4, cx+20, cy+19); | 176 | //p.drawLine(cx+5, cy+4, cx+20, cy+19); |
178 | } | 177 | } |
179 | 178 | ||
180 | if (this_fret==0){ | 179 | if (this_fret==0){ |
181 | // above, blank | 180 | // above, blank |
182 | }else if(this_fret==1){ | 181 | }else if(this_fret==1){ |
183 | // top | 182 | // top |
184 | p.drawPixmap(cx,cy,stringtop_pix); | 183 | p.drawPixmap(cx,cy,stringtop_pix); |
185 | }else{ | 184 | }else{ |
186 | // normal | 185 | // normal |
187 | p.drawPixmap(cx,cy,string_pix); | 186 | p.drawPixmap(cx,cy,string_pix); |
188 | } | 187 | } |
189 | 188 | ||
190 | // frets at bottom | 189 | // frets at bottom |
191 | // thick line if at top | 190 | // thick line if at top |
192 | // int x0 = (f==0)?(cx+12):cx; | 191 | // int x0 = (f==0)?(cx+12):cx; |
193 | // int x1 = (f==5)?(cx+12):(cx+23); | 192 | // int x1 = (f==5)?(cx+12):(cx+23); |
194 | // for (int offset=23; offset>((this_fret==0)?20:22); offset--){ | 193 | // for (int offset=23; offset>((this_fret==0)?20:22); offset--){ |
195 | //fl_line(x0, cy+offset, x1, cy+offset); | 194 | //fl_line(x0, cy+offset, x1, cy+offset); |
196 | //p.drawLine(x0, cy+offset, x1, cy+offset); | 195 | //p.drawLine(x0, cy+offset, x1, cy+offset); |
197 | // } | 196 | // } |
198 | 197 | ||
199 | // finger if at that position | 198 | // finger if at that position |
200 | if ((initial_fret==0 && pp == finger[f]) || | 199 | if ((initial_fret==0 && pp == finger[f]) || |
201 | (initial_fret!=0 && pp == finger[f]-8)){ | 200 | (initial_fret!=0 && pp == finger[f]-8)){ |
202 | p.drawPixmap(cx,cy,finger_pix); | 201 | p.drawPixmap(cx,cy,finger_pix); |
203 | 202 | ||
204 | // fl_color(FL_WHITE); | 203 | // fl_color(FL_WHITE); |
205 | // p.setBrush(white); | 204 | // p.setBrush(white); |
206 | // p.setPen(NoPen); | 205 | // p.setPen(NoPen); |
207 | 206 | ||
208 | // fl_rectf(cx+4, cy+4, 16, 16); | 207 | // fl_rectf(cx+4, cy+4, 16, 16); |
209 | //p.drawRect( QRect(cx+4, cy+4, 16, 16)); | 208 | //p.drawRect( QRect(cx+4, cy+4, 16, 16)); |
210 | // fl_color(FL_BLACK); | 209 | // fl_color(FL_BLACK); |
211 | //p.setPen(black); | 210 | //p.setPen(black); |
212 | // fl_line(cx+4, cy+11, cx+7, cy+16); | 211 | // fl_line(cx+4, cy+11, cx+7, cy+16); |
213 | //p.drawLine(cx+4, cy+11, cx+7, cy+16); | 212 | //p.drawLine(cx+4, cy+11, cx+7, cy+16); |
214 | // fl_line(cx+7, cy+16, cx+12, cy+19); | 213 | // fl_line(cx+7, cy+16, cx+12, cy+19); |
215 | //p.drawLine(cx+7, cy+16, cx+12, cy+19); | 214 | //p.drawLine(cx+7, cy+16, cx+12, cy+19); |
216 | // fl_line(cx+12, cy+19, cx+16, cy+16); | 215 | // fl_line(cx+12, cy+19, cx+16, cy+16); |
217 | //p.drawLine(cx+12, cy+19, cx+16, cy+16); | 216 | //p.drawLine(cx+12, cy+19, cx+16, cy+16); |
218 | // fl_line(cx+16, cy+16, cx+19, cy+12); | 217 | // fl_line(cx+16, cy+16, cx+19, cy+12); |
219 | //p.drawLine(cx+16, cy+16, cx+19, cy+12); | 218 | //p.drawLine(cx+16, cy+16, cx+19, cy+12); |
220 | // fl_line(cx+19, cy+12, cx+16, cy+7); | 219 | // fl_line(cx+19, cy+12, cx+16, cy+7); |
221 | //p.drawLine(cx+19, cy+12, cx+16, cy+7); | 220 | //p.drawLine(cx+19, cy+12, cx+16, cy+7); |
222 | // fl_line(cx+16, cy+7, cx+12, cy+4); | 221 | // fl_line(cx+16, cy+7, cx+12, cy+4); |
223 | //p.drawLine(cx+16, cy+7, cx+12, cy+4); | 222 | //p.drawLine(cx+16, cy+7, cx+12, cy+4); |
224 | // fl_line(cx+11, cy+4, cx+7, cy+7); | 223 | // fl_line(cx+11, cy+4, cx+7, cy+7); |
225 | //p.drawLine(cx+11, cy+4, cx+7, cy+7); | 224 | //p.drawLine(cx+11, cy+4, cx+7, cy+7); |
226 | // fl_line(cx+7, cy+7, cx+4, cy+11); | 225 | // fl_line(cx+7, cy+7, cx+4, cy+11); |
227 | //p.drawLine(cx+7, cy+7, cx+4, cy+11); | 226 | //p.drawLine(cx+7, cy+7, cx+4, cy+11); |
228 | } | 227 | } |
229 | } | 228 | } |
230 | } | 229 | } |
231 | p.end(); | 230 | p.end(); |
232 | } | 231 | } |
233 | 232 | ||
234 | 233 | ||
diff --git a/noncore/multimedia/powerchord/gs.cpp b/noncore/multimedia/powerchord/gs.cpp index fdcfb74..69d9d75 100644 --- a/noncore/multimedia/powerchord/gs.cpp +++ b/noncore/multimedia/powerchord/gs.cpp | |||
@@ -1,465 +1,463 @@ | |||
1 | 1 | ||
2 | //#include <FL/Fl.H> | 2 | //#include <FL/Fl.H> |
3 | //#include <FL/Fl_Widget.H> | 3 | //#include <FL/Fl_Widget.H> |
4 | //#include <FL/fl_draw.H> | 4 | //#include <FL/fl_draw.H> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | //#include <qpixmap.h> | 6 | //#include <qpixmap.h> |
7 | #include "gs.h" | 7 | #include "gs.h" |
8 | 8 | ||
9 | #include <sys/ioctl.h> | 9 | #include <sys/ioctl.h> |
10 | #include <unistd.h> | 10 | #include <unistd.h> |
11 | #include <fcntl.h> | 11 | #include <fcntl.h> |
12 | #include <sys/soundcard.h> | 12 | #include <sys/soundcard.h> |
13 | 13 | ||
14 | #include <errno.h> | 14 | #include <errno.h> |
15 | #include <string.h> | 15 | #include <string.h> |
16 | 16 | ||
17 | #include <stdlib.h> | 17 | #include <stdlib.h> |
18 | 18 | ||
19 | //#include <qpainter.h> | 19 | //#include <qpainter.h> |
20 | #include <qmessagebox.h> | ||
21 | #include <qstring.h> | ||
22 | 20 | ||
23 | 21 | ||
24 | gs::gs() | 22 | gs::gs() |
25 | { | 23 | { |
26 | 24 | ||
27 | finger[0] = OPEN; | 25 | finger[0] = OPEN; |
28 | finger[1] = OPEN; | 26 | finger[1] = OPEN; |
29 | finger[2] = OPEN; | 27 | finger[2] = OPEN; |
30 | finger[3] = OPEN; | 28 | finger[3] = OPEN; |
31 | finger[4] = OPEN; | 29 | finger[4] = OPEN; |
32 | finger[5] = OPEN; | 30 | finger[5] = OPEN; |
33 | 31 | ||
34 | tuning[0] = 0; | 32 | tuning[0] = 0; |
35 | tuning[1] = 0; | 33 | tuning[1] = 0; |
36 | tuning[2] = 0; | 34 | tuning[2] = 0; |
37 | tuning[3] = 0; | 35 | tuning[3] = 0; |
38 | tuning[4] = 0; | 36 | tuning[4] = 0; |
39 | tuning[5] = 0; | 37 | tuning[5] = 0; |
40 | 38 | ||
41 | initial_fret = 0; | 39 | initial_fret = 0; |
42 | 40 | ||
43 | audio_fd = -1; | 41 | audio_fd = -1; |
44 | 42 | ||
45 | pb_rate0 = 0; | 43 | pb_rate0 = 0; |
46 | pb_rate1 = 0; | 44 | pb_rate1 = 0; |
47 | pb_rate2 = 0; | 45 | pb_rate2 = 0; |
48 | pb_rate3 = 0; | 46 | pb_rate3 = 0; |
49 | pb_rate4 = 0; | 47 | pb_rate4 = 0; |
50 | pb_rate5 = 0; | 48 | pb_rate5 = 0; |
51 | pb_rate6 = 0; | 49 | pb_rate6 = 0; |
52 | 50 | ||
53 | pb_oct0 = 0; | 51 | pb_oct0 = 0; |
54 | pb_oct1 = 0; | 52 | pb_oct1 = 0; |
55 | pb_oct2 = 0; | 53 | pb_oct2 = 0; |
56 | pb_oct3 = 0; | 54 | pb_oct3 = 0; |
57 | pb_oct4 = 0; | 55 | pb_oct4 = 0; |
58 | pb_oct5 = 0; | 56 | pb_oct5 = 0; |
59 | pb_oct6 = 0; | 57 | pb_oct6 = 0; |
60 | 58 | ||
61 | // initialise reverb buffer | 59 | // initialise reverb buffer |
62 | reverb = (signed short *)malloc(1024 * sizeof(signed short)); | 60 | reverb = (signed short *)malloc(1024 * sizeof(signed short)); |
63 | 61 | ||
64 | for (reverb_ptr=0;reverb_ptr<1024;reverb_ptr++){ | 62 | for (reverb_ptr=0;reverb_ptr<1024;reverb_ptr++){ |
65 | reverb[reverb_ptr] = 0; | 63 | reverb[reverb_ptr] = 0; |
66 | } | 64 | } |
67 | reverb_ptr = 0; | 65 | reverb_ptr = 0; |
68 | reverb_max = 1024; | 66 | reverb_max = 1024; |
69 | 67 | ||
70 | // load sampled 'E' string | 68 | // load sampled 'E' string |
71 | int samplen = 25000; | 69 | int samplen = 25000; |
72 | 70 | ||
73 | signed short *dsp_buf = (signed short *)malloc(samplen * sizeof(signed short)); | 71 | signed short *dsp_buf = (signed short *)malloc(samplen * sizeof(signed short)); |
74 | signed short *dsp_buf_ptr = dsp_buf; | 72 | signed short *dsp_buf_ptr = dsp_buf; |
75 | 73 | ||
76 | int raw_fd; | 74 | int raw_fd; |
77 | 75 | ||
78 | QString path = getenv( "OPIEDIR" ); | 76 | QString path = getenv( "OPIEDIR" ); |
79 | path.append( "/share/powerchord/acguitar.raw" ); | 77 | path.append( "/share/powerchord/acguitar.raw" ); |
80 | 78 | ||
81 | raw_fd = open( (const char*) path, O_RDONLY); | 79 | raw_fd = open( (const char*) path, O_RDONLY); |
82 | 80 | ||
83 | if (raw_fd < 0){ | 81 | if (raw_fd < 0){ |
84 | fprintf(stderr, "Failed to open raw file (%s)\n", strerror(errno)); | 82 | fprintf(stderr, "Failed to open raw file (%s)\n", strerror(errno)); |
85 | exit(-1); | 83 | exit(-1); |
86 | } | 84 | } |
87 | 85 | ||
88 | int totread = 0; | 86 | int totread = 0; |
89 | int i; | 87 | int i; |
90 | 88 | ||
91 | while (totread < samplen*2){ | 89 | while (totread < samplen*2){ |
92 | int want = samplen*2 - totread; | 90 | int want = samplen*2 - totread; |
93 | 91 | ||
94 | int numread = read(raw_fd, dsp_buf_ptr, want); | 92 | int numread = read(raw_fd, dsp_buf_ptr, want); |
95 | fprintf(stderr, "read %d bytes\n", numread); | 93 | fprintf(stderr, "read %d bytes\n", numread); |
96 | totread += numread; | 94 | totread += numread; |
97 | dsp_buf_ptr += numread/2; | 95 | dsp_buf_ptr += numread/2; |
98 | 96 | ||
99 | if (numread == 0){ | 97 | if (numread == 0){ |
100 | fprintf(stderr, "failed to read bytes\n"); | 98 | fprintf(stderr, "failed to read bytes\n"); |
101 | exit(-1); | 99 | exit(-1); |
102 | } | 100 | } |
103 | } | 101 | } |
104 | 102 | ||
105 | close(raw_fd); | 103 | close(raw_fd); |
106 | 104 | ||
107 | // scale down a bit for mixing | 105 | // scale down a bit for mixing |
108 | for (i=0;i<samplen;i++){ | 106 | for (i=0;i<samplen;i++){ |
109 | dsp_buf[i] /= 6; | 107 | dsp_buf[i] /= 6; |
110 | } | 108 | } |
111 | 109 | ||
112 | set_tonebank(0, dsp_buf, samplen); | 110 | set_tonebank(0, dsp_buf, samplen); |
113 | set_tonebank(1, dsp_buf, samplen); | 111 | set_tonebank(1, dsp_buf, samplen); |
114 | set_tonebank(2, dsp_buf, samplen); | 112 | set_tonebank(2, dsp_buf, samplen); |
115 | set_tonebank(3, dsp_buf, samplen); | 113 | set_tonebank(3, dsp_buf, samplen); |
116 | set_tonebank(4, dsp_buf, samplen); | 114 | set_tonebank(4, dsp_buf, samplen); |
117 | set_tonebank(5, dsp_buf, samplen); | 115 | set_tonebank(5, dsp_buf, samplen); |
118 | set_tonebank(6, dsp_buf, samplen); | 116 | set_tonebank(6, dsp_buf, samplen); |
119 | 117 | ||
120 | } | 118 | } |
121 | 119 | ||
122 | void gs::set_tonebank(int tb, signed short *buf, int length) | 120 | void gs::set_tonebank(int tb, signed short *buf, int length) |
123 | { | 121 | { |
124 | switch(tb){ | 122 | switch(tb){ |
125 | case 0: | 123 | case 0: |
126 | tonebank0 = buf; | 124 | tonebank0 = buf; |
127 | tonebank_length0 = length; | 125 | tonebank_length0 = length; |
128 | break; | 126 | break; |
129 | case 1: | 127 | case 1: |
130 | tonebank1 = buf; | 128 | tonebank1 = buf; |
131 | tonebank_length1 = length; | 129 | tonebank_length1 = length; |
132 | break; | 130 | break; |
133 | case 2: | 131 | case 2: |
134 | tonebank2 = buf; | 132 | tonebank2 = buf; |
135 | tonebank_length2 = length; | 133 | tonebank_length2 = length; |
136 | break; | 134 | break; |
137 | case 3: | 135 | case 3: |
138 | tonebank3 = buf; | 136 | tonebank3 = buf; |
139 | tonebank_length3 = length; | 137 | tonebank_length3 = length; |
140 | break; | 138 | break; |
141 | case 4: | 139 | case 4: |
142 | tonebank4 = buf; | 140 | tonebank4 = buf; |
143 | tonebank_length4 = length; | 141 | tonebank_length4 = length; |
144 | break; | 142 | break; |
145 | case 5: | 143 | case 5: |
146 | tonebank5 = buf; | 144 | tonebank5 = buf; |
147 | tonebank_length5 = length; | 145 | tonebank_length5 = length; |
148 | break; | 146 | break; |
149 | case 6: | 147 | case 6: |
150 | tonebank6 = buf; | 148 | tonebank6 = buf; |
151 | tonebank_length6 = length; | 149 | tonebank_length6 = length; |
152 | break; | 150 | break; |
153 | 151 | ||
154 | } | 152 | } |
155 | } | 153 | } |
156 | 154 | ||
157 | 155 | ||
158 | void gs::Finger(int f, int position){ | 156 | void gs::Finger(int f, int position){ |
159 | if (f < 0 || f > 5){ | 157 | if (f < 0 || f > 5){ |
160 | fprintf(stderr, "Error - finger2 value was %d\n", f); | 158 | fprintf(stderr, "Error - finger2 value was %d\n", f); |
161 | return; | 159 | return; |
162 | } | 160 | } |
163 | 161 | ||
164 | finger[f] = position; | 162 | finger[f] = position; |
165 | } | 163 | } |
166 | 164 | ||
167 | void gs::Tuning(int t[6]){ | 165 | void gs::Tuning(int t[6]){ |
168 | for (int i=0;i<6;i++){ | 166 | for (int i=0;i<6;i++){ |
169 | tuning[i] = t[i]; | 167 | tuning[i] = t[i]; |
170 | } | 168 | } |
171 | } | 169 | } |
172 | 170 | ||
173 | // length in ps (seconds x 10^-9) of the period of a note. | 171 | // length in ps (seconds x 10^-9) of the period of a note. |
174 | // we use these as ratios in a breshenham-like algorithm to | 172 | // we use these as ratios in a breshenham-like algorithm to |
175 | // scale a deep note to a higher pitch | 173 | // scale a deep note to a higher pitch |
176 | // They are derived from f(A) = 440Hz and multiply each successive | 174 | // They are derived from f(A) = 440Hz and multiply each successive |
177 | // semitone by the 12th root of 2 (such that after 12 multiplications for | 175 | // semitone by the 12th root of 2 (such that after 12 multiplications for |
178 | // 12 semitones you have a note exactly 2x the frequency of the initial one, | 176 | // 12 semitones you have a note exactly 2x the frequency of the initial one, |
179 | // - an octave higher in other words.) | 177 | // - an octave higher in other words.) |
180 | 178 | ||
181 | int gs::note_periods[12] = { | 179 | int gs::note_periods[12] = { |
182 | 90703, | 180 | 90703, |
183 | 85612, | 181 | 85612, |
184 | 80802, | 182 | 80802, |
185 | 76272, | 183 | 76272, |
186 | 71991, | 184 | 71991, |
187 | 67950, | 185 | 67950, |
188 | 64137, | 186 | 64137, |
189 | 60537, | 187 | 60537, |
190 | 57139, | 188 | 57139, |
191 | 53932, | 189 | 53932, |
192 | 50905, | 190 | 50905, |
193 | 48048 | 191 | 48048 |
194 | }; | 192 | }; |
195 | 193 | ||
196 | int gs::octave_step[6] = { | 194 | int gs::octave_step[6] = { |
197 | 1, | 195 | 1, |
198 | 2, | 196 | 2, |
199 | 4, | 197 | 4, |
200 | 8, | 198 | 8, |
201 | 16, | 199 | 16, |
202 | 32 | 200 | 32 |
203 | }; | 201 | }; |
204 | 202 | ||
205 | int gs::Play(){ | 203 | int gs::Play(){ |
206 | int format; | 204 | int format; |
207 | int channels; | 205 | int channels; |
208 | int speed; | 206 | int speed; |
209 | 207 | ||
210 | frames = 0; | 208 | frames = 0; |
211 | 209 | ||
212 | if (audio_fd == -1){ | 210 | if (audio_fd == -1){ |
213 | if ( (audio_fd = open("/dev/dsp", O_WRONLY, 0) ) == -1){ | 211 | if ( (audio_fd = open("/dev/dsp", O_WRONLY, 0) ) == -1){ |
214 | audio_fd = -1; | 212 | audio_fd = -1; |
215 | return 1; | 213 | return 1; |
216 | } | 214 | } |
217 | 215 | ||
218 | format = AFMT_S16_NE; | 216 | format = AFMT_S16_NE; |
219 | 217 | ||
220 | if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format) == -1){ | 218 | if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format) == -1){ |
221 | fprintf(stderr, "Error SNDCTL DSP SETFMT, %s\n", strerror(errno)); | 219 | fprintf(stderr, "Error SNDCTL DSP SETFMT, %s\n", strerror(errno)); |
222 | exit(0); | 220 | exit(0); |
223 | } | 221 | } |
224 | 222 | ||
225 | channels = 1; | 223 | channels = 1; |
226 | 224 | ||
227 | if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels) == -1){ | 225 | if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &channels) == -1){ |
228 | fprintf(stderr, "Error SNDCTL DSP CHANNELS, %s\n", strerror(errno)); | 226 | fprintf(stderr, "Error SNDCTL DSP CHANNELS, %s\n", strerror(errno)); |
229 | exit(0); | 227 | exit(0); |
230 | } | 228 | } |
231 | 229 | ||
232 | speed = 11025; | 230 | speed = 11025; |
233 | 231 | ||
234 | if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed) == -1){ | 232 | if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed) == -1){ |
235 | fprintf(stderr, "Error SNDCTL DSP SPEED, %s\n", strerror(errno)); | 233 | fprintf(stderr, "Error SNDCTL DSP SPEED, %s\n", strerror(errno)); |
236 | exit(0); | 234 | exit(0); |
237 | } | 235 | } |
238 | 236 | ||
239 | // buffering q's | 237 | // buffering q's |
240 | //audio_buf_info info; | 238 | //audio_buf_info info; |
241 | //if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1){ | 239 | //if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1){ |
242 | // fprintf(stderr, "Error SNDCTL DSP GETOSPACE, %s\n", strerror(errno)); | 240 | // fprintf(stderr, "Error SNDCTL DSP GETOSPACE, %s\n", strerror(errno)); |
243 | // exit(0); | 241 | // exit(0); |
244 | //} | 242 | //} |
245 | //fprintf(stderr, "fragments %d\nfragstotal %d\nfragsize %d\nbytes %d\n", info.fragments, info.fragstotal, info.fragsize, info.bytes); | 243 | //fprintf(stderr, "fragments %d\nfragstotal %d\nfragsize %d\nbytes %d\n", info.fragments, info.fragstotal, info.fragsize, info.bytes); |
246 | 244 | ||
247 | 245 | ||
248 | 246 | ||
249 | // audio math. | 247 | // audio math. |
250 | // A4 = 440Hz | 248 | // A4 = 440Hz |
251 | // +1 octave = 2x freq | 249 | // +1 octave = 2x freq |
252 | // -1 octave = /2 freq. | 250 | // -1 octave = /2 freq. |
253 | // +1 semitone = *= 12 root 2; | 251 | // +1 semitone = *= 12 root 2; |
254 | // ie. * 1.059463094 | 252 | // ie. * 1.059463094 |
255 | 253 | ||
256 | // tones, approx Hz, samples at 11025 | 254 | // tones, approx Hz, samples at 11025 |
257 | // A4 440 25 | 255 | // A4 440 25 |
258 | // A#4 466 24 | 256 | // A#4 466 24 |
259 | // B4 494 22 | 257 | // B4 494 22 |
260 | // C4 523 21 | 258 | // C4 523 21 |
261 | // C#4 554 20 | 259 | // C#4 554 20 |
262 | // D4 587 19 | 260 | // D4 587 19 |
263 | // D#4 622 18 | 261 | // D#4 622 18 |
264 | // E4 659 17 | 262 | // E4 659 17 |
265 | // F4 698 16 | 263 | // F4 698 16 |
266 | // F#4 740 15 | 264 | // F#4 740 15 |
267 | // G4 784 14 | 265 | // G4 784 14 |
268 | // G#4 831 13 | 266 | // G#4 831 13 |
269 | 267 | ||
270 | 268 | ||
271 | } | 269 | } |
272 | else{ | 270 | else{ |
273 | fprintf(stderr, "Already playing\n"); | 271 | fprintf(stderr, "Already playing\n"); |
274 | } | 272 | } |
275 | 273 | ||
276 | return 0; | 274 | return 0; |
277 | } | 275 | } |
278 | 276 | ||
279 | void gs::note_start(int chan, int note, int octave) | 277 | void gs::note_start(int chan, int note, int octave) |
280 | { | 278 | { |
281 | switch (chan){ | 279 | switch (chan){ |
282 | 280 | ||
283 | case 0: | 281 | case 0: |
284 | pb_rate0 = note_periods[note]; | 282 | pb_rate0 = note_periods[note]; |
285 | pb_oct0 = octave_step[octave]; | 283 | pb_oct0 = octave_step[octave]; |
286 | pb_ratio0 = 0; | 284 | pb_ratio0 = 0; |
287 | pb_rsc0 = 0; | 285 | pb_rsc0 = 0; |
288 | break; | 286 | break; |
289 | case 1: | 287 | case 1: |
290 | pb_rate1 = note_periods[note]; | 288 | pb_rate1 = note_periods[note]; |
291 | pb_oct1 = octave_step[octave]; | 289 | pb_oct1 = octave_step[octave]; |
292 | pb_ratio1 = 0; | 290 | pb_ratio1 = 0; |
293 | pb_rsc1 = 0; | 291 | pb_rsc1 = 0; |
294 | break; | 292 | break; |
295 | case 2: | 293 | case 2: |
296 | pb_rate2 = note_periods[note]; | 294 | pb_rate2 = note_periods[note]; |
297 | pb_oct2 = octave_step[octave]; | 295 | pb_oct2 = octave_step[octave]; |
298 | pb_ratio2 = 0; | 296 | pb_ratio2 = 0; |
299 | pb_rsc2 = 0; | 297 | pb_rsc2 = 0; |
300 | break; | 298 | break; |
301 | case 3: | 299 | case 3: |
302 | pb_rate3 = note_periods[note]; | 300 | pb_rate3 = note_periods[note]; |
303 | pb_oct3 = octave_step[octave]; | 301 | pb_oct3 = octave_step[octave]; |
304 | pb_ratio3 = 0; | 302 | pb_ratio3 = 0; |
305 | pb_rsc3 = 0; | 303 | pb_rsc3 = 0; |
306 | break; | 304 | break; |
307 | case 4: | 305 | case 4: |
308 | pb_rate4 = note_periods[note]; | 306 | pb_rate4 = note_periods[note]; |
309 | pb_oct4 = octave_step[octave]; | 307 | pb_oct4 = octave_step[octave]; |
310 | pb_ratio4 = 0; | 308 | pb_ratio4 = 0; |
311 | pb_rsc4 = 0; | 309 | pb_rsc4 = 0; |
312 | break; | 310 | break; |
313 | case 5: | 311 | case 5: |
314 | pb_rate5 = note_periods[note]; | 312 | pb_rate5 = note_periods[note]; |
315 | pb_oct5 = octave_step[octave]; | 313 | pb_oct5 = octave_step[octave]; |
316 | pb_ratio5 = 0; | 314 | pb_ratio5 = 0; |
317 | pb_rsc5 = 0; | 315 | pb_rsc5 = 0; |
318 | break; | 316 | break; |
319 | case 6: | 317 | case 6: |
320 | pb_rate6 = note_periods[note]; | 318 | pb_rate6 = note_periods[note]; |
321 | pb_oct6 = octave_step[octave]; | 319 | pb_oct6 = octave_step[octave]; |
322 | pb_ratio6 = 0; | 320 | pb_ratio6 = 0; |
323 | pb_rsc6 = 0; | 321 | pb_rsc6 = 0; |
324 | break; | 322 | break; |
325 | default: | 323 | default: |
326 | fprintf(stderr, "Bad channel\n"); | 324 | fprintf(stderr, "Bad channel\n"); |
327 | exit(-1); | 325 | exit(-1); |
328 | } | 326 | } |
329 | 327 | ||
330 | 328 | ||
331 | } | 329 | } |
332 | 330 | ||
333 | void gs::write_buffer(){ | 331 | void gs::write_buffer(){ |
334 | int num_read; | 332 | int num_read; |
335 | num_read = write(audio_fd, (void *)audio_buf, BUFSIZE*2); | 333 | num_read = write(audio_fd, (void *)audio_buf, BUFSIZE*2); |
336 | // fprintf(stderr, "Wrote %d bytes\n", num_read); | 334 | // fprintf(stderr, "Wrote %d bytes\n", num_read); |
337 | } | 335 | } |
338 | 336 | ||
339 | void gs::fill_buffer() | 337 | void gs::fill_buffer() |
340 | { | 338 | { |
341 | frames ++; | 339 | frames ++; |
342 | 340 | ||
343 | int i; | 341 | int i; |
344 | 342 | ||
345 | for (i=0;i<BUFSIZE;i++){ | 343 | for (i=0;i<BUFSIZE;i++){ |
346 | 344 | ||
347 | audio_buf[i] = 0; | 345 | audio_buf[i] = 0; |
348 | 346 | ||
349 | if (pb_rate0){ | 347 | if (pb_rate0){ |
350 | audio_buf[i] += tonebank0[pb_rsc0]; | 348 | audio_buf[i] += tonebank0[pb_rsc0]; |
351 | pb_rsc0 += pb_oct0; | 349 | pb_rsc0 += pb_oct0; |
352 | pb_ratio0 += 90703; | 350 | pb_ratio0 += 90703; |
353 | pb_ratio0 -= pb_rate0; | 351 | pb_ratio0 -= pb_rate0; |
354 | if (pb_ratio0 >= pb_rate0){ | 352 | if (pb_ratio0 >= pb_rate0){ |
355 | pb_rsc0 += pb_oct0; | 353 | pb_rsc0 += pb_oct0; |
356 | pb_ratio0 -= pb_rate0; | 354 | pb_ratio0 -= pb_rate0; |
357 | 355 | ||
358 | } | 356 | } |
359 | if (pb_rsc0 >= tonebank_length0) pb_rate0 = 0; | 357 | if (pb_rsc0 >= tonebank_length0) pb_rate0 = 0; |
360 | } | 358 | } |
361 | 359 | ||
362 | if (pb_rate1){ | 360 | if (pb_rate1){ |
363 | audio_buf[i] += tonebank1[pb_rsc1]; | 361 | audio_buf[i] += tonebank1[pb_rsc1]; |
364 | pb_rsc1 += pb_oct1; | 362 | pb_rsc1 += pb_oct1; |
365 | pb_ratio1 += 90703; | 363 | pb_ratio1 += 90703; |
366 | pb_ratio1 -= pb_rate1; | 364 | pb_ratio1 -= pb_rate1; |
367 | if (pb_ratio1 >= pb_rate1){ | 365 | if (pb_ratio1 >= pb_rate1){ |
368 | pb_rsc1 += pb_oct1; | 366 | pb_rsc1 += pb_oct1; |
369 | pb_ratio1 -= pb_rate1; | 367 | pb_ratio1 -= pb_rate1; |
370 | 368 | ||
371 | } | 369 | } |
372 | if (pb_rsc1 >= tonebank_length1) pb_rate1 = 0; | 370 | if (pb_rsc1 >= tonebank_length1) pb_rate1 = 0; |
373 | } | 371 | } |
374 | 372 | ||
375 | if (pb_rate2){ | 373 | if (pb_rate2){ |
376 | audio_buf[i] += tonebank2[pb_rsc2]; | 374 | audio_buf[i] += tonebank2[pb_rsc2]; |
377 | pb_rsc2 += pb_oct2; | 375 | pb_rsc2 += pb_oct2; |
378 | pb_ratio2 += 90703; | 376 | pb_ratio2 += 90703; |
379 | pb_ratio2 -= pb_rate2; | 377 | pb_ratio2 -= pb_rate2; |
380 | if (pb_ratio2 >= pb_rate2){ | 378 | if (pb_ratio2 >= pb_rate2){ |
381 | pb_rsc2 += pb_oct2; | 379 | pb_rsc2 += pb_oct2; |
382 | pb_ratio2 -= pb_rate2; | 380 | pb_ratio2 -= pb_rate2; |
383 | 381 | ||
384 | } | 382 | } |
385 | if (pb_rsc2 >= tonebank_length2) pb_rate2 = 0; | 383 | if (pb_rsc2 >= tonebank_length2) pb_rate2 = 0; |
386 | } | 384 | } |
387 | 385 | ||
388 | if (pb_rate3){ | 386 | if (pb_rate3){ |
389 | audio_buf[i] += tonebank3[pb_rsc3]; | 387 | audio_buf[i] += tonebank3[pb_rsc3]; |
390 | pb_rsc3 += pb_oct3; | 388 | pb_rsc3 += pb_oct3; |
391 | pb_ratio3 += 90703; | 389 | pb_ratio3 += 90703; |
392 | pb_ratio3 -= pb_rate3; | 390 | pb_ratio3 -= pb_rate3; |
393 | if (pb_ratio3 >= pb_rate3){ | 391 | if (pb_ratio3 >= pb_rate3){ |
394 | pb_rsc3 += pb_oct3; | 392 | pb_rsc3 += pb_oct3; |
395 | pb_ratio3 -= pb_rate3; | 393 | pb_ratio3 -= pb_rate3; |
396 | 394 | ||
397 | } | 395 | } |
398 | if (pb_rsc3 >= tonebank_length3) pb_rate3 = 0; | 396 | if (pb_rsc3 >= tonebank_length3) pb_rate3 = 0; |
399 | } | 397 | } |
400 | 398 | ||
401 | if (pb_rate4){ | 399 | if (pb_rate4){ |
402 | audio_buf[i] += tonebank4[pb_rsc4]; | 400 | audio_buf[i] += tonebank4[pb_rsc4]; |
403 | pb_rsc4 += pb_oct4; | 401 | pb_rsc4 += pb_oct4; |
404 | pb_ratio4 += 90703; | 402 | pb_ratio4 += 90703; |
405 | pb_ratio4 -= pb_rate4; | 403 | pb_ratio4 -= pb_rate4; |
406 | if (pb_ratio4 >= pb_rate4){ | 404 | if (pb_ratio4 >= pb_rate4){ |
407 | pb_rsc4 += pb_oct4; | 405 | pb_rsc4 += pb_oct4; |
408 | pb_ratio4 -= pb_rate4; | 406 | pb_ratio4 -= pb_rate4; |
409 | 407 | ||
410 | } | 408 | } |
411 | if (pb_rsc4 >= tonebank_length4) pb_rate4 = 0; | 409 | if (pb_rsc4 >= tonebank_length4) pb_rate4 = 0; |
412 | } | 410 | } |
413 | 411 | ||
414 | if (pb_rate5){ | 412 | if (pb_rate5){ |
415 | audio_buf[i] += tonebank5[pb_rsc5]; | 413 | audio_buf[i] += tonebank5[pb_rsc5]; |
416 | pb_rsc5 += pb_oct5; | 414 | pb_rsc5 += pb_oct5; |
417 | pb_ratio5 += 90703; | 415 | pb_ratio5 += 90703; |
418 | pb_ratio5 -= pb_rate5; | 416 | pb_ratio5 -= pb_rate5; |
419 | if (pb_ratio5 >= pb_rate5){ | 417 | if (pb_ratio5 >= pb_rate5){ |
420 | pb_rsc5 += pb_oct5; | 418 | pb_rsc5 += pb_oct5; |
421 | pb_ratio5 -= pb_rate5; | 419 | pb_ratio5 -= pb_rate5; |
422 | 420 | ||
423 | } | 421 | } |
424 | if (pb_rsc5 >= tonebank_length5) pb_rate5 = 0; | 422 | if (pb_rsc5 >= tonebank_length5) pb_rate5 = 0; |
425 | } | 423 | } |
426 | 424 | ||
427 | if (pb_rate6){ | 425 | if (pb_rate6){ |
428 | audio_buf[i] += tonebank6[pb_rsc6]; | 426 | audio_buf[i] += tonebank6[pb_rsc6]; |
429 | pb_rsc6 += pb_oct6; | 427 | pb_rsc6 += pb_oct6; |
430 | pb_ratio6 += 90703; | 428 | pb_ratio6 += 90703; |
431 | pb_ratio6 -= pb_rate6; | 429 | pb_ratio6 -= pb_rate6; |
432 | if (pb_ratio6 >= pb_rate6){ | 430 | if (pb_ratio6 >= pb_rate6){ |
433 | pb_rsc6 += pb_oct6; | 431 | pb_rsc6 += pb_oct6; |
434 | pb_ratio6 -= pb_rate6; | 432 | pb_ratio6 -= pb_rate6; |
435 | 433 | ||
436 | } | 434 | } |
437 | if (pb_rsc6 >= tonebank_length6) pb_rate6 = 0; | 435 | if (pb_rsc6 >= tonebank_length6) pb_rate6 = 0; |
438 | } | 436 | } |
439 | 437 | ||
440 | // do reverb | 438 | // do reverb |
441 | signed short rtmp = reverb[reverb_ptr]; | 439 | signed short rtmp = reverb[reverb_ptr]; |
442 | reverb[reverb_ptr] /= 2; | 440 | reverb[reverb_ptr] /= 2; |
443 | reverb[reverb_ptr] += audio_buf[i]/4; | 441 | reverb[reverb_ptr] += audio_buf[i]/4; |
444 | audio_buf[i] += rtmp; | 442 | audio_buf[i] += rtmp; |
445 | reverb_ptr++; | 443 | reverb_ptr++; |
446 | if (reverb_ptr >= reverb_max) reverb_ptr = 0; | 444 | if (reverb_ptr >= reverb_max) reverb_ptr = 0; |
447 | } | 445 | } |
448 | } | 446 | } |
449 | 447 | ||
450 | 448 | ||
451 | void gs::Stop(){ | 449 | void gs::Stop(){ |
452 | if (audio_fd == -1){ | 450 | if (audio_fd == -1){ |
453 | fprintf(stderr, "Already stopped\n"); | 451 | fprintf(stderr, "Already stopped\n"); |
454 | } | 452 | } |
455 | else{ | 453 | else{ |
456 | //ioctl(audio_fd, SNDCTL_DSP_RESET, 0); | 454 | //ioctl(audio_fd, SNDCTL_DSP_RESET, 0); |
457 | 455 | ||
458 | close(audio_fd); | 456 | close(audio_fd); |
459 | audio_fd = -1; | 457 | audio_fd = -1; |
460 | } | 458 | } |
461 | 459 | ||
462 | } | 460 | } |
463 | 461 | ||
464 | gs::~gs() | 462 | gs::~gs() |
465 | {} | 463 | {} |
diff --git a/noncore/multimedia/powerchord/powerchord.cpp b/noncore/multimedia/powerchord/powerchord.cpp index 79a26ea..31d517b 100644 --- a/noncore/multimedia/powerchord/powerchord.cpp +++ b/noncore/multimedia/powerchord/powerchord.cpp | |||
@@ -1,28 +1,27 @@ | |||
1 | #include "powerchord.h" | 1 | #include "powerchord.h" |
2 | #include <qpushbutton.h> | ||
3 | 2 | ||
4 | /* | 3 | /* |
5 | * Constructs a Example which is a child of 'parent', with the | 4 | * Constructs a Example which is a child of 'parent', with the |
6 | * name 'name' and widget flags set to 'f' | 5 | * name 'name' and widget flags set to 'f' |
7 | */ | 6 | */ |
8 | Powerchord::Powerchord( QWidget* parent, const char* name, WFlags fl ) | 7 | Powerchord::Powerchord( QWidget* parent, const char* name, WFlags fl ) |
9 | : PowerchordBase( parent, name, fl ) | 8 | : PowerchordBase( parent, name, fl ) |
10 | { | 9 | { |
11 | // connect(quit, SIGNAL(clicked), this, SLOT(goodBye())); | 10 | // connect(quit, SIGNAL(clicked), this, SLOT(goodBye())); |
12 | } | 11 | } |
13 | 12 | ||
14 | /* | 13 | /* |
15 | * Destroys the object and frees any allocated resources | 14 | * Destroys the object and frees any allocated resources |
16 | */ | 15 | */ |
17 | Powerchord::~Powerchord() | 16 | Powerchord::~Powerchord() |
18 | { | 17 | { |
19 | // no need to delete child widgets, Qt does it all for us | 18 | // no need to delete child widgets, Qt does it all for us |
20 | } | 19 | } |
21 | 20 | ||
22 | /* | 21 | /* |
23 | * A simple slot... not very interesting. | 22 | * A simple slot... not very interesting. |
24 | */ | 23 | */ |
25 | void Powerchord::goodBye() | 24 | void Powerchord::goodBye() |
26 | { | 25 | { |
27 | close(); | 26 | close(); |
28 | } | 27 | } |
diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp index 7978426..4fb5dda 100644 --- a/noncore/multimedia/powerchord/powerchordbase.cpp +++ b/noncore/multimedia/powerchord/powerchordbase.cpp | |||
@@ -1,592 +1,585 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'powerchordbase.ui' | 2 | ** Form implementation generated from reading ui file 'powerchordbase.ui' |
3 | ** | 3 | ** |
4 | ** Created: Sun Jan 13 23:05:11 2002 | 4 | ** Created: Sun Jan 13 23:05:11 2002 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "powerchordbase.h" | 9 | #include "powerchordbase.h" |
10 | 10 | ||
11 | #include "fretboard.h" | 11 | #include "fretboard.h" |
12 | #include "vumeter.h" | 12 | #include "vumeter.h" |
13 | #include "gs.h" | ||
14 | #include <qcombobox.h> | 13 | #include <qcombobox.h> |
15 | #include <qframe.h> | ||
16 | #include <qlabel.h> | 14 | #include <qlabel.h> |
17 | #include <qlistbox.h> | 15 | #include <qlistbox.h> |
18 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
19 | #include <qspinbox.h> | 17 | #include <qspinbox.h> |
20 | #include <qtabwidget.h> | 18 | #include <qtabwidget.h> |
21 | #include <qlayout.h> | 19 | #include <qlayout.h> |
22 | #include <qvariant.h> | ||
23 | #include <qtooltip.h> | 20 | #include <qtooltip.h> |
24 | #include <qwhatsthis.h> | ||
25 | #include <qimage.h> | ||
26 | #include <qpixmap.h> | ||
27 | #include <qbitmap.h> | ||
28 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
29 | 22 | ||
30 | 23 | ||
31 | /* | 24 | /* |
32 | * Constructs a PowerchordBase which is a child of 'parent', with the | 25 | * Constructs a PowerchordBase which is a child of 'parent', with the |
33 | * name 'name' and widget flags set to 'f' | 26 | * name 'name' and widget flags set to 'f' |
34 | */ | 27 | */ |
35 | PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) | 28 | PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) |
36 | : QWidget( parent, name, fl ) | 29 | : QWidget( parent, name, fl ) |
37 | { | 30 | { |
38 | simulation_timer = 0; | 31 | simulation_timer = 0; |
39 | audio_timer = 0; | 32 | audio_timer = 0; |
40 | 33 | ||
41 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); | 34 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); |
42 | 35 | ||
43 | // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); | 36 | // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); |
44 | QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); | 37 | QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); |
45 | QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); | 38 | QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); |
46 | QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); | 39 | QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); |
47 | QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); | 40 | QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); |
48 | QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); | 41 | QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); |
49 | image6 = Resource::loadPixmap( "powerchord/image6"); | 42 | image6 = Resource::loadPixmap( "powerchord/image6"); |
50 | image_open = Resource::loadPixmap( "powerchord/image_open"); | 43 | image_open = Resource::loadPixmap( "powerchord/image_open"); |
51 | 44 | ||
52 | // image0.setMask(image0.createHeuristicMask()); | 45 | // image0.setMask(image0.createHeuristicMask()); |
53 | image1.setMask(image1.createHeuristicMask()); | 46 | image1.setMask(image1.createHeuristicMask()); |
54 | // image2.setMask(image2.createHeuristicMask()); | 47 | // image2.setMask(image2.createHeuristicMask()); |
55 | // image3.setMask(image3.createHeuristicMask()); | 48 | // image3.setMask(image3.createHeuristicMask()); |
56 | // image4.setMask(image4.createHeuristicMask()); | 49 | // image4.setMask(image4.createHeuristicMask()); |
57 | // image5.setMask(image5.createHeuristicMask()); | 50 | // image5.setMask(image5.createHeuristicMask()); |
58 | // image6->setMask(image6->createHeuristicMask()); | 51 | // image6->setMask(image6->createHeuristicMask()); |
59 | // image_open->setMask(image_open->createHeuristicMask()); | 52 | // image_open->setMask(image_open->createHeuristicMask()); |
60 | 53 | ||
61 | if ( !name ) | 54 | if ( !name ) |
62 | setName( "PowerchordBase" ); | 55 | setName( "PowerchordBase" ); |
63 | resize( 240, 284 ); | 56 | resize( 240, 284 ); |
64 | setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); | 57 | setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); |
65 | setMinimumSize( QSize( 240, 284 ) ); | 58 | setMinimumSize( QSize( 240, 284 ) ); |
66 | setMaximumSize( QSize( 240, 284 ) ); | 59 | setMaximumSize( QSize( 240, 284 ) ); |
67 | setCaption( tr( "Powerchord" ) ); | 60 | setCaption( tr( "Powerchord" ) ); |
68 | 61 | ||
69 | tabs = new QTabWidget( this, "tabs" ); | 62 | tabs = new QTabWidget( this, "tabs" ); |
70 | tabs->setEnabled( TRUE ); | 63 | tabs->setEnabled( TRUE ); |
71 | tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); | 64 | tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); |
72 | tabs->setTabPosition( QTabWidget::Bottom ); | 65 | tabs->setTabPosition( QTabWidget::Bottom ); |
73 | 66 | ||
74 | tab = new QWidget( tabs, "tab" ); | 67 | tab = new QWidget( tabs, "tab" ); |
75 | 68 | ||
76 | chordkey = new QComboBox( FALSE, tab, "chordkey" ); | 69 | chordkey = new QComboBox( FALSE, tab, "chordkey" ); |
77 | chordkey->insertItem( tr( "maj" ) ); | 70 | chordkey->insertItem( tr( "maj" ) ); |
78 | chordkey->insertItem( tr( "min" ) ); | 71 | chordkey->insertItem( tr( "min" ) ); |
79 | chordkey->insertItem( tr( "7th" ) ); | 72 | chordkey->insertItem( tr( "7th" ) ); |
80 | chordkey->insertItem( tr( "m7" ) ); | 73 | chordkey->insertItem( tr( "m7" ) ); |
81 | chordkey->insertItem( tr( "maj7" ) ); | 74 | chordkey->insertItem( tr( "maj7" ) ); |
82 | chordkey->insertItem( tr( "6th" ) ); | 75 | chordkey->insertItem( tr( "6th" ) ); |
83 | chordkey->insertItem( tr( "m6th" ) ); | 76 | chordkey->insertItem( tr( "m6th" ) ); |
84 | chordkey->insertItem( tr( "aug" ) ); | 77 | chordkey->insertItem( tr( "aug" ) ); |
85 | chordkey->insertItem( tr( "dim" ) ); | 78 | chordkey->insertItem( tr( "dim" ) ); |
86 | chordkey->insertItem( tr( "sus4" ) ); | 79 | chordkey->insertItem( tr( "sus4" ) ); |
87 | chordkey->insertItem( tr( "7sus4" ) ); | 80 | chordkey->insertItem( tr( "7sus4" ) ); |
88 | chordkey->insertItem( tr( "9th" ) ); | 81 | chordkey->insertItem( tr( "9th" ) ); |
89 | chordkey->insertItem( tr( "add9" ) ); | 82 | chordkey->insertItem( tr( "add9" ) ); |
90 | chordkey->insertItem( tr( "m9th" ) ); | 83 | chordkey->insertItem( tr( "m9th" ) ); |
91 | chordkey->insertItem( tr( "maj9" ) ); | 84 | chordkey->insertItem( tr( "maj9" ) ); |
92 | chordkey->insertItem( tr( "sus2" ) ); | 85 | chordkey->insertItem( tr( "sus2" ) ); |
93 | chordkey->insertItem( tr( "7sus2" ) ); | 86 | chordkey->insertItem( tr( "7sus2" ) ); |
94 | chordkey->insertItem( tr( "11th" ) ); | 87 | chordkey->insertItem( tr( "11th" ) ); |
95 | chordkey->insertItem( tr( "m11th" ) ); | 88 | chordkey->insertItem( tr( "m11th" ) ); |
96 | chordkey->insertItem( tr( "13th" ) ); | 89 | chordkey->insertItem( tr( "13th" ) ); |
97 | chordkey->insertItem( tr( "m13th" ) ); | 90 | chordkey->insertItem( tr( "m13th" ) ); |
98 | chordkey->insertItem( tr( "maj13" ) ); | 91 | chordkey->insertItem( tr( "maj13" ) ); |
99 | chordkey->insertItem( tr( "6/9" ) ); | 92 | chordkey->insertItem( tr( "6/9" ) ); |
100 | chordkey->insertItem( tr( "flat5" ) ); | 93 | chordkey->insertItem( tr( "flat5" ) ); |
101 | chordkey->insertItem( tr( "7#9" ) ); | 94 | chordkey->insertItem( tr( "7#9" ) ); |
102 | chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); | 95 | chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); |
103 | chordkey->insertItem( tr( "5" ) ); | 96 | chordkey->insertItem( tr( "5" ) ); |
104 | chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); | 97 | chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); |
105 | 98 | ||
106 | chordfret = new QComboBox( FALSE, tab, "chordfret" ); | 99 | chordfret = new QComboBox( FALSE, tab, "chordfret" ); |
107 | chordfret->insertItem( tr( "open" ) ); | 100 | chordfret->insertItem( tr( "open" ) ); |
108 | chordfret->insertItem( tr( "1st" ) ); | 101 | chordfret->insertItem( tr( "1st" ) ); |
109 | chordfret->insertItem( tr( "2nd" ) ); | 102 | chordfret->insertItem( tr( "2nd" ) ); |
110 | chordfret->insertItem( tr( "3rd" ) ); | 103 | chordfret->insertItem( tr( "3rd" ) ); |
111 | chordfret->insertItem( tr( "4th" ) ); | 104 | chordfret->insertItem( tr( "4th" ) ); |
112 | chordfret->insertItem( tr( "5th" ) ); | 105 | chordfret->insertItem( tr( "5th" ) ); |
113 | chordfret->insertItem( tr( "6th" ) ); | 106 | chordfret->insertItem( tr( "6th" ) ); |
114 | chordfret->insertItem( tr( "7th" ) ); | 107 | chordfret->insertItem( tr( "7th" ) ); |
115 | chordfret->insertItem( tr( "8th" ) ); | 108 | chordfret->insertItem( tr( "8th" ) ); |
116 | chordfret->insertItem( tr( "9th" ) ); | 109 | chordfret->insertItem( tr( "9th" ) ); |
117 | chordfret->insertItem( tr( "10th" ) ); | 110 | chordfret->insertItem( tr( "10th" ) ); |
118 | chordfret->insertItem( tr( "11th" ) ); | 111 | chordfret->insertItem( tr( "11th" ) ); |
119 | chordfret->insertItem( tr( "12th" ) ); | 112 | chordfret->insertItem( tr( "12th" ) ); |
120 | chordfret->insertItem( tr( "13th" ) ); | 113 | chordfret->insertItem( tr( "13th" ) ); |
121 | chordfret->insertItem( tr( "14th" ) ); | 114 | chordfret->insertItem( tr( "14th" ) ); |
122 | chordfret->insertItem( tr( "15th" ) ); | 115 | chordfret->insertItem( tr( "15th" ) ); |
123 | chordfret->insertItem( tr( "16th" ) ); | 116 | chordfret->insertItem( tr( "16th" ) ); |
124 | chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width | 117 | chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width |
125 | 118 | ||
126 | chordnote = new QComboBox( FALSE, tab, "chordnote" ); | 119 | chordnote = new QComboBox( FALSE, tab, "chordnote" ); |
127 | chordnote->insertItem( tr( "C" ) ); | 120 | chordnote->insertItem( tr( "C" ) ); |
128 | chordnote->insertItem( tr( "C#" ) ); | 121 | chordnote->insertItem( tr( "C#" ) ); |
129 | chordnote->insertItem( tr( "D" ) ); | 122 | chordnote->insertItem( tr( "D" ) ); |
130 | chordnote->insertItem( tr( "Eb" ) ); | 123 | chordnote->insertItem( tr( "Eb" ) ); |
131 | chordnote->insertItem( tr( "E" ) ); | 124 | chordnote->insertItem( tr( "E" ) ); |
132 | chordnote->insertItem( tr( "F" ) ); | 125 | chordnote->insertItem( tr( "F" ) ); |
133 | chordnote->insertItem( tr( "F#" ) ); | 126 | chordnote->insertItem( tr( "F#" ) ); |
134 | chordnote->insertItem( tr( "G" ) ); | 127 | chordnote->insertItem( tr( "G" ) ); |
135 | chordnote->insertItem( tr( "G#" ) ); | 128 | chordnote->insertItem( tr( "G#" ) ); |
136 | chordnote->insertItem( tr( "A" ) ); | 129 | chordnote->insertItem( tr( "A" ) ); |
137 | chordnote->insertItem( tr( "Bb" ) ); | 130 | chordnote->insertItem( tr( "Bb" ) ); |
138 | chordnote->insertItem( tr( "B" ) ); | 131 | chordnote->insertItem( tr( "B" ) ); |
139 | chordnote->setGeometry( QRect( 0, 0, 40, 21 ) ); | 132 | chordnote->setGeometry( QRect( 0, 0, 40, 21 ) ); |
140 | chordnote->setCurrentItem( 9 ); | 133 | chordnote->setCurrentItem( 9 ); |
141 | 134 | ||
142 | QWidget* privateLayoutWidget = new QWidget( tab, "Layout1" ); | 135 | QWidget* privateLayoutWidget = new QWidget( tab, "Layout1" ); |
143 | privateLayoutWidget->setGeometry( QRect( 5, 232, 160, 20 ) ); | 136 | privateLayoutWidget->setGeometry( QRect( 5, 232, 160, 20 ) ); |
144 | Layout1 = new QHBoxLayout( privateLayoutWidget ); | 137 | Layout1 = new QHBoxLayout( privateLayoutWidget ); |
145 | Layout1->setSpacing( 6 ); | 138 | Layout1->setSpacing( 6 ); |
146 | Layout1->setMargin( 0 ); | 139 | Layout1->setMargin( 0 ); |
147 | 140 | ||
148 | s1_1 = new QLabel( privateLayoutWidget, "s1_1" ); | 141 | s1_1 = new QLabel( privateLayoutWidget, "s1_1" ); |
149 | s1_1->setText( tr( "E" ) ); | 142 | s1_1->setText( tr( "E" ) ); |
150 | s1_1->setAlignment( int( QLabel::AlignCenter ) ); | 143 | s1_1->setAlignment( int( QLabel::AlignCenter ) ); |
151 | Layout1->addWidget( s1_1 ); | 144 | Layout1->addWidget( s1_1 ); |
152 | 145 | ||
153 | s1_2 = new QLabel( privateLayoutWidget, "s1_2" ); | 146 | s1_2 = new QLabel( privateLayoutWidget, "s1_2" ); |
154 | s1_2->setText( tr( "A" ) ); | 147 | s1_2->setText( tr( "A" ) ); |
155 | s1_2->setAlignment( int( QLabel::AlignCenter ) ); | 148 | s1_2->setAlignment( int( QLabel::AlignCenter ) ); |
156 | Layout1->addWidget( s1_2 ); | 149 | Layout1->addWidget( s1_2 ); |
157 | 150 | ||
158 | s1_3 = new QLabel( privateLayoutWidget, "s1_3" ); | 151 | s1_3 = new QLabel( privateLayoutWidget, "s1_3" ); |
159 | s1_3->setText( tr( "E" ) ); | 152 | s1_3->setText( tr( "E" ) ); |
160 | s1_3->setAlignment( int( QLabel::AlignCenter ) ); | 153 | s1_3->setAlignment( int( QLabel::AlignCenter ) ); |
161 | Layout1->addWidget( s1_3 ); | 154 | Layout1->addWidget( s1_3 ); |
162 | 155 | ||
163 | s1_4 = new QLabel( privateLayoutWidget, "s1_4" ); | 156 | s1_4 = new QLabel( privateLayoutWidget, "s1_4" ); |
164 | s1_4->setText( tr( "A" ) ); | 157 | s1_4->setText( tr( "A" ) ); |
165 | s1_4->setAlignment( int( QLabel::AlignCenter ) ); | 158 | s1_4->setAlignment( int( QLabel::AlignCenter ) ); |
166 | Layout1->addWidget( s1_4 ); | 159 | Layout1->addWidget( s1_4 ); |
167 | 160 | ||
168 | s1_5 = new QLabel( privateLayoutWidget, "s1_5" ); | 161 | s1_5 = new QLabel( privateLayoutWidget, "s1_5" ); |
169 | s1_5->setText( tr( "C#" ) ); | 162 | s1_5->setText( tr( "C#" ) ); |
170 | s1_5->setAlignment( int( QLabel::AlignCenter ) ); | 163 | s1_5->setAlignment( int( QLabel::AlignCenter ) ); |
171 | Layout1->addWidget( s1_5 ); | 164 | Layout1->addWidget( s1_5 ); |
172 | 165 | ||
173 | s1_6 = new QLabel( privateLayoutWidget, "s1_6" ); | 166 | s1_6 = new QLabel( privateLayoutWidget, "s1_6" ); |
174 | s1_6->setText( tr( "E" ) ); | 167 | s1_6->setText( tr( "E" ) ); |
175 | s1_6->setAlignment( int( QLabel::AlignCenter ) ); | 168 | s1_6->setAlignment( int( QLabel::AlignCenter ) ); |
176 | Layout1->addWidget( s1_6 ); | 169 | Layout1->addWidget( s1_6 ); |
177 | 170 | ||
178 | // sound_label = new QLabel( tab, "sound_label" ); | 171 | // sound_label = new QLabel( tab, "sound_label" ); |
179 | // sound_label->setGeometry( QRect( 185, 160, 32, 17 ) ); | 172 | // sound_label->setGeometry( QRect( 185, 160, 32, 17 ) ); |
180 | // sound_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sound_label->sizePolicy().hasHeightForWidth() ) ); | 173 | // sound_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sound_label->sizePolicy().hasHeightForWidth() ) ); |
181 | // sound_label->setPixmap( image0 ); | 174 | // sound_label->setPixmap( image0 ); |
182 | // sound_label->pixmap()->setMask(*image0.mask()); | 175 | // sound_label->pixmap()->setMask(*image0.mask()); |
183 | // sound_label->setScaledContents( TRUE ); | 176 | // sound_label->setScaledContents( TRUE ); |
184 | // sound_label->setBackgroundMode( QWidget::PaletteButton ); | 177 | // sound_label->setBackgroundMode( QWidget::PaletteButton ); |
185 | // sound_label->setBackgroundColor(this->backgroundColor()); | 178 | // sound_label->setBackgroundColor(this->backgroundColor()); |
186 | // sound_label->setPalette( QPalette( QColor( 232, 227, 215) ) ); | 179 | // sound_label->setPalette( QPalette( QColor( 232, 227, 215) ) ); |
187 | 180 | ||
188 | 181 | ||
189 | Frame6 = new QFrame( tab, "Frame6" ); | 182 | Frame6 = new QFrame( tab, "Frame6" ); |
190 | Frame6->setGeometry( QRect( 170, 145, 66, 10 ) ); | 183 | Frame6->setGeometry( QRect( 170, 145, 66, 10 ) ); |
191 | Frame6->setFrameShape( QFrame::HLine ); | 184 | Frame6->setFrameShape( QFrame::HLine ); |
192 | Frame6->setFrameShadow( QFrame::Raised ); | 185 | Frame6->setFrameShadow( QFrame::Raised ); |
193 | 186 | ||
194 | chordshow_label = new QLabel( tab, "chordshow_label" ); | 187 | chordshow_label = new QLabel( tab, "chordshow_label" ); |
195 | chordshow_label->setGeometry( QRect( 185, 60, 32, 17 ) ); | 188 | chordshow_label->setGeometry( QRect( 185, 60, 32, 17 ) ); |
196 | // chordshow_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, chordshow_label->sizePolicy().hasHeightForWidth() ) ); | 189 | // chordshow_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, chordshow_label->sizePolicy().hasHeightForWidth() ) ); |
197 | chordshow_label->setFrameShape( QLabel::NoFrame ); | 190 | chordshow_label->setFrameShape( QLabel::NoFrame ); |
198 | chordshow_label->setPixmap( image1 ); | 191 | chordshow_label->setPixmap( image1 ); |
199 | chordshow_label->setScaledContents( TRUE ); | 192 | chordshow_label->setScaledContents( TRUE ); |
200 | // chordshow_label->setBackgroundMode( QWidget::PaletteButton ); | 193 | // chordshow_label->setBackgroundMode( QWidget::PaletteButton ); |
201 | 194 | ||
202 | transport_rec = new QPushButton( tab, "transport_rec" ); | 195 | transport_rec = new QPushButton( tab, "transport_rec" ); |
203 | transport_rec->setGeometry( QRect( 170, 80, 30, 30 ) ); | 196 | transport_rec->setGeometry( QRect( 170, 80, 30, 30 ) ); |
204 | transport_rec->setText( tr( "" ) ); | 197 | transport_rec->setText( tr( "" ) ); |
205 | transport_rec->setPixmap( image2 ); | 198 | transport_rec->setPixmap( image2 ); |
206 | 199 | ||
207 | play_sound = new QPushButton( tab, "play_sound" ); | 200 | play_sound = new QPushButton( tab, "play_sound" ); |
208 | play_sound->setGeometry( QRect( 170, 180, 60, 55 ) ); | 201 | play_sound->setGeometry( QRect( 170, 180, 60, 55 ) ); |
209 | play_sound->setText( tr( "" ) ); | 202 | play_sound->setText( tr( "" ) ); |
210 | play_sound->setPixmap( image3 ); | 203 | play_sound->setPixmap( image3 ); |
211 | 204 | ||
212 | Frame6_2 = new QFrame( tab, "Frame6_2" ); | 205 | Frame6_2 = new QFrame( tab, "Frame6_2" ); |
213 | Frame6_2->setGeometry( QRect( 170, 45, 66, 10 ) ); | 206 | Frame6_2->setGeometry( QRect( 170, 45, 66, 10 ) ); |
214 | Frame6_2->setFrameShape( QFrame::HLine ); | 207 | Frame6_2->setFrameShape( QFrame::HLine ); |
215 | Frame6_2->setFrameShadow( QFrame::Raised ); | 208 | Frame6_2->setFrameShadow( QFrame::Raised ); |
216 | 209 | ||
217 | transport_play = new QPushButton( tab, "transport_play" ); | 210 | transport_play = new QPushButton( tab, "transport_play" ); |
218 | transport_play->setEnabled( FALSE ); | 211 | transport_play->setEnabled( FALSE ); |
219 | transport_play->setGeometry( QRect( 200, 80, 30, 30 ) ); | 212 | transport_play->setGeometry( QRect( 200, 80, 30, 30 ) ); |
220 | transport_play->setText( tr( "" ) ); | 213 | transport_play->setText( tr( "" ) ); |
221 | transport_play->setPixmap( image3 ); | 214 | transport_play->setPixmap( image3 ); |
222 | 215 | ||
223 | transport_rew = new QPushButton( tab, "transport_rew" ); | 216 | transport_rew = new QPushButton( tab, "transport_rew" ); |
224 | transport_rew->setEnabled( FALSE ); | 217 | transport_rew->setEnabled( FALSE ); |
225 | transport_rew->setGeometry( QRect( 170, 110, 30, 30 ) ); | 218 | transport_rew->setGeometry( QRect( 170, 110, 30, 30 ) ); |
226 | transport_rew->setText( tr( "" ) ); | 219 | transport_rew->setText( tr( "" ) ); |
227 | transport_rew->setPixmap( image4 ); | 220 | transport_rew->setPixmap( image4 ); |
228 | 221 | ||
229 | transport_fwd = new QPushButton( tab, "transport_fwd" ); | 222 | transport_fwd = new QPushButton( tab, "transport_fwd" ); |
230 | transport_fwd->setEnabled( FALSE ); | 223 | transport_fwd->setEnabled( FALSE ); |
231 | transport_fwd->setGeometry( QRect( 200, 110, 30, 30 ) ); | 224 | transport_fwd->setGeometry( QRect( 200, 110, 30, 30 ) ); |
232 | transport_fwd->setText( tr( "" ) ); | 225 | transport_fwd->setText( tr( "" ) ); |
233 | transport_fwd->setPixmap( image5 ); | 226 | transport_fwd->setPixmap( image5 ); |
234 | 227 | ||
235 | chordname = new QLabel( tab, "chordname" ); | 228 | chordname = new QLabel( tab, "chordname" ); |
236 | chordname->setGeometry( QRect( 146, 0, 90, 20 ) ); //cxm moved l 5 | 229 | chordname->setGeometry( QRect( 146, 0, 90, 20 ) ); //cxm moved l 5 |
237 | chordname->setText( tr( "A" ) ); | 230 | chordname->setText( tr( "A" ) ); |
238 | chordname->setAlignment( int( QLabel::AlignCenter ) ); | 231 | chordname->setAlignment( int( QLabel::AlignCenter ) ); |
239 | QToolTip::add( chordname, tr( "" ) ); | 232 | QToolTip::add( chordname, tr( "" ) ); |
240 | 233 | ||
241 | synth = new gs(); | 234 | synth = new gs(); |
242 | tuner = new gt(); | 235 | tuner = new gt(); |
243 | frets = new FretBoard( tab, "frets" ); | 236 | frets = new FretBoard( tab, "frets" ); |
244 | frets->setGeometry( QRect( 0, 20, 168, 210 ) ); | 237 | frets->setGeometry( QRect( 0, 20, 168, 210 ) ); |
245 | tabs->insertTab( tab, tr( "Guitar" ) ); | 238 | tabs->insertTab( tab, tr( "Guitar" ) ); |
246 | 239 | ||
247 | tab_2 = new QWidget( tabs, "tab_2" ); | 240 | tab_2 = new QWidget( tabs, "tab_2" ); |
248 | 241 | ||
249 | optlab2 = new QLabel( tab_2, "optlab2" ); | 242 | optlab2 = new QLabel( tab_2, "optlab2" ); |
250 | optlab2->setGeometry( QRect( 9, 58, 120, 41 ) ); | 243 | optlab2->setGeometry( QRect( 9, 58, 120, 41 ) ); |
251 | optlab2->setText( tr( "Alternative tunings are possible" ) ); | 244 | optlab2->setText( tr( "Alternative tunings are possible" ) ); |
252 | optlab2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); | 245 | optlab2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); |
253 | 246 | ||
254 | span = new QComboBox( FALSE, tab_2, "span" ); | 247 | span = new QComboBox( FALSE, tab_2, "span" ); |
255 | span->insertItem( tr( "2" ) ); | 248 | span->insertItem( tr( "2" ) ); |
256 | span->insertItem( tr( "3" ) ); | 249 | span->insertItem( tr( "3" ) ); |
257 | span->insertItem( tr( "4" ) ); | 250 | span->insertItem( tr( "4" ) ); |
258 | span->insertItem( tr( "5" ) ); | 251 | span->insertItem( tr( "5" ) ); |
259 | span->insertItem( tr( "6" ) ); | 252 | span->insertItem( tr( "6" ) ); |
260 | span->setGeometry( QRect( 180, 20, 50, 21 ) ); | 253 | span->setGeometry( QRect( 180, 20, 50, 21 ) ); |
261 | span->setCurrentItem( 1 ); | 254 | span->setCurrentItem( 1 ); |
262 | 255 | ||
263 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); | 256 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); |
264 | TextLabel1->setGeometry( QRect( 3, 109, 226, 140 ) ); | 257 | TextLabel1->setGeometry( QRect( 3, 109, 226, 140 ) ); |
265 | TextLabel1->setText( tr( QString::fromUtf8( "©2002 Camilo Mesias\n" | 258 | TextLabel1->setText( tr( QString::fromUtf8( "©2002 Camilo Mesias\n" |
266 | "camilo@mesias.co.uk\n" | 259 | "camilo@mesias.co.uk\n" |
267 | "Version 0.0.7 beta" ) ) ); | 260 | "Version 0.0.7 beta" ) ) ); |
268 | TextLabel1->setAlignment( int( QLabel::AlignBottom | QLabel::AlignLeft ) ); | 261 | TextLabel1->setAlignment( int( QLabel::AlignBottom | QLabel::AlignLeft ) ); |
269 | 262 | ||
270 | tuning = new QComboBox( FALSE, tab_2, "tuning" ); | 263 | tuning = new QComboBox( FALSE, tab_2, "tuning" ); |
271 | tuning->insertItem( tr( "EADGBE" ) ); | 264 | tuning->insertItem( tr( "EADGBE" ) ); |
272 | tuning->insertItem( tr( "EBEG#BE" ) ); | 265 | tuning->insertItem( tr( "EBEG#BE" ) ); |
273 | tuning->insertItem( tr( "EAEAC#E" ) ); | 266 | tuning->insertItem( tr( "EAEAC#E" ) ); |
274 | tuning->insertItem( tr( "EADF#BE" ) ); | 267 | tuning->insertItem( tr( "EADF#BE" ) ); |
275 | tuning->insertItem( tr( "EADGCF" ) ); | 268 | tuning->insertItem( tr( "EADGCF" ) ); |
276 | tuning->insertItem( tr( "DADGAD" ) ); | 269 | tuning->insertItem( tr( "DADGAD" ) ); |
277 | tuning->insertItem( tr( "DGCGCD" ) ); | 270 | tuning->insertItem( tr( "DGCGCD" ) ); |
278 | tuning->insertItem( tr( "DADF#AD" ) ); | 271 | tuning->insertItem( tr( "DADF#AD" ) ); |
279 | tuning->insertItem( tr( "DADGBE" ) ); | 272 | tuning->insertItem( tr( "DADGBE" ) ); |
280 | tuning->insertItem( tr( "DGDGBD" ) ); | 273 | tuning->insertItem( tr( "DGDGBD" ) ); |
281 | tuning->insertItem( tr( "DADACD" ) ); | 274 | tuning->insertItem( tr( "DADACD" ) ); |
282 | tuning->insertItem( tr( "CGCGAE" ) ); | 275 | tuning->insertItem( tr( "CGCGAE" ) ); |
283 | tuning->insertItem( tr( "FADGBE" ) ); | 276 | tuning->insertItem( tr( "FADGBE" ) ); |
284 | tuning->insertItem( tr( "G minor" ) ); | 277 | tuning->insertItem( tr( "G minor" ) ); |
285 | tuning->setGeometry( QRect( 140, 70, 91, 21 ) ); | 278 | tuning->setGeometry( QRect( 140, 70, 91, 21 ) ); |
286 | 279 | ||
287 | optlab1 = new QLabel( tab_2, "optlab1" ); | 280 | optlab1 = new QLabel( tab_2, "optlab1" ); |
288 | optlab1->setGeometry( QRect( 8, 8, 160, 40 ) ); | 281 | optlab1->setGeometry( QRect( 8, 8, 160, 40 ) ); |
289 | optlab1->setText( tr( "Span: the greatest number of frets over which you want chords to be generated" ) ); | 282 | optlab1->setText( tr( "Span: the greatest number of frets over which you want chords to be generated" ) ); |
290 | optlab1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); | 283 | optlab1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); |
291 | tabs->insertTab( tab_2, tr( "Options" ) ); | 284 | tabs->insertTab( tab_2, tr( "Options" ) ); |
292 | 285 | ||
293 | Tuner = new QWidget( tabs, "Tuner" ); | 286 | Tuner = new QWidget( tabs, "Tuner" ); |
294 | 287 | ||
295 | Frame4 = new QFrame( Tuner, "Frame4" ); | 288 | Frame4 = new QFrame( Tuner, "Frame4" ); |
296 | Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); | 289 | Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); |
297 | Frame4->setFrameShape( QFrame::Box ); | 290 | Frame4->setFrameShape( QFrame::Box ); |
298 | Frame4->setFrameShadow( QFrame::Raised ); | 291 | Frame4->setFrameShadow( QFrame::Raised ); |
299 | 292 | ||
300 | vu = new VUMeter( Frame4, "vu" ); | 293 | vu = new VUMeter( Frame4, "vu" ); |
301 | vu->setGeometry( QRect( 5, 5, 220, 115 ) ); | 294 | vu->setGeometry( QRect( 5, 5, 220, 115 ) ); |
302 | 295 | ||
303 | tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); | 296 | tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); |
304 | tuner_note->insertItem( tr( "auto" ) ); | 297 | tuner_note->insertItem( tr( "auto" ) ); |
305 | tuner_note->insertItem( tr( "E" ) ); | 298 | tuner_note->insertItem( tr( "E" ) ); |
306 | tuner_note->insertItem( tr( "D" ) ); | 299 | tuner_note->insertItem( tr( "D" ) ); |
307 | tuner_note->insertItem( tr( "G" ) ); | 300 | tuner_note->insertItem( tr( "G" ) ); |
308 | tuner_note->insertItem( tr( "A" ) ); | 301 | tuner_note->insertItem( tr( "A" ) ); |
309 | tuner_note->insertItem( tr( "B" ) ); | 302 | tuner_note->insertItem( tr( "B" ) ); |
310 | tuner_note->insertItem( tr( "C" ) ); | 303 | tuner_note->insertItem( tr( "C" ) ); |
311 | tuner_note->insertItem( tr( "F" ) ); | 304 | tuner_note->insertItem( tr( "F" ) ); |
312 | tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); | 305 | tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); |
313 | 306 | ||
314 | Frame8 = new QFrame( Tuner, "Frame8" ); | 307 | Frame8 = new QFrame( Tuner, "Frame8" ); |
315 | Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); | 308 | Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); |
316 | Frame8->setFrameShape( QFrame::HLine ); | 309 | Frame8->setFrameShape( QFrame::HLine ); |
317 | Frame8->setFrameShadow( QFrame::Raised ); | 310 | Frame8->setFrameShadow( QFrame::Raised ); |
318 | 311 | ||
319 | tuner_start = new QPushButton( Tuner, "tuner_start" ); | 312 | tuner_start = new QPushButton( Tuner, "tuner_start" ); |
320 | tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); | 313 | tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); |
321 | tuner_start->setText( tr( "Start" ) ); | 314 | tuner_start->setText( tr( "Start" ) ); |
322 | 315 | ||
323 | tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); | 316 | tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); |
324 | tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); | 317 | tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); |
325 | tuner_lab1->setText( tr( "Tuner operation" ) ); | 318 | tuner_lab1->setText( tr( "Tuner operation" ) ); |
326 | 319 | ||
327 | tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); | 320 | tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); |
328 | tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); | 321 | tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); |
329 | tuner_lab2->setText( tr( "Pitch calibration" ) ); | 322 | tuner_lab2->setText( tr( "Pitch calibration" ) ); |
330 | 323 | ||
331 | tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); | 324 | tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); |
332 | tuner_calib_note->insertItem( tr( "A" ) ); | 325 | tuner_calib_note->insertItem( tr( "A" ) ); |
333 | tuner_calib_note->insertItem( tr( "C" ) ); | 326 | tuner_calib_note->insertItem( tr( "C" ) ); |
334 | tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); | 327 | tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); |
335 | 328 | ||
336 | tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); | 329 | tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); |
337 | tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); | 330 | tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); |
338 | tuner_calib_freq->setSuffix( tr( "Hz" ) ); | 331 | tuner_calib_freq->setSuffix( tr( "Hz" ) ); |
339 | tuner_calib_freq->setWrapping( TRUE ); | 332 | tuner_calib_freq->setWrapping( TRUE ); |
340 | tuner_calib_freq->setMaxValue( 500 ); | 333 | tuner_calib_freq->setMaxValue( 500 ); |
341 | tuner_calib_freq->setMinValue( 300 ); | 334 | tuner_calib_freq->setMinValue( 300 ); |
342 | tuner_calib_freq->setValue( 440 ); | 335 | tuner_calib_freq->setValue( 440 ); |
343 | 336 | ||
344 | tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); | 337 | tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); |
345 | tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); | 338 | tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); |
346 | tuner_lab3->setText( tr( "Pitch" ) ); | 339 | tuner_lab3->setText( tr( "Pitch" ) ); |
347 | 340 | ||
348 | tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); | 341 | tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); |
349 | tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); | 342 | tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); |
350 | tuner_pic1->setFrameShape( QLabel::NoFrame ); | 343 | tuner_pic1->setFrameShape( QLabel::NoFrame ); |
351 | tuner_pic1->setPixmap( image6 ); | 344 | tuner_pic1->setPixmap( image6 ); |
352 | tuner_pic1->setScaledContents( TRUE ); | 345 | tuner_pic1->setScaledContents( TRUE ); |
353 | tabs->insertTab( Tuner, tr( "Tuner" ) ); | 346 | tabs->insertTab( Tuner, tr( "Tuner" ) ); |
354 | 347 | ||
355 | tab_3 = new QWidget( tabs, "tab_3" ); | 348 | tab_3 = new QWidget( tabs, "tab_3" ); |
356 | 349 | ||
357 | chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); | 350 | chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); |
358 | chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); | 351 | chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); |
359 | chordlistlab1->setText( tr( "Chord list" ) ); | 352 | chordlistlab1->setText( tr( "Chord list" ) ); |
360 | 353 | ||
361 | chordlist = new QListBox( tab_3, "chordlist" ); | 354 | chordlist = new QListBox( tab_3, "chordlist" ); |
362 | chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); | 355 | chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); |
363 | 356 | ||
364 | list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); | 357 | list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); |
365 | list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); | 358 | list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); |
366 | list_remove_btn->setText( tr( "Remove" ) ); | 359 | list_remove_btn->setText( tr( "Remove" ) ); |
367 | tabs->insertTab( tab_3, tr( "Chords" ) ); | 360 | tabs->insertTab( tab_3, tr( "Chords" ) ); |
368 | 361 | ||
369 | // hope this does what it's supposed to!! | 362 | // hope this does what it's supposed to!! |
370 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); | 363 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); |
371 | 364 | ||
372 | // signals and slots connections | 365 | // signals and slots connections |
373 | 366 | ||
374 | //cxm | 367 | //cxm |
375 | connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); | 368 | connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); |
376 | connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); | 369 | connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); |
377 | connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); | 370 | connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); |
378 | connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); | 371 | connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); |
379 | connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); | 372 | connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); |
380 | connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); | 373 | connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); |
381 | connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); | 374 | connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); |
382 | 375 | ||
383 | connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); | 376 | connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); |
384 | connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); | 377 | connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); |
385 | connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); | 378 | connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); |
386 | connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); | 379 | connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); |
387 | connect( frets, SIGNAL( s1nameChanged(const QString&) ), s1_1, SLOT( setText(const QString&) ) ); | 380 | connect( frets, SIGNAL( s1nameChanged(const QString&) ), s1_1, SLOT( setText(const QString&) ) ); |
388 | connect( frets, SIGNAL( s2nameChanged(const QString&) ), s1_2, SLOT( setText(const QString&) ) ); | 381 | connect( frets, SIGNAL( s2nameChanged(const QString&) ), s1_2, SLOT( setText(const QString&) ) ); |
389 | connect( frets, SIGNAL( s3nameChanged(const QString&) ), s1_3, SLOT( setText(const QString&) ) ); | 382 | connect( frets, SIGNAL( s3nameChanged(const QString&) ), s1_3, SLOT( setText(const QString&) ) ); |
390 | connect( frets, SIGNAL( s4nameChanged(const QString&) ), s1_4, SLOT( setText(const QString&) ) ); | 383 | connect( frets, SIGNAL( s4nameChanged(const QString&) ), s1_4, SLOT( setText(const QString&) ) ); |
391 | connect( frets, SIGNAL( s5nameChanged(const QString&) ), s1_5, SLOT( setText(const QString&) ) ); | 384 | connect( frets, SIGNAL( s5nameChanged(const QString&) ), s1_5, SLOT( setText(const QString&) ) ); |
392 | connect( frets, SIGNAL( s6nameChanged(const QString&) ), s1_6, SLOT( setText(const QString&) ) ); | 385 | connect( frets, SIGNAL( s6nameChanged(const QString&) ), s1_6, SLOT( setText(const QString&) ) ); |
393 | connect( frets, SIGNAL( nameChanged(const QString&) ), chordname, SLOT( setText(const QString&) ) ); | 386 | connect( frets, SIGNAL( nameChanged(const QString&) ), chordname, SLOT( setText(const QString&) ) ); |
394 | } | 387 | } |
395 | 388 | ||
396 | 389 | ||
397 | static int known=0; | 390 | static int known=0; |
398 | #include <qmessagebox.h> | 391 | #include <qmessagebox.h> |
399 | void PowerchordBase::transport_rec_cb(){ | 392 | void PowerchordBase::transport_rec_cb(){ |
400 | chordlist->insertItem(chordname->text(),-1); | 393 | chordlist->insertItem(chordname->text(),-1); |
401 | if (!known){ | 394 | if (!known){ |
402 | QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); | 395 | QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); |
403 | known = 1; | 396 | known = 1; |
404 | } | 397 | } |
405 | } | 398 | } |
406 | void PowerchordBase::list_remove_cb(){ | 399 | void PowerchordBase::list_remove_cb(){ |
407 | if (chordlist->count() > 0){ | 400 | if (chordlist->count() > 0){ |
408 | chordlist->removeItem(0); | 401 | chordlist->removeItem(0); |
409 | } | 402 | } |
410 | } | 403 | } |
411 | void PowerchordBase::play_chord_cb(){ | 404 | void PowerchordBase::play_chord_cb(){ |
412 | // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); | 405 | // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); |
413 | 406 | ||
414 | 407 | ||
415 | if (audio_timer){ | 408 | if (audio_timer){ |
416 | audio_timer->stop(); | 409 | audio_timer->stop(); |
417 | // set pixmap? | 410 | // set pixmap? |
418 | synth->Stop(); | 411 | synth->Stop(); |
419 | delete(audio_timer); | 412 | delete(audio_timer); |
420 | audio_timer = 0; | 413 | audio_timer = 0; |
421 | }else{ | 414 | }else{ |
422 | // get notes from chord engine | 415 | // get notes from chord engine |
423 | 416 | ||
424 | int note; | 417 | int note; |
425 | int base; | 418 | int base; |
426 | int octave; | 419 | int octave; |
427 | note = frets->ce.noteindex(0); | 420 | note = frets->ce.noteindex(0); |
428 | if (note >= 0){ | 421 | if (note >= 0){ |
429 | //fprintf(stderr, "Note was %d\n", note); | 422 | //fprintf(stderr, "Note was %d\n", note); |
430 | base = note % 12; | 423 | base = note % 12; |
431 | octave = note / 12; | 424 | octave = note / 12; |
432 | synth->note_start(0, base, octave); | 425 | synth->note_start(0, base, octave); |
433 | }else{ | 426 | }else{ |
434 | // subtle bug here - replay second note if 1st one muted | 427 | // subtle bug here - replay second note if 1st one muted |
435 | note = frets->ce.noteindex(1); | 428 | note = frets->ce.noteindex(1); |
436 | base = note % 12; | 429 | base = note % 12; |
437 | octave = note / 12; | 430 | octave = note / 12; |
438 | synth->note_start(1, base, octave); | 431 | synth->note_start(1, base, octave); |
439 | 432 | ||
440 | } | 433 | } |
441 | 434 | ||
442 | // init synth | 435 | // init synth |
443 | if (synth->Play()){ | 436 | if (synth->Play()){ |
444 | // error | 437 | // error |
445 | QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); | 438 | QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); |
446 | return; | 439 | return; |
447 | } | 440 | } |
448 | synth->fill_buffer(); | 441 | synth->fill_buffer(); |
449 | 442 | ||
450 | // start timer | 443 | // start timer |
451 | audio_timer = new QTimer(); | 444 | audio_timer = new QTimer(); |
452 | connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); | 445 | connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); |
453 | // set pixmap on player? | 446 | // set pixmap on player? |
454 | audio_timer->start(19); // 19 msec (fudge factor!!) | 447 | audio_timer->start(19); // 19 msec (fudge factor!!) |
455 | } | 448 | } |
456 | } | 449 | } |
457 | 450 | ||
458 | 451 | ||
459 | 452 | ||
460 | void PowerchordBase::audio_cb(){ | 453 | void PowerchordBase::audio_cb(){ |
461 | // play the next bit of audio until quiet | 454 | // play the next bit of audio until quiet |
462 | 455 | ||
463 | // strum timing | 456 | // strum timing |
464 | #define INTERVAL 2 | 457 | #define INTERVAL 2 |
465 | 458 | ||
466 | if ((synth->Frames() % INTERVAL) == 0){ | 459 | if ((synth->Frames() % INTERVAL) == 0){ |
467 | int string = synth->Frames() / INTERVAL; | 460 | int string = synth->Frames() / INTERVAL; |
468 | if (string <= 5){ | 461 | if (string <= 5){ |
469 | int note; | 462 | int note; |
470 | int base; | 463 | int base; |
471 | int octave; | 464 | int octave; |
472 | note = frets->ce.noteindex(string); | 465 | note = frets->ce.noteindex(string); |
473 | // check not muted... | 466 | // check not muted... |
474 | if (note > 0){ | 467 | if (note > 0){ |
475 | base = note % 12; | 468 | base = note % 12; |
476 | octave = note / 12; | 469 | octave = note / 12; |
477 | synth->note_start(string, base, octave); | 470 | synth->note_start(string, base, octave); |
478 | } | 471 | } |
479 | } | 472 | } |
480 | } | 473 | } |
481 | 474 | ||
482 | if (synth->Playing()){ | 475 | if (synth->Playing()){ |
483 | synth->write_buffer(); | 476 | synth->write_buffer(); |
484 | synth->fill_buffer(); | 477 | synth->fill_buffer(); |
485 | }else{ | 478 | }else{ |
486 | audio_timer->stop(); | 479 | audio_timer->stop(); |
487 | // set pixmap? | 480 | // set pixmap? |
488 | synth->Stop(); | 481 | synth->Stop(); |
489 | delete(audio_timer); | 482 | delete(audio_timer); |
490 | audio_timer = 0; | 483 | audio_timer = 0; |
491 | } | 484 | } |
492 | } | 485 | } |
493 | 486 | ||
494 | // the real tuner | 487 | // the real tuner |
495 | // void PowerchordBase::tuner_start_cb(){ | 488 | // void PowerchordBase::tuner_start_cb(){ |
496 | 489 | ||
497 | // if (tuner->Listening()){ | 490 | // if (tuner->Listening()){ |
498 | // simulation_timer->stop(); | 491 | // simulation_timer->stop(); |
499 | // tuner->Stop(); | 492 | // tuner->Stop(); |
500 | // tuner_pic1->setPixmap( *image6 ); | 493 | // tuner_pic1->setPixmap( *image6 ); |
501 | 494 | ||
502 | // }else{ | 495 | // }else{ |
503 | // tuner_pic1->setPixmap( *image_open ); | 496 | // tuner_pic1->setPixmap( *image_open ); |
504 | 497 | ||
505 | // if (!simulation_timer){ | 498 | // if (!simulation_timer){ |
506 | // simulation_timer = new QTimer(); | 499 | // simulation_timer = new QTimer(); |
507 | 500 | ||
508 | 501 | ||
509 | // connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); | 502 | // connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); |
510 | // } | 503 | // } |
511 | 504 | ||
512 | // simulation_timer->start(50); | 505 | // simulation_timer->start(50); |
513 | // tuner->Listen(); | 506 | // tuner->Listen(); |
514 | 507 | ||
515 | // } | 508 | // } |
516 | // } | 509 | // } |
517 | 510 | ||
518 | void PowerchordBase::tuner_cb(){ | 511 | void PowerchordBase::tuner_cb(){ |
519 | if (tuner->Listening()){ | 512 | if (tuner->Listening()){ |
520 | tuner->read_buffer(); | 513 | tuner->read_buffer(); |
521 | tuner->process_buffer(); | 514 | tuner->process_buffer(); |
522 | 515 | ||
523 | // update gui | 516 | // update gui |
524 | // do something with the note: tuner->Note() | 517 | // do something with the note: tuner->Note() |
525 | emit frequency_change(tuner->Tuning()); | 518 | emit frequency_change(tuner->Tuning()); |
526 | 519 | ||
527 | }else{ | 520 | }else{ |
528 | simulation_timer->stop(); | 521 | simulation_timer->stop(); |
529 | tuner->Stop(); | 522 | tuner->Stop(); |
530 | tuner_pic1->setPixmap( image6 ); | 523 | tuner_pic1->setPixmap( image6 ); |
531 | } | 524 | } |
532 | } | 525 | } |
533 | 526 | ||
534 | 527 | ||
535 | void PowerchordBase::tuner_start_cb(){ | 528 | void PowerchordBase::tuner_start_cb(){ |
536 | if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){ | 529 | if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){ |
537 | if (simulation_timer){ | 530 | if (simulation_timer){ |
538 | simulation_timer->stop(); | 531 | simulation_timer->stop(); |
539 | }else{ | 532 | }else{ |
540 | simulation_timer = new QTimer(); | 533 | simulation_timer = new QTimer(); |
541 | connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); | 534 | connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); |
542 | 535 | ||
543 | } | 536 | } |
544 | simulation_x = -45; | 537 | simulation_x = -45; |
545 | simulation_v = 0; | 538 | simulation_v = 0; |
546 | simulation_iter = 0; | 539 | simulation_iter = 0; |
547 | 540 | ||
548 | tuner_pic1->setPixmap( image_open ); | 541 | tuner_pic1->setPixmap( image_open ); |
549 | simulation_timer->start(100); | 542 | simulation_timer->start(100); |
550 | } | 543 | } |
551 | } | 544 | } |
552 | 545 | ||
553 | #include <stdio.h> | 546 | #include <stdio.h> |
554 | 547 | ||
555 | void PowerchordBase::tuner_simulation_cb(){ | 548 | void PowerchordBase::tuner_simulation_cb(){ |
556 | if (simulation_x < -10 || simulation_x > 10){ | 549 | if (simulation_x < -10 || simulation_x > 10){ |
557 | simulation_v = (simulation_v/2)-(simulation_x/5); | 550 | simulation_v = (simulation_v/2)-(simulation_x/5); |
558 | } | 551 | } |
559 | 552 | ||
560 | simulation_x += simulation_v; | 553 | simulation_x += simulation_v; |
561 | simulation_iter++; | 554 | simulation_iter++; |
562 | 555 | ||
563 | if (simulation_x > 50){ | 556 | if (simulation_x > 50){ |
564 | simulation_x = 50; | 557 | simulation_x = 50; |
565 | } | 558 | } |
566 | 559 | ||
567 | if (simulation_x < -50){ | 560 | if (simulation_x < -50){ |
568 | simulation_x = -50; | 561 | simulation_x = -50; |
569 | } | 562 | } |
570 | 563 | ||
571 | if (simulation_iter > 50){ | 564 | if (simulation_iter > 50){ |
572 | simulation_timer->stop(); | 565 | simulation_timer->stop(); |
573 | emit frequency_change(0); | 566 | emit frequency_change(0); |
574 | tuner_pic1->setPixmap( image6 ); | 567 | tuner_pic1->setPixmap( image6 ); |
575 | }else{ | 568 | }else{ |
576 | emit frequency_change(simulation_x); | 569 | emit frequency_change(simulation_x); |
577 | } | 570 | } |
578 | } | 571 | } |
579 | 572 | ||
580 | /* | 573 | /* |
581 | * Destroys the object and frees any allocated resources | 574 | * Destroys the object and frees any allocated resources |
582 | */ | 575 | */ |
583 | PowerchordBase::~PowerchordBase() | 576 | PowerchordBase::~PowerchordBase() |
584 | { | 577 | { |
585 | // no need to delete child widgets, Qt does it all for us | 578 | // no need to delete child widgets, Qt does it all for us |
586 | } | 579 | } |
587 | 580 | ||
588 | void PowerchordBase::change_handler() | 581 | void PowerchordBase::change_handler() |
589 | { | 582 | { |
590 | qWarning( "PowerchordBase::change_handler(): Not implemented yet!" ); | 583 | qWarning( "PowerchordBase::change_handler(): Not implemented yet!" ); |
591 | } | 584 | } |
592 | 585 | ||
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp index d2b65a9..79ee925 100644 --- a/noncore/multimedia/showimg/ImageFileSelector.cpp +++ b/noncore/multimedia/showimg/ImageFileSelector.cpp | |||
@@ -1,271 +1,260 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "qpe/global.h" | ||
4 | #include "qpe/applnk.h" | ||
5 | #include "qpe/lnkproperties.h" | ||
6 | #include "qpe/applnk.h" | ||
7 | #include "qpe/qpeapplication.h" | 3 | #include "qpe/qpeapplication.h" |
8 | 4 | ||
9 | #include <stdlib.h> | 5 | #include <stdlib.h> |
10 | 6 | ||
11 | #include <qdir.h> | ||
12 | #include <qwidget.h> | ||
13 | #include <qheader.h> | ||
14 | #include <qimage.h> | ||
15 | #include <qpixmap.h> | ||
16 | #include <qlabel.h> | 7 | #include <qlabel.h> |
17 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
18 | #include <qpainter.h> | ||
19 | #include <qscrollview.h> | ||
20 | 9 | ||
21 | #include "ImageFileSelector.h" | 10 | #include "ImageFileSelector.h" |
22 | 11 | ||
23 | 12 | ||
24 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) | 13 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) |
25 | : QWidget( parent ),fl(f) | 14 | : QWidget( parent ),fl(f) |
26 | { | 15 | { |
27 | setBackgroundMode(NoBackground); | 16 | setBackgroundMode(NoBackground); |
28 | if ( w!=-1 ) | 17 | if ( w!=-1 ) |
29 | setMinimumSize(w,p.height()+24); | 18 | setMinimumSize(w,p.height()+24); |
30 | else | 19 | else |
31 | setMinimumSize(p.width(),p.height()+24); | 20 | setMinimumSize(p.width(),p.height()+24); |
32 | description=new QLabel(text,this); | 21 | description=new QLabel(text,this); |
33 | description->setBackgroundColor(colorGroup().base()); | 22 | description->setBackgroundColor(colorGroup().base()); |
34 | description->setAlignment(AlignCenter); | 23 | description->setAlignment(AlignCenter); |
35 | description->setGeometry(0,height()-24,width(),24); | 24 | description->setGeometry(0,height()-24,width(),24); |
36 | pixmap=p; | 25 | pixmap=p; |
37 | } | 26 | } |
38 | 27 | ||
39 | void ThumbWidget::resizeEvent(QResizeEvent *) | 28 | void ThumbWidget::resizeEvent(QResizeEvent *) |
40 | { | 29 | { |
41 | description->setGeometry(0,height()-24,width(),24); | 30 | description->setGeometry(0,height()-24,width(),24); |
42 | } | 31 | } |
43 | 32 | ||
44 | void ThumbWidget::paintEvent( QPaintEvent *e ) | 33 | void ThumbWidget::paintEvent( QPaintEvent *e ) |
45 | { | 34 | { |
46 | QPainter painter(this); | 35 | QPainter painter(this); |
47 | 36 | ||
48 | painter.setClipRect(e->rect()); | 37 | painter.setClipRect(e->rect()); |
49 | painter.fillRect(0,0,width(),height(),QColor(255,255,255)); | 38 | painter.fillRect(0,0,width(),height(),QColor(255,255,255)); |
50 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); | 39 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); |
51 | 40 | ||
52 | } | 41 | } |
53 | 42 | ||
54 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) | 43 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) |
55 | { | 44 | { |
56 | emit clicked(fl); | 45 | emit clicked(fl); |
57 | } | 46 | } |
58 | 47 | ||
59 | 48 | ||
60 | 49 | ||
61 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) | 50 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) |
62 | : QListViewItem( parent ), fl( f ) | 51 | : QListViewItem( parent ), fl( f ) |
63 | { | 52 | { |
64 | setText( 0, f.name() ); | 53 | setText( 0, f.name() ); |
65 | QFileInfo fi(f.file()); | 54 | QFileInfo fi(f.file()); |
66 | setText( 1, (fi.extension()).upper() ); | 55 | setText( 1, (fi.extension()).upper() ); |
67 | setPixmap( 0, f.pixmap() ); | 56 | setPixmap( 0, f.pixmap() ); |
68 | 57 | ||
69 | 58 | ||
70 | } | 59 | } |
71 | 60 | ||
72 | 61 | ||
73 | ImageFileSelectorItem::~ImageFileSelectorItem() | 62 | ImageFileSelectorItem::~ImageFileSelectorItem() |
74 | { | 63 | { |
75 | 64 | ||
76 | } | 65 | } |
77 | 66 | ||
78 | 67 | ||
79 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) | 68 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) |
80 | : QWidgetStack(parent) | 69 | : QWidgetStack(parent) |
81 | { | 70 | { |
82 | 71 | ||
83 | detailed=new QListView(this); | 72 | detailed=new QListView(this); |
84 | 73 | ||
85 | detailed->addColumn (tr("Title")); | 74 | detailed->addColumn (tr("Title")); |
86 | detailed->addColumn (tr("Type")); | 75 | detailed->addColumn (tr("Type")); |
87 | detailed->setAllColumnsShowFocus( true ); | 76 | detailed->setAllColumnsShowFocus( true ); |
88 | 77 | ||
89 | tList.setAutoDelete(true); | 78 | tList.setAutoDelete(true); |
90 | 79 | ||
91 | thumb =new QScrollView(this); | 80 | thumb =new QScrollView(this); |
92 | thumb->setVScrollBarMode (QScrollView::Auto ); | 81 | thumb->setVScrollBarMode (QScrollView::Auto ); |
93 | thumb->viewport()->setBackgroundColor(colorGroup().base()); | 82 | thumb->viewport()->setBackgroundColor(colorGroup().base()); |
94 | 83 | ||
95 | background=new QWidget(0); | 84 | background=new QWidget(0); |
96 | background->setBackgroundColor(colorGroup().base()); | 85 | background->setBackgroundColor(colorGroup().base()); |
97 | thumb->addChild(background); | 86 | thumb->addChild(background); |
98 | gl = new QGridLayout(background,1,2,4,4); | 87 | gl = new QGridLayout(background,1,2,4,4); |
99 | 88 | ||
100 | 89 | ||
101 | 90 | ||
102 | connect( detailed, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 91 | connect( detailed, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
103 | this, SLOT( fileClicked(int,QListViewItem*,const QPoint&,int) ) ); | 92 | this, SLOT( fileClicked(int,QListViewItem*,const QPoint&,int) ) ); |
104 | connect( detailed, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 93 | connect( detailed, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
105 | this, SLOT( filePressed(int,QListViewItem*,const QPoint&,int) ) ); | 94 | this, SLOT( filePressed(int,QListViewItem*,const QPoint&,int) ) ); |
106 | connect( detailed, SIGNAL( returnPressed(QListViewItem*) ), | 95 | connect( detailed, SIGNAL( returnPressed(QListViewItem*) ), |
107 | this, SLOT( fileClicked(QListViewItem*) ) ); | 96 | this, SLOT( fileClicked(QListViewItem*) ) ); |
108 | 97 | ||
109 | cView=UNKNOWN; | 98 | cView=UNKNOWN; |
110 | setView(scv); | 99 | setView(scv); |
111 | reread(); | 100 | reread(); |
112 | 101 | ||
113 | } | 102 | } |
114 | ImageFileSelector::~ImageFileSelector() | 103 | ImageFileSelector::~ImageFileSelector() |
115 | { | 104 | { |
116 | 105 | ||
117 | } | 106 | } |
118 | 107 | ||
119 | 108 | ||
120 | void ImageFileSelector::switchView() | 109 | void ImageFileSelector::switchView() |
121 | { | 110 | { |
122 | CURRENT_VIEW v=cView; | 111 | CURRENT_VIEW v=cView; |
123 | 112 | ||
124 | if ( v==DETAILED ) | 113 | if ( v==DETAILED ) |
125 | v=THUMBNAIL; | 114 | v=THUMBNAIL; |
126 | else | 115 | else |
127 | v=DETAILED; | 116 | v=DETAILED; |
128 | setView(v); | 117 | setView(v); |
129 | } | 118 | } |
130 | 119 | ||
131 | void ImageFileSelector::setView(CURRENT_VIEW v) | 120 | void ImageFileSelector::setView(CURRENT_VIEW v) |
132 | { | 121 | { |
133 | 122 | ||
134 | if ( v==cView ) | 123 | if ( v==cView ) |
135 | return; | 124 | return; |
136 | cView=v; | 125 | cView=v; |
137 | 126 | ||
138 | if ( cView!=DETAILED ) | 127 | if ( cView!=DETAILED ) |
139 | { | 128 | { |
140 | raiseWidget(thumb); | 129 | raiseWidget(thumb); |
141 | updateSizes(); | 130 | updateSizes(); |
142 | } | 131 | } |
143 | else | 132 | else |
144 | { | 133 | { |
145 | raiseWidget(detailed); | 134 | raiseWidget(detailed); |
146 | updateSizes(); | 135 | updateSizes(); |
147 | } | 136 | } |
148 | 137 | ||
149 | 138 | ||
150 | } | 139 | } |
151 | 140 | ||
152 | void ImageFileSelector::resizeEvent(QResizeEvent *) | 141 | void ImageFileSelector::resizeEvent(QResizeEvent *) |
153 | { | 142 | { |
154 | updateSizes(); | 143 | updateSizes(); |
155 | } | 144 | } |
156 | 145 | ||
157 | void ImageFileSelector::updateSizes() | 146 | void ImageFileSelector::updateSizes() |
158 | { | 147 | { |
159 | int ww=(detailed->width()-detailed->frameWidth()*2); | 148 | int ww=(detailed->width()-detailed->frameWidth()*2); |
160 | double w=(double)ww*0.70; | 149 | double w=(double)ww*0.70; |
161 | detailed->setColumnWidth(0,(int)w); | 150 | detailed->setColumnWidth(0,(int)w); |
162 | detailed->setColumnWidth(1,ww-(int)w); | 151 | detailed->setColumnWidth(1,ww-(int)w); |
163 | background->setMinimumWidth(thumb->visibleWidth()); | 152 | background->setMinimumWidth(thumb->visibleWidth()); |
164 | thumb->updateScrollBars(); | 153 | thumb->updateScrollBars(); |
165 | } | 154 | } |
166 | 155 | ||
167 | void ImageFileSelector::reread(bool) | 156 | void ImageFileSelector::reread(bool) |
168 | { | 157 | { |
169 | // qDebug("reread"); | 158 | // qDebug("reread"); |
170 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); | 159 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); |
171 | QString oldFile; | 160 | QString oldFile; |
172 | if ( item ) | 161 | if ( item ) |
173 | oldFile = item->file().file(); | 162 | oldFile = item->file().file(); |
174 | detailed->clear(); | 163 | detailed->clear(); |
175 | tList.clear(); | 164 | tList.clear(); |
176 | DocLnkSet files; | 165 | DocLnkSet files; |
177 | Global::findDocuments(&files, "image/*"); | 166 | Global::findDocuments(&files, "image/*"); |
178 | count = files.children().count(); | 167 | count = files.children().count(); |
179 | QListIterator<DocLnk> dit( files.children() ); | 168 | QListIterator<DocLnk> dit( files.children() ); |
180 | // int y=0; | 169 | // int y=0; |
181 | // int x=4; | 170 | // int x=4; |
182 | // int totalHeight=4; | 171 | // int totalHeight=4; |
183 | ThumbWidget *l=0; | 172 | ThumbWidget *l=0; |
184 | int width=80; | 173 | int width=80; |
185 | gl->expand(dit.count()/2,2); | 174 | gl->expand(dit.count()/2,2); |
186 | int i,j; | 175 | int i,j; |
187 | i=j=0; | 176 | i=j=0; |
188 | detailed->setUpdatesEnabled(false); | 177 | detailed->setUpdatesEnabled(false); |
189 | thumb->setUpdatesEnabled(false); | 178 | thumb->setUpdatesEnabled(false); |
190 | 179 | ||
191 | for ( ; dit.current(); ++dit ) { | 180 | for ( ; dit.current(); ++dit ) { |
192 | item = new ImageFileSelectorItem( detailed, **dit ); | 181 | item = new ImageFileSelectorItem( detailed, **dit ); |
193 | if ( item->file().file() == oldFile ) | 182 | if ( item->file().file() == oldFile ) |
194 | detailed->setCurrentItem( item ); | 183 | detailed->setCurrentItem( item ); |
195 | } | 184 | } |
196 | 185 | ||
197 | QListViewItemIterator it( detailed ); | 186 | QListViewItemIterator it( detailed ); |
198 | ImageFileSelectorItem *ii; | 187 | ImageFileSelectorItem *ii; |
199 | // iterate through all items of the listview | 188 | // iterate through all items of the listview |
200 | for ( ; it.current(); ++it ) { | 189 | for ( ; it.current(); ++it ) { |
201 | ii=(ImageFileSelectorItem *)it.current(); | 190 | ii=(ImageFileSelectorItem *)it.current(); |
202 | QImage img( ii->file().file() ); | 191 | QImage img( ii->file().file() ); |
203 | if( !img.isNull()) { | 192 | if( !img.isNull()) { |
204 | img=img.smoothScale(64,64); | 193 | img=img.smoothScale(64,64); |
205 | QPixmap pix; | 194 | QPixmap pix; |
206 | pix.convertFromImage(img); | 195 | pix.convertFromImage(img); |
207 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); | 196 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); |
208 | l->setBackgroundColor(colorGroup().base()); | 197 | l->setBackgroundColor(colorGroup().base()); |
209 | gl->addWidget(l,j,i); | 198 | gl->addWidget(l,j,i); |
210 | i++; | 199 | i++; |
211 | if ( i==2 ) { | 200 | if ( i==2 ) { |
212 | i=0; | 201 | i=0; |
213 | j++; | 202 | j++; |
214 | } | 203 | } |
215 | tList.append(l); | 204 | tList.append(l); |
216 | connect(l,SIGNAL(clicked(const DocLnk&)),this,SLOT(thumbClicked(const DocLnk&))); | 205 | connect(l,SIGNAL(clicked(const DocLnk&)),this,SLOT(thumbClicked(const DocLnk&))); |
217 | } | 206 | } |
218 | } | 207 | } |
219 | 208 | ||
220 | if ( !detailed->selectedItem() ) | 209 | if ( !detailed->selectedItem() ) |
221 | detailed->setCurrentItem( detailed->firstChild() ); | 210 | detailed->setCurrentItem( detailed->firstChild() ); |
222 | 211 | ||
223 | detailed->setUpdatesEnabled(true); | 212 | detailed->setUpdatesEnabled(true); |
224 | thumb->setUpdatesEnabled(true); | 213 | thumb->setUpdatesEnabled(true); |
225 | detailed->update(); | 214 | detailed->update(); |
226 | thumb->update(); | 215 | thumb->update(); |
227 | } | 216 | } |
228 | 217 | ||
229 | int ImageFileSelector::fileCount() | 218 | int ImageFileSelector::fileCount() |
230 | { | 219 | { |
231 | return count; | 220 | return count; |
232 | } | 221 | } |
233 | const DocLnk * ImageFileSelector::selected() | 222 | const DocLnk * ImageFileSelector::selected() |
234 | { | 223 | { |
235 | qDebug("image selected"); | 224 | qDebug("image selected"); |
236 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); | 225 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); |
237 | if ( item ) | 226 | if ( item ) |
238 | return new DocLnk( item->file() ); | 227 | return new DocLnk( item->file() ); |
239 | return 0; | 228 | return 0; |
240 | } | 229 | } |
241 | 230 | ||
242 | 231 | ||
243 | 232 | ||
244 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) | 233 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) |
245 | { | 234 | { |
246 | if ( !i ) | 235 | if ( !i ) |
247 | return; | 236 | return; |
248 | if ( button == Qt::LeftButton ) | 237 | if ( button == Qt::LeftButton ) |
249 | { | 238 | { |
250 | fileClicked( i ); | 239 | fileClicked( i ); |
251 | } | 240 | } |
252 | } | 241 | } |
253 | // pressed to get 'right down' | 242 | // pressed to get 'right down' |
254 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) | 243 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) |
255 | { | 244 | { |
256 | 245 | ||
257 | } | 246 | } |
258 | void ImageFileSelector::fileClicked( QListViewItem *i) | 247 | void ImageFileSelector::fileClicked( QListViewItem *i) |
259 | { | 248 | { |
260 | if ( !i ) | 249 | if ( !i ) |
261 | return; | 250 | return; |
262 | emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); | 251 | emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); |
263 | emit closeMe(); | 252 | emit closeMe(); |
264 | } | 253 | } |
265 | 254 | ||
266 | void ImageFileSelector::thumbClicked(const DocLnk &f) | 255 | void ImageFileSelector::thumbClicked(const DocLnk &f) |
267 | { | 256 | { |
268 | emit fileSelected( f ); | 257 | emit fileSelected( f ); |
269 | emit closeMe(); | 258 | emit closeMe(); |
270 | } | 259 | } |
271 | 260 | ||
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp index efb1c68..1c864e9 100644 --- a/noncore/multimedia/showimg/main.cpp +++ b/noncore/multimedia/showimg/main.cpp | |||
@@ -1,27 +1,26 @@ | |||
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 | #include <qpe/qpeapplication.h> | ||
24 | 23 | ||
25 | #include <opie/oapplicationfactory.h> | 24 | #include <opie/oapplicationfactory.h> |
26 | 25 | ||
27 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) \ No newline at end of file | 26 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) \ No newline at end of file |
diff --git a/noncore/multimedia/showimg/settingsdialog.cpp b/noncore/multimedia/showimg/settingsdialog.cpp index 55d555a..202bd0c 100644 --- a/noncore/multimedia/showimg/settingsdialog.cpp +++ b/noncore/multimedia/showimg/settingsdialog.cpp | |||
@@ -1,88 +1,86 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 "settingsdialog.h" | 21 | #include "settingsdialog.h" |
22 | #include <qslider.h> | 22 | #include <qslider.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qradiobutton.h> | ||
26 | #include <qbuttongroup.h> | ||
27 | 25 | ||
28 | SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f ) | 26 | SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f ) |
29 | : SettingsDialogBase( parent, name, modal, f ) | 27 | : SettingsDialogBase( parent, name, modal, f ) |
30 | { | 28 | { |
31 | connect( delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delayChanged(int)) ); | 29 | connect( delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delayChanged(int)) ); |
32 | } | 30 | } |
33 | 31 | ||
34 | void SettingsDialog::setDelay( int d ) | 32 | void SettingsDialog::setDelay( int d ) |
35 | { | 33 | { |
36 | delaySlider->setValue( d ); | 34 | delaySlider->setValue( d ); |
37 | delayChanged( d ); | 35 | delayChanged( d ); |
38 | } | 36 | } |
39 | 37 | ||
40 | int SettingsDialog::delay() const | 38 | int SettingsDialog::delay() const |
41 | { | 39 | { |
42 | return delaySlider->value(); | 40 | return delaySlider->value(); |
43 | } | 41 | } |
44 | 42 | ||
45 | void SettingsDialog::setRepeat( bool r ) | 43 | void SettingsDialog::setRepeat( bool r ) |
46 | { | 44 | { |
47 | repeatCheck->setChecked( r ); | 45 | repeatCheck->setChecked( r ); |
48 | } | 46 | } |
49 | 47 | ||
50 | bool SettingsDialog::repeat() const | 48 | bool SettingsDialog::repeat() const |
51 | { | 49 | { |
52 | return repeatCheck->isChecked(); | 50 | return repeatCheck->isChecked(); |
53 | } | 51 | } |
54 | 52 | ||
55 | void SettingsDialog::delayChanged( int d ) | 53 | void SettingsDialog::delayChanged( int d ) |
56 | { | 54 | { |
57 | delayText->setText( QString::number( d ) + " s" ); | 55 | delayText->setText( QString::number( d ) + " s" ); |
58 | } | 56 | } |
59 | 57 | ||
60 | void SettingsDialog::setReverse(bool r) | 58 | void SettingsDialog::setReverse(bool r) |
61 | { | 59 | { |
62 | reverseCheck->setChecked(r); | 60 | reverseCheck->setChecked(r); |
63 | } | 61 | } |
64 | 62 | ||
65 | bool SettingsDialog::reverse() const | 63 | bool SettingsDialog::reverse() const |
66 | { | 64 | { |
67 | return reverseCheck->isChecked(); | 65 | return reverseCheck->isChecked(); |
68 | } | 66 | } |
69 | 67 | ||
70 | void SettingsDialog::setRotate(bool r) | 68 | void SettingsDialog::setRotate(bool r) |
71 | { | 69 | { |
72 | rotateCheck->setChecked(r); | 70 | rotateCheck->setChecked(r); |
73 | } | 71 | } |
74 | 72 | ||
75 | bool SettingsDialog::rotate() const | 73 | bool SettingsDialog::rotate() const |
76 | { | 74 | { |
77 | return rotateCheck->isChecked(); | 75 | return rotateCheck->isChecked(); |
78 | } | 76 | } |
79 | 77 | ||
80 | void SettingsDialog::setFastLoad(bool f) | 78 | void SettingsDialog::setFastLoad(bool f) |
81 | { | 79 | { |
82 | fastLoadCheck->setChecked(f); | 80 | fastLoadCheck->setChecked(f); |
83 | } | 81 | } |
84 | 82 | ||
85 | bool SettingsDialog::fastLoad() const | 83 | bool SettingsDialog::fastLoad() const |
86 | { | 84 | { |
87 | return fastLoadCheck->isChecked(); | 85 | return fastLoadCheck->isChecked(); |
88 | } | 86 | } |
diff --git a/noncore/multimedia/showimg/settingsdialogbase.cpp b/noncore/multimedia/showimg/settingsdialogbase.cpp index e0c5bb0..7a64e89 100644 --- a/noncore/multimedia/showimg/settingsdialogbase.cpp +++ b/noncore/multimedia/showimg/settingsdialogbase.cpp | |||
@@ -1,106 +1,102 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'settingsdialogbase.ui' | 2 | ** Form implementation generated from reading ui file 'settingsdialogbase.ui' |
3 | ** | 3 | ** |
4 | ** Created: Sun Nov 3 07:29:03 2002 | 4 | ** Created: Sun Nov 3 07:29:03 2002 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "settingsdialogbase.h" | 9 | #include "settingsdialogbase.h" |
10 | 10 | ||
11 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
12 | #include <qgroupbox.h> | 12 | #include <qgroupbox.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | ||
15 | #include <qslider.h> | 14 | #include <qslider.h> |
16 | #include <qlayout.h> | 15 | #include <qlayout.h> |
17 | #include <qvariant.h> | ||
18 | #include <qtooltip.h> | ||
19 | #include <qwhatsthis.h> | ||
20 | 16 | ||
21 | /* | 17 | /* |
22 | * Constructs a SettingsDialogBase which is a child of 'parent', with the | 18 | * Constructs a SettingsDialogBase which is a child of 'parent', with the |
23 | * name 'name' and widget flags set to 'f' | 19 | * name 'name' and widget flags set to 'f' |
24 | * | 20 | * |
25 | * The dialog will by default be modeless, unless you set 'modal' to | 21 | * The dialog will by default be modeless, unless you set 'modal' to |
26 | * TRUE to construct a modal dialog. | 22 | * TRUE to construct a modal dialog. |
27 | */ | 23 | */ |
28 | SettingsDialogBase::SettingsDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl ) | 24 | SettingsDialogBase::SettingsDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl ) |
29 | : QDialog( parent, name, modal, fl ) | 25 | : QDialog( parent, name, modal, fl ) |
30 | { | 26 | { |
31 | if ( !name ) | 27 | if ( !name ) |
32 | setName( "SettingsDialogBase" ); | 28 | setName( "SettingsDialogBase" ); |
33 | resize( 246, 201 ); | 29 | resize( 246, 201 ); |
34 | setCaption( tr( "Preferences" ) ); | 30 | setCaption( tr( "Preferences" ) ); |
35 | SettingsDialogBaseLayout = new QVBoxLayout( this ); | 31 | SettingsDialogBaseLayout = new QVBoxLayout( this ); |
36 | SettingsDialogBaseLayout->setSpacing( 6 ); | 32 | SettingsDialogBaseLayout->setSpacing( 6 ); |
37 | SettingsDialogBaseLayout->setMargin( 6 ); | 33 | SettingsDialogBaseLayout->setMargin( 6 ); |
38 | 34 | ||
39 | GroupBox1 = new QGroupBox( this, "GroupBox1" ); | 35 | GroupBox1 = new QGroupBox( this, "GroupBox1" ); |
40 | GroupBox1->setTitle( tr( "Slide Show" ) ); | 36 | GroupBox1->setTitle( tr( "Slide Show" ) ); |
41 | GroupBox1->setColumnLayout(0, Qt::Vertical ); | 37 | GroupBox1->setColumnLayout(0, Qt::Vertical ); |
42 | GroupBox1->layout()->setSpacing( 0 ); | 38 | GroupBox1->layout()->setSpacing( 0 ); |
43 | GroupBox1->layout()->setMargin( 0 ); | 39 | GroupBox1->layout()->setMargin( 0 ); |
44 | GroupBox1Layout = new QVBoxLayout( GroupBox1->layout() ); | 40 | GroupBox1Layout = new QVBoxLayout( GroupBox1->layout() ); |
45 | GroupBox1Layout->setAlignment( Qt::AlignTop ); | 41 | GroupBox1Layout->setAlignment( Qt::AlignTop ); |
46 | GroupBox1Layout->setSpacing( 6 ); | 42 | GroupBox1Layout->setSpacing( 6 ); |
47 | GroupBox1Layout->setMargin( 11 ); | 43 | GroupBox1Layout->setMargin( 11 ); |
48 | 44 | ||
49 | Layout3 = new QGridLayout; | 45 | Layout3 = new QGridLayout; |
50 | Layout3->setSpacing( 6 ); | 46 | Layout3->setSpacing( 6 ); |
51 | Layout3->setMargin( 0 ); | 47 | Layout3->setMargin( 0 ); |
52 | 48 | ||
53 | TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); | 49 | TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); |
54 | TextLabel1->setText( tr( "Delay between pictures" ) ); | 50 | TextLabel1->setText( tr( "Delay between pictures" ) ); |
55 | 51 | ||
56 | Layout3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); | 52 | Layout3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); |
57 | 53 | ||
58 | delaySlider = new QSlider( GroupBox1, "delaySlider" ); | 54 | delaySlider = new QSlider( GroupBox1, "delaySlider" ); |
59 | delaySlider->setMinValue( 2 ); | 55 | delaySlider->setMinValue( 2 ); |
60 | delaySlider->setMaxValue( 60 ); | 56 | delaySlider->setMaxValue( 60 ); |
61 | delaySlider->setLineStep( 2 ); | 57 | delaySlider->setLineStep( 2 ); |
62 | delaySlider->setOrientation( QSlider::Horizontal ); | 58 | delaySlider->setOrientation( QSlider::Horizontal ); |
63 | delaySlider->setTickmarks( QSlider::Right ); | 59 | delaySlider->setTickmarks( QSlider::Right ); |
64 | delaySlider->setTickInterval( 10); | 60 | delaySlider->setTickInterval( 10); |
65 | 61 | ||
66 | Layout3->addWidget( delaySlider, 1, 0 ); | 62 | Layout3->addWidget( delaySlider, 1, 0 ); |
67 | 63 | ||
68 | delayText = new QLabel( GroupBox1, "delayText" ); | 64 | delayText = new QLabel( GroupBox1, "delayText" ); |
69 | delayText->setMinimumSize( QSize( 25, 0 ) ); | 65 | delayText->setMinimumSize( QSize( 25, 0 ) ); |
70 | delayText->setText( tr( "s" ) ); | 66 | delayText->setText( tr( "s" ) ); |
71 | delayText->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); | 67 | delayText->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); |
72 | 68 | ||
73 | Layout3->addWidget( delayText, 1, 1 ); | 69 | Layout3->addWidget( delayText, 1, 1 ); |
74 | GroupBox1Layout->addLayout( Layout3 ); | 70 | GroupBox1Layout->addLayout( Layout3 ); |
75 | 71 | ||
76 | repeatCheck = new QCheckBox( GroupBox1, "repeatCheck" ); | 72 | repeatCheck = new QCheckBox( GroupBox1, "repeatCheck" ); |
77 | repeatCheck->setText( tr( "Repeat slideshow" ) ); | 73 | repeatCheck->setText( tr( "Repeat slideshow" ) ); |
78 | GroupBox1Layout->addWidget( repeatCheck ); | 74 | GroupBox1Layout->addWidget( repeatCheck ); |
79 | 75 | ||
80 | reverseCheck = new QCheckBox( GroupBox1, "reverseCheck" ); | 76 | reverseCheck = new QCheckBox( GroupBox1, "reverseCheck" ); |
81 | reverseCheck->setText( tr( "Show pictures in reverse" ) ); | 77 | reverseCheck->setText( tr( "Show pictures in reverse" ) ); |
82 | GroupBox1Layout->addWidget( reverseCheck ); | 78 | GroupBox1Layout->addWidget( reverseCheck ); |
83 | SettingsDialogBaseLayout->addWidget( GroupBox1 ); | 79 | SettingsDialogBaseLayout->addWidget( GroupBox1 ); |
84 | 80 | ||
85 | rotateCheck = new QCheckBox( this, "rotateCheck" ); | 81 | rotateCheck = new QCheckBox( this, "rotateCheck" ); |
86 | rotateCheck->setText( tr( "Load pictures rotated 90 degrees" ) ); | 82 | rotateCheck->setText( tr( "Load pictures rotated 90 degrees" ) ); |
87 | SettingsDialogBaseLayout->addWidget( rotateCheck ); | 83 | SettingsDialogBaseLayout->addWidget( rotateCheck ); |
88 | 84 | ||
89 | fastLoadCheck = new QCheckBox( this, "fastLoadCheck" ); | 85 | fastLoadCheck = new QCheckBox( this, "fastLoadCheck" ); |
90 | fastLoadCheck->setText( tr( "Fast load pictures" ) ); | 86 | fastLoadCheck->setText( tr( "Fast load pictures" ) ); |
91 | SettingsDialogBaseLayout->addWidget( fastLoadCheck ); | 87 | SettingsDialogBaseLayout->addWidget( fastLoadCheck ); |
92 | fastLoadCheck->hide(); //FIXME | 88 | fastLoadCheck->hide(); //FIXME |
93 | // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); | 89 | // QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); |
94 | // layout->addItem( spacer, 10, 0 ); | 90 | // layout->addItem( spacer, 10, 0 ); |
95 | 91 | ||
96 | 92 | ||
97 | } | 93 | } |
98 | 94 | ||
99 | /* | 95 | /* |
100 | * Destroys the object and frees any allocated resources | 96 | * Destroys the object and frees any allocated resources |
101 | */ | 97 | */ |
102 | SettingsDialogBase::~SettingsDialogBase() | 98 | SettingsDialogBase::~SettingsDialogBase() |
103 | { | 99 | { |
104 | // no need to delete child widgets, Qt does it all for us | 100 | // no need to delete child widgets, Qt does it all for us |
105 | } | 101 | } |
106 | 102 | ||
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 02a1d91..82eac33 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -1,1251 +1,1238 @@ | |||
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 <opie/ofiledialog.h> | 30 | #include <opie/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/fileselector.h> | ||
36 | #include <qpe/applnk.h> | ||
37 | #include <qfileinfo.h> | ||
38 | #include <math.h> | 35 | #include <math.h> |
39 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
40 | #include <qwidgetstack.h> | ||
41 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
42 | #include <qaction.h> | 38 | #include <qaction.h> |
43 | #include <qfiledialog.h> | 39 | #include <qfiledialog.h> |
44 | #include <qmessagebox.h> | ||
45 | #include <qpopupmenu.h> | ||
46 | #include <qscrollview.h> | ||
47 | #include <qlabel.h> | ||
48 | #include <qpainter.h> | ||
49 | #include <qkeycode.h> | ||
50 | #include <qapplication.h> | ||
51 | #include <qclipboard.h> | ||
52 | #include <qtimer.h> | ||
53 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
54 | 41 | ||
55 | 42 | ||
56 | 43 | ||
57 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) | 44 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) |
58 | : QDialog(parent,0,true) | 45 | : QDialog(parent,0,true) |
59 | { | 46 | { |
60 | setCaption(caption); | 47 | setCaption(caption); |
61 | 48 | ||
62 | if ( parent ) { | 49 | if ( parent ) { |
63 | setPalette(parent->palette()); | 50 | setPalette(parent->palette()); |
64 | } | 51 | } |
65 | 52 | ||
66 | b=brightness; | 53 | b=brightness; |
67 | img=image; | 54 | img=image; |
68 | 55 | ||
69 | setMinimumSize(140,80); | 56 | setMinimumSize(140,80); |
70 | 57 | ||
71 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); | 58 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); |
72 | 59 | ||
73 | pixmap =new ImageWidget(this);; | 60 | pixmap =new ImageWidget(this);; |
74 | QPixmap pm; | 61 | QPixmap pm; |
75 | pm.convertFromImage(img); | 62 | pm.convertFromImage(img); |
76 | pixmap->setPixmap(pm); | 63 | pixmap->setPixmap(pm); |
77 | pixmap->setMinimumSize(pm.width(),pm.height()); | 64 | pixmap->setMinimumSize(pm.width(),pm.height()); |
78 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); | 65 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); |
79 | QLabel *l=new QLabel(tr("Brightness")+":",this); | 66 | QLabel *l=new QLabel(tr("Brightness")+":",this); |
80 | gl->addWidget(l,1,0,AlignLeft); | 67 | gl->addWidget(l,1,0,AlignLeft); |
81 | spb=new QSpinBox(-100,100,2,this); | 68 | spb=new QSpinBox(-100,100,2,this); |
82 | gl->addWidget(spb,1,1,AlignRight); | 69 | gl->addWidget(spb,1,1,AlignRight); |
83 | 70 | ||
84 | spb->setValue(0); | 71 | spb->setValue(0); |
85 | 72 | ||
86 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); | 73 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); |
87 | 74 | ||
88 | } | 75 | } |
89 | 76 | ||
90 | void ControlsDialog::bValueChanged(int value) | 77 | void ControlsDialog::bValueChanged(int value) |
91 | { | 78 | { |
92 | QImage nImage=img; | 79 | QImage nImage=img; |
93 | nImage.detach(); | 80 | nImage.detach(); |
94 | ImageViewer::intensity(nImage, (float)value/100); | 81 | ImageViewer::intensity(nImage, (float)value/100); |
95 | QPixmap pm; | 82 | QPixmap pm; |
96 | pm.convertFromImage(nImage); | 83 | pm.convertFromImage(nImage); |
97 | pixmap->setPixmap(pm); | 84 | pixmap->setPixmap(pm); |
98 | pixmap->repaint(false); | 85 | pixmap->repaint(false); |
99 | 86 | ||
100 | 87 | ||
101 | } | 88 | } |
102 | 89 | ||
103 | void ControlsDialog::accept() | 90 | void ControlsDialog::accept() |
104 | { | 91 | { |
105 | *b=spb->value(); | 92 | *b=spb->value(); |
106 | done(1); | 93 | done(1); |
107 | } | 94 | } |
108 | 95 | ||
109 | //=========================================================================== | 96 | //=========================================================================== |
110 | 97 | ||
111 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) | 98 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) |
112 | : QDialog(parent,0,true) | 99 | : QDialog(parent,0,true) |
113 | { | 100 | { |
114 | setCaption(caption); | 101 | setCaption(caption); |
115 | 102 | ||
116 | if ( parent ) | 103 | if ( parent ) |
117 | { | 104 | { |
118 | setPalette(parent->palette()); | 105 | setPalette(parent->palette()); |
119 | } | 106 | } |
120 | 107 | ||
121 | 108 | ||
122 | 109 | ||
123 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; | 110 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; |
124 | 111 | ||
125 | setMinimumSize(180,80); | 112 | setMinimumSize(180,80); |
126 | int num=ImageViewer::LAST+1; | 113 | int num=ImageViewer::LAST+1; |
127 | if ( text[ImageViewer::ALPHA].isEmpty() ) | 114 | if ( text[ImageViewer::ALPHA].isEmpty() ) |
128 | num--; | 115 | num--; |
129 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); | 116 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); |
130 | QLabel *l; | 117 | QLabel *l; |
131 | int count=0; | 118 | int count=0; |
132 | for ( int i=0;i<num;i++ ) | 119 | for ( int i=0;i<num;i++ ) |
133 | { | 120 | { |
134 | if ( i==1 ) | 121 | if ( i==1 ) |
135 | { | 122 | { |
136 | QFrame *frm=new QFrame(this); | 123 | QFrame *frm=new QFrame(this); |
137 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); | 124 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); |
138 | gl->addMultiCellWidget(frm,i,i,0,1); | 125 | gl->addMultiCellWidget(frm,i,i,0,1); |
139 | } | 126 | } |
140 | else | 127 | else |
141 | { | 128 | { |
142 | l=new QLabel( tr( labels[count] )+":",this); | 129 | l=new QLabel( tr( labels[count] )+":",this); |
143 | gl->addWidget(l,i,0,AlignLeft); | 130 | gl->addWidget(l,i,0,AlignLeft); |
144 | l=new QLabel(text[count],this); | 131 | l=new QLabel(text[count],this); |
145 | gl->addWidget(l,i,1,AlignRight); | 132 | gl->addWidget(l,i,1,AlignRight); |
146 | count++; | 133 | count++; |
147 | } | 134 | } |
148 | 135 | ||
149 | } | 136 | } |
150 | 137 | ||
151 | } | 138 | } |
152 | 139 | ||
153 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) | 140 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) |
154 | { | 141 | { |
155 | InfoDialog *dlg=new InfoDialog(caption,text,parent); | 142 | InfoDialog *dlg=new InfoDialog(caption,text,parent); |
156 | dlg->exec(); | 143 | dlg->exec(); |
157 | delete dlg; | 144 | delete dlg; |
158 | } | 145 | } |
159 | 146 | ||
160 | //=========================================================================== | 147 | //=========================================================================== |
161 | 148 | ||
162 | 149 | ||
163 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 150 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
164 | { | 151 | { |
165 | vb = new QVBoxLayout( this ); | 152 | vb = new QVBoxLayout( this ); |
166 | 153 | ||
167 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); | 154 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); |
168 | pic=new ImageWidget(image); | 155 | pic=new ImageWidget(image); |
169 | image->addChild(pic); | 156 | image->addChild(pic); |
170 | 157 | ||
171 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 158 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
172 | 159 | ||
173 | vb->addWidget( image ); | 160 | vb->addWidget( image ); |
174 | 161 | ||
175 | } | 162 | } |
176 | 163 | ||
177 | void ImagePane::setPixmap( const QPixmap &pm ) | 164 | void ImagePane::setPixmap( const QPixmap &pm ) |
178 | { | 165 | { |
179 | pic->setPixmap( pm ); | 166 | pic->setPixmap( pm ); |
180 | pic->resize(pm.width(),pm.height()); | 167 | pic->resize(pm.width(),pm.height()); |
181 | image->updateScrollBars (); | 168 | image->updateScrollBars (); |
182 | pic->repaint(false); | 169 | pic->repaint(false); |
183 | } | 170 | } |
184 | 171 | ||
185 | void ImagePane::imageClicked() | 172 | void ImagePane::imageClicked() |
186 | { | 173 | { |
187 | emit clicked(); | 174 | emit clicked(); |
188 | } | 175 | } |
189 | //=========================================================================== | 176 | //=========================================================================== |
190 | /* | 177 | /* |
191 | Draws the portion of the scaled pixmap that needs to be updated | 178 | Draws the portion of the scaled pixmap that needs to be updated |
192 | */ | 179 | */ |
193 | 180 | ||
194 | void ImageWidget::paintEvent( QPaintEvent *e ) | 181 | void ImageWidget::paintEvent( QPaintEvent *e ) |
195 | { | 182 | { |
196 | QPainter painter(this); | 183 | QPainter painter(this); |
197 | 184 | ||
198 | painter.setClipRect(e->rect()); | 185 | painter.setClipRect(e->rect()); |
199 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); | 186 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); |
200 | 187 | ||
201 | if ( pixmap.size() != QSize( 0, 0 ) ) | 188 | if ( pixmap.size() != QSize( 0, 0 ) ) |
202 | { // is an image loaded? | 189 | { // is an image loaded? |
203 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 190 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
204 | } | 191 | } |
205 | } | 192 | } |
206 | 193 | ||
207 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 194 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
208 | { | 195 | { |
209 | emit clicked(); | 196 | emit clicked(); |
210 | } | 197 | } |
211 | 198 | ||
212 | //=========================================================================== | 199 | //=========================================================================== |
213 | 200 | ||
214 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | 201 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) |
215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) | 202 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
216 | { | 203 | { |
217 | setCaption( tr("Image Viewer") ); | 204 | setCaption( tr("Image Viewer") ); |
218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 205 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
219 | 206 | ||
220 | 207 | ||
221 | Config cfg("Image Viewer"); | 208 | Config cfg("Image Viewer"); |
222 | cfg.setGroup("Image Viewer"); | 209 | cfg.setGroup("Image Viewer"); |
223 | 210 | ||
224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 211 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
225 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 212 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
226 | 213 | ||
227 | isFullScreen = FALSE; | 214 | isFullScreen = FALSE; |
228 | 215 | ||
229 | setToolBarsMovable( FALSE ); | 216 | setToolBarsMovable( FALSE ); |
230 | 217 | ||
231 | toolBar = new QToolBar( this ); | 218 | toolBar = new QToolBar( this ); |
232 | toolBar->setHorizontalStretchable( TRUE ); | 219 | toolBar->setHorizontalStretchable( TRUE ); |
233 | 220 | ||
234 | menuBar = new QMenuBar( toolBar ); | 221 | menuBar = new QMenuBar( toolBar ); |
235 | 222 | ||
236 | current=menuBar; | 223 | current=menuBar; |
237 | 224 | ||
238 | 225 | ||
239 | 226 | ||
240 | fileMenuFile = new QPopupMenu(this); | 227 | fileMenuFile = new QPopupMenu(this); |
241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 228 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
242 | fileMenuFile->insertItem(tr("Open"), | 229 | fileMenuFile->insertItem(tr("Open"), |
243 | this, SLOT(openFile()), 0); | 230 | this, SLOT(openFile()), 0); |
244 | 231 | ||
245 | viewMenuFile = new QPopupMenu( this ); | 232 | viewMenuFile = new QPopupMenu( this ); |
246 | //menubarFile->insertItem( tr("View"), viewMenu ); | 233 | //menubarFile->insertItem( tr("View"), viewMenu ); |
247 | viewMenuFile->insertItem( tr("Thumbnail View"), | 234 | viewMenuFile->insertItem( tr("Thumbnail View"), |
248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 235 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
249 | 236 | ||
250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 237 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
251 | 238 | ||
252 | 239 | ||
253 | 240 | ||
254 | 241 | ||
255 | optionsMenuFile = new QPopupMenu( this); | 242 | optionsMenuFile = new QPopupMenu( this); |
256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 243 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 244 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
258 | QString::null, 0, this, 0 ); | 245 | QString::null, 0, this, 0 ); |
259 | slideAction->setToggleAction( TRUE ); | 246 | slideAction->setToggleAction( TRUE ); |
260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 247 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
261 | slideAction->addTo( optionsMenuFile); | 248 | slideAction->addTo( optionsMenuFile); |
262 | // slideAction->addTo( toolBar ); | 249 | // slideAction->addTo( toolBar ); |
263 | 250 | ||
264 | 251 | ||
265 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 252 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
266 | optionsMenuFile->insertSeparator(); | 253 | optionsMenuFile->insertSeparator(); |
267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 254 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 255 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
269 | 256 | ||
270 | QStrList fmt = QImage::outputFormats(); | 257 | QStrList fmt = QImage::outputFormats(); |
271 | 258 | ||
272 | 259 | ||
273 | fileMenuView = new QPopupMenu( this ); | 260 | fileMenuView = new QPopupMenu( this ); |
274 | //menubarView->insertItem( tr("File"),fileMenu ); | 261 | //menubarView->insertItem( tr("File"),fileMenu ); |
275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 262 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
276 | fileMenuView->insertSeparator(); | 263 | fileMenuView->insertSeparator(); |
277 | 264 | ||
278 | viewMenuView = new QPopupMenu(this ); | 265 | viewMenuView = new QPopupMenu(this ); |
279 | viewMenuView->setCheckable ( true ); | 266 | viewMenuView->setCheckable ( true ); |
280 | 267 | ||
281 | //menubarView->insertItem( tr("View"),viewMenu ); | 268 | //menubarView->insertItem( tr("View"),viewMenu ); |
282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 269 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 270 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
284 | 271 | ||
285 | stack = new QWidgetStack( this ); | 272 | stack = new QWidgetStack( this ); |
286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 273 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
287 | setCentralWidget( stack ); | 274 | setCentralWidget( stack ); |
288 | 275 | ||
289 | 276 | ||
290 | imagePanel = new ImagePane( stack ); | 277 | imagePanel = new ImagePane( stack ); |
291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 278 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
292 | 279 | ||
293 | 280 | ||
294 | ImageFileSelector::CURRENT_VIEW cv; | 281 | ImageFileSelector::CURRENT_VIEW cv; |
295 | if(showThumbView) | 282 | if(showThumbView) |
296 | cv=ImageFileSelector::THUMBNAIL; | 283 | cv=ImageFileSelector::THUMBNAIL; |
297 | else | 284 | else |
298 | cv=ImageFileSelector::DETAILED; | 285 | cv=ImageFileSelector::DETAILED; |
299 | 286 | ||
300 | qDebug("cv = %d",cv); | 287 | qDebug("cv = %d",cv); |
301 | 288 | ||
302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 289 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
303 | 290 | ||
304 | //switchThumbView(); | 291 | //switchThumbView(); |
305 | 292 | ||
306 | 293 | ||
307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 294 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
308 | //fileSelector->setNewVisible(FALSE); | 295 | //fileSelector->setNewVisible(FALSE); |
309 | //fileSelector->setCloseVisible(FALSE); | 296 | //fileSelector->setCloseVisible(FALSE); |
310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 297 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
311 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), | 298 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), |
312 | this, SLOT( openFile(const DocLnk&) ) ); | 299 | this, SLOT( openFile(const DocLnk&) ) ); |
313 | 300 | ||
314 | imageList = fileSelector->fileList(); | 301 | imageList = fileSelector->fileList(); |
315 | slideAction->setEnabled( imageList.count() != 0); | 302 | slideAction->setEnabled( imageList.count() != 0); |
316 | 303 | ||
317 | iconToolBar = new QToolBar(this); | 304 | iconToolBar = new QToolBar(this); |
318 | 305 | ||
319 | QAction *a; | 306 | QAction *a; |
320 | 307 | ||
321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 308 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 309 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
323 | a->addTo( fileMenuView); | 310 | a->addTo( fileMenuView); |
324 | a->addTo( iconToolBar ); | 311 | a->addTo( iconToolBar ); |
325 | 312 | ||
326 | 313 | ||
327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 314 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 315 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
329 | a->addTo( iconToolBar ); | 316 | a->addTo( iconToolBar ); |
330 | a->addTo( viewMenuView ); | 317 | a->addTo( viewMenuView ); |
331 | 318 | ||
332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 319 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 320 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
334 | a->addTo( iconToolBar ); | 321 | a->addTo( iconToolBar ); |
335 | a->addTo( viewMenuView ); | 322 | a->addTo( viewMenuView ); |
336 | 323 | ||
337 | 324 | ||
338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); | 325 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); |
339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 326 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
340 | //a->addTo( iconToolBar ); | 327 | //a->addTo( iconToolBar ); |
341 | a->addTo( viewMenuView ); | 328 | a->addTo( viewMenuView ); |
342 | 329 | ||
343 | 330 | ||
344 | 331 | ||
345 | viewMenuView->insertSeparator(); | 332 | viewMenuView->insertSeparator(); |
346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 333 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 334 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
348 | viewMenuView->insertSeparator(); | 335 | viewMenuView->insertSeparator(); |
349 | 336 | ||
350 | 337 | ||
351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 338 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 339 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
353 | sss->addTo( iconToolBar ); | 340 | sss->addTo( iconToolBar ); |
354 | sss->addTo( viewMenuView ); | 341 | sss->addTo( viewMenuView ); |
355 | 342 | ||
356 | sss->setOn(isSized); | 343 | sss->setOn(isSized); |
357 | viewMenuView->insertSeparator(); | 344 | viewMenuView->insertSeparator(); |
358 | 345 | ||
359 | 346 | ||
360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 347 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
361 | QString::null, 0, this, 0 ); | 348 | QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 349 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
363 | a->addTo( iconToolBar ); | 350 | a->addTo( iconToolBar ); |
364 | a->addTo( viewMenuView); | 351 | a->addTo( viewMenuView); |
365 | 352 | ||
366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 353 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
367 | QString::null, 0, this, 0 ); | 354 | QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 355 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
369 | a->addTo( iconToolBar ); | 356 | a->addTo( iconToolBar ); |
370 | a->addTo( viewMenuView); | 357 | a->addTo( viewMenuView); |
371 | 358 | ||
372 | 359 | ||
373 | Config config( "ImageViewer" ); | 360 | Config config( "ImageViewer" ); |
374 | config.setGroup( "SlideShow" ); | 361 | config.setGroup( "SlideShow" ); |
375 | slideDelay = config.readNumEntry( "Delay", 2); | 362 | slideDelay = config.readNumEntry( "Delay", 2); |
376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 363 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
377 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 364 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
378 | 365 | ||
379 | config.setGroup("Default"); | 366 | config.setGroup("Default"); |
380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 367 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 368 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
382 | slideTimer = new QTimer( this ); | 369 | slideTimer = new QTimer( this ); |
383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 370 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
384 | 371 | ||
385 | switchToFileSelector(); | 372 | switchToFileSelector(); |
386 | 373 | ||
387 | setMouseTracking( TRUE ); | 374 | setMouseTracking( TRUE ); |
388 | 375 | ||
389 | 376 | ||
390 | } | 377 | } |
391 | 378 | ||
392 | ImageViewer::~ImageViewer() | 379 | ImageViewer::~ImageViewer() |
393 | { | 380 | { |
394 | Config cfg("Image Viewer"); | 381 | Config cfg("Image Viewer"); |
395 | cfg.setGroup("Image Viewer"); | 382 | cfg.setGroup("Image Viewer"); |
396 | 383 | ||
397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 384 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
398 | cfg.writeEntry("SizeToScreen",(int)isSized); | 385 | cfg.writeEntry("SizeToScreen",(int)isSized); |
399 | 386 | ||
400 | cfg.setGroup( "SlideShow" ); | 387 | cfg.setGroup( "SlideShow" ); |
401 | cfg.writeEntry( "Delay", slideDelay); | 388 | cfg.writeEntry( "Delay", slideDelay); |
402 | cfg.writeEntry( "Repeat", slideRepeat ); | 389 | cfg.writeEntry( "Repeat", slideRepeat ); |
403 | cfg.writeEntry("Reverse", slideReverse); | 390 | cfg.writeEntry("Reverse", slideReverse); |
404 | 391 | ||
405 | cfg.setGroup("Default"); | 392 | cfg.setGroup("Default"); |
406 | cfg.writeEntry("Rotate", rotateOnLoad); | 393 | cfg.writeEntry("Rotate", rotateOnLoad); |
407 | cfg.writeEntry("FastLoad", fastLoad); | 394 | cfg.writeEntry("FastLoad", fastLoad); |
408 | 395 | ||
409 | delete imagePanel; // in case it is fullscreen | 396 | delete imagePanel; // in case it is fullscreen |
410 | } | 397 | } |
411 | 398 | ||
412 | void ImageViewer::help() { | 399 | void ImageViewer::help() { |
413 | 400 | ||
414 | } | 401 | } |
415 | 402 | ||
416 | 403 | ||
417 | void ImageViewer::settings() | 404 | void ImageViewer::settings() |
418 | { | 405 | { |
419 | SettingsDialog dlg( this, 0, TRUE ); | 406 | SettingsDialog dlg( this, 0, TRUE ); |
420 | dlg.setDelay( slideDelay ); | 407 | dlg.setDelay( slideDelay ); |
421 | dlg.setRepeat( slideRepeat ); | 408 | dlg.setRepeat( slideRepeat ); |
422 | dlg.setReverse( slideReverse ); | 409 | dlg.setReverse( slideReverse ); |
423 | dlg.setRotate(rotateOnLoad); | 410 | dlg.setRotate(rotateOnLoad); |
424 | dlg.setFastLoad(fastLoad); | 411 | dlg.setFastLoad(fastLoad); |
425 | 412 | ||
426 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 413 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
427 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 414 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
428 | slideDelay = dlg.delay(); | 415 | slideDelay = dlg.delay(); |
429 | slideRepeat = dlg.repeat(); | 416 | slideRepeat = dlg.repeat(); |
430 | slideReverse = dlg.reverse(); | 417 | slideReverse = dlg.reverse(); |
431 | rotateOnLoad = dlg.rotate(); | 418 | rotateOnLoad = dlg.rotate(); |
432 | fastLoad = dlg.fastLoad(); | 419 | fastLoad = dlg.fastLoad(); |
433 | 420 | ||
434 | Config config( "ImageViewer" ); | 421 | Config config( "ImageViewer" ); |
435 | config.setGroup( "SlideShow" ); | 422 | config.setGroup( "SlideShow" ); |
436 | config.writeEntry( "Delay", slideDelay ); | 423 | config.writeEntry( "Delay", slideDelay ); |
437 | config.writeEntry( "Repeat", slideRepeat ); | 424 | config.writeEntry( "Repeat", slideRepeat ); |
438 | config.writeEntry("Reverse", slideReverse); | 425 | config.writeEntry("Reverse", slideReverse); |
439 | 426 | ||
440 | config.setGroup("Default"); | 427 | config.setGroup("Default"); |
441 | config.writeEntry("Rotate", rotateOnLoad); | 428 | config.writeEntry("Rotate", rotateOnLoad); |
442 | config.writeEntry("FastLoad", fastLoad); | 429 | config.writeEntry("FastLoad", fastLoad); |
443 | } | 430 | } |
444 | } | 431 | } |
445 | 432 | ||
446 | void ImageViewer::switchSizeToScreen() | 433 | void ImageViewer::switchSizeToScreen() |
447 | { | 434 | { |
448 | isSized=!isSized; | 435 | isSized=!isSized; |
449 | sss->setOn(isSized); | 436 | sss->setOn(isSized); |
450 | updateImage(); | 437 | updateImage(); |
451 | } | 438 | } |
452 | 439 | ||
453 | void ImageViewer::updateImage() | 440 | void ImageViewer::updateImage() |
454 | { | 441 | { |
455 | if ( isSized ) { | 442 | if ( isSized ) { |
456 | imagePanel->setPixmap(pmScaled); | 443 | imagePanel->setPixmap(pmScaled); |
457 | } else { | 444 | } else { |
458 | imagePanel->setPixmap(pm); | 445 | imagePanel->setPixmap(pm); |
459 | } | 446 | } |
460 | } | 447 | } |
461 | 448 | ||
462 | void ImageViewer::switchThumbView() | 449 | void ImageViewer::switchThumbView() |
463 | { | 450 | { |
464 | 451 | ||
465 | showThumbView=!showThumbView; | 452 | showThumbView=!showThumbView; |
466 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 453 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
467 | fileSelector->switchView(); | 454 | fileSelector->switchView(); |
468 | 455 | ||
469 | } | 456 | } |
470 | 457 | ||
471 | void ImageViewer::switchToFileSelector() | 458 | void ImageViewer::switchToFileSelector() |
472 | { | 459 | { |
473 | stack->raiseWidget(fileSelector); | 460 | stack->raiseWidget(fileSelector); |
474 | menuBar->clear(); | 461 | menuBar->clear(); |
475 | menuBar->insertItem( tr("File"), fileMenuFile ); | 462 | menuBar->insertItem( tr("File"), fileMenuFile ); |
476 | menuBar->insertItem( tr("View"), viewMenuFile ); | 463 | menuBar->insertItem( tr("View"), viewMenuFile ); |
477 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 464 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
478 | iconToolBar->hide(); | 465 | iconToolBar->hide(); |
479 | imagePanel->disable(); | 466 | imagePanel->disable(); |
480 | slideShow(false); | 467 | slideShow(false); |
481 | 468 | ||
482 | } | 469 | } |
483 | 470 | ||
484 | void ImageViewer::switchToImageView() | 471 | void ImageViewer::switchToImageView() |
485 | { | 472 | { |
486 | stack->raiseWidget(imagePanel); | 473 | stack->raiseWidget(imagePanel); |
487 | 474 | ||
488 | menuBar->clear(); | 475 | menuBar->clear(); |
489 | menuBar->insertItem( tr("File"), fileMenuView ); | 476 | menuBar->insertItem( tr("File"), fileMenuView ); |
490 | menuBar->insertItem( tr("View"), viewMenuView ); | 477 | menuBar->insertItem( tr("View"), viewMenuView ); |
491 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); | 478 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); |
492 | iconToolBar->show(); | 479 | iconToolBar->show(); |
493 | 480 | ||
494 | imagePanel->setPosition(0,0); | 481 | imagePanel->setPosition(0,0); |
495 | 482 | ||
496 | } | 483 | } |
497 | 484 | ||
498 | 485 | ||
499 | void ImageViewer::setDocument(const QString& fileref) | 486 | void ImageViewer::setDocument(const QString& fileref) |
500 | { | 487 | { |
501 | delayLoad = fileref; | 488 | delayLoad = fileref; |
502 | switchToImageView(); | 489 | switchToImageView(); |
503 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 490 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
504 | } | 491 | } |
505 | 492 | ||
506 | void ImageViewer::doDelayedLoad() | 493 | void ImageViewer::doDelayedLoad() |
507 | { | 494 | { |
508 | show(delayLoad); | 495 | show(delayLoad); |
509 | } | 496 | } |
510 | 497 | ||
511 | void ImageViewer::show() | 498 | void ImageViewer::show() |
512 | { | 499 | { |
513 | normalView(); | 500 | normalView(); |
514 | QMainWindow::show(); | 501 | QMainWindow::show(); |
515 | } | 502 | } |
516 | 503 | ||
517 | void ImageViewer::show(const QString& fileref) | 504 | void ImageViewer::show(const QString& fileref) |
518 | { | 505 | { |
519 | // qDebug("Show "+fileref); | 506 | // qDebug("Show "+fileref); |
520 | bFromDocView = TRUE; | 507 | bFromDocView = TRUE; |
521 | closeFileSelector(); | 508 | closeFileSelector(); |
522 | DocLnk link(fileref); | 509 | DocLnk link(fileref); |
523 | if ( link.isValid() ) { | 510 | if ( link.isValid() ) { |
524 | openFile(link); | 511 | openFile(link); |
525 | } else { | 512 | } else { |
526 | filename = fileref; | 513 | filename = fileref; |
527 | updateCaption( fileref ); | 514 | updateCaption( fileref ); |
528 | loadImage( fileref ); | 515 | loadImage( fileref ); |
529 | } | 516 | } |
530 | } | 517 | } |
531 | 518 | ||
532 | void ImageViewer::openFile() { | 519 | void ImageViewer::openFile() { |
533 | MimeTypes types; | 520 | MimeTypes types; |
534 | QStringList image; | 521 | QStringList image; |
535 | image << "image/*"; | 522 | image << "image/*"; |
536 | types.insert("Images", image); | 523 | types.insert("Images", image); |
537 | 524 | ||
538 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 525 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
539 | DocLnk link(str); | 526 | DocLnk link(str); |
540 | // if ( link.isValid() ) | 527 | // if ( link.isValid() ) |
541 | openFile(link); | 528 | openFile(link); |
542 | 529 | ||
543 | } | 530 | } |
544 | 531 | ||
545 | void ImageViewer::openFile( const DocLnk &link ) | 532 | void ImageViewer::openFile( const DocLnk &link ) |
546 | { | 533 | { |
547 | closeFileSelector(); | 534 | closeFileSelector(); |
548 | // DocLnk link(file); | 535 | // DocLnk link(file); |
549 | qDebug("open "+link.name()); | 536 | qDebug("open "+link.name()); |
550 | updateCaption( link.name() ); | 537 | updateCaption( link.name() ); |
551 | loadImage( link.file() ); | 538 | loadImage( link.file() ); |
552 | if (slideTimer->isActive()) { | 539 | if (slideTimer->isActive()) { |
553 | slideTimer->start(slideDelay * 1000, FALSE); | 540 | slideTimer->start(slideDelay * 1000, FALSE); |
554 | } | 541 | } |
555 | 542 | ||
556 | } | 543 | } |
557 | 544 | ||
558 | void ImageViewer::open() | 545 | void ImageViewer::open() |
559 | { | 546 | { |
560 | switchToFileSelector(); | 547 | switchToFileSelector(); |
561 | } | 548 | } |
562 | 549 | ||
563 | void ImageViewer::closeFileSelector() | 550 | void ImageViewer::closeFileSelector() |
564 | { | 551 | { |
565 | switchToImageView(); | 552 | switchToImageView(); |
566 | } | 553 | } |
567 | 554 | ||
568 | void ImageViewer::updateCaption( QString name ) | 555 | void ImageViewer::updateCaption( QString name ) |
569 | { | 556 | { |
570 | int sep = name.findRev( '/' ); | 557 | int sep = name.findRev( '/' ); |
571 | if ( sep >= 0 ) | 558 | if ( sep >= 0 ) |
572 | name = name.mid( sep+1 ); | 559 | name = name.mid( sep+1 ); |
573 | setCaption( name + tr(" - Image Viewer") ); | 560 | setCaption( name + tr(" - Image Viewer") ); |
574 | } | 561 | } |
575 | 562 | ||
576 | /* | 563 | /* |
577 | This function loads an image from a file. | 564 | This function loads an image from a file. |
578 | */ | 565 | */ |
579 | 566 | ||
580 | void ImageViewer::loadImage( const char *fileName ) | 567 | void ImageViewer::loadImage( const char *fileName ) |
581 | { | 568 | { |
582 | filename = fileName; | 569 | filename = fileName; |
583 | if ( filename ) { | 570 | if ( filename ) { |
584 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 571 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
585 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); | 572 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); |
586 | qApp->processEvents(); | 573 | qApp->processEvents(); |
587 | bool ok = image.load(filename, 0); | 574 | bool ok = image.load(filename, 0); |
588 | if ( ok ) { | 575 | if ( ok ) { |
589 | ok = reconvertImage(); | 576 | ok = reconvertImage(); |
590 | updateImageInfo(filename); | 577 | updateImageInfo(filename); |
591 | } | 578 | } |
592 | if ( !ok ) { | 579 | if ( !ok ) { |
593 | pm.resize(0,0); // couldn't load image | 580 | pm.resize(0,0); // couldn't load image |
594 | update(); | 581 | update(); |
595 | } | 582 | } |
596 | QApplication::restoreOverrideCursor(); // restore original cursor | 583 | QApplication::restoreOverrideCursor(); // restore original cursor |
597 | } | 584 | } |
598 | 585 | ||
599 | // fastLoad ? ", Fast" : "", | 586 | // fastLoad ? ", Fast" : "", |
600 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); | 587 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); |
601 | 588 | ||
602 | 589 | ||
603 | // matrix.reset(); | 590 | // matrix.reset(); |
604 | rotated90 = FALSE; | 591 | rotated90 = FALSE; |
605 | 592 | ||
606 | if (rotateOnLoad) { | 593 | if (rotateOnLoad) { |
607 | rotated90 = TRUE; | 594 | rotated90 = TRUE; |
608 | rot90(); | 595 | rot90(); |
609 | // matrix.rotate( -90.0 ); | 596 | // matrix.rotate( -90.0 ); |
610 | } | 597 | } |
611 | 598 | ||
612 | switchToImageView(); | 599 | switchToImageView(); |
613 | updateImage(); | 600 | updateImage(); |
614 | 601 | ||
615 | } | 602 | } |
616 | 603 | ||
617 | bool ImageViewer::loadSelected() | 604 | bool ImageViewer::loadSelected() |
618 | { | 605 | { |
619 | bool ok = false; | 606 | bool ok = false; |
620 | if ( stack->visibleWidget() == fileSelector ) | 607 | if ( stack->visibleWidget() == fileSelector ) |
621 | { | 608 | { |
622 | const DocLnk *link = fileSelector->selected(); | 609 | const DocLnk *link = fileSelector->selected(); |
623 | if ( link ) | 610 | if ( link ) |
624 | { | 611 | { |
625 | if ( link->file() != filename ) | 612 | if ( link->file() != filename ) |
626 | { | 613 | { |
627 | updateCaption( link->name() ); | 614 | updateCaption( link->name() ); |
628 | filename = link->file(); | 615 | filename = link->file(); |
629 | qApp->processEvents(); | 616 | qApp->processEvents(); |
630 | ok = image.load(filename, 0); | 617 | ok = image.load(filename, 0); |
631 | if ( ok ) | 618 | if ( ok ) |
632 | { | 619 | { |
633 | updateImageInfo(filename); | 620 | updateImageInfo(filename); |
634 | ok = reconvertImage(); | 621 | ok = reconvertImage(); |
635 | } | 622 | } |
636 | if ( !ok ) | 623 | if ( !ok ) |
637 | pm.resize(0,0); | 624 | pm.resize(0,0); |
638 | } | 625 | } |
639 | } | 626 | } |
640 | } | 627 | } |
641 | if ( !image.isNull() ) | 628 | if ( !image.isNull() ) |
642 | { | 629 | { |
643 | ok = true; | 630 | ok = true; |
644 | closeFileSelector(); | 631 | closeFileSelector(); |
645 | } | 632 | } |
646 | 633 | ||
647 | return ok; | 634 | return ok; |
648 | } | 635 | } |
649 | 636 | ||
650 | bool ImageViewer::reconvertImage() | 637 | bool ImageViewer::reconvertImage() |
651 | { | 638 | { |
652 | bool success = FALSE; | 639 | bool success = FALSE; |
653 | 640 | ||
654 | if ( image.isNull() ) return FALSE; | 641 | if ( image.isNull() ) return FALSE; |
655 | 642 | ||
656 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 643 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
657 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) | 644 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) |
658 | { | 645 | { |
659 | pmScaled = QPixmap(); | 646 | pmScaled = QPixmap(); |
660 | scale(); | 647 | scale(); |
661 | success = TRUE; // load successful | 648 | success = TRUE; // load successful |
662 | } | 649 | } |
663 | else | 650 | else |
664 | { | 651 | { |
665 | pm.resize(0,0); // couldn't load image | 652 | pm.resize(0,0); // couldn't load image |
666 | } | 653 | } |
667 | QApplication::restoreOverrideCursor(); // restore original cursor | 654 | QApplication::restoreOverrideCursor(); // restore original cursor |
668 | 655 | ||
669 | return success; // TRUE if loaded OK | 656 | return success; // TRUE if loaded OK |
670 | } | 657 | } |
671 | 658 | ||
672 | 659 | ||
673 | int ImageViewer::calcHeight() | 660 | int ImageViewer::calcHeight() |
674 | { | 661 | { |
675 | if ( !isFullScreen ) | 662 | if ( !isFullScreen ) |
676 | return imagePanel->paneHeight(); | 663 | return imagePanel->paneHeight(); |
677 | else | 664 | else |
678 | return qApp->desktop()->height(); | 665 | return qApp->desktop()->height(); |
679 | } | 666 | } |
680 | /* | 667 | /* |
681 | This functions scales the pixmap in the member variable "pm" to fit the | 668 | This functions scales the pixmap in the member variable "pm" to fit the |
682 | widget size and puts the resulting pixmap in the member variable "pmScaled". | 669 | widget size and puts the resulting pixmap in the member variable "pmScaled". |
683 | */ | 670 | */ |
684 | void ImageViewer::scale() | 671 | void ImageViewer::scale() |
685 | { | 672 | { |
686 | int h = calcHeight(); | 673 | int h = calcHeight(); |
687 | if ( image.isNull() ) return; | 674 | if ( image.isNull() ) return; |
688 | 675 | ||
689 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 676 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
690 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) | 677 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) |
691 | { // no need to scale if widget | 678 | { // no need to scale if widget |
692 | pmScaled = pm; // size equals pixmap size | 679 | pmScaled = pm; // size equals pixmap size |
693 | } | 680 | } |
694 | else | 681 | else |
695 | { | 682 | { |
696 | double hs = (double)h / (double)image.height(); | 683 | double hs = (double)h / (double)image.height(); |
697 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); | 684 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); |
698 | double scaleFactor = (hs > ws) ? ws : hs; | 685 | double scaleFactor = (hs > ws) ? ws : hs; |
699 | int smoothW = (int)(scaleFactor * image.width()); | 686 | int smoothW = (int)(scaleFactor * image.width()); |
700 | int smoothH = (int)(scaleFactor * image.height()); | 687 | int smoothH = (int)(scaleFactor * image.height()); |
701 | 688 | ||
702 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); | 689 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); |
703 | } | 690 | } |
704 | QApplication::restoreOverrideCursor(); // restore original cursor | 691 | QApplication::restoreOverrideCursor(); // restore original cursor |
705 | } | 692 | } |
706 | 693 | ||
707 | /* | 694 | /* |
708 | The resize event handler, if a valid pixmap was loaded it will call | 695 | The resize event handler, if a valid pixmap was loaded it will call |
709 | scale() to fit the pixmap to the new widget size. | 696 | scale() to fit the pixmap to the new widget size. |
710 | */ | 697 | */ |
711 | 698 | ||
712 | void ImageViewer::resizeEvent( QResizeEvent * ) | 699 | void ImageViewer::resizeEvent( QResizeEvent * ) |
713 | { | 700 | { |
714 | 701 | ||
715 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image | 702 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image |
716 | return; | 703 | return; |
717 | 704 | ||
718 | int h = calcHeight(); | 705 | int h = calcHeight(); |
719 | 706 | ||
720 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) | 707 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) |
721 | { // if new size, | 708 | { // if new size, |
722 | scale(); // scale pmScaled to window | 709 | scale(); // scale pmScaled to window |
723 | } | 710 | } |
724 | if ( image.hasAlphaBuffer() ) | 711 | if ( image.hasAlphaBuffer() ) |
725 | erase(); | 712 | erase(); |
726 | } | 713 | } |
727 | 714 | ||
728 | 715 | ||
729 | void ImageViewer::hFlip() | 716 | void ImageViewer::hFlip() |
730 | { | 717 | { |
731 | // matrix.scale( -1.0, 1.0 ); | 718 | // matrix.scale( -1.0, 1.0 ); |
732 | 719 | ||
733 | setImage(image.mirror(TRUE,FALSE)); | 720 | setImage(image.mirror(TRUE,FALSE)); |
734 | } | 721 | } |
735 | 722 | ||
736 | void ImageViewer::vFlip() | 723 | void ImageViewer::vFlip() |
737 | { | 724 | { |
738 | // matrix.scale( 1.0, -1.0 ); | 725 | // matrix.scale( 1.0, -1.0 ); |
739 | setImage(image.mirror(FALSE,TRUE)); | 726 | setImage(image.mirror(FALSE,TRUE)); |
740 | } | 727 | } |
741 | 728 | ||
742 | void ImageViewer::rot180() | 729 | void ImageViewer::rot180() |
743 | { | 730 | { |
744 | // matrix.rotate( 180.0 ); | 731 | // matrix.rotate( 180.0 ); |
745 | setImage(image.mirror(TRUE,TRUE)); | 732 | setImage(image.mirror(TRUE,TRUE)); |
746 | } | 733 | } |
747 | 734 | ||
748 | void ImageViewer::rot90() | 735 | void ImageViewer::rot90() |
749 | { | 736 | { |
750 | QImage oldimage; | 737 | QImage oldimage; |
751 | oldimage = image.convertDepth(32); | 738 | oldimage = image.convertDepth(32); |
752 | // matrix.rotate( -90.0 ); | 739 | // matrix.rotate( -90.0 ); |
753 | setImage(rotate(oldimage,Rotate90)); | 740 | setImage(rotate(oldimage,Rotate90)); |
754 | 741 | ||
755 | } | 742 | } |
756 | void ImageViewer::rot270() | 743 | void ImageViewer::rot270() |
757 | { | 744 | { |
758 | 745 | ||
759 | QImage oldimage; | 746 | QImage oldimage; |
760 | oldimage = image.convertDepth(32); | 747 | oldimage = image.convertDepth(32); |
761 | // matrix.rotate(90.0); | 748 | // matrix.rotate(90.0); |
762 | setImage(rotate(oldimage,Rotate270)); | 749 | setImage(rotate(oldimage,Rotate270)); |
763 | 750 | ||
764 | } | 751 | } |
765 | 752 | ||
766 | void ImageViewer::blackAndWhite() | 753 | void ImageViewer::blackAndWhite() |
767 | { | 754 | { |
768 | 755 | ||
769 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); | 756 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); |
770 | setImage(toGray(image,false)); | 757 | setImage(toGray(image,false)); |
771 | } | 758 | } |
772 | 759 | ||
773 | void ImageViewer::displayControlsDialog() | 760 | void ImageViewer::displayControlsDialog() |
774 | { | 761 | { |
775 | int w=80; | 762 | int w=80; |
776 | int h=w; | 763 | int h=w; |
777 | QImage small; | 764 | QImage small; |
778 | 765 | ||
779 | if ( image.width()<w ||image.height()<h ) | 766 | if ( image.width()<w ||image.height()<h ) |
780 | small=image.smoothScale(w,h); | 767 | small=image.smoothScale(w,h); |
781 | else | 768 | else |
782 | small=image.copy(0,0,w,h); | 769 | small=image.copy(0,0,w,h); |
783 | 770 | ||
784 | int newB=0; | 771 | int newB=0; |
785 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); | 772 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); |
786 | dlg->exec(); | 773 | dlg->exec(); |
787 | if ( newB ) { | 774 | if ( newB ) { |
788 | intensity(image,(float)newB/100); | 775 | intensity(image,(float)newB/100); |
789 | setImage(image); | 776 | setImage(image); |
790 | } | 777 | } |
791 | 778 | ||
792 | } | 779 | } |
793 | 780 | ||
794 | 781 | ||
795 | void ImageViewer::displayInfoDialog() | 782 | void ImageViewer::displayInfoDialog() |
796 | { | 783 | { |
797 | 784 | ||
798 | QStringList ls; | 785 | QStringList ls; |
799 | 786 | ||
800 | for ( int i=0;i<LAST;i++ ) | 787 | for ( int i=0;i<LAST;i++ ) |
801 | ls.append(imageInfo[i]); | 788 | ls.append(imageInfo[i]); |
802 | 789 | ||
803 | InfoDialog::displayInfo("Image Viewer",ls,this); | 790 | InfoDialog::displayInfo("Image Viewer",ls,this); |
804 | } | 791 | } |
805 | void ImageViewer::normalView() | 792 | void ImageViewer::normalView() |
806 | { | 793 | { |
807 | if ( !imagePanel->parentWidget() ) | 794 | if ( !imagePanel->parentWidget() ) |
808 | { | 795 | { |
809 | 796 | ||
810 | isFullScreen = FALSE; | 797 | isFullScreen = FALSE; |
811 | stack->addWidget( imagePanel, 1 ); | 798 | stack->addWidget( imagePanel, 1 ); |
812 | switchToImageView(); | 799 | switchToImageView(); |
813 | if ( isSized ) | 800 | if ( isSized ) |
814 | scale(); | 801 | scale(); |
815 | 802 | ||
816 | updateImage(); | 803 | updateImage(); |
817 | 804 | ||
818 | } | 805 | } |
819 | } | 806 | } |
820 | 807 | ||
821 | void ImageViewer::stopSlideShow() { | 808 | void ImageViewer::stopSlideShow() { |
822 | if (slideTimer->isActive()) | 809 | if (slideTimer->isActive()) |
823 | slideTimer->stop(); | 810 | slideTimer->stop(); |
824 | } | 811 | } |
825 | 812 | ||
826 | void ImageViewer::fullScreen() | 813 | void ImageViewer::fullScreen() |
827 | { | 814 | { |
828 | // Full-screen option | 815 | // Full-screen option |
829 | // contributed by Robert Wittams <robert@wittams.com> | 816 | // contributed by Robert Wittams <robert@wittams.com> |
830 | if ( imagePanel->parentWidget() && loadSelected() ) | 817 | if ( imagePanel->parentWidget() && loadSelected() ) |
831 | { | 818 | { |
832 | isFullScreen = TRUE; | 819 | isFullScreen = TRUE; |
833 | imagePanel->reparent(0,QPoint(0,0)); | 820 | imagePanel->reparent(0,QPoint(0,0)); |
834 | imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 821 | imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
835 | 822 | ||
836 | if ( isSized ) | 823 | if ( isSized ) |
837 | scale(); | 824 | scale(); |
838 | updateImage(); | 825 | updateImage(); |
839 | imagePanel->showFullScreen(); | 826 | imagePanel->showFullScreen(); |
840 | } | 827 | } |
841 | } | 828 | } |
842 | 829 | ||
843 | void ImageViewer::setImage(const QImage& newimage) | 830 | void ImageViewer::setImage(const QImage& newimage) |
844 | { | 831 | { |
845 | image = newimage; | 832 | image = newimage; |
846 | reconvertImage(); | 833 | reconvertImage(); |
847 | updateImage(); | 834 | updateImage(); |
848 | } | 835 | } |
849 | 836 | ||
850 | void ImageViewer::updateImageInfo(QString &filePath) | 837 | void ImageViewer::updateImageInfo(QString &filePath) |
851 | { | 838 | { |
852 | 839 | ||
853 | for ( int i=0;i<LAST;i++ ) | 840 | for ( int i=0;i<LAST;i++ ) |
854 | { | 841 | { |
855 | imageInfo[i]=""; | 842 | imageInfo[i]=""; |
856 | } | 843 | } |
857 | 844 | ||
858 | imageInfo[FORMAT]=QImage::imageFormat (filePath ); | 845 | imageInfo[FORMAT]=QImage::imageFormat (filePath ); |
859 | QFileInfo fi(filePath); | 846 | QFileInfo fi(filePath); |
860 | imageInfo[PATH]=fi.fileName(); | 847 | imageInfo[PATH]=fi.fileName(); |
861 | imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; | 848 | imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; |
862 | QString message("%1x%2"); | 849 | QString message("%1x%2"); |
863 | imageInfo[SIZE]=QString("%1x%2"); | 850 | imageInfo[SIZE]=QString("%1x%2"); |
864 | imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); | 851 | imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); |
865 | if ( image.numColors() > 0 ) | 852 | if ( image.numColors() > 0 ) |
866 | { | 853 | { |
867 | imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); | 854 | imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); |
868 | } | 855 | } |
869 | else if ( image.depth() >= 16 ) | 856 | else if ( image.depth() >= 16 ) |
870 | { | 857 | { |
871 | imageInfo[COLORS]=tr(" True color"); | 858 | imageInfo[COLORS]=tr(" True color"); |
872 | } | 859 | } |
873 | if ( image.hasAlphaBuffer() ) | 860 | if ( image.hasAlphaBuffer() ) |
874 | { | 861 | { |
875 | if ( image.depth() == 8 ) | 862 | if ( image.depth() == 8 ) |
876 | { | 863 | { |
877 | int i; | 864 | int i; |
878 | bool alpha[256]; | 865 | bool alpha[256]; |
879 | int nalpha=0; | 866 | int nalpha=0; |
880 | 867 | ||
881 | for ( i=0; i<256; i++ ) | 868 | for ( i=0; i<256; i++ ) |
882 | alpha[i] = FALSE; | 869 | alpha[i] = FALSE; |
883 | 870 | ||
884 | for ( i=0; i<image.numColors(); i++ ) | 871 | for ( i=0; i<image.numColors(); i++ ) |
885 | { | 872 | { |
886 | int alevel = image.color(i) >> 24; | 873 | int alevel = image.color(i) >> 24; |
887 | if ( !alpha[alevel] ) | 874 | if ( !alpha[alevel] ) |
888 | { | 875 | { |
889 | alpha[alevel] = TRUE; | 876 | alpha[alevel] = TRUE; |
890 | nalpha++; | 877 | nalpha++; |
891 | } | 878 | } |
892 | } | 879 | } |
893 | imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); | 880 | imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); |
894 | } | 881 | } |
895 | else | 882 | else |
896 | { | 883 | { |
897 | imageInfo[ALPHA]=tr("8-bit alpha channel"); | 884 | imageInfo[ALPHA]=tr("8-bit alpha channel"); |
898 | } | 885 | } |
899 | } | 886 | } |
900 | 887 | ||
901 | } | 888 | } |
902 | 889 | ||
903 | void ImageViewer::closeEvent( QCloseEvent *e ) | 890 | void ImageViewer::closeEvent( QCloseEvent *e ) |
904 | { | 891 | { |
905 | if ( stack->visibleWidget() == imagePanel && !bFromDocView ) | 892 | if ( stack->visibleWidget() == imagePanel && !bFromDocView ) |
906 | { | 893 | { |
907 | e->ignore(); | 894 | e->ignore(); |
908 | open(); | 895 | open(); |
909 | } | 896 | } |
910 | else | 897 | else |
911 | { | 898 | { |
912 | bFromDocView = FALSE; | 899 | bFromDocView = FALSE; |
913 | e->accept(); | 900 | e->accept(); |
914 | } | 901 | } |
915 | } | 902 | } |
916 | 903 | ||
917 | // Intensity,toGray and rotate code courtesy of KDE project. | 904 | // Intensity,toGray and rotate code courtesy of KDE project. |
918 | 905 | ||
919 | 906 | ||
920 | QImage& ImageViewer::intensity(QImage &image, float percent) | 907 | QImage& ImageViewer::intensity(QImage &image, float percent) |
921 | { | 908 | { |
922 | 909 | ||
923 | int segColors = image.depth() > 8 ? 256 : image.numColors(); | 910 | int segColors = image.depth() > 8 ? 256 : image.numColors(); |
924 | unsigned char *segTbl = new unsigned char[segColors]; | 911 | unsigned char *segTbl = new unsigned char[segColors]; |
925 | int pixels = image.depth() > 8 ? image.width()*image.height() : | 912 | int pixels = image.depth() > 8 ? image.width()*image.height() : |
926 | image.numColors(); | 913 | image.numColors(); |
927 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : | 914 | unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : |
928 | (unsigned int *)image.colorTable(); | 915 | (unsigned int *)image.colorTable(); |
929 | 916 | ||
930 | bool brighten = (percent >= 0); | 917 | bool brighten = (percent >= 0); |
931 | if ( percent < 0 ) | 918 | if ( percent < 0 ) |
932 | percent = -percent; | 919 | percent = -percent; |
933 | 920 | ||
934 | if ( brighten ) | 921 | if ( brighten ) |
935 | { // keep overflow check out of loops | 922 | { // keep overflow check out of loops |
936 | for ( int i=0; i < segColors; ++i ) | 923 | for ( int i=0; i < segColors; ++i ) |
937 | { | 924 | { |
938 | int tmp = (int)(i*percent); | 925 | int tmp = (int)(i*percent); |
939 | if ( tmp > 255 ) | 926 | if ( tmp > 255 ) |
940 | tmp = 255; | 927 | tmp = 255; |
941 | segTbl[i] = tmp; | 928 | segTbl[i] = tmp; |
942 | } | 929 | } |
943 | } | 930 | } |
944 | else | 931 | else |
945 | { | 932 | { |
946 | for ( int i=0; i < segColors; ++i ) | 933 | for ( int i=0; i < segColors; ++i ) |
947 | { | 934 | { |
948 | int tmp = (int)(i*percent); | 935 | int tmp = (int)(i*percent); |
949 | if ( tmp < 0 ) | 936 | if ( tmp < 0 ) |
950 | tmp = 0; | 937 | tmp = 0; |
951 | segTbl[i] = tmp; | 938 | segTbl[i] = tmp; |
952 | } | 939 | } |
953 | } | 940 | } |
954 | 941 | ||
955 | if ( brighten ) | 942 | if ( brighten ) |
956 | { // same here | 943 | { // same here |
957 | for ( int i=0; i < pixels; ++i ) | 944 | for ( int i=0; i < pixels; ++i ) |
958 | { | 945 | { |
959 | int r = qRed(data[i]); | 946 | int r = qRed(data[i]); |
960 | int g = qGreen(data[i]); | 947 | int g = qGreen(data[i]); |
961 | int b = qBlue(data[i]); | 948 | int b = qBlue(data[i]); |
962 | int a = qAlpha(data[i]); | 949 | int a = qAlpha(data[i]); |
963 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; | 950 | r = r + segTbl[r] > 255 ? 255 : r + segTbl[r]; |
964 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; | 951 | g = g + segTbl[g] > 255 ? 255 : g + segTbl[g]; |
965 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; | 952 | b = b + segTbl[b] > 255 ? 255 : b + segTbl[b]; |
966 | data[i] = qRgba(r, g, b,a); | 953 | data[i] = qRgba(r, g, b,a); |
967 | } | 954 | } |
968 | } | 955 | } |
969 | else | 956 | else |
970 | { | 957 | { |
971 | for ( int i=0; i < pixels; ++i ) | 958 | for ( int i=0; i < pixels; ++i ) |
972 | { | 959 | { |
973 | int r = qRed(data[i]); | 960 | int r = qRed(data[i]); |
974 | int g = qGreen(data[i]); | 961 | int g = qGreen(data[i]); |
975 | int b = qBlue(data[i]); | 962 | int b = qBlue(data[i]); |
976 | int a = qAlpha(data[i]); | 963 | int a = qAlpha(data[i]); |
977 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; | 964 | r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; |
978 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; | 965 | g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; |
979 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; | 966 | b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; |
980 | data[i] = qRgba(r, g, b, a); | 967 | data[i] = qRgba(r, g, b, a); |
981 | } | 968 | } |
982 | } | 969 | } |
983 | delete [] segTbl; | 970 | delete [] segTbl; |
984 | 971 | ||
985 | return image; | 972 | return image; |
986 | } | 973 | } |
987 | 974 | ||
988 | QImage& ImageViewer::toGray(QImage &img, bool fast) | 975 | QImage& ImageViewer::toGray(QImage &img, bool fast) |
989 | { | 976 | { |
990 | if ( img.width() == 0 || img.height() == 0 ) | 977 | if ( img.width() == 0 || img.height() == 0 ) |
991 | return img; | 978 | return img; |
992 | 979 | ||
993 | if ( fast ) | 980 | if ( fast ) |
994 | { | 981 | { |
995 | if ( img.depth() == 32 ) | 982 | if ( img.depth() == 32 ) |
996 | { | 983 | { |
997 | register uchar * r(img.bits()); | 984 | register uchar * r(img.bits()); |
998 | register uchar * g(img.bits() + 1); | 985 | register uchar * g(img.bits() + 1); |
999 | register uchar * b(img.bits() + 2); | 986 | register uchar * b(img.bits() + 2); |
1000 | 987 | ||
1001 | uchar * end(img.bits() + img.numBytes()); | 988 | uchar * end(img.bits() + img.numBytes()); |
1002 | 989 | ||
1003 | while ( r != end ) | 990 | while ( r != end ) |
1004 | { | 991 | { |
1005 | 992 | ||
1006 | *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3 | 993 | *r = *g = *b = (((*r + *g) >> 1) + *b) >> 1; // (r + b + g) / 3 |
1007 | 994 | ||
1008 | r += 4; | 995 | r += 4; |
1009 | g += 4; | 996 | g += 4; |
1010 | b += 4; | 997 | b += 4; |
1011 | } | 998 | } |
1012 | } | 999 | } |
1013 | else | 1000 | else |
1014 | { | 1001 | { |
1015 | for ( int i = 0; i < img.numColors(); i++ ) | 1002 | for ( int i = 0; i < img.numColors(); i++ ) |
1016 | { | 1003 | { |
1017 | register uint r = qRed(img.color(i)); | 1004 | register uint r = qRed(img.color(i)); |
1018 | register uint g = qGreen(img.color(i)); | 1005 | register uint g = qGreen(img.color(i)); |
1019 | register uint b = qBlue(img.color(i)); | 1006 | register uint b = qBlue(img.color(i)); |
1020 | 1007 | ||
1021 | register uint gray = (((r + g) >> 1) + b) >> 1; | 1008 | register uint gray = (((r + g) >> 1) + b) >> 1; |
1022 | img.setColor(i, qRgba(gray, gray, gray, qAlpha(img.color(i)))); | 1009 | img.setColor(i, qRgba(gray, gray, gray, qAlpha(img.color(i)))); |
1023 | } | 1010 | } |
1024 | } | 1011 | } |
1025 | } | 1012 | } |
1026 | else | 1013 | else |
1027 | { | 1014 | { |
1028 | int pixels = img.depth() > 8 ? img.width()*img.height() : | 1015 | int pixels = img.depth() > 8 ? img.width()*img.height() : |
1029 | img.numColors(); | 1016 | img.numColors(); |
1030 | unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : | 1017 | unsigned int *data = img.depth() > 8 ? (unsigned int *)img.bits() : |
1031 | (unsigned int *)img.colorTable(); | 1018 | (unsigned int *)img.colorTable(); |
1032 | int val, i; | 1019 | int val, i; |
1033 | for ( i=0; i < pixels; ++i ) | 1020 | for ( i=0; i < pixels; ++i ) |
1034 | { | 1021 | { |
1035 | val = qGray(data[i]); | 1022 | val = qGray(data[i]); |
1036 | data[i] = qRgba(val, val, val, qAlpha(data[i])); | 1023 | data[i] = qRgba(val, val, val, qAlpha(data[i])); |
1037 | } | 1024 | } |
1038 | } | 1025 | } |
1039 | return img; | 1026 | return img; |
1040 | } | 1027 | } |
1041 | 1028 | ||
1042 | 1029 | ||
1043 | QImage ImageViewer::rotate(QImage &img, RotateDirection r) | 1030 | QImage ImageViewer::rotate(QImage &img, RotateDirection r) |
1044 | { | 1031 | { |
1045 | QImage dest; | 1032 | QImage dest; |
1046 | int x, y; | 1033 | int x, y; |
1047 | if ( img.depth() > 8 ) | 1034 | if ( img.depth() > 8 ) |
1048 | { | 1035 | { |
1049 | unsigned int *srcData, *destData; | 1036 | unsigned int *srcData, *destData; |
1050 | switch ( r ) | 1037 | switch ( r ) |
1051 | { | 1038 | { |
1052 | case Rotate90: | 1039 | case Rotate90: |
1053 | dest.create(img.height(), img.width(), img.depth()); | 1040 | dest.create(img.height(), img.width(), img.depth()); |
1054 | for ( y=0; y < img.height(); ++y ) | 1041 | for ( y=0; y < img.height(); ++y ) |
1055 | { | 1042 | { |
1056 | srcData = (unsigned int *)img.scanLine(y); | 1043 | srcData = (unsigned int *)img.scanLine(y); |
1057 | for ( x=0; x < img.width(); ++x ) | 1044 | for ( x=0; x < img.width(); ++x ) |
1058 | { | 1045 | { |
1059 | destData = (unsigned int *)dest.scanLine(x); | 1046 | destData = (unsigned int *)dest.scanLine(x); |
1060 | destData[img.height()-y-1] = srcData[x]; | 1047 | destData[img.height()-y-1] = srcData[x]; |
1061 | } | 1048 | } |
1062 | } | 1049 | } |
1063 | break; | 1050 | break; |
1064 | case Rotate180: | 1051 | case Rotate180: |
1065 | dest.create(img.width(), img.height(), img.depth()); | 1052 | dest.create(img.width(), img.height(), img.depth()); |
1066 | for ( y=0; y < img.height(); ++y ) | 1053 | for ( y=0; y < img.height(); ++y ) |
1067 | { | 1054 | { |
1068 | srcData = (unsigned int *)img.scanLine(y); | 1055 | srcData = (unsigned int *)img.scanLine(y); |
1069 | destData = (unsigned int *)dest.scanLine(img.height()-y-1); | 1056 | destData = (unsigned int *)dest.scanLine(img.height()-y-1); |
1070 | for ( x=0; x < img.width(); ++x ) | 1057 | for ( x=0; x < img.width(); ++x ) |
1071 | destData[img.width()-x-1] = srcData[x]; | 1058 | destData[img.width()-x-1] = srcData[x]; |
1072 | } | 1059 | } |
1073 | break; | 1060 | break; |
1074 | case Rotate270: | 1061 | case Rotate270: |
1075 | dest.create(img.height(), img.width(), img.depth()); | 1062 | dest.create(img.height(), img.width(), img.depth()); |
1076 | for ( y=0; y < img.height(); ++y ) | 1063 | for ( y=0; y < img.height(); ++y ) |
1077 | { | 1064 | { |
1078 | srcData = (unsigned int *)img.scanLine(y); | 1065 | srcData = (unsigned int *)img.scanLine(y); |
1079 | for ( x=0; x < img.width(); ++x ) | 1066 | for ( x=0; x < img.width(); ++x ) |
1080 | { | 1067 | { |
1081 | destData = (unsigned int *)dest.scanLine(img.width()-x-1); | 1068 | destData = (unsigned int *)dest.scanLine(img.width()-x-1); |
1082 | destData[y] = srcData[x]; | 1069 | destData[y] = srcData[x]; |
1083 | } | 1070 | } |
1084 | } | 1071 | } |
1085 | break; | 1072 | break; |
1086 | default: | 1073 | default: |
1087 | dest = img; | 1074 | dest = img; |
1088 | break; | 1075 | break; |
1089 | } | 1076 | } |
1090 | } | 1077 | } |
1091 | else | 1078 | else |
1092 | { | 1079 | { |
1093 | unsigned char *srcData, *destData; | 1080 | unsigned char *srcData, *destData; |
1094 | unsigned int *srcTable, *destTable; | 1081 | unsigned int *srcTable, *destTable; |
1095 | switch ( r ) | 1082 | switch ( r ) |
1096 | { | 1083 | { |
1097 | case Rotate90: | 1084 | case Rotate90: |
1098 | dest.create(img.height(), img.width(), img.depth()); | 1085 | dest.create(img.height(), img.width(), img.depth()); |
1099 | dest.setNumColors(img.numColors()); | 1086 | dest.setNumColors(img.numColors()); |
1100 | srcTable = (unsigned int *)img.colorTable(); | 1087 | srcTable = (unsigned int *)img.colorTable(); |
1101 | destTable = (unsigned int *)dest.colorTable(); | 1088 | destTable = (unsigned int *)dest.colorTable(); |
1102 | for ( x=0; x < img.numColors(); ++x ) | 1089 | for ( x=0; x < img.numColors(); ++x ) |
1103 | destTable[x] = srcTable[x]; | 1090 | destTable[x] = srcTable[x]; |
1104 | for ( y=0; y < img.height(); ++y ) | 1091 | for ( y=0; y < img.height(); ++y ) |
1105 | { | 1092 | { |
1106 | srcData = (unsigned char *)img.scanLine(y); | 1093 | srcData = (unsigned char *)img.scanLine(y); |
1107 | for ( x=0; x < img.width(); ++x ) | 1094 | for ( x=0; x < img.width(); ++x ) |
1108 | { | 1095 | { |
1109 | destData = (unsigned char *)dest.scanLine(x); | 1096 | destData = (unsigned char *)dest.scanLine(x); |
1110 | destData[img.height()-y-1] = srcData[x]; | 1097 | destData[img.height()-y-1] = srcData[x]; |
1111 | } | 1098 | } |
1112 | } | 1099 | } |
1113 | break; | 1100 | break; |
1114 | case Rotate180: | 1101 | case Rotate180: |
1115 | dest.create(img.width(), img.height(), img.depth()); | 1102 | dest.create(img.width(), img.height(), img.depth()); |
1116 | dest.setNumColors(img.numColors()); | 1103 | dest.setNumColors(img.numColors()); |
1117 | srcTable = (unsigned int *)img.colorTable(); | 1104 | srcTable = (unsigned int *)img.colorTable(); |
1118 | destTable = (unsigned int *)dest.colorTable(); | 1105 | destTable = (unsigned int *)dest.colorTable(); |
1119 | for ( x=0; x < img.numColors(); ++x ) | 1106 | for ( x=0; x < img.numColors(); ++x ) |
1120 | destTable[x] = srcTable[x]; | 1107 | destTable[x] = srcTable[x]; |
1121 | for ( y=0; y < img.height(); ++y ) | 1108 | for ( y=0; y < img.height(); ++y ) |
1122 | { | 1109 | { |
1123 | srcData = (unsigned char *)img.scanLine(y); | 1110 | srcData = (unsigned char *)img.scanLine(y); |
1124 | destData = (unsigned char *)dest.scanLine(img.height()-y-1); | 1111 | destData = (unsigned char *)dest.scanLine(img.height()-y-1); |
1125 | for ( x=0; x < img.width(); ++x ) | 1112 | for ( x=0; x < img.width(); ++x ) |
1126 | destData[img.width()-x-1] = srcData[x]; | 1113 | destData[img.width()-x-1] = srcData[x]; |
1127 | } | 1114 | } |
1128 | break; | 1115 | break; |
1129 | case Rotate270: | 1116 | case Rotate270: |
1130 | dest.create(img.height(), img.width(), img.depth()); | 1117 | dest.create(img.height(), img.width(), img.depth()); |
1131 | dest.setNumColors(img.numColors()); | 1118 | dest.setNumColors(img.numColors()); |
1132 | srcTable = (unsigned int *)img.colorTable(); | 1119 | srcTable = (unsigned int *)img.colorTable(); |
1133 | destTable = (unsigned int *)dest.colorTable(); | 1120 | destTable = (unsigned int *)dest.colorTable(); |
1134 | for ( x=0; x < img.numColors(); ++x ) | 1121 | for ( x=0; x < img.numColors(); ++x ) |
1135 | destTable[x] = srcTable[x]; | 1122 | destTable[x] = srcTable[x]; |
1136 | for ( y=0; y < img.height(); ++y ) | 1123 | for ( y=0; y < img.height(); ++y ) |
1137 | { | 1124 | { |
1138 | srcData = (unsigned char *)img.scanLine(y); | 1125 | srcData = (unsigned char *)img.scanLine(y); |
1139 | for ( x=0; x < img.width(); ++x ) | 1126 | for ( x=0; x < img.width(); ++x ) |
1140 | { | 1127 | { |
1141 | destData = (unsigned char *)dest.scanLine(img.width()-x-1); | 1128 | destData = (unsigned char *)dest.scanLine(img.width()-x-1); |
1142 | destData[y] = srcData[x]; | 1129 | destData[y] = srcData[x]; |
1143 | } | 1130 | } |
1144 | } | 1131 | } |
1145 | break; | 1132 | break; |
1146 | default: | 1133 | default: |
1147 | dest = img; | 1134 | dest = img; |
1148 | break; | 1135 | break; |
1149 | } | 1136 | } |
1150 | 1137 | ||
1151 | } | 1138 | } |
1152 | return (dest); | 1139 | return (dest); |
1153 | } | 1140 | } |
1154 | 1141 | ||
1155 | void ImageViewer::slideShow( bool on ) | 1142 | void ImageViewer::slideShow( bool on ) |
1156 | { | 1143 | { |
1157 | if (on) { | 1144 | if (on) { |
1158 | if (!imageList.isEmpty()) { | 1145 | if (!imageList.isEmpty()) { |
1159 | slideTimer->start(slideDelay * 1000, FALSE); | 1146 | slideTimer->start(slideDelay * 1000, FALSE); |
1160 | filename = ""; // force restart | 1147 | filename = ""; // force restart |
1161 | slideReverse ? prevImage() : nextImage(); | 1148 | slideReverse ? prevImage() : nextImage(); |
1162 | } | 1149 | } |
1163 | } else { | 1150 | } else { |
1164 | slideTimer->stop(); | 1151 | slideTimer->stop(); |
1165 | slideAction->setOn( false); | 1152 | slideAction->setOn( false); |
1166 | } | 1153 | } |
1167 | } | 1154 | } |
1168 | 1155 | ||
1169 | void ImageViewer::slideUpdate() | 1156 | void ImageViewer::slideUpdate() |
1170 | { | 1157 | { |
1171 | bool final_image = slideReverse ? prevImage() : nextImage(); | 1158 | bool final_image = slideReverse ? prevImage() : nextImage(); |
1172 | 1159 | ||
1173 | if (final_image && !slideRepeat) { | 1160 | if (final_image && !slideRepeat) { |
1174 | slideTimer->stop(); | 1161 | slideTimer->stop(); |
1175 | slideAction->setOn(FALSE); | 1162 | slideAction->setOn(FALSE); |
1176 | } | 1163 | } |
1177 | } | 1164 | } |
1178 | 1165 | ||
1179 | // | 1166 | // |
1180 | // Display the image after the current one in the image list. | 1167 | // Display the image after the current one in the image list. |
1181 | // Return TRUE if the next call to nextImage() will wrap around to the | 1168 | // Return TRUE if the next call to nextImage() will wrap around to the |
1182 | // first image in the list (ie. we're now viewing the last image in the list). | 1169 | // first image in the list (ie. we're now viewing the last image in the list). |
1183 | // | 1170 | // |
1184 | bool ImageViewer::nextImage(void) | 1171 | bool ImageViewer::nextImage(void) |
1185 | { | 1172 | { |
1186 | int idx = 0; | 1173 | int idx = 0; |
1187 | 1174 | ||
1188 | if (imageList.count() > 0) { | 1175 | if (imageList.count() > 0) { |
1189 | idx = imageIndex(); | 1176 | idx = imageIndex(); |
1190 | if (idx != -1) { | 1177 | if (idx != -1) { |
1191 | if (idx == int(imageList.count() - 1)) { | 1178 | if (idx == int(imageList.count() - 1)) { |
1192 | idx = 0; | 1179 | idx = 0; |
1193 | } else { | 1180 | } else { |
1194 | idx++; | 1181 | idx++; |
1195 | } | 1182 | } |
1196 | } else { | 1183 | } else { |
1197 | idx = 0; | 1184 | idx = 0; |
1198 | } | 1185 | } |
1199 | openFile(imageList[idx]); | 1186 | openFile(imageList[idx]); |
1200 | } | 1187 | } |
1201 | 1188 | ||
1202 | return idx == int(imageList.count() - 1) ? TRUE : FALSE; | 1189 | return idx == int(imageList.count() - 1) ? TRUE : FALSE; |
1203 | } | 1190 | } |
1204 | 1191 | ||
1205 | // | 1192 | // |
1206 | // Display the image preceeding the current one in the image list. | 1193 | // Display the image preceeding the current one in the image list. |
1207 | // Return TRUE if the next call to prevImage() will wrap around to the last | 1194 | // Return TRUE if the next call to prevImage() will wrap around to the last |
1208 | // image in the list (ie. we're now viewing the first image in the list). | 1195 | // image in the list (ie. we're now viewing the first image in the list). |
1209 | // | 1196 | // |
1210 | bool ImageViewer::prevImage(void) | 1197 | bool ImageViewer::prevImage(void) |
1211 | { | 1198 | { |
1212 | int idx = -1; | 1199 | int idx = -1; |
1213 | 1200 | ||
1214 | if (imageList.count() > 0) { | 1201 | if (imageList.count() > 0) { |
1215 | idx = imageIndex(); | 1202 | idx = imageIndex(); |
1216 | if (idx != -1) { | 1203 | if (idx != -1) { |
1217 | if (idx == 0) { | 1204 | if (idx == 0) { |
1218 | idx = imageList.count() - 1; | 1205 | idx = imageList.count() - 1; |
1219 | } else { | 1206 | } else { |
1220 | idx--; | 1207 | idx--; |
1221 | } | 1208 | } |
1222 | } else { | 1209 | } else { |
1223 | idx = imageList.count() - 1; | 1210 | idx = imageList.count() - 1; |
1224 | } | 1211 | } |
1225 | openFile(imageList[idx]); | 1212 | openFile(imageList[idx]); |
1226 | } | 1213 | } |
1227 | 1214 | ||
1228 | return idx == 0 ? TRUE : FALSE; | 1215 | return idx == 0 ? TRUE : FALSE; |
1229 | } | 1216 | } |
1230 | 1217 | ||
1231 | // | 1218 | // |
1232 | // Return the index into the imageList of the currently viewed | 1219 | // Return the index into the imageList of the currently viewed |
1233 | // image (ie. ImageViewer::filename in ImageViewer::imageList). | 1220 | // image (ie. ImageViewer::filename in ImageViewer::imageList). |
1234 | // | 1221 | // |
1235 | int ImageViewer::imageIndex(void) | 1222 | int ImageViewer::imageIndex(void) |
1236 | { | 1223 | { |
1237 | QValueListConstIterator<DocLnk> i; | 1224 | QValueListConstIterator<DocLnk> i; |
1238 | int index; | 1225 | int index; |
1239 | 1226 | ||
1240 | if (imageList.count() == 0) { | 1227 | if (imageList.count() == 0) { |
1241 | return -1; | 1228 | return -1; |
1242 | } | 1229 | } |
1243 | 1230 | ||
1244 | for (index = 0, i = imageList.begin(); i != imageList.end(); ++i, index++) { | 1231 | for (index = 0, i = imageList.begin(); i != imageList.end(); ++i, index++) { |
1245 | if ((*i).file() == filename) { | 1232 | if ((*i).file() == filename) { |
1246 | return index; | 1233 | return index; |
1247 | } | 1234 | } |
1248 | } | 1235 | } |
1249 | 1236 | ||
1250 | return -1; | 1237 | return -1; |
1251 | } | 1238 | } |
diff --git a/noncore/multimedia/tonleiter/editinst.cpp b/noncore/multimedia/tonleiter/editinst.cpp index 5616569..ccb4560 100644 --- a/noncore/multimedia/tonleiter/editinst.cpp +++ b/noncore/multimedia/tonleiter/editinst.cpp | |||
@@ -1,111 +1,110 @@ | |||
1 | #include "editinst.h" | 1 | #include "editinst.h" |
2 | 2 | ||
3 | #include <qlabel.h> | ||
4 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
5 | 4 | ||
6 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
7 | 6 | ||
8 | Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) | 7 | Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) |
9 | :QDialog(parent,name,true,0),data(data) | 8 | :QDialog(parent,name,true,0),data(data) |
10 | { | 9 | { |
11 | setCaption("Tonleiter::"+tr("Instrument")); | 10 | setCaption("Tonleiter::"+tr("Instrument")); |
12 | QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); | 11 | QBoxLayout* masterlayout=new QBoxLayout(this,QBoxLayout::TopToBottom); |
13 | instid=data->getCurrentInstrumentID(); | 12 | instid=data->getCurrentInstrumentID(); |
14 | stringlist.setAutoDelete(true); | 13 | stringlist.setAutoDelete(true); |
15 | 14 | ||
16 | QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); | 15 | QBoxLayout* toplayout=new QBoxLayout(masterlayout,QBoxLayout::LeftToRight); |
17 | 16 | ||
18 | //Name combo + Add + Delete | 17 | //Name combo + Add + Delete |
19 | boxInst=new QComboBox(this,"boxInst"); | 18 | boxInst=new QComboBox(this,"boxInst"); |
20 | boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 19 | boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
21 | connect(boxInst,SIGNAL(activated(int)),this,SLOT(setCurrentInstrumetID(int))); | 20 | connect(boxInst,SIGNAL(activated(int)),this,SLOT(setCurrentInstrumetID(int))); |
22 | for(int i=0;i<data->noOfInstruments();i++) | 21 | for(int i=0;i<data->noOfInstruments();i++) |
23 | { | 22 | { |
24 | Instrument inst=data->getInstrument(i); | 23 | Instrument inst=data->getInstrument(i); |
25 | QString name=inst.instName(); | 24 | QString name=inst.instName(); |
26 | if(name.isNull()) continue; | 25 | if(name.isNull()) continue; |
27 | boxInst->insertItem(name,i); | 26 | boxInst->insertItem(name,i); |
28 | } | 27 | } |
29 | boxInst->setCurrentItem(instid); | 28 | boxInst->setCurrentItem(instid); |
30 | toplayout->addWidget(boxInst); | 29 | toplayout->addWidget(boxInst); |
31 | 30 | ||
32 | QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); | 31 | QPushButton* addButton=new QPushButton(tr("Add"),this,"addButton"); |
33 | connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); | 32 | connect(addButton,SIGNAL(pressed()),this,SLOT(addInstrument())); |
34 | toplayout->addWidget(addButton); | 33 | toplayout->addWidget(addButton); |
35 | 34 | ||
36 | QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); | 35 | QPushButton* delButton=new QPushButton(tr("Delete"),this,"delButton"); |
37 | connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); | 36 | connect(delButton,SIGNAL(pressed()),this,SLOT(deleteInstrument())); |
38 | toplayout->addWidget(delButton); | 37 | toplayout->addWidget(delButton); |
39 | 38 | ||
40 | QPushButton* addhighButton=new QPushButton(tr("Add High String"),this,"addhighButton"); | 39 | QPushButton* addhighButton=new QPushButton(tr("Add High String"),this,"addhighButton"); |
41 | masterlayout->addWidget(addhighButton); | 40 | masterlayout->addWidget(addhighButton); |
42 | 41 | ||
43 | scrollview=new QScrollView(this); | 42 | scrollview=new QScrollView(this); |
44 | scrollview->setVScrollBarMode(QScrollView::AlwaysOn); | 43 | scrollview->setVScrollBarMode(QScrollView::AlwaysOn); |
45 | scrollview->setHScrollBarMode(QScrollView::AlwaysOff); | 44 | scrollview->setHScrollBarMode(QScrollView::AlwaysOff); |
46 | stringwidget=new QVBox(scrollview->viewport()); | 45 | stringwidget=new QVBox(scrollview->viewport()); |
47 | stringwidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); | 46 | stringwidget->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); |
48 | stringwidget->setSpacing(10); | 47 | stringwidget->setSpacing(10); |
49 | scrollview->addChild(stringwidget); | 48 | scrollview->addChild(stringwidget); |
50 | scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 49 | scrollview->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
51 | masterlayout->addWidget(scrollview); | 50 | masterlayout->addWidget(scrollview); |
52 | 51 | ||
53 | loadInstrument(); | 52 | loadInstrument(); |
54 | 53 | ||
55 | QPushButton* addlowButton=new QPushButton(tr("Add Low String"),this,"addlowButton"); | 54 | QPushButton* addlowButton=new QPushButton(tr("Add Low String"),this,"addlowButton"); |
56 | masterlayout->addWidget(addlowButton); | 55 | masterlayout->addWidget(addlowButton); |
57 | 56 | ||
58 | //make dialog fit the screen | 57 | //make dialog fit the screen |
59 | QPEApplication::showDialog( this ); | 58 | QPEApplication::showDialog( this ); |
60 | } | 59 | } |
61 | //**************************************************************************** | 60 | //**************************************************************************** |
62 | Menu::InstEditDialog::~InstEditDialog() | 61 | Menu::InstEditDialog::~InstEditDialog() |
63 | { | 62 | { |
64 | } | 63 | } |
65 | //**************************************************************************** | 64 | //**************************************************************************** |
66 | void Menu::InstEditDialog::setCurrentInstrumetID(int id) | 65 | void Menu::InstEditDialog::setCurrentInstrumetID(int id) |
67 | { | 66 | { |
68 | saveInstrument(); | 67 | saveInstrument(); |
69 | instid=id; | 68 | instid=id; |
70 | data->setCurrentInstrumetID(id); | 69 | data->setCurrentInstrumetID(id); |
71 | loadInstrument(); | 70 | loadInstrument(); |
72 | } | 71 | } |
73 | //**************************************************************************** | 72 | //**************************************************************************** |
74 | void Menu::InstEditDialog::addInstrument() | 73 | void Menu::InstEditDialog::addInstrument() |
75 | { | 74 | { |
76 | } | 75 | } |
77 | //**************************************************************************** | 76 | //**************************************************************************** |
78 | void Menu::InstEditDialog::deleteInstrument() | 77 | void Menu::InstEditDialog::deleteInstrument() |
79 | { | 78 | { |
80 | } | 79 | } |
81 | //**************************************************************************** | 80 | //**************************************************************************** |
82 | void Menu::InstEditDialog::addLowString() | 81 | void Menu::InstEditDialog::addLowString() |
83 | { | 82 | { |
84 | } | 83 | } |
85 | //**************************************************************************** | 84 | //**************************************************************************** |
86 | void Menu::InstEditDialog::addHighString() | 85 | void Menu::InstEditDialog::addHighString() |
87 | { | 86 | { |
88 | } | 87 | } |
89 | //**************************************************************************** | 88 | //**************************************************************************** |
90 | void Menu::InstEditDialog::deleteString(int id) | 89 | void Menu::InstEditDialog::deleteString(int id) |
91 | { | 90 | { |
92 | } | 91 | } |
93 | //**************************************************************************** | 92 | //**************************************************************************** |
94 | void Menu::InstEditDialog::saveInstrument() | 93 | void Menu::InstEditDialog::saveInstrument() |
95 | { | 94 | { |
96 | //auto delete is set to true so widgets _should_ be deleted | 95 | //auto delete is set to true so widgets _should_ be deleted |
97 | stringlist.clear(); | 96 | stringlist.clear(); |
98 | } | 97 | } |
99 | //**************************************************************************** | 98 | //**************************************************************************** |
100 | void Menu::InstEditDialog::loadInstrument() | 99 | void Menu::InstEditDialog::loadInstrument() |
101 | { | 100 | { |
102 | stringlist.clear(); | 101 | stringlist.clear(); |
103 | Instrument inst=data->getInstrument(instid); | 102 | Instrument inst=data->getInstrument(instid); |
104 | qDebug("load Instrument : %d strings",inst.noOfStrings()); | 103 | qDebug("load Instrument : %d strings",inst.noOfStrings()); |
105 | for(uint s=0;s<inst.noOfStrings();s++) | 104 | for(uint s=0;s<inst.noOfStrings();s++) |
106 | { | 105 | { |
107 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); | 106 | stringlist.append(new EditStringWidget(inst.string(s),stringwidget)); |
108 | } | 107 | } |
109 | } | 108 | } |
110 | //**************************************************************************** | 109 | //**************************************************************************** |
111 | //**************************************************************************** | 110 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/editstringwidget.cpp b/noncore/multimedia/tonleiter/editstringwidget.cpp index d22bbc5..33dc6e1 100644 --- a/noncore/multimedia/tonleiter/editstringwidget.cpp +++ b/noncore/multimedia/tonleiter/editstringwidget.cpp | |||
@@ -1,32 +1,31 @@ | |||
1 | #include "editstringwidget.h" | 1 | #include "editstringwidget.h" |
2 | 2 | ||
3 | #include <qlabel.h> | ||
4 | #include <qlayout.h> | 3 | #include <qlayout.h> |
5 | 4 | ||
6 | using namespace Data; | 5 | using namespace Data; |
7 | 6 | ||
8 | Menu::EditStringWidget::EditStringWidget(int note,QWidget* parent,const char* name,WFlags f) | 7 | Menu::EditStringWidget::EditStringWidget(int note,QWidget* parent,const char* name,WFlags f) |
9 | :QFrame(parent,name,f) | 8 | :QFrame(parent,name,f) |
10 | { | 9 | { |
11 | QBoxLayout* layout=new QBoxLayout(this,QBoxLayout::LeftToRight,10); | 10 | QBoxLayout* layout=new QBoxLayout(this,QBoxLayout::LeftToRight,10); |
12 | 11 | ||
13 | boxNote=new QComboBox(this,"boxNote"); | 12 | boxNote=new QComboBox(this,"boxNote"); |
14 | boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 13 | boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
15 | //connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); | 14 | //connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); |
16 | layout->addWidget(boxNote,1,1); | 15 | layout->addWidget(boxNote,1,1); |
17 | for(int a=0;a<12;a++) | 16 | for(int a=0;a<12;a++) |
18 | boxNote->insertItem(Note::notenames[a],a); | 17 | boxNote->insertItem(Note::notenames[a],a); |
19 | boxNote->setCurrentItem(note-12*Note::getOctaveOfNote(note)); | 18 | boxNote->setCurrentItem(note-12*Note::getOctaveOfNote(note)); |
20 | layout->addWidget(boxNote); | 19 | layout->addWidget(boxNote); |
21 | 20 | ||
22 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 21 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
23 | setFrameShape(QFrame::Panel); | 22 | setFrameShape(QFrame::Panel); |
24 | setFrameShadow(QFrame::Sunken); | 23 | setFrameShadow(QFrame::Sunken); |
25 | 24 | ||
26 | } | 25 | } |
27 | //**************************************************************************** | 26 | //**************************************************************************** |
28 | Menu::EditStringWidget::~EditStringWidget() | 27 | Menu::EditStringWidget::~EditStringWidget() |
29 | { | 28 | { |
30 | } | 29 | } |
31 | //**************************************************************************** | 30 | //**************************************************************************** |
32 | //**************************************************************************** | 31 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/mainwidget.cpp b/noncore/multimedia/tonleiter/mainwidget.cpp index b9c3d01..db16541 100644 --- a/noncore/multimedia/tonleiter/mainwidget.cpp +++ b/noncore/multimedia/tonleiter/mainwidget.cpp | |||
@@ -1,45 +1,44 @@ | |||
1 | #include "mainwidget.h" | 1 | #include "mainwidget.h" |
2 | 2 | ||
3 | #include <qwidget.h> | ||
4 | #include <qlayout.h> | 3 | #include <qlayout.h> |
5 | 4 | ||
6 | MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) | 5 | MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) |
7 | :QMainWindow(parent,name,f) | 6 | :QMainWindow(parent,name,f) |
8 | { | 7 | { |
9 | setCaption("Tonleiter"); | 8 | setCaption("Tonleiter"); |
10 | data=new Data::TonleiterData(this); | 9 | data=new Data::TonleiterData(this); |
11 | 10 | ||
12 | QWidget* mainwidget=new QWidget(this,"mainwidget"); | 11 | QWidget* mainwidget=new QWidget(this,"mainwidget"); |
13 | setCentralWidget(mainwidget); | 12 | setCentralWidget(mainwidget); |
14 | QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom); | 13 | QBoxLayout* mainlayout=new QBoxLayout(mainwidget,QBoxLayout::TopToBottom); |
15 | 14 | ||
16 | menuwidget=new Menu::MenuWidget(data,mainwidget); | 15 | menuwidget=new Menu::MenuWidget(data,mainwidget); |
17 | mainlayout->addWidget(menuwidget); | 16 | mainlayout->addWidget(menuwidget); |
18 | 17 | ||
19 | fretboard=new Graph::FretBoard(data,mainwidget); | 18 | fretboard=new Graph::FretBoard(data,mainwidget); |
20 | connect(fretboard,SIGNAL(pressed()),this,SLOT(fretboardPressed())); | 19 | connect(fretboard,SIGNAL(pressed()),this,SLOT(fretboardPressed())); |
21 | mainlayout->addWidget(fretboard); | 20 | mainlayout->addWidget(fretboard); |
22 | 21 | ||
23 | showmenu=true; | 22 | showmenu=true; |
24 | 23 | ||
25 | } | 24 | } |
26 | //**************************************************************************** | 25 | //**************************************************************************** |
27 | MainWidget::~MainWidget() | 26 | MainWidget::~MainWidget() |
28 | { | 27 | { |
29 | } | 28 | } |
30 | //**************************************************************************** | 29 | //**************************************************************************** |
31 | void MainWidget::fretboardPressed() | 30 | void MainWidget::fretboardPressed() |
32 | { | 31 | { |
33 | if(showmenu) | 32 | if(showmenu) |
34 | { | 33 | { |
35 | menuwidget->hide(); | 34 | menuwidget->hide(); |
36 | showmenu=false; | 35 | showmenu=false; |
37 | } | 36 | } |
38 | else | 37 | else |
39 | { | 38 | { |
40 | menuwidget->show(); | 39 | menuwidget->show(); |
41 | showmenu=true; | 40 | showmenu=true; |
42 | } | 41 | } |
43 | } | 42 | } |
44 | //**************************************************************************** | 43 | //**************************************************************************** |
45 | //**************************************************************************** | 44 | //**************************************************************************** |
diff --git a/noncore/multimedia/tonleiter/menuwidget.cpp b/noncore/multimedia/tonleiter/menuwidget.cpp index 56a2f8a..91d052e 100644 --- a/noncore/multimedia/tonleiter/menuwidget.cpp +++ b/noncore/multimedia/tonleiter/menuwidget.cpp | |||
@@ -1,107 +1,105 @@ | |||
1 | #include "menuwidget.h" | 1 | #include "menuwidget.h" |
2 | 2 | ||
3 | #include <qlabel.h> | ||
4 | #include <qlayout.h> | ||
5 | 3 | ||
6 | #include "editinst.h" | 4 | #include "editinst.h" |
7 | #include "editscale.h" | 5 | #include "editscale.h" |
8 | 6 | ||
9 | Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) | 7 | Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) |
10 | :QWidget(parent,name,f),data(data) | 8 | :QWidget(parent,name,f),data(data) |
11 | { | 9 | { |
12 | QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); | 10 | QGridLayout* layout=new QGridLayout(this,3,3,10,-1,"menulayout"); |
13 | 11 | ||
14 | //Instrument | 12 | //Instrument |
15 | QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); | 13 | QLabel* instLabel=new QLabel(tr("Instr."),this,"instLabel"); |
16 | instLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 14 | instLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
17 | layout->addWidget(instLabel,0,0); | 15 | layout->addWidget(instLabel,0,0); |
18 | 16 | ||
19 | boxInst=new QComboBox(this,"boxInst"); | 17 | boxInst=new QComboBox(this,"boxInst"); |
20 | boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 18 | boxInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
21 | connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); | 19 | connect(boxInst,SIGNAL(activated(int)),data,SLOT(setCurrentInstrumetID(int))); |
22 | layout->addWidget(boxInst,0,1); | 20 | layout->addWidget(boxInst,0,1); |
23 | 21 | ||
24 | editInst=new QPushButton(tr("Edit"),this,"editInst"); | 22 | editInst=new QPushButton(tr("Edit"),this,"editInst"); |
25 | editInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 23 | editInst->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
26 | connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed())); | 24 | connect(editInst,SIGNAL(pressed()),this,SLOT(editInstPressed())); |
27 | layout->addWidget(editInst,0,2); | 25 | layout->addWidget(editInst,0,2); |
28 | 26 | ||
29 | //Note | 27 | //Note |
30 | QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); | 28 | QLabel* noteLabel=new QLabel(tr("Note"),this,"noteLabel"); |
31 | noteLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 29 | noteLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
32 | layout->addWidget(noteLabel,1,0); | 30 | layout->addWidget(noteLabel,1,0); |
33 | 31 | ||
34 | boxNote=new QComboBox(this,"boxNote"); | 32 | boxNote=new QComboBox(this,"boxNote"); |
35 | boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 33 | boxNote->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
36 | connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); | 34 | connect(boxNote,SIGNAL(activated(int)),data,SLOT(setCurrentNote(int))); |
37 | layout->addWidget(boxNote,1,1); | 35 | layout->addWidget(boxNote,1,1); |
38 | for(int a=0;a<12;a++) | 36 | for(int a=0;a<12;a++) |
39 | boxNote->insertItem(Note::notenames[a],a); | 37 | boxNote->insertItem(Note::notenames[a],a); |
40 | boxNote->setCurrentItem(data->getCurrentBaseNote()); | 38 | boxNote->setCurrentItem(data->getCurrentBaseNote()); |
41 | 39 | ||
42 | noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); | 40 | noteCheck=new QCheckBox(tr("show"),this,"noteCheck"); |
43 | noteCheck->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 41 | noteCheck->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
44 | noteCheck->setChecked(data->isDrawNames()); | 42 | noteCheck->setChecked(data->isDrawNames()); |
45 | connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); | 43 | connect(noteCheck,SIGNAL(toggled(bool)),data,SLOT(setDrawNames(bool))); |
46 | layout->addWidget(noteCheck,1,2); | 44 | layout->addWidget(noteCheck,1,2); |
47 | 45 | ||
48 | //Scale | 46 | //Scale |
49 | QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); | 47 | QLabel* scaleLabel=new QLabel(tr("Scale"),this,"scaleLabel"); |
50 | scaleLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 48 | scaleLabel->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
51 | layout->addWidget(scaleLabel,2,0); | 49 | layout->addWidget(scaleLabel,2,0); |
52 | 50 | ||
53 | boxScale=new QComboBox(this,"boxScale"); | 51 | boxScale=new QComboBox(this,"boxScale"); |
54 | boxScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 52 | boxScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
55 | connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); | 53 | connect(boxScale,SIGNAL(activated(int)),data,SLOT(setCurrentScaleID(int))); |
56 | layout->addWidget(boxScale,2,1); | 54 | layout->addWidget(boxScale,2,1); |
57 | 55 | ||
58 | editScale=new QPushButton(tr("Edit"),this,"editScale"); | 56 | editScale=new QPushButton(tr("Edit"),this,"editScale"); |
59 | editScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 57 | editScale->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
60 | connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed())); | 58 | connect(editScale,SIGNAL(pressed()),this,SLOT(editScalePressed())); |
61 | layout->addWidget(editScale,2,2); | 59 | layout->addWidget(editScale,2,2); |
62 | 60 | ||
63 | updateBoxes(); | 61 | updateBoxes(); |
64 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); | 62 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Maximum)); |
65 | } | 63 | } |
66 | //**************************************************************************** | 64 | //**************************************************************************** |
67 | Menu::MenuWidget::~MenuWidget() | 65 | Menu::MenuWidget::~MenuWidget() |
68 | { | 66 | { |
69 | } | 67 | } |
70 | //**************************************************************************** | 68 | //**************************************************************************** |
71 | void Menu::MenuWidget::editInstPressed() | 69 | void Menu::MenuWidget::editInstPressed() |
72 | { | 70 | { |
73 | InstEditDialog* instdialog=new InstEditDialog(data,this); | 71 | InstEditDialog* instdialog=new InstEditDialog(data,this); |
74 | instdialog->exec(); | 72 | instdialog->exec(); |
75 | } | 73 | } |
76 | //**************************************************************************** | 74 | //**************************************************************************** |
77 | void Menu::MenuWidget::editScalePressed() | 75 | void Menu::MenuWidget::editScalePressed() |
78 | { | 76 | { |
79 | ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this); | 77 | ScaleEditDialog* scaledialog=new ScaleEditDialog(data,this); |
80 | scaledialog->exec(); | 78 | scaledialog->exec(); |
81 | } | 79 | } |
82 | //**************************************************************************** | 80 | //**************************************************************************** |
83 | void Menu::MenuWidget::updateBoxes() | 81 | void Menu::MenuWidget::updateBoxes() |
84 | { | 82 | { |
85 | boxInst->clear(); | 83 | boxInst->clear(); |
86 | 84 | ||
87 | for(int i=0;i<data->noOfInstruments();i++) | 85 | for(int i=0;i<data->noOfInstruments();i++) |
88 | { | 86 | { |
89 | Instrument inst=data->getInstrument(i); | 87 | Instrument inst=data->getInstrument(i); |
90 | QString name=inst.instName(); | 88 | QString name=inst.instName(); |
91 | if(name.isNull()) continue; | 89 | if(name.isNull()) continue; |
92 | boxInst->insertItem(name,i); | 90 | boxInst->insertItem(name,i); |
93 | } | 91 | } |
94 | boxInst->setCurrentItem(data->getCurrentInstrumentID()); | 92 | boxInst->setCurrentItem(data->getCurrentInstrumentID()); |
95 | 93 | ||
96 | boxScale->clear(); | 94 | boxScale->clear(); |
97 | for(int s=0;s<data->noOfScales();s++) | 95 | for(int s=0;s<data->noOfScales();s++) |
98 | { | 96 | { |
99 | Scale scale=data->getScale(s); | 97 | Scale scale=data->getScale(s); |
100 | QString name=scale.scaleName(); | 98 | QString name=scale.scaleName(); |
101 | if(name.isNull()) continue; | 99 | if(name.isNull()) continue; |
102 | boxScale->insertItem(name,s); | 100 | boxScale->insertItem(name,s); |
103 | } | 101 | } |
104 | boxScale->setCurrentItem(data->getCurrentScaleID()); | 102 | boxScale->setCurrentItem(data->getCurrentScaleID()); |
105 | } | 103 | } |
106 | //**************************************************************************** | 104 | //**************************************************************************** |
107 | //**************************************************************************** | 105 | //**************************************************************************** |