summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-02 15:11:14 (UTC)
committer chicken <chicken>2004-03-02 15:11:14 (UTC)
commitb48c5437e9631094d15ec7280a9d1cf212b3eb28 (patch) (unidiff)
tree4c0095e58acc98ba6e8ba40240c491d03b99be92
parent12dd57c04b42d4517061ed847b1aa041dd8af841 (diff)
downloadopie-b48c5437e9631094d15ec7280a9d1cf212b3eb28.zip
opie-b48c5437e9631094d15ec7280a9d1cf212b3eb28.tar.gz
opie-b48c5437e9631094d15ec7280a9d1cf212b3eb28.tar.bz2
fix includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/gui/mainwindow.h2
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/om3u.cpp15
-rw-r--r--noncore/multimedia/opieplayer2/playlistselection.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/volumecontrol.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp3
-rw-r--r--noncore/multimedia/opierec/main.cpp1
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp1
-rw-r--r--noncore/multimedia/opierec/wavFile.cpp1
-rw-r--r--noncore/multimedia/opierec/waveform.cpp1
-rw-r--r--noncore/multimedia/powerchord/fretboard.cpp1
-rw-r--r--noncore/multimedia/powerchord/gs.cpp2
-rw-r--r--noncore/multimedia/powerchord/powerchord.cpp1
-rw-r--r--noncore/multimedia/powerchord/powerchordbase.cpp7
-rw-r--r--noncore/multimedia/showimg/ImageFileSelector.cpp11
-rw-r--r--noncore/multimedia/showimg/main.cpp1
-rw-r--r--noncore/multimedia/showimg/settingsdialog.cpp2
-rw-r--r--noncore/multimedia/showimg/settingsdialogbase.cpp4
-rw-r--r--noncore/multimedia/showimg/showimg.cpp13
-rw-r--r--noncore/multimedia/tonleiter/editinst.cpp1
-rw-r--r--noncore/multimedia/tonleiter/editstringwidget.cpp1
-rw-r--r--noncore/multimedia/tonleiter/mainwidget.cpp1
-rw-r--r--noncore/multimedia/tonleiter/menuwidget.cpp2
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
25class QAction; 23class QAction;
26class QActionGroup; 24class QActionGroup;
27class QIconSet; 25class QIconSet;
28class QTimerEvent; 26class QTimerEvent;
29class QToolButton; 27class QToolButton;
30class QLabel; 28class QLabel;
31class MainWindowBase; 29class MainWindowBase;
32class QCopChannel; 30class QCopChannel;
33class PreviewWidget; 31class PreviewWidget;
34 32
35class CameraMainWindow: public QMainWindow 33class 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
41namespace 39namespace
42{ 40{
43 41
44const int xo = -2; // movable x offset 42const int xo = -2; // movable x offset
45const int yo = 22; // movable y offset 43const int yo = 22; // movable y offset
46 44
47const MediaWidget::SkinButtonInfo skinInfo[] = 45const 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
61const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 59const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
62 60
63void changeTextColor( QWidget * w) { 61void 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
72AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 70AudioWidget::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
97AudioWidget::~AudioWidget() { 95AudioWidget::~AudioWidget() {
98 96
99// mediaPlayerState->setPlaying(false); 97// mediaPlayerState->setPlaying(false);
100} 98}
101 99
102MediaWidget::GUIInfo AudioWidget::guiInfo() 100MediaWidget::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
107void AudioWidget::resizeEvent( QResizeEvent *e ) { 105void 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
123void AudioWidget::sliderPressed() { 121void AudioWidget::sliderPressed() {
124 audioSliderBeingMoved = TRUE; 122 audioSliderBeingMoved = TRUE;
125} 123}
126 124
127 125
128void AudioWidget::sliderReleased() { 126void 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
136void AudioWidget::setPosition( long i ) { 134void 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
142void AudioWidget::setLength( long max ) { 140void AudioWidget::setLength( long max ) {
143 updateSlider( mediaPlayerState.position(), max ); 141 updateSlider( mediaPlayerState.position(), max );
144} 142}
145 143
146 144
147void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 145void 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
158void AudioWidget::loadSkin() 156void 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
188void AudioWidget::setSeekable( bool isSeekable ) { 186void 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
212static QString timeAsString( long length ) { 210static 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
218void AudioWidget::updateSlider( long i, long max ) { 216void 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
241void AudioWidget::skipFor() { 239void 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
247void AudioWidget::skipBack() { 245void 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
255void AudioWidget::stopSkip() { 253void AudioWidget::stopSkip() {
256 killTimers(); 254 killTimers();
257} 255}
258 256
259 257
260void AudioWidget::timerEvent( QTimerEvent * ) { 258void 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
268void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 266void 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
46InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 39InputDialog::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 */
66QString InputDialog::text() const { 59QString 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 */
72InputDialog::~InputDialog() { 65InputDialog::~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
49typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 48typedef 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
52extern "C" { 51extern "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
69using namespace XINE; 68using namespace XINE;
70 69
71Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) 70Lib::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
108void Lib::run() 107void 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
116void Lib::initialize() 115void 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
153Lib::~Lib() { 152Lib::~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
171void Lib::resize ( const QSize &s ) { 170void 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
180int Lib::majorVersion() { 179int 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
186int Lib::minorVersion() { 185int 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
192int Lib::subVersion() { 191int 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
198int Lib::play( const QString& fileName, int startPos, int start_time ) { 197int 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
216void Lib::stop() { 215void 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
223void Lib::pause( bool toggle ) { 222void 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
229int Lib::speed() const { 228int 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
235void Lib::setSpeed( int speed ) { 234void 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
241int Lib::status() const { 240int 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
247int Lib::currentPosition() const { 246int 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
255int Lib::currentTime() const { 254int 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
267int Lib::length() const { 266int 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
286valid stream, then return -1 (this value could be used to make the stream 285valid stream, then return -1 (this value could be used to make the stream
287unseekable, but it should never occur!! Mr. Murphy ? :) ) */ 286unseekable, but it should never occur!! Mr. Murphy ? :) ) */
288 287
289 return -1; 288 return -1;
290} 289}
291 290
292bool Lib::isSeekable() const { 291bool 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
298void Lib::seekTo( int time ) { 297void 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
307Frame Lib::currentFrame() const { 306Frame 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
314QString Lib::metaInfo( int number) const { 313QString 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
320int Lib::error() const { 319int 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
326void Lib::ensureInitialized() 325void 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
336void Lib::setWidget( XineVideoWidget *widget ) 335void 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
344void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 343void 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
351void Lib::handleXineEvent( const xine_event_t* t ) { 350void 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
355void Lib::handleXineEvent( int type ) { 354void 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
364void Lib::setShowVideo( bool video ) { 363void 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
371bool Lib::isShowingVideo() const { 370bool 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
377bool Lib::hasVideo() const { 376bool 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
383void Lib::showVideoFullScreen( bool fullScreen ) { 382void 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
389bool Lib::isVideoFullScreen() const { 388bool 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
395void Lib::setScaling( bool scale ) { 394void 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
401void Lib::setGamma( int value ) { 400void 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
407bool Lib::isScaling() const { 406bool 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
413void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { 412void 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
417void Lib::xine_display_frame( void* user_data, uint8_t *frame, 416void 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
422void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 421void 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
11OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> ) 8OPIE_EXPORT_APP( OApplicationFactory<PlayListWidget> )
12 9
13#if 0 10#if 0
14int main(int argc, char **argv) { 11int 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
23MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 19MediaPlayer::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
59MediaPlayer::~MediaPlayer() { 55MediaPlayer::~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
71void MediaPlayer::pauseCheck( bool b ) { 67void 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
77void MediaPlayer::play() { 73void MediaPlayer::play() {
78 mediaPlayerState.setPlaying( FALSE ); 74 mediaPlayerState.setPlaying( FALSE );
79 mediaPlayerState.setPlaying( TRUE ); 75 mediaPlayerState.setPlaying( TRUE );
80} 76}
81 77
82void MediaPlayer::setPlaying( bool play ) { 78void 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
131void MediaPlayer::prev() { 127void 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
146void MediaPlayer::next() { 142void 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
169void MediaPlayer::startDecreasingVolume() { 165void 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
176void MediaPlayer::startIncreasingVolume() { 172void 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
183bool drawnOnScreenDisplay = FALSE; 179bool drawnOnScreenDisplay = FALSE;
184unsigned int onScreenDisplayVolume = 0; 180unsigned int onScreenDisplayVolume = 0;
185const int yoff = 110; 181const int yoff = 110;
186 182
187void MediaPlayer::stopChangingVolume() { 183void 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
206void MediaPlayer::timerEvent( QTimerEvent * ) { 202void 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
285void MediaPlayer::blank( bool b ) { 281void 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
320void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 316void 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
342void MediaPlayer::cleanUp() {// this happens on closing 338void 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
351void MediaPlayer::recreateAudioAndVideoWidgets() const 347void 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
379AudioWidget *MediaPlayer::audioUI() const 375AudioWidget *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
386VideoWidget *MediaPlayer::videoUI() const 382VideoWidget *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
393XineControl *MediaPlayer::xineControl() const 389XineControl *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
400void MediaPlayer::reloadSkins() 396void 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
50MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 45MediaPlayerState::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
59MediaPlayerState::~MediaPlayerState() { 54MediaPlayerState::~MediaPlayerState() {
60} 55}
61 56
62 57
63void MediaPlayerState::readConfig( Config& cfg ) { 58void 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
79void MediaPlayerState::writeConfig( Config& cfg ) const { 74void 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
88MediaPlayerState::DisplayType MediaPlayerState::displayType() const 83MediaPlayerState::DisplayType MediaPlayerState::displayType() const
89{ 84{
90 return m_displayType; 85 return m_displayType;
91} 86}
92 87
93// slots 88// slots
94void MediaPlayerState::setIsStreaming( bool b ) { 89void MediaPlayerState::setIsStreaming( bool b ) {
95 streaming = b; 90 streaming = b;
96} 91}
97 92
98void MediaPlayerState::setIsSeekable( bool b ) { 93void MediaPlayerState::setIsSeekable( bool b ) {
99 seekable = b; 94 seekable = b;
100 emit isSeekableToggled(b); 95 emit isSeekableToggled(b);
101} 96}
102 97
103 98
104void MediaPlayerState::setFullscreen( bool b ) { 99void 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
113void MediaPlayerState::setBlanked( bool b ) { 108void 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
122void MediaPlayerState::setScaled( bool b ) { 117void 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
130void MediaPlayerState::setLooping( bool b ) { 125void 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
138void MediaPlayerState::setShuffled( bool b ) { 133void 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
146void MediaPlayerState::setPaused( bool b ) { 141void 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
156void MediaPlayerState::setPlaying( bool b ) { 151void 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
165void MediaPlayerState::setStopped( bool b ) { 160void 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
173void MediaPlayerState::setPosition( long p ) { 168void 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
181void MediaPlayerState::updatePosition( long p ){ 176void 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
189void MediaPlayerState::setVideoGamma( int v ){ 184void 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
197void MediaPlayerState::setLength( long l ) { 192void 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
205void MediaPlayerState::setDisplayType( DisplayType displayType ) 200void 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
214void MediaPlayerState::setPrev(){ 209void MediaPlayerState::setPrev(){
215 emit prev(); 210 emit prev();
216} 211}
217 212
218void MediaPlayerState::setNext() { 213void MediaPlayerState::setNext() {
219 emit next(); 214 emit next();
220} 215}
221 216
222void MediaPlayerState::setList() { 217void MediaPlayerState::setList() {
223 setPlaying( FALSE ); 218 setPlaying( FALSE );
224 setDisplayType( MediaSelection ); 219 setDisplayType( MediaSelection );
225} 220}
226 221
227void MediaPlayerState::setVideo() { 222void MediaPlayerState::setVideo() {
228 setDisplayType( Video ); 223 setDisplayType( Video );
229} 224}
230 225
231void MediaPlayerState::setAudio() { 226void MediaPlayerState::setAudio() {
232 setDisplayType( Audio ); 227 setDisplayType( Audio );
233} 228}
234 229
235void MediaPlayerState::toggleFullscreen() { 230void MediaPlayerState::toggleFullscreen() {
236 setFullscreen( !fullscreen ); 231 setFullscreen( !fullscreen );
237} 232}
238 233
239void MediaPlayerState::toggleScaled() { 234void MediaPlayerState::toggleScaled() {
240 setScaled( !scaled); 235 setScaled( !scaled);
241} 236}
242 237
243void MediaPlayerState::toggleLooping() { 238void MediaPlayerState::toggleLooping() {
244 setLooping( !looping); 239 setLooping( !looping);
245} 240}
246 241
247void MediaPlayerState::toggleShuffled() { 242void MediaPlayerState::toggleShuffled() {
248 setShuffled( !shuffled); 243 setShuffled( !shuffled);
249} 244}
250 245
251void MediaPlayerState::togglePaused() { 246void MediaPlayerState::togglePaused() {
252 setPaused( !paused); 247 setPaused( !paused);
253} 248}
254 249
255void MediaPlayerState::togglePlaying() { 250void MediaPlayerState::togglePlaying() {
256 setPlaying( !playing); 251 setPlaying( !playing);
257} 252}
258 253
259void MediaPlayerState::toggleBlank() { 254void 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
29MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 28MediaWidget::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
42MediaWidget::~MediaWidget() 41MediaWidget::~MediaWidget()
43{ 42{
44} 43}
45 44
46void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 45void 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
60MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 59MediaWidget::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
70void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) 69void 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
77void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 76void 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
86void MediaWidget::closeEvent( QCloseEvent * ) 85void MediaWidget::closeEvent( QCloseEvent * )
87{ 86{
88 mediaPlayerState.setList(); 87 mediaPlayerState.setList();
89} 88}
90 89
91void MediaWidget::paintEvent( QPaintEvent *pe ) 90void 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
108void MediaWidget::resizeEvent( QResizeEvent *e ) 107void 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
125MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 124MediaWidget::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
140void MediaWidget::mousePressEvent( QMouseEvent *event ) 139void 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
158void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 157void 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
173void MediaWidget::makeVisible() 172void MediaWidget::makeVisible()
174{ 173{
175} 174}
176 175
177void MediaWidget::handleCommand( Command command, bool buttonDown ) 176void 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
195bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 194bool 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
203void MediaWidget::paintAllButtons( QPainter &p ) 202void 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
210void MediaWidget::paintButton( const Button &button ) 209void 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
216void MediaWidget::paintButton( QPainter &p, const Button &button ) 215void 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
224void MediaWidget::setToggleButton( Command command, bool down ) 223void 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
233void MediaWidget::setToggleButton( Button &button, bool down ) 232void 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
239void MediaWidget::toggleButton( Button &button ) 238void 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
246QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) 245QPixmap 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
255QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) 254QPixmap 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
51Om3u::Om3u( const QString &filePath, int mode) 38Om3u::Om3u( const QString &filePath, int mode)
52 : QStringList (){ 39 : QStringList (){
53qDebug("<<<<<<<new m3u "+filePath); 40qDebug("<<<<<<<new m3u "+filePath);
54 f.setName(filePath); 41 f.setName(filePath);
55 f.open(mode); 42 f.open(mode);
56} 43}
57 44
58Om3u::~Om3u(){} 45Om3u::~Om3u(){}
59 46
60void Om3u::readM3u() { 47void 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
86void Om3u::readPls() { //it's a pls file 73void 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
124void Om3u::write() { //writes list to m3u file 111void 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
137void Om3u::add(const QString &filePath) { //adds to m3u file 124void Om3u::add(const QString &filePath) { //adds to m3u file
138 append(filePath); 125 append(filePath);
139} 126}
140 127
141void Om3u::remove(const QString &filePath) { //removes from m3u list 128void 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
155void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file 142void 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
161void Om3u::close() { //closes m3u file 148void 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
35class PlayListSelectionItem : public QListViewItem { 27class PlayListSelectionItem : public QListViewItem {
36public: 28public:
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
47private: 39private:
48 const DocLnk *fl; 40 const DocLnk *fl;
49}; 41};
50 42
51 43
52PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) 44PlayListSelection::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
70PlayListSelection::~PlayListSelection() { 62PlayListSelection::~PlayListSelection() {
71} 63}
72 64
73 65
74// #ifdef USE_PLAYLIST_BACKGROUND 66// #ifdef USE_PLAYLIST_BACKGROUND
75void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { 67void 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
85void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { 77void 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
97const DocLnk *PlayListSelection::current() { 89const 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
105void PlayListSelection::addToSelection( const DocLnk &lnk ) { 97void 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
115void PlayListSelection::removeSelected() { 107void 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
123void PlayListSelection::moveSelectedUp() { 115void 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
131void PlayListSelection::moveSelectedDown() { 123void 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
139bool PlayListSelection::prev() { 131bool 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
149bool PlayListSelection::next() { 141bool 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
160bool PlayListSelection::first() { 152bool 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
171bool PlayListSelection::last() { 163bool 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
184void PlayListSelection::unSelect() 176void PlayListSelection::unSelect()
185{ 177{
186 //QListViewItem *item = selectedItem(); 178 //QListViewItem *item = selectedItem();
187 setSelected( currentItem(), FALSE); 179 setSelected( currentItem(), FALSE);
188} 180}
189 181
190void PlayListSelection::writeCurrent( Config& cfg ) { 182void 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
199void PlayListSelection::setSelectedItem(const QString &strk ) { 191void 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,555 +1,554 @@
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
51PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 50PlayListWidget::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
164PlayListWidget::~PlayListWidget() { 163PlayListWidget::~PlayListWidget() {
165 delete d; 164 delete d;
166 delete m_mp; 165 delete m_mp;
167} 166}
168 167
169 168
170void PlayListWidget::initializeStates() { 169void 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
177void PlayListWidget::writeDefaultPlaylist() { 176void 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
202void PlayListWidget::addToSelection( const DocLnk& lnk ) { 201void 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
212void PlayListWidget::clearList() { 211void 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
222void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 221void 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
238void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 237void 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
254void PlayListWidget::addAllToList() { 253void 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
287void PlayListWidget::addAllMusicToList() { 286void 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
308void PlayListWidget::addAllVideoToList() { 307void 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
327void PlayListWidget::setDocument( const QString& fileref ) { 326void 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
359void PlayListWidget::useSelectedDocument() { 358void PlayListWidget::useSelectedDocument() {
360 d->setDocumentUsed = FALSE; 359 d->setDocumentUsed = FALSE;
361} 360}
362 361
363 362
364const DocLnk *PlayListWidget::current() const { // this is fugly 363const 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
377bool PlayListWidget::prev() { 376bool 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
403bool PlayListWidget::next() { 402bool 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
420bool PlayListWidget::first() { 419bool PlayListWidget::first() {
421 return d->selectedFiles->first(); 420 return d->selectedFiles->first();
422} 421}
423 422
424 423
425bool PlayListWidget::last() { 424bool 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
435void PlayListWidget::loadList( const DocLnk & lnk) { 434void 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
446void PlayListWidget::addSelected() { 445void 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
467void PlayListWidget::removeSelected() { 466void PlayListWidget::removeSelected() {
468 d->selectedFiles->removeSelected( ); 467 d->selectedFiles->removeSelected( );
469 writeCurrentM3u(); 468 writeCurrentM3u();
470} 469}
471 470
472 471
473void PlayListWidget::playIt( QListViewItem *it) { 472void 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
481void PlayListWidget::addToSelection( QListViewItem *it) { 480void 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
502void PlayListWidget::tabChanged(QWidget *) { 501void 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() );
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
49PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) 48PlayListWidgetGui::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
175PlayListWidgetGui::~PlayListWidgetGui() { 174PlayListWidgetGui::~PlayListWidgetGui() {
176} 175}
177 176
178void PlayListWidgetGui::setView( char view ) { 177void 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
186void PlayListWidgetGui::setActiveWindow() { 185void 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
35struct SkinData 33struct 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
46class SkinCache : public Singleton<SkinCache> 44class SkinCache : public Singleton<SkinCache>
47{ 45{
48public: 46public:
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
55private: 53private:
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
66Skin::Skin( const QString &name, const QString &fileNameInfix ) 64Skin::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
72Skin::Skin( const QString &fileNameInfix ) 70Skin::Skin( const QString &fileNameInfix )
73 : m_fileNameInfix( fileNameInfix ) 71 : m_fileNameInfix( fileNameInfix )
74{ 72{
75 init( defaultSkinName() ); 73 init( defaultSkinName() );
76} 74}
77 75
78Skin::~Skin() 76Skin::~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
86void Skin::init( const QString &name ) 84void 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
93QPixmap Skin::backgroundPixmap() const 91QPixmap 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
100QImage Skin::buttonUpImage() const 98QImage 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
107QImage Skin::buttonDownImage() const 105QImage 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
114QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const 112QImage 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
130void Skin::addButtonToMask( int tag, const QImage &maskImage ) const 128void 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
144QImage Skin::buttonMaskImage( const QString &fileName ) const 142QImage 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
155QString Skin::defaultSkinName() 153QString 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
162QImage Skin::loadImage( const QString &fileName ) 160QImage Skin::loadImage( const QString &fileName )
163{ 161{
164 return QImage( Resource::findPixmap( fileName ) ); 162 return QImage( Resource::findPixmap( fileName ) );
165} 163}
166 164
167SkinCache::SkinCache() 165SkinCache::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
175SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) 173SkinData *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
196void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) 194void 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
213SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) 211SkinLoader::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
219SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() 217SkinLoader::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
256SkinLoader::SkinLoader() 254SkinLoader::SkinLoader()
257 : m_currentLoader( 0 ), m_timerId( -1 ) 255 : m_currentLoader( 0 ), m_timerId( -1 )
258{ 256{
259} 257}
260 258
261SkinLoader::~SkinLoader() 259SkinLoader::~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
268void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) 266void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo )
269{ 267{
270 schedule( Skin::defaultSkinName(), guiInfo ); 268 schedule( Skin::defaultSkinName(), guiInfo );
271} 269}
272 270
273void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) 271void 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
278void SkinLoader::start() 276void 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
285void SkinLoader::timerEvent( QTimerEvent *ev ) 283void 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
318void SkinLoader::deleteMe() 316void 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
46namespace 44namespace
47{ 45{
48 46
49const int xo = 2; // movable x offset 47const int xo = 2; // movable x offset
50const int yo = 0; // movable y offset 48const int yo = 0; // movable y offset
51 49
52const MediaWidget::SkinButtonInfo skinInfo[] = 50const 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
63const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 61const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
64 62
65} 63}
66 64
67VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 65VideoWidget::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
88VideoWidget::~VideoWidget() 86VideoWidget::~VideoWidget()
89{ 87{
90} 88}
91 89
92MediaWidget::GUIInfo VideoWidget::guiInfo() 90MediaWidget::GUIInfo VideoWidget::guiInfo()
93{ 91{
94 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); 92 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount );
95} 93}
96 94
97void VideoWidget::resizeEvent( QResizeEvent *e ) { 95void 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
118void VideoWidget::sliderPressed() { 116void VideoWidget::sliderPressed() {
119 videoSliderBeingMoved = TRUE; 117 videoSliderBeingMoved = TRUE;
120} 118}
121 119
122void VideoWidget::sliderReleased() { 120void 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
131void VideoWidget::setPosition( long i ) { 129void VideoWidget::setPosition( long i ) {
132 updateSlider( i, mediaPlayerState.length() ); 130 updateSlider( i, mediaPlayerState.length() );
133} 131}
134 132
135 133
136void VideoWidget::setLength( long max ) { 134void VideoWidget::setLength( long max ) {
137 updateSlider( mediaPlayerState.position(), max ); 135 updateSlider( mediaPlayerState.position(), max );
138} 136}
139 137
140void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 138void 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
153void VideoWidget::loadSkin() 151void 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
167void VideoWidget::updateSlider( long i, long max ) { 165void 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
184void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 182void 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
192void VideoWidget::backToNormal() { 190void 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
198void VideoWidget::makeVisible() { 196void 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
242void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 240void 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
290XineVideoWidget* VideoWidget::vidWidget() { 288XineVideoWidget* VideoWidget::vidWidget() {
291 return videoFrame; 289 return videoFrame;
292} 290}
293 291
294 292
295void VideoWidget::setFullscreen ( bool b ) { 293void VideoWidget::setFullscreen ( bool b ) {
296 setToggleButton( FullScreen, b ); 294 setToggleButton( FullScreen, b );
297} 295}
298 296
299 297
300void VideoWidget::setPlaying( bool b) { 298void 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
9int VolumeControl::volume() { 7int 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
18void VolumeControl::setVolume( int volumePerc ) { 16void 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
36void VolumeControl::incVol( int ammount ) { 34void VolumeControl::incVol( int ammount ) {
37 int oldVol = volume(); 35 int oldVol = volume();
38 setVolume( oldVol + ammount); 36 setVolume( oldVol + ammount);
39} 37}
40 38
41void VolumeControl::decVol( int ammount ) { 39void 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
47VolumeControl::VolumeControl( ) { 45VolumeControl::VolumeControl( ) {
48 volume(); 46 volume();
49} 47}
50 48
51VolumeControl::~VolumeControl() { 49VolumeControl::~VolumeControl() {
52 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; 50 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false;
53} 51}
54 52
55void VolumeControl::setMute(bool on) { 53void 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
44XineControl::XineControl( XineVideoWidget *xineWidget, 43XineControl::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
54XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 53XineControl::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
66void XineControl::init() 65void 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
80XineControl::~XineControl() { 79XineControl::~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
91void XineControl::play( const QString& fileName ) { 90void 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
138void XineControl::nextMedia() { 137void XineControl::nextMedia() {
139 mediaPlayerState.setNext(); 138 mediaPlayerState.setNext();
140} 139}
141 140
142void XineControl::setGamma( int value ) { 141void XineControl::setGamma( int value ) {
143 libXine->setGamma( value ); 142 libXine->setGamma( value );
144} 143}
145 144
146void XineControl::stop( bool isSet ) { 145void 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 */
164void XineControl::pause( bool isSet) { 163void 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 */
172long XineControl::currentTime() { 171long 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 */
182void XineControl::length() { 181void 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 */
192long XineControl::position() { 191long 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 */
208void XineControl::setFullscreen( bool isSet ) { 207void XineControl::setFullscreen( bool isSet ) {
209 libXine->showVideoFullScreen( isSet ); 208 libXine->showVideoFullScreen( isSet );
210} 209}
211 210
212 211
213QString XineControl::getMetaInfo() { 212QString 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
243QString XineControl::getErrorCode() { 242QString 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 */
266void XineControl::seekTo( long second ) { 265void XineControl::seekTo( long second ) {
267 libXine->seekTo( (int)second ); 266 libXine->seekTo( (int)second );
268} 267}
269 268
270void XineControl::videoResized ( const QSize &s ) { 269void 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
52static inline void memcpy_rev ( void *dst, void *src, size_t len ) 49static 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
64static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) 61static 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
75static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) 72static 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
88XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) 85XineVideoWidget::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
101XineVideoWidget::~XineVideoWidget ( ) 98XineVideoWidget::~XineVideoWidget ( )
102{ 99{
103 delete m_logo; 100 delete m_logo;
104} 101}
105 102
106void XineVideoWidget::clear ( ) 103void XineVideoWidget::clear ( )
107{ 104{
108 m_buff = 0; 105 m_buff = 0;
109 repaint ( false ); 106 repaint ( false );
110} 107}
111 108
112QSize XineVideoWidget::videoSize() const 109QSize 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
127void XineVideoWidget::paintEvent ( QPaintEvent * ) 124void 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
235QImage *XineVideoWidget::logo ( ) const 232QImage *XineVideoWidget::logo ( ) const
236{ 233{
237 return m_logo; 234 return m_logo;
238} 235}
239 236
240 237
241void XineVideoWidget::setLogo ( QImage* logo ) 238void 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
247void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) 244void 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
268void XineVideoWidget::resizeEvent ( QResizeEvent * ) 265void XineVideoWidget::resizeEvent ( QResizeEvent * )
269{ 266{
270 emit videoResized( videoSize() ); 267 emit videoResized( videoSize() );
271} 268}
272 269
273 270
274void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) 271void 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
16int main(int argc, char* argv[]) { 15int 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>
26OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) 25OPIE_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,523 +1,522 @@
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
15extern "C" { 14extern "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>
61static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 }; 60static int deviceSampleRates[8] = { 32000, 44100, 48000, 88200, 96000, 176400, 192000, -1 };
62static int deviceBitRates[] = { 8, 16, 24, 32, -1 }; 61static int deviceBitRates[] = { 8, 16, 24, 32, -1 };
63#else //OSS 62#else //OSS
64static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 }; 63static int deviceSampleRates[6] = { 11025, 16000, 22050, 32000, 44100, -1 };
65static int deviceBitRates[] = { 8, 16, -1 }; 64static 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
86struct adpcm_state encoder_state; 85struct adpcm_state encoder_state;
87struct adpcm_state decoder_state; 86struct adpcm_state decoder_state;
88 87
89typedef struct { 88typedef 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
107fileParameters filePara; 106fileParameters filePara;
108 107
109bool monitoring, recording, playing; 108bool monitoring, recording, playing;
110bool stopped; 109bool stopped;
111QLabel *timeLabel; 110QLabel *timeLabel;
112QSlider *timeSlider; 111QSlider *timeSlider;
113int sd; 112int sd;
114 113
115Waveform* waveform; 114Waveform* waveform;
116Device *soundDevice; 115Device *soundDevice;
117 116
118 117
119#ifdef THREADED 118#ifdef THREADED
120void quickRec() 119void 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
288void playIt() 287void 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
423QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 422QtRec::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
465QtRec::~QtRec() { 464QtRec::~QtRec() {
466 465
467} 466}
468 467
469void QtRec::cleanUp() { 468void 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
485void QtRec::init() { 484void 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 );
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
24WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, 23WavFile::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
42bool WavFile::newFile() { 41bool 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 }
96return true; 95return true;
97} 96}
98 97
99WavFile::~WavFile() { 98WavFile::~WavFile() {
100 99
101 closeFile(); 100 closeFile();
102} 101}
103 102
104void WavFile::closeFile() { 103void WavFile::closeFile() {
105 if(track.isOpen()) 104 if(track.isOpen())
106 track.close(); 105 track.close();
107} 106}
108 107
109int WavFile::openFile(const QString &currentFileName) { 108int WavFile::openFile(const QString &currentFileName) {
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
126bool WavFile::setWavHeader(int fd, wavhdr *hdr) { 125bool 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
158bool WavFile::adjustHeaders(int fd, int total) { 157bool 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
168int WavFile::parseWavHeader(int fd) { 167int 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
281QString WavFile::trackName() { 280QString WavFile::trackName() {
282 return track.name(); 281 return track.name();
283} 282}
284 283
285int WavFile::wavHandle(){ 284int WavFile::wavHandle(){
286 return track.handle(); 285 return track.handle();
287} 286}
288 287
289int WavFile::getFormat() { 288int WavFile::getFormat() {
290return wavFormat; 289return wavFormat;
291} 290}
292 291
293int WavFile::getResolution() { 292int WavFile::getResolution() {
294return wavResolution; 293return wavResolution;
295} 294}
296 295
297int WavFile::getSampleRate() { 296int WavFile::getSampleRate() {
298 return wavSampleRate; 297 return wavSampleRate;
299} 298}
300 299
301int WavFile::getNumberSamples() { 300int WavFile::getNumberSamples() {
302 return wavNumberSamples; 301 return wavNumberSamples;
303} 302}
304 303
305bool WavFile::isTempFile() { 304bool WavFile::isTempFile() {
306return useTmpFile; 305return useTmpFile;
307} 306}
308 307
309int WavFile::getChannels() { 308int 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
26Waveform::Waveform( QWidget *parent, const char *name, WFlags fl ) 25Waveform::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
39void Waveform::changeSettings( int frequency, int channels ) 38void 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
54Waveform::~Waveform() 53Waveform::~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
63void Waveform::reset() 62void 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
73void Waveform::newSamples( const short *buf, int len ) 72void 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
107void Waveform::makePixmap() 106void 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
117void Waveform::draw() 116void 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
145void Waveform::paintEvent( QPaintEvent * ) 144void 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
31void FretBoard::refresh(){ 30void 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
64FretBoard::FretBoard(QWidget *parent, const char *name ) 63FretBoard::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
105void FretBoard::Finger(int f, int position){ 104void 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
128void FretBoard::paintEvent(QPaintEvent *){ 127void 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
24gs::gs() 22gs::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
122void gs::set_tonebank(int tb, signed short *buf, int length) 120void 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
158void gs::Finger(int f, int position){ 156void 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
167void gs::Tuning(int t[6]){ 165void 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
181int gs::note_periods[12] = { 179int gs::note_periods[12] = {
18290703, 18090703,
18385612, 18185612,
18480802, 18280802,
18576272, 18376272,
18671991, 18471991,
18767950, 18567950,
18864137, 18664137,
18960537, 18760537,
19057139, 18857139,
19153932, 18953932,
19250905, 19050905,
19348048 19148048
194}; 192};
195 193
196int gs::octave_step[6] = { 194int 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
205int gs::Play(){ 203int 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
279void gs::note_start(int chan, int note, int octave) 277void 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
333void gs::write_buffer(){ 331void 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
339void gs::fill_buffer() 337void 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
451void gs::Stop(){ 449void 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
464gs::~gs() 462gs::~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 */
8Powerchord::Powerchord( QWidget* parent, const char* name, WFlags fl ) 7Powerchord::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 */
17Powerchord::~Powerchord() 16Powerchord::~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 */
25void Powerchord::goodBye() 24void 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,539 +1,532 @@
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 */
35PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) 28PowerchordBase::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
397static int known=0; 390static int known=0;
398#include <qmessagebox.h> 391#include <qmessagebox.h>
399void PowerchordBase::transport_rec_cb(){ 392void 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}
406void PowerchordBase::list_remove_cb(){ 399void 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}
411void PowerchordBase::play_chord_cb(){ 404void 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
460void PowerchordBase::audio_cb(){ 453void 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
518void PowerchordBase::tuner_cb(){ 511void 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
535void PowerchordBase::tuner_start_cb(){ 528void 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{
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
24ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) 13ThumbWidget::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
39void ThumbWidget::resizeEvent(QResizeEvent *) 28void 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
44void ThumbWidget::paintEvent( QPaintEvent *e ) 33void 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
54void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) 43void ThumbWidget::mouseReleaseEvent(QMouseEvent* )
55{ 44{
56 emit clicked(fl); 45 emit clicked(fl);
57} 46}
58 47
59 48
60 49
61ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) 50ImageFileSelectorItem::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
73ImageFileSelectorItem::~ImageFileSelectorItem() 62ImageFileSelectorItem::~ImageFileSelectorItem()
74{ 63{
75 64
76} 65}
77 66
78 67
79ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) 68ImageFileSelector::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}
114ImageFileSelector::~ImageFileSelector() 103ImageFileSelector::~ImageFileSelector()
115{ 104{
116 105
117} 106}
118 107
119 108
120void ImageFileSelector::switchView() 109void 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
131void ImageFileSelector::setView(CURRENT_VIEW v) 120void 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
152void ImageFileSelector::resizeEvent(QResizeEvent *) 141void ImageFileSelector::resizeEvent(QResizeEvent *)
153{ 142{
154 updateSizes(); 143 updateSizes();
155} 144}
156 145
157void ImageFileSelector::updateSizes() 146void 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
167void ImageFileSelector::reread(bool) 156void 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
229int ImageFileSelector::fileCount() 218int ImageFileSelector::fileCount()
230{ 219{
231 return count; 220 return count;
232} 221}
233const DocLnk * ImageFileSelector::selected() 222const 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
244void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) 233void 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'
254void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) 243void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int )
255{ 244{
256 245
257} 246}
258void ImageFileSelector::fileClicked( QListViewItem *i) 247void 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
266void ImageFileSelector::thumbClicked(const DocLnk &f) 255void 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
27OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) \ No newline at end of file 26OPIE_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
28SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f ) 26SettingsDialog::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
34void SettingsDialog::setDelay( int d ) 32void SettingsDialog::setDelay( int d )
35{ 33{
36 delaySlider->setValue( d ); 34 delaySlider->setValue( d );
37 delayChanged( d ); 35 delayChanged( d );
38} 36}
39 37
40int SettingsDialog::delay() const 38int SettingsDialog::delay() const
41{ 39{
42 return delaySlider->value(); 40 return delaySlider->value();
43} 41}
44 42
45void SettingsDialog::setRepeat( bool r ) 43void SettingsDialog::setRepeat( bool r )
46{ 44{
47 repeatCheck->setChecked( r ); 45 repeatCheck->setChecked( r );
48} 46}
49 47
50bool SettingsDialog::repeat() const 48bool SettingsDialog::repeat() const
51{ 49{
52 return repeatCheck->isChecked(); 50 return repeatCheck->isChecked();
53} 51}
54 52
55void SettingsDialog::delayChanged( int d ) 53void SettingsDialog::delayChanged( int d )
56{ 54{
57 delayText->setText( QString::number( d ) + " s" ); 55 delayText->setText( QString::number( d ) + " s" );
58} 56}
59 57
60void SettingsDialog::setReverse(bool r) 58void SettingsDialog::setReverse(bool r)
61{ 59{
62 reverseCheck->setChecked(r); 60 reverseCheck->setChecked(r);
63} 61}
64 62
65bool SettingsDialog::reverse() const 63bool SettingsDialog::reverse() const
66{ 64{
67 return reverseCheck->isChecked(); 65 return reverseCheck->isChecked();
68} 66}
69 67
70void SettingsDialog::setRotate(bool r) 68void SettingsDialog::setRotate(bool r)
71{ 69{
72 rotateCheck->setChecked(r); 70 rotateCheck->setChecked(r);
73} 71}
74 72
75bool SettingsDialog::rotate() const 73bool SettingsDialog::rotate() const
76{ 74{
77 return rotateCheck->isChecked(); 75 return rotateCheck->isChecked();
78} 76}
79 77
80void SettingsDialog::setFastLoad(bool f) 78void SettingsDialog::setFastLoad(bool f)
81{ 79{
82 fastLoadCheck->setChecked(f); 80 fastLoadCheck->setChecked(f);
83} 81}
84 82
85bool SettingsDialog::fastLoad() const 83bool 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 */
28SettingsDialogBase::SettingsDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl ) 24SettingsDialogBase::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 */
102SettingsDialogBase::~SettingsDialogBase() 98SettingsDialogBase::~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,564 +1,551 @@
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
57ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) 44ControlsDialog::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
90void ControlsDialog::bValueChanged(int value) 77void 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
103void ControlsDialog::accept() 90void 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
111InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) 98InfoDialog::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
153void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) 140void 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
163ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) 150ImagePane::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
177void ImagePane::setPixmap( const QPixmap &pm ) 164void 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
185void ImagePane::imageClicked() 172void 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
194void ImageWidget::paintEvent( QPaintEvent *e ) 181void 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
207void ImageWidget::mouseReleaseEvent(QMouseEvent *) 194void ImageWidget::mouseReleaseEvent(QMouseEvent *)
208{ 195{
209 emit clicked(); 196 emit clicked();
210} 197}
211 198
212//=========================================================================== 199//===========================================================================
213 200
214ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) 201ImageViewer::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
392ImageViewer::~ImageViewer() 379ImageViewer::~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
412void ImageViewer::help() { 399void ImageViewer::help() {
413 400
414} 401}
415 402
416 403
417void ImageViewer::settings() 404void 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
446void ImageViewer::switchSizeToScreen() 433void 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
453void ImageViewer::updateImage() 440void 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
462void ImageViewer::switchThumbView() 449void 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
471void ImageViewer::switchToFileSelector() 458void 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
484void ImageViewer::switchToImageView() 471void 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
499void ImageViewer::setDocument(const QString& fileref) 486void 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
506void ImageViewer::doDelayedLoad() 493void ImageViewer::doDelayedLoad()
507{ 494{
508 show(delayLoad); 495 show(delayLoad);
509} 496}
510 497
511void ImageViewer::show() 498void ImageViewer::show()
512{ 499{
513 normalView(); 500 normalView();
514 QMainWindow::show(); 501 QMainWindow::show();
515} 502}
516 503
517void ImageViewer::show(const QString& fileref) 504void 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
532void ImageViewer::openFile() { 519void 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
545void ImageViewer::openFile( const DocLnk &link ) 532void 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
558void ImageViewer::open() 545void ImageViewer::open()
559{ 546{
560 switchToFileSelector(); 547 switchToFileSelector();
561} 548}
562 549
563void ImageViewer::closeFileSelector() 550void ImageViewer::closeFileSelector()
564{ 551{
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
8Menu::InstEditDialog::InstEditDialog(TonleiterData* data,QWidget* parent,const char* name) 7Menu::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//****************************************************************************
62Menu::InstEditDialog::~InstEditDialog() 61Menu::InstEditDialog::~InstEditDialog()
63{ 62{
64} 63}
65//**************************************************************************** 64//****************************************************************************
66void Menu::InstEditDialog::setCurrentInstrumetID(int id) 65void 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//****************************************************************************
74void Menu::InstEditDialog::addInstrument() 73void Menu::InstEditDialog::addInstrument()
75{ 74{
76} 75}
77//**************************************************************************** 76//****************************************************************************
78void Menu::InstEditDialog::deleteInstrument() 77void Menu::InstEditDialog::deleteInstrument()
79{ 78{
80} 79}
81//**************************************************************************** 80//****************************************************************************
82void Menu::InstEditDialog::addLowString() 81void Menu::InstEditDialog::addLowString()
83{ 82{
84} 83}
85//**************************************************************************** 84//****************************************************************************
86void Menu::InstEditDialog::addHighString() 85void Menu::InstEditDialog::addHighString()
87{ 86{
88} 87}
89//**************************************************************************** 88//****************************************************************************
90void Menu::InstEditDialog::deleteString(int id) 89void Menu::InstEditDialog::deleteString(int id)
91{ 90{
92} 91}
93//**************************************************************************** 92//****************************************************************************
94void Menu::InstEditDialog::saveInstrument() 93void 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//****************************************************************************
100void Menu::InstEditDialog::loadInstrument() 99void 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
6using namespace Data; 5using namespace Data;
7 6
8Menu::EditStringWidget::EditStringWidget(int note,QWidget* parent,const char* name,WFlags f) 7Menu::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//****************************************************************************
28Menu::EditStringWidget::~EditStringWidget() 27Menu::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
6MainWidget::MainWidget(QWidget* parent,const char* name,WFlags f) 5MainWidget::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//****************************************************************************
27MainWidget::~MainWidget() 26MainWidget::~MainWidget()
28{ 27{
29} 28}
30//**************************************************************************** 29//****************************************************************************
31void MainWidget::fretboardPressed() 30void 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
9Menu::MenuWidget::MenuWidget(TonleiterData* data,QWidget* parent,const char* name,WFlags f) 7Menu::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//****************************************************************************
67Menu::MenuWidget::~MenuWidget() 65Menu::MenuWidget::~MenuWidget()
68{ 66{
69} 67}
70//**************************************************************************** 68//****************************************************************************
71void Menu::MenuWidget::editInstPressed() 69void 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//****************************************************************************
77void Menu::MenuWidget::editScalePressed() 75void 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//****************************************************************************
83void Menu::MenuWidget::updateBoxes() 81void 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//****************************************************************************