author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/multimedia | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 88 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/threadutil.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 30 | ||||
-rw-r--r-- | noncore/multimedia/powerchord/powerchordbase.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/showimg/ImageFileSelector.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 4 |
13 files changed, 98 insertions, 98 deletions
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index 2f42049..e4e1b6c 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp | |||
@@ -1,486 +1,486 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 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 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #include "previewwidget.h" | 17 | #include "previewwidget.h" |
18 | #include "zcameraio.h" | 18 | #include "zcameraio.h" |
19 | #include "imageio.h" | 19 | #include "imageio.h" |
20 | #include "avi.h" | 20 | #include "avi.h" |
21 | 21 | ||
22 | /* OPIE */ | 22 | /* OPIE */ |
23 | #include <opie2/ofiledialog.h> | 23 | #include <opie2/ofiledialog.h> |
24 | #include <opie2/odevice.h> | 24 | #include <opie2/odevice.h> |
25 | #include <opie2/oapplication.h> | 25 | #include <opie2/oapplication.h> |
26 | #include <opie2/oconfig.h> | 26 | #include <opie2/oconfig.h> |
27 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | using namespace Opie; | 31 | using namespace Opie; |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qaction.h> | 35 | #include <qaction.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qdatastream.h> | 39 | #include <qdatastream.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qimage.h> | 42 | #include <qimage.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qprogressbar.h> | 46 | #include <qprogressbar.h> |
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qdirectpainter_qws.h> | 50 | #include <qdirectpainter_qws.h> |
51 | 51 | ||
52 | /* STD */ | 52 | /* STD */ |
53 | #include <assert.h> | 53 | #include <assert.h> |
54 | #include <sys/types.h> | 54 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <fcntl.h> | 56 | #include <fcntl.h> |
57 | #include <string.h> | 57 | #include <string.h> |
58 | #include <errno.h> | 58 | #include <errno.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | 60 | ||
61 | #define CAPTUREFILE "/tmp/capture.dat" | 61 | #define CAPTUREFILE "/tmp/capture.dat" |
62 | #define OUTPUTFILE "/tmp/output.avi" | 62 | #define OUTPUTFILE "/tmp/output.avi" |
63 | 63 | ||
64 | #define OUTPUT_TO_CUSTOM 250 | 64 | #define OUTPUT_TO_CUSTOM 250 |
65 | #define OUTPUT_TO_DOCFOLDER 251 | 65 | #define OUTPUT_TO_DOCFOLDER 251 |
66 | 66 | ||
67 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) | 67 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) |
68 | :QMainWindow( parent, name, f ), | 68 | :QMainWindow( parent, name, f ), |
69 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) | 69 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) |
70 | _capturing( false ), | 70 | _capturing( false ), |
71 | _pics( 1 ), _videos( 1 ) | 71 | _pics( 1 ), _videos( 1 ) |
72 | { | 72 | { |
73 | #ifdef QT_NO_DEBUG | 73 | #ifdef QT_NO_DEBUG |
74 | if ( !ZCameraIO::instance()->isOpen() ) | 74 | if ( !ZCameraIO::instance()->isOpen() ) |
75 | { | 75 | { |
76 | QVBox* v = new QVBox( this ); | 76 | QVBox* v = new QVBox( this ); |
77 | v->setMargin( 10 ); | 77 | v->setMargin( 10 ); |
78 | QLabel* l1 = new QLabel( v ); | 78 | QLabel* l1 = new QLabel( v ); |
79 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); | 79 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); |
80 | QLabel* l2 = new QLabel( v ); | 80 | QLabel* l2 = new QLabel( v ); |
81 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" | 81 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" |
82 | "* Is the sharpzdc_cs module loaded ?<br>" | 82 | "* Is the sharpzdc_cs module loaded ?<br>" |
83 | "* Is /dev/sharpzdc read/writable ?<p>" ); | 83 | "* Is /dev/sharpzdc read/writable ?<p>" ); |
84 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); | 84 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); |
85 | setCentralWidget( v ); | 85 | setCentralWidget( v ); |
86 | return; | 86 | return; |
87 | } | 87 | } |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | init(); | 90 | init(); |
91 | 91 | ||
92 | _rotation = 270; //TODO: grab these from the actual settings | 92 | _rotation = 270; //TODO: grab these from the actual settings |
93 | 93 | ||
94 | preview = new PreviewWidget( this, "camera preview widget" ); | 94 | preview = new PreviewWidget( this, "camera preview widget" ); |
95 | //setCentralWidget( preview ); <--- don't do this! | 95 | //setCentralWidget( preview ); <--- don't do this! |
96 | preview->resize( QSize( 240, 288 ) ); | 96 | preview->resize( QSize( 240, 288 ) ); |
97 | preview->show(); | 97 | preview->show(); |
98 | 98 | ||
99 | // construct a System Channel to receive setRotation messages | 99 | // construct a System Channel to receive setRotation messages |
100 | _sysChannel = new QCopChannel( "QPE/System", this ); | 100 | _sysChannel = new QCopChannel( "QPE/System", this ); |
101 | connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 101 | connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
102 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 102 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
103 | 103 | ||
104 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); | 104 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); |
105 | 105 | ||
106 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); | 106 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); |
107 | 107 | ||
108 | updateCaption(); | 108 | updateCaption(); |
109 | 109 | ||
110 | }; | 110 | }; |
111 | 111 | ||
112 | 112 | ||
113 | CameraMainWindow::~CameraMainWindow() | 113 | CameraMainWindow::~CameraMainWindow() |
114 | { | 114 | { |
115 | // write back configuration | 115 | // write back configuration |
116 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 116 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
117 | cgs.config()->writeEntry( "flip", flip ); | 117 | cgs.config()->writeEntry( "flip", flip ); |
118 | cgs.config()->writeEntry( "quality", quality ); | 118 | cgs.config()->writeEntry( "quality", quality ); |
119 | cgs.config()->writeEntry( "zoom", zoom ); | 119 | cgs.config()->writeEntry( "zoom", zoom ); |
120 | cgs.config()->writeEntry( "captureX", captureX ); | 120 | cgs.config()->writeEntry( "captureX", captureX ); |
121 | cgs.config()->writeEntry( "captureY", captureY ); | 121 | cgs.config()->writeEntry( "captureY", captureY ); |
122 | cgs.config()->writeEntry( "captureFormat", captureFormat ); | 122 | cgs.config()->writeEntry( "captureFormat", captureFormat ); |
123 | cgs.config()->writeEntry( "outputTo", outputTo ); | 123 | cgs.config()->writeEntry( "outputTo", outputTo ); |
124 | cgs.config()->writeEntry( "prefix", prefix ); | 124 | cgs.config()->writeEntry( "prefix", prefix ); |
125 | cgs.config()->writeEntry( "appendSettings", appendSettings ); | 125 | cgs.config()->writeEntry( "appendSettings", appendSettings ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void CameraMainWindow::init() | 129 | void CameraMainWindow::init() |
130 | { | 130 | { |
131 | // get values from configuration | 131 | // get values from configuration |
132 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 132 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
133 | flip = cgs.config()->readEntry( "flip", "A" ); | 133 | flip = cgs.config()->readEntry( "flip", "A" ); |
134 | quality = cgs.config()->readNumEntry( "quality", 50 ); | 134 | quality = cgs.config()->readNumEntry( "quality", 50 ); |
135 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); | 135 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); |
136 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); | 136 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); |
137 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); | 137 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); |
138 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); | 138 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); |
139 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); | 139 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); |
140 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); | 140 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); |
141 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); | 141 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); |
142 | 142 | ||
143 | // create action groups | 143 | // create action groups |
144 | QAction* a; | 144 | QAction* a; |
145 | resog = new QActionGroup( 0, "reso", true ); | 145 | resog = new QActionGroup( 0, "reso", true ); |
146 | resog->setToggleAction( true ); | 146 | resog->setToggleAction( true ); |
147 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); | 147 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); |
148 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); | 148 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); |
149 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); | 149 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); |
150 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); | 150 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); |
151 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); | 151 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); |
152 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); | 152 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); |
153 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); | 153 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); |
154 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); | 154 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); |
155 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); | 155 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); |
156 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); | 156 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); |
157 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); | 157 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); |
158 | if ( a ) a->setOn( true ); | 158 | if ( a ) a->setOn( true ); |
159 | else owarn << "can't set resolution" << oendl; | 159 | else owarn << "can't set resolution" << oendl; |
160 | 160 | ||
161 | qualityg = new QActionGroup( 0, "quality", true ); | 161 | qualityg = new QActionGroup( 0, "quality", true ); |
162 | qualityg->setToggleAction( true ); | 162 | qualityg->setToggleAction( true ); |
163 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); | 163 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); |
164 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); | 164 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); |
165 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); | 165 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); |
166 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); | 166 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); |
167 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); | 167 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); |
168 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); | 168 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); |
169 | if ( a ) a->setOn( true ); | 169 | if ( a ) a->setOn( true ); |
170 | else owarn << "can't set quality" << oendl; | 170 | else owarn << "can't set quality" << oendl; |
171 | 171 | ||
172 | zoomg = new QActionGroup( 0, "zoom", true ); | 172 | zoomg = new QActionGroup( 0, "zoom", true ); |
173 | zoomg->setToggleAction( true ); | 173 | zoomg->setToggleAction( true ); |
174 | new QAction( "x 1", 0, 0, zoomg, "1", true ); | 174 | new QAction( "x 1", 0, 0, zoomg, "1", true ); |
175 | new QAction( "x 2", 0, 0, zoomg, "2", true ); | 175 | new QAction( "x 2", 0, 0, zoomg, "2", true ); |
176 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); | 176 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); |
177 | if ( a ) a->setOn( true ); | 177 | if ( a ) a->setOn( true ); |
178 | else owarn << "can't set zoom" << oendl; | 178 | else owarn << "can't set zoom" << oendl; |
179 | 179 | ||
180 | flipg = new QActionGroup( 0, "flip", true ); | 180 | flipg = new QActionGroup( 0, "flip", true ); |
181 | flipg->setToggleAction( true ); | 181 | flipg->setToggleAction( true ); |
182 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); | 182 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); |
183 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); | 183 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); |
184 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); | 184 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); |
185 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); | 185 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); |
186 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); | 186 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); |
187 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); | 187 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); |
188 | if ( a ) a->setOn( true ); | 188 | if ( a ) a->setOn( true ); |
189 | else owarn << "can't set flip" << oendl; | 189 | else owarn << "can't set flip" << oendl; |
190 | 190 | ||
191 | outputTog = new QActionGroup( 0, "output", true ); | 191 | outputTog = new QActionGroup( 0, "output", true ); |
192 | outputTog->setToggleAction( true ); | 192 | outputTog->setToggleAction( true ); |
193 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); | 193 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); |
194 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); | 194 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); |
195 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); | 195 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); |
196 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); | 196 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); |
197 | custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? | 197 | custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? |
198 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); | 198 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); |
199 | if ( a ) a->setOn( true ); | 199 | if ( a ) a->setOn( true ); |
200 | else owarn << "can't set outputTo" << oendl; | 200 | else owarn << "can't set outputTo" << oendl; |
201 | 201 | ||
202 | outputg = new QActionGroup( 0, "output", true ); | 202 | outputg = new QActionGroup( 0, "output", true ); |
203 | outputg->setToggleAction( true ); | 203 | outputg->setToggleAction( true ); |
204 | new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); | 204 | new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); |
205 | new QAction( "PNG", 0, 0, outputg, "PNG", true ); | 205 | new QAction( "PNG", 0, 0, outputg, "PNG", true ); |
206 | new QAction( "BMP", 0, 0, outputg, "BMP", true ); | 206 | new QAction( "BMP", 0, 0, outputg, "BMP", true ); |
207 | new QAction( "AVI", 0, 0, outputg, "AVI", true ); | 207 | new QAction( "AVI", 0, 0, outputg, "AVI", true ); |
208 | a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); | 208 | a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); |
209 | if ( a ) a->setOn( true ); | 209 | if ( a ) a->setOn( true ); |
210 | else owarn << "can't set output format" << oendl; | 210 | else owarn << "can't set output format" << oendl; |
211 | 211 | ||
212 | connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); | 212 | connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); |
213 | connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); | 213 | connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); |
214 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); | 214 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); |
215 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); | 215 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); |
216 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); | 216 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); |
217 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); | 217 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) | 221 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) |
222 | { | 222 | { |
223 | int _newrotation; | 223 | int _newrotation; |
224 | 224 | ||
225 | QDataStream stream( data, IO_ReadOnly ); | 225 | QDataStream stream( data, IO_ReadOnly ); |
226 | odebug << "received system message: " << msg << oendl; | 226 | odebug << "received system message: " << msg << oendl; |
227 | if ( msg == "setCurrentRotation(int)" ) | 227 | if ( msg == "setCurrentRotation(int)" ) |
228 | { | 228 | { |
229 | stream >> _newrotation; | 229 | stream >> _newrotation; |
230 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; | 230 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; |
231 | 231 | ||
232 | switch ( _newrotation ) | 232 | switch ( _newrotation ) |
233 | { | 233 | { |
234 | case 270: preview->resize( QSize( 240, 288 ) ); break; | 234 | case 270: preview->resize( QSize( 240, 288 ) ); break; |
235 | case 180: preview->resize( QSize( 320, 208 ) ); break; | 235 | case 180: preview->resize( QSize( 320, 208 ) ); break; |
236 | default: QMessageBox::warning( this, "opie-camera", | 236 | default: QMessageBox::warning( this, "opie-camera", |
237 | "This rotation is not supported.\n" | 237 | "This rotation is not supported.\n" |
238 | "Supported are 180° and 270°" ); | 238 | "Supported are 180° and 270°" ); |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( _newrotation != _rotation ) | 241 | if ( _newrotation != _rotation ) |
242 | { | 242 | { |
243 | int tmp = captureX; | 243 | int tmp = captureX; |
244 | captureX = captureY; | 244 | captureX = captureY; |
245 | captureY = tmp; | 245 | captureY = tmp; |
246 | _rotation = _newrotation; | 246 | _rotation = _newrotation; |
247 | } | 247 | } |
248 | 248 | ||
249 | updateCaption(); | 249 | updateCaption(); |
250 | 250 | ||
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void CameraMainWindow::changeZoom( int zoom ) | 255 | void CameraMainWindow::changeZoom( int zoom ) |
256 | { | 256 | { |
257 | int z; | 257 | int z; |
258 | switch ( zoom ) | 258 | switch ( zoom ) |
259 | { | 259 | { |
260 | case 0: z = 128; break; | 260 | case 0: z = 128; break; |
261 | case 1: z = 256; break; | 261 | case 1: z = 256; break; |
262 | case 2: z = 512; break; | 262 | case 2: z = 512; break; |
263 | default: assert( 0 ); break; | 263 | default: assert( 0 ); break; |
264 | } | 264 | } |
265 | 265 | ||
266 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); | 266 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | void CameraMainWindow::showContextMenu() | 270 | void CameraMainWindow::showContextMenu() |
271 | { | 271 | { |
272 | QPopupMenu reso; | 272 | QPopupMenu reso; |
273 | reso.setCheckable( true ); | 273 | reso.setCheckable( true ); |
274 | resog->addTo( &reso ); | 274 | resog->addTo( &reso ); |
275 | 275 | ||
276 | QPopupMenu quality; | 276 | QPopupMenu quality; |
277 | quality.setCheckable( true ); | 277 | quality.setCheckable( true ); |
278 | qualityg->addTo( &quality ); | 278 | qualityg->addTo( &quality ); |
279 | 279 | ||
280 | QPopupMenu flip; | 280 | QPopupMenu flip; |
281 | flip.setCheckable( true ); | 281 | flip.setCheckable( true ); |
282 | flipg->addTo( &flip ); | 282 | flipg->addTo( &flip ); |
283 | 283 | ||
284 | QPopupMenu zoom; | 284 | QPopupMenu zoom; |
285 | zoom.setCheckable( true ); | 285 | zoom.setCheckable( true ); |
286 | zoomg->addTo( &zoom ); | 286 | zoomg->addTo( &zoom ); |
287 | 287 | ||
288 | QPopupMenu prefix; | 288 | QPopupMenu prefix; |
289 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); | 289 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); |
290 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); | 290 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); |
291 | prefix.setItemChecked( id, appendSettings ); | 291 | prefix.setItemChecked( id, appendSettings ); |
292 | 292 | ||
293 | QPopupMenu outputTo; | 293 | QPopupMenu outputTo; |
294 | outputTo.setCheckable( true ); | 294 | outputTo.setCheckable( true ); |
295 | outputTog->addTo( &outputTo ); | 295 | outputTog->addTo( &outputTo ); |
296 | 296 | ||
297 | QPopupMenu output; | 297 | QPopupMenu output; |
298 | output.setCheckable( true ); | 298 | output.setCheckable( true ); |
299 | outputg->addTo( &output ); | 299 | outputg->addTo( &output ); |
300 | 300 | ||
301 | QPopupMenu m( this ); | 301 | QPopupMenu m( this ); |
302 | m.insertItem( "&Resolution", &reso ); | 302 | m.insertItem( "&Resolution", &reso ); |
303 | m.insertItem( "&Zoom", &zoom ); | 303 | m.insertItem( "&Zoom", &zoom ); |
304 | m.insertItem( "&Flip", &flip ); | 304 | m.insertItem( "&Flip", &flip ); |
305 | m.insertItem( "&Quality", &quality ); | 305 | m.insertItem( "&Quality", &quality ); |
306 | m.insertSeparator(); | 306 | m.insertSeparator(); |
307 | m.insertItem( "&Prefix", &prefix ); | 307 | m.insertItem( "&Prefix", &prefix ); |
308 | m.insertItem( "Output &To", &outputTo ); | 308 | m.insertItem( "Output &To", &outputTo ); |
309 | m.insertItem( "&Output As", &output ); | 309 | m.insertItem( "&Output As", &output ); |
310 | 310 | ||
311 | #ifndef QT_NO_DEBUG | 311 | #ifndef QT_NO_DEBUG |
312 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); | 312 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); |
313 | #endif | 313 | #endif |
314 | 314 | ||
315 | m.exec( QCursor::pos() ); | 315 | m.exec( QCursor::pos() ); |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) | 319 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) |
320 | { | 320 | { |
321 | switch ( _rotation ) | 321 | switch ( _rotation ) |
322 | { | 322 | { |
323 | case 270: | 323 | case 270: |
324 | captureY = a->text().left(3).toInt(); | 324 | captureY = a->text().left(3).toInt(); |
325 | captureX = a->text().right(3).toInt(); | 325 | captureX = a->text().right(3).toInt(); |
326 | break; | 326 | break; |
327 | case 180: | 327 | case 180: |
328 | captureX = a->text().left(3).toInt(); | 328 | captureX = a->text().left(3).toInt(); |
329 | captureY = a->text().right(3).toInt(); | 329 | captureY = a->text().right(3).toInt(); |
330 | break; | 330 | break; |
331 | default: QMessageBox::warning( this, "opie-camera", | 331 | default: QMessageBox::warning( this, "opie-camera", |
332 | "This rotation is not supported.\n" | 332 | "This rotation is not supported.\n" |
333 | "Supported are 180° and 270°" ); | 333 | "Supported are 180° and 270°" ); |
334 | } | 334 | } |
335 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; | 335 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; |
336 | updateCaption(); | 336 | updateCaption(); |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) | 340 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) |
341 | { | 341 | { |
342 | quality = a->text().left(3).toInt(); | 342 | quality = a->text().left(3).toInt(); |
343 | odebug << "Quality now: " << quality << oendl; | 343 | odebug << "Quality now: " << quality << oendl; |
344 | updateCaption(); | 344 | updateCaption(); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) | 348 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) |
349 | { | 349 | { |
350 | zoom = QString( a->text().at(2) ).toInt(); | 350 | zoom = QString( a->text().at(2) ).toInt(); |
351 | odebug << "Zoom now: " << zoom << oendl; | 351 | odebug << "Zoom now: " << zoom << oendl; |
352 | ZCameraIO::instance()->setZoom( zoom ); | 352 | ZCameraIO::instance()->setZoom( zoom ); |
353 | updateCaption(); | 353 | updateCaption(); |
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | ||
357 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) | 357 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) |
358 | { | 358 | { |
359 | flip = QString( a->text().at(0) ); | 359 | flip = QString( a->text().at(0) ); |
360 | odebug << "Flip now: " << flip << oendl; | 360 | odebug << "Flip now: " << flip << oendl; |
361 | if ( flip == "A" ) | 361 | if ( flip == "A" ) |
362 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | 362 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); |
363 | else if ( flip == "0" ) | 363 | else if ( flip == "0" ) |
364 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | 364 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); |
365 | else if ( flip == "X" ) | 365 | else if ( flip == "X" ) |
366 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | 366 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); |
367 | else if ( flip == "Y" ) | 367 | else if ( flip == "Y" ) |
368 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | 368 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); |
369 | else if ( flip == "*" ) | 369 | else if ( flip == "*" ) |
370 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | 370 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); |
371 | 371 | ||
372 | updateCaption(); | 372 | updateCaption(); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) | 376 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) |
377 | { | 377 | { |
378 | if ( a->text() == "&Custom..." ) | 378 | if ( a->text() == "&Custom..." ) |
379 | { | 379 | { |
380 | QMap<QString, QStringList> map; | 380 | QMap<QString, QStringList> map; |
381 | map.insert( tr("All"), QStringList() ); | 381 | map.insert( tr("All"), QStringList() ); |
382 | QStringList text; | 382 | QStringList text; |
383 | text << "text/*"; | 383 | text << "text/*"; |
384 | map.insert(tr("Text"), text ); | 384 | map.insert(tr("Text"), text ); |
385 | text << "*"; | 385 | text << "*"; |
386 | map.insert(tr("All"), text ); | 386 | map.insert(tr("All"), text ); |
387 | 387 | ||
388 | QString str; | 388 | QString str; |
389 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 389 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
390 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) | 390 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) |
391 | { | 391 | { |
392 | docfolder->setOn( true ); | 392 | docfolder->setOn( true ); |
393 | outputTo = "Documents Folder"; | 393 | outputTo = "Documents Folder"; |
394 | } | 394 | } |
395 | else | 395 | else |
396 | { | 396 | { |
397 | outputTo = str; | 397 | outputTo = str; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | else | 400 | else |
401 | { | 401 | { |
402 | outputTo = a->text(); | 402 | outputTo = a->text(); |
403 | } | 403 | } |
404 | odebug << "Output to now: " << outputTo << oendl; | 404 | odebug << "Output to now: " << outputTo << oendl; |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) | 408 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) |
409 | { | 409 | { |
410 | captureFormat = a->text(); | 410 | captureFormat = a->text(); |
411 | odebug << "Output format now: " << captureFormat << oendl; | 411 | odebug << "Output format now: " << captureFormat << oendl; |
412 | updateCaption(); | 412 | updateCaption(); |
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | void CameraMainWindow::prefixItemChoosen() | 416 | void CameraMainWindow::prefixItemChoosen() |
417 | { | 417 | { |
418 | QDialog* d = new QDialog( this, "dialog", true ); | 418 | QDialog* d = new QDialog( this, "dialog", true ); |
419 | d->setCaption( "Enter Prefix..." ); | 419 | d->setCaption( "Enter Prefix..." ); |
420 | QVBoxLayout* v = new QVBoxLayout( d ); | 420 | QVBoxLayout* v = new QVBoxLayout( d ); |
421 | QLineEdit* le = new QLineEdit( prefix, d ); | 421 | QLineEdit* le = new QLineEdit( prefix, d ); |
422 | v->addWidget( le ); | 422 | v->addWidget( le ); |
423 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty | 423 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty |
424 | if ( d->exec() == QDialog::Accepted ) | 424 | if ( d->exec() == QDialog::Accepted ) |
425 | prefix = le->text(); | 425 | prefix = le->text(); |
426 | odebug << "Prefix now: " << prefix << oendl; | 426 | odebug << "Prefix now: " << prefix << oendl; |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void CameraMainWindow::appendSettingsChoosen() | 430 | void CameraMainWindow::appendSettingsChoosen() |
431 | { | 431 | { |
432 | appendSettings = !appendSettings; | 432 | appendSettings = !appendSettings; |
433 | odebug << "appendSettings now: " << appendSettings << oendl; | 433 | odebug << "appendSettings now: " << appendSettings << oendl; |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void CameraMainWindow::shutterClicked() | 437 | void CameraMainWindow::shutterClicked() |
438 | { | 438 | { |
439 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick | 439 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick |
440 | { | 440 | { |
441 | Global::statusMessage( "CAPTURING..." ); | 441 | Global::statusMessage( "CAPTURING..." ); |
442 | qApp->processEvents(); | 442 | qApp->processEvents(); |
443 | 443 | ||
444 | odebug << "Shutter has been pressed" << oendl; | 444 | odebug << "Shutter has been pressed" << oendl; |
445 | ODevice::inst()->playTouchSound(); | 445 | ODevice::inst()->playTouchSound(); |
446 | 446 | ||
447 | performCapture( captureFormat ); | 447 | performCapture( captureFormat ); |
448 | } | 448 | } |
449 | else // capture video! start with one shutter click and stop with the next | 449 | else // capture video! start with one shutter click and stop with the next |
450 | { | 450 | { |
451 | !_capturing ? startVideoCapture() : stopVideoCapture(); | 451 | !_capturing ? startVideoCapture() : stopVideoCapture(); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | void CameraMainWindow::performCapture( const QString& format ) | 456 | void CameraMainWindow::performCapture( const QString& format ) |
457 | { | 457 | { |
458 | QString name; | 458 | QString name; |
459 | 459 | ||
460 | if ( outputTo == "Documents Folder" ) | 460 | if ( outputTo == "Documents Folder" ) |
461 | { | 461 | { |
462 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 462 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
463 | if ( !QDir( name ).exists() ) | 463 | if ( !QDir( name ).exists() ) |
464 | { | 464 | { |
465 | odebug << "creating directory " << name << oendl; | 465 | odebug << "creating directory " << name << oendl; |
466 | QString msg = "mkdir -p " + name; | 466 | QString msg = "mkdir -p " + name; |
467 | system( msg.latin1() ); | 467 | system( msg.latin1() ); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | else | 470 | else |
471 | name = outputTo; | 471 | name = outputTo; |
472 | 472 | ||
473 | name.append( prefix ); | 473 | name.append( prefix ); |
474 | if ( appendSettings ) | 474 | if ( appendSettings ) |
475 | { | 475 | { |
476 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); | 476 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); |
477 | } | 477 | } |
478 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); | 478 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); |
479 | 479 | ||
480 | QImage i; | 480 | QImage i; |
481 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | 481 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); |
482 | QImage im = i.convertDepth( 32 ); | 482 | QImage im = i.convertDepth( 32 ); |
483 | bool result = im.save( name, format, quality ); | 483 | bool result = im.save( name, format, quality ); |
484 | if ( !result ) | 484 | if ( !result ) |
485 | { | 485 | { |
486 | oerr << "imageio-Problem while writing." << oendl; | 486 | oerr << "imageio-Problem while writing." << oendl; |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 870b4f3..f3eafab 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,326 +1,326 @@ | |||
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" | 36 | #include "mediaplayerstate.h" |
37 | #include "playlistwidget.h" | 37 | #include "playlistwidget.h" |
38 | 38 | ||
39 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
40 | 40 | ||
41 | namespace | 41 | namespace |
42 | { | 42 | { |
43 | 43 | ||
44 | const int xo = -2; // movable x offset | 44 | const int xo = -2; // movable x offset |
45 | const int yo = 22; // movable y offset | 45 | const int yo = 22; // movable y offset |
46 | 46 | ||
47 | const MediaWidget::SkinButtonInfo skinInfo[] = | 47 | const MediaWidget::SkinButtonInfo skinInfo[] = |
48 | { | 48 | { |
49 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 49 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
50 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 50 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
51 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | 51 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, |
52 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | 52 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, |
53 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 53 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
54 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 54 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
55 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 55 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
56 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 56 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
57 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 57 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
58 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 58 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
59 | }; | 59 | }; |
60 | 60 | ||
61 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 61 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
62 | 62 | ||
63 | void changeTextColor( QWidget * w) { | 63 | void changeTextColor( QWidget * w) { |
64 | QPalette p = w->palette(); | 64 | QPalette p = w->palette(); |
65 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 65 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
66 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 66 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
67 | w->setPalette( p ); | 67 | w->setPalette( p ); |
68 | } | 68 | } |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 72 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
73 | 73 | ||
74 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 74 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
75 | audioSliderBeingMoved( false ) | 75 | audioSliderBeingMoved( false ) |
76 | { | 76 | { |
77 | setCaption( tr("OpiePlayer") ); | 77 | setCaption( tr("OpiePlayer") ); |
78 | 78 | ||
79 | loadSkin(); | 79 | loadSkin(); |
80 | 80 | ||
81 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 81 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
82 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 82 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); |
83 | 83 | ||
84 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 84 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
85 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 85 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
86 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 86 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
87 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 87 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
88 | 88 | ||
89 | // Intialise state | 89 | // Intialise state |
90 | setLength( mediaPlayerState.length() ); | 90 | setLength( mediaPlayerState.length() ); |
91 | setPosition( mediaPlayerState.position() ); | 91 | setPosition( mediaPlayerState.position() ); |
92 | setLooping( mediaPlayerState.isFullscreen() ); | 92 | setLooping( mediaPlayerState.isFullscreen() ); |
93 | // setPaused( mediaPlayerState->paused() ); | 93 | // setPaused( mediaPlayerState->paused() ); |
94 | setPlaying( mediaPlayerState.isPlaying() ); | 94 | setPlaying( mediaPlayerState.isPlaying() ); |
95 | } | 95 | } |
96 | 96 | ||
97 | AudioWidget::~AudioWidget() { | 97 | AudioWidget::~AudioWidget() { |
98 | 98 | ||
99 | // mediaPlayerState->setPlaying(false); | 99 | // mediaPlayerState->setPlaying(false); |
100 | } | 100 | } |
101 | 101 | ||
102 | MediaWidget::GUIInfo AudioWidget::guiInfo() | 102 | MediaWidget::GUIInfo AudioWidget::guiInfo() |
103 | { | 103 | { |
104 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); | 104 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); |
105 | } | 105 | } |
106 | 106 | ||
107 | void AudioWidget::resizeEvent( QResizeEvent *e ) { | 107 | void AudioWidget::resizeEvent( QResizeEvent *e ) { |
108 | int h = height(); | 108 | int h = height(); |
109 | int w = width(); | 109 | int w = width(); |
110 | 110 | ||
111 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 111 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
112 | slider.setFixedWidth( w - 110 ); | 112 | slider.setFixedWidth( w - 110 ); |
113 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 113 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
114 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 114 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
115 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 115 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
116 | 116 | ||
117 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; | 117 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; |
118 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; | 118 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; |
119 | 119 | ||
120 | MediaWidget::resizeEvent( e ); | 120 | MediaWidget::resizeEvent( e ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void AudioWidget::sliderPressed() { | 123 | void AudioWidget::sliderPressed() { |
124 | audioSliderBeingMoved = TRUE; | 124 | audioSliderBeingMoved = TRUE; |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void AudioWidget::sliderReleased() { | 128 | void AudioWidget::sliderReleased() { |
129 | audioSliderBeingMoved = FALSE; | 129 | audioSliderBeingMoved = FALSE; |
130 | if ( slider.width() == 0 ) | 130 | if ( slider.width() == 0 ) |
131 | return; | 131 | return; |
132 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 132 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
133 | mediaPlayerState.setPosition( val ); | 133 | mediaPlayerState.setPosition( val ); |
134 | } | 134 | } |
135 | 135 | ||
136 | void AudioWidget::setPosition( long i ) { | 136 | void AudioWidget::setPosition( long i ) { |
137 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 137 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
138 | updateSlider( i, mediaPlayerState.length() ); | 138 | updateSlider( i, mediaPlayerState.length() ); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void AudioWidget::setLength( long max ) { | 142 | void AudioWidget::setLength( long max ) { |
143 | updateSlider( mediaPlayerState.position(), max ); | 143 | updateSlider( mediaPlayerState.position(), max ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 147 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
148 | if ( mediaType == MediaPlayerState::Audio ) { | 148 | if ( mediaType == MediaPlayerState::Audio ) { |
149 | // startTimer( 150 ); | 149 | // startTimer( 150 ); |
150 | QPEApplication::showWidget( this ); | 150 | QPEApplication::showWidget( this ); |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | 153 | ||
154 | killTimers(); | 154 | killTimers(); |
155 | hide(); | 155 | hide(); |
156 | } | 156 | } |
157 | 157 | ||
158 | void AudioWidget::loadSkin() | 158 | void AudioWidget::loadSkin() |
159 | { | 159 | { |
160 | loadDefaultSkin( guiInfo() ); | 160 | loadDefaultSkin( guiInfo() ); |
161 | 161 | ||
162 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 162 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
163 | // changeTextColor( &songInfo ); | 163 | // changeTextColor( &songInfo ); |
164 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 164 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
165 | // songInfo.setFrameStyle( QFrame::NoFrame); | 165 | // songInfo.setFrameStyle( QFrame::NoFrame); |
166 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 166 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
167 | // songInfo.setForegroundColor(Qt::white); | 167 | // songInfo.setForegroundColor(Qt::white); |
168 | 168 | ||
169 | slider.setFixedHeight( 20 ); | 169 | slider.setFixedHeight( 20 ); |
170 | slider.setMinValue( 0 ); | 170 | slider.setMinValue( 0 ); |
171 | slider.setMaxValue( 1 ); | 171 | slider.setMaxValue( 1 ); |
172 | slider.setFocusPolicy( QWidget::NoFocus ); | 172 | slider.setFocusPolicy( QWidget::NoFocus ); |
173 | slider.setBackgroundPixmap( backgroundPixmap ); | 173 | slider.setBackgroundPixmap( backgroundPixmap ); |
174 | 174 | ||
175 | // Config cofg("qpe"); | 175 | // Config cofg("qpe"); |
176 | // cofg.setGroup("Appearance"); | 176 | // cofg.setGroup("Appearance"); |
177 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 177 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
178 | 178 | ||
179 | time.setFocusPolicy( QWidget::NoFocus ); | 179 | time.setFocusPolicy( QWidget::NoFocus ); |
180 | time.setAlignment( Qt::AlignCenter ); | 180 | time.setAlignment( Qt::AlignCenter ); |
181 | 181 | ||
182 | // time.setFrame(FALSE); | 182 | // time.setFrame(FALSE); |
183 | // changeTextColor( &time ); | 183 | // changeTextColor( &time ); |
184 | 184 | ||
185 | resizeEvent( 0 ); | 185 | resizeEvent( 0 ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void AudioWidget::setSeekable( bool isSeekable ) { | 188 | void AudioWidget::setSeekable( bool isSeekable ) { |
189 | 189 | ||
190 | if ( !isSeekable ) { | 190 | if ( !isSeekable ) { |
191 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 191 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
192 | if( !slider.isHidden()) { | 192 | if( !slider.isHidden()) { |
193 | slider.hide(); | 193 | slider.hide(); |
194 | } | 194 | } |
195 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 195 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
196 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 196 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
197 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 197 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
198 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 198 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
199 | } else { | 199 | } else { |
200 | // this stops the slider from being moved, thus | 200 | // this stops the slider from being moved, thus |
201 | // does not stop stream when it reaches the end | 201 | // does not stop stream when it reaches the end |
202 | slider.show(); | 202 | slider.show(); |
203 | qDebug( " CONNECT SET POSTION " ); | 203 | qDebug( " CONNECT SET POSTION " ); |
204 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 204 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
205 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 205 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
206 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 206 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
207 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 207 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | static QString timeAsString( long length ) { | 212 | static QString timeAsString( long length ) { |
213 | int minutes = length / 60; | 213 | int minutes = length / 60; |
214 | int seconds = length % 60; | 214 | int seconds = length % 60; |
215 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 215 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
216 | } | 216 | } |
217 | 217 | ||
218 | void AudioWidget::updateSlider( long i, long max ) { | 218 | void AudioWidget::updateSlider( long i, long max ) { |
219 | 219 | ||
220 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 220 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
221 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 221 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
222 | 222 | ||
223 | if ( max == 0 ) { | 223 | if ( max == 0 ) { |
224 | return; | 224 | return; |
225 | } | 225 | } |
226 | // Will flicker too much if we don't do this | 226 | // Will flicker too much if we don't do this |
227 | // Scale to something reasonable | 227 | // Scale to something reasonable |
228 | int width = slider.width(); | 228 | int width = slider.width(); |
229 | int val = int((double)i * width / max); | 229 | int val = int((double)i * width / max); |
230 | if ( !audioSliderBeingMoved ) { | 230 | if ( !audioSliderBeingMoved ) { |
231 | if ( slider.value() != val ) { | 231 | if ( slider.value() != val ) { |
232 | slider.setValue( val ); | 232 | slider.setValue( val ); |
233 | } | 233 | } |
234 | 234 | ||
235 | if ( slider.maxValue() != width ) { | 235 | if ( slider.maxValue() != width ) { |
236 | slider.setMaxValue( width ); | 236 | slider.setMaxValue( width ); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | void AudioWidget::skipFor() { | 241 | void AudioWidget::skipFor() { |
242 | skipDirection = +1; | 242 | skipDirection = +1; |
243 | startTimer( 50 ); | 243 | startTimer( 50 ); |
244 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 244 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
245 | } | 245 | } |
246 | 246 | ||
247 | void AudioWidget::skipBack() { | 247 | void AudioWidget::skipBack() { |
248 | skipDirection = -1; | 248 | skipDirection = -1; |
249 | startTimer( 50 ); | 249 | startTimer( 50 ); |
250 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 250 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | 254 | ||
255 | void AudioWidget::stopSkip() { | 255 | void AudioWidget::stopSkip() { |
256 | killTimers(); | 256 | killTimers(); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void AudioWidget::timerEvent( QTimerEvent * ) { | 260 | void AudioWidget::timerEvent( QTimerEvent * ) { |
261 | if ( skipDirection == +1 ) { | 261 | if ( skipDirection == +1 ) { |
262 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 262 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
263 | } else if ( skipDirection == -1 ) { | 263 | } else if ( skipDirection == -1 ) { |
264 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 264 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 268 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
269 | switch ( e->key() ) { | 269 | switch ( e->key() ) { |
270 | ////////////////////////////// Zaurus keys | 270 | ////////////////////////////// Zaurus keys |
271 | case Key_Home: | 271 | case Key_Home: |
272 | break; | 272 | break; |
273 | case Key_F9: //activity | 273 | case Key_F9: //activity |
274 | hide(); | 274 | hide(); |
275 | // qDebug("Audio F9"); | 275 | // qDebug("Audio F9"); |
276 | e->accept(); | 276 | e->accept(); |
277 | break; | 277 | break; |
278 | case Key_F10: //contacts | 278 | case Key_F10: //contacts |
279 | break; | 279 | break; |
280 | case Key_F11: //menu | 280 | case Key_F11: //menu |
281 | mediaPlayerState.toggleBlank(); | 281 | mediaPlayerState.toggleBlank(); |
282 | e->accept(); | 282 | e->accept(); |
283 | break; | 283 | break; |
284 | case Key_F12: //home | 284 | case Key_F12: //home |
285 | break; | 285 | break; |
286 | case Key_F13: //mail | 286 | case Key_F13: //mail |
287 | mediaPlayerState.toggleBlank(); | 287 | mediaPlayerState.toggleBlank(); |
288 | e->accept(); | 288 | e->accept(); |
289 | break; | 289 | break; |
290 | case Key_Space: { | 290 | case Key_Space: { |
291 | e->accept(); | 291 | e->accept(); |
292 | mediaPlayerState.togglePaused(); | 292 | mediaPlayerState.togglePaused(); |
293 | } | 293 | } |
294 | break; | 294 | break; |
295 | case Key_Down: | 295 | case Key_Down: |
296 | // toggleButton(6); | 296 | // toggleButton(6); |
297 | emit lessClicked(); | 297 | emit lessClicked(); |
298 | emit lessReleased(); | 298 | emit lessReleased(); |
299 | // toggleButton(6); | 299 | // toggleButton(6); |
300 | e->accept(); | 300 | e->accept(); |
301 | break; | 301 | break; |
302 | case Key_Up: | 302 | case Key_Up: |
303 | // toggleButton(5); | 303 | // toggleButton(5); |
304 | emit moreClicked(); | 304 | emit moreClicked(); |
305 | emit moreReleased(); | 305 | emit moreReleased(); |
306 | // toggleButton(5); | 306 | // toggleButton(5); |
307 | e->accept(); | 307 | e->accept(); |
308 | break; | 308 | break; |
309 | case Key_Right: | 309 | case Key_Right: |
310 | // toggleButton(3); | 310 | // toggleButton(3); |
311 | mediaPlayerState.setNext(); | 311 | mediaPlayerState.setNext(); |
312 | // toggleButton(3); | 312 | // toggleButton(3); |
313 | e->accept(); | 313 | e->accept(); |
314 | break; | 314 | break; |
315 | case Key_Left: | 315 | case Key_Left: |
316 | // toggleButton(4); | 316 | // toggleButton(4); |
317 | mediaPlayerState.setPrev(); | 317 | mediaPlayerState.setPrev(); |
318 | // toggleButton(4); | 318 | // toggleButton(4); |
319 | e->accept(); | 319 | e->accept(); |
320 | break; | 320 | break; |
321 | case Key_Escape: { | 321 | case Key_Escape: { |
322 | } | 322 | } |
323 | break; | 323 | break; |
324 | 324 | ||
325 | }; | 325 | }; |
326 | } | 326 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 9f51006..1e6bc4d 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,405 +1,405 @@ | |||
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> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | #include <qfileinfo.h> | 4 | #include <qfileinfo.h> |
5 | 5 | ||
6 | #include "mediaplayer.h" | 6 | #include "mediaplayer.h" |
7 | #include "playlistwidget.h" | 7 | #include "playlistwidget.h" |
8 | #include "audiowidget.h" | 8 | #include "audiowidget.h" |
9 | #include "videowidget.h" | 9 | #include "videowidget.h" |
10 | #include "volumecontrol.h" | 10 | #include "volumecontrol.h" |
11 | #include "lib.h" | 11 | #include "lib.h" |
12 | 12 | ||
13 | #include "mediaplayerstate.h" | 13 | #include "mediaplayerstate.h" |
14 | 14 | ||
15 | // for setBacklight() | 15 | // for setBacklight() |
16 | #include <linux/fb.h> | 16 | #include <linux/fb.h> |
17 | #include <sys/file.h> | 17 | #include <sys/file.h> |
18 | #include <sys/ioctl.h> | 18 | #include <sys/ioctl.h> |
19 | 19 | ||
20 | 20 | ||
21 | #define FBIOBLANK 0x4611 | 21 | #define FBIOBLANK 0x4611 |
22 | 22 | ||
23 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 23 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
24 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 24 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
25 | 25 | ||
26 | m_audioUI = 0; | 26 | m_audioUI = 0; |
27 | m_videoUI = 0; | 27 | m_videoUI = 0; |
28 | m_xineControl = 0; | 28 | m_xineControl = 0; |
29 | xine = new XINE::Lib( XINE::Lib::InitializeInThread ); | 29 | xine = new XINE::Lib( XINE::Lib::InitializeInThread ); |
30 | 30 | ||
31 | fd=-1;fl=-1; | 31 | fd=-1;fl=-1; |
32 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 32 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
33 | 33 | ||
34 | qApp->processEvents(); | 34 | qApp->processEvents(); |
35 | // QPEApplication::grabKeyboard(); // EVIL | 35 | // QPEApplication::grabKeyboard(); // EVIL |
36 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 36 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
37 | 37 | ||
38 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 38 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
39 | 39 | ||
40 | // What is pauseCheck good for? (Simon) | 40 | // What is pauseCheck good for? (Simon) |
41 | // connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 41 | // connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); |
42 | 42 | ||
43 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 43 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
44 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 44 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
45 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 45 | connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); |
46 | 46 | ||
47 | volControl = new VolumeControl; | 47 | volControl = new VolumeControl; |
48 | Config cfg( "OpiePlayer" ); | 48 | Config cfg( "OpiePlayer" ); |
49 | cfg.setGroup("PlayList"); | 49 | cfg.setGroup("PlayList"); |
50 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 50 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
51 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 51 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
52 | 52 | ||
53 | m_skinLoader = new SkinLoader; | 53 | m_skinLoader = new SkinLoader; |
54 | m_skinLoader->schedule( AudioWidget::guiInfo() ); | 54 | m_skinLoader->schedule( AudioWidget::guiInfo() ); |
55 | m_skinLoader->schedule( VideoWidget::guiInfo() ); | 55 | m_skinLoader->schedule( VideoWidget::guiInfo() ); |
56 | m_skinLoader->start(); | 56 | m_skinLoader->start(); |
57 | } | 57 | } |
58 | 58 | ||
59 | MediaPlayer::~MediaPlayer() { | 59 | MediaPlayer::~MediaPlayer() { |
60 | // this shold never happen, but one never knows... | 60 | // this shold never happen, but one never knows... |
61 | if ( xine ) { | 61 | if ( xine ) { |
62 | xine->ensureInitialized(); | 62 | xine->ensureInitialized(); |
63 | delete xine; | 63 | delete xine; |
64 | } | 64 | } |
65 | delete m_xineControl; | 65 | delete m_xineControl; |
66 | delete m_audioUI; | 66 | delete m_audioUI; |
67 | delete m_videoUI; | 67 | delete m_videoUI; |
68 | delete volControl; | 68 | delete volControl; |
69 | } | 69 | } |
70 | 70 | ||
71 | void MediaPlayer::pauseCheck( bool b ) { | 71 | void MediaPlayer::pauseCheck( bool b ) { |
72 | if ( b && !mediaPlayerState.isPlaying() ) { | 72 | if ( b && !mediaPlayerState.isPlaying() ) { |
73 | mediaPlayerState.setPaused( FALSE ); | 73 | mediaPlayerState.setPaused( FALSE ); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | void MediaPlayer::play() { | 77 | void MediaPlayer::play() { |
78 | mediaPlayerState.setPlaying( FALSE ); | 78 | mediaPlayerState.setPlaying( FALSE ); |
79 | mediaPlayerState.setPlaying( TRUE ); | 79 | mediaPlayerState.setPlaying( TRUE ); |
80 | } | 80 | } |
81 | 81 | ||
82 | void MediaPlayer::setPlaying( bool play ) { | 82 | void MediaPlayer::setPlaying( bool play ) { |
83 | if ( !play ) { | 83 | if ( !play ) { |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | if ( mediaPlayerState.isPaused() ) { | 87 | if ( mediaPlayerState.isPaused() ) { |
88 | mediaPlayerState.setPaused( FALSE ); | 88 | mediaPlayerState.setPaused( FALSE ); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | 91 | ||
92 | QString tickerText, time, fileName; | 92 | QString tickerText, time, fileName; |
93 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 93 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
94 | //if playing in file list.. play in a different way | 94 | //if playing in file list.. play in a different way |
95 | // random and looping settings enabled causes problems here, | 95 | // 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, | 96 | // since there is no selected file in the playlist, but a selected file in the file list, |
97 | // so we remember and shutoff | 97 | // so we remember and shutoff |
98 | l = mediaPlayerState.isLooping(); | 98 | l = mediaPlayerState.isLooping(); |
99 | if(l) { | 99 | if(l) { |
100 | mediaPlayerState.setLooping( false ); | 100 | mediaPlayerState.setLooping( false ); |
101 | } | 101 | } |
102 | r = mediaPlayerState.isShuffled(); | 102 | r = mediaPlayerState.isShuffled(); |
103 | mediaPlayerState.setShuffled( false ); | 103 | mediaPlayerState.setShuffled( false ); |
104 | } | 104 | } |
105 | 105 | ||
106 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 106 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
107 | fileName = playListEntry.name; | 107 | fileName = playListEntry.name; |
108 | xineControl()->play( playListEntry.file ); | 108 | xineControl()->play( playListEntry.file ); |
109 | 109 | ||
110 | long seconds = mediaPlayerState.length(); | 110 | long seconds = mediaPlayerState.length(); |
111 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 111 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
112 | 112 | ||
113 | if( fileName.left(4) == "http" ) { | 113 | if( fileName.left(4) == "http" ) { |
114 | fileName = QFileInfo( fileName ).baseName(); | 114 | fileName = QFileInfo( fileName ).baseName(); |
115 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 115 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
116 | tickerText = tr( " File: " ) + fileName; | 116 | tickerText = tr( " File: " ) + fileName; |
117 | } else { | 117 | } else { |
118 | tickerText = xineControl()->getMetaInfo(); | 118 | tickerText = xineControl()->getMetaInfo(); |
119 | } | 119 | } |
120 | } else { | 120 | } else { |
121 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 121 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
122 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 122 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
123 | } else { | 123 | } else { |
124 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; | 124 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | audioUI()->setTickerText( tickerText ); | 127 | audioUI()->setTickerText( tickerText ); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | void MediaPlayer::prev() { | 131 | void MediaPlayer::prev() { |
132 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 132 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
133 | if ( playList.prev() ) { | 133 | if ( playList.prev() ) { |
134 | play(); | 134 | play(); |
135 | } else if ( mediaPlayerState.isLooping() ) { | 135 | } else if ( mediaPlayerState.isLooping() ) { |
136 | if ( playList.last() ) { | 136 | if ( playList.last() ) { |
137 | play(); | 137 | play(); |
138 | } | 138 | } |
139 | } else { | 139 | } else { |
140 | mediaPlayerState.setList(); | 140 | mediaPlayerState.setList(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void MediaPlayer::next() { | 146 | void MediaPlayer::next() { |
147 | 147 | ||
148 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 148 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
149 | if ( playList.next() ) { | 149 | if ( playList.next() ) { |
150 | play(); | 150 | play(); |
151 | } else if ( mediaPlayerState.isLooping() ) { | 151 | } else if ( mediaPlayerState.isLooping() ) { |
152 | if ( playList.first() ) { | 152 | if ( playList.first() ) { |
153 | play(); | 153 | play(); |
154 | } | 154 | } |
155 | } else { | 155 | } else { |
156 | mediaPlayerState.setList(); | 156 | mediaPlayerState.setList(); |
157 | } | 157 | } |
158 | } else { //if playing from file list, let's just stop | 158 | } else { //if playing from file list, let's just stop |
159 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 159 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
160 | mediaPlayerState.setPlaying(false); | 160 | mediaPlayerState.setPlaying(false); |
161 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 161 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
162 | if(l) mediaPlayerState.setLooping(l); | 162 | if(l) mediaPlayerState.setLooping(l); |
163 | if(r) mediaPlayerState.setShuffled(r); | 163 | if(r) mediaPlayerState.setShuffled(r); |
164 | } | 164 | } |
165 | qApp->processEvents(); | 165 | qApp->processEvents(); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | void MediaPlayer::startDecreasingVolume() { | 169 | void MediaPlayer::startDecreasingVolume() { |
170 | volumeDirection = -1; | 170 | volumeDirection = -1; |
171 | startTimer( 100 ); | 171 | startTimer( 100 ); |
172 | volControl->decVol(2); | 172 | volControl->decVol(2); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void MediaPlayer::startIncreasingVolume() { | 176 | void MediaPlayer::startIncreasingVolume() { |
177 | volumeDirection = +1; | 177 | volumeDirection = +1; |
178 | startTimer( 100 ); | 178 | startTimer( 100 ); |
179 | volControl->incVol(2); | 179 | volControl->incVol(2); |
180 | } | 180 | } |
181 | 181 | ||
182 | 182 | ||
183 | bool drawnOnScreenDisplay = FALSE; | 183 | bool drawnOnScreenDisplay = FALSE; |
184 | unsigned int onScreenDisplayVolume = 0; | 184 | unsigned int onScreenDisplayVolume = 0; |
185 | const int yoff = 110; | 185 | const int yoff = 110; |
186 | 186 | ||
187 | void MediaPlayer::stopChangingVolume() { | 187 | void MediaPlayer::stopChangingVolume() { |
188 | killTimers(); | 188 | killTimers(); |
189 | // Get rid of the on-screen display stuff | 189 | // Get rid of the on-screen display stuff |
190 | drawnOnScreenDisplay = FALSE; | 190 | drawnOnScreenDisplay = FALSE; |
191 | onScreenDisplayVolume = 0; | 191 | onScreenDisplayVolume = 0; |
192 | int w=0; | 192 | int w=0; |
193 | int h=0; | 193 | int h=0; |
194 | if( !xineControl()->hasVideo() ) { | 194 | if( !xineControl()->hasVideo() ) { |
195 | w = audioUI()->width(); | 195 | w = audioUI()->width(); |
196 | h = audioUI()->height(); | 196 | h = audioUI()->height(); |
197 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 197 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
198 | } else { | 198 | } else { |
199 | w = videoUI()->width(); | 199 | w = videoUI()->width(); |
200 | h = videoUI()->height(); | 200 | h = videoUI()->height(); |
201 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 201 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 206 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
207 | if ( volumeDirection == +1 ) { | 207 | if ( volumeDirection == +1 ) { |
208 | volControl->incVol( 2 ); | 208 | volControl->incVol( 2 ); |
209 | } else if ( volumeDirection == -1 ) { | 209 | } else if ( volumeDirection == -1 ) { |
210 | volControl->decVol( 2 ); | 210 | volControl->decVol( 2 ); |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | // TODO FIXME | 214 | // TODO FIXME |
215 | // huh?? | 215 | // huh?? |
216 | unsigned int v= 0; | 216 | unsigned int v= 0; |
217 | v = volControl->volume(); | 217 | v = volControl->volume(); |
218 | v = v / 10; | 218 | v = v / 10; |
219 | 219 | ||
220 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 220 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
221 | return; | 221 | return; |
222 | } | 222 | } |
223 | 223 | ||
224 | int w=0; int h=0; | 224 | int w=0; int h=0; |
225 | if( !xineControl()->hasVideo() ) { | 225 | if( !xineControl()->hasVideo() ) { |
226 | w = audioUI()->width(); | 226 | w = audioUI()->width(); |
227 | h = audioUI()->height(); | 227 | h = audioUI()->height(); |
228 | 228 | ||
229 | if ( drawnOnScreenDisplay ) { | 229 | if ( drawnOnScreenDisplay ) { |
230 | if ( onScreenDisplayVolume > v ) { | 230 | if ( onScreenDisplayVolume > v ) { |
231 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 231 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | drawnOnScreenDisplay = TRUE; | 234 | drawnOnScreenDisplay = TRUE; |
235 | onScreenDisplayVolume = v; | 235 | onScreenDisplayVolume = v; |
236 | QPainter p( audioUI() ); | 236 | QPainter p( audioUI() ); |
237 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 237 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
238 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 238 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
239 | 239 | ||
240 | QFont f; | 240 | QFont f; |
241 | f.setPixelSize( 20 ); | 241 | f.setPixelSize( 20 ); |
242 | f.setBold( TRUE ); | 242 | f.setBold( TRUE ); |
243 | p.setFont( f ); | 243 | p.setFont( f ); |
244 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 244 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
245 | 245 | ||
246 | for ( unsigned int i = 0; i < 10; i++ ) { | 246 | for ( unsigned int i = 0; i < 10; i++ ) { |
247 | if ( v > i ) { | 247 | if ( v > i ) { |
248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
249 | } else { | 249 | } else { |
250 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 250 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | } else { | 253 | } else { |
254 | w = videoUI()->width(); | 254 | w = videoUI()->width(); |
255 | h = videoUI()->height(); | 255 | h = videoUI()->height(); |
256 | 256 | ||
257 | if ( drawnOnScreenDisplay ) { | 257 | if ( drawnOnScreenDisplay ) { |
258 | if ( onScreenDisplayVolume > v ) { | 258 | if ( onScreenDisplayVolume > v ) { |
259 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 259 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | drawnOnScreenDisplay = TRUE; | 262 | drawnOnScreenDisplay = TRUE; |
263 | onScreenDisplayVolume = v; | 263 | onScreenDisplayVolume = v; |
264 | QPainter p( videoUI() ); | 264 | QPainter p( videoUI() ); |
265 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 265 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
266 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 266 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
267 | 267 | ||
268 | QFont f; | 268 | QFont f; |
269 | f.setPixelSize( 20 ); | 269 | f.setPixelSize( 20 ); |
270 | f.setBold( TRUE ); | 270 | f.setBold( TRUE ); |
271 | p.setFont( f ); | 271 | p.setFont( f ); |
272 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 272 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
273 | 273 | ||
274 | for ( unsigned int i = 0; i < 10; i++ ) { | 274 | for ( unsigned int i = 0; i < 10; i++ ) { |
275 | if ( v > i ) { | 275 | if ( v > i ) { |
276 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 276 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
277 | } else { | 277 | } else { |
278 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 278 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void MediaPlayer::blank( bool b ) { | 285 | void MediaPlayer::blank( bool b ) { |
286 | fd=open("/dev/fb0",O_RDWR); | 286 | fd=open("/dev/fb0",O_RDWR); |
287 | #ifdef QT_QWS_SL5XXX | 287 | #ifdef QT_QWS_SL5XXX |
288 | fl= open( "/dev/fl", O_RDWR ); | 288 | fl= open( "/dev/fl", O_RDWR ); |
289 | #endif | 289 | #endif |
290 | if (fd != -1) { | 290 | if (fd != -1) { |
291 | if ( b ) { | 291 | if ( b ) { |
292 | qDebug("do blanking"); | 292 | qDebug("do blanking"); |
293 | #ifdef QT_QWS_SL5XXX | 293 | #ifdef QT_QWS_SL5XXX |
294 | ioctl( fd, FBIOBLANK, 1 ); | 294 | ioctl( fd, FBIOBLANK, 1 ); |
295 | if(fl !=-1) { | 295 | if(fl !=-1) { |
296 | ioctl( fl, 2 ); | 296 | ioctl( fl, 2 ); |
297 | ::close(fl); | 297 | ::close(fl); |
298 | } | 298 | } |
299 | #else | 299 | #else |
300 | ioctl( fd, FBIOBLANK, 3 ); | 300 | ioctl( fd, FBIOBLANK, 3 ); |
301 | #endif | 301 | #endif |
302 | isBlanked = TRUE; | 302 | isBlanked = TRUE; |
303 | } else { | 303 | } else { |
304 | qDebug("do unblanking"); | 304 | qDebug("do unblanking"); |
305 | ioctl( fd, FBIOBLANK, 0); | 305 | ioctl( fd, FBIOBLANK, 0); |
306 | #ifdef QT_QWS_SL5XXX | 306 | #ifdef QT_QWS_SL5XXX |
307 | if(fl != -1) { | 307 | if(fl != -1) { |
308 | ioctl( fl, 1); | 308 | ioctl( fl, 1); |
309 | ::close(fl); | 309 | ::close(fl); |
310 | } | 310 | } |
311 | #endif | 311 | #endif |
312 | isBlanked = FALSE; | 312 | isBlanked = FALSE; |
313 | } | 313 | } |
314 | close( fd ); | 314 | close( fd ); |
315 | } else { | 315 | } else { |
316 | qDebug("<< /dev/fb0 could not be opened >>"); | 316 | qDebug("<< /dev/fb0 could not be opened >>"); |
317 | } | 317 | } |
318 | } | 318 | } |
319 | 319 | ||
320 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 320 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
321 | switch ( e->key() ) { | 321 | switch ( e->key() ) { |
322 | ////////////////////////////// Zaurus keys | 322 | ////////////////////////////// Zaurus keys |
323 | case Key_Home: | 323 | case Key_Home: |
324 | break; | 324 | break; |
325 | case Key_F9: //activity | 325 | case Key_F9: //activity |
326 | break; | 326 | break; |
327 | case Key_F10: //contacts | 327 | case Key_F10: //contacts |
328 | break; | 328 | break; |
329 | case Key_F11: //menu | 329 | case Key_F11: //menu |
330 | break; | 330 | break; |
331 | case Key_F12: //home | 331 | case Key_F12: //home |
332 | qDebug("Blank here"); | 332 | qDebug("Blank here"); |
333 | // mediaPlayerState->toggleBlank(); | 333 | // mediaPlayerState->toggleBlank(); |
334 | break; | 334 | break; |
335 | case Key_F13: //mail | 335 | case Key_F13: //mail |
336 | qDebug("Blank here"); | 336 | qDebug("Blank here"); |
337 | // mediaPlayerState->toggleBlank(); | 337 | // mediaPlayerState->toggleBlank(); |
338 | break; | 338 | break; |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void MediaPlayer::cleanUp() {// this happens on closing | 342 | void MediaPlayer::cleanUp() {// this happens on closing |
343 | Config cfg( "OpiePlayer" ); | 343 | Config cfg( "OpiePlayer" ); |
344 | mediaPlayerState.writeConfig( cfg ); | 344 | mediaPlayerState.writeConfig( cfg ); |
345 | playList.writeDefaultPlaylist( ); | 345 | playList.writeDefaultPlaylist( ); |
346 | 346 | ||
347 | // QPEApplication::grabKeyboard(); | 347 | // QPEApplication::grabKeyboard(); |
348 | // QPEApplication::ungrabKeyboard(); | 348 | // QPEApplication::ungrabKeyboard(); |
349 | } | 349 | } |
350 | 350 | ||
351 | void MediaPlayer::recreateAudioAndVideoWidgets() const | 351 | void MediaPlayer::recreateAudioAndVideoWidgets() const |
352 | { | 352 | { |
353 | delete m_skinLoader; | 353 | delete m_skinLoader; |
354 | 354 | ||
355 | delete m_xineControl; | 355 | delete m_xineControl; |
356 | delete m_audioUI; | 356 | delete m_audioUI; |
357 | delete m_videoUI; | 357 | delete m_videoUI; |
358 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 358 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
359 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 359 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
360 | 360 | ||
361 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 361 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
362 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 362 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
363 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 363 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
364 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | 365 | ||
366 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 366 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
367 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 367 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
368 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 368 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
369 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 369 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
370 | 370 | ||
371 | if ( !xine ) | 371 | if ( !xine ) |
372 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); | 372 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); |
373 | 373 | ||
374 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); | 374 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); |
375 | 375 | ||
376 | xine = 0; | 376 | xine = 0; |
377 | } | 377 | } |
378 | 378 | ||
379 | AudioWidget *MediaPlayer::audioUI() const | 379 | AudioWidget *MediaPlayer::audioUI() const |
380 | { | 380 | { |
381 | if ( !m_audioUI ) | 381 | if ( !m_audioUI ) |
382 | recreateAudioAndVideoWidgets(); | 382 | recreateAudioAndVideoWidgets(); |
383 | return m_audioUI; | 383 | return m_audioUI; |
384 | } | 384 | } |
385 | 385 | ||
386 | VideoWidget *MediaPlayer::videoUI() const | 386 | VideoWidget *MediaPlayer::videoUI() const |
387 | { | 387 | { |
388 | if ( !m_videoUI ) | 388 | if ( !m_videoUI ) |
389 | recreateAudioAndVideoWidgets(); | 389 | recreateAudioAndVideoWidgets(); |
390 | return m_videoUI; | 390 | return m_videoUI; |
391 | } | 391 | } |
392 | 392 | ||
393 | XineControl *MediaPlayer::xineControl() const | 393 | XineControl *MediaPlayer::xineControl() const |
394 | { | 394 | { |
395 | if ( !m_xineControl ) | 395 | if ( !m_xineControl ) |
396 | recreateAudioAndVideoWidgets(); | 396 | recreateAudioAndVideoWidgets(); |
397 | return m_xineControl; | 397 | return m_xineControl; |
398 | } | 398 | } |
399 | 399 | ||
400 | void MediaPlayer::reloadSkins() | 400 | void MediaPlayer::reloadSkins() |
401 | { | 401 | { |
402 | audioUI()->loadSkin(); | 402 | audioUI()->loadSkin(); |
403 | videoUI()->loadSkin(); | 403 | videoUI()->loadSkin(); |
404 | } | 404 | } |
405 | 405 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index f193001..08c62a2 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,263 +1,263 @@ | |||
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" | 26 | #include "playlistwidget.h" |
27 | #include "skin.h" | 27 | #include "skin.h" |
28 | 28 | ||
29 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 29 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
30 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) | 30 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) |
31 | { | 31 | { |
32 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 32 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), |
33 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 33 | this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); |
34 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 34 | connect( &mediaPlayerState, SIGNAL( lengthChanged(long) ), |
35 | this, SLOT( setLength( long ) ) ); | 35 | this, SLOT( setLength(long) ) ); |
36 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 36 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), |
37 | this, SLOT( setPlaying( bool ) ) ); | 37 | this, SLOT( setPlaying(bool) ) ); |
38 | 38 | ||
39 | setBackgroundMode( NoBackground ); | 39 | setBackgroundMode( NoBackground ); |
40 | } | 40 | } |
41 | 41 | ||
42 | MediaWidget::~MediaWidget() | 42 | MediaWidget::~MediaWidget() |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, | 46 | void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, |
47 | const Skin &skin ) | 47 | const Skin &skin ) |
48 | { | 48 | { |
49 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); | 49 | buttonMask = skin.buttonMask( skinInfo, buttonCount ); |
50 | 50 | ||
51 | buttons.clear(); | 51 | buttons.clear(); |
52 | buttons.reserve( buttonCount ); | 52 | buttons.reserve( buttonCount ); |
53 | 53 | ||
54 | for ( uint i = 0; i < buttonCount; ++i ) { | 54 | for ( uint i = 0; i < buttonCount; ++i ) { |
55 | Button button = setupButton( skinInfo[ i ], skin ); | 55 | Button button = setupButton( skinInfo[ i ], skin ); |
56 | buttons.push_back( button ); | 56 | buttons.push_back( button ); |
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) | 60 | MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) |
61 | { | 61 | { |
62 | Button button; | 62 | Button button; |
63 | button.command = buttonInfo.command; | 63 | button.command = buttonInfo.command; |
64 | button.type = buttonInfo.type; | 64 | button.type = buttonInfo.type; |
65 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); | 65 | button.mask = skin.buttonMaskImage( buttonInfo.fileName ); |
66 | 66 | ||
67 | return button; | 67 | return button; |
68 | } | 68 | } |
69 | 69 | ||
70 | void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) | 70 | void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) |
71 | { | 71 | { |
72 | Skin skin( guiInfo.fileNameInfix ); | 72 | Skin skin( guiInfo.fileNameInfix ); |
73 | skin.setCachable( false ); | 73 | skin.setCachable( false ); |
74 | loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); | 74 | loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) | 77 | void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) |
78 | { | 78 | { |
79 | backgroundPixmap = skin.backgroundPixmap(); | 79 | backgroundPixmap = skin.backgroundPixmap(); |
80 | buttonUpImage = skin.buttonUpImage(); | 80 | buttonUpImage = skin.buttonUpImage(); |
81 | buttonDownImage = skin.buttonDownImage(); | 81 | buttonDownImage = skin.buttonDownImage(); |
82 | 82 | ||
83 | setupButtons( skinInfo, buttonCount, skin ); | 83 | setupButtons( skinInfo, buttonCount, skin ); |
84 | } | 84 | } |
85 | 85 | ||
86 | void MediaWidget::closeEvent( QCloseEvent * ) | 86 | void MediaWidget::closeEvent( QCloseEvent * ) |
87 | { | 87 | { |
88 | mediaPlayerState.setList(); | 88 | mediaPlayerState.setList(); |
89 | } | 89 | } |
90 | 90 | ||
91 | void MediaWidget::paintEvent( QPaintEvent *pe ) | 91 | void MediaWidget::paintEvent( QPaintEvent *pe ) |
92 | { | 92 | { |
93 | QPainter p( this ); | 93 | QPainter p( this ); |
94 | 94 | ||
95 | if ( mediaPlayerState.isFullscreen() ) { | 95 | if ( mediaPlayerState.isFullscreen() ) { |
96 | // Clear the background | 96 | // Clear the background |
97 | p.setBrush( QBrush( Qt::black ) ); | 97 | p.setBrush( QBrush( Qt::black ) ); |
98 | return; | 98 | return; |
99 | } | 99 | } |
100 | 100 | ||
101 | QPixmap buffer( size() ); | 101 | QPixmap buffer( size() ); |
102 | QPainter bufferedPainter( &buffer ); | 102 | QPainter bufferedPainter( &buffer ); |
103 | bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); | 103 | bufferedPainter.drawTiledPixmap( rect(), backgroundPixmap, QPoint( 0, 0 ) ); |
104 | paintAllButtons( bufferedPainter ); | 104 | paintAllButtons( bufferedPainter ); |
105 | p.drawPixmap( 0, 0, buffer ); | 105 | p.drawPixmap( 0, 0, buffer ); |
106 | } | 106 | } |
107 | 107 | ||
108 | void MediaWidget::resizeEvent( QResizeEvent *e ) | 108 | void MediaWidget::resizeEvent( QResizeEvent *e ) |
109 | { | 109 | { |
110 | QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); | 110 | QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); |
111 | QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); | 111 | QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); |
112 | 112 | ||
113 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { | 113 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { |
114 | Button &button = *it; | 114 | Button &button = *it; |
115 | 115 | ||
116 | if ( button.mask.isNull() ) | 116 | if ( button.mask.isNull() ) |
117 | continue; | 117 | continue; |
118 | button.pixUp = addMaskToPixmap( pixUp, button.mask ); | 118 | button.pixUp = addMaskToPixmap( pixUp, button.mask ); |
119 | button.pixDown = addMaskToPixmap( pixDn, button.mask ); | 119 | button.pixDown = addMaskToPixmap( pixDn, button.mask ); |
120 | } | 120 | } |
121 | 121 | ||
122 | QWidget::resizeEvent( e ); | 122 | QWidget::resizeEvent( e ); |
123 | } | 123 | } |
124 | 124 | ||
125 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) | 125 | MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) |
126 | { | 126 | { |
127 | if ( position.x() <= 0 || position.y() <= 0 || | 127 | if ( position.x() <= 0 || position.y() <= 0 || |
128 | position.x() >= buttonMask.width() || | 128 | position.x() >= buttonMask.width() || |
129 | position.y() >= buttonMask.height() ) | 129 | position.y() >= buttonMask.height() ) |
130 | return 0; | 130 | return 0; |
131 | 131 | ||
132 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); | 132 | int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); |
133 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 133 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
134 | if ( it->command + 1 == pixelIdx ) | 134 | if ( it->command + 1 == pixelIdx ) |
135 | return &( *it ); | 135 | return &( *it ); |
136 | 136 | ||
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | 139 | ||
140 | void MediaWidget::mousePressEvent( QMouseEvent *event ) | 140 | void MediaWidget::mousePressEvent( QMouseEvent *event ) |
141 | { | 141 | { |
142 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 142 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
143 | 143 | ||
144 | if ( !button ) { | 144 | if ( !button ) { |
145 | QWidget::mousePressEvent( event ); | 145 | QWidget::mousePressEvent( event ); |
146 | return; | 146 | return; |
147 | } | 147 | } |
148 | 148 | ||
149 | switch ( button->command ) { | 149 | switch ( button->command ) { |
150 | case VolumeUp: emit moreClicked(); return; | 150 | case VolumeUp: emit moreClicked(); return; |
151 | case VolumeDown: emit lessClicked(); return; | 151 | case VolumeDown: emit lessClicked(); return; |
152 | case Back: emit backClicked(); return; | 152 | case Back: emit backClicked(); return; |
153 | case Forward: emit forwardClicked(); return; | 153 | case Forward: emit forwardClicked(); return; |
154 | default: break; | 154 | default: break; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) | 158 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) |
159 | { | 159 | { |
160 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); | 160 | Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); |
161 | 161 | ||
162 | if ( !button ) { | 162 | if ( !button ) { |
163 | QWidget::mouseReleaseEvent( event ); | 163 | QWidget::mouseReleaseEvent( event ); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | 166 | ||
167 | if ( button->type == ToggleButton ) | 167 | if ( button->type == ToggleButton ) |
168 | toggleButton( *button ); | 168 | toggleButton( *button ); |
169 | 169 | ||
170 | handleCommand( button->command, button->isDown ); | 170 | handleCommand( button->command, button->isDown ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void MediaWidget::makeVisible() | 173 | void MediaWidget::makeVisible() |
174 | { | 174 | { |
175 | } | 175 | } |
176 | 176 | ||
177 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 177 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
178 | { | 178 | { |
179 | switch ( command ) { | 179 | switch ( command ) { |
180 | case Play: mediaPlayerState.togglePaused(); return; | 180 | case Play: mediaPlayerState.togglePaused(); return; |
181 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 181 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
182 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 182 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
183 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 183 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
184 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 184 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
185 | case VolumeUp: emit moreReleased(); return; | 185 | case VolumeUp: emit moreReleased(); return; |
186 | case VolumeDown: emit lessReleased(); return; | 186 | case VolumeDown: emit lessReleased(); return; |
187 | case PlayList: mediaPlayerState.setList(); return; | 187 | case PlayList: mediaPlayerState.setList(); return; |
188 | case Forward: emit forwardReleased(); return; | 188 | case Forward: emit forwardReleased(); return; |
189 | case Back: emit backReleased(); return; | 189 | case Back: emit backReleased(); return; |
190 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; | 190 | case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; |
191 | default: assert( false ); | 191 | default: assert( false ); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 195 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
196 | { | 196 | { |
197 | return ( position.x() > 0 && position.y() > 0 && | 197 | return ( position.x() > 0 && position.y() > 0 && |
198 | position.x() < buttonMask.width() && | 198 | position.x() < buttonMask.width() && |
199 | position.y() < buttonMask.height() && | 199 | position.y() < buttonMask.height() && |
200 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 200 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | void MediaWidget::paintAllButtons( QPainter &p ) | 203 | void MediaWidget::paintAllButtons( QPainter &p ) |
204 | { | 204 | { |
205 | for ( ButtonVector::const_iterator it = buttons.begin(); | 205 | for ( ButtonVector::const_iterator it = buttons.begin(); |
206 | it != buttons.end(); ++it ) | 206 | it != buttons.end(); ++it ) |
207 | paintButton( p, *it ); | 207 | paintButton( p, *it ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void MediaWidget::paintButton( const Button &button ) | 210 | void MediaWidget::paintButton( const Button &button ) |
211 | { | 211 | { |
212 | QPainter p( this ); | 212 | QPainter p( this ); |
213 | paintButton( p, button ); | 213 | paintButton( p, button ); |
214 | } | 214 | } |
215 | 215 | ||
216 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 216 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
217 | { | 217 | { |
218 | if ( button.isDown ) | 218 | if ( button.isDown ) |
219 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 219 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
220 | else | 220 | else |
221 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 221 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
222 | } | 222 | } |
223 | 223 | ||
224 | void MediaWidget::setToggleButton( Command command, bool down ) | 224 | void MediaWidget::setToggleButton( Command command, bool down ) |
225 | { | 225 | { |
226 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) | 226 | for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) |
227 | if ( it->command == command ) { | 227 | if ( it->command == command ) { |
228 | setToggleButton( *it, down ); | 228 | setToggleButton( *it, down ); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | void MediaWidget::setToggleButton( Button &button, bool down ) | 233 | void MediaWidget::setToggleButton( Button &button, bool down ) |
234 | { | 234 | { |
235 | if ( down != button.isDown ) | 235 | if ( down != button.isDown ) |
236 | toggleButton( button ); | 236 | toggleButton( button ); |
237 | } | 237 | } |
238 | 238 | ||
239 | void MediaWidget::toggleButton( Button &button ) | 239 | void MediaWidget::toggleButton( Button &button ) |
240 | { | 240 | { |
241 | button.isDown = !button.isDown; | 241 | button.isDown = !button.isDown; |
242 | 242 | ||
243 | paintButton( button ); | 243 | paintButton( button ); |
244 | } | 244 | } |
245 | 245 | ||
246 | QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) | 246 | QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) |
247 | { | 247 | { |
248 | QPixmap pix( image.size() ); | 248 | QPixmap pix( image.size() ); |
249 | QPainter p( &pix ); | 249 | QPainter p( &pix ); |
250 | p.drawTiledPixmap( pix.rect(), background, offset ); | 250 | p.drawTiledPixmap( pix.rect(), background, offset ); |
251 | p.drawImage( 0, 0, image ); | 251 | p.drawImage( 0, 0, image ); |
252 | return pix; | 252 | return pix; |
253 | } | 253 | } |
254 | 254 | ||
255 | QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) | 255 | QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) |
256 | { | 256 | { |
257 | QPixmap result( pix ); | 257 | QPixmap result( pix ); |
258 | result.setMask( mask ); | 258 | result.setMask( mask ); |
259 | return result; | 259 | return result; |
260 | } | 260 | } |
261 | 261 | ||
262 | /* vim: et sw=4 ts=4 | 262 | /* vim: et sw=4 ts=4 |
263 | */ | 263 | */ |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 9a9e1ec..0a84268 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,937 +1,937 @@ | |||
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" | 43 | #include "mediaplayerstate.h" |
44 | #include "inputDialog.h" | 44 | #include "inputDialog.h" |
45 | #include "om3u.h" | 45 | #include "om3u.h" |
46 | #include "playlistfileview.h" | 46 | #include "playlistfileview.h" |
47 | 47 | ||
48 | //only needed for the random play | 48 | //only needed for the random play |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 51 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
52 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 52 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
53 | { | 53 | { |
54 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 54 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
55 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 55 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 59 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
60 | "opieplayer2/add_to_playlist", | 60 | "opieplayer2/add_to_playlist", |
61 | this , SLOT(addSelected() ) ); | 61 | this , SLOT(addSelected() ) ); |
62 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 62 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
63 | "opieplayer2/remove_from_playlist", | 63 | "opieplayer2/remove_from_playlist", |
64 | this , SLOT(removeSelected() ) ); | 64 | this , SLOT(removeSelected() ) ); |
65 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 65 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
66 | this , SLOT( btnPlay( bool) ), TRUE ); | 66 | this , SLOT( btnPlay(bool) ), TRUE ); |
67 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 67 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
68 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 68 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); |
69 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 69 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
70 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 70 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); |
71 | 71 | ||
72 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 72 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
73 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 73 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
74 | this, SLOT( addAllMusicToList() ) ); | 74 | this, SLOT( addAllMusicToList() ) ); |
75 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 75 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
76 | this, SLOT( addAllVideoToList() ) ); | 76 | this, SLOT( addAllVideoToList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
78 | this, SLOT( addAllToList() ) ); | 78 | this, SLOT( addAllToList() ) ); |
79 | pmPlayList->insertSeparator(-1); | 79 | pmPlayList->insertSeparator(-1); |
80 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
81 | this,SLOT( openFile() ) ); | 81 | this,SLOT( openFile() ) ); |
82 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 82 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
83 | this,SLOT( openURL() ) ); | 83 | this,SLOT( openURL() ) ); |
84 | pmPlayList->insertSeparator(-1); | 84 | pmPlayList->insertSeparator(-1); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 86 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
89 | audioView, SLOT( scanFiles() ) ); | 89 | audioView, SLOT( scanFiles() ) ); |
90 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 90 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
91 | videoView, SLOT( scanFiles() ) ); | 91 | videoView, SLOT( scanFiles() ) ); |
92 | 92 | ||
93 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 93 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
94 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 94 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
95 | 95 | ||
96 | Config cfg( "OpiePlayer" ); | 96 | Config cfg( "OpiePlayer" ); |
97 | bool b= cfg.readBoolEntry("FullScreen", 0); | 97 | bool b= cfg.readBoolEntry("FullScreen", 0); |
98 | mediaPlayerState->setFullscreen( b ); | 98 | mediaPlayerState->setFullscreen( b ); |
99 | pmView->setItemChecked( -16, b ); | 99 | pmView->setItemChecked( -16, b ); |
100 | 100 | ||
101 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 101 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
102 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 102 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
103 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 103 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
104 | d->selectedFiles, SLOT(removeSelected() ) ); | 104 | d->selectedFiles, SLOT(removeSelected() ) ); |
105 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 105 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
106 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 106 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
107 | QVBox *stretch2 = new QVBox( vbox1 ); | 107 | QVBox *stretch2 = new QVBox( vbox1 ); |
108 | 108 | ||
109 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 109 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
110 | SLOT( deletePlaylist() ) ); | 110 | SLOT( deletePlaylist() ) ); |
111 | connect( pmView, SIGNAL( activated( int ) ), | 111 | connect( pmView, SIGNAL( activated(int) ), |
112 | this, SLOT( pmViewActivated( int ) ) ); | 112 | this, SLOT( pmViewActivated(int) ) ); |
113 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 113 | connect( skinsMenu, SIGNAL( activated(int) ) , |
114 | this, SLOT( skinsMenuActivated( int ) ) ); | 114 | this, SLOT( skinsMenuActivated(int) ) ); |
115 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 115 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
116 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 116 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
117 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 117 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
118 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 118 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
119 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 119 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), |
120 | this,SLOT( playIt( QListViewItem *) ) ); | 120 | this,SLOT( playIt(QListViewItem*) ) ); |
121 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 121 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), |
122 | this, SLOT( addToSelection( QListViewItem *) ) ); | 122 | this, SLOT( addToSelection(QListViewItem*) ) ); |
123 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 123 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
124 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 124 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
125 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 125 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), |
126 | this,SLOT( playIt( QListViewItem *) ) ); | 126 | this,SLOT( playIt(QListViewItem*) ) ); |
127 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 127 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), |
128 | this, SLOT( addToSelection( QListViewItem *) ) ); | 128 | this, SLOT( addToSelection(QListViewItem*) ) ); |
129 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 129 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), |
130 | this, SLOT( loadList( const DocLnk & ) ) ); | 130 | this, SLOT( loadList(const DocLnk&) ) ); |
131 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 131 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
132 | this, SLOT( tabChanged( QWidget* ) ) ); | 132 | this, SLOT( tabChanged(QWidget*) ) ); |
133 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 133 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), |
134 | d->tbPlay, SLOT( setOn( bool ) ) ); | 134 | d->tbPlay, SLOT( setOn(bool) ) ); |
135 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 135 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
136 | d->tbLoop, SLOT( setOn( bool ) ) ); | 136 | d->tbLoop, SLOT( setOn(bool) ) ); |
137 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 137 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
138 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 138 | d->tbShuffle, SLOT( setOn(bool) ) ); |
139 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 139 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
140 | this, SLOT( playIt( QListViewItem *) ) ); | 140 | this, SLOT( playIt(QListViewItem*) ) ); |
141 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 141 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
142 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 142 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
143 | 143 | ||
144 | connect( this, SIGNAL(skinSelected() ), | 144 | connect( this, SIGNAL(skinSelected() ), |
145 | m_mp, SLOT( reloadSkins() ) ); | 145 | m_mp, SLOT( reloadSkins() ) ); |
146 | 146 | ||
147 | // see which skins are installed | 147 | // see which skins are installed |
148 | populateSkinsMenu(); | 148 | populateSkinsMenu(); |
149 | initializeStates(); | 149 | initializeStates(); |
150 | 150 | ||
151 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); | 151 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); |
152 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 152 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
153 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 153 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
154 | 154 | ||
155 | 155 | ||
156 | cfg.setGroup("PlayList"); | 156 | cfg.setGroup("PlayList"); |
157 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 157 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
158 | loadList(DocLnk( currentPlaylist ) ); | 158 | loadList(DocLnk( currentPlaylist ) ); |
159 | 159 | ||
160 | tabWidget->showPage( playListTab ); | 160 | tabWidget->showPage( playListTab ); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | PlayListWidget::~PlayListWidget() { | 164 | PlayListWidget::~PlayListWidget() { |
165 | delete d; | 165 | delete d; |
166 | delete m_mp; | 166 | delete m_mp; |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | void PlayListWidget::initializeStates() { | 170 | void PlayListWidget::initializeStates() { |
171 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 171 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
172 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 172 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
173 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 173 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
174 | d->playListFrame->show(); | 174 | d->playListFrame->show(); |
175 | } | 175 | } |
176 | 176 | ||
177 | void PlayListWidget::writeDefaultPlaylist() { | 177 | void PlayListWidget::writeDefaultPlaylist() { |
178 | 178 | ||
179 | Config config( "OpiePlayer" ); | 179 | Config config( "OpiePlayer" ); |
180 | config.setGroup( "PlayList" ); | 180 | config.setGroup( "PlayList" ); |
181 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 181 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
182 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 182 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
183 | if( currentString == filename) { | 183 | if( currentString == filename) { |
184 | Om3u *m3uList; | 184 | Om3u *m3uList; |
185 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 185 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
186 | if( d->selectedFiles->first() ) { | 186 | if( d->selectedFiles->first() ) { |
187 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 187 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
188 | do { | 188 | do { |
189 | // qDebug(d->selectedFiles->current()->file()); | 189 | // qDebug(d->selectedFiles->current()->file()); |
190 | m3uList->add( d->selectedFiles->current()->file() ); | 190 | m3uList->add( d->selectedFiles->current()->file() ); |
191 | } | 191 | } |
192 | while ( d->selectedFiles->next() ); | 192 | while ( d->selectedFiles->next() ); |
193 | 193 | ||
194 | m3uList->write(); | 194 | m3uList->write(); |
195 | m3uList->close(); | 195 | m3uList->close(); |
196 | delete m3uList; | 196 | delete m3uList; |
197 | 197 | ||
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 202 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
203 | d->setDocumentUsed = FALSE; | 203 | d->setDocumentUsed = FALSE; |
204 | if( QFileInfo( lnk.file() ).exists() || | 204 | if( QFileInfo( lnk.file() ).exists() || |
205 | lnk.file().left(4) == "http" ) { | 205 | lnk.file().left(4) == "http" ) { |
206 | d->selectedFiles->addToSelection( lnk ); | 206 | d->selectedFiles->addToSelection( lnk ); |
207 | } | 207 | } |
208 | // writeCurrentM3u(); | 208 | // writeCurrentM3u(); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | void PlayListWidget::clearList() { | 212 | void PlayListWidget::clearList() { |
213 | while ( first() ) { | 213 | while ( first() ) { |
214 | d->selectedFiles->removeSelected(); | 214 | d->selectedFiles->removeSelected(); |
215 | } | 215 | } |
216 | Config cfg( "OpiePlayer" ); | 216 | Config cfg( "OpiePlayer" ); |
217 | cfg.setGroup("PlayList"); | 217 | cfg.setGroup("PlayList"); |
218 | cfg.writeEntry("CurrentPlaylist","default"); | 218 | cfg.writeEntry("CurrentPlaylist","default"); |
219 | setCaption("OpiePlayer"); | 219 | setCaption("OpiePlayer"); |
220 | } | 220 | } |
221 | 221 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 223 | switch (mouse) { |
224 | case LeftButton: | 224 | case LeftButton: |
225 | break; | 225 | break; |
226 | case RightButton: | 226 | case RightButton: |
227 | { | 227 | { |
228 | QPopupMenu m; | 228 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 231 | m.exec( QCursor::pos() ); |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 239 | switch (mouse) { |
240 | case LeftButton: | 240 | case LeftButton: |
241 | break; | 241 | break; |
242 | case RightButton: | 242 | case RightButton: |
243 | { | 243 | { |
244 | QPopupMenu m; | 244 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 247 | m.exec( QCursor::pos() ); |
248 | } | 248 | } |
249 | break; | 249 | break; |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | void PlayListWidget::addAllToList() { | 254 | void PlayListWidget::addAllToList() { |
255 | 255 | ||
256 | 256 | ||
257 | audioView->populateView(); | 257 | audioView->populateView(); |
258 | 258 | ||
259 | QListViewItemIterator audioIt( audioView ); | 259 | QListViewItemIterator audioIt( audioView ); |
260 | DocLnk lnk; | 260 | DocLnk lnk; |
261 | QString filename; | 261 | QString filename; |
262 | // iterate through all items of the listview | 262 | // iterate through all items of the listview |
263 | for ( ; audioIt.current(); ++audioIt ) { | 263 | for ( ; audioIt.current(); ++audioIt ) { |
264 | filename = audioIt.current()->text(3); | 264 | filename = audioIt.current()->text(3); |
265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
266 | lnk.setFile( filename ); //sets file name | 266 | lnk.setFile( filename ); //sets file name |
267 | d->selectedFiles->addToSelection( lnk); | 267 | d->selectedFiles->addToSelection( lnk); |
268 | } | 268 | } |
269 | 269 | ||
270 | videoView->populateView(); | 270 | videoView->populateView(); |
271 | 271 | ||
272 | QListViewItemIterator videoIt( videoView ); | 272 | QListViewItemIterator videoIt( videoView ); |
273 | for ( ; videoIt.current(); ++videoIt ) { | 273 | for ( ; videoIt.current(); ++videoIt ) { |
274 | filename = videoIt.current()->text(3); | 274 | filename = videoIt.current()->text(3); |
275 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 275 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
276 | lnk.setFile( filename ); //sets file name | 276 | lnk.setFile( filename ); //sets file name |
277 | d->selectedFiles->addToSelection( lnk); | 277 | d->selectedFiles->addToSelection( lnk); |
278 | } | 278 | } |
279 | 279 | ||
280 | tabWidget->setCurrentPage(0); | 280 | tabWidget->setCurrentPage(0); |
281 | 281 | ||
282 | writeCurrentM3u(); | 282 | writeCurrentM3u(); |
283 | d->selectedFiles->first(); | 283 | d->selectedFiles->first(); |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | void PlayListWidget::addAllMusicToList() { | 287 | void PlayListWidget::addAllMusicToList() { |
288 | 288 | ||
289 | audioView->populateView(); | 289 | audioView->populateView(); |
290 | 290 | ||
291 | QListViewItemIterator audioIt( audioView ); | 291 | QListViewItemIterator audioIt( audioView ); |
292 | DocLnk lnk; | 292 | DocLnk lnk; |
293 | QString filename; | 293 | QString filename; |
294 | // iterate through all items of the listview | 294 | // iterate through all items of the listview |
295 | for ( ; audioIt.current(); ++audioIt ) { | 295 | for ( ; audioIt.current(); ++audioIt ) { |
296 | filename = audioIt.current()->text(3); | 296 | filename = audioIt.current()->text(3); |
297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
298 | lnk.setFile( filename ); //sets file name | 298 | lnk.setFile( filename ); //sets file name |
299 | d->selectedFiles->addToSelection( lnk); | 299 | d->selectedFiles->addToSelection( lnk); |
300 | } | 300 | } |
301 | 301 | ||
302 | tabWidget->setCurrentPage(0); | 302 | tabWidget->setCurrentPage(0); |
303 | writeCurrentM3u(); | 303 | writeCurrentM3u(); |
304 | d->selectedFiles->first(); | 304 | d->selectedFiles->first(); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void PlayListWidget::addAllVideoToList() { | 308 | void PlayListWidget::addAllVideoToList() { |
309 | 309 | ||
310 | videoView->populateView(); | 310 | videoView->populateView(); |
311 | 311 | ||
312 | QListViewItemIterator videoIt( videoView ); | 312 | QListViewItemIterator videoIt( videoView ); |
313 | DocLnk lnk; | 313 | DocLnk lnk; |
314 | QString filename; | 314 | QString filename; |
315 | for ( ; videoIt.current(); ++videoIt ) { | 315 | for ( ; videoIt.current(); ++videoIt ) { |
316 | filename = videoIt.current()->text(3); | 316 | filename = videoIt.current()->text(3); |
317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
318 | lnk.setFile( filename ); //sets file name | 318 | lnk.setFile( filename ); //sets file name |
319 | d->selectedFiles->addToSelection( lnk); | 319 | d->selectedFiles->addToSelection( lnk); |
320 | } | 320 | } |
321 | tabWidget->setCurrentPage(0); | 321 | tabWidget->setCurrentPage(0); |
322 | writeCurrentM3u(); | 322 | writeCurrentM3u(); |
323 | d->selectedFiles->first(); | 323 | d->selectedFiles->first(); |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void PlayListWidget::setDocument( const QString& fileref ) { | 327 | void PlayListWidget::setDocument( const QString& fileref ) { |
328 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 328 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
329 | fromSetDocument = TRUE; | 329 | fromSetDocument = TRUE; |
330 | QFileInfo fileInfo(fileref); | 330 | QFileInfo fileInfo(fileref); |
331 | 331 | ||
332 | if ( !fileInfo.exists() ) { | 332 | if ( !fileInfo.exists() ) { |
333 | QMessageBox::warning( this, tr( "Invalid File" ), | 333 | QMessageBox::warning( this, tr( "Invalid File" ), |
334 | tr( "There was a problem in getting the file." ) ); | 334 | tr( "There was a problem in getting the file." ) ); |
335 | return; | 335 | return; |
336 | } | 336 | } |
337 | 337 | ||
338 | clearList(); | 338 | clearList(); |
339 | QString extension = fileInfo.extension(false); | 339 | QString extension = fileInfo.extension(false); |
340 | 340 | ||
341 | if( extension.find( "m3u", 0, false) != -1 | 341 | if( extension.find( "m3u", 0, false) != -1 |
342 | || extension.find( "pls", 0, false) != -1 ) { | 342 | || extension.find( "pls", 0, false) != -1 ) { |
343 | readListFromFile( fileref ); | 343 | readListFromFile( fileref ); |
344 | } else { | 344 | } else { |
345 | clearList(); | 345 | clearList(); |
346 | DocLnk lnk; | 346 | DocLnk lnk; |
347 | lnk.setName( fileInfo.baseName() ); //sets name | 347 | lnk.setName( fileInfo.baseName() ); //sets name |
348 | lnk.setFile( fileref ); //sets file name | 348 | lnk.setFile( fileref ); //sets file name |
349 | addToSelection( lnk ); | 349 | addToSelection( lnk ); |
350 | writeCurrentM3u(); | 350 | writeCurrentM3u(); |
351 | 351 | ||
352 | d->setDocumentUsed = TRUE; | 352 | d->setDocumentUsed = TRUE; |
353 | mediaPlayerState->setPlaying( FALSE ); | 353 | mediaPlayerState->setPlaying( FALSE ); |
354 | mediaPlayerState->setPlaying( TRUE ); | 354 | mediaPlayerState->setPlaying( TRUE ); |
355 | } | 355 | } |
356 | } | 356 | } |
357 | 357 | ||
358 | 358 | ||
359 | void PlayListWidget::useSelectedDocument() { | 359 | void PlayListWidget::useSelectedDocument() { |
360 | d->setDocumentUsed = FALSE; | 360 | d->setDocumentUsed = FALSE; |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | const DocLnk *PlayListWidget::current() const { // this is fugly | 364 | const DocLnk *PlayListWidget::current() const { // this is fugly |
365 | assert( currentTab() == CurrentPlayList ); | 365 | assert( currentTab() == CurrentPlayList ); |
366 | 366 | ||
367 | const DocLnk *lnk = d->selectedFiles->current(); | 367 | const DocLnk *lnk = d->selectedFiles->current(); |
368 | if ( !lnk ) { | 368 | if ( !lnk ) { |
369 | d->selectedFiles->first(); | 369 | d->selectedFiles->first(); |
370 | lnk = d->selectedFiles->current(); | 370 | lnk = d->selectedFiles->current(); |
371 | } | 371 | } |
372 | assert( lnk ); | 372 | assert( lnk ); |
373 | return lnk; | 373 | return lnk; |
374 | } | 374 | } |
375 | 375 | ||
376 | 376 | ||
377 | bool PlayListWidget::prev() { | 377 | bool PlayListWidget::prev() { |
378 | if ( mediaPlayerState->isShuffled() ) { | 378 | if ( mediaPlayerState->isShuffled() ) { |
379 | const DocLnk *cur = current(); | 379 | const DocLnk *cur = current(); |
380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
381 | for ( int i = 0; i < j; i++ ) { | 381 | for ( int i = 0; i < j; i++ ) { |
382 | if ( !d->selectedFiles->next() ) | 382 | if ( !d->selectedFiles->next() ) |
383 | d->selectedFiles->first(); | 383 | d->selectedFiles->first(); |
384 | } | 384 | } |
385 | if ( cur == current() ) | 385 | if ( cur == current() ) |
386 | if ( !d->selectedFiles->next() ) { | 386 | if ( !d->selectedFiles->next() ) { |
387 | d->selectedFiles->first(); | 387 | d->selectedFiles->first(); |
388 | } | 388 | } |
389 | return TRUE; | 389 | return TRUE; |
390 | } else { | 390 | } else { |
391 | if ( !d->selectedFiles->prev() ) { | 391 | if ( !d->selectedFiles->prev() ) { |
392 | if ( mediaPlayerState->isLooping() ) { | 392 | if ( mediaPlayerState->isLooping() ) { |
393 | return d->selectedFiles->last(); | 393 | return d->selectedFiles->last(); |
394 | } else { | 394 | } else { |
395 | return FALSE; | 395 | return FALSE; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | return TRUE; | 398 | return TRUE; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | 402 | ||
403 | bool PlayListWidget::next() { | 403 | bool PlayListWidget::next() { |
404 | //qDebug("<<<<<<<<<<<<next()"); | 404 | //qDebug("<<<<<<<<<<<<next()"); |
405 | if ( mediaPlayerState->isShuffled() ) { | 405 | if ( mediaPlayerState->isShuffled() ) { |
406 | return prev(); | 406 | return prev(); |
407 | } else { | 407 | } else { |
408 | if ( !d->selectedFiles->next() ) { | 408 | if ( !d->selectedFiles->next() ) { |
409 | if ( mediaPlayerState->isLooping() ) { | 409 | if ( mediaPlayerState->isLooping() ) { |
410 | return d->selectedFiles->first(); | 410 | return d->selectedFiles->first(); |
411 | } else { | 411 | } else { |
412 | return FALSE; | 412 | return FALSE; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | return TRUE; | 415 | return TRUE; |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | bool PlayListWidget::first() { | 420 | bool PlayListWidget::first() { |
421 | return d->selectedFiles->first(); | 421 | return d->selectedFiles->first(); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | bool PlayListWidget::last() { | 425 | bool PlayListWidget::last() { |
426 | return d->selectedFiles->last(); | 426 | return d->selectedFiles->last(); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void PlayListWidget::saveList() { | 430 | void PlayListWidget::saveList() { |
431 | writem3u(); | 431 | writem3u(); |
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | void PlayListWidget::loadList( const DocLnk & lnk) { | 435 | void PlayListWidget::loadList( const DocLnk & lnk) { |
436 | QString name = lnk.name(); | 436 | QString name = lnk.name(); |
437 | 437 | ||
438 | if( name.length()>0) { | 438 | if( name.length()>0) { |
439 | setCaption("OpiePlayer: "+name); | 439 | setCaption("OpiePlayer: "+name); |
440 | clearList(); | 440 | clearList(); |
441 | readListFromFile(lnk.file()); | 441 | readListFromFile(lnk.file()); |
442 | tabWidget->setCurrentPage(0); | 442 | tabWidget->setCurrentPage(0); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | void PlayListWidget::addSelected() { | 446 | void PlayListWidget::addSelected() { |
447 | assert( inFileListMode() ); | 447 | assert( inFileListMode() ); |
448 | 448 | ||
449 | QListViewItemIterator it( currentFileListView ); | 449 | QListViewItemIterator it( currentFileListView ); |
450 | for ( ; it.current(); ++it ) | 450 | for ( ; it.current(); ++it ) |
451 | if ( it.current()->isSelected() ) { | 451 | if ( it.current()->isSelected() ) { |
452 | QString filename = it.current()->text(3); | 452 | QString filename = it.current()->text(3); |
453 | 453 | ||
454 | DocLnk lnk; | 454 | DocLnk lnk; |
455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
456 | lnk.setFile( filename ); //sets file name | 456 | lnk.setFile( filename ); //sets file name |
457 | 457 | ||
458 | d->selectedFiles->addToSelection( lnk ); | 458 | d->selectedFiles->addToSelection( lnk ); |
459 | } | 459 | } |
460 | 460 | ||
461 | currentFileListView->clearSelection(); | 461 | currentFileListView->clearSelection(); |
462 | 462 | ||
463 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | void PlayListWidget::removeSelected() { | 467 | void PlayListWidget::removeSelected() { |
468 | d->selectedFiles->removeSelected( ); | 468 | d->selectedFiles->removeSelected( ); |
469 | writeCurrentM3u(); | 469 | writeCurrentM3u(); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void PlayListWidget::playIt( QListViewItem *it) { | 473 | void PlayListWidget::playIt( QListViewItem *it) { |
474 | if(!it) return; | 474 | if(!it) return; |
475 | mediaPlayerState->setPlaying(FALSE); | 475 | mediaPlayerState->setPlaying(FALSE); |
476 | mediaPlayerState->setPlaying(TRUE); | 476 | mediaPlayerState->setPlaying(TRUE); |
477 | d->selectedFiles->unSelect(); | 477 | d->selectedFiles->unSelect(); |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | void PlayListWidget::addToSelection( QListViewItem *it) { | 481 | void PlayListWidget::addToSelection( QListViewItem *it) { |
482 | d->setDocumentUsed = FALSE; | 482 | d->setDocumentUsed = FALSE; |
483 | 483 | ||
484 | if(it) { | 484 | if(it) { |
485 | if ( currentTab() == CurrentPlayList ) | 485 | if ( currentTab() == CurrentPlayList ) |
486 | return; | 486 | return; |
487 | DocLnk lnk; | 487 | DocLnk lnk; |
488 | QString filename; | 488 | QString filename; |
489 | 489 | ||
490 | filename=it->text(3); | 490 | filename=it->text(3); |
491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
492 | lnk.setFile( filename ); //sets file name | 492 | lnk.setFile( filename ); //sets file name |
493 | d->selectedFiles->addToSelection( lnk); | 493 | d->selectedFiles->addToSelection( lnk); |
494 | 494 | ||
495 | writeCurrentM3u(); | 495 | writeCurrentM3u(); |
496 | // tabWidget->setCurrentPage(0); | 496 | // tabWidget->setCurrentPage(0); |
497 | 497 | ||
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | void PlayListWidget::tabChanged(QWidget *) { | 502 | void PlayListWidget::tabChanged(QWidget *) { |
503 | 503 | ||
504 | d->tbPlay->setEnabled( true ); | 504 | d->tbPlay->setEnabled( true ); |
505 | 505 | ||
506 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | 506 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
507 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 507 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
508 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | 508 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
509 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 509 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
510 | 510 | ||
511 | currentFileListView = 0; | 511 | currentFileListView = 0; |
512 | 512 | ||
513 | switch ( currentTab() ) { | 513 | switch ( currentTab() ) { |
514 | case CurrentPlayList: | 514 | case CurrentPlayList: |
515 | { | 515 | { |
516 | if( !tbDeletePlaylist->isHidden() ) { | 516 | if( !tbDeletePlaylist->isHidden() ) { |
517 | tbDeletePlaylist->hide(); | 517 | tbDeletePlaylist->hide(); |
518 | } | 518 | } |
519 | d->tbRemoveFromList->setEnabled(TRUE); | 519 | d->tbRemoveFromList->setEnabled(TRUE); |
520 | d->tbAddToList->setEnabled(FALSE); | 520 | d->tbAddToList->setEnabled(FALSE); |
521 | 521 | ||
522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
523 | } | 523 | } |
524 | break; | 524 | break; |
525 | case AudioFiles: | 525 | case AudioFiles: |
526 | { | 526 | { |
527 | audioView->populateView(); | 527 | audioView->populateView(); |
528 | 528 | ||
529 | if( !tbDeletePlaylist->isHidden() ) { | 529 | if( !tbDeletePlaylist->isHidden() ) { |
530 | tbDeletePlaylist->hide(); | 530 | tbDeletePlaylist->hide(); |
531 | } | 531 | } |
532 | d->tbRemoveFromList->setEnabled(FALSE); | 532 | d->tbRemoveFromList->setEnabled(FALSE); |
533 | d->tbAddToList->setEnabled(TRUE); | 533 | d->tbAddToList->setEnabled(TRUE); |
534 | 534 | ||
535 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | 535 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
536 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 536 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
537 | 537 | ||
538 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 538 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
539 | 539 | ||
540 | currentFileListView = audioView; | 540 | currentFileListView = audioView; |
541 | } | 541 | } |
542 | break; | 542 | break; |
543 | case VideoFiles: | 543 | case VideoFiles: |
544 | { | 544 | { |
545 | videoView->populateView(); | 545 | videoView->populateView(); |
546 | if( !tbDeletePlaylist->isHidden() ) { | 546 | if( !tbDeletePlaylist->isHidden() ) { |
547 | tbDeletePlaylist->hide(); | 547 | tbDeletePlaylist->hide(); |
548 | } | 548 | } |
549 | d->tbRemoveFromList->setEnabled(FALSE); | 549 | d->tbRemoveFromList->setEnabled(FALSE); |
550 | d->tbAddToList->setEnabled(TRUE); | 550 | d->tbAddToList->setEnabled(TRUE); |
551 | 551 | ||
552 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | 552 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
553 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 553 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
554 | 554 | ||
555 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 555 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
556 | 556 | ||
557 | currentFileListView = videoView; | 557 | currentFileListView = videoView; |
558 | } | 558 | } |
559 | break; | 559 | break; |
560 | case PlayLists: | 560 | case PlayLists: |
561 | { | 561 | { |
562 | if( tbDeletePlaylist->isHidden() ) { | 562 | if( tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->show(); | 563 | tbDeletePlaylist->show(); |
564 | } | 564 | } |
565 | playLists->reread(); | 565 | playLists->reread(); |
566 | d->tbAddToList->setEnabled(FALSE); | 566 | d->tbAddToList->setEnabled(FALSE); |
567 | 567 | ||
568 | d->tbPlay->setEnabled( false ); | 568 | d->tbPlay->setEnabled( false ); |
569 | } | 569 | } |
570 | break; | 570 | break; |
571 | }; | 571 | }; |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | void PlayListWidget::btnPlay(bool b) { | 575 | void PlayListWidget::btnPlay(bool b) { |
576 | // mediaPlayerState->setPlaying(false); | 576 | // mediaPlayerState->setPlaying(false); |
577 | mediaPlayerState->setPlaying(b); | 577 | mediaPlayerState->setPlaying(b); |
578 | insanityBool=FALSE; | 578 | insanityBool=FALSE; |
579 | } | 579 | } |
580 | 580 | ||
581 | void PlayListWidget::deletePlaylist() { | 581 | void PlayListWidget::deletePlaylist() { |
582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
583 | (tr("You really want to delete\nthis playlist?")), | 583 | (tr("You really want to delete\nthis playlist?")), |
584 | (tr("Yes")), (tr("No")), 0 )){ | 584 | (tr("Yes")), (tr("No")), 0 )){ |
585 | case 0: // Yes clicked, | 585 | case 0: // Yes clicked, |
586 | QFile().remove(playLists->selectedDocument().file()); | 586 | QFile().remove(playLists->selectedDocument().file()); |
587 | QFile().remove(playLists->selectedDocument().linkFile()); | 587 | QFile().remove(playLists->selectedDocument().linkFile()); |
588 | playLists->reread(); | 588 | playLists->reread(); |
589 | break; | 589 | break; |
590 | case 1: // Cancel | 590 | case 1: // Cancel |
591 | break; | 591 | break; |
592 | }; | 592 | }; |
593 | } | 593 | } |
594 | 594 | ||
595 | 595 | ||
596 | void PlayListWidget::playSelected() { | 596 | void PlayListWidget::playSelected() { |
597 | btnPlay( TRUE); | 597 | btnPlay( TRUE); |
598 | } | 598 | } |
599 | 599 | ||
600 | bool PlayListWidget::inFileListMode() const | 600 | bool PlayListWidget::inFileListMode() const |
601 | { | 601 | { |
602 | TabType tab = currentTab(); | 602 | TabType tab = currentTab(); |
603 | return tab == AudioFiles || tab == VideoFiles; | 603 | return tab == AudioFiles || tab == VideoFiles; |
604 | } | 604 | } |
605 | 605 | ||
606 | void PlayListWidget::openURL() { | 606 | void PlayListWidget::openURL() { |
607 | // http://66.28.164.33:2080 | 607 | // http://66.28.164.33:2080 |
608 | // http://somafm.com/star0242.m3u | 608 | // http://somafm.com/star0242.m3u |
609 | QString filename, name; | 609 | QString filename, name; |
610 | InputDialog *fileDlg; | 610 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
612 | fileDlg->exec(); | 612 | fileDlg->exec(); |
613 | if( fileDlg->result() == 1 ) { | 613 | if( fileDlg->result() == 1 ) { |
614 | filename = fileDlg->text(); | 614 | filename = fileDlg->text(); |
615 | qDebug( "Selected filename is " + filename ); | 615 | qDebug( "Selected filename is " + filename ); |
616 | // Om3u *m3uList; | 616 | // Om3u *m3uList; |
617 | DocLnk lnk; | 617 | DocLnk lnk; |
618 | Config cfg( "OpiePlayer" ); | 618 | Config cfg( "OpiePlayer" ); |
619 | cfg.setGroup("PlayList"); | 619 | cfg.setGroup("PlayList"); |
620 | 620 | ||
621 | if(filename.left(4) == "http") { | 621 | if(filename.left(4) == "http") { |
622 | QString m3uFile, m3uFilePath; | 622 | QString m3uFile, m3uFilePath; |
623 | if(filename.find(":",8,TRUE) != -1) { //found a port | 623 | if(filename.find(":",8,TRUE) != -1) { //found a port |
624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
625 | m3uFile = m3uFile.right( 7); | 625 | m3uFile = m3uFile.right( 7); |
626 | } else if(filename.left(4) == "http"){ | 626 | } else if(filename.left(4) == "http"){ |
627 | m3uFile=filename; | 627 | m3uFile=filename; |
628 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 628 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
629 | } else{ | 629 | } else{ |
630 | m3uFile=filename; | 630 | m3uFile=filename; |
631 | } | 631 | } |
632 | 632 | ||
633 | lnk.setName( filename ); //sets name | 633 | lnk.setName( filename ); //sets name |
634 | lnk.setFile( filename ); //sets file name | 634 | lnk.setFile( filename ); //sets file name |
635 | 635 | ||
636 | // lnk.setIcon("opieplayer2/musicfile"); | 636 | // lnk.setIcon("opieplayer2/musicfile"); |
637 | 637 | ||
638 | d->selectedFiles->addToSelection( lnk ); | 638 | d->selectedFiles->addToSelection( lnk ); |
639 | writeCurrentM3u(); | 639 | writeCurrentM3u(); |
640 | d->selectedFiles->setSelectedItem( lnk.name()); | 640 | d->selectedFiles->setSelectedItem( lnk.name()); |
641 | } | 641 | } |
642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
643 | readListFromFile( filename ); | 643 | readListFromFile( filename ); |
644 | } else { | 644 | } else { |
645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
646 | lnk.setFile( filename ); //sets file name | 646 | lnk.setFile( filename ); //sets file name |
647 | d->selectedFiles->addToSelection( lnk); | 647 | d->selectedFiles->addToSelection( lnk); |
648 | writeCurrentM3u(); | 648 | writeCurrentM3u(); |
649 | d->selectedFiles->setSelectedItem( lnk.name()); | 649 | d->selectedFiles->setSelectedItem( lnk.name()); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | 652 | ||
653 | 653 | ||
654 | delete fileDlg; | 654 | delete fileDlg; |
655 | } | 655 | } |
656 | 656 | ||
657 | 657 | ||
658 | void PlayListWidget::openFile() { | 658 | void PlayListWidget::openFile() { |
659 | 659 | ||
660 | QString filename, name; | 660 | QString filename, name; |
661 | 661 | ||
662 | Config cfg( "OpiePlayer" ); | 662 | Config cfg( "OpiePlayer" ); |
663 | cfg.setGroup("Dialog"); | 663 | cfg.setGroup("Dialog"); |
664 | MimeTypes types; | 664 | MimeTypes types; |
665 | QStringList audio, video, all; | 665 | QStringList audio, video, all; |
666 | audio << "audio/*"; | 666 | audio << "audio/*"; |
667 | audio << "playlist/plain"; | 667 | audio << "playlist/plain"; |
668 | audio << "application/ogg"; | 668 | audio << "application/ogg"; |
669 | audio << "audio/x-mpegurl"; | 669 | audio << "audio/x-mpegurl"; |
670 | 670 | ||
671 | video << "video/*"; | 671 | video << "video/*"; |
672 | video << "playlist/plain"; | 672 | video << "playlist/plain"; |
673 | 673 | ||
674 | all += audio; | 674 | all += audio; |
675 | all += video; | 675 | all += video; |
676 | types.insert("All Media Files", all ); | 676 | types.insert("All Media Files", all ); |
677 | types.insert("Audio", audio ); | 677 | types.insert("Audio", audio ); |
678 | types.insert("Video", video ); | 678 | types.insert("Video", video ); |
679 | 679 | ||
680 | QString str = OFileDialog::getOpenFileName( 1, | 680 | QString str = OFileDialog::getOpenFileName( 1, |
681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
682 | types, 0 ); | 682 | types, 0 ); |
683 | 683 | ||
684 | if(str.left(2) == "//") { | 684 | if(str.left(2) == "//") { |
685 | str=str.right(str.length()-1); | 685 | str=str.right(str.length()-1); |
686 | } | 686 | } |
687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
688 | 688 | ||
689 | if( !str.isEmpty() ) { | 689 | if( !str.isEmpty() ) { |
690 | 690 | ||
691 | qDebug( "Selected filename is " + str ); | 691 | qDebug( "Selected filename is " + str ); |
692 | filename = str; | 692 | filename = str; |
693 | DocLnk lnk; | 693 | DocLnk lnk; |
694 | 694 | ||
695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
696 | readListFromFile( filename ); | 696 | readListFromFile( filename ); |
697 | } else { | 697 | } else { |
698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
699 | lnk.setFile( filename ); //sets file name | 699 | lnk.setFile( filename ); //sets file name |
700 | d->selectedFiles->addToSelection( lnk ); | 700 | d->selectedFiles->addToSelection( lnk ); |
701 | writeCurrentM3u(); | 701 | writeCurrentM3u(); |
702 | d->selectedFiles->setSelectedItem( lnk.name() ); | 702 | d->selectedFiles->setSelectedItem( lnk.name() ); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void PlayListWidget::readListFromFile( const QString &filename ) { | 708 | void PlayListWidget::readListFromFile( const QString &filename ) { |
709 | qDebug( "read list filename " + filename ); | 709 | qDebug( "read list filename " + filename ); |
710 | QFileInfo fi(filename); | 710 | QFileInfo fi(filename); |
711 | Om3u *m3uList; | 711 | Om3u *m3uList; |
712 | QString s, name; | 712 | QString s, name; |
713 | m3uList = new Om3u( filename, IO_ReadOnly ); | 713 | m3uList = new Om3u( filename, IO_ReadOnly ); |
714 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 714 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
715 | m3uList->readM3u(); | 715 | m3uList->readM3u(); |
716 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 716 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
717 | m3uList->readPls(); | 717 | m3uList->readPls(); |
718 | 718 | ||
719 | DocLnk lnk; | 719 | DocLnk lnk; |
720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
721 | s = *it; | 721 | s = *it; |
722 | // qDebug(s); | 722 | // qDebug(s); |
723 | if(s.left(4)=="http") { | 723 | if(s.left(4)=="http") { |
724 | lnk.setName( s ); //sets file name | 724 | lnk.setName( s ); //sets file name |
725 | lnk.setIcon("opieplayer2/musicfile"); | 725 | lnk.setIcon("opieplayer2/musicfile"); |
726 | lnk.setFile( s ); //sets file name | 726 | lnk.setFile( s ); //sets file name |
727 | 727 | ||
728 | } else { //is file | 728 | } else { //is file |
729 | lnk.setName( QFileInfo(s).baseName()); | 729 | lnk.setName( QFileInfo(s).baseName()); |
730 | if(s.left(1) != "/") { | 730 | if(s.left(1) != "/") { |
731 | 731 | ||
732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
733 | } else { | 733 | } else { |
734 | lnk.setFile( s); | 734 | lnk.setFile( s); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | d->selectedFiles->addToSelection( lnk ); | 737 | d->selectedFiles->addToSelection( lnk ); |
738 | } | 738 | } |
739 | Config config( "OpiePlayer" ); | 739 | Config config( "OpiePlayer" ); |
740 | config.setGroup( "PlayList" ); | 740 | config.setGroup( "PlayList" ); |
741 | 741 | ||
742 | config.writeEntry("CurrentPlaylist",filename); | 742 | config.writeEntry("CurrentPlaylist",filename); |
743 | config.write(); | 743 | config.write(); |
744 | currentPlayList=filename; | 744 | currentPlayList=filename; |
745 | 745 | ||
746 | m3uList->close(); | 746 | m3uList->close(); |
747 | delete m3uList; | 747 | delete m3uList; |
748 | 748 | ||
749 | d->selectedFiles->setSelectedItem( s); | 749 | d->selectedFiles->setSelectedItem( s); |
750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
751 | 751 | ||
752 | } | 752 | } |
753 | 753 | ||
754 | // writes current playlist to current m3u file */ | 754 | // writes current playlist to current m3u file */ |
755 | void PlayListWidget::writeCurrentM3u() { | 755 | void PlayListWidget::writeCurrentM3u() { |
756 | qDebug("writing to current m3u"); | 756 | qDebug("writing to current m3u"); |
757 | Config cfg( "OpiePlayer" ); | 757 | Config cfg( "OpiePlayer" ); |
758 | cfg.setGroup("PlayList"); | 758 | cfg.setGroup("PlayList"); |
759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
760 | 760 | ||
761 | Om3u *m3uList; | 761 | Om3u *m3uList; |
762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
763 | if( d->selectedFiles->first()) { | 763 | if( d->selectedFiles->first()) { |
764 | 764 | ||
765 | do { | 765 | do { |
766 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 766 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
767 | m3uList->add( d->selectedFiles->current()->file() ); | 767 | m3uList->add( d->selectedFiles->current()->file() ); |
768 | } | 768 | } |
769 | while ( d->selectedFiles->next() ); | 769 | while ( d->selectedFiles->next() ); |
770 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 770 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
771 | m3uList->write(); | 771 | m3uList->write(); |
772 | m3uList->close(); | 772 | m3uList->close(); |
773 | } | 773 | } |
774 | delete m3uList; | 774 | delete m3uList; |
775 | 775 | ||
776 | } | 776 | } |
777 | 777 | ||
778 | /* | 778 | /* |
779 | writes current playlist to m3u file */ | 779 | writes current playlist to m3u file */ |
780 | void PlayListWidget::writem3u() { | 780 | void PlayListWidget::writem3u() { |
781 | //InputDilog *fileDlg; | 781 | //InputDilog *fileDlg; |
782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
783 | //fileDlg->exec(); | 783 | //fileDlg->exec(); |
784 | 784 | ||
785 | Config cfg( "OpiePlayer" ); | 785 | Config cfg( "OpiePlayer" ); |
786 | cfg.setGroup("Dialog"); | 786 | cfg.setGroup("Dialog"); |
787 | MimeTypes types; | 787 | MimeTypes types; |
788 | QStringList audio, video, all; | 788 | QStringList audio, video, all; |
789 | audio << "audio/*"; | 789 | audio << "audio/*"; |
790 | audio << "playlist/plain"; | 790 | audio << "playlist/plain"; |
791 | audio << "audio/x-mpegurl"; | 791 | audio << "audio/x-mpegurl"; |
792 | 792 | ||
793 | video << "video/*"; | 793 | video << "video/*"; |
794 | video << "playlist/plain"; | 794 | video << "playlist/plain"; |
795 | 795 | ||
796 | all += audio; | 796 | all += audio; |
797 | all += video; | 797 | all += video; |
798 | types.insert("All Media Files", all ); | 798 | types.insert("All Media Files", all ); |
799 | types.insert("Audio", audio ); | 799 | types.insert("Audio", audio ); |
800 | types.insert("Video", video ); | 800 | types.insert("Video", video ); |
801 | 801 | ||
802 | QString str = OFileDialog::getOpenFileName( 1, | 802 | QString str = OFileDialog::getOpenFileName( 1, |
803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
804 | types, 0 ); | 804 | types, 0 ); |
805 | if(str.left(2) == "//") str=str.right(str.length()-1); | 805 | if(str.left(2) == "//") str=str.right(str.length()-1); |
806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
807 | 807 | ||
808 | 808 | ||
809 | QString name, filename, list; | 809 | QString name, filename, list; |
810 | Om3u *m3uList; | 810 | Om3u *m3uList; |
811 | 811 | ||
812 | if( !str.isEmpty() ) { | 812 | if( !str.isEmpty() ) { |
813 | name = str; | 813 | name = str; |
814 | // name = fileDlg->text(); | 814 | // name = fileDlg->text(); |
815 | // qDebug( filename ); | 815 | // qDebug( filename ); |
816 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 816 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
817 | filename = name; | 817 | filename = name; |
818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
819 | } | 819 | } |
820 | else //otherwise dump it somewhere noticable | 820 | else //otherwise dump it somewhere noticable |
821 | filename = QPEApplication::documentDir() + "/" + name; | 821 | filename = QPEApplication::documentDir() + "/" + name; |
822 | 822 | ||
823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
824 | filename += ".m3u"; | 824 | filename += ".m3u"; |
825 | 825 | ||
826 | if( d->selectedFiles->first()) { //ramble through playlist view | 826 | if( d->selectedFiles->first()) { //ramble through playlist view |
827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
828 | 828 | ||
829 | do { | 829 | do { |
830 | m3uList->add( d->selectedFiles->current()->file()); | 830 | m3uList->add( d->selectedFiles->current()->file()); |
831 | } | 831 | } |
832 | while ( d->selectedFiles->next() ); | 832 | while ( d->selectedFiles->next() ); |
833 | // qDebug( list ); | 833 | // qDebug( list ); |
834 | m3uList->write(); | 834 | m3uList->write(); |
835 | m3uList->close(); | 835 | m3uList->close(); |
836 | delete m3uList; | 836 | delete m3uList; |
837 | 837 | ||
838 | //delete fileDlg; | 838 | //delete fileDlg; |
839 | 839 | ||
840 | DocLnk lnk; | 840 | DocLnk lnk; |
841 | lnk.setFile( filename); | 841 | lnk.setFile( filename); |
842 | lnk.setIcon("opieplayer2/playlist2"); | 842 | lnk.setIcon("opieplayer2/playlist2"); |
843 | lnk.setName( name); //sets file name | 843 | lnk.setName( name); //sets file name |
844 | 844 | ||
845 | // qDebug(filename); | 845 | // qDebug(filename); |
846 | Config config( "OpiePlayer" ); | 846 | Config config( "OpiePlayer" ); |
847 | config.setGroup( "PlayList" ); | 847 | config.setGroup( "PlayList" ); |
848 | 848 | ||
849 | config.writeEntry("CurrentPlaylist",filename); | 849 | config.writeEntry("CurrentPlaylist",filename); |
850 | currentPlayList=filename; | 850 | currentPlayList=filename; |
851 | 851 | ||
852 | if(!lnk.writeLink()) { | 852 | if(!lnk.writeLink()) { |
853 | qDebug("Writing doclink did not work"); | 853 | qDebug("Writing doclink did not work"); |
854 | } | 854 | } |
855 | 855 | ||
856 | setCaption(tr("OpiePlayer: ") + name); | 856 | setCaption(tr("OpiePlayer: ") + name); |
857 | } | 857 | } |
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
862 | switch ( e->key() ) { | 862 | switch ( e->key() ) { |
863 | ////////////////////////////// Zaurus keys | 863 | ////////////////////////////// Zaurus keys |
864 | case Key_F9: //activity | 864 | case Key_F9: //activity |
865 | // if(audioUI->isHidden()) | 865 | // if(audioUI->isHidden()) |
866 | // audioUI->showMaximized(); | 866 | // audioUI->showMaximized(); |
867 | break; | 867 | break; |
868 | case Key_F10: //contacts | 868 | case Key_F10: //contacts |
869 | // if( videoUI->isHidden()) | 869 | // if( videoUI->isHidden()) |
870 | // videoUI->showMaximized(); | 870 | // videoUI->showMaximized(); |
871 | break; | 871 | break; |
872 | case Key_F11: //menu | 872 | case Key_F11: //menu |
873 | break; | 873 | break; |
874 | case Key_F12: //home | 874 | case Key_F12: //home |
875 | // doBlank(); | 875 | // doBlank(); |
876 | break; | 876 | break; |
877 | case Key_F13: //mail | 877 | case Key_F13: //mail |
878 | // doUnblank(); | 878 | // doUnblank(); |
879 | break; | 879 | break; |
880 | case Key_Q: //add to playlist | 880 | case Key_Q: //add to playlist |
881 | addSelected(); | 881 | addSelected(); |
882 | break; | 882 | break; |
883 | case Key_R: //remove from playlist | 883 | case Key_R: //remove from playlist |
884 | removeSelected(); | 884 | removeSelected(); |
885 | break; | 885 | break; |
886 | // case Key_P: //play | 886 | // case Key_P: //play |
887 | // qDebug("Play"); | 887 | // qDebug("Play"); |
888 | // playSelected(); | 888 | // playSelected(); |
889 | // break; | 889 | // break; |
890 | case Key_Space: | 890 | case Key_Space: |
891 | // playSelected(); puh | 891 | // playSelected(); puh |
892 | break; | 892 | break; |
893 | case Key_1: | 893 | case Key_1: |
894 | tabWidget->setCurrentPage( 0 ); | 894 | tabWidget->setCurrentPage( 0 ); |
895 | break; | 895 | break; |
896 | case Key_2: | 896 | case Key_2: |
897 | tabWidget->setCurrentPage( 1 ); | 897 | tabWidget->setCurrentPage( 1 ); |
898 | break; | 898 | break; |
899 | case Key_3: | 899 | case Key_3: |
900 | tabWidget->setCurrentPage( 2 ); | 900 | tabWidget->setCurrentPage( 2 ); |
901 | break; | 901 | break; |
902 | case Key_4: | 902 | case Key_4: |
903 | tabWidget->setCurrentPage( 3 ); | 903 | tabWidget->setCurrentPage( 3 ); |
904 | break; | 904 | break; |
905 | case Key_Down: | 905 | case Key_Down: |
906 | if ( !d->selectedFiles->next() ) | 906 | if ( !d->selectedFiles->next() ) |
907 | d->selectedFiles->first(); | 907 | d->selectedFiles->first(); |
908 | break; | 908 | break; |
909 | case Key_Up: | 909 | case Key_Up: |
910 | if ( !d->selectedFiles->prev() ) | 910 | if ( !d->selectedFiles->prev() ) |
911 | // d->selectedFiles->last(); | 911 | // d->selectedFiles->last(); |
912 | break; | 912 | break; |
913 | } | 913 | } |
914 | } | 914 | } |
915 | 915 | ||
916 | void PlayListWidget::pmViewActivated(int index) { | 916 | void PlayListWidget::pmViewActivated(int index) { |
917 | // qDebug("%d", index); | 917 | // qDebug("%d", index); |
918 | switch(index) { | 918 | switch(index) { |
919 | case -16: | 919 | case -16: |
920 | { | 920 | { |
921 | mediaPlayerState->toggleFullscreen(); | 921 | mediaPlayerState->toggleFullscreen(); |
922 | bool b=mediaPlayerState->isFullscreen(); | 922 | bool b=mediaPlayerState->isFullscreen(); |
923 | pmView->setItemChecked( index, b); | 923 | pmView->setItemChecked( index, b); |
924 | Config cfg( "OpiePlayer" ); | 924 | Config cfg( "OpiePlayer" ); |
925 | cfg.writeEntry( "FullScreen", b ); | 925 | cfg.writeEntry( "FullScreen", b ); |
926 | } | 926 | } |
927 | break; | 927 | break; |
928 | }; | 928 | }; |
929 | } | 929 | } |
930 | 930 | ||
931 | void PlayListWidget::populateSkinsMenu() { | 931 | void PlayListWidget::populateSkinsMenu() { |
932 | int item = 0; | 932 | int item = 0; |
933 | defaultSkinIndex = 0; | 933 | defaultSkinIndex = 0; |
934 | QString skinName; | 934 | QString skinName; |
935 | Config cfg( "OpiePlayer" ); | 935 | Config cfg( "OpiePlayer" ); |
936 | cfg.setGroup("Options" ); | 936 | cfg.setGroup("Options" ); |
937 | QString skin = cfg.readEntry( "Skin", "default" ); | 937 | QString skin = cfg.readEntry( "Skin", "default" ); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index fec91ea..33fe188 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,194 +1,194 @@ | |||
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" | 47 | #include "mediaplayerstate.h" |
48 | 48 | ||
49 | PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) | 49 | PlayListWidgetGui::PlayListWidgetGui(QWidget* parent, const char* name ) |
50 | : QMainWindow( parent, name ) { | 50 | : QMainWindow( parent, name ) { |
51 | 51 | ||
52 | d = new PlayListWidgetPrivate; | 52 | d = new PlayListWidgetPrivate; |
53 | d->setDocumentUsed = FALSE; | 53 | d->setDocumentUsed = FALSE; |
54 | 54 | ||
55 | setBackgroundMode( PaletteButton ); | 55 | setBackgroundMode( PaletteButton ); |
56 | setToolBarsMovable( FALSE ); | 56 | setToolBarsMovable( FALSE ); |
57 | 57 | ||
58 | // Create Toolbar | 58 | // Create Toolbar |
59 | QToolBar *toolbar = new QToolBar( this ); | 59 | QToolBar *toolbar = new QToolBar( this ); |
60 | toolbar->setHorizontalStretchable( TRUE ); | 60 | toolbar->setHorizontalStretchable( TRUE ); |
61 | 61 | ||
62 | // Create Menubar | 62 | // Create Menubar |
63 | QMenuBar *menu = new QMenuBar( toolbar ); | 63 | QMenuBar *menu = new QMenuBar( toolbar ); |
64 | menu->setMargin( 0 ); | 64 | menu->setMargin( 0 ); |
65 | 65 | ||
66 | bar = new QToolBar( this ); | 66 | bar = new QToolBar( this ); |
67 | bar->setLabel( tr( "Play Operations" ) ); | 67 | bar->setLabel( tr( "Play Operations" ) ); |
68 | 68 | ||
69 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 69 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
70 | tbDeletePlaylist->setFlat( TRUE ); | 70 | tbDeletePlaylist->setFlat( TRUE ); |
71 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 71 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
72 | 72 | ||
73 | tbDeletePlaylist->hide(); | 73 | tbDeletePlaylist->hide(); |
74 | 74 | ||
75 | pmPlayList = new QPopupMenu( this ); | 75 | pmPlayList = new QPopupMenu( this ); |
76 | menu->insertItem( tr( "File" ), pmPlayList ); | 76 | menu->insertItem( tr( "File" ), pmPlayList ); |
77 | 77 | ||
78 | pmView = new QPopupMenu( this ); | 78 | pmView = new QPopupMenu( this ); |
79 | menu->insertItem( tr( "View" ), pmView ); | 79 | menu->insertItem( tr( "View" ), pmView ); |
80 | pmView->isCheckable(); | 80 | pmView->isCheckable(); |
81 | 81 | ||
82 | skinsMenu = new QPopupMenu( this ); | 82 | skinsMenu = new QPopupMenu( this ); |
83 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 83 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
84 | skinsMenu->isCheckable(); | 84 | skinsMenu->isCheckable(); |
85 | 85 | ||
86 | gammaMenu = new QPopupMenu( this ); | 86 | gammaMenu = new QPopupMenu( this ); |
87 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); | 87 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
88 | 88 | ||
89 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 89 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
90 | gammaSlider->setRange( -40, 40 ); | 90 | gammaSlider->setRange( -40, 40 ); |
91 | gammaSlider->setTickmarks( QSlider::Left ); | 91 | gammaSlider->setTickmarks( QSlider::Left ); |
92 | gammaSlider->setTickInterval( 20 ); | 92 | gammaSlider->setTickInterval( 20 ); |
93 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); | 93 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); |
94 | gammaSlider->setValue( 0 ); | 94 | gammaSlider->setValue( 0 ); |
95 | gammaSlider->setMinimumHeight( 50 ); | 95 | gammaSlider->setMinimumHeight( 50 ); |
96 | 96 | ||
97 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 97 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
98 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); | 98 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); |
99 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); | 99 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); |
100 | 100 | ||
101 | gammaMenu->insertItem( gammaSlider ); | 101 | gammaMenu->insertItem( gammaSlider ); |
102 | gammaMenu->insertItem( gammaLCD ); | 102 | gammaMenu->insertItem( gammaLCD ); |
103 | 103 | ||
104 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | 104 | connect( gammaSlider, SIGNAL( valueChanged(int) ), gammaLCD, SLOT( display(int) ) ); |
105 | 105 | ||
106 | vbox5 = new QVBox( this ); | 106 | vbox5 = new QVBox( this ); |
107 | QVBox *vbox4 = new QVBox( vbox5 ); | 107 | QVBox *vbox4 = new QVBox( vbox5 ); |
108 | QHBox *hbox6 = new QHBox( vbox4 ); | 108 | QHBox *hbox6 = new QHBox( vbox4 ); |
109 | 109 | ||
110 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 110 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
111 | 111 | ||
112 | playListTab = new QWidget( tabWidget, "PlayListTab" ); | 112 | playListTab = new QWidget( tabWidget, "PlayListTab" ); |
113 | tabWidget->insertTab( playListTab, "Playlist"); | 113 | tabWidget->insertTab( playListTab, "Playlist"); |
114 | 114 | ||
115 | QGridLayout *Playout = new QGridLayout( playListTab ); | 115 | QGridLayout *Playout = new QGridLayout( playListTab ); |
116 | Playout->setSpacing( 2); | 116 | Playout->setSpacing( 2); |
117 | Playout->setMargin( 2); | 117 | Playout->setMargin( 2); |
118 | 118 | ||
119 | // Add the playlist area | 119 | // Add the playlist area |
120 | QVBox *vbox3 = new QVBox( playListTab ); | 120 | QVBox *vbox3 = new QVBox( playListTab ); |
121 | d->playListFrame = vbox3; | 121 | d->playListFrame = vbox3; |
122 | 122 | ||
123 | QHBox *hbox2 = new QHBox( vbox3 ); | 123 | QHBox *hbox2 = new QHBox( vbox3 ); |
124 | d->selectedFiles = new PlayListSelection( hbox2 ); | 124 | d->selectedFiles = new PlayListSelection( hbox2 ); |
125 | 125 | ||
126 | vbox1 = new QVBox( hbox2 ); | 126 | vbox1 = new QVBox( hbox2 ); |
127 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 127 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
128 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 128 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
129 | 129 | ||
130 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 130 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
131 | 131 | ||
132 | QWidget *aTab; | 132 | QWidget *aTab; |
133 | aTab = new QWidget( tabWidget, "aTab" ); | 133 | aTab = new QWidget( tabWidget, "aTab" ); |
134 | 134 | ||
135 | QGridLayout *Alayout = new QGridLayout( aTab ); | 135 | QGridLayout *Alayout = new QGridLayout( aTab ); |
136 | Alayout->setSpacing( 2 ); | 136 | Alayout->setSpacing( 2 ); |
137 | Alayout->setMargin( 2 ); | 137 | Alayout->setMargin( 2 ); |
138 | // no m3u's here please | 138 | // no m3u's here please |
139 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" ); | 139 | audioView = new PlayListFileView( "audio/mpeg;audio/x-wav;application/ogg", "opieplayer2/musicfile", aTab, "Audioview" ); |
140 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 140 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
141 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 141 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
142 | 142 | ||
143 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 143 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
144 | 144 | ||
145 | QWidget *vTab; | 145 | QWidget *vTab; |
146 | vTab = new QWidget( tabWidget, "vTab" ); | 146 | vTab = new QWidget( tabWidget, "vTab" ); |
147 | 147 | ||
148 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 148 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
149 | Vlayout->setSpacing( 2 ); | 149 | Vlayout->setSpacing( 2 ); |
150 | Vlayout->setMargin( 2 ); | 150 | Vlayout->setMargin( 2 ); |
151 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); | 151 | videoView = new PlayListFileView( "video/*", "opieplayer2/videofile", vTab, "Videoview" ); |
152 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 152 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
153 | 153 | ||
154 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 154 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
155 | 155 | ||
156 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 156 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
157 | 157 | ||
158 | //playlists list | 158 | //playlists list |
159 | QWidget *LTab; | 159 | QWidget *LTab; |
160 | LTab = new QWidget( tabWidget, "LTab" ); | 160 | LTab = new QWidget( tabWidget, "LTab" ); |
161 | QGridLayout *Llayout = new QGridLayout( LTab ); | 161 | QGridLayout *Llayout = new QGridLayout( LTab ); |
162 | Llayout->setSpacing( 2 ); | 162 | Llayout->setSpacing( 2 ); |
163 | Llayout->setMargin( 2 ); | 163 | Llayout->setMargin( 2 ); |
164 | 164 | ||
165 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 165 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
166 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 166 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
167 | 167 | ||
168 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 168 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
169 | 169 | ||
170 | setCentralWidget( vbox5 ); | 170 | setCentralWidget( vbox5 ); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | 174 | ||
175 | PlayListWidgetGui::~PlayListWidgetGui() { | 175 | PlayListWidgetGui::~PlayListWidgetGui() { |
176 | } | 176 | } |
177 | 177 | ||
178 | void PlayListWidgetGui::setView( char view ) { | 178 | void PlayListWidgetGui::setView( char view ) { |
179 | if ( view == 'l' ) | 179 | if ( view == 'l' ) |
180 | showMaximized(); | 180 | showMaximized(); |
181 | else | 181 | else |
182 | hide(); | 182 | hide(); |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
186 | void PlayListWidgetGui::setActiveWindow() { | 186 | void PlayListWidgetGui::setActiveWindow() { |
187 | // qDebug("SETTING active window"); | 187 | // qDebug("SETTING active window"); |
188 | // When we get raised we need to ensure that it switches views | 188 | // When we get raised we need to ensure that it switches views |
189 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); | 189 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); |
190 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate | 190 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate |
191 | mediaPlayerState->setDisplayType( origDisplayType ); // now switch back | 191 | mediaPlayerState->setDisplayType( origDisplayType ); // now switch back |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
diff --git a/noncore/multimedia/opieplayer2/threadutil.cpp b/noncore/multimedia/opieplayer2/threadutil.cpp index ff38b1e..fb951b4 100644 --- a/noncore/multimedia/opieplayer2/threadutil.cpp +++ b/noncore/multimedia/opieplayer2/threadutil.cpp | |||
@@ -1,394 +1,394 @@ | |||
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "threadutil.h" | 20 | #include "threadutil.h" |
21 | 21 | ||
22 | #include <qsocketnotifier.h> | 22 | #include <qsocketnotifier.h> |
23 | 23 | ||
24 | #include <pthread.h> | 24 | #include <pthread.h> |
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <errno.h> | 27 | #include <errno.h> |
28 | 28 | ||
29 | using namespace ThreadUtil; | 29 | using namespace ThreadUtil; |
30 | 30 | ||
31 | struct Mutex::Data | 31 | struct Mutex::Data |
32 | { | 32 | { |
33 | Data() | 33 | Data() |
34 | { | 34 | { |
35 | pthread_mutex_init( &mutex, 0 ); | 35 | pthread_mutex_init( &mutex, 0 ); |
36 | } | 36 | } |
37 | ~Data() | 37 | ~Data() |
38 | { | 38 | { |
39 | pthread_mutex_destroy( &mutex ); | 39 | pthread_mutex_destroy( &mutex ); |
40 | } | 40 | } |
41 | 41 | ||
42 | pthread_mutex_t mutex; | 42 | pthread_mutex_t mutex; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | Mutex::Mutex() | 45 | Mutex::Mutex() |
46 | : d( new Data ) | 46 | : d( new Data ) |
47 | { | 47 | { |
48 | } | 48 | } |
49 | 49 | ||
50 | Mutex::~Mutex() | 50 | Mutex::~Mutex() |
51 | { | 51 | { |
52 | delete d; | 52 | delete d; |
53 | } | 53 | } |
54 | 54 | ||
55 | void Mutex::lock() | 55 | void Mutex::lock() |
56 | { | 56 | { |
57 | pthread_mutex_lock( &d->mutex ); | 57 | pthread_mutex_lock( &d->mutex ); |
58 | } | 58 | } |
59 | 59 | ||
60 | void Mutex::unlock() | 60 | void Mutex::unlock() |
61 | { | 61 | { |
62 | pthread_mutex_unlock( &d->mutex ); | 62 | pthread_mutex_unlock( &d->mutex ); |
63 | } | 63 | } |
64 | 64 | ||
65 | bool Mutex::tryLock() | 65 | bool Mutex::tryLock() |
66 | { | 66 | { |
67 | return pthread_mutex_trylock( &d->mutex ) == 0; | 67 | return pthread_mutex_trylock( &d->mutex ) == 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | bool Mutex::isLocked() | 70 | bool Mutex::isLocked() |
71 | { | 71 | { |
72 | if ( !tryLock() ) | 72 | if ( !tryLock() ) |
73 | return true; | 73 | return true; |
74 | 74 | ||
75 | unlock(); | 75 | unlock(); |
76 | return false; | 76 | return false; |
77 | } | 77 | } |
78 | 78 | ||
79 | struct WaitCondition::Data | 79 | struct WaitCondition::Data |
80 | { | 80 | { |
81 | Data() | 81 | Data() |
82 | { | 82 | { |
83 | int result = pthread_cond_init( &waitCondition, 0 ); | 83 | int result = pthread_cond_init( &waitCondition, 0 ); |
84 | assert( result == 0 ); | 84 | assert( result == 0 ); |
85 | } | 85 | } |
86 | ~Data() | 86 | ~Data() |
87 | { | 87 | { |
88 | pthread_cond_destroy( &waitCondition ); | 88 | pthread_cond_destroy( &waitCondition ); |
89 | } | 89 | } |
90 | 90 | ||
91 | pthread_cond_t waitCondition; | 91 | pthread_cond_t waitCondition; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | WaitCondition::WaitCondition() | 94 | WaitCondition::WaitCondition() |
95 | : d( new Data ) | 95 | : d( new Data ) |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | WaitCondition::~WaitCondition() | 99 | WaitCondition::~WaitCondition() |
100 | { | 100 | { |
101 | delete d; | 101 | delete d; |
102 | } | 102 | } |
103 | 103 | ||
104 | bool WaitCondition::wait() | 104 | bool WaitCondition::wait() |
105 | { | 105 | { |
106 | Mutex m; | 106 | Mutex m; |
107 | m.lock(); | 107 | m.lock(); |
108 | return wait( m ); | 108 | return wait( m ); |
109 | } | 109 | } |
110 | 110 | ||
111 | bool WaitCondition::wait( Mutex &mutex ) | 111 | bool WaitCondition::wait( Mutex &mutex ) |
112 | { | 112 | { |
113 | return pthread_cond_wait( &d->waitCondition, &mutex.d->mutex ); | 113 | return pthread_cond_wait( &d->waitCondition, &mutex.d->mutex ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void WaitCondition::wakeOne() | 116 | void WaitCondition::wakeOne() |
117 | { | 117 | { |
118 | pthread_cond_signal( &d->waitCondition ); | 118 | pthread_cond_signal( &d->waitCondition ); |
119 | } | 119 | } |
120 | 120 | ||
121 | void WaitCondition::wakeAll() | 121 | void WaitCondition::wakeAll() |
122 | { | 122 | { |
123 | pthread_cond_broadcast( &d->waitCondition ); | 123 | pthread_cond_broadcast( &d->waitCondition ); |
124 | } | 124 | } |
125 | 125 | ||
126 | struct Thread::Data | 126 | struct Thread::Data |
127 | { | 127 | { |
128 | Data() : isRunning( false ) | 128 | Data() : isRunning( false ) |
129 | {} | 129 | {} |
130 | 130 | ||
131 | pthread_t self; | 131 | pthread_t self; |
132 | Mutex guard; | 132 | Mutex guard; |
133 | bool isRunning; | 133 | bool isRunning; |
134 | 134 | ||
135 | WaitCondition finishCondition; | 135 | WaitCondition finishCondition; |
136 | 136 | ||
137 | Thread *thr; | 137 | Thread *thr; |
138 | 138 | ||
139 | void run() { thr->run(); } | 139 | void run() { thr->run(); } |
140 | }; | 140 | }; |
141 | 141 | ||
142 | extern "C" | 142 | extern "C" |
143 | { | 143 | { |
144 | 144 | ||
145 | static void terminate_thread( void *arg ) | 145 | static void terminate_thread( void *arg ) |
146 | { | 146 | { |
147 | Thread::Data *data = ( Thread::Data* )arg; | 147 | Thread::Data *data = ( Thread::Data* )arg; |
148 | 148 | ||
149 | assert( data ); | 149 | assert( data ); |
150 | 150 | ||
151 | AutoLock locker( data->guard ); | 151 | AutoLock locker( data->guard ); |
152 | data->isRunning = false; | 152 | data->isRunning = false; |
153 | data->finishCondition.wakeAll(); | 153 | data->finishCondition.wakeAll(); |
154 | } | 154 | } |
155 | 155 | ||
156 | static void *start_thread( void *arg ) | 156 | static void *start_thread( void *arg ) |
157 | { | 157 | { |
158 | Thread::Data *data = ( Thread::Data* )arg; | 158 | Thread::Data *data = ( Thread::Data* )arg; |
159 | 159 | ||
160 | pthread_cleanup_push( terminate_thread, data ); | 160 | pthread_cleanup_push( terminate_thread, data ); |
161 | 161 | ||
162 | data->isRunning = true; | 162 | data->isRunning = true; |
163 | data->run(); | 163 | data->run(); |
164 | 164 | ||
165 | pthread_cleanup_pop( true ); | 165 | pthread_cleanup_pop( true ); |
166 | 166 | ||
167 | Thread::exit(); | 167 | Thread::exit(); |
168 | return 0; // never reached | 168 | return 0; // never reached |
169 | } | 169 | } |
170 | 170 | ||
171 | } | 171 | } |
172 | 172 | ||
173 | Thread::Thread() | 173 | Thread::Thread() |
174 | : d( new Data ) | 174 | : d( new Data ) |
175 | { | 175 | { |
176 | d->thr = this; | 176 | d->thr = this; |
177 | } | 177 | } |
178 | 178 | ||
179 | Thread::~Thread() | 179 | Thread::~Thread() |
180 | { | 180 | { |
181 | assert( d->isRunning == false ); | 181 | assert( d->isRunning == false ); |
182 | delete d; | 182 | delete d; |
183 | } | 183 | } |
184 | 184 | ||
185 | void Thread::start() | 185 | void Thread::start() |
186 | { | 186 | { |
187 | AutoLock lock( d->guard ); | 187 | AutoLock lock( d->guard ); |
188 | 188 | ||
189 | if ( d->isRunning ) { | 189 | if ( d->isRunning ) { |
190 | qDebug( "ThreadUtil::Thread::start() called for running thread." ); | 190 | qDebug( "ThreadUtil::Thread::start() called for running thread." ); |
191 | return; | 191 | return; |
192 | } | 192 | } |
193 | 193 | ||
194 | pthread_attr_t attributes; | 194 | pthread_attr_t attributes; |
195 | pthread_attr_init( &attributes ); | 195 | pthread_attr_init( &attributes ); |
196 | pthread_attr_setscope( &attributes, PTHREAD_SCOPE_SYSTEM ); | 196 | pthread_attr_setscope( &attributes, PTHREAD_SCOPE_SYSTEM ); |
197 | int err = pthread_create( &d->self, &attributes, start_thread, ( void* )d ); | 197 | int err = pthread_create( &d->self, &attributes, start_thread, ( void* )d ); |
198 | if ( err != 0 ) { | 198 | if ( err != 0 ) { |
199 | qDebug( "ThreadUtil::Thread::start() : can't create thread: %s", strerror( err ) ); | 199 | qDebug( "ThreadUtil::Thread::start() : can't create thread: %s", strerror( err ) ); |
200 | pthread_attr_destroy( &attributes ); | 200 | pthread_attr_destroy( &attributes ); |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | pthread_attr_destroy( &attributes ); | 203 | pthread_attr_destroy( &attributes ); |
204 | } | 204 | } |
205 | 205 | ||
206 | void Thread::terminate() | 206 | void Thread::terminate() |
207 | { | 207 | { |
208 | AutoLock lock( d->guard ); | 208 | AutoLock lock( d->guard ); |
209 | if ( !d->isRunning ) | 209 | if ( !d->isRunning ) |
210 | return; | 210 | return; |
211 | 211 | ||
212 | pthread_cancel( d->self ); | 212 | pthread_cancel( d->self ); |
213 | } | 213 | } |
214 | 214 | ||
215 | bool Thread::wait() | 215 | bool Thread::wait() |
216 | { | 216 | { |
217 | AutoLock lock( d->guard ); | 217 | AutoLock lock( d->guard ); |
218 | if ( !d->isRunning ) | 218 | if ( !d->isRunning ) |
219 | return true; | 219 | return true; |
220 | 220 | ||
221 | return d->finishCondition.wait( d->guard ); | 221 | return d->finishCondition.wait( d->guard ); |
222 | } | 222 | } |
223 | 223 | ||
224 | bool Thread::isRunning() const | 224 | bool Thread::isRunning() const |
225 | { | 225 | { |
226 | AutoLock lock( d->guard ); | 226 | AutoLock lock( d->guard ); |
227 | return d->isRunning; | 227 | return d->isRunning; |
228 | } | 228 | } |
229 | 229 | ||
230 | void Thread::exit() | 230 | void Thread::exit() |
231 | { | 231 | { |
232 | pthread_exit( 0 ); | 232 | pthread_exit( 0 ); |
233 | } | 233 | } |
234 | 234 | ||
235 | OnewayNotifier::OnewayNotifier() | 235 | OnewayNotifier::OnewayNotifier() |
236 | { | 236 | { |
237 | int fds[ 2 ]; | 237 | int fds[ 2 ]; |
238 | pipe( fds ); | 238 | pipe( fds ); |
239 | m_readFd = fds[ 0 ]; | 239 | m_readFd = fds[ 0 ]; |
240 | m_writeFd = fds[ 1 ]; | 240 | m_writeFd = fds[ 1 ]; |
241 | 241 | ||
242 | m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read ); | 242 | m_notifier = new QSocketNotifier( m_readFd, QSocketNotifier::Read ); |
243 | connect( m_notifier, SIGNAL( activated( int ) ), | 243 | connect( m_notifier, SIGNAL( activated(int) ), |
244 | this, SLOT( wakeUp() ) ); | 244 | this, SLOT( wakeUp() ) ); |
245 | } | 245 | } |
246 | 246 | ||
247 | OnewayNotifier::~OnewayNotifier() | 247 | OnewayNotifier::~OnewayNotifier() |
248 | { | 248 | { |
249 | delete m_notifier; | 249 | delete m_notifier; |
250 | 250 | ||
251 | ::close( m_readFd ); | 251 | ::close( m_readFd ); |
252 | ::close( m_writeFd ); | 252 | ::close( m_writeFd ); |
253 | } | 253 | } |
254 | 254 | ||
255 | void OnewayNotifier::notify() | 255 | void OnewayNotifier::notify() |
256 | { | 256 | { |
257 | const char c = 42; | 257 | const char c = 42; |
258 | ::write( m_writeFd, &c, 1 ); | 258 | ::write( m_writeFd, &c, 1 ); |
259 | } | 259 | } |
260 | 260 | ||
261 | void OnewayNotifier::wakeUp() | 261 | void OnewayNotifier::wakeUp() |
262 | { | 262 | { |
263 | char c = 0; | 263 | char c = 0; |
264 | 264 | ||
265 | if ( ::read( m_readFd, &c, 1 ) != 1 ) | 265 | if ( ::read( m_readFd, &c, 1 ) != 1 ) |
266 | return; | 266 | return; |
267 | 267 | ||
268 | emit awake(); | 268 | emit awake(); |
269 | } | 269 | } |
270 | 270 | ||
271 | ChannelMessage::ChannelMessage( int type ) | 271 | ChannelMessage::ChannelMessage( int type ) |
272 | : m_type( type ), m_isCall( false ), m_replied( false ), | 272 | : m_type( type ), m_isCall( false ), m_replied( false ), |
273 | m_inEventHandler( false ) | 273 | m_inEventHandler( false ) |
274 | { | 274 | { |
275 | } | 275 | } |
276 | 276 | ||
277 | ChannelMessage::~ChannelMessage() | 277 | ChannelMessage::~ChannelMessage() |
278 | { | 278 | { |
279 | if ( m_guard.isLocked() ) | 279 | if ( m_guard.isLocked() ) |
280 | m_guard.unlock(); | 280 | m_guard.unlock(); |
281 | } | 281 | } |
282 | 282 | ||
283 | void ChannelMessage::reply() | 283 | void ChannelMessage::reply() |
284 | { | 284 | { |
285 | if ( !m_isCall ) | 285 | if ( !m_isCall ) |
286 | { | 286 | { |
287 | qDebug( "ChannelMessage::reply() - can't reply oneway message!" ); | 287 | qDebug( "ChannelMessage::reply() - can't reply oneway message!" ); |
288 | return; | 288 | return; |
289 | } | 289 | } |
290 | 290 | ||
291 | if ( m_inEventHandler ) | 291 | if ( m_inEventHandler ) |
292 | { | 292 | { |
293 | m_replied = true; | 293 | m_replied = true; |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | 296 | ||
297 | m_condition.wakeOne(); | 297 | m_condition.wakeOne(); |
298 | m_guard.unlock(); | 298 | m_guard.unlock(); |
299 | } | 299 | } |
300 | 300 | ||
301 | struct Channel::Private | 301 | struct Channel::Private |
302 | { | 302 | { |
303 | Private() | 303 | Private() |
304 | { | 304 | { |
305 | ownerThread = pthread_self(); | 305 | ownerThread = pthread_self(); |
306 | } | 306 | } |
307 | 307 | ||
308 | pthread_t ownerThread; | 308 | pthread_t ownerThread; |
309 | }; | 309 | }; |
310 | 310 | ||
311 | Channel::Channel( QObject *parent, const char *name ) | 311 | Channel::Channel( QObject *parent, const char *name ) |
312 | : QObject( parent, name ), d( new Private ) | 312 | : QObject( parent, name ), d( new Private ) |
313 | { | 313 | { |
314 | connect( &m_notifier, SIGNAL( awake() ), | 314 | connect( &m_notifier, SIGNAL( awake() ), |
315 | this, SLOT( deliver() ) ); | 315 | this, SLOT( deliver() ) ); |
316 | } | 316 | } |
317 | 317 | ||
318 | Channel::~Channel() | 318 | Channel::~Channel() |
319 | { | 319 | { |
320 | delete d; | 320 | delete d; |
321 | } | 321 | } |
322 | 322 | ||
323 | void Channel::send( ChannelMessage *message, SendType type ) | 323 | void Channel::send( ChannelMessage *message, SendType type ) |
324 | { | 324 | { |
325 | if ( type == WaitForReply ) | 325 | if ( type == WaitForReply ) |
326 | { | 326 | { |
327 | message->m_guard.lock(); | 327 | message->m_guard.lock(); |
328 | message->m_isCall = true; | 328 | message->m_isCall = true; |
329 | } | 329 | } |
330 | 330 | ||
331 | m_pendingMessagesGuard.lock(); | 331 | m_pendingMessagesGuard.lock(); |
332 | m_pendingMessages << MsgEnvelope( type, message ); | 332 | m_pendingMessages << MsgEnvelope( type, message ); |
333 | m_pendingMessagesGuard.unlock(); | 333 | m_pendingMessagesGuard.unlock(); |
334 | 334 | ||
335 | if ( d->ownerThread == pthread_self() ) { | 335 | if ( d->ownerThread == pthread_self() ) { |
336 | assert( type != WaitForReply ); | 336 | assert( type != WaitForReply ); |
337 | 337 | ||
338 | deliver(); | 338 | deliver(); |
339 | } | 339 | } |
340 | else | 340 | else |
341 | m_notifier.notify(); | 341 | m_notifier.notify(); |
342 | //QThread::postEvent( this, new QCustomEvent( QEvent::User, envelope ) ); | 342 | //QThread::postEvent( this, new QCustomEvent( QEvent::User, envelope ) ); |
343 | 343 | ||
344 | if ( type == WaitForReply ) | 344 | if ( type == WaitForReply ) |
345 | { | 345 | { |
346 | message->m_condition.wait( message->m_guard ); | 346 | message->m_condition.wait( message->m_guard ); |
347 | message->m_guard.unlock(); | 347 | message->m_guard.unlock(); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | void Channel::deliver() | 351 | void Channel::deliver() |
352 | { | 352 | { |
353 | AutoLock lock( m_pendingMessagesGuard ); | 353 | AutoLock lock( m_pendingMessagesGuard ); |
354 | 354 | ||
355 | while ( !m_pendingMessages.isEmpty() ) { | 355 | while ( !m_pendingMessages.isEmpty() ) { |
356 | MsgEnvelope envelope = m_pendingMessages.first(); | 356 | MsgEnvelope envelope = m_pendingMessages.first(); |
357 | 357 | ||
358 | m_pendingMessages.remove( m_pendingMessages.begin() ); | 358 | m_pendingMessages.remove( m_pendingMessages.begin() ); |
359 | 359 | ||
360 | m_pendingMessagesGuard.unlock(); | 360 | m_pendingMessagesGuard.unlock(); |
361 | deliverOne( envelope ); | 361 | deliverOne( envelope ); |
362 | m_pendingMessagesGuard.lock(); | 362 | m_pendingMessagesGuard.lock(); |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | void Channel::deliverOne( const MsgEnvelope &envelope ) | 366 | void Channel::deliverOne( const MsgEnvelope &envelope ) |
367 | { | 367 | { |
368 | ChannelMessage *msg = envelope.msg; | 368 | ChannelMessage *msg = envelope.msg; |
369 | 369 | ||
370 | assert( msg ); | 370 | assert( msg ); |
371 | 371 | ||
372 | if ( envelope.type == WaitForReply ) | 372 | if ( envelope.type == WaitForReply ) |
373 | { | 373 | { |
374 | msg->m_guard.lock(); | 374 | msg->m_guard.lock(); |
375 | msg->m_inEventHandler = true; | 375 | msg->m_inEventHandler = true; |
376 | } | 376 | } |
377 | 377 | ||
378 | receiveMessage( msg, envelope.type ); | 378 | receiveMessage( msg, envelope.type ); |
379 | 379 | ||
380 | if ( envelope.type == WaitForReply ) | 380 | if ( envelope.type == WaitForReply ) |
381 | { | 381 | { |
382 | msg->m_inEventHandler = false; | 382 | msg->m_inEventHandler = false; |
383 | if ( msg->m_replied ) | 383 | if ( msg->m_replied ) |
384 | { | 384 | { |
385 | msg->m_condition.wakeOne(); | 385 | msg->m_condition.wakeOne(); |
386 | // this is a bit tricky. we unlock only when we reply. | 386 | // this is a bit tricky. we unlock only when we reply. |
387 | // reply() does an unlock as well. | 387 | // reply() does an unlock as well. |
388 | msg->m_guard.unlock(); | 388 | msg->m_guard.unlock(); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | 392 | ||
393 | /* vim: et sw=4 ts=4 | 393 | /* vim: et sw=4 ts=4 |
394 | */ | 394 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index c829e03..a4d09f5 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,303 +1,303 @@ | |||
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" | 35 | #include "mediaplayerstate.h" |
36 | #include "playlistwidget.h" | 36 | #include "playlistwidget.h" |
37 | 37 | ||
38 | 38 | ||
39 | #ifdef Q_WS_QWS | 39 | #ifdef Q_WS_QWS |
40 | # define USE_DIRECT_PAINTER | 40 | # define USE_DIRECT_PAINTER |
41 | # include <qdirectpainter_qws.h> | 41 | # include <qdirectpainter_qws.h> |
42 | # include <qgfxraster_qws.h> | 42 | # include <qgfxraster_qws.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | 45 | ||
46 | namespace | 46 | namespace |
47 | { | 47 | { |
48 | 48 | ||
49 | const int xo = 2; // movable x offset | 49 | const int xo = 2; // movable x offset |
50 | const int yo = 0; // movable y offset | 50 | const int yo = 0; // movable y offset |
51 | 51 | ||
52 | const MediaWidget::SkinButtonInfo skinInfo[] = | 52 | const MediaWidget::SkinButtonInfo skinInfo[] = |
53 | { | 53 | { |
54 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 54 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
55 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 55 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
56 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, | 56 | { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, |
57 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, | 57 | { MediaWidget::Previous, "back", MediaWidget::NormalButton }, |
58 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 58 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
59 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 59 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
60 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } | 60 | { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } |
61 | }; | 61 | }; |
62 | 62 | ||
63 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 63 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
64 | 64 | ||
65 | } | 65 | } |
66 | 66 | ||
67 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 67 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
68 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) | 68 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) |
69 | { | 69 | { |
70 | setCaption( tr("OpiePlayer - Video") ); | 70 | setCaption( tr("OpiePlayer - Video") ); |
71 | 71 | ||
72 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 72 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
73 | 73 | ||
74 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 74 | connect ( videoFrame, SIGNAL( videoResized(const QSize&)), this, SIGNAL( videoResized(const QSize&))); |
75 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 75 | connect ( videoFrame, SIGNAL( clicked() ), this, SLOT ( backToNormal() ) ); |
76 | 76 | ||
77 | slider = 0; | 77 | slider = 0; |
78 | 78 | ||
79 | loadSkin(); | 79 | loadSkin(); |
80 | 80 | ||
81 | setLength( mediaPlayerState.length() ); | 81 | setLength( mediaPlayerState.length() ); |
82 | setPosition( mediaPlayerState.position() ); | 82 | setPosition( mediaPlayerState.position() ); |
83 | setFullscreen( mediaPlayerState.isFullscreen() ); | 83 | setFullscreen( mediaPlayerState.isFullscreen() ); |
84 | setPlaying( mediaPlayerState.isPlaying() ); | 84 | setPlaying( mediaPlayerState.isPlaying() ); |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | VideoWidget::~VideoWidget() | 88 | VideoWidget::~VideoWidget() |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | MediaWidget::GUIInfo VideoWidget::guiInfo() | 92 | MediaWidget::GUIInfo VideoWidget::guiInfo() |
93 | { | 93 | { |
94 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); | 94 | return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void VideoWidget::resizeEvent( QResizeEvent *e ) { | 97 | void VideoWidget::resizeEvent( QResizeEvent *e ) { |
98 | int h = height(); | 98 | int h = height(); |
99 | int w = width(); | 99 | int w = width(); |
100 | //int Vh = 160; | 100 | //int Vh = 160; |
101 | //int Vw = 220; | 101 | //int Vw = 220; |
102 | 102 | ||
103 | slider->setFixedWidth( w - 20 ); | 103 | slider->setFixedWidth( w - 20 ); |
104 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 104 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
105 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 105 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
106 | slider->setFocusPolicy( QWidget::NoFocus ); | 106 | slider->setFocusPolicy( QWidget::NoFocus ); |
107 | slider->setBackgroundPixmap( backgroundPixmap ); | 107 | slider->setBackgroundPixmap( backgroundPixmap ); |
108 | 108 | ||
109 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 109 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
110 | if(w>h) | 110 | if(w>h) |
111 | upperLeftOfButtonMask.ry() = 0; | 111 | upperLeftOfButtonMask.ry() = 0; |
112 | else | 112 | else |
113 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 113 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
114 | 114 | ||
115 | MediaWidget::resizeEvent( e ); | 115 | MediaWidget::resizeEvent( e ); |
116 | } | 116 | } |
117 | 117 | ||
118 | void VideoWidget::sliderPressed() { | 118 | void VideoWidget::sliderPressed() { |
119 | videoSliderBeingMoved = TRUE; | 119 | videoSliderBeingMoved = TRUE; |
120 | } | 120 | } |
121 | 121 | ||
122 | void VideoWidget::sliderReleased() { | 122 | void VideoWidget::sliderReleased() { |
123 | videoSliderBeingMoved = FALSE; | 123 | videoSliderBeingMoved = FALSE; |
124 | if ( slider->width() == 0 ) { | 124 | if ( slider->width() == 0 ) { |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 127 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
128 | mediaPlayerState.setPosition( val ); | 128 | mediaPlayerState.setPosition( val ); |
129 | } | 129 | } |
130 | 130 | ||
131 | void VideoWidget::setPosition( long i ) { | 131 | void VideoWidget::setPosition( long i ) { |
132 | updateSlider( i, mediaPlayerState.length() ); | 132 | updateSlider( i, mediaPlayerState.length() ); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void VideoWidget::setLength( long max ) { | 136 | void VideoWidget::setLength( long max ) { |
137 | updateSlider( mediaPlayerState.position(), max ); | 137 | updateSlider( mediaPlayerState.position(), max ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 140 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
141 | { | 141 | { |
142 | if ( displayType == MediaPlayerState::Video ) { | 142 | if ( displayType == MediaPlayerState::Video ) { |
143 | makeVisible(); | 143 | makeVisible(); |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | 146 | ||
147 | // Effectively blank the view next time we show it so it looks nicer | 147 | // Effectively blank the view next time we show it so it looks nicer |
148 | scaledWidth = 0; | 148 | scaledWidth = 0; |
149 | scaledHeight = 0; | 149 | scaledHeight = 0; |
150 | hide(); | 150 | hide(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void VideoWidget::loadSkin() | 153 | void VideoWidget::loadSkin() |
154 | { | 154 | { |
155 | loadDefaultSkin( guiInfo() ); | 155 | loadDefaultSkin( guiInfo() ); |
156 | 156 | ||
157 | delete slider; | 157 | delete slider; |
158 | slider = new QSlider( Qt::Horizontal, this ); | 158 | slider = new QSlider( Qt::Horizontal, this ); |
159 | slider->setMinValue( 0 ); | 159 | slider->setMinValue( 0 ); |
160 | slider->setMaxValue( 1 ); | 160 | slider->setMaxValue( 1 ); |
161 | slider->setBackgroundPixmap( backgroundPixmap ); | 161 | slider->setBackgroundPixmap( backgroundPixmap ); |
162 | //slider->setFocusPolicy( QWidget::NoFocus ); | 162 | //slider->setFocusPolicy( QWidget::NoFocus ); |
163 | 163 | ||
164 | resizeEvent( 0 ); | 164 | resizeEvent( 0 ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void VideoWidget::updateSlider( long i, long max ) { | 167 | void VideoWidget::updateSlider( long i, long max ) { |
168 | // Will flicker too much if we don't do this | 168 | // Will flicker too much if we don't do this |
169 | if ( max == 0 ) { | 169 | if ( max == 0 ) { |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | int width = slider->width(); | 172 | int width = slider->width(); |
173 | int val = int((double)i * width / max); | 173 | int val = int((double)i * width / max); |
174 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 174 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
175 | if ( slider->value() != val ) { | 175 | if ( slider->value() != val ) { |
176 | slider->setValue( val ); | 176 | slider->setValue( val ); |
177 | } | 177 | } |
178 | if ( slider->maxValue() != width ) { | 178 | if ( slider->maxValue() != width ) { |
179 | slider->setMaxValue( width ); | 179 | slider->setMaxValue( width ); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 184 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
185 | if ( mediaPlayerState.isFullscreen() ) { | 185 | if ( mediaPlayerState.isFullscreen() ) { |
186 | mediaPlayerState.setFullscreen( FALSE ); | 186 | mediaPlayerState.setFullscreen( FALSE ); |
187 | makeVisible(); | 187 | makeVisible(); |
188 | } | 188 | } |
189 | MediaWidget::mouseReleaseEvent( event ); | 189 | MediaWidget::mouseReleaseEvent( event ); |
190 | } | 190 | } |
191 | 191 | ||
192 | void VideoWidget::backToNormal() { | 192 | void VideoWidget::backToNormal() { |
193 | mediaPlayerState.setFullscreen( FALSE ); | 193 | mediaPlayerState.setFullscreen( FALSE ); |
194 | makeVisible(); | 194 | makeVisible(); |
195 | setToggleButton( FullScreen, false ); | 195 | setToggleButton( FullScreen, false ); |
196 | } | 196 | } |
197 | 197 | ||
198 | void VideoWidget::makeVisible() { | 198 | void VideoWidget::makeVisible() { |
199 | if ( mediaPlayerState.isFullscreen() ) { | 199 | if ( mediaPlayerState.isFullscreen() ) { |
200 | showFullScreen(); | 200 | showFullScreen(); |
201 | resize( qApp->desktop()->size() ); | 201 | resize( qApp->desktop()->size() ); |
202 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 202 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
203 | 203 | ||
204 | slider->hide(); | 204 | slider->hide(); |
205 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 205 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
206 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 206 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
207 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 207 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
208 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 208 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
209 | 209 | ||
210 | } else { | 210 | } else { |
211 | showNormal(); | 211 | showNormal(); |
212 | showMaximized(); | 212 | showMaximized(); |
213 | QWidget *d = QApplication::desktop(); | 213 | QWidget *d = QApplication::desktop(); |
214 | int w = d->width(); | 214 | int w = d->width(); |
215 | int h = d->height(); | 215 | int h = d->height(); |
216 | 216 | ||
217 | if(w>h) { | 217 | if(w>h) { |
218 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 218 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
219 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 219 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
220 | } else { | 220 | } else { |
221 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 221 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( !mediaPlayerState.isSeekable() ) { | 224 | if ( !mediaPlayerState.isSeekable() ) { |
225 | if( !slider->isHidden()) { | 225 | if( !slider->isHidden()) { |
226 | slider->hide(); | 226 | slider->hide(); |
227 | } | 227 | } |
228 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 228 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
229 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 229 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
230 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 230 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
231 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 231 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
232 | } else { | 232 | } else { |
233 | slider->show(); | 233 | slider->show(); |
234 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 234 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
235 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 235 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
236 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 236 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
237 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 237 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 242 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
243 | switch ( e->key() ) { | 243 | switch ( e->key() ) { |
244 | ////////////////////////////// Zaurus keys | 244 | ////////////////////////////// Zaurus keys |
245 | case Key_Home: | 245 | case Key_Home: |
246 | break; | 246 | break; |
247 | case Key_F9: //activity | 247 | case Key_F9: //activity |
248 | break; | 248 | break; |
249 | case Key_F10: //contacts | 249 | case Key_F10: //contacts |
250 | // hide(); | 250 | // hide(); |
251 | break; | 251 | break; |
252 | case Key_F11: //menu | 252 | case Key_F11: //menu |
253 | break; | 253 | break; |
254 | case Key_F12: //home | 254 | case Key_F12: //home |
255 | break; | 255 | break; |
256 | case Key_F13: //mail | 256 | case Key_F13: //mail |
257 | break; | 257 | break; |
258 | case Key_Space: { | 258 | case Key_Space: { |
259 | if(mediaPlayerState.isPlaying()) { | 259 | if(mediaPlayerState.isPlaying()) { |
260 | mediaPlayerState.setPlaying(FALSE); | 260 | mediaPlayerState.setPlaying(FALSE); |
261 | } else { | 261 | } else { |
262 | mediaPlayerState.setPlaying(TRUE); | 262 | mediaPlayerState.setPlaying(TRUE); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | break; | 265 | break; |
266 | case Key_Down: | 266 | case Key_Down: |
267 | // toggleButton(6); | 267 | // toggleButton(6); |
268 | emit lessClicked(); | 268 | emit lessClicked(); |
269 | emit lessReleased(); | 269 | emit lessReleased(); |
270 | // toggleButton(6); | 270 | // toggleButton(6); |
271 | break; | 271 | break; |
272 | case Key_Up: | 272 | case Key_Up: |
273 | // toggleButton(5); | 273 | // toggleButton(5); |
274 | emit moreClicked(); | 274 | emit moreClicked(); |
275 | emit moreReleased(); | 275 | emit moreReleased(); |
276 | // toggleButton(5); | 276 | // toggleButton(5); |
277 | break; | 277 | break; |
278 | case Key_Right: | 278 | case Key_Right: |
279 | mediaPlayerState.setNext(); | 279 | mediaPlayerState.setNext(); |
280 | break; | 280 | break; |
281 | case Key_Left: | 281 | case Key_Left: |
282 | mediaPlayerState.setPrev(); | 282 | mediaPlayerState.setPrev(); |
283 | break; | 283 | break; |
284 | case Key_Escape: | 284 | case Key_Escape: |
285 | break; | 285 | break; |
286 | 286 | ||
287 | }; | 287 | }; |
288 | } | 288 | } |
289 | 289 | ||
290 | XineVideoWidget* VideoWidget::vidWidget() { | 290 | XineVideoWidget* VideoWidget::vidWidget() { |
291 | return videoFrame; | 291 | return videoFrame; |
292 | } | 292 | } |
293 | 293 | ||
294 | 294 | ||
295 | void VideoWidget::setFullscreen ( bool b ) { | 295 | void VideoWidget::setFullscreen ( bool b ) { |
296 | setToggleButton( FullScreen, b ); | 296 | setToggleButton( FullScreen, b ); |
297 | } | 297 | } |
298 | 298 | ||
299 | 299 | ||
300 | void VideoWidget::setPlaying( bool b) { | 300 | void VideoWidget::setPlaying( bool b) { |
301 | setToggleButton( Play, b ); | 301 | setToggleButton( Play, b ); |
302 | } | 302 | } |
303 | 303 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index a392f4a..70f2ffd 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,272 +1,272 @@ | |||
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" | 41 | #include "mediaplayerstate.h" |
42 | #include "xinevideowidget.h" | 42 | #include "xinevideowidget.h" |
43 | 43 | ||
44 | XineControl::XineControl( XineVideoWidget *xineWidget, | 44 | XineControl::XineControl( XineVideoWidget *xineWidget, |
45 | MediaPlayerState &_mediaPlayerState, | 45 | MediaPlayerState &_mediaPlayerState, |
46 | QObject *parent, const char *name ) | 46 | QObject *parent, const char *name ) |
47 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 47 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
48 | { | 48 | { |
49 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); | 49 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); |
50 | 50 | ||
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 54 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
55 | MediaPlayerState &_mediaPlayerState, | 55 | MediaPlayerState &_mediaPlayerState, |
56 | QObject *parent, const char *name ) | 56 | QObject *parent, const char *name ) |
57 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 57 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
58 | { | 58 | { |
59 | xine->ensureInitialized(); | 59 | xine->ensureInitialized(); |
60 | 60 | ||
61 | xine->setWidget( xineWidget ); | 61 | xine->setWidget( xineWidget ); |
62 | 62 | ||
63 | init(); | 63 | init(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void XineControl::init() | 66 | void XineControl::init() |
67 | { | 67 | { |
68 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); | 68 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
69 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); | 69 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); |
70 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 70 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); |
71 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 71 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); |
72 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 72 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); |
73 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 73 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); |
74 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 74 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
75 | connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); | 75 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); |
76 | 76 | ||
77 | disabledSuspendScreenSaver = FALSE; | 77 | disabledSuspendScreenSaver = FALSE; |
78 | } | 78 | } |
79 | 79 | ||
80 | XineControl::~XineControl() { | 80 | XineControl::~XineControl() { |
81 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 81 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
82 | if ( disabledSuspendScreenSaver ) { | 82 | if ( disabledSuspendScreenSaver ) { |
83 | disabledSuspendScreenSaver = FALSE; | 83 | disabledSuspendScreenSaver = FALSE; |
84 | // Re-enable the suspend mode | 84 | // Re-enable the suspend mode |
85 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 85 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
86 | } | 86 | } |
87 | #endif | 87 | #endif |
88 | delete libXine; | 88 | delete libXine; |
89 | } | 89 | } |
90 | 90 | ||
91 | void XineControl::play( const QString& fileName ) { | 91 | void XineControl::play( const QString& fileName ) { |
92 | 92 | ||
93 | hasVideoChannel = FALSE; | 93 | hasVideoChannel = FALSE; |
94 | hasAudioChannel = FALSE; | 94 | hasAudioChannel = FALSE; |
95 | m_fileName = fileName; | 95 | m_fileName = fileName; |
96 | 96 | ||
97 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 97 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
98 | 98 | ||
99 | if ( !libXine->play( fileName, 0, 0 ) ) { | 99 | if ( !libXine->play( fileName, 0, 0 ) ) { |
100 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 100 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
101 | // toggle stop so the the play button is reset | 101 | // toggle stop so the the play button is reset |
102 | mediaPlayerState.setPlaying( false ); | 102 | mediaPlayerState.setPlaying( false ); |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | mediaPlayerState.setPlaying( true ); | 105 | mediaPlayerState.setPlaying( true ); |
106 | 106 | ||
107 | MediaPlayerState::DisplayType displayType; | 107 | MediaPlayerState::DisplayType displayType; |
108 | if ( !libXine->hasVideo() ) { | 108 | if ( !libXine->hasVideo() ) { |
109 | displayType = MediaPlayerState::Audio; | 109 | displayType = MediaPlayerState::Audio; |
110 | qDebug("HAS AUDIO"); | 110 | qDebug("HAS AUDIO"); |
111 | libXine->setShowVideo( false ); | 111 | libXine->setShowVideo( false ); |
112 | hasAudioChannel = TRUE; | 112 | hasAudioChannel = TRUE; |
113 | } else { | 113 | } else { |
114 | displayType = MediaPlayerState::Video; | 114 | displayType = MediaPlayerState::Video; |
115 | qDebug("HAS VIDEO"); | 115 | qDebug("HAS VIDEO"); |
116 | libXine->setShowVideo( true ); | 116 | libXine->setShowVideo( true ); |
117 | hasVideoChannel = TRUE; | 117 | hasVideoChannel = TRUE; |
118 | } | 118 | } |
119 | // determine if slider is shown | 119 | // determine if slider is shown |
120 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 120 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
121 | 121 | ||
122 | // which gui (video / audio) | 122 | // which gui (video / audio) |
123 | mediaPlayerState.setDisplayType( displayType ); | 123 | mediaPlayerState.setDisplayType( displayType ); |
124 | 124 | ||
125 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 125 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
126 | if ( !disabledSuspendScreenSaver ) { | 126 | if ( !disabledSuspendScreenSaver ) { |
127 | disabledSuspendScreenSaver = TRUE; | 127 | disabledSuspendScreenSaver = TRUE; |
128 | // Stop the screen from blanking and power saving state | 128 | // Stop the screen from blanking and power saving state |
129 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 129 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
130 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 130 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
131 | } | 131 | } |
132 | #endif | 132 | #endif |
133 | 133 | ||
134 | length(); | 134 | length(); |
135 | position(); | 135 | position(); |
136 | } | 136 | } |
137 | 137 | ||
138 | void XineControl::nextMedia() { | 138 | void XineControl::nextMedia() { |
139 | mediaPlayerState.setNext(); | 139 | mediaPlayerState.setNext(); |
140 | } | 140 | } |
141 | 141 | ||
142 | void XineControl::setGamma( int value ) { | 142 | void XineControl::setGamma( int value ) { |
143 | libXine->setGamma( value ); | 143 | libXine->setGamma( value ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void XineControl::stop( bool isSet ) { | 146 | void XineControl::stop( bool isSet ) { |
147 | if ( !isSet ) { | 147 | if ( !isSet ) { |
148 | libXine->stop(); | 148 | libXine->stop(); |
149 | 149 | ||
150 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 150 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
151 | if ( disabledSuspendScreenSaver ) { | 151 | if ( disabledSuspendScreenSaver ) { |
152 | disabledSuspendScreenSaver = FALSE; | 152 | disabledSuspendScreenSaver = FALSE; |
153 | // Re-enable the suspend mode | 153 | // Re-enable the suspend mode |
154 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 154 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
155 | } | 155 | } |
156 | #endif | 156 | #endif |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * Pause playback | 161 | * Pause playback |
162 | * @isSet | 162 | * @isSet |
163 | */ | 163 | */ |
164 | void XineControl::pause( bool isSet) { | 164 | void XineControl::pause( bool isSet) { |
165 | libXine->pause( isSet ); | 165 | libXine->pause( isSet ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | /** | 169 | /** |
170 | * get current time in playback | 170 | * get current time in playback |
171 | */ | 171 | */ |
172 | long XineControl::currentTime() { | 172 | long XineControl::currentTime() { |
173 | // todo: jede sekunde überprüfen | 173 | // todo: jede sekunde überprüfen |
174 | m_currentTime = libXine->currentTime(); | 174 | m_currentTime = libXine->currentTime(); |
175 | return m_currentTime; | 175 | return m_currentTime; |
176 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 176 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
177 | } | 177 | } |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * Set the length of the media file | 180 | * Set the length of the media file |
181 | */ | 181 | */ |
182 | void XineControl::length() { | 182 | void XineControl::length() { |
183 | m_length = libXine->length(); | 183 | m_length = libXine->length(); |
184 | mediaPlayerState.setLength( m_length ); | 184 | mediaPlayerState.setLength( m_length ); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | /** | 188 | /** |
189 | * Reports the position the xine backend is at right now | 189 | * Reports the position the xine backend is at right now |
190 | * @return long the postion in seconds | 190 | * @return long the postion in seconds |
191 | */ | 191 | */ |
192 | long XineControl::position() { | 192 | long XineControl::position() { |
193 | m_position = ( currentTime() ); | 193 | m_position = ( currentTime() ); |
194 | mediaPlayerState.updatePosition( m_position ); | 194 | mediaPlayerState.updatePosition( m_position ); |
195 | long emitPos = (long)m_position; | 195 | long emitPos = (long)m_position; |
196 | emit positionChanged( emitPos ); | 196 | emit positionChanged( emitPos ); |
197 | if( mediaPlayerState.isPlaying() ) { | 197 | if( mediaPlayerState.isPlaying() ) { |
198 | // needs to be stopped the media is stopped | 198 | // needs to be stopped the media is stopped |
199 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 199 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
200 | } | 200 | } |
201 | return m_position; | 201 | return m_position; |
202 | } | 202 | } |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * Set videoplayback to fullscreen | 205 | * Set videoplayback to fullscreen |
206 | * @param isSet | 206 | * @param isSet |
207 | */ | 207 | */ |
208 | void XineControl::setFullscreen( bool isSet ) { | 208 | void XineControl::setFullscreen( bool isSet ) { |
209 | libXine->showVideoFullScreen( isSet ); | 209 | libXine->showVideoFullScreen( isSet ); |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | QString XineControl::getMetaInfo() { | 213 | QString XineControl::getMetaInfo() { |
214 | 214 | ||
215 | QString returnString; | 215 | QString returnString; |
216 | 216 | ||
217 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 217 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
218 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 218 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
219 | } | 219 | } |
220 | 220 | ||
221 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 221 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
222 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 222 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
223 | } | 223 | } |
224 | 224 | ||
225 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 225 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
226 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 226 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
227 | } | 227 | } |
228 | 228 | ||
229 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 229 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
230 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 230 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 233 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
234 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 234 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
235 | } | 235 | } |
236 | 236 | ||
237 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 237 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
238 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 238 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
239 | } | 239 | } |
240 | return returnString; | 240 | return returnString; |
241 | } | 241 | } |
242 | 242 | ||
243 | QString XineControl::getErrorCode() { | 243 | QString XineControl::getErrorCode() { |
244 | 244 | ||
245 | int errorCode = libXine->error(); | 245 | int errorCode = libXine->error(); |
246 | 246 | ||
247 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); | 247 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); |
248 | 248 | ||
249 | if ( errorCode == 1 ) { | 249 | if ( errorCode == 1 ) { |
250 | return tr( "No input plugin found for this media type" ); | 250 | return tr( "No input plugin found for this media type" ); |
251 | } else if ( errorCode == 2 ) { | 251 | } else if ( errorCode == 2 ) { |
252 | return tr( "No demux plugin found for this media type" ); | 252 | return tr( "No demux plugin found for this media type" ); |
253 | } else if ( errorCode == 3 ) { | 253 | } else if ( errorCode == 3 ) { |
254 | return tr( "Demuxing failed for this media type" ); | 254 | return tr( "Demuxing failed for this media type" ); |
255 | } else if ( errorCode == 4 ) { | 255 | } else if ( errorCode == 4 ) { |
256 | return tr( "Malformed MRL" ); | 256 | return tr( "Malformed MRL" ); |
257 | } else { | 257 | } else { |
258 | return tr( "Some other error" ); | 258 | return tr( "Some other error" ); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | /** | 262 | /** |
263 | * Seek to a position in the track | 263 | * Seek to a position in the track |
264 | * @param second the second to jump to | 264 | * @param second the second to jump to |
265 | */ | 265 | */ |
266 | void XineControl::seekTo( long second ) { | 266 | void XineControl::seekTo( long second ) { |
267 | libXine->seekTo( (int)second ); | 267 | libXine->seekTo( (int)second ); |
268 | } | 268 | } |
269 | 269 | ||
270 | void XineControl::videoResized ( const QSize &s ) { | 270 | void XineControl::videoResized ( const QSize &s ) { |
271 | libXine->resize( s ); | 271 | libXine->resize( s ); |
272 | } | 272 | } |
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 0a6e5ae..f2035ef 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -380,802 +380,802 @@ void playIt() | |||
380 | break; | 380 | break; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); | 383 | printf("\nplaying number %d, bytes %d, total %d\r",number, bytesWritten, total); |
384 | fflush(stdout); | 384 | fflush(stdout); |
385 | } //end loop | 385 | } //end loop |
386 | } else { | 386 | } else { |
387 | /////////////////////////////// format = AFMT_U8; | 387 | /////////////////////////////// format = AFMT_U8; |
388 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; | 388 | unsigned char unsigned_inbuffer[ BUFSIZE ]; //, unsigned_outbuffer[BUFSIZE]; |
389 | memset( unsigned_inbuffer, 0, BUFSIZE); | 389 | memset( unsigned_inbuffer, 0, BUFSIZE); |
390 | for(;;) { | 390 | for(;;) { |
391 | // main loop | 391 | // main loop |
392 | if (stopped) { | 392 | if (stopped) { |
393 | break; // stop if playing was set to false | 393 | break; // stop if playing was set to false |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); | 396 | number = ::read( filePara.fd, unsigned_inbuffer, BUFSIZE); |
397 | //data = (val >> 8) ^ 0x80; | 397 | //data = (val >> 8) ^ 0x80; |
398 | // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; | 398 | // unsigned_outbuffer = (unsigned_inbuffer >> 8) ^ 0x80; |
399 | bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); | 399 | bytesWritten = write ( filePara.sd, unsigned_inbuffer, number); |
400 | waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); | 400 | waveform->newSamples( (const short *)unsigned_inbuffer, bytesWritten ); |
401 | total += bytesWritten; | 401 | total += bytesWritten; |
402 | 402 | ||
403 | timeSlider->setValue( total); | 403 | timeSlider->setValue( total); |
404 | filePara.numberSamples = total; | 404 | filePara.numberSamples = total; |
405 | 405 | ||
406 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; | 406 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate; |
407 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); | 407 | // timeString.sprintf("%.2f",filePara.numberOfRecordedSeconds); |
408 | // timeLabel->setText( timeString + tr(" seconds")); | 408 | // timeLabel->setText( timeString + tr(" seconds")); |
409 | qApp->processEvents(); | 409 | qApp->processEvents(); |
410 | 410 | ||
411 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { | 411 | if( /*total >= filePara.numberSamples || */ bytesWritten == 0) { |
412 | // if( total >= filePara.numberSamples ) { | 412 | // if( total >= filePara.numberSamples ) { |
413 | stopped = true; | 413 | stopped = true; |
414 | break; | 414 | break; |
415 | } | 415 | } |
416 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); | 416 | // printf("Writing number %d, bytes %d, total %d, numberSamples %d\r",number, bytesWritten , total, filePara.numberSamples); |
417 | // fflush(stdout); | 417 | // fflush(stdout); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
423 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | 423 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) |
424 | : QWidget( parent, name, fl ) | 424 | : QWidget( parent, name, fl ) |
425 | { | 425 | { |
426 | if ( !name ) | 426 | if ( !name ) |
427 | setName( "OpieRec" ); | 427 | setName( "OpieRec" ); |
428 | init(); | 428 | init(); |
429 | initConfig(); | 429 | initConfig(); |
430 | initConnections(); | 430 | initConnections(); |
431 | renameBox = 0; | 431 | renameBox = 0; |
432 | 432 | ||
433 | // open sound device to get volumes | 433 | // open sound device to get volumes |
434 | Config hwcfg("OpieRec"); | 434 | Config hwcfg("OpieRec"); |
435 | hwcfg.setGroup("Hardware"); | 435 | hwcfg.setGroup("Hardware"); |
436 | 436 | ||
437 | 437 | ||
438 | soundDevice = new Device( this, | 438 | soundDevice = new Device( this, |
439 | hwcfg.readEntry( "Audio",DSPSTROUT), | 439 | hwcfg.readEntry( "Audio",DSPSTROUT), |
440 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); | 440 | hwcfg.readEntry( "Mixer",DSPSTRMIXEROUT), false); |
441 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); | 441 | // soundDevice = new Device( this, hwcfg.readEntry( "Audio","hw:0"), hwcfg.readEntry( "Mixer","hw:0"), false); |
442 | 442 | ||
443 | // soundDevice->setDeviceFormat(AFMT_S16_LE); | 443 | // soundDevice->setDeviceFormat(AFMT_S16_LE); |
444 | // soundDevice->setDeviceChannels(1); | 444 | // soundDevice->setDeviceChannels(1); |
445 | // soundDevice->setDeviceRate( 22050); | 445 | // soundDevice->setDeviceRate( 22050); |
446 | 446 | ||
447 | getInVol(); | 447 | getInVol(); |
448 | getOutVol(); | 448 | getOutVol(); |
449 | 449 | ||
450 | soundDevice->closeDevice( true); | 450 | soundDevice->closeDevice( true); |
451 | soundDevice->sd = -1; | 451 | soundDevice->sd = -1; |
452 | soundDevice = 0; | 452 | soundDevice = 0; |
453 | wavFile = 0; | 453 | wavFile = 0; |
454 | 454 | ||
455 | if( soundDevice) delete soundDevice; | 455 | if( soundDevice) delete soundDevice; |
456 | 456 | ||
457 | initIconView(); | 457 | initIconView(); |
458 | 458 | ||
459 | if( autoMute) | 459 | if( autoMute) |
460 | doMute( true); | 460 | doMute( true); |
461 | ListView1->setFocus(); | 461 | ListView1->setFocus(); |
462 | playing = false; | 462 | playing = false; |
463 | } | 463 | } |
464 | 464 | ||
465 | QtRec::~QtRec() { | 465 | QtRec::~QtRec() { |
466 | 466 | ||
467 | } | 467 | } |
468 | 468 | ||
469 | void QtRec::cleanUp() { | 469 | void QtRec::cleanUp() { |
470 | 470 | ||
471 | if( !stopped) { | 471 | if( !stopped) { |
472 | stopped = true; | 472 | stopped = true; |
473 | endRecording(); | 473 | endRecording(); |
474 | } | 474 | } |
475 | 475 | ||
476 | ListView1->clear(); | 476 | ListView1->clear(); |
477 | 477 | ||
478 | if( autoMute) | 478 | if( autoMute) |
479 | doMute(false); | 479 | doMute(false); |
480 | 480 | ||
481 | if( wavFile) delete wavFile; | 481 | if( wavFile) delete wavFile; |
482 | // if(soundDevice) delete soundDevice; | 482 | // if(soundDevice) delete soundDevice; |
483 | } | 483 | } |
484 | 484 | ||
485 | void QtRec::init() { | 485 | void QtRec::init() { |
486 | 486 | ||
487 | needsStereoOut = false; | 487 | needsStereoOut = false; |
488 | QPixmap image3( ( const char** ) image3_data ); | 488 | QPixmap image3( ( const char** ) image3_data ); |
489 | QPixmap image4( ( const char** ) image4_data ); | 489 | QPixmap image4( ( const char** ) image4_data ); |
490 | QPixmap image6( ( const char** ) image6_data ); | 490 | QPixmap image6( ( const char** ) image6_data ); |
491 | 491 | ||
492 | stopped = true; | 492 | stopped = true; |
493 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 493 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
494 | QGridLayout *layout = new QGridLayout( this ); | 494 | QGridLayout *layout = new QGridLayout( this ); |
495 | layout->setSpacing( 2); | 495 | layout->setSpacing( 2); |
496 | layout->setMargin( 2); | 496 | layout->setMargin( 2); |
497 | 497 | ||
498 | TabWidget = new QTabWidget( this, "TabWidget" ); | 498 | TabWidget = new QTabWidget( this, "TabWidget" ); |
499 | layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); | 499 | layout->addMultiCellWidget(TabWidget, 0, 7, 0, 7); |
500 | // TabWidget->setTabShape(QTabWidget::Triangular); | 500 | // TabWidget->setTabShape(QTabWidget::Triangular); |
501 | 501 | ||
502 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 502 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
503 | tab = new QWidget( TabWidget, "tab" ); | 503 | tab = new QWidget( TabWidget, "tab" ); |
504 | 504 | ||
505 | QGridLayout *layout1 = new QGridLayout( tab); | 505 | QGridLayout *layout1 = new QGridLayout( tab); |
506 | layout1->setSpacing( 2); | 506 | layout1->setSpacing( 2); |
507 | layout1->setMargin( 2); | 507 | layout1->setMargin( 2); |
508 | 508 | ||
509 | timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); | 509 | timeSlider = new QSlider( 0,100,10,0, QSlider::Horizontal, tab, (const char *) "timeSlider" ); |
510 | layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); | 510 | layout1->addMultiCellWidget( timeSlider, 1, 1, 0, 3); |
511 | 511 | ||
512 | timeLabel = new QLabel( tab, "TimeLabel" ); | 512 | timeLabel = new QLabel( tab, "TimeLabel" ); |
513 | layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); | 513 | layout1->addMultiCellWidget( timeLabel, 0, 0, 0, 3); |
514 | 514 | ||
515 | playLabel2 = new QLabel(tab, "PlayLabel2" ); | 515 | playLabel2 = new QLabel(tab, "PlayLabel2" ); |
516 | playLabel2->setText(tr("Play") ); | 516 | playLabel2->setText(tr("Play") ); |
517 | playLabel2->setFixedHeight( 18); | 517 | playLabel2->setFixedHeight( 18); |
518 | layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); | 518 | layout1->addMultiCellWidget( playLabel2, 0, 0, 4, 4); |
519 | 519 | ||
520 | Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); | 520 | Stop_PushButton = new QPushButton( tab, "Stop_PushButton" ); |
521 | layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); | 521 | layout1->addMultiCellWidget( Stop_PushButton, 1, 1, 4, 4); |
522 | Stop_PushButton->setFixedSize( 22, 22); | 522 | Stop_PushButton->setFixedSize( 22, 22); |
523 | Stop_PushButton->setPixmap( image4 ); | 523 | Stop_PushButton->setPixmap( image4 ); |
524 | 524 | ||
525 | toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); | 525 | toBeginningButton = new QPushButton( tab, "Beginning_PushButton" ); |
526 | layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); | 526 | layout1->addMultiCellWidget(toBeginningButton, 1, 1, 5, 5); |
527 | toBeginningButton->setFixedSize( 22, 22); | 527 | toBeginningButton->setFixedSize( 22, 22); |
528 | toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); | 528 | toBeginningButton->setPixmap( Resource::loadPixmap("fastback") ); |
529 | 529 | ||
530 | toEndButton = new QPushButton( tab, "End_PushButton" ); | 530 | toEndButton = new QPushButton( tab, "End_PushButton" ); |
531 | layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); | 531 | layout1->addMultiCellWidget( toEndButton, 1, 1, 6, 6); |
532 | toEndButton->setFixedSize( 22, 22); | 532 | toEndButton->setFixedSize( 22, 22); |
533 | toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); | 533 | toEndButton->setPixmap( Resource::loadPixmap( "fastforward" ) ); |
534 | 534 | ||
535 | QLabel *recLabel2; | 535 | QLabel *recLabel2; |
536 | recLabel2 = new QLabel( tab, "recLabel2" ); | 536 | recLabel2 = new QLabel( tab, "recLabel2" ); |
537 | recLabel2->setText(tr("Rec")); | 537 | recLabel2->setText(tr("Rec")); |
538 | recLabel2->setFixedHeight( 18); | 538 | recLabel2->setFixedHeight( 18); |
539 | layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); | 539 | layout1->addMultiCellWidget( recLabel2, 0, 0, 7, 7); |
540 | 540 | ||
541 | Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); | 541 | Rec_PushButton = new QPushButton( tab, "Rec_PushButton" ); |
542 | layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); | 542 | layout1->addMultiCellWidget( Rec_PushButton, 1, 1, 7, 7); |
543 | Rec_PushButton->setFixedSize( 22, 22); | 543 | Rec_PushButton->setFixedSize( 22, 22); |
544 | Rec_PushButton->setPixmap( image6 ); | 544 | Rec_PushButton->setPixmap( image6 ); |
545 | 545 | ||
546 | t = new QTimer( this ); | 546 | t = new QTimer( this ); |
547 | connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); | 547 | connect( t, SIGNAL( timeout() ), SLOT( timerBreak() ) ); |
548 | 548 | ||
549 | rewindTimer = new QTimer( this ); | 549 | rewindTimer = new QTimer( this ); |
550 | connect( rewindTimer, SIGNAL( timeout() ), | 550 | connect( rewindTimer, SIGNAL( timeout() ), |
551 | this, SLOT( rewindTimerTimeout() ) ); | 551 | this, SLOT( rewindTimerTimeout() ) ); |
552 | 552 | ||
553 | forwardTimer = new QTimer( this ); | 553 | forwardTimer = new QTimer( this ); |
554 | connect( forwardTimer, SIGNAL( timeout() ), | 554 | connect( forwardTimer, SIGNAL( timeout() ), |
555 | this, SLOT( forwardTimerTimeout() ) ); | 555 | this, SLOT( forwardTimerTimeout() ) ); |
556 | 556 | ||
557 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); | 557 | deleteSoundButton = new QPushButton( tab, "deleteSoundButton" ); |
558 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); | 558 | layout1->addMultiCellWidget( deleteSoundButton, 1, 1, 8, 8); |
559 | deleteSoundButton->setText( tr( "Delete" ) ); | 559 | deleteSoundButton->setText( tr( "Delete" ) ); |
560 | 560 | ||
561 | ListView1 = new QListView( tab, "IconView1" ); | 561 | ListView1 = new QListView( tab, "IconView1" ); |
562 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); | 562 | layout1->addMultiCellWidget( ListView1, 2, 2, 0, 8); |
563 | 563 | ||
564 | ListView1->addColumn( tr( "Name" ) ); | 564 | ListView1->addColumn( tr( "Name" ) ); |
565 | ListView1->setColumnWidth( 0, 140); | 565 | ListView1->setColumnWidth( 0, 140); |
566 | ListView1->setSorting( 1, false); | 566 | ListView1->setSorting( 1, false); |
567 | ListView1->addColumn( tr( "Time" ) ); //in seconds | 567 | ListView1->addColumn( tr( "Time" ) ); //in seconds |
568 | ListView1->setColumnWidth( 1, 50); | 568 | ListView1->setColumnWidth( 1, 50); |
569 | ListView1->addColumn( tr("Location") ); | 569 | ListView1->addColumn( tr("Location") ); |
570 | ListView1->setColumnWidth( 2, 50); | 570 | ListView1->setColumnWidth( 2, 50); |
571 | ListView1->addColumn( tr("Date") ); | 571 | ListView1->addColumn( tr("Date") ); |
572 | ListView1->setColumnWidth( 3, 63); | 572 | ListView1->setColumnWidth( 3, 63); |
573 | 573 | ||
574 | ListView1->setColumnWidthMode( 0, QListView::Manual); | 574 | ListView1->setColumnWidthMode( 0, QListView::Manual); |
575 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); | 575 | ListView1->setColumnAlignment( 1, QListView::AlignCenter); |
576 | ListView1->setColumnAlignment( 2, QListView::AlignRight); | 576 | ListView1->setColumnAlignment( 2, QListView::AlignRight); |
577 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); | 577 | ListView1->setColumnAlignment( 3, QListView::AlignLeft); |
578 | ListView1->setAllColumnsShowFocus( true ); | 578 | ListView1->setAllColumnsShowFocus( true ); |
579 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); | 579 | QPEApplication::setStylusOperation( ListView1->viewport(), QPEApplication::RightOnHold); |
580 | 580 | ||
581 | TabWidget->insertTab( tab, tr( "Files" ) ); | 581 | TabWidget->insertTab( tab, tr( "Files" ) ); |
582 | 582 | ||
583 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** | 583 | ///**********<<<<<<<<<<<<>>>>>>>>>>>>*************** |
584 | tab_3 = new QWidget( TabWidget, "tab_3" ); | 584 | tab_3 = new QWidget( TabWidget, "tab_3" ); |
585 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); | 585 | QGridLayout *glayout3 = new QGridLayout( tab_3 ); |
586 | glayout3->setSpacing( 2); | 586 | glayout3->setSpacing( 2); |
587 | glayout3->setMargin( 2); | 587 | glayout3->setMargin( 2); |
588 | //////////////////////////////////// | 588 | //////////////////////////////////// |
589 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); | 589 | sampleGroup = new QGroupBox( tab_3, "samplegroup" ); |
590 | sampleGroup->setTitle( tr( "Sample Rate" ) ); | 590 | sampleGroup->setTitle( tr( "Sample Rate" ) ); |
591 | sampleGroup->setFixedSize( 95,50); | 591 | sampleGroup->setFixedSize( 95,50); |
592 | 592 | ||
593 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); | 593 | sampleRateComboBox = new QComboBox( false, sampleGroup, "SampleRateComboBox" ); |
594 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); | 594 | sampleRateComboBox->setGeometry( QRect( 10, 20, 80, 25 ) ); |
595 | //#ifndef QT_QWS_EBX | 595 | //#ifndef QT_QWS_EBX |
596 | QString s; | 596 | QString s; |
597 | int z = 0; | 597 | int z = 0; |
598 | while( deviceSampleRates[z] != -1) { | 598 | while( deviceSampleRates[z] != -1) { |
599 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); | 599 | sampleRateComboBox->insertItem( s.setNum( deviceSampleRates[z], 10)); |
600 | z++; | 600 | z++; |
601 | } | 601 | } |
602 | 602 | ||
603 | 603 | ||
604 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); | 604 | glayout3->addMultiCellWidget( sampleGroup, 0, 0, 0, 0); |
605 | 605 | ||
606 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); | 606 | sizeGroup= new QGroupBox( tab_3, "sizeGroup" ); |
607 | sizeGroup->setTitle( tr( "Limit Size" ) ); | 607 | sizeGroup->setTitle( tr( "Limit Size" ) ); |
608 | sizeGroup->setFixedSize( 80, 50); | 608 | sizeGroup->setFixedSize( 80, 50); |
609 | 609 | ||
610 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); | 610 | sizeLimitCombo = new QComboBox( false, sizeGroup, "sizeLimitCombo" ); |
611 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); | 611 | sizeLimitCombo ->setGeometry( QRect( 5, 20, 70, 25 ) ); |
612 | sizeLimitCombo->insertItem(tr("Unlimited")); | 612 | sizeLimitCombo->insertItem(tr("Unlimited")); |
613 | 613 | ||
614 | for(int i=1;i<13; i++) { | 614 | for(int i=1;i<13; i++) { |
615 | sizeLimitCombo->insertItem( QString::number( i * 5)); | 615 | sizeLimitCombo->insertItem( QString::number( i * 5)); |
616 | } | 616 | } |
617 | 617 | ||
618 | 618 | ||
619 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); | 619 | glayout3->addMultiCellWidget( sizeGroup, 0, 0, 1, 1); |
620 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); | 620 | dirGroup = new QGroupBox( tab_3, "dirGroup" ); |
621 | dirGroup->setTitle( tr( "File Directory" ) ); | 621 | dirGroup->setTitle( tr( "File Directory" ) ); |
622 | dirGroup->setFixedSize( 130, 50); | 622 | dirGroup->setFixedSize( 130, 50); |
623 | 623 | ||
624 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); | 624 | directoryComboBox = new QComboBox( false, dirGroup, "dirGroup" ); |
625 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); | 625 | directoryComboBox->setGeometry( QRect( 10, 15, 115, 25 ) ); |
626 | 626 | ||
627 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); | 627 | glayout3->addMultiCellWidget( dirGroup, 1, 1, 0, 0); |
628 | 628 | ||
629 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); | 629 | bitGroup = new QGroupBox( tab_3, "bitGroup" ); |
630 | bitGroup->setTitle( tr( "Bit Depth" ) ); | 630 | bitGroup->setTitle( tr( "Bit Depth" ) ); |
631 | bitGroup->setFixedSize( 65, 50); | 631 | bitGroup->setFixedSize( 65, 50); |
632 | 632 | ||
633 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); | 633 | bitRateComboBox = new QComboBox( false, bitGroup, "BitRateComboBox" ); |
634 | 634 | ||
635 | z = 0; | 635 | z = 0; |
636 | while( deviceBitRates[z] != -1) { | 636 | while( deviceBitRates[z] != -1) { |
637 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); | 637 | bitRateComboBox->insertItem( s.setNum( deviceBitRates[z], 10) ); |
638 | z++; | 638 | z++; |
639 | } | 639 | } |
640 | 640 | ||
641 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); | 641 | bitRateComboBox->setGeometry( QRect( 5, 20, 50, 25 ) ); |
642 | 642 | ||
643 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); | 643 | glayout3->addMultiCellWidget( bitGroup, 1, 1, 1, 1); |
644 | 644 | ||
645 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); | 645 | compressionCheckBox = new QCheckBox ( tr("Wave Compression (smaller files)"), tab_3 ); |
646 | 646 | ||
647 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); | 647 | autoMuteCheckBox = new QCheckBox ( tr("Auto Mute"), tab_3 ); |
648 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); | 648 | stereoCheckBox = new QCheckBox ( tr("Stereo Channels"), tab_3 ); |
649 | 649 | ||
650 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); | 650 | glayout3->addMultiCellWidget( compressionCheckBox, 2, 2, 0, 3); |
651 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); | 651 | glayout3->addMultiCellWidget( autoMuteCheckBox, 3, 3, 0, 0); |
652 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); | 652 | glayout3->addMultiCellWidget( stereoCheckBox, 3, 3, 1, 1); |
653 | 653 | ||
654 | tab_5 = new QWidget( TabWidget, "tab_5" ); | 654 | tab_5 = new QWidget( TabWidget, "tab_5" ); |
655 | 655 | ||
656 | QHBoxLayout *Layout19a; | 656 | QHBoxLayout *Layout19a; |
657 | Layout19a = new QHBoxLayout( tab_5); | 657 | Layout19a = new QHBoxLayout( tab_5); |
658 | Layout19a->setSpacing( 2 ); | 658 | Layout19a->setSpacing( 2 ); |
659 | Layout19a->setMargin( 0 ); | 659 | Layout19a->setMargin( 0 ); |
660 | 660 | ||
661 | Layout15 = new QVBoxLayout( this); | 661 | Layout15 = new QVBoxLayout( this); |
662 | Layout15->setSpacing( 2 ); | 662 | Layout15->setSpacing( 2 ); |
663 | Layout15->setMargin( 0 ); | 663 | Layout15->setMargin( 0 ); |
664 | 664 | ||
665 | Layout15b = new QVBoxLayout( this); | 665 | Layout15b = new QVBoxLayout( this); |
666 | Layout15b->setSpacing( 2 ); | 666 | Layout15b->setSpacing( 2 ); |
667 | Layout15b->setMargin( 0 ); | 667 | Layout15b->setMargin( 0 ); |
668 | 668 | ||
669 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); | 669 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); |
670 | TextLabel2->setText( tr( "In")); | 670 | TextLabel2->setText( tr( "In")); |
671 | TextLabel2->setFixedWidth( 35); | 671 | TextLabel2->setFixedWidth( 35); |
672 | Layout15->addWidget( TextLabel2 ); | 672 | Layout15->addWidget( TextLabel2 ); |
673 | 673 | ||
674 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); | 674 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); |
675 | TextLabel3->setText( tr( "Out" ) ); | 675 | TextLabel3->setText( tr( "Out" ) ); |
676 | Layout15b->addWidget( TextLabel3 ); | 676 | Layout15b->addWidget( TextLabel3 ); |
677 | 677 | ||
678 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); | 678 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); |
679 | InputSlider->setTickmarks( QSlider::Both); | 679 | InputSlider->setTickmarks( QSlider::Both); |
680 | Layout15->addWidget( InputSlider); | 680 | Layout15->addWidget( InputSlider); |
681 | 681 | ||
682 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); | 682 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); |
683 | OutputSlider->setTickmarks( QSlider::Both); | 683 | OutputSlider->setTickmarks( QSlider::Both); |
684 | 684 | ||
685 | Layout15b->addWidget( OutputSlider ); | 685 | Layout15b->addWidget( OutputSlider ); |
686 | 686 | ||
687 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 687 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
688 | Layout15->addWidget( outMuteCheckBox ); | 688 | Layout15->addWidget( outMuteCheckBox ); |
689 | 689 | ||
690 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 690 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
691 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | 691 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); |
692 | Layout15b->addWidget( inMuteCheckBox ); | 692 | Layout15b->addWidget( inMuteCheckBox ); |
693 | 693 | ||
694 | 694 | ||
695 | Layout19a->addLayout( Layout15 ); | 695 | Layout19a->addLayout( Layout15 ); |
696 | Layout19a->addLayout( Layout15b ); | 696 | Layout19a->addLayout( Layout15b ); |
697 | 697 | ||
698 | fillDirectoryCombo(); | 698 | fillDirectoryCombo(); |
699 | 699 | ||
700 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | 700 | TabWidget->insertTab( tab_3, tr( "Options" ) ); |
701 | 701 | ||
702 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 702 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
703 | 703 | ||
704 | 704 | ||
705 | waveform = new Waveform( this, "waveform" ); | 705 | waveform = new Waveform( this, "waveform" ); |
706 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); | 706 | // waveform->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)3, waveform->sizePolicy().hasHeightForWidth() ) ); |
707 | waveform->setMinimumSize( QSize( 0, 50 ) ); | 707 | waveform->setMinimumSize( QSize( 0, 50 ) ); |
708 | 708 | ||
709 | layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); | 709 | layout->addMultiCellWidget( waveform, 8, 8, 0, 7 ); |
710 | waveform->setBackgroundColor ( black ); | 710 | waveform->setBackgroundColor ( black ); |
711 | } | 711 | } |
712 | 712 | ||
713 | void QtRec::initIconView() { | 713 | void QtRec::initIconView() { |
714 | 714 | ||
715 | ListView1->clear(); | 715 | ListView1->clear(); |
716 | Config cfg("OpieRec"); | 716 | Config cfg("OpieRec"); |
717 | cfg.setGroup("Sounds"); | 717 | cfg.setGroup("Sounds"); |
718 | QString temp; | 718 | QString temp; |
719 | QPixmap image0( ( const char** ) image0_data ); | 719 | QPixmap image0( ( const char** ) image0_data ); |
720 | 720 | ||
721 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 721 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
722 | // qDebug("init number of files %d", nFiles); | 722 | // qDebug("init number of files %d", nFiles); |
723 | 723 | ||
724 | for(int i=1;i<= nFiles;i++) { | 724 | for(int i=1;i<= nFiles;i++) { |
725 | 725 | ||
726 | QListViewItem * item; | 726 | QListViewItem * item; |
727 | QString fileS, mediaLocation, fileDate, filePath; | 727 | QString fileS, mediaLocation, fileDate, filePath; |
728 | 728 | ||
729 | temp.sprintf( "%d",i); | 729 | temp.sprintf( "%d",i); |
730 | temp = cfg.readEntry( temp,""); //reads currentFile | 730 | temp = cfg.readEntry( temp,""); //reads currentFile |
731 | filePath = cfg.readEntry( temp,""); //currentFileName | 731 | filePath = cfg.readEntry( temp,""); //currentFileName |
732 | 732 | ||
733 | QFileInfo info(filePath); | 733 | QFileInfo info(filePath); |
734 | fileDate = info.lastModified().toString(); | 734 | fileDate = info.lastModified().toString(); |
735 | 735 | ||
736 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds | 736 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds |
737 | mediaLocation = getStorage( filePath); | 737 | mediaLocation = getStorage( filePath); |
738 | if( info.exists()) { | 738 | if( info.exists()) { |
739 | item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); | 739 | item = new QListViewItem( ListView1, temp, fileS, mediaLocation, fileDate); |
740 | item->setPixmap( 0, image0); | 740 | item->setPixmap( 0, image0); |
741 | if( currentFileName == filePath) | 741 | if( currentFileName == filePath) |
742 | ListView1->setSelected( item, true); | 742 | ListView1->setSelected( item, true); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | } | 745 | } |
746 | 746 | ||
747 | void QtRec::initConnections() { | 747 | void QtRec::initConnections() { |
748 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 748 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
749 | 749 | ||
750 | connect( toBeginningButton, SIGNAL( pressed()), | 750 | connect( toBeginningButton, SIGNAL( pressed()), |
751 | this, SLOT( rewindPressed() )); | 751 | this, SLOT( rewindPressed() )); |
752 | connect( toBeginningButton, SIGNAL( released()), | 752 | connect( toBeginningButton, SIGNAL( released()), |
753 | this, SLOT( rewindReleased() )); | 753 | this, SLOT( rewindReleased() )); |
754 | connect( toEndButton, SIGNAL( pressed()), | 754 | connect( toEndButton, SIGNAL( pressed()), |
755 | this, SLOT( FastforwardPressed() )); | 755 | this, SLOT( FastforwardPressed() )); |
756 | connect( toEndButton, SIGNAL( released()), | 756 | connect( toEndButton, SIGNAL( released()), |
757 | this, SLOT( FastforwardReleased() )); | 757 | this, SLOT( FastforwardReleased() )); |
758 | connect( deleteSoundButton, SIGNAL(released()), | 758 | connect( deleteSoundButton, SIGNAL(released()), |
759 | this, SLOT( deleteSound() )); | 759 | this, SLOT( deleteSound() )); |
760 | connect( Stop_PushButton, SIGNAL(released()), | 760 | connect( Stop_PushButton, SIGNAL(released()), |
761 | this, SLOT( doPlayBtn() )); | 761 | this, SLOT( doPlayBtn() )); |
762 | connect( Rec_PushButton, SIGNAL(released()), | 762 | connect( Rec_PushButton, SIGNAL(released()), |
763 | this, SLOT( newSound() ) ); | 763 | this, SLOT( newSound() ) ); |
764 | connect( TabWidget, SIGNAL( currentChanged( QWidget*)), | 764 | connect( TabWidget, SIGNAL( currentChanged(QWidget*)), |
765 | this, SLOT(thisTab(QWidget*) )); | 765 | this, SLOT(thisTab(QWidget*) )); |
766 | connect( OutputSlider, SIGNAL(sliderReleased()), | 766 | connect( OutputSlider, SIGNAL(sliderReleased()), |
767 | this, SLOT( changedOutVolume()) ); | 767 | this, SLOT( changedOutVolume()) ); |
768 | connect( InputSlider, SIGNAL(sliderReleased()), | 768 | connect( InputSlider, SIGNAL(sliderReleased()), |
769 | this, SLOT( changedInVolume()) ); | 769 | this, SLOT( changedInVolume()) ); |
770 | 770 | ||
771 | connect( sampleRateComboBox, SIGNAL(activated( int)), | 771 | connect( sampleRateComboBox, SIGNAL(activated(int)), |
772 | this, SLOT( changesamplerateCombo(int)) ); | 772 | this, SLOT( changesamplerateCombo(int)) ); |
773 | connect( bitRateComboBox, SIGNAL(activated( int)), | 773 | connect( bitRateComboBox, SIGNAL(activated(int)), |
774 | this, SLOT( changebitrateCombo(int)) ); | 774 | this, SLOT( changebitrateCombo(int)) ); |
775 | 775 | ||
776 | connect( directoryComboBox, SIGNAL(activated( int)), | 776 | connect( directoryComboBox, SIGNAL(activated(int)), |
777 | this, SLOT( changeDirCombo(int)) ); | 777 | this, SLOT( changeDirCombo(int)) ); |
778 | connect( sizeLimitCombo, SIGNAL(activated( int)), | 778 | connect( sizeLimitCombo, SIGNAL(activated(int)), |
779 | this, SLOT( changeSizeLimitCombo(int)) ); | 779 | this, SLOT( changeSizeLimitCombo(int)) ); |
780 | 780 | ||
781 | connect( stereoCheckBox, SIGNAL(toggled( bool)), | 781 | connect( stereoCheckBox, SIGNAL(toggled(bool)), |
782 | this, SLOT( changeStereoCheck(bool)) ); | 782 | this, SLOT( changeStereoCheck(bool)) ); |
783 | 783 | ||
784 | connect( outMuteCheckBox, SIGNAL(toggled( bool)), | 784 | connect( outMuteCheckBox, SIGNAL(toggled(bool)), |
785 | this, SLOT( doVolMuting(bool)) ); | 785 | this, SLOT( doVolMuting(bool)) ); |
786 | connect( inMuteCheckBox , SIGNAL(toggled( bool)), | 786 | connect( inMuteCheckBox , SIGNAL(toggled(bool)), |
787 | this, SLOT( doMicMuting(bool)) ); | 787 | this, SLOT( doMicMuting(bool)) ); |
788 | 788 | ||
789 | connect( ListView1,SIGNAL(doubleClicked( QListViewItem*)), | 789 | connect( ListView1,SIGNAL(doubleClicked(QListViewItem*)), |
790 | this,SLOT( itClick(QListViewItem*))); | 790 | this,SLOT( itClick(QListViewItem*))); |
791 | connect( ListView1, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 791 | connect( ListView1, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
792 | this,SLOT( listPressed(int, QListViewItem *, const QPoint&, int)) ); | 792 | this,SLOT( listPressed(int,QListViewItem*,const QPoint&,int)) ); |
793 | connect( timeSlider, SIGNAL( sliderMoved( int)), | 793 | connect( timeSlider, SIGNAL( sliderMoved(int)), |
794 | this, SLOT( changeTimeSlider(int) )); | 794 | this, SLOT( changeTimeSlider(int) )); |
795 | connect( timeSlider, SIGNAL( sliderPressed( )), | 795 | connect( timeSlider, SIGNAL( sliderPressed()), |
796 | this, SLOT( timeSliderPressed() )); | 796 | this, SLOT( timeSliderPressed() )); |
797 | connect( timeSlider, SIGNAL( sliderReleased( )), | 797 | connect( timeSlider, SIGNAL( sliderReleased()), |
798 | this, SLOT( timeSliderReleased() )); | 798 | this, SLOT( timeSliderReleased() )); |
799 | connect( compressionCheckBox, SIGNAL( toggled(bool)), | 799 | connect( compressionCheckBox, SIGNAL( toggled(bool)), |
800 | this, SLOT( compressionSelected(bool))); | 800 | this, SLOT( compressionSelected(bool))); |
801 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), | 801 | connect( autoMuteCheckBox, SIGNAL( toggled(bool)), |
802 | this, SLOT( slotAutoMute(bool))); | 802 | this, SLOT( slotAutoMute(bool))); |
803 | } | 803 | } |
804 | 804 | ||
805 | void QtRec::initConfig() { | 805 | void QtRec::initConfig() { |
806 | int index, fred, i; | 806 | int index, fred, i; |
807 | Config cfg("OpieRec"); | 807 | Config cfg("OpieRec"); |
808 | cfg.setGroup("Settings"); | 808 | cfg.setGroup("Settings"); |
809 | 809 | ||
810 | index = cfg.readNumEntry("samplerate",22050); | 810 | index = cfg.readNumEntry("samplerate",22050); |
811 | bool ok; | 811 | bool ok; |
812 | 812 | ||
813 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { | 813 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { |
814 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 814 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
815 | if( index == fred) { | 815 | if( index == fred) { |
816 | filePara.sampleRate = fred; | 816 | filePara.sampleRate = fred; |
817 | sampleRateComboBox->setCurrentItem(ws); | 817 | sampleRateComboBox->setCurrentItem(ws); |
818 | } | 818 | } |
819 | } | 819 | } |
820 | 820 | ||
821 | i = cfg.readNumEntry("bitrate",16); | 821 | i = cfg.readNumEntry("bitrate",16); |
822 | if(i == 16) | 822 | if(i == 16) |
823 | bitRateComboBox->setCurrentItem( 1); | 823 | bitRateComboBox->setCurrentItem( 1); |
824 | elseif(i == 24) | 824 | elseif(i == 24) |
825 | bitRateComboBox->setCurrentItem( 2); | 825 | bitRateComboBox->setCurrentItem( 2); |
826 | elseif(i == 32) | 826 | elseif(i == 32) |
827 | bitRateComboBox->setCurrentItem( 3); | 827 | bitRateComboBox->setCurrentItem( 3); |
828 | else | 828 | else |
829 | bitRateComboBox->setCurrentItem( 0); | 829 | bitRateComboBox->setCurrentItem( 0); |
830 | 830 | ||
831 | filePara.resolution = i; | 831 | filePara.resolution = i; |
832 | 832 | ||
833 | i = cfg.readNumEntry("sizeLimit", 5 ); | 833 | i = cfg.readNumEntry("sizeLimit", 5 ); |
834 | QString temp; | 834 | QString temp; |
835 | sizeLimitCombo->setCurrentItem((i/5)); | 835 | sizeLimitCombo->setCurrentItem((i/5)); |
836 | 836 | ||
837 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 837 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
838 | if( stereoCheckBox->isChecked()) { | 838 | if( stereoCheckBox->isChecked()) { |
839 | filePara.channels = 2; | 839 | filePara.channels = 2; |
840 | } else { | 840 | } else { |
841 | filePara.channels = 1; | 841 | filePara.channels = 1; |
842 | } | 842 | } |
843 | 843 | ||
844 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 844 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
845 | if( compressionCheckBox->isChecked()) { | 845 | if( compressionCheckBox->isChecked()) { |
846 | bitRateComboBox->setEnabled(false); | 846 | bitRateComboBox->setEnabled(false); |
847 | bitRateComboBox->setCurrentItem(0); | 847 | bitRateComboBox->setCurrentItem(0); |
848 | filePara.resolution=16; | 848 | filePara.resolution=16; |
849 | } | 849 | } |
850 | 850 | ||
851 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 851 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
852 | if( autoMuteCheckBox->isChecked()) | 852 | if( autoMuteCheckBox->isChecked()) |
853 | slotAutoMute(true); | 853 | slotAutoMute(true); |
854 | else | 854 | else |
855 | slotAutoMute(false); | 855 | slotAutoMute(false); |
856 | 856 | ||
857 | Config cofg( "qpe"); | 857 | Config cofg( "qpe"); |
858 | cofg.setGroup( "Volume"); | 858 | cofg.setGroup( "Volume"); |
859 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 859 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
860 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 860 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
861 | } | 861 | } |
862 | 862 | ||
863 | void QtRec::stop() { | 863 | void QtRec::stop() { |
864 | qWarning("STOP"); | 864 | qWarning("STOP"); |
865 | setRecordButton(false); | 865 | setRecordButton(false); |
866 | 866 | ||
867 | if( !recording) | 867 | if( !recording) |
868 | endPlaying(); | 868 | endPlaying(); |
869 | else | 869 | else |
870 | endRecording(); | 870 | endRecording(); |
871 | timeSlider->setValue(0); | 871 | timeSlider->setValue(0); |
872 | } | 872 | } |
873 | 873 | ||
874 | void QtRec::doPlayBtn() { | 874 | void QtRec::doPlayBtn() { |
875 | 875 | ||
876 | if(!stopped) { | 876 | if(!stopped) { |
877 | playLabel2->setText(tr("Play")); | 877 | playLabel2->setText(tr("Play")); |
878 | stop(); | 878 | stop(); |
879 | } else { | 879 | } else { |
880 | if(ListView1->currentItem() == 0) return; | 880 | if(ListView1->currentItem() == 0) return; |
881 | playLabel2->setText(tr("Stop")); | 881 | playLabel2->setText(tr("Stop")); |
882 | currentFile = ListView1->currentItem()->text(0); | 882 | currentFile = ListView1->currentItem()->text(0); |
883 | start(); | 883 | start(); |
884 | } | 884 | } |
885 | } | 885 | } |
886 | 886 | ||
887 | void QtRec::start() { //play | 887 | void QtRec::start() { //play |
888 | if( stopped) { | 888 | if( stopped) { |
889 | QPixmap image3( ( const char** ) image3_data ); | 889 | QPixmap image3( ( const char** ) image3_data ); |
890 | Stop_PushButton->setPixmap( image3 ); | 890 | Stop_PushButton->setPixmap( image3 ); |
891 | Stop_PushButton->setDown( true); | 891 | Stop_PushButton->setDown( true); |
892 | stopped = false; | 892 | stopped = false; |
893 | paused = false; | 893 | paused = false; |
894 | secCount = 1; | 894 | secCount = 1; |
895 | 895 | ||
896 | if( openPlayFile()) | 896 | if( openPlayFile()) |
897 | if( setupAudio( false)) //recording is false | 897 | if( setupAudio( false)) //recording is false |
898 | doPlay(); | 898 | doPlay(); |
899 | } | 899 | } |
900 | } | 900 | } |
901 | 901 | ||
902 | bool QtRec::rec() { //record | 902 | bool QtRec::rec() { //record |
903 | QString timeString; | 903 | QString timeString; |
904 | timeString.sprintf("%.0f", 0.0); | 904 | timeString.sprintf("%.0f", 0.0); |
905 | timeLabel->setText( timeString+ " seconds"); | 905 | timeLabel->setText( timeString+ " seconds"); |
906 | if(!stopped) { | 906 | if(!stopped) { |
907 | monitoring = true; | 907 | monitoring = true; |
908 | return false; | 908 | return false; |
909 | } else { | 909 | } else { |
910 | secCount = 1; | 910 | secCount = 1; |
911 | playLabel2->setText(tr("Stop")); | 911 | playLabel2->setText(tr("Stop")); |
912 | monitoring = false; | 912 | monitoring = false; |
913 | setRecordButton( true); | 913 | setRecordButton( true); |
914 | 914 | ||
915 | if( setupAudio( true)) | 915 | if( setupAudio( true)) |
916 | if(setUpFile()) { | 916 | if(setUpFile()) { |
917 | int fileSize = 0; | 917 | int fileSize = 0; |
918 | Config cfg("OpieRec"); | 918 | Config cfg("OpieRec"); |
919 | cfg.setGroup("Settings"); | 919 | cfg.setGroup("Settings"); |
920 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", | 920 | // qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", |
921 | // soundDevice->getDeviceBits(), | 921 | // soundDevice->getDeviceBits(), |
922 | // soundDevice->getDeviceRate(), | 922 | // soundDevice->getDeviceRate(), |
923 | // soundDevice->getDeviceChannels()); | 923 | // soundDevice->getDeviceChannels()); |
924 | 924 | ||
925 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 925 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
926 | // qDebug("sample rate is %d", filePara.sampleRate); | 926 | // qDebug("sample rate is %d", filePara.sampleRate); |
927 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 927 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
928 | 928 | ||
929 | // qDebug("size limit %d sec", filePara.SecondsToRecord); | 929 | // qDebug("size limit %d sec", filePara.SecondsToRecord); |
930 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 930 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
931 | 931 | ||
932 | if( filePara.SecondsToRecord == 0) { | 932 | if( filePara.SecondsToRecord == 0) { |
933 | fileSize = diskSize; | 933 | fileSize = diskSize; |
934 | } else if( filePara.format == WAVE_FORMAT_PCM) { | 934 | } else if( filePara.format == WAVE_FORMAT_PCM) { |
935 | // qDebug("WAVE_FORMAT_PCM"); | 935 | // qDebug("WAVE_FORMAT_PCM"); |
936 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 936 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
937 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; | 937 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; |
938 | } else { | 938 | } else { |
939 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 939 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
940 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 940 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
941 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; | 941 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; |
942 | } | 942 | } |
943 | 943 | ||
944 | filePara.samplesToRecord = fileSize; | 944 | filePara.samplesToRecord = fileSize; |
945 | qDebug("filesize should be %d, bits %d, rate %d", | 945 | qDebug("filesize should be %d, bits %d, rate %d", |
946 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); | 946 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); |
947 | if( paused) { | 947 | if( paused) { |
948 | paused = false; | 948 | paused = false; |
949 | } | 949 | } |
950 | // else { | 950 | // else { |
951 | qDebug("Setting timeslider %d", filePara.samplesToRecord); | 951 | qDebug("Setting timeslider %d", filePara.samplesToRecord); |
952 | // if(fileSize != 0) | 952 | // if(fileSize != 0) |
953 | timeSlider->setRange(0, filePara.samplesToRecord); | 953 | timeSlider->setRange(0, filePara.samplesToRecord); |
954 | // } | 954 | // } |
955 | 955 | ||
956 | if( diskSize < fileSize/1024) { | 956 | if( diskSize < fileSize/1024) { |
957 | QMessageBox::warning(this, | 957 | QMessageBox::warning(this, |
958 | tr("Low Disk Space"), | 958 | tr("Low Disk Space"), |
959 | tr("You are running low of\nrecording space\n" | 959 | tr("You are running low of\nrecording space\n" |
960 | "or a card isn't being recognized")); | 960 | "or a card isn't being recognized")); |
961 | stopped = true; //we need to be stopped | 961 | stopped = true; //we need to be stopped |
962 | stop(); | 962 | stop(); |
963 | } else { | 963 | } else { |
964 | QString msg; | 964 | QString msg; |
965 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 965 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
966 | #ifdef DEV_VERSION | 966 | #ifdef DEV_VERSION |
967 | setCaption( msg); | 967 | setCaption( msg); |
968 | #endif | 968 | #endif |
969 | filePara.fileName=currentFile.latin1(); | 969 | filePara.fileName=currentFile.latin1(); |
970 | qDebug("Start recording thread"); | 970 | qDebug("Start recording thread"); |
971 | stopped = false; | 971 | stopped = false; |
972 | 972 | ||
973 | #ifdef THREADED | 973 | #ifdef THREADED |
974 | pthread_t thread1; | 974 | pthread_t thread1; |
975 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 975 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
976 | #endif | 976 | #endif |
977 | toBeginningButton->setEnabled( false); | 977 | toBeginningButton->setEnabled( false); |
978 | toEndButton->setEnabled( false); | 978 | toEndButton->setEnabled( false); |
979 | 979 | ||
980 | startTimer(1000); | 980 | startTimer(1000); |
981 | #ifndef THREADED | 981 | #ifndef THREADED |
982 | quickRec(); | 982 | quickRec(); |
983 | #endif | 983 | #endif |
984 | } | 984 | } |
985 | } //end setUpFile | 985 | } //end setUpFile |
986 | } //end setupAudio | 986 | } //end setupAudio |
987 | return true; | 987 | return true; |
988 | } | 988 | } |
989 | /* | 989 | /* |
990 | This happens when a tab is selected*/ | 990 | This happens when a tab is selected*/ |
991 | void QtRec::thisTab(QWidget* widg) { | 991 | void QtRec::thisTab(QWidget* widg) { |
992 | if(widg != NULL) { | 992 | if(widg != NULL) { |
993 | int index = TabWidget->currentPageIndex(); | 993 | int index = TabWidget->currentPageIndex(); |
994 | 994 | ||
995 | if(index == 0) { //file page | 995 | if(index == 0) { //file page |
996 | } | 996 | } |
997 | 997 | ||
998 | if(index == 1) { //control page | 998 | if(index == 1) { //control page |
999 | fillDirectoryCombo(); | 999 | fillDirectoryCombo(); |
1000 | // soundDevice->getOutVol(); | 1000 | // soundDevice->getOutVol(); |
1001 | // soundDevice->getInVol(); | 1001 | // soundDevice->getInVol(); |
1002 | } | 1002 | } |
1003 | 1003 | ||
1004 | if( index==2) { //help page | 1004 | if( index==2) { //help page |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | qApp->processEvents(); | 1007 | qApp->processEvents(); |
1008 | update(); | 1008 | update(); |
1009 | } | 1009 | } |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void QtRec::getOutVol( ) { | 1012 | void QtRec::getOutVol( ) { |
1013 | filePara.outVol = soundDevice->getOutVolume(); | 1013 | filePara.outVol = soundDevice->getOutVolume(); |
1014 | // qDebug("out vol %d", filePara.outVol); | 1014 | // qDebug("out vol %d", filePara.outVol); |
1015 | OutputSlider->setValue( -filePara.outVol); | 1015 | OutputSlider->setValue( -filePara.outVol); |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void QtRec::getInVol() { | 1018 | void QtRec::getInVol() { |
1019 | filePara.inVol = soundDevice->getInVolume(); | 1019 | filePara.inVol = soundDevice->getInVolume(); |
1020 | // qDebug("in vol %d", filePara.inVol); | 1020 | // qDebug("in vol %d", filePara.inVol); |
1021 | InputSlider->setValue( -filePara.inVol); | 1021 | InputSlider->setValue( -filePara.inVol); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void QtRec::changedOutVolume() { | 1024 | void QtRec::changedOutVolume() { |
1025 | soundDevice->changedOutVolume( -OutputSlider->value()); | 1025 | soundDevice->changedOutVolume( -OutputSlider->value()); |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | void QtRec::changedInVolume( ) { | 1028 | void QtRec::changedInVolume( ) { |
1029 | soundDevice->changedInVolume( -InputSlider->value()); | 1029 | soundDevice->changedInVolume( -InputSlider->value()); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | 1032 | ||
1033 | bool QtRec::setupAudio( bool b) { | 1033 | bool QtRec::setupAudio( bool b) { |
1034 | bool ok; | 1034 | bool ok; |
1035 | int sampleformat, stereo, flags; | 1035 | int sampleformat, stereo, flags; |
1036 | QString dspString, mixerString; | 1036 | QString dspString, mixerString; |
1037 | 1037 | ||
1038 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 | 1038 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 |
1039 | 1039 | ||
1040 | if( !b) { | 1040 | if( !b) { |
1041 | // we want to play | 1041 | // we want to play |
1042 | #ifdef PDAUDIO //ALSA | 1042 | #ifdef PDAUDIO //ALSA |
1043 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1043 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1044 | sampleformat = SND_PCM_FORMAT_S16; | 1044 | sampleformat = SND_PCM_FORMAT_S16; |
1045 | filePara.resolution = 16; | 1045 | filePara.resolution = 16; |
1046 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { | 1046 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { |
1047 | sampleformat = SND_PCM_FORMAT_S24; | 1047 | sampleformat = SND_PCM_FORMAT_S24; |
1048 | filePara.resolution = 24; | 1048 | filePara.resolution = 24; |
1049 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { | 1049 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { |
1050 | sampleformat = SND_PCM_FORMAT_S32; | 1050 | sampleformat = SND_PCM_FORMAT_S32; |
1051 | filePara.resolution = 32; | 1051 | filePara.resolution = 32; |
1052 | } else { | 1052 | } else { |
1053 | sampleformat = SND_PCM_FORMAT_U8; | 1053 | sampleformat = SND_PCM_FORMAT_U8; |
1054 | filePara.resolution = 8; | 1054 | filePara.resolution = 8; |
1055 | } | 1055 | } |
1056 | #else | 1056 | #else |
1057 | // we want to play | 1057 | // we want to play |
1058 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1058 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1059 | sampleformat = AFMT_S16_LE; | 1059 | sampleformat = AFMT_S16_LE; |
1060 | filePara.resolution = 16; | 1060 | filePara.resolution = 16; |
1061 | } else { | 1061 | } else { |
1062 | sampleformat = AFMT_U8; | 1062 | sampleformat = AFMT_U8; |
1063 | filePara.resolution = 8; | 1063 | filePara.resolution = 8; |
1064 | } | 1064 | } |
1065 | #endif | 1065 | #endif |
1066 | 1066 | ||
1067 | stereo = filePara.channels; | 1067 | stereo = filePara.channels; |
1068 | flags = O_WRONLY; | 1068 | flags = O_WRONLY; |
1069 | Config hwcfg("OpieRec"); | 1069 | Config hwcfg("OpieRec"); |
1070 | hwcfg.setGroup("Hardware"); | 1070 | hwcfg.setGroup("Hardware"); |
1071 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); | 1071 | dspString = hwcfg.readEntry( "Audio", DSPSTROUT); |
1072 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); | 1072 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXEROUT); |
1073 | recording = false; | 1073 | recording = false; |
1074 | } else { // we want to record | 1074 | } else { // we want to record |
1075 | 1075 | ||
1076 | #ifdef PDAUDIO //ALSA | 1076 | #ifdef PDAUDIO //ALSA |
1077 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1077 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
1078 | sampleformat = SND_PCM_FORMAT_S16; | 1078 | sampleformat = SND_PCM_FORMAT_S16; |
1079 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") | 1079 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") |
1080 | sampleformat = SND_PCM_FORMAT_S24; | 1080 | sampleformat = SND_PCM_FORMAT_S24; |
1081 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") | 1081 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") |
1082 | sampleformat = SND_PCM_FORMAT_S32; | 1082 | sampleformat = SND_PCM_FORMAT_S32; |
1083 | else | 1083 | else |
1084 | sampleformat = SND_PCM_FORMAT_U8; | 1084 | sampleformat = SND_PCM_FORMAT_U8; |
1085 | 1085 | ||
1086 | #else | 1086 | #else |
1087 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1087 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
1088 | sampleformat = AFMT_S16_LE; | 1088 | sampleformat = AFMT_S16_LE; |
1089 | else | 1089 | else |
1090 | sampleformat = AFMT_U8; | 1090 | sampleformat = AFMT_U8; |
1091 | 1091 | ||
1092 | if( !compressionCheckBox->isChecked()) { | 1092 | if( !compressionCheckBox->isChecked()) { |
1093 | filePara.format = WAVE_FORMAT_PCM; | 1093 | filePara.format = WAVE_FORMAT_PCM; |
1094 | // qDebug("WAVE_FORMAT_PCM"); | 1094 | // qDebug("WAVE_FORMAT_PCM"); |
1095 | } else { | 1095 | } else { |
1096 | filePara.format = WAVE_FORMAT_DVI_ADPCM; | 1096 | filePara.format = WAVE_FORMAT_DVI_ADPCM; |
1097 | sampleformat = AFMT_S16_LE; | 1097 | sampleformat = AFMT_S16_LE; |
1098 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); | 1098 | // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
1099 | } | 1099 | } |
1100 | #endif | 1100 | #endif |
1101 | 1101 | ||
1102 | stereo = filePara.channels; | 1102 | stereo = filePara.channels; |
1103 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1103 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1104 | flags= O_RDWR; | 1104 | flags= O_RDWR; |
1105 | // flags= O_RDONLY; | 1105 | // flags= O_RDONLY; |
1106 | Config hwcfg("OpieRec"); | 1106 | Config hwcfg("OpieRec"); |
1107 | hwcfg.setGroup("Hardware"); | 1107 | hwcfg.setGroup("Hardware"); |
1108 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); | 1108 | dspString = hwcfg.readEntry( "Audio", DSPSTRIN); |
1109 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); | 1109 | mixerString = hwcfg.readEntry( "Mixer", DSPSTRMIXERIN); |
1110 | recording = true; | 1110 | recording = true; |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | // if(soundDevice) delete soundDevice; | 1113 | // if(soundDevice) delete soundDevice; |
1114 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); | 1114 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); |
1115 | qWarning("change waveform settings"); | 1115 | qWarning("change waveform settings"); |
1116 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1116 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1117 | 1117 | ||
1118 | soundDevice = new Device( this, dspString, mixerString, b); | 1118 | soundDevice = new Device( this, dspString, mixerString, b); |
1119 | // soundDevice->openDsp(); | 1119 | // soundDevice->openDsp(); |
1120 | soundDevice->reset(); | 1120 | soundDevice->reset(); |
1121 | 1121 | ||
1122 | qDebug("device has been made %d", soundDevice->sd); | 1122 | qDebug("device has been made %d", soundDevice->sd); |
1123 | 1123 | ||
1124 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | 1124 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> |
1125 | soundDevice->setDeviceFormat( sampleformat); | 1125 | soundDevice->setDeviceFormat( sampleformat); |
1126 | soundDevice->setDeviceChannels( filePara.channels); | 1126 | soundDevice->setDeviceChannels( filePara.channels); |
1127 | soundDevice->setDeviceRate( filePara.sampleRate); | 1127 | soundDevice->setDeviceRate( filePara.sampleRate); |
1128 | soundDevice->getDeviceFragSize(); | 1128 | soundDevice->getDeviceFragSize(); |
1129 | #ifdef QT_QWS_EBX | 1129 | #ifdef QT_QWS_EBX |
1130 | int frag = FRAGSIZE; | 1130 | int frag = FRAGSIZE; |
1131 | soundDevice->setFragSize( frag); | 1131 | soundDevice->setFragSize( frag); |
1132 | soundDevice->getDeviceFragSize(); | 1132 | soundDevice->getDeviceFragSize(); |
1133 | #endif | 1133 | #endif |
1134 | ///////////////// | 1134 | ///////////////// |
1135 | filePara.sd = soundDevice->sd; | 1135 | filePara.sd = soundDevice->sd; |
1136 | 1136 | ||
1137 | if ( filePara.sd == -1) { | 1137 | if ( filePara.sd == -1) { |
1138 | 1138 | ||
1139 | monitoring = false; | 1139 | monitoring = false; |
1140 | stopped = true; | 1140 | stopped = true; |
1141 | update(); | 1141 | update(); |
1142 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); | 1142 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); |
1143 | return false; | 1143 | return false; |
1144 | } | 1144 | } |
1145 | if(autoMute) | 1145 | if(autoMute) |
1146 | doMute(false); | 1146 | doMute(false); |
1147 | 1147 | ||
1148 | return true; | 1148 | return true; |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | 1151 | ||
1152 | bool QtRec::setUpFile() { //setup file for recording | 1152 | bool QtRec::setUpFile() { //setup file for recording |
1153 | // qDebug("Setting up wavfile"); | 1153 | // qDebug("Setting up wavfile"); |
1154 | // if(wavFile) delete wavFile; | 1154 | // if(wavFile) delete wavFile; |
1155 | wavFile = new WavFile( this, (const QString &)"", | 1155 | wavFile = new WavFile( this, (const QString &)"", |
1156 | true, | 1156 | true, |
1157 | filePara.sampleRate, | 1157 | filePara.sampleRate, |
1158 | filePara.channels, | 1158 | filePara.channels, |
1159 | filePara.resolution, | 1159 | filePara.resolution, |
1160 | filePara.format); | 1160 | filePara.format); |
1161 | 1161 | ||
1162 | filePara.fd = wavFile->wavHandle(); | 1162 | filePara.fd = wavFile->wavHandle(); |
1163 | if(filePara.fd == -1) { | 1163 | if(filePara.fd == -1) { |
1164 | return false; | 1164 | return false; |
1165 | } else { | 1165 | } else { |
1166 | // filePara.channels=1; | 1166 | // filePara.channels=1; |
1167 | } | 1167 | } |
1168 | return true; | 1168 | return true; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> | 1171 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> |
1172 | bool QtRec::doPlay() { | 1172 | bool QtRec::doPlay() { |
1173 | 1173 | ||
1174 | if( !paused) { | 1174 | if( !paused) { |
1175 | total = 0; | 1175 | total = 0; |
1176 | filePara.numberOfRecordedSeconds = 0; | 1176 | filePara.numberOfRecordedSeconds = 0; |
1177 | } else { | 1177 | } else { |
1178 | paused = false; | 1178 | paused = false; |
1179 | secCount = (int)filePara.numberOfRecordedSeconds; | 1179 | secCount = (int)filePara.numberOfRecordedSeconds; |
1180 | } | 1180 | } |
1181 | playing = true; | 1181 | playing = true; |
@@ -1275,769 +1275,769 @@ void QtRec::newSound() { | |||
1275 | deleteSound(); | 1275 | deleteSound(); |
1276 | } | 1276 | } |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | void QtRec::itClick(QListViewItem *item) { | 1279 | void QtRec::itClick(QListViewItem *item) { |
1280 | currentFile = item->text(0); | 1280 | currentFile = item->text(0); |
1281 | setCaption("OpieRecord "+currentFile); | 1281 | setCaption("OpieRecord "+currentFile); |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void QtRec::deleteSound() { | 1284 | void QtRec::deleteSound() { |
1285 | Config cfg("OpieRec"); | 1285 | Config cfg("OpieRec"); |
1286 | cfg.setGroup("Sounds"); | 1286 | cfg.setGroup("Sounds"); |
1287 | if( ListView1->currentItem() == NULL) | 1287 | if( ListView1->currentItem() == NULL) |
1288 | return; | 1288 | return; |
1289 | #ifndef DEV_VERSION | 1289 | #ifndef DEV_VERSION |
1290 | switch ( QMessageBox::warning(this,tr("Delete"), | 1290 | switch ( QMessageBox::warning(this,tr("Delete"), |
1291 | tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), | 1291 | tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), |
1292 | tr("Yes"),tr("No"),0,1,1) ) { | 1292 | tr("Yes"),tr("No"),0,1,1) ) { |
1293 | case 0: | 1293 | case 0: |
1294 | #endif | 1294 | #endif |
1295 | { | 1295 | { |
1296 | QString file = ListView1->currentItem()->text(0); | 1296 | QString file = ListView1->currentItem()->text(0); |
1297 | QString fileName; | 1297 | QString fileName; |
1298 | fileName = cfg.readEntry( file, ""); | 1298 | fileName = cfg.readEntry( file, ""); |
1299 | QFile f( fileName); | 1299 | QFile f( fileName); |
1300 | if( f.exists()) | 1300 | if( f.exists()) |
1301 | if( !f.remove()) | 1301 | if( !f.remove()) |
1302 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); | 1302 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); |
1303 | 1303 | ||
1304 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1304 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1305 | bool found = false; | 1305 | bool found = false; |
1306 | for(int i=0;i<nFiles+1;i++) { | 1306 | for(int i=0;i<nFiles+1;i++) { |
1307 | 1307 | ||
1308 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { | 1308 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { |
1309 | found = true; | 1309 | found = true; |
1310 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1310 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1311 | } | 1311 | } |
1312 | if(found) | 1312 | if(found) |
1313 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1313 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | cfg.removeEntry( cfg.readEntry( file)); | 1316 | cfg.removeEntry( cfg.readEntry( file)); |
1317 | cfg.removeEntry( file); | 1317 | cfg.removeEntry( file); |
1318 | cfg.writeEntry( "NumberofFiles", nFiles-1); | 1318 | cfg.writeEntry( "NumberofFiles", nFiles-1); |
1319 | cfg.write(); | 1319 | cfg.write(); |
1320 | 1320 | ||
1321 | ListView1->takeItem( ListView1->currentItem() ); | 1321 | ListView1->takeItem( ListView1->currentItem() ); |
1322 | delete ListView1->currentItem(); | 1322 | delete ListView1->currentItem(); |
1323 | 1323 | ||
1324 | ListView1->clear(); | 1324 | ListView1->clear(); |
1325 | ListView1->setSelected( ListView1->firstChild(), true); | 1325 | ListView1->setSelected( ListView1->firstChild(), true); |
1326 | initIconView(); | 1326 | initIconView(); |
1327 | update(); | 1327 | update(); |
1328 | } | 1328 | } |
1329 | #ifndef DEV_VERSION | 1329 | #ifndef DEV_VERSION |
1330 | }; | 1330 | }; |
1331 | #endif | 1331 | #endif |
1332 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1332 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
1333 | 1333 | ||
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | void QtRec::keyPressEvent( QKeyEvent *e) { | 1336 | void QtRec::keyPressEvent( QKeyEvent *e) { |
1337 | 1337 | ||
1338 | switch ( e->key() ) { | 1338 | switch ( e->key() ) { |
1339 | // case Key_F1: | 1339 | // case Key_F1: |
1340 | // if(stopped && !recording) | 1340 | // if(stopped && !recording) |
1341 | // newSound(); | 1341 | // newSound(); |
1342 | // else | 1342 | // else |
1343 | // stop(); | 1343 | // stop(); |
1344 | // break; | 1344 | // break; |
1345 | // case Key_F2: { | 1345 | // case Key_F2: { |
1346 | // if( !e->isAutoRepeat()) | 1346 | // if( !e->isAutoRepeat()) |
1347 | // rewindPressed(); | 1347 | // rewindPressed(); |
1348 | // } | 1348 | // } |
1349 | // break; | 1349 | // break; |
1350 | // case Key_F3: { | 1350 | // case Key_F3: { |
1351 | // if( !e->isAutoRepeat()) | 1351 | // if( !e->isAutoRepeat()) |
1352 | // FastforwardPressed(); | 1352 | // FastforwardPressed(); |
1353 | // } | 1353 | // } |
1354 | // break; | 1354 | // break; |
1355 | 1355 | ||
1356 | ////////////////////////////// Zaurus keys | 1356 | ////////////////////////////// Zaurus keys |
1357 | case Key_F9: //activity | 1357 | case Key_F9: //activity |
1358 | break; | 1358 | break; |
1359 | case Key_F10: //contacts | 1359 | case Key_F10: //contacts |
1360 | break; | 1360 | break; |
1361 | case Key_F11: //menu | 1361 | case Key_F11: //menu |
1362 | break; | 1362 | break; |
1363 | case Key_F12: //home | 1363 | case Key_F12: //home |
1364 | break; | 1364 | break; |
1365 | case Key_F13: //mail | 1365 | case Key_F13: //mail |
1366 | break; | 1366 | break; |
1367 | case Key_Space: | 1367 | case Key_Space: |
1368 | break; | 1368 | break; |
1369 | case Key_Delete: | 1369 | case Key_Delete: |
1370 | break; | 1370 | break; |
1371 | case Key_Up: | 1371 | case Key_Up: |
1372 | // stop(); | 1372 | // stop(); |
1373 | break; | 1373 | break; |
1374 | case Key_Down: | 1374 | case Key_Down: |
1375 | // newSound(); | 1375 | // newSound(); |
1376 | break; | 1376 | break; |
1377 | case Key_Left: { | 1377 | case Key_Left: { |
1378 | qDebug("rewinding"); | 1378 | qDebug("rewinding"); |
1379 | if( !e->isAutoRepeat()) | 1379 | if( !e->isAutoRepeat()) |
1380 | rewindPressed(); | 1380 | rewindPressed(); |
1381 | } | 1381 | } |
1382 | break; | 1382 | break; |
1383 | case Key_Right: { | 1383 | case Key_Right: { |
1384 | if( !e->isAutoRepeat()) | 1384 | if( !e->isAutoRepeat()) |
1385 | FastforwardPressed(); | 1385 | FastforwardPressed(); |
1386 | } | 1386 | } |
1387 | break; | 1387 | break; |
1388 | } | 1388 | } |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | void QtRec::keyReleaseEvent( QKeyEvent *e) { | 1391 | void QtRec::keyReleaseEvent( QKeyEvent *e) { |
1392 | switch ( e->key() ) { | 1392 | switch ( e->key() ) { |
1393 | // case Key_F1: | 1393 | // case Key_F1: |
1394 | // if(stopped && !recording) | 1394 | // if(stopped && !recording) |
1395 | // newSound(); | 1395 | // newSound(); |
1396 | // else | 1396 | // else |
1397 | // stop(); | 1397 | // stop(); |
1398 | // break; | 1398 | // break; |
1399 | // case Key_F2: | 1399 | // case Key_F2: |
1400 | // rewindReleased(); | 1400 | // rewindReleased(); |
1401 | // break; | 1401 | // break; |
1402 | // case Key_F3: | 1402 | // case Key_F3: |
1403 | // FastforwardReleased(); | 1403 | // FastforwardReleased(); |
1404 | // break; | 1404 | // break; |
1405 | 1405 | ||
1406 | ////////////////////////////// Zaurus keys | 1406 | ////////////////////////////// Zaurus keys |
1407 | case Key_F9: //activity | 1407 | case Key_F9: //activity |
1408 | break; | 1408 | break; |
1409 | case Key_F10: //contacts | 1409 | case Key_F10: //contacts |
1410 | break; | 1410 | break; |
1411 | case Key_F11: //menu | 1411 | case Key_F11: //menu |
1412 | break; | 1412 | break; |
1413 | case Key_F12: //home | 1413 | case Key_F12: //home |
1414 | if(stopped) | 1414 | if(stopped) |
1415 | doPlayBtn(); | 1415 | doPlayBtn(); |
1416 | else | 1416 | else |
1417 | stop(); | 1417 | stop(); |
1418 | break; | 1418 | break; |
1419 | case Key_F13: //mail | 1419 | case Key_F13: //mail |
1420 | break; | 1420 | break; |
1421 | case Key_Space: | 1421 | case Key_Space: |
1422 | if(stopped && !recording) | 1422 | if(stopped && !recording) |
1423 | newSound(); | 1423 | newSound(); |
1424 | else | 1424 | else |
1425 | stop(); | 1425 | stop(); |
1426 | break; | 1426 | break; |
1427 | case Key_Delete: | 1427 | case Key_Delete: |
1428 | deleteSound(); | 1428 | deleteSound(); |
1429 | break; | 1429 | break; |
1430 | case Key_Up: | 1430 | case Key_Up: |
1431 | // stop(); | 1431 | // stop(); |
1432 | qDebug("Up"); | 1432 | qDebug("Up"); |
1433 | break; | 1433 | break; |
1434 | case Key_Down: | 1434 | case Key_Down: |
1435 | // start(); | 1435 | // start(); |
1436 | // qDebug("Down"); | 1436 | // qDebug("Down"); |
1437 | // newSound(); | 1437 | // newSound(); |
1438 | break; | 1438 | break; |
1439 | case Key_Left: | 1439 | case Key_Left: |
1440 | qDebug("Left"); | 1440 | qDebug("Left"); |
1441 | rewindReleased(); | 1441 | rewindReleased(); |
1442 | break; | 1442 | break; |
1443 | case Key_Right: | 1443 | case Key_Right: |
1444 | qDebug("Right"); | 1444 | qDebug("Right"); |
1445 | FastforwardReleased(); | 1445 | FastforwardReleased(); |
1446 | break; | 1446 | break; |
1447 | } | 1447 | } |
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | void QtRec::endRecording() { | 1450 | void QtRec::endRecording() { |
1451 | monitoring = false; | 1451 | monitoring = false; |
1452 | recording = false; | 1452 | recording = false; |
1453 | stopped = true; | 1453 | stopped = true; |
1454 | waveform->reset(); | 1454 | waveform->reset(); |
1455 | setRecordButton( false); | 1455 | setRecordButton( false); |
1456 | 1456 | ||
1457 | toBeginningButton->setEnabled( true); | 1457 | toBeginningButton->setEnabled( true); |
1458 | toEndButton->setEnabled( true); | 1458 | toEndButton->setEnabled( true); |
1459 | 1459 | ||
1460 | killTimers(); | 1460 | killTimers(); |
1461 | 1461 | ||
1462 | if(autoMute) | 1462 | if(autoMute) |
1463 | doMute( true); | 1463 | doMute( true); |
1464 | 1464 | ||
1465 | soundDevice->closeDevice( true); | 1465 | soundDevice->closeDevice( true); |
1466 | 1466 | ||
1467 | if( wavFile->track.isOpen()) { | 1467 | if( wavFile->track.isOpen()) { |
1468 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); | 1468 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); |
1469 | // soundDevice->sd=-1; | 1469 | // soundDevice->sd=-1; |
1470 | filePara.numberSamples = 0; | 1470 | filePara.numberSamples = 0; |
1471 | // filePara.sd=-1; | 1471 | // filePara.sd=-1; |
1472 | wavFile->closeFile(); | 1472 | wavFile->closeFile(); |
1473 | filePara.fd=0; | 1473 | filePara.fd=0; |
1474 | 1474 | ||
1475 | if( wavFile->isTempFile()) { | 1475 | if( wavFile->isTempFile()) { |
1476 | // move tmp file to regular file | 1476 | // move tmp file to regular file |
1477 | QString cmd; | 1477 | QString cmd; |
1478 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1478 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1479 | // qDebug("moving tmp file to "+currentFileName); | 1479 | // qDebug("moving tmp file to "+currentFileName); |
1480 | system( cmd.latin1()); | 1480 | system( cmd.latin1()); |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | qDebug("Just moved " + wavFile->currentFileName); | 1483 | qDebug("Just moved " + wavFile->currentFileName); |
1484 | Config cfg("OpieRec"); | 1484 | Config cfg("OpieRec"); |
1485 | cfg.setGroup("Sounds"); | 1485 | cfg.setGroup("Sounds"); |
1486 | 1486 | ||
1487 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1487 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1488 | 1488 | ||
1489 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); | 1489 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); |
1490 | currentFile = currentFile.left( currentFile.length() - 4); | 1490 | currentFile = currentFile.left( currentFile.length() - 4); |
1491 | 1491 | ||
1492 | cfg.writeEntry( "NumberofFiles", nFiles + 1); | 1492 | cfg.writeEntry( "NumberofFiles", nFiles + 1); |
1493 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); | 1493 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); |
1494 | cfg.writeEntry( currentFile, wavFile->currentFileName); | 1494 | cfg.writeEntry( currentFile, wavFile->currentFileName); |
1495 | 1495 | ||
1496 | QString time; | 1496 | QString time; |
1497 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1497 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1498 | cfg.writeEntry( wavFile->currentFileName, time ); | 1498 | cfg.writeEntry( wavFile->currentFileName, time ); |
1499 | // qDebug("writing config numberOfRecordedSeconds "+time); | 1499 | // qDebug("writing config numberOfRecordedSeconds "+time); |
1500 | 1500 | ||
1501 | cfg.write(); | 1501 | cfg.write(); |
1502 | qDebug("finished recording"); | 1502 | qDebug("finished recording"); |
1503 | timeLabel->setText(""); | 1503 | timeLabel->setText(""); |
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | if(soundDevice) delete soundDevice; | 1506 | if(soundDevice) delete soundDevice; |
1507 | 1507 | ||
1508 | timeSlider->setValue(0); | 1508 | timeSlider->setValue(0); |
1509 | initIconView(); | 1509 | initIconView(); |
1510 | selectItemByName( currentFile); | 1510 | selectItemByName( currentFile); |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | void QtRec::endPlaying() { | 1513 | void QtRec::endPlaying() { |
1514 | monitoring = false; | 1514 | monitoring = false; |
1515 | recording = false; | 1515 | recording = false; |
1516 | playing = false; | 1516 | playing = false; |
1517 | stopped = true; | 1517 | stopped = true; |
1518 | waveform->reset(); | 1518 | waveform->reset(); |
1519 | // errorStop(); | 1519 | // errorStop(); |
1520 | // qDebug("end playing"); | 1520 | // qDebug("end playing"); |
1521 | setRecordButton( false); | 1521 | setRecordButton( false); |
1522 | 1522 | ||
1523 | toBeginningButton->setEnabled( true); | 1523 | toBeginningButton->setEnabled( true); |
1524 | toEndButton->setEnabled( true); | 1524 | toEndButton->setEnabled( true); |
1525 | 1525 | ||
1526 | if(autoMute) | 1526 | if(autoMute) |
1527 | doMute( true); | 1527 | doMute( true); |
1528 | 1528 | ||
1529 | soundDevice->closeDevice( false); | 1529 | soundDevice->closeDevice( false); |
1530 | soundDevice->sd = -1; | 1530 | soundDevice->sd = -1; |
1531 | // if(soundDevice) delete soundDevice; | 1531 | // if(soundDevice) delete soundDevice; |
1532 | // qDebug("file and sound device closed"); | 1532 | // qDebug("file and sound device closed"); |
1533 | timeLabel->setText(""); | 1533 | timeLabel->setText(""); |
1534 | total = 0; | 1534 | total = 0; |
1535 | filePara.numberSamples = 0; | 1535 | filePara.numberSamples = 0; |
1536 | filePara.sd = -1; | 1536 | filePara.sd = -1; |
1537 | // wavFile->closeFile(); | 1537 | // wavFile->closeFile(); |
1538 | filePara.fd = 0; | 1538 | filePara.fd = 0; |
1539 | // if(wavFile) delete wavFile; //this crashes | 1539 | // if(wavFile) delete wavFile; //this crashes |
1540 | 1540 | ||
1541 | // qDebug("track closed"); | 1541 | // qDebug("track closed"); |
1542 | killTimers(); | 1542 | killTimers(); |
1543 | qWarning("reset slider"); | 1543 | qWarning("reset slider"); |
1544 | timeSlider->setValue(0); | 1544 | timeSlider->setValue(0); |
1545 | 1545 | ||
1546 | if(soundDevice) delete soundDevice; | 1546 | if(soundDevice) delete soundDevice; |
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | 1549 | ||
1550 | bool QtRec::openPlayFile() { | 1550 | bool QtRec::openPlayFile() { |
1551 | 1551 | ||
1552 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1553 | if( currentFile.isEmpty()) { | 1553 | if( currentFile.isEmpty()) { |
1554 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); | 1554 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); |
1555 | endPlaying(); | 1555 | endPlaying(); |
1556 | return false; | 1556 | return false; |
1557 | } | 1557 | } |
1558 | QString currentFileName; | 1558 | QString currentFileName; |
1559 | Config cfg("OpieRec"); | 1559 | Config cfg("OpieRec"); |
1560 | cfg.setGroup("Sounds"); | 1560 | cfg.setGroup("Sounds"); |
1561 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); | 1561 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); |
1562 | for(int i=0;i<nFiles+1;i++) { //look for file | 1562 | for(int i=0;i<nFiles+1;i++) { //look for file |
1563 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { | 1563 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { |
1564 | currentFileName = cfg.readEntry( currentFile, "" ); | 1564 | currentFileName = cfg.readEntry( currentFile, "" ); |
1565 | qDebug("opening for play: " + currentFileName); | 1565 | qDebug("opening for play: " + currentFileName); |
1566 | } | 1566 | } |
1567 | } | 1567 | } |
1568 | wavFile = new WavFile(this, | 1568 | wavFile = new WavFile(this, |
1569 | currentFileName, | 1569 | currentFileName, |
1570 | false); | 1570 | false); |
1571 | filePara.fd = wavFile->wavHandle(); | 1571 | filePara.fd = wavFile->wavHandle(); |
1572 | if(filePara.fd == -1) { | 1572 | if(filePara.fd == -1) { |
1573 | // if(!track.open(IO_ReadOnly)) { | 1573 | // if(!track.open(IO_ReadOnly)) { |
1574 | QString errorMsg = (QString)strerror(errno); | 1574 | QString errorMsg = (QString)strerror(errno); |
1575 | monitoring = false; | 1575 | monitoring = false; |
1576 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1576 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); |
1577 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") | 1577 | QMessageBox::message(tr("Note"), tr("Could not open audio file.\n") |
1578 | + errorMsg + "\n" + currentFile); | 1578 | + errorMsg + "\n" + currentFile); |
1579 | return false; | 1579 | return false; |
1580 | } else { | 1580 | } else { |
1581 | 1581 | ||
1582 | filePara.numberSamples = wavFile->getNumberSamples(); | 1582 | filePara.numberSamples = wavFile->getNumberSamples(); |
1583 | filePara.format = wavFile->getFormat(); | 1583 | filePara.format = wavFile->getFormat(); |
1584 | filePara.sampleRate = wavFile->getSampleRate(); | 1584 | filePara.sampleRate = wavFile->getSampleRate(); |
1585 | filePara.resolution = wavFile->getResolution(); | 1585 | filePara.resolution = wavFile->getResolution(); |
1586 | filePara.channels = wavFile->getChannels(); | 1586 | filePara.channels = wavFile->getChannels(); |
1587 | timeSlider->setPageStep(1); | 1587 | timeSlider->setPageStep(1); |
1588 | monitoring = true; | 1588 | monitoring = true; |
1589 | 1589 | ||
1590 | qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); | 1590 | qDebug("file %d, samples %d %d", filePara.fd, filePara.numberSamples, filePara.sampleRate); |
1591 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); | 1591 | int sec = (int) (( filePara.numberSamples / filePara.sampleRate) / filePara.channels) / ( filePara.channels*( filePara.resolution/8)); |
1592 | 1592 | ||
1593 | qWarning("seconds %d", sec); | 1593 | qWarning("seconds %d", sec); |
1594 | 1594 | ||
1595 | timeSlider->setRange(0, filePara.numberSamples ); | 1595 | timeSlider->setRange(0, filePara.numberSamples ); |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | return true; | 1598 | return true; |
1599 | } | 1599 | } |
1600 | 1600 | ||
1601 | void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { | 1601 | void QtRec::listPressed( int mouse, QListViewItem *item, const QPoint &, int ) { |
1602 | if(item == NULL ) | 1602 | if(item == NULL ) |
1603 | return; | 1603 | return; |
1604 | switch (mouse) { | 1604 | switch (mouse) { |
1605 | case 1: { | 1605 | case 1: { |
1606 | if( renameBox != 0 ) //tricky | 1606 | if( renameBox != 0 ) //tricky |
1607 | cancelRename(); | 1607 | cancelRename(); |
1608 | 1608 | ||
1609 | currentFile = item->text(0); | 1609 | currentFile = item->text(0); |
1610 | setCaption( "OpieRecord " + currentFile); | 1610 | setCaption( "OpieRecord " + currentFile); |
1611 | } | 1611 | } |
1612 | break; | 1612 | break; |
1613 | case 2: | 1613 | case 2: |
1614 | showListMenu(item); | 1614 | showListMenu(item); |
1615 | ListView1->clearSelection(); | 1615 | ListView1->clearSelection(); |
1616 | break; | 1616 | break; |
1617 | }; | 1617 | }; |
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | void QtRec::showListMenu(QListViewItem * item) { | 1620 | void QtRec::showListMenu(QListViewItem * item) { |
1621 | if(item == NULL) | 1621 | if(item == NULL) |
1622 | return; | 1622 | return; |
1623 | QPopupMenu *m = new QPopupMenu(this); | 1623 | QPopupMenu *m = new QPopupMenu(this); |
1624 | m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); | 1624 | m->insertItem( tr("Play"), this, SLOT( doMenuPlay() )); |
1625 | if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); | 1625 | if(Ir::supported()) m->insertItem( tr( "Send with Ir" ), this, SLOT( doBeam() )); |
1626 | m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); | 1626 | m->insertItem( tr( "Rename" ), this, SLOT( doRename() )); |
1627 | // #if defined (QTOPIA_INTERNAL_FSLP) | 1627 | // #if defined (QTOPIA_INTERNAL_FSLP) |
1628 | // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 1628 | // m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
1629 | // #endif | 1629 | // #endif |
1630 | m->insertSeparator(); | 1630 | m->insertSeparator(); |
1631 | m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); | 1631 | m->insertItem( tr("Delete"), this, SLOT( deleteSound() ) ); |
1632 | m->exec( QCursor::pos() ); | 1632 | m->exec( QCursor::pos() ); |
1633 | qApp->processEvents(); | 1633 | qApp->processEvents(); |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | void QtRec::fileBeamFinished( Ir *ir) { | 1636 | void QtRec::fileBeamFinished( Ir *ir) { |
1637 | if(ir) | 1637 | if(ir) |
1638 | QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); | 1638 | QMessageBox::message( tr("Ir Beam out"), tr("Ir sent.") ,tr("Ok") ); |
1639 | 1639 | ||
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | void QtRec::doBeam() { | 1642 | void QtRec::doBeam() { |
1643 | qApp->processEvents(); | 1643 | qApp->processEvents(); |
1644 | if( ListView1->currentItem() == NULL) | 1644 | if( ListView1->currentItem() == NULL) |
1645 | return; | 1645 | return; |
1646 | Ir ir; | 1646 | Ir ir; |
1647 | if( ir.supported()) { | 1647 | if( ir.supported()) { |
1648 | QString file = ListView1->currentItem()->text(0); | 1648 | QString file = ListView1->currentItem()->text(0); |
1649 | Config cfg("OpieRec"); | 1649 | Config cfg("OpieRec"); |
1650 | cfg.setGroup("Sounds"); | 1650 | cfg.setGroup("Sounds"); |
1651 | 1651 | ||
1652 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1652 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1653 | 1653 | ||
1654 | for(int i=0;i<nFiles+1;i++) { | 1654 | for(int i=0;i<nFiles+1;i++) { |
1655 | if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { | 1655 | if( cfg.readEntry( QString::number( i),"").find( file, 0, true) != -1) { |
1656 | QString filePath = cfg.readEntry(file,""); | 1656 | QString filePath = cfg.readEntry(file,""); |
1657 | Ir *file = new Ir(this, "IR"); | 1657 | Ir *file = new Ir(this, "IR"); |
1658 | connect( file, SIGNAL( done(Ir*)), | 1658 | connect( file, SIGNAL( done(Ir*)), |
1659 | this, SLOT( fileBeamFinished( Ir * ))); | 1659 | this, SLOT( fileBeamFinished(Ir*))); |
1660 | file->send( filePath, "OPieRec audio file\n" + filePath ); | 1660 | file->send( filePath, "OPieRec audio file\n" + filePath ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | } | 1663 | } |
1664 | } | 1664 | } |
1665 | 1665 | ||
1666 | void QtRec::doMenuPlay() { | 1666 | void QtRec::doMenuPlay() { |
1667 | qApp->processEvents(); | 1667 | qApp->processEvents(); |
1668 | currentFile = ListView1->currentItem()->text(0); | 1668 | currentFile = ListView1->currentItem()->text(0); |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | void QtRec::doRename() { | 1671 | void QtRec::doRename() { |
1672 | QRect r = ListView1->itemRect( ListView1->currentItem( )); | 1672 | QRect r = ListView1->itemRect( ListView1->currentItem( )); |
1673 | r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); | 1673 | r = QRect( ListView1->viewportToContents( r.topLeft() ), r.size() ); |
1674 | r.setX( ListView1->contentsX() ); | 1674 | r.setX( ListView1->contentsX() ); |
1675 | if ( r.width() > ListView1->visibleWidth() ) | 1675 | if ( r.width() > ListView1->visibleWidth() ) |
1676 | r.setWidth( ListView1->visibleWidth() ); | 1676 | r.setWidth( ListView1->visibleWidth() ); |
1677 | 1677 | ||
1678 | renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); | 1678 | renameBox = new QLineEdit( ListView1->viewport(), "qt_renamebox" ); |
1679 | renameBox->setFrame(true); | 1679 | renameBox->setFrame(true); |
1680 | 1680 | ||
1681 | renameBox->setText( ListView1->currentItem()->text(0) ); | 1681 | renameBox->setText( ListView1->currentItem()->text(0) ); |
1682 | 1682 | ||
1683 | renameBox->selectAll(); | 1683 | renameBox->selectAll(); |
1684 | renameBox->installEventFilter( this ); | 1684 | renameBox->installEventFilter( this ); |
1685 | ListView1->addChild( renameBox, r.x(), r.y() ); | 1685 | ListView1->addChild( renameBox, r.x(), r.y() ); |
1686 | renameBox->resize( r.size() ); | 1686 | renameBox->resize( r.size() ); |
1687 | ListView1->viewport()->setFocusProxy( renameBox ); | 1687 | ListView1->viewport()->setFocusProxy( renameBox ); |
1688 | renameBox->setFocus(); | 1688 | renameBox->setFocus(); |
1689 | renameBox->show(); | 1689 | renameBox->show(); |
1690 | 1690 | ||
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | void QtRec::okRename() { | 1693 | void QtRec::okRename() { |
1694 | qDebug(renameBox->text()); | 1694 | qDebug(renameBox->text()); |
1695 | QString filename = renameBox->text(); | 1695 | QString filename = renameBox->text(); |
1696 | cancelRename(); | 1696 | cancelRename(); |
1697 | 1697 | ||
1698 | if( ListView1->currentItem() == NULL) | 1698 | if( ListView1->currentItem() == NULL) |
1699 | return; | 1699 | return; |
1700 | 1700 | ||
1701 | Config cfg("OpieRec"); | 1701 | Config cfg("OpieRec"); |
1702 | cfg.setGroup("Sounds"); | 1702 | cfg.setGroup("Sounds"); |
1703 | 1703 | ||
1704 | QString file = ListView1->currentItem()->text(0); | 1704 | QString file = ListView1->currentItem()->text(0); |
1705 | 1705 | ||
1706 | qDebug("filename is " + filename); | 1706 | qDebug("filename is " + filename); |
1707 | 1707 | ||
1708 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1708 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
1709 | 1709 | ||
1710 | for(int i=0;i<nFiles+1;i++) { //look for file | 1710 | for(int i=0;i<nFiles+1;i++) { //look for file |
1711 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { | 1711 | if( cfg.readEntry( QString::number(i),"").find(file,0,true) != -1) { |
1712 | 1712 | ||
1713 | QString filePath = cfg.readEntry(file,""); | 1713 | QString filePath = cfg.readEntry(file,""); |
1714 | 1714 | ||
1715 | cfg.writeEntry( QString::number(i), filename ); | 1715 | cfg.writeEntry( QString::number(i), filename ); |
1716 | cfg.writeEntry( filename, filePath ); | 1716 | cfg.writeEntry( filename, filePath ); |
1717 | cfg.removeEntry( file); | 1717 | cfg.removeEntry( file); |
1718 | cfg.write(); | 1718 | cfg.write(); |
1719 | } | 1719 | } |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | ListView1->takeItem( ListView1->currentItem() ); | 1722 | ListView1->takeItem( ListView1->currentItem() ); |
1723 | delete ListView1->currentItem(); | 1723 | delete ListView1->currentItem(); |
1724 | ListView1->clear(); | 1724 | ListView1->clear(); |
1725 | initIconView(); | 1725 | initIconView(); |
1726 | update(); | 1726 | update(); |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | void QtRec::cancelRename() { | 1729 | void QtRec::cancelRename() { |
1730 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; | 1730 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; |
1731 | delete renameBox; | 1731 | delete renameBox; |
1732 | renameBox = 0; | 1732 | renameBox = 0; |
1733 | if ( resetFocus ) { | 1733 | if ( resetFocus ) { |
1734 | ListView1->viewport()->setFocusProxy( ListView1 ); | 1734 | ListView1->viewport()->setFocusProxy( ListView1 ); |
1735 | ListView1->setFocus(); | 1735 | ListView1->setFocus(); |
1736 | } | 1736 | } |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | bool QtRec::eventFilter( QObject * o, QEvent * e ) { | 1739 | bool QtRec::eventFilter( QObject * o, QEvent * e ) { |
1740 | if ( o->inherits( "QLineEdit" ) ) { | 1740 | if ( o->inherits( "QLineEdit" ) ) { |
1741 | if ( e->type() == QEvent::KeyPress ) { | 1741 | if ( e->type() == QEvent::KeyPress ) { |
1742 | QKeyEvent *ke = (QKeyEvent*)e; | 1742 | QKeyEvent *ke = (QKeyEvent*)e; |
1743 | if ( ke->key() == Key_Return || | 1743 | if ( ke->key() == Key_Return || |
1744 | ke->key() == Key_Enter ) { | 1744 | ke->key() == Key_Enter ) { |
1745 | okRename(); | 1745 | okRename(); |
1746 | return true; | 1746 | return true; |
1747 | } else if ( ke->key() == Key_Escape ) { | 1747 | } else if ( ke->key() == Key_Escape ) { |
1748 | cancelRename(); | 1748 | cancelRename(); |
1749 | return true; | 1749 | return true; |
1750 | } | 1750 | } |
1751 | } else if ( e->type() == QEvent::FocusOut ) { | 1751 | } else if ( e->type() == QEvent::FocusOut ) { |
1752 | cancelRename(); | 1752 | cancelRename(); |
1753 | return true; | 1753 | return true; |
1754 | } | 1754 | } |
1755 | } | 1755 | } |
1756 | return QWidget::eventFilter( o, e ); | 1756 | return QWidget::eventFilter( o, e ); |
1757 | } | 1757 | } |
1758 | 1758 | ||
1759 | 1759 | ||
1760 | int QtRec::getCurrentSizeLimit() { | 1760 | int QtRec::getCurrentSizeLimit() { |
1761 | return sizeLimitCombo->currentItem() * 5; | 1761 | return sizeLimitCombo->currentItem() * 5; |
1762 | } | 1762 | } |
1763 | 1763 | ||
1764 | void QtRec::timerBreak() { | 1764 | void QtRec::timerBreak() { |
1765 | endPlaying(); | 1765 | endPlaying(); |
1766 | } | 1766 | } |
1767 | 1767 | ||
1768 | void QtRec::doVolMuting(bool b) { | 1768 | void QtRec::doVolMuting(bool b) { |
1769 | Config cfg( "qpe" ); | 1769 | Config cfg( "qpe" ); |
1770 | cfg. setGroup( "Volume" ); | 1770 | cfg. setGroup( "Volume" ); |
1771 | cfg.writeEntry( "Mute",b); | 1771 | cfg.writeEntry( "Mute",b); |
1772 | cfg.write(); | 1772 | cfg.write(); |
1773 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; | 1773 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << b; |
1774 | } | 1774 | } |
1775 | 1775 | ||
1776 | void QtRec::doMicMuting(bool b) { | 1776 | void QtRec::doMicMuting(bool b) { |
1777 | // qDebug("mic mute"); | 1777 | // qDebug("mic mute"); |
1778 | Config cfg( "qpe" ); | 1778 | Config cfg( "qpe" ); |
1779 | cfg. setGroup( "Volume" ); | 1779 | cfg. setGroup( "Volume" ); |
1780 | cfg.writeEntry( "MicMute",b); | 1780 | cfg.writeEntry( "MicMute",b); |
1781 | cfg.write(); | 1781 | cfg.write(); |
1782 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; | 1782 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << b; |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void QtRec::compressionSelected(bool b) { | 1785 | void QtRec::compressionSelected(bool b) { |
1786 | Config cfg("OpieRec"); | 1786 | Config cfg("OpieRec"); |
1787 | cfg.setGroup("Settings"); | 1787 | cfg.setGroup("Settings"); |
1788 | cfg.writeEntry("wavCompression", b); | 1788 | cfg.writeEntry("wavCompression", b); |
1789 | cfg.writeEntry("bitrate", 16); | 1789 | cfg.writeEntry("bitrate", 16); |
1790 | filePara.resolution = 16; | 1790 | filePara.resolution = 16; |
1791 | cfg.write(); | 1791 | cfg.write(); |
1792 | 1792 | ||
1793 | if(b) { | 1793 | if(b) { |
1794 | bitRateComboBox->setEnabled( false); | 1794 | bitRateComboBox->setEnabled( false); |
1795 | bitRateComboBox->setCurrentItem( 0); | 1795 | bitRateComboBox->setCurrentItem( 0); |
1796 | filePara.resolution = 16; | 1796 | filePara.resolution = 16; |
1797 | } else{ | 1797 | } else{ |
1798 | bitRateComboBox->setEnabled( true); | 1798 | bitRateComboBox->setEnabled( true); |
1799 | } | 1799 | } |
1800 | } | 1800 | } |
1801 | 1801 | ||
1802 | long QtRec::checkDiskSpace(const QString &path) { | 1802 | long QtRec::checkDiskSpace(const QString &path) { |
1803 | 1803 | ||
1804 | struct statfs fs; | 1804 | struct statfs fs; |
1805 | 1805 | ||
1806 | if ( !statfs( path.latin1(), &fs ) ) { | 1806 | if ( !statfs( path.latin1(), &fs ) ) { |
1807 | 1807 | ||
1808 | int blkSize = fs.f_bsize; | 1808 | int blkSize = fs.f_bsize; |
1809 | int availBlks = fs.f_bavail; | 1809 | int availBlks = fs.f_bavail; |
1810 | 1810 | ||
1811 | long mult = blkSize / 1024; | 1811 | long mult = blkSize / 1024; |
1812 | long div = 1024 / blkSize; | 1812 | long div = 1024 / blkSize; |
1813 | 1813 | ||
1814 | if ( !mult ) mult = 1; | 1814 | if ( !mult ) mult = 1; |
1815 | if ( !div ) div = 1; | 1815 | if ( !div ) div = 1; |
1816 | 1816 | ||
1817 | return availBlks * mult / div; | 1817 | return availBlks * mult / div; |
1818 | } | 1818 | } |
1819 | return -1; | 1819 | return -1; |
1820 | } | 1820 | } |
1821 | 1821 | ||
1822 | // short f_fstyp; /* File system type */ | 1822 | // short f_fstyp; /* File system type */ |
1823 | // long f_bsize; /* Block size */ | 1823 | // long f_bsize; /* Block size */ |
1824 | // long f_frsize; /* Fragment size */ | 1824 | // long f_frsize; /* Fragment size */ |
1825 | // long f_blocks; /* Total number of blocks*/ | 1825 | // long f_blocks; /* Total number of blocks*/ |
1826 | // long f_bfree; /* Count of free blocks */ | 1826 | // long f_bfree; /* Count of free blocks */ |
1827 | // long f_files; /* Total number of file nodes */ | 1827 | // long f_files; /* Total number of file nodes */ |
1828 | // long f_ffree; /* Count of free file nodes */ | 1828 | // long f_ffree; /* Count of free file nodes */ |
1829 | // char f_fname[6]; /* Volumename */ | 1829 | // char f_fname[6]; /* Volumename */ |
1830 | // char f_fpack[6]; /* Pack name */ | 1830 | // char f_fpack[6]; /* Pack name */ |
1831 | 1831 | ||
1832 | void QtRec::receive( const QCString &msg, const QByteArray & ) { | 1832 | void QtRec::receive( const QCString &msg, const QByteArray & ) { |
1833 | qDebug("Voicerecord received message "+msg); | 1833 | qDebug("Voicerecord received message "+msg); |
1834 | 1834 | ||
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | 1837 | ||
1838 | ///////////////////////////// timerEvent | 1838 | ///////////////////////////// timerEvent |
1839 | void QtRec::timerEvent( QTimerEvent * ) { | 1839 | void QtRec::timerEvent( QTimerEvent * ) { |
1840 | 1840 | ||
1841 | // if(!recording) | 1841 | // if(!recording) |
1842 | // timeSlider->setValue( secCount); | 1842 | // timeSlider->setValue( secCount); |
1843 | // else | 1843 | // else |
1844 | // timeSlider->setValue( filePara.numberOfRecordedSeconds); | 1844 | // timeSlider->setValue( filePara.numberOfRecordedSeconds); |
1845 | 1845 | ||
1846 | if( stopped && playing) { | 1846 | if( stopped && playing) { |
1847 | stop(); | 1847 | stop(); |
1848 | } | 1848 | } |
1849 | 1849 | ||
1850 | if( stopped && recording ){ | 1850 | if( stopped && recording ){ |
1851 | stop(); | 1851 | stop(); |
1852 | } | 1852 | } |
1853 | 1853 | ||
1854 | if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { | 1854 | if( recording && filePara.SecondsToRecord < secCount && filePara.SecondsToRecord != 0) { |
1855 | stop(); | 1855 | stop(); |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | qDebug( "%d", secCount ); | 1858 | qDebug( "%d", secCount ); |
1859 | QString timeString; | 1859 | QString timeString; |
1860 | #ifdef DEV_VERSION | 1860 | #ifdef DEV_VERSION |
1861 | QString msg; | 1861 | QString msg; |
1862 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1862 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
1863 | setCaption( msg +" :: "+QString::number(secCount)); | 1863 | setCaption( msg +" :: "+QString::number(secCount)); |
1864 | #endif | 1864 | #endif |
1865 | 1865 | ||
1866 | timeString.sprintf("%d", secCount); | 1866 | timeString.sprintf("%d", secCount); |
1867 | timeLabel->setText( timeString + " seconds"); | 1867 | timeLabel->setText( timeString + " seconds"); |
1868 | 1868 | ||
1869 | secCount++; | 1869 | secCount++; |
1870 | } | 1870 | } |
1871 | 1871 | ||
1872 | void QtRec::changeTimeSlider(int index) { | 1872 | void QtRec::changeTimeSlider(int index) { |
1873 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; | 1873 | if( ListView1->currentItem() == 0 || !wavFile->track.isOpen()) return; |
1874 | // qDebug("Slider moved to %d",index); | 1874 | // qDebug("Slider moved to %d",index); |
1875 | paused = true; | 1875 | paused = true; |
1876 | stopped = true; | 1876 | stopped = true; |
1877 | 1877 | ||
1878 | sliderPos=index; | 1878 | sliderPos=index; |
1879 | 1879 | ||
1880 | QString timeString; | 1880 | QString timeString; |
1881 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1881 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1882 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1882 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1883 | secCount = (int)filePara.numberOfRecordedSeconds; | 1883 | secCount = (int)filePara.numberOfRecordedSeconds; |
1884 | timeLabel->setText( timeString + tr(" seconds")); | 1884 | timeLabel->setText( timeString + tr(" seconds")); |
1885 | } | 1885 | } |
1886 | 1886 | ||
1887 | void QtRec::timeSliderPressed() { | 1887 | void QtRec::timeSliderPressed() { |
1888 | if( ListView1->currentItem() == 0) return; | 1888 | if( ListView1->currentItem() == 0) return; |
1889 | // qDebug("slider pressed"); | 1889 | // qDebug("slider pressed"); |
1890 | paused = true; | 1890 | paused = true; |
1891 | stopped = true; | 1891 | stopped = true; |
1892 | } | 1892 | } |
1893 | 1893 | ||
1894 | void QtRec::timeSliderReleased() { | 1894 | void QtRec::timeSliderReleased() { |
1895 | if( ListView1->currentItem() == 0) return; | 1895 | if( ListView1->currentItem() == 0) return; |
1896 | sliderPos = timeSlider->value(); | 1896 | sliderPos = timeSlider->value(); |
1897 | 1897 | ||
1898 | // qDebug("slider released %d", sliderPos); | 1898 | // qDebug("slider released %d", sliderPos); |
1899 | stopped = false; | 1899 | stopped = false; |
1900 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1900 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1901 | total = newPos*4; | 1901 | total = newPos*4; |
1902 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1902 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1903 | 1903 | ||
1904 | doPlay(); | 1904 | doPlay(); |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | void QtRec::rewindPressed() { | 1907 | void QtRec::rewindPressed() { |
1908 | if( ListView1->currentItem() == 0) return; | 1908 | if( ListView1->currentItem() == 0) return; |
1909 | if( !wavFile->track.isOpen()) { | 1909 | if( !wavFile->track.isOpen()) { |
1910 | if( !openPlayFile() ) | 1910 | if( !openPlayFile() ) |
1911 | return; | 1911 | return; |
1912 | else | 1912 | else |
1913 | if( !setupAudio( false)) | 1913 | if( !setupAudio( false)) |
1914 | return; | 1914 | return; |
1915 | } else { | 1915 | } else { |
1916 | killTimers(); | 1916 | killTimers(); |
1917 | paused = true; | 1917 | paused = true; |
1918 | stopped = true; | 1918 | stopped = true; |
1919 | rewindTimer->start( 50, false); | 1919 | rewindTimer->start( 50, false); |
1920 | } | 1920 | } |
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | void QtRec::rewindTimerTimeout() { | 1923 | void QtRec::rewindTimerTimeout() { |
1924 | int sliderValue = timeSlider->value(); | 1924 | int sliderValue = timeSlider->value(); |
1925 | sliderValue = sliderValue - ( filePara.numberSamples / 100); | 1925 | sliderValue = sliderValue - ( filePara.numberSamples / 100); |
1926 | // if(toBeginningButton->isDown()) | 1926 | // if(toBeginningButton->isDown()) |
1927 | timeSlider->setValue( sliderValue ) ; | 1927 | timeSlider->setValue( sliderValue ) ; |
1928 | // qDebug("%d", sliderValue); | 1928 | // qDebug("%d", sliderValue); |
1929 | QString timeString; | 1929 | QString timeString; |
1930 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; | 1930 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; |
1931 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1931 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1932 | timeLabel->setText( timeString+ tr(" seconds")); | 1932 | timeLabel->setText( timeString+ tr(" seconds")); |
1933 | } | 1933 | } |
1934 | 1934 | ||
1935 | void QtRec::rewindReleased() { | 1935 | void QtRec::rewindReleased() { |
1936 | rewindTimer->stop(); | 1936 | rewindTimer->stop(); |
1937 | if( wavFile->track.isOpen()) { | 1937 | if( wavFile->track.isOpen()) { |
1938 | sliderPos=timeSlider->value(); | 1938 | sliderPos=timeSlider->value(); |
1939 | stopped = false; | 1939 | stopped = false; |
1940 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1940 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1941 | total = newPos * 4; | 1941 | total = newPos * 4; |
1942 | // qDebug("rewind released %d", total); | 1942 | // qDebug("rewind released %d", total); |
1943 | startTimer( 1000); | 1943 | startTimer( 1000); |
1944 | doPlay(); | 1944 | doPlay(); |
1945 | } | 1945 | } |
1946 | } | 1946 | } |
1947 | 1947 | ||
1948 | void QtRec::FastforwardPressed() { | 1948 | void QtRec::FastforwardPressed() { |
1949 | if( ListView1->currentItem() == 0) return; | 1949 | if( ListView1->currentItem() == 0) return; |
1950 | if( !wavFile->track.isOpen()) | 1950 | if( !wavFile->track.isOpen()) |
1951 | if( !openPlayFile() ) | 1951 | if( !openPlayFile() ) |
1952 | return; | 1952 | return; |
1953 | else | 1953 | else |
1954 | if( !setupAudio( false)) | 1954 | if( !setupAudio( false)) |
1955 | return; | 1955 | return; |
1956 | killTimers(); | 1956 | killTimers(); |
1957 | 1957 | ||
1958 | paused = true; | 1958 | paused = true; |
1959 | stopped = true; | 1959 | stopped = true; |
1960 | forwardTimer->start(50, false); | 1960 | forwardTimer->start(50, false); |
1961 | } | 1961 | } |
1962 | 1962 | ||
1963 | 1963 | ||
1964 | void QtRec::forwardTimerTimeout() { | 1964 | void QtRec::forwardTimerTimeout() { |
1965 | int sliderValue = timeSlider->value(); | 1965 | int sliderValue = timeSlider->value(); |
1966 | sliderValue = sliderValue + ( filePara.numberSamples / 100); | 1966 | sliderValue = sliderValue + ( filePara.numberSamples / 100); |
1967 | 1967 | ||
1968 | // if(toEndButton->isDown()) | 1968 | // if(toEndButton->isDown()) |
1969 | timeSlider->setValue( sliderValue); | 1969 | timeSlider->setValue( sliderValue); |
1970 | 1970 | ||
1971 | QString timeString; | 1971 | QString timeString; |
1972 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; | 1972 | filePara.numberOfRecordedSeconds = (float)sliderValue / (float)filePara.sampleRate * (float)2; |
1973 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); | 1973 | timeString.sprintf( "%.2f", filePara.numberOfRecordedSeconds); |
1974 | timeLabel->setText( timeString+ tr(" seconds")); | 1974 | timeLabel->setText( timeString+ tr(" seconds")); |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | void QtRec::FastforwardReleased() { | 1977 | void QtRec::FastforwardReleased() { |
1978 | forwardTimer->stop(); | 1978 | forwardTimer->stop(); |
1979 | if( wavFile->track.isOpen()) { | 1979 | if( wavFile->track.isOpen()) { |
1980 | sliderPos=timeSlider->value(); | 1980 | sliderPos=timeSlider->value(); |
1981 | stopped = false; | 1981 | stopped = false; |
1982 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); | 1982 | int newPos = lseek( filePara.fd, sliderPos, SEEK_SET); |
1983 | total = newPos * 4; | 1983 | total = newPos * 4; |
1984 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; | 1984 | filePara.numberOfRecordedSeconds = (float)sliderPos / (float)filePara.sampleRate * (float)2; |
1985 | startTimer( 1000); | 1985 | startTimer( 1000); |
1986 | doPlay(); | 1986 | doPlay(); |
1987 | } | 1987 | } |
1988 | } | 1988 | } |
1989 | 1989 | ||
1990 | 1990 | ||
1991 | QString QtRec::getStorage(const QString &fileName) { | 1991 | QString QtRec::getStorage(const QString &fileName) { |
1992 | 1992 | ||
1993 | StorageInfo storageInfo; | 1993 | StorageInfo storageInfo; |
1994 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1994 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1995 | QListIterator<FileSystem> it ( fs ); | 1995 | QListIterator<FileSystem> it ( fs ); |
1996 | QString storage; | 1996 | QString storage; |
1997 | for( ; it.current(); ++it ){ | 1997 | for( ; it.current(); ++it ){ |
1998 | const QString name = ( *it)->name(); | 1998 | const QString name = ( *it)->name(); |
1999 | const QString path = ( *it)->path(); | 1999 | const QString path = ( *it)->path(); |
2000 | const QString disk = ( *it)->disk(); | 2000 | const QString disk = ( *it)->disk(); |
2001 | if( fileName.find( path,0,true) != -1) | 2001 | if( fileName.find( path,0,true) != -1) |
2002 | storage = name; | 2002 | storage = name; |
2003 | // const QString options = (*it)->options(); | 2003 | // const QString options = (*it)->options(); |
2004 | // if( name.find( tr("Internal"),0,true) == -1) { | 2004 | // if( name.find( tr("Internal"),0,true) == -1) { |
2005 | // storageComboBox->insertItem( name +" -> "+disk); | 2005 | // storageComboBox->insertItem( name +" -> "+disk); |
2006 | // qDebug(name); | 2006 | // qDebug(name); |
2007 | } | 2007 | } |
2008 | return storage; | 2008 | return storage; |
2009 | // struct mntent *me; | 2009 | // struct mntent *me; |
2010 | // // if(fileName == "/etc/mtab") { | 2010 | // // if(fileName == "/etc/mtab") { |
2011 | // FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 2011 | // FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
2012 | // if ( mntfp ) { | 2012 | // if ( mntfp ) { |
2013 | // while ( (me = getmntent( mntfp )) != 0 ) { | 2013 | // while ( (me = getmntent( mntfp )) != 0 ) { |
2014 | // QString filesystemType = me->mnt_type; | 2014 | // QString filesystemType = me->mnt_type; |
2015 | 2015 | ||
2016 | // } | 2016 | // } |
2017 | // } | 2017 | // } |
2018 | // endmntent( mntfp ); | 2018 | // endmntent( mntfp ); |
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | void QtRec::setRecordButton(bool b) { | 2021 | void QtRec::setRecordButton(bool b) { |
2022 | 2022 | ||
2023 | if(b) { //about to record or play | 2023 | if(b) { //about to record or play |
2024 | 2024 | ||
2025 | Rec_PushButton->setDown( true); | 2025 | Rec_PushButton->setDown( true); |
2026 | QPixmap image3( ( const char** ) image3_data ); | 2026 | QPixmap image3( ( const char** ) image3_data ); |
2027 | Stop_PushButton->setPixmap( image3 ); | 2027 | Stop_PushButton->setPixmap( image3 ); |
2028 | if(Stop_PushButton->isDown()) | 2028 | if(Stop_PushButton->isDown()) |
2029 | Stop_PushButton->setDown( true); | 2029 | Stop_PushButton->setDown( true); |
2030 | playLabel2->setText( tr("Stop") ); | 2030 | playLabel2->setText( tr("Stop") ); |
2031 | 2031 | ||
2032 | } else { //about to stop | 2032 | } else { //about to stop |
2033 | 2033 | ||
2034 | QPixmap image4( ( const char** ) image4_data ); | 2034 | QPixmap image4( ( const char** ) image4_data ); |
2035 | Stop_PushButton->setPixmap( image4); | 2035 | Stop_PushButton->setPixmap( image4); |
2036 | if(Stop_PushButton->isDown()) | 2036 | if(Stop_PushButton->isDown()) |
2037 | Stop_PushButton->setDown( false); | 2037 | Stop_PushButton->setDown( false); |
2038 | playLabel2->setText( tr("Play") ); | 2038 | playLabel2->setText( tr("Play") ); |
2039 | if(Rec_PushButton->isDown()) | 2039 | if(Rec_PushButton->isDown()) |
2040 | Rec_PushButton->setDown( false); | 2040 | Rec_PushButton->setDown( false); |
2041 | } | 2041 | } |
2042 | } | 2042 | } |
2043 | 2043 | ||
diff --git a/noncore/multimedia/powerchord/powerchordbase.cpp b/noncore/multimedia/powerchord/powerchordbase.cpp index 0b97984..7978426 100644 --- a/noncore/multimedia/powerchord/powerchordbase.cpp +++ b/noncore/multimedia/powerchord/powerchordbase.cpp | |||
@@ -3,590 +3,590 @@ | |||
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" | 13 | #include "gs.h" |
14 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
15 | #include <qframe.h> | 15 | #include <qframe.h> |
16 | #include <qlabel.h> | 16 | #include <qlabel.h> |
17 | #include <qlistbox.h> | 17 | #include <qlistbox.h> |
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <qtabwidget.h> | 20 | #include <qtabwidget.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qvariant.h> | 22 | #include <qvariant.h> |
23 | #include <qtooltip.h> | 23 | #include <qtooltip.h> |
24 | #include <qwhatsthis.h> | 24 | #include <qwhatsthis.h> |
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qbitmap.h> | 27 | #include <qbitmap.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | 29 | ||
30 | 30 | ||
31 | /* | 31 | /* |
32 | * Constructs a PowerchordBase which is a child of 'parent', with the | 32 | * Constructs a PowerchordBase which is a child of 'parent', with the |
33 | * name 'name' and widget flags set to 'f' | 33 | * name 'name' and widget flags set to 'f' |
34 | */ | 34 | */ |
35 | PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) | 35 | PowerchordBase::PowerchordBase( QWidget* parent, const char* name, WFlags fl ) |
36 | : QWidget( parent, name, fl ) | 36 | : QWidget( parent, name, fl ) |
37 | { | 37 | { |
38 | simulation_timer = 0; | 38 | simulation_timer = 0; |
39 | audio_timer = 0; | 39 | audio_timer = 0; |
40 | 40 | ||
41 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); | 41 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); |
42 | 42 | ||
43 | // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); | 43 | // QPixmap image0(QString("/opt/Qtopia/pics/powerchord/image0")); |
44 | QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); | 44 | QPixmap image1 = Resource::loadPixmap( "powerchord/image1"); |
45 | QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); | 45 | QPixmap image2 = Resource::loadPixmap( "powerchord/image2"); |
46 | QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); | 46 | QPixmap image3 = Resource::loadPixmap( "powerchord/image3"); |
47 | QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); | 47 | QPixmap image4 = Resource::loadPixmap( "powerchord/image4"); |
48 | QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); | 48 | QPixmap image5 = Resource::loadPixmap( "powerchord/image5"); |
49 | image6 = Resource::loadPixmap( "powerchord/image6"); | 49 | image6 = Resource::loadPixmap( "powerchord/image6"); |
50 | image_open = Resource::loadPixmap( "powerchord/image_open"); | 50 | image_open = Resource::loadPixmap( "powerchord/image_open"); |
51 | 51 | ||
52 | // image0.setMask(image0.createHeuristicMask()); | 52 | // image0.setMask(image0.createHeuristicMask()); |
53 | image1.setMask(image1.createHeuristicMask()); | 53 | image1.setMask(image1.createHeuristicMask()); |
54 | // image2.setMask(image2.createHeuristicMask()); | 54 | // image2.setMask(image2.createHeuristicMask()); |
55 | // image3.setMask(image3.createHeuristicMask()); | 55 | // image3.setMask(image3.createHeuristicMask()); |
56 | // image4.setMask(image4.createHeuristicMask()); | 56 | // image4.setMask(image4.createHeuristicMask()); |
57 | // image5.setMask(image5.createHeuristicMask()); | 57 | // image5.setMask(image5.createHeuristicMask()); |
58 | // image6->setMask(image6->createHeuristicMask()); | 58 | // image6->setMask(image6->createHeuristicMask()); |
59 | // image_open->setMask(image_open->createHeuristicMask()); | 59 | // image_open->setMask(image_open->createHeuristicMask()); |
60 | 60 | ||
61 | if ( !name ) | 61 | if ( !name ) |
62 | setName( "PowerchordBase" ); | 62 | setName( "PowerchordBase" ); |
63 | resize( 240, 284 ); | 63 | resize( 240, 284 ); |
64 | setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); | 64 | setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, sizePolicy().hasHeightForWidth() ) ); |
65 | setMinimumSize( QSize( 240, 284 ) ); | 65 | setMinimumSize( QSize( 240, 284 ) ); |
66 | setMaximumSize( QSize( 240, 284 ) ); | 66 | setMaximumSize( QSize( 240, 284 ) ); |
67 | setCaption( tr( "Powerchord" ) ); | 67 | setCaption( tr( "Powerchord" ) ); |
68 | 68 | ||
69 | tabs = new QTabWidget( this, "tabs" ); | 69 | tabs = new QTabWidget( this, "tabs" ); |
70 | tabs->setEnabled( TRUE ); | 70 | tabs->setEnabled( TRUE ); |
71 | tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); | 71 | tabs->setGeometry( QRect( 0, 0, 240, 286 ) ); |
72 | tabs->setTabPosition( QTabWidget::Bottom ); | 72 | tabs->setTabPosition( QTabWidget::Bottom ); |
73 | 73 | ||
74 | tab = new QWidget( tabs, "tab" ); | 74 | tab = new QWidget( tabs, "tab" ); |
75 | 75 | ||
76 | chordkey = new QComboBox( FALSE, tab, "chordkey" ); | 76 | chordkey = new QComboBox( FALSE, tab, "chordkey" ); |
77 | chordkey->insertItem( tr( "maj" ) ); | 77 | chordkey->insertItem( tr( "maj" ) ); |
78 | chordkey->insertItem( tr( "min" ) ); | 78 | chordkey->insertItem( tr( "min" ) ); |
79 | chordkey->insertItem( tr( "7th" ) ); | 79 | chordkey->insertItem( tr( "7th" ) ); |
80 | chordkey->insertItem( tr( "m7" ) ); | 80 | chordkey->insertItem( tr( "m7" ) ); |
81 | chordkey->insertItem( tr( "maj7" ) ); | 81 | chordkey->insertItem( tr( "maj7" ) ); |
82 | chordkey->insertItem( tr( "6th" ) ); | 82 | chordkey->insertItem( tr( "6th" ) ); |
83 | chordkey->insertItem( tr( "m6th" ) ); | 83 | chordkey->insertItem( tr( "m6th" ) ); |
84 | chordkey->insertItem( tr( "aug" ) ); | 84 | chordkey->insertItem( tr( "aug" ) ); |
85 | chordkey->insertItem( tr( "dim" ) ); | 85 | chordkey->insertItem( tr( "dim" ) ); |
86 | chordkey->insertItem( tr( "sus4" ) ); | 86 | chordkey->insertItem( tr( "sus4" ) ); |
87 | chordkey->insertItem( tr( "7sus4" ) ); | 87 | chordkey->insertItem( tr( "7sus4" ) ); |
88 | chordkey->insertItem( tr( "9th" ) ); | 88 | chordkey->insertItem( tr( "9th" ) ); |
89 | chordkey->insertItem( tr( "add9" ) ); | 89 | chordkey->insertItem( tr( "add9" ) ); |
90 | chordkey->insertItem( tr( "m9th" ) ); | 90 | chordkey->insertItem( tr( "m9th" ) ); |
91 | chordkey->insertItem( tr( "maj9" ) ); | 91 | chordkey->insertItem( tr( "maj9" ) ); |
92 | chordkey->insertItem( tr( "sus2" ) ); | 92 | chordkey->insertItem( tr( "sus2" ) ); |
93 | chordkey->insertItem( tr( "7sus2" ) ); | 93 | chordkey->insertItem( tr( "7sus2" ) ); |
94 | chordkey->insertItem( tr( "11th" ) ); | 94 | chordkey->insertItem( tr( "11th" ) ); |
95 | chordkey->insertItem( tr( "m11th" ) ); | 95 | chordkey->insertItem( tr( "m11th" ) ); |
96 | chordkey->insertItem( tr( "13th" ) ); | 96 | chordkey->insertItem( tr( "13th" ) ); |
97 | chordkey->insertItem( tr( "m13th" ) ); | 97 | chordkey->insertItem( tr( "m13th" ) ); |
98 | chordkey->insertItem( tr( "maj13" ) ); | 98 | chordkey->insertItem( tr( "maj13" ) ); |
99 | chordkey->insertItem( tr( "6/9" ) ); | 99 | chordkey->insertItem( tr( "6/9" ) ); |
100 | chordkey->insertItem( tr( "flat5" ) ); | 100 | chordkey->insertItem( tr( "flat5" ) ); |
101 | chordkey->insertItem( tr( "7#9" ) ); | 101 | chordkey->insertItem( tr( "7#9" ) ); |
102 | chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); | 102 | chordkey->insertItem( tr( QString::fromUtf8( "ø7" ) ) ); |
103 | chordkey->insertItem( tr( "5" ) ); | 103 | chordkey->insertItem( tr( "5" ) ); |
104 | chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); | 104 | chordkey->setGeometry( QRect( 40, 0, 51, 21 ) ); |
105 | 105 | ||
106 | chordfret = new QComboBox( FALSE, tab, "chordfret" ); | 106 | chordfret = new QComboBox( FALSE, tab, "chordfret" ); |
107 | chordfret->insertItem( tr( "open" ) ); | 107 | chordfret->insertItem( tr( "open" ) ); |
108 | chordfret->insertItem( tr( "1st" ) ); | 108 | chordfret->insertItem( tr( "1st" ) ); |
109 | chordfret->insertItem( tr( "2nd" ) ); | 109 | chordfret->insertItem( tr( "2nd" ) ); |
110 | chordfret->insertItem( tr( "3rd" ) ); | 110 | chordfret->insertItem( tr( "3rd" ) ); |
111 | chordfret->insertItem( tr( "4th" ) ); | 111 | chordfret->insertItem( tr( "4th" ) ); |
112 | chordfret->insertItem( tr( "5th" ) ); | 112 | chordfret->insertItem( tr( "5th" ) ); |
113 | chordfret->insertItem( tr( "6th" ) ); | 113 | chordfret->insertItem( tr( "6th" ) ); |
114 | chordfret->insertItem( tr( "7th" ) ); | 114 | chordfret->insertItem( tr( "7th" ) ); |
115 | chordfret->insertItem( tr( "8th" ) ); | 115 | chordfret->insertItem( tr( "8th" ) ); |
116 | chordfret->insertItem( tr( "9th" ) ); | 116 | chordfret->insertItem( tr( "9th" ) ); |
117 | chordfret->insertItem( tr( "10th" ) ); | 117 | chordfret->insertItem( tr( "10th" ) ); |
118 | chordfret->insertItem( tr( "11th" ) ); | 118 | chordfret->insertItem( tr( "11th" ) ); |
119 | chordfret->insertItem( tr( "12th" ) ); | 119 | chordfret->insertItem( tr( "12th" ) ); |
120 | chordfret->insertItem( tr( "13th" ) ); | 120 | chordfret->insertItem( tr( "13th" ) ); |
121 | chordfret->insertItem( tr( "14th" ) ); | 121 | chordfret->insertItem( tr( "14th" ) ); |
122 | chordfret->insertItem( tr( "15th" ) ); | 122 | chordfret->insertItem( tr( "15th" ) ); |
123 | chordfret->insertItem( tr( "16th" ) ); | 123 | chordfret->insertItem( tr( "16th" ) ); |
124 | chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width | 124 | chordfret->setGeometry( QRect( 90, 0, 55, 21 ) ); //cxm less 5 width |
125 | 125 | ||
126 | chordnote = new QComboBox( FALSE, tab, "chordnote" ); | 126 | chordnote = new QComboBox( FALSE, tab, "chordnote" ); |
127 | chordnote->insertItem( tr( "C" ) ); | 127 | chordnote->insertItem( tr( "C" ) ); |
128 | chordnote->insertItem( tr( "C#" ) ); | 128 | chordnote->insertItem( tr( "C#" ) ); |
129 | chordnote->insertItem( tr( "D" ) ); | 129 | chordnote->insertItem( tr( "D" ) ); |
130 | chordnote->insertItem( tr( "Eb" ) ); | 130 | chordnote->insertItem( tr( "Eb" ) ); |
131 | chordnote->insertItem( tr( "E" ) ); | 131 | chordnote->insertItem( tr( "E" ) ); |
132 | chordnote->insertItem( tr( "F" ) ); | 132 | chordnote->insertItem( tr( "F" ) ); |
133 | chordnote->insertItem( tr( "F#" ) ); | 133 | chordnote->insertItem( tr( "F#" ) ); |
134 | chordnote->insertItem( tr( "G" ) ); | 134 | chordnote->insertItem( tr( "G" ) ); |
135 | chordnote->insertItem( tr( "G#" ) ); | 135 | chordnote->insertItem( tr( "G#" ) ); |
136 | chordnote->insertItem( tr( "A" ) ); | 136 | chordnote->insertItem( tr( "A" ) ); |
137 | chordnote->insertItem( tr( "Bb" ) ); | 137 | chordnote->insertItem( tr( "Bb" ) ); |
138 | chordnote->insertItem( tr( "B" ) ); | 138 | chordnote->insertItem( tr( "B" ) ); |
139 | chordnote->setGeometry( QRect( 0, 0, 40, 21 ) ); | 139 | chordnote->setGeometry( QRect( 0, 0, 40, 21 ) ); |
140 | chordnote->setCurrentItem( 9 ); | 140 | chordnote->setCurrentItem( 9 ); |
141 | 141 | ||
142 | QWidget* privateLayoutWidget = new QWidget( tab, "Layout1" ); | 142 | QWidget* privateLayoutWidget = new QWidget( tab, "Layout1" ); |
143 | privateLayoutWidget->setGeometry( QRect( 5, 232, 160, 20 ) ); | 143 | privateLayoutWidget->setGeometry( QRect( 5, 232, 160, 20 ) ); |
144 | Layout1 = new QHBoxLayout( privateLayoutWidget ); | 144 | Layout1 = new QHBoxLayout( privateLayoutWidget ); |
145 | Layout1->setSpacing( 6 ); | 145 | Layout1->setSpacing( 6 ); |
146 | Layout1->setMargin( 0 ); | 146 | Layout1->setMargin( 0 ); |
147 | 147 | ||
148 | s1_1 = new QLabel( privateLayoutWidget, "s1_1" ); | 148 | s1_1 = new QLabel( privateLayoutWidget, "s1_1" ); |
149 | s1_1->setText( tr( "E" ) ); | 149 | s1_1->setText( tr( "E" ) ); |
150 | s1_1->setAlignment( int( QLabel::AlignCenter ) ); | 150 | s1_1->setAlignment( int( QLabel::AlignCenter ) ); |
151 | Layout1->addWidget( s1_1 ); | 151 | Layout1->addWidget( s1_1 ); |
152 | 152 | ||
153 | s1_2 = new QLabel( privateLayoutWidget, "s1_2" ); | 153 | s1_2 = new QLabel( privateLayoutWidget, "s1_2" ); |
154 | s1_2->setText( tr( "A" ) ); | 154 | s1_2->setText( tr( "A" ) ); |
155 | s1_2->setAlignment( int( QLabel::AlignCenter ) ); | 155 | s1_2->setAlignment( int( QLabel::AlignCenter ) ); |
156 | Layout1->addWidget( s1_2 ); | 156 | Layout1->addWidget( s1_2 ); |
157 | 157 | ||
158 | s1_3 = new QLabel( privateLayoutWidget, "s1_3" ); | 158 | s1_3 = new QLabel( privateLayoutWidget, "s1_3" ); |
159 | s1_3->setText( tr( "E" ) ); | 159 | s1_3->setText( tr( "E" ) ); |
160 | s1_3->setAlignment( int( QLabel::AlignCenter ) ); | 160 | s1_3->setAlignment( int( QLabel::AlignCenter ) ); |
161 | Layout1->addWidget( s1_3 ); | 161 | Layout1->addWidget( s1_3 ); |
162 | 162 | ||
163 | s1_4 = new QLabel( privateLayoutWidget, "s1_4" ); | 163 | s1_4 = new QLabel( privateLayoutWidget, "s1_4" ); |
164 | s1_4->setText( tr( "A" ) ); | 164 | s1_4->setText( tr( "A" ) ); |
165 | s1_4->setAlignment( int( QLabel::AlignCenter ) ); | 165 | s1_4->setAlignment( int( QLabel::AlignCenter ) ); |
166 | Layout1->addWidget( s1_4 ); | 166 | Layout1->addWidget( s1_4 ); |
167 | 167 | ||
168 | s1_5 = new QLabel( privateLayoutWidget, "s1_5" ); | 168 | s1_5 = new QLabel( privateLayoutWidget, "s1_5" ); |
169 | s1_5->setText( tr( "C#" ) ); | 169 | s1_5->setText( tr( "C#" ) ); |
170 | s1_5->setAlignment( int( QLabel::AlignCenter ) ); | 170 | s1_5->setAlignment( int( QLabel::AlignCenter ) ); |
171 | Layout1->addWidget( s1_5 ); | 171 | Layout1->addWidget( s1_5 ); |
172 | 172 | ||
173 | s1_6 = new QLabel( privateLayoutWidget, "s1_6" ); | 173 | s1_6 = new QLabel( privateLayoutWidget, "s1_6" ); |
174 | s1_6->setText( tr( "E" ) ); | 174 | s1_6->setText( tr( "E" ) ); |
175 | s1_6->setAlignment( int( QLabel::AlignCenter ) ); | 175 | s1_6->setAlignment( int( QLabel::AlignCenter ) ); |
176 | Layout1->addWidget( s1_6 ); | 176 | Layout1->addWidget( s1_6 ); |
177 | 177 | ||
178 | // sound_label = new QLabel( tab, "sound_label" ); | 178 | // sound_label = new QLabel( tab, "sound_label" ); |
179 | // sound_label->setGeometry( QRect( 185, 160, 32, 17 ) ); | 179 | // sound_label->setGeometry( QRect( 185, 160, 32, 17 ) ); |
180 | // sound_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sound_label->sizePolicy().hasHeightForWidth() ) ); | 180 | // sound_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sound_label->sizePolicy().hasHeightForWidth() ) ); |
181 | // sound_label->setPixmap( image0 ); | 181 | // sound_label->setPixmap( image0 ); |
182 | // sound_label->pixmap()->setMask(*image0.mask()); | 182 | // sound_label->pixmap()->setMask(*image0.mask()); |
183 | // sound_label->setScaledContents( TRUE ); | 183 | // sound_label->setScaledContents( TRUE ); |
184 | // sound_label->setBackgroundMode( QWidget::PaletteButton ); | 184 | // sound_label->setBackgroundMode( QWidget::PaletteButton ); |
185 | // sound_label->setBackgroundColor(this->backgroundColor()); | 185 | // sound_label->setBackgroundColor(this->backgroundColor()); |
186 | // sound_label->setPalette( QPalette( QColor( 232, 227, 215) ) ); | 186 | // sound_label->setPalette( QPalette( QColor( 232, 227, 215) ) ); |
187 | 187 | ||
188 | 188 | ||
189 | Frame6 = new QFrame( tab, "Frame6" ); | 189 | Frame6 = new QFrame( tab, "Frame6" ); |
190 | Frame6->setGeometry( QRect( 170, 145, 66, 10 ) ); | 190 | Frame6->setGeometry( QRect( 170, 145, 66, 10 ) ); |
191 | Frame6->setFrameShape( QFrame::HLine ); | 191 | Frame6->setFrameShape( QFrame::HLine ); |
192 | Frame6->setFrameShadow( QFrame::Raised ); | 192 | Frame6->setFrameShadow( QFrame::Raised ); |
193 | 193 | ||
194 | chordshow_label = new QLabel( tab, "chordshow_label" ); | 194 | chordshow_label = new QLabel( tab, "chordshow_label" ); |
195 | chordshow_label->setGeometry( QRect( 185, 60, 32, 17 ) ); | 195 | chordshow_label->setGeometry( QRect( 185, 60, 32, 17 ) ); |
196 | // chordshow_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, chordshow_label->sizePolicy().hasHeightForWidth() ) ); | 196 | // chordshow_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, chordshow_label->sizePolicy().hasHeightForWidth() ) ); |
197 | chordshow_label->setFrameShape( QLabel::NoFrame ); | 197 | chordshow_label->setFrameShape( QLabel::NoFrame ); |
198 | chordshow_label->setPixmap( image1 ); | 198 | chordshow_label->setPixmap( image1 ); |
199 | chordshow_label->setScaledContents( TRUE ); | 199 | chordshow_label->setScaledContents( TRUE ); |
200 | // chordshow_label->setBackgroundMode( QWidget::PaletteButton ); | 200 | // chordshow_label->setBackgroundMode( QWidget::PaletteButton ); |
201 | 201 | ||
202 | transport_rec = new QPushButton( tab, "transport_rec" ); | 202 | transport_rec = new QPushButton( tab, "transport_rec" ); |
203 | transport_rec->setGeometry( QRect( 170, 80, 30, 30 ) ); | 203 | transport_rec->setGeometry( QRect( 170, 80, 30, 30 ) ); |
204 | transport_rec->setText( tr( "" ) ); | 204 | transport_rec->setText( tr( "" ) ); |
205 | transport_rec->setPixmap( image2 ); | 205 | transport_rec->setPixmap( image2 ); |
206 | 206 | ||
207 | play_sound = new QPushButton( tab, "play_sound" ); | 207 | play_sound = new QPushButton( tab, "play_sound" ); |
208 | play_sound->setGeometry( QRect( 170, 180, 60, 55 ) ); | 208 | play_sound->setGeometry( QRect( 170, 180, 60, 55 ) ); |
209 | play_sound->setText( tr( "" ) ); | 209 | play_sound->setText( tr( "" ) ); |
210 | play_sound->setPixmap( image3 ); | 210 | play_sound->setPixmap( image3 ); |
211 | 211 | ||
212 | Frame6_2 = new QFrame( tab, "Frame6_2" ); | 212 | Frame6_2 = new QFrame( tab, "Frame6_2" ); |
213 | Frame6_2->setGeometry( QRect( 170, 45, 66, 10 ) ); | 213 | Frame6_2->setGeometry( QRect( 170, 45, 66, 10 ) ); |
214 | Frame6_2->setFrameShape( QFrame::HLine ); | 214 | Frame6_2->setFrameShape( QFrame::HLine ); |
215 | Frame6_2->setFrameShadow( QFrame::Raised ); | 215 | Frame6_2->setFrameShadow( QFrame::Raised ); |
216 | 216 | ||
217 | transport_play = new QPushButton( tab, "transport_play" ); | 217 | transport_play = new QPushButton( tab, "transport_play" ); |
218 | transport_play->setEnabled( FALSE ); | 218 | transport_play->setEnabled( FALSE ); |
219 | transport_play->setGeometry( QRect( 200, 80, 30, 30 ) ); | 219 | transport_play->setGeometry( QRect( 200, 80, 30, 30 ) ); |
220 | transport_play->setText( tr( "" ) ); | 220 | transport_play->setText( tr( "" ) ); |
221 | transport_play->setPixmap( image3 ); | 221 | transport_play->setPixmap( image3 ); |
222 | 222 | ||
223 | transport_rew = new QPushButton( tab, "transport_rew" ); | 223 | transport_rew = new QPushButton( tab, "transport_rew" ); |
224 | transport_rew->setEnabled( FALSE ); | 224 | transport_rew->setEnabled( FALSE ); |
225 | transport_rew->setGeometry( QRect( 170, 110, 30, 30 ) ); | 225 | transport_rew->setGeometry( QRect( 170, 110, 30, 30 ) ); |
226 | transport_rew->setText( tr( "" ) ); | 226 | transport_rew->setText( tr( "" ) ); |
227 | transport_rew->setPixmap( image4 ); | 227 | transport_rew->setPixmap( image4 ); |
228 | 228 | ||
229 | transport_fwd = new QPushButton( tab, "transport_fwd" ); | 229 | transport_fwd = new QPushButton( tab, "transport_fwd" ); |
230 | transport_fwd->setEnabled( FALSE ); | 230 | transport_fwd->setEnabled( FALSE ); |
231 | transport_fwd->setGeometry( QRect( 200, 110, 30, 30 ) ); | 231 | transport_fwd->setGeometry( QRect( 200, 110, 30, 30 ) ); |
232 | transport_fwd->setText( tr( "" ) ); | 232 | transport_fwd->setText( tr( "" ) ); |
233 | transport_fwd->setPixmap( image5 ); | 233 | transport_fwd->setPixmap( image5 ); |
234 | 234 | ||
235 | chordname = new QLabel( tab, "chordname" ); | 235 | chordname = new QLabel( tab, "chordname" ); |
236 | chordname->setGeometry( QRect( 146, 0, 90, 20 ) ); //cxm moved l 5 | 236 | chordname->setGeometry( QRect( 146, 0, 90, 20 ) ); //cxm moved l 5 |
237 | chordname->setText( tr( "A" ) ); | 237 | chordname->setText( tr( "A" ) ); |
238 | chordname->setAlignment( int( QLabel::AlignCenter ) ); | 238 | chordname->setAlignment( int( QLabel::AlignCenter ) ); |
239 | QToolTip::add( chordname, tr( "" ) ); | 239 | QToolTip::add( chordname, tr( "" ) ); |
240 | 240 | ||
241 | synth = new gs(); | 241 | synth = new gs(); |
242 | tuner = new gt(); | 242 | tuner = new gt(); |
243 | frets = new FretBoard( tab, "frets" ); | 243 | frets = new FretBoard( tab, "frets" ); |
244 | frets->setGeometry( QRect( 0, 20, 168, 210 ) ); | 244 | frets->setGeometry( QRect( 0, 20, 168, 210 ) ); |
245 | tabs->insertTab( tab, tr( "Guitar" ) ); | 245 | tabs->insertTab( tab, tr( "Guitar" ) ); |
246 | 246 | ||
247 | tab_2 = new QWidget( tabs, "tab_2" ); | 247 | tab_2 = new QWidget( tabs, "tab_2" ); |
248 | 248 | ||
249 | optlab2 = new QLabel( tab_2, "optlab2" ); | 249 | optlab2 = new QLabel( tab_2, "optlab2" ); |
250 | optlab2->setGeometry( QRect( 9, 58, 120, 41 ) ); | 250 | optlab2->setGeometry( QRect( 9, 58, 120, 41 ) ); |
251 | optlab2->setText( tr( "Alternative tunings are possible" ) ); | 251 | optlab2->setText( tr( "Alternative tunings are possible" ) ); |
252 | optlab2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); | 252 | optlab2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); |
253 | 253 | ||
254 | span = new QComboBox( FALSE, tab_2, "span" ); | 254 | span = new QComboBox( FALSE, tab_2, "span" ); |
255 | span->insertItem( tr( "2" ) ); | 255 | span->insertItem( tr( "2" ) ); |
256 | span->insertItem( tr( "3" ) ); | 256 | span->insertItem( tr( "3" ) ); |
257 | span->insertItem( tr( "4" ) ); | 257 | span->insertItem( tr( "4" ) ); |
258 | span->insertItem( tr( "5" ) ); | 258 | span->insertItem( tr( "5" ) ); |
259 | span->insertItem( tr( "6" ) ); | 259 | span->insertItem( tr( "6" ) ); |
260 | span->setGeometry( QRect( 180, 20, 50, 21 ) ); | 260 | span->setGeometry( QRect( 180, 20, 50, 21 ) ); |
261 | span->setCurrentItem( 1 ); | 261 | span->setCurrentItem( 1 ); |
262 | 262 | ||
263 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); | 263 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); |
264 | TextLabel1->setGeometry( QRect( 3, 109, 226, 140 ) ); | 264 | TextLabel1->setGeometry( QRect( 3, 109, 226, 140 ) ); |
265 | TextLabel1->setText( tr( QString::fromUtf8( "©2002 Camilo Mesias\n" | 265 | TextLabel1->setText( tr( QString::fromUtf8( "©2002 Camilo Mesias\n" |
266 | "camilo@mesias.co.uk\n" | 266 | "camilo@mesias.co.uk\n" |
267 | "Version 0.0.7 beta" ) ) ); | 267 | "Version 0.0.7 beta" ) ) ); |
268 | TextLabel1->setAlignment( int( QLabel::AlignBottom | QLabel::AlignLeft ) ); | 268 | TextLabel1->setAlignment( int( QLabel::AlignBottom | QLabel::AlignLeft ) ); |
269 | 269 | ||
270 | tuning = new QComboBox( FALSE, tab_2, "tuning" ); | 270 | tuning = new QComboBox( FALSE, tab_2, "tuning" ); |
271 | tuning->insertItem( tr( "EADGBE" ) ); | 271 | tuning->insertItem( tr( "EADGBE" ) ); |
272 | tuning->insertItem( tr( "EBEG#BE" ) ); | 272 | tuning->insertItem( tr( "EBEG#BE" ) ); |
273 | tuning->insertItem( tr( "EAEAC#E" ) ); | 273 | tuning->insertItem( tr( "EAEAC#E" ) ); |
274 | tuning->insertItem( tr( "EADF#BE" ) ); | 274 | tuning->insertItem( tr( "EADF#BE" ) ); |
275 | tuning->insertItem( tr( "EADGCF" ) ); | 275 | tuning->insertItem( tr( "EADGCF" ) ); |
276 | tuning->insertItem( tr( "DADGAD" ) ); | 276 | tuning->insertItem( tr( "DADGAD" ) ); |
277 | tuning->insertItem( tr( "DGCGCD" ) ); | 277 | tuning->insertItem( tr( "DGCGCD" ) ); |
278 | tuning->insertItem( tr( "DADF#AD" ) ); | 278 | tuning->insertItem( tr( "DADF#AD" ) ); |
279 | tuning->insertItem( tr( "DADGBE" ) ); | 279 | tuning->insertItem( tr( "DADGBE" ) ); |
280 | tuning->insertItem( tr( "DGDGBD" ) ); | 280 | tuning->insertItem( tr( "DGDGBD" ) ); |
281 | tuning->insertItem( tr( "DADACD" ) ); | 281 | tuning->insertItem( tr( "DADACD" ) ); |
282 | tuning->insertItem( tr( "CGCGAE" ) ); | 282 | tuning->insertItem( tr( "CGCGAE" ) ); |
283 | tuning->insertItem( tr( "FADGBE" ) ); | 283 | tuning->insertItem( tr( "FADGBE" ) ); |
284 | tuning->insertItem( tr( "G minor" ) ); | 284 | tuning->insertItem( tr( "G minor" ) ); |
285 | tuning->setGeometry( QRect( 140, 70, 91, 21 ) ); | 285 | tuning->setGeometry( QRect( 140, 70, 91, 21 ) ); |
286 | 286 | ||
287 | optlab1 = new QLabel( tab_2, "optlab1" ); | 287 | optlab1 = new QLabel( tab_2, "optlab1" ); |
288 | optlab1->setGeometry( QRect( 8, 8, 160, 40 ) ); | 288 | 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" ) ); | 289 | 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 ) ); | 290 | optlab1->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) ); |
291 | tabs->insertTab( tab_2, tr( "Options" ) ); | 291 | tabs->insertTab( tab_2, tr( "Options" ) ); |
292 | 292 | ||
293 | Tuner = new QWidget( tabs, "Tuner" ); | 293 | Tuner = new QWidget( tabs, "Tuner" ); |
294 | 294 | ||
295 | Frame4 = new QFrame( Tuner, "Frame4" ); | 295 | Frame4 = new QFrame( Tuner, "Frame4" ); |
296 | Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); | 296 | Frame4->setGeometry( QRect( 0, 0, 230, 126 ) ); |
297 | Frame4->setFrameShape( QFrame::Box ); | 297 | Frame4->setFrameShape( QFrame::Box ); |
298 | Frame4->setFrameShadow( QFrame::Raised ); | 298 | Frame4->setFrameShadow( QFrame::Raised ); |
299 | 299 | ||
300 | vu = new VUMeter( Frame4, "vu" ); | 300 | vu = new VUMeter( Frame4, "vu" ); |
301 | vu->setGeometry( QRect( 5, 5, 220, 115 ) ); | 301 | vu->setGeometry( QRect( 5, 5, 220, 115 ) ); |
302 | 302 | ||
303 | tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); | 303 | tuner_note = new QComboBox( FALSE, Tuner, "tuner_note" ); |
304 | tuner_note->insertItem( tr( "auto" ) ); | 304 | tuner_note->insertItem( tr( "auto" ) ); |
305 | tuner_note->insertItem( tr( "E" ) ); | 305 | tuner_note->insertItem( tr( "E" ) ); |
306 | tuner_note->insertItem( tr( "D" ) ); | 306 | tuner_note->insertItem( tr( "D" ) ); |
307 | tuner_note->insertItem( tr( "G" ) ); | 307 | tuner_note->insertItem( tr( "G" ) ); |
308 | tuner_note->insertItem( tr( "A" ) ); | 308 | tuner_note->insertItem( tr( "A" ) ); |
309 | tuner_note->insertItem( tr( "B" ) ); | 309 | tuner_note->insertItem( tr( "B" ) ); |
310 | tuner_note->insertItem( tr( "C" ) ); | 310 | tuner_note->insertItem( tr( "C" ) ); |
311 | tuner_note->insertItem( tr( "F" ) ); | 311 | tuner_note->insertItem( tr( "F" ) ); |
312 | tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); | 312 | tuner_note->setGeometry( QRect( 5, 160, 90, 20 ) ); |
313 | 313 | ||
314 | Frame8 = new QFrame( Tuner, "Frame8" ); | 314 | Frame8 = new QFrame( Tuner, "Frame8" ); |
315 | Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); | 315 | Frame8->setGeometry( QRect( -2, 188, 231, 10 ) ); |
316 | Frame8->setFrameShape( QFrame::HLine ); | 316 | Frame8->setFrameShape( QFrame::HLine ); |
317 | Frame8->setFrameShadow( QFrame::Raised ); | 317 | Frame8->setFrameShadow( QFrame::Raised ); |
318 | 318 | ||
319 | tuner_start = new QPushButton( Tuner, "tuner_start" ); | 319 | tuner_start = new QPushButton( Tuner, "tuner_start" ); |
320 | tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); | 320 | tuner_start->setGeometry( QRect( 100, 155, 91, 30 ) ); |
321 | tuner_start->setText( tr( "Start" ) ); | 321 | tuner_start->setText( tr( "Start" ) ); |
322 | 322 | ||
323 | tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); | 323 | tuner_lab1 = new QLabel( Tuner, "tuner_lab1" ); |
324 | tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); | 324 | tuner_lab1->setGeometry( QRect( 10, 130, 100, 21 ) ); |
325 | tuner_lab1->setText( tr( "Tuner operation" ) ); | 325 | tuner_lab1->setText( tr( "Tuner operation" ) ); |
326 | 326 | ||
327 | tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); | 327 | tuner_lab2 = new QLabel( Tuner, "tuner_lab2" ); |
328 | tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); | 328 | tuner_lab2->setGeometry( QRect( 10, 200, 100, 16 ) ); |
329 | tuner_lab2->setText( tr( "Pitch calibration" ) ); | 329 | tuner_lab2->setText( tr( "Pitch calibration" ) ); |
330 | 330 | ||
331 | tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); | 331 | tuner_calib_note = new QComboBox( FALSE, Tuner, "tuner_calib_note" ); |
332 | tuner_calib_note->insertItem( tr( "A" ) ); | 332 | tuner_calib_note->insertItem( tr( "A" ) ); |
333 | tuner_calib_note->insertItem( tr( "C" ) ); | 333 | tuner_calib_note->insertItem( tr( "C" ) ); |
334 | tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); | 334 | tuner_calib_note->setGeometry( QRect( 5, 225, 90, 21 ) ); |
335 | 335 | ||
336 | tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); | 336 | tuner_calib_freq = new QSpinBox( Tuner, "tuner_calib_freq" ); |
337 | tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); | 337 | tuner_calib_freq->setGeometry( QRect( 105, 225, 71, 21 ) ); |
338 | tuner_calib_freq->setSuffix( tr( "Hz" ) ); | 338 | tuner_calib_freq->setSuffix( tr( "Hz" ) ); |
339 | tuner_calib_freq->setWrapping( TRUE ); | 339 | tuner_calib_freq->setWrapping( TRUE ); |
340 | tuner_calib_freq->setMaxValue( 500 ); | 340 | tuner_calib_freq->setMaxValue( 500 ); |
341 | tuner_calib_freq->setMinValue( 300 ); | 341 | tuner_calib_freq->setMinValue( 300 ); |
342 | tuner_calib_freq->setValue( 440 ); | 342 | tuner_calib_freq->setValue( 440 ); |
343 | 343 | ||
344 | tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); | 344 | tuner_lab3 = new QLabel( Tuner, "tuner_lab3" ); |
345 | tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); | 345 | tuner_lab3->setGeometry( QRect( 185, 225, 40, 21 ) ); |
346 | tuner_lab3->setText( tr( "Pitch" ) ); | 346 | tuner_lab3->setText( tr( "Pitch" ) ); |
347 | 347 | ||
348 | tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); | 348 | tuner_pic1 = new QLabel( Tuner, "tuner_pic1" ); |
349 | tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); | 349 | tuner_pic1->setGeometry( QRect( 195, 155, 31, 31 ) ); |
350 | tuner_pic1->setFrameShape( QLabel::NoFrame ); | 350 | tuner_pic1->setFrameShape( QLabel::NoFrame ); |
351 | tuner_pic1->setPixmap( image6 ); | 351 | tuner_pic1->setPixmap( image6 ); |
352 | tuner_pic1->setScaledContents( TRUE ); | 352 | tuner_pic1->setScaledContents( TRUE ); |
353 | tabs->insertTab( Tuner, tr( "Tuner" ) ); | 353 | tabs->insertTab( Tuner, tr( "Tuner" ) ); |
354 | 354 | ||
355 | tab_3 = new QWidget( tabs, "tab_3" ); | 355 | tab_3 = new QWidget( tabs, "tab_3" ); |
356 | 356 | ||
357 | chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); | 357 | chordlistlab1 = new QLabel( tab_3, "chordlistlab1" ); |
358 | chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); | 358 | chordlistlab1->setGeometry( QRect( 5, 5, 216, 16 ) ); |
359 | chordlistlab1->setText( tr( "Chord list" ) ); | 359 | chordlistlab1->setText( tr( "Chord list" ) ); |
360 | 360 | ||
361 | chordlist = new QListBox( tab_3, "chordlist" ); | 361 | chordlist = new QListBox( tab_3, "chordlist" ); |
362 | chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); | 362 | chordlist->setGeometry( QRect( 5, 25, 220, 200 ) ); |
363 | 363 | ||
364 | list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); | 364 | list_remove_btn = new QPushButton( tab_3, "list_remove_btn" ); |
365 | list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); | 365 | list_remove_btn->setGeometry( QRect( 150, 230, 71, 25 ) ); |
366 | list_remove_btn->setText( tr( "Remove" ) ); | 366 | list_remove_btn->setText( tr( "Remove" ) ); |
367 | tabs->insertTab( tab_3, tr( "Chords" ) ); | 367 | tabs->insertTab( tab_3, tr( "Chords" ) ); |
368 | 368 | ||
369 | // hope this does what it's supposed to!! | 369 | // hope this does what it's supposed to!! |
370 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); | 370 | // setPalette( QPalette( QColor( 232, 227, 215) ) ); |
371 | 371 | ||
372 | // signals and slots connections | 372 | // signals and slots connections |
373 | 373 | ||
374 | //cxm | 374 | //cxm |
375 | connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); | 375 | connect( tuning, SIGNAL( activated(int) ), frets, SLOT( Tune(int) ) ); |
376 | connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); | 376 | connect( span, SIGNAL( activated(int) ), frets, SLOT( Span(int) ) ); |
377 | connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); | 377 | connect( transport_rec, SIGNAL( clicked() ), this, SLOT( transport_rec_cb() )); |
378 | connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); | 378 | connect( play_sound, SIGNAL( clicked() ), this, SLOT( play_chord_cb() )); |
379 | connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); | 379 | connect( tuner_start, SIGNAL( clicked() ), this, SLOT( tuner_start_cb() )); |
380 | connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); | 380 | connect( tuner_note, SIGNAL( textChanged(const QString&) ), vu, SLOT( AnnotL(const QString&) )); |
381 | connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); | 381 | connect( this, SIGNAL( frequency_change(int) ), vu, SLOT( Value(int) )); |
382 | 382 | ||
383 | connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); | 383 | connect( chordnote, SIGNAL( activated(int) ), frets, SLOT( Base(int) ) ); |
384 | connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); | 384 | connect( chordkey, SIGNAL( activated(int) ), frets, SLOT( Chord(int) ) ); |
385 | connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); | 385 | connect( chordfret, SIGNAL( activated(int) ), frets, SLOT( Fret(int) ) ); |
386 | connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); | 386 | connect( list_remove_btn, SIGNAL( clicked() ), this, SLOT( list_remove_cb() ) ); |
387 | connect( frets, SIGNAL( s1nameChanged(const QString &) ), s1_1, SLOT( setText(const QString&) ) ); | 387 | 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&) ) ); | 388 | 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&) ) ); | 389 | 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&) ) ); | 390 | 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&) ) ); | 391 | 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&) ) ); | 392 | connect( frets, SIGNAL( s6nameChanged(const QString&) ), s1_6, SLOT( setText(const QString&) ) ); |
393 | connect( frets, SIGNAL( nameChanged(const QString &) ), chordname, SLOT( setText(const QString&) ) ); | 393 | connect( frets, SIGNAL( nameChanged(const QString&) ), chordname, SLOT( setText(const QString&) ) ); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | static int known=0; | 397 | static int known=0; |
398 | #include <qmessagebox.h> | 398 | #include <qmessagebox.h> |
399 | void PowerchordBase::transport_rec_cb(){ | 399 | void PowerchordBase::transport_rec_cb(){ |
400 | chordlist->insertItem(chordname->text(),-1); | 400 | chordlist->insertItem(chordname->text(),-1); |
401 | if (!known){ | 401 | if (!known){ |
402 | QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); | 402 | QMessageBox::information(this, "Powerchord", "This chord has been saved\ninto the list of chords,\nfor later playback."); |
403 | known = 1; | 403 | known = 1; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | void PowerchordBase::list_remove_cb(){ | 406 | void PowerchordBase::list_remove_cb(){ |
407 | if (chordlist->count() > 0){ | 407 | if (chordlist->count() > 0){ |
408 | chordlist->removeItem(0); | 408 | chordlist->removeItem(0); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | void PowerchordBase::play_chord_cb(){ | 411 | void PowerchordBase::play_chord_cb(){ |
412 | // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); | 412 | // QMessageBox::information(this, "Coming soon!", "This button plays\nthe chord by synthesizing\nthe sound of the notes."); |
413 | 413 | ||
414 | 414 | ||
415 | if (audio_timer){ | 415 | if (audio_timer){ |
416 | audio_timer->stop(); | 416 | audio_timer->stop(); |
417 | // set pixmap? | 417 | // set pixmap? |
418 | synth->Stop(); | 418 | synth->Stop(); |
419 | delete(audio_timer); | 419 | delete(audio_timer); |
420 | audio_timer = 0; | 420 | audio_timer = 0; |
421 | }else{ | 421 | }else{ |
422 | // get notes from chord engine | 422 | // get notes from chord engine |
423 | 423 | ||
424 | int note; | 424 | int note; |
425 | int base; | 425 | int base; |
426 | int octave; | 426 | int octave; |
427 | note = frets->ce.noteindex(0); | 427 | note = frets->ce.noteindex(0); |
428 | if (note >= 0){ | 428 | if (note >= 0){ |
429 | //fprintf(stderr, "Note was %d\n", note); | 429 | //fprintf(stderr, "Note was %d\n", note); |
430 | base = note % 12; | 430 | base = note % 12; |
431 | octave = note / 12; | 431 | octave = note / 12; |
432 | synth->note_start(0, base, octave); | 432 | synth->note_start(0, base, octave); |
433 | }else{ | 433 | }else{ |
434 | // subtle bug here - replay second note if 1st one muted | 434 | // subtle bug here - replay second note if 1st one muted |
435 | note = frets->ce.noteindex(1); | 435 | note = frets->ce.noteindex(1); |
436 | base = note % 12; | 436 | base = note % 12; |
437 | octave = note / 12; | 437 | octave = note / 12; |
438 | synth->note_start(1, base, octave); | 438 | synth->note_start(1, base, octave); |
439 | 439 | ||
440 | } | 440 | } |
441 | 441 | ||
442 | // init synth | 442 | // init synth |
443 | if (synth->Play()){ | 443 | if (synth->Play()){ |
444 | // error | 444 | // error |
445 | QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); | 445 | QMessageBox::information(this, "Powerchord", "Unable to open device for sound playback - check that no other application is using it."); |
446 | return; | 446 | return; |
447 | } | 447 | } |
448 | synth->fill_buffer(); | 448 | synth->fill_buffer(); |
449 | 449 | ||
450 | // start timer | 450 | // start timer |
451 | audio_timer = new QTimer(); | 451 | audio_timer = new QTimer(); |
452 | connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); | 452 | connect(audio_timer, SIGNAL( timeout() ), this, SLOT( audio_cb() )); |
453 | // set pixmap on player? | 453 | // set pixmap on player? |
454 | audio_timer->start(19); // 19 msec (fudge factor!!) | 454 | audio_timer->start(19); // 19 msec (fudge factor!!) |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | 459 | ||
460 | void PowerchordBase::audio_cb(){ | 460 | void PowerchordBase::audio_cb(){ |
461 | // play the next bit of audio until quiet | 461 | // play the next bit of audio until quiet |
462 | 462 | ||
463 | // strum timing | 463 | // strum timing |
464 | #define INTERVAL 2 | 464 | #define INTERVAL 2 |
465 | 465 | ||
466 | if ((synth->Frames() % INTERVAL) == 0){ | 466 | if ((synth->Frames() % INTERVAL) == 0){ |
467 | int string = synth->Frames() / INTERVAL; | 467 | int string = synth->Frames() / INTERVAL; |
468 | if (string <= 5){ | 468 | if (string <= 5){ |
469 | int note; | 469 | int note; |
470 | int base; | 470 | int base; |
471 | int octave; | 471 | int octave; |
472 | note = frets->ce.noteindex(string); | 472 | note = frets->ce.noteindex(string); |
473 | // check not muted... | 473 | // check not muted... |
474 | if (note > 0){ | 474 | if (note > 0){ |
475 | base = note % 12; | 475 | base = note % 12; |
476 | octave = note / 12; | 476 | octave = note / 12; |
477 | synth->note_start(string, base, octave); | 477 | synth->note_start(string, base, octave); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
482 | if (synth->Playing()){ | 482 | if (synth->Playing()){ |
483 | synth->write_buffer(); | 483 | synth->write_buffer(); |
484 | synth->fill_buffer(); | 484 | synth->fill_buffer(); |
485 | }else{ | 485 | }else{ |
486 | audio_timer->stop(); | 486 | audio_timer->stop(); |
487 | // set pixmap? | 487 | // set pixmap? |
488 | synth->Stop(); | 488 | synth->Stop(); |
489 | delete(audio_timer); | 489 | delete(audio_timer); |
490 | audio_timer = 0; | 490 | audio_timer = 0; |
491 | } | 491 | } |
492 | } | 492 | } |
493 | 493 | ||
494 | // the real tuner | 494 | // the real tuner |
495 | // void PowerchordBase::tuner_start_cb(){ | 495 | // void PowerchordBase::tuner_start_cb(){ |
496 | 496 | ||
497 | // if (tuner->Listening()){ | 497 | // if (tuner->Listening()){ |
498 | // simulation_timer->stop(); | 498 | // simulation_timer->stop(); |
499 | // tuner->Stop(); | 499 | // tuner->Stop(); |
500 | // tuner_pic1->setPixmap( *image6 ); | 500 | // tuner_pic1->setPixmap( *image6 ); |
501 | 501 | ||
502 | // }else{ | 502 | // }else{ |
503 | // tuner_pic1->setPixmap( *image_open ); | 503 | // tuner_pic1->setPixmap( *image_open ); |
504 | 504 | ||
505 | // if (!simulation_timer){ | 505 | // if (!simulation_timer){ |
506 | // simulation_timer = new QTimer(); | 506 | // simulation_timer = new QTimer(); |
507 | 507 | ||
508 | 508 | ||
509 | // connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); | 509 | // connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_cb() )); |
510 | // } | 510 | // } |
511 | 511 | ||
512 | // simulation_timer->start(50); | 512 | // simulation_timer->start(50); |
513 | // tuner->Listen(); | 513 | // tuner->Listen(); |
514 | 514 | ||
515 | // } | 515 | // } |
516 | // } | 516 | // } |
517 | 517 | ||
518 | void PowerchordBase::tuner_cb(){ | 518 | void PowerchordBase::tuner_cb(){ |
519 | if (tuner->Listening()){ | 519 | if (tuner->Listening()){ |
520 | tuner->read_buffer(); | 520 | tuner->read_buffer(); |
521 | tuner->process_buffer(); | 521 | tuner->process_buffer(); |
522 | 522 | ||
523 | // update gui | 523 | // update gui |
524 | // do something with the note: tuner->Note() | 524 | // do something with the note: tuner->Note() |
525 | emit frequency_change(tuner->Tuning()); | 525 | emit frequency_change(tuner->Tuning()); |
526 | 526 | ||
527 | }else{ | 527 | }else{ |
528 | simulation_timer->stop(); | 528 | simulation_timer->stop(); |
529 | tuner->Stop(); | 529 | tuner->Stop(); |
530 | tuner_pic1->setPixmap( image6 ); | 530 | tuner_pic1->setPixmap( image6 ); |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | 534 | ||
535 | void PowerchordBase::tuner_start_cb(){ | 535 | void PowerchordBase::tuner_start_cb(){ |
536 | if (0 == QMessageBox::information(this, "Powerchord", "Using the microphone,\nthe note's frequency\nis analysed. This\nis a simulation.", "OK", "Cancel", 0, 1)){ | 536 | 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){ | 537 | if (simulation_timer){ |
538 | simulation_timer->stop(); | 538 | simulation_timer->stop(); |
539 | }else{ | 539 | }else{ |
540 | simulation_timer = new QTimer(); | 540 | simulation_timer = new QTimer(); |
541 | connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); | 541 | connect(simulation_timer, SIGNAL( timeout() ), this, SLOT( tuner_simulation_cb() )); |
542 | 542 | ||
543 | } | 543 | } |
544 | simulation_x = -45; | 544 | simulation_x = -45; |
545 | simulation_v = 0; | 545 | simulation_v = 0; |
546 | simulation_iter = 0; | 546 | simulation_iter = 0; |
547 | 547 | ||
548 | tuner_pic1->setPixmap( image_open ); | 548 | tuner_pic1->setPixmap( image_open ); |
549 | simulation_timer->start(100); | 549 | simulation_timer->start(100); |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | #include <stdio.h> | 553 | #include <stdio.h> |
554 | 554 | ||
555 | void PowerchordBase::tuner_simulation_cb(){ | 555 | void PowerchordBase::tuner_simulation_cb(){ |
556 | if (simulation_x < -10 || simulation_x > 10){ | 556 | if (simulation_x < -10 || simulation_x > 10){ |
557 | simulation_v = (simulation_v/2)-(simulation_x/5); | 557 | simulation_v = (simulation_v/2)-(simulation_x/5); |
558 | } | 558 | } |
559 | 559 | ||
560 | simulation_x += simulation_v; | 560 | simulation_x += simulation_v; |
561 | simulation_iter++; | 561 | simulation_iter++; |
562 | 562 | ||
563 | if (simulation_x > 50){ | 563 | if (simulation_x > 50){ |
564 | simulation_x = 50; | 564 | simulation_x = 50; |
565 | } | 565 | } |
566 | 566 | ||
567 | if (simulation_x < -50){ | 567 | if (simulation_x < -50){ |
568 | simulation_x = -50; | 568 | simulation_x = -50; |
569 | } | 569 | } |
570 | 570 | ||
571 | if (simulation_iter > 50){ | 571 | if (simulation_iter > 50){ |
572 | simulation_timer->stop(); | 572 | simulation_timer->stop(); |
573 | emit frequency_change(0); | 573 | emit frequency_change(0); |
574 | tuner_pic1->setPixmap( image6 ); | 574 | tuner_pic1->setPixmap( image6 ); |
575 | }else{ | 575 | }else{ |
576 | emit frequency_change(simulation_x); | 576 | emit frequency_change(simulation_x); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | /* | 580 | /* |
581 | * Destroys the object and frees any allocated resources | 581 | * Destroys the object and frees any allocated resources |
582 | */ | 582 | */ |
583 | PowerchordBase::~PowerchordBase() | 583 | PowerchordBase::~PowerchordBase() |
584 | { | 584 | { |
585 | // no need to delete child widgets, Qt does it all for us | 585 | // no need to delete child widgets, Qt does it all for us |
586 | } | 586 | } |
587 | 587 | ||
588 | void PowerchordBase::change_handler() | 588 | void PowerchordBase::change_handler() |
589 | { | 589 | { |
590 | qWarning( "PowerchordBase::change_handler(): Not implemented yet!" ); | 590 | qWarning( "PowerchordBase::change_handler(): Not implemented yet!" ); |
591 | } | 591 | } |
592 | 592 | ||
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp index 7872c09..d2b65a9 100644 --- a/noncore/multimedia/showimg/ImageFileSelector.cpp +++ b/noncore/multimedia/showimg/ImageFileSelector.cpp | |||
@@ -1,271 +1,271 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "qpe/global.h" | 3 | #include "qpe/global.h" |
4 | #include "qpe/applnk.h" | 4 | #include "qpe/applnk.h" |
5 | #include "qpe/lnkproperties.h" | 5 | #include "qpe/lnkproperties.h" |
6 | #include "qpe/applnk.h" | 6 | #include "qpe/applnk.h" |
7 | #include "qpe/qpeapplication.h" | 7 | #include "qpe/qpeapplication.h" |
8 | 8 | ||
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | 10 | ||
11 | #include <qdir.h> | 11 | #include <qdir.h> |
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qheader.h> | 13 | #include <qheader.h> |
14 | #include <qimage.h> | 14 | #include <qimage.h> |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | #include <qlabel.h> | 16 | #include <qlabel.h> |
17 | #include <qfileinfo.h> | 17 | #include <qfileinfo.h> |
18 | #include <qpainter.h> | 18 | #include <qpainter.h> |
19 | #include <qscrollview.h> | 19 | #include <qscrollview.h> |
20 | 20 | ||
21 | #include "ImageFileSelector.h" | 21 | #include "ImageFileSelector.h" |
22 | 22 | ||
23 | 23 | ||
24 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) | 24 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) |
25 | : QWidget( parent ),fl(f) | 25 | : QWidget( parent ),fl(f) |
26 | { | 26 | { |
27 | setBackgroundMode(NoBackground); | 27 | setBackgroundMode(NoBackground); |
28 | if ( w!=-1 ) | 28 | if ( w!=-1 ) |
29 | setMinimumSize(w,p.height()+24); | 29 | setMinimumSize(w,p.height()+24); |
30 | else | 30 | else |
31 | setMinimumSize(p.width(),p.height()+24); | 31 | setMinimumSize(p.width(),p.height()+24); |
32 | description=new QLabel(text,this); | 32 | description=new QLabel(text,this); |
33 | description->setBackgroundColor(colorGroup().base()); | 33 | description->setBackgroundColor(colorGroup().base()); |
34 | description->setAlignment(AlignCenter); | 34 | description->setAlignment(AlignCenter); |
35 | description->setGeometry(0,height()-24,width(),24); | 35 | description->setGeometry(0,height()-24,width(),24); |
36 | pixmap=p; | 36 | pixmap=p; |
37 | } | 37 | } |
38 | 38 | ||
39 | void ThumbWidget::resizeEvent(QResizeEvent *) | 39 | void ThumbWidget::resizeEvent(QResizeEvent *) |
40 | { | 40 | { |
41 | description->setGeometry(0,height()-24,width(),24); | 41 | description->setGeometry(0,height()-24,width(),24); |
42 | } | 42 | } |
43 | 43 | ||
44 | void ThumbWidget::paintEvent( QPaintEvent *e ) | 44 | void ThumbWidget::paintEvent( QPaintEvent *e ) |
45 | { | 45 | { |
46 | QPainter painter(this); | 46 | QPainter painter(this); |
47 | 47 | ||
48 | painter.setClipRect(e->rect()); | 48 | painter.setClipRect(e->rect()); |
49 | painter.fillRect(0,0,width(),height(),QColor(255,255,255)); | 49 | painter.fillRect(0,0,width(),height(),QColor(255,255,255)); |
50 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); | 50 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) | 54 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) |
55 | { | 55 | { |
56 | emit clicked(fl); | 56 | emit clicked(fl); |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) | 61 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) |
62 | : QListViewItem( parent ), fl( f ) | 62 | : QListViewItem( parent ), fl( f ) |
63 | { | 63 | { |
64 | setText( 0, f.name() ); | 64 | setText( 0, f.name() ); |
65 | QFileInfo fi(f.file()); | 65 | QFileInfo fi(f.file()); |
66 | setText( 1, (fi.extension()).upper() ); | 66 | setText( 1, (fi.extension()).upper() ); |
67 | setPixmap( 0, f.pixmap() ); | 67 | setPixmap( 0, f.pixmap() ); |
68 | 68 | ||
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | ImageFileSelectorItem::~ImageFileSelectorItem() | 73 | ImageFileSelectorItem::~ImageFileSelectorItem() |
74 | { | 74 | { |
75 | 75 | ||
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) | 79 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) |
80 | : QWidgetStack(parent) | 80 | : QWidgetStack(parent) |
81 | { | 81 | { |
82 | 82 | ||
83 | detailed=new QListView(this); | 83 | detailed=new QListView(this); |
84 | 84 | ||
85 | detailed->addColumn (tr("Title")); | 85 | detailed->addColumn (tr("Title")); |
86 | detailed->addColumn (tr("Type")); | 86 | detailed->addColumn (tr("Type")); |
87 | detailed->setAllColumnsShowFocus( true ); | 87 | detailed->setAllColumnsShowFocus( true ); |
88 | 88 | ||
89 | tList.setAutoDelete(true); | 89 | tList.setAutoDelete(true); |
90 | 90 | ||
91 | thumb =new QScrollView(this); | 91 | thumb =new QScrollView(this); |
92 | thumb->setVScrollBarMode (QScrollView::Auto ); | 92 | thumb->setVScrollBarMode (QScrollView::Auto ); |
93 | thumb->viewport()->setBackgroundColor(colorGroup().base()); | 93 | thumb->viewport()->setBackgroundColor(colorGroup().base()); |
94 | 94 | ||
95 | background=new QWidget(0); | 95 | background=new QWidget(0); |
96 | background->setBackgroundColor(colorGroup().base()); | 96 | background->setBackgroundColor(colorGroup().base()); |
97 | thumb->addChild(background); | 97 | thumb->addChild(background); |
98 | gl = new QGridLayout(background,1,2,4,4); | 98 | gl = new QGridLayout(background,1,2,4,4); |
99 | 99 | ||
100 | 100 | ||
101 | 101 | ||
102 | connect( detailed, SIGNAL( mouseButtonClicked( int, QListViewItem *, const QPoint &, int ) ), | 102 | connect( detailed, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
103 | this, SLOT( fileClicked( int, QListViewItem *, const QPoint &, int ) ) ); | 103 | this, SLOT( fileClicked(int,QListViewItem*,const QPoint&,int) ) ); |
104 | connect( detailed, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint &, int ) ), | 104 | connect( detailed, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
105 | this, SLOT( filePressed( int, QListViewItem *, const QPoint &, int ) ) ); | 105 | this, SLOT( filePressed(int,QListViewItem*,const QPoint&,int) ) ); |
106 | connect( detailed, SIGNAL( returnPressed( QListViewItem * ) ), | 106 | connect( detailed, SIGNAL( returnPressed(QListViewItem*) ), |
107 | this, SLOT( fileClicked( QListViewItem * ) ) ); | 107 | this, SLOT( fileClicked(QListViewItem*) ) ); |
108 | 108 | ||
109 | cView=UNKNOWN; | 109 | cView=UNKNOWN; |
110 | setView(scv); | 110 | setView(scv); |
111 | reread(); | 111 | reread(); |
112 | 112 | ||
113 | } | 113 | } |
114 | ImageFileSelector::~ImageFileSelector() | 114 | ImageFileSelector::~ImageFileSelector() |
115 | { | 115 | { |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void ImageFileSelector::switchView() | 120 | void ImageFileSelector::switchView() |
121 | { | 121 | { |
122 | CURRENT_VIEW v=cView; | 122 | CURRENT_VIEW v=cView; |
123 | 123 | ||
124 | if ( v==DETAILED ) | 124 | if ( v==DETAILED ) |
125 | v=THUMBNAIL; | 125 | v=THUMBNAIL; |
126 | else | 126 | else |
127 | v=DETAILED; | 127 | v=DETAILED; |
128 | setView(v); | 128 | setView(v); |
129 | } | 129 | } |
130 | 130 | ||
131 | void ImageFileSelector::setView(CURRENT_VIEW v) | 131 | void ImageFileSelector::setView(CURRENT_VIEW v) |
132 | { | 132 | { |
133 | 133 | ||
134 | if ( v==cView ) | 134 | if ( v==cView ) |
135 | return; | 135 | return; |
136 | cView=v; | 136 | cView=v; |
137 | 137 | ||
138 | if ( cView!=DETAILED ) | 138 | if ( cView!=DETAILED ) |
139 | { | 139 | { |
140 | raiseWidget(thumb); | 140 | raiseWidget(thumb); |
141 | updateSizes(); | 141 | updateSizes(); |
142 | } | 142 | } |
143 | else | 143 | else |
144 | { | 144 | { |
145 | raiseWidget(detailed); | 145 | raiseWidget(detailed); |
146 | updateSizes(); | 146 | updateSizes(); |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | void ImageFileSelector::resizeEvent(QResizeEvent *) | 152 | void ImageFileSelector::resizeEvent(QResizeEvent *) |
153 | { | 153 | { |
154 | updateSizes(); | 154 | updateSizes(); |
155 | } | 155 | } |
156 | 156 | ||
157 | void ImageFileSelector::updateSizes() | 157 | void ImageFileSelector::updateSizes() |
158 | { | 158 | { |
159 | int ww=(detailed->width()-detailed->frameWidth()*2); | 159 | int ww=(detailed->width()-detailed->frameWidth()*2); |
160 | double w=(double)ww*0.70; | 160 | double w=(double)ww*0.70; |
161 | detailed->setColumnWidth(0,(int)w); | 161 | detailed->setColumnWidth(0,(int)w); |
162 | detailed->setColumnWidth(1,ww-(int)w); | 162 | detailed->setColumnWidth(1,ww-(int)w); |
163 | background->setMinimumWidth(thumb->visibleWidth()); | 163 | background->setMinimumWidth(thumb->visibleWidth()); |
164 | thumb->updateScrollBars(); | 164 | thumb->updateScrollBars(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void ImageFileSelector::reread(bool) | 167 | void ImageFileSelector::reread(bool) |
168 | { | 168 | { |
169 | // qDebug("reread"); | 169 | // qDebug("reread"); |
170 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); | 170 | ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); |
171 | QString oldFile; | 171 | QString oldFile; |
172 | if ( item ) | 172 | if ( item ) |
173 | oldFile = item->file().file(); | 173 | oldFile = item->file().file(); |
174 | detailed->clear(); | 174 | detailed->clear(); |
175 | tList.clear(); | 175 | tList.clear(); |
176 | DocLnkSet files; | 176 | DocLnkSet files; |
177 | Global::findDocuments(&files, "image/*"); | 177 | Global::findDocuments(&files, "image/*"); |
178 | count = files.children().count(); | 178 | count = files.children().count(); |
179 | QListIterator<DocLnk> dit( files.children() ); | 179 | QListIterator<DocLnk> dit( files.children() ); |
180 | // int y=0; | 180 | // int y=0; |
181 | // int x=4; | 181 | // int x=4; |
182 | // int totalHeight=4; | 182 | // int totalHeight=4; |
183 | ThumbWidget *l=0; | 183 | ThumbWidget *l=0; |
184 | int width=80; | 184 | int width=80; |
185 | gl->expand(dit.count()/2,2); | 185 | gl->expand(dit.count()/2,2); |
186 | int i,j; | 186 | int i,j; |
187 | i=j=0; | 187 | i=j=0; |
188 | detailed->setUpdatesEnabled(false); | 188 | detailed->setUpdatesEnabled(false); |
189 | thumb->setUpdatesEnabled(false); | 189 | thumb->setUpdatesEnabled(false); |
190 | 190 | ||
191 | for ( ; dit.current(); ++dit ) { | 191 | for ( ; dit.current(); ++dit ) { |
192 | item = new ImageFileSelectorItem( detailed, **dit ); | 192 | item = new ImageFileSelectorItem( detailed, **dit ); |
193 | if ( item->file().file() == oldFile ) | 193 | if ( item->file().file() == oldFile ) |
194 | detailed->setCurrentItem( item ); | 194 | detailed->setCurrentItem( item ); |
195 | } | 195 | } |
196 | 196 | ||
197 | QListViewItemIterator it( detailed ); | 197 | QListViewItemIterator it( detailed ); |
198 | ImageFileSelectorItem *ii; | 198 | ImageFileSelectorItem *ii; |
199 | // iterate through all items of the listview | 199 | // iterate through all items of the listview |
200 | for ( ; it.current(); ++it ) { | 200 | for ( ; it.current(); ++it ) { |
201 | ii=(ImageFileSelectorItem *)it.current(); | 201 | ii=(ImageFileSelectorItem *)it.current(); |
202 | QImage img( ii->file().file() ); | 202 | QImage img( ii->file().file() ); |
203 | if( !img.isNull()) { | 203 | if( !img.isNull()) { |
204 | img=img.smoothScale(64,64); | 204 | img=img.smoothScale(64,64); |
205 | QPixmap pix; | 205 | QPixmap pix; |
206 | pix.convertFromImage(img); | 206 | pix.convertFromImage(img); |
207 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); | 207 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); |
208 | l->setBackgroundColor(colorGroup().base()); | 208 | l->setBackgroundColor(colorGroup().base()); |
209 | gl->addWidget(l,j,i); | 209 | gl->addWidget(l,j,i); |
210 | i++; | 210 | i++; |
211 | if ( i==2 ) { | 211 | if ( i==2 ) { |
212 | i=0; | 212 | i=0; |
213 | j++; | 213 | j++; |
214 | } | 214 | } |
215 | tList.append(l); | 215 | tList.append(l); |
216 | connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &))); | 216 | connect(l,SIGNAL(clicked(const DocLnk&)),this,SLOT(thumbClicked(const DocLnk&))); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | if ( !detailed->selectedItem() ) | 220 | if ( !detailed->selectedItem() ) |
221 | detailed->setCurrentItem( detailed->firstChild() ); | 221 | detailed->setCurrentItem( detailed->firstChild() ); |
222 | 222 | ||
223 | detailed->setUpdatesEnabled(true); | 223 | detailed->setUpdatesEnabled(true); |
224 | thumb->setUpdatesEnabled(true); | 224 | thumb->setUpdatesEnabled(true); |
225 | detailed->update(); | 225 | detailed->update(); |
226 | thumb->update(); | 226 | thumb->update(); |
227 | } | 227 | } |
228 | 228 | ||
229 | int ImageFileSelector::fileCount() | 229 | int ImageFileSelector::fileCount() |
230 | { | 230 | { |
231 | return count; | 231 | return count; |
232 | } | 232 | } |
233 | const DocLnk * ImageFileSelector::selected() | 233 | const DocLnk * ImageFileSelector::selected() |
234 | { | 234 | { |
235 | qDebug("image selected"); | 235 | qDebug("image selected"); |
236 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); | 236 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); |
237 | if ( item ) | 237 | if ( item ) |
238 | return new DocLnk( item->file() ); | 238 | return new DocLnk( item->file() ); |
239 | return 0; | 239 | return 0; |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | 243 | ||
244 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) | 244 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) |
245 | { | 245 | { |
246 | if ( !i ) | 246 | if ( !i ) |
247 | return; | 247 | return; |
248 | if ( button == Qt::LeftButton ) | 248 | if ( button == Qt::LeftButton ) |
249 | { | 249 | { |
250 | fileClicked( i ); | 250 | fileClicked( i ); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | // pressed to get 'right down' | 253 | // pressed to get 'right down' |
254 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) | 254 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) |
255 | { | 255 | { |
256 | 256 | ||
257 | } | 257 | } |
258 | void ImageFileSelector::fileClicked( QListViewItem *i) | 258 | void ImageFileSelector::fileClicked( QListViewItem *i) |
259 | { | 259 | { |
260 | if ( !i ) | 260 | if ( !i ) |
261 | return; | 261 | return; |
262 | emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); | 262 | emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); |
263 | emit closeMe(); | 263 | emit closeMe(); |
264 | } | 264 | } |
265 | 265 | ||
266 | void ImageFileSelector::thumbClicked(const DocLnk &f) | 266 | void ImageFileSelector::thumbClicked(const DocLnk &f) |
267 | { | 267 | { |
268 | emit fileSelected( f ); | 268 | emit fileSelected( f ); |
269 | emit closeMe(); | 269 | emit closeMe(); |
270 | } | 270 | } |
271 | 271 | ||
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index ba76e57..02a1d91 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -1,696 +1,696 @@ | |||
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> | 35 | #include <qpe/fileselector.h> |
36 | #include <qpe/applnk.h> | 36 | #include <qpe/applnk.h> |
37 | #include <qfileinfo.h> | 37 | #include <qfileinfo.h> |
38 | #include <math.h> | 38 | #include <math.h> |
39 | #include <qmenubar.h> | 39 | #include <qmenubar.h> |
40 | #include <qwidgetstack.h> | 40 | #include <qwidgetstack.h> |
41 | #include <qpe/qpetoolbar.h> | 41 | #include <qpe/qpetoolbar.h> |
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qfiledialog.h> | 43 | #include <qfiledialog.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qscrollview.h> | 46 | #include <qscrollview.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qpainter.h> | 48 | #include <qpainter.h> |
49 | #include <qkeycode.h> | 49 | #include <qkeycode.h> |
50 | #include <qapplication.h> | 50 | #include <qapplication.h> |
51 | #include <qclipboard.h> | 51 | #include <qclipboard.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qspinbox.h> | 53 | #include <qspinbox.h> |
54 | 54 | ||
55 | 55 | ||
56 | 56 | ||
57 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) | 57 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) |
58 | : QDialog(parent,0,true) | 58 | : QDialog(parent,0,true) |
59 | { | 59 | { |
60 | setCaption(caption); | 60 | setCaption(caption); |
61 | 61 | ||
62 | if ( parent ) { | 62 | if ( parent ) { |
63 | setPalette(parent->palette()); | 63 | setPalette(parent->palette()); |
64 | } | 64 | } |
65 | 65 | ||
66 | b=brightness; | 66 | b=brightness; |
67 | img=image; | 67 | img=image; |
68 | 68 | ||
69 | setMinimumSize(140,80); | 69 | setMinimumSize(140,80); |
70 | 70 | ||
71 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); | 71 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); |
72 | 72 | ||
73 | pixmap =new ImageWidget(this);; | 73 | pixmap =new ImageWidget(this);; |
74 | QPixmap pm; | 74 | QPixmap pm; |
75 | pm.convertFromImage(img); | 75 | pm.convertFromImage(img); |
76 | pixmap->setPixmap(pm); | 76 | pixmap->setPixmap(pm); |
77 | pixmap->setMinimumSize(pm.width(),pm.height()); | 77 | pixmap->setMinimumSize(pm.width(),pm.height()); |
78 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); | 78 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); |
79 | QLabel *l=new QLabel(tr("Brightness")+":",this); | 79 | QLabel *l=new QLabel(tr("Brightness")+":",this); |
80 | gl->addWidget(l,1,0,AlignLeft); | 80 | gl->addWidget(l,1,0,AlignLeft); |
81 | spb=new QSpinBox(-100,100,2,this); | 81 | spb=new QSpinBox(-100,100,2,this); |
82 | gl->addWidget(spb,1,1,AlignRight); | 82 | gl->addWidget(spb,1,1,AlignRight); |
83 | 83 | ||
84 | spb->setValue(0); | 84 | spb->setValue(0); |
85 | 85 | ||
86 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); | 86 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | void ControlsDialog::bValueChanged(int value) | 90 | void ControlsDialog::bValueChanged(int value) |
91 | { | 91 | { |
92 | QImage nImage=img; | 92 | QImage nImage=img; |
93 | nImage.detach(); | 93 | nImage.detach(); |
94 | ImageViewer::intensity(nImage, (float)value/100); | 94 | ImageViewer::intensity(nImage, (float)value/100); |
95 | QPixmap pm; | 95 | QPixmap pm; |
96 | pm.convertFromImage(nImage); | 96 | pm.convertFromImage(nImage); |
97 | pixmap->setPixmap(pm); | 97 | pixmap->setPixmap(pm); |
98 | pixmap->repaint(false); | 98 | pixmap->repaint(false); |
99 | 99 | ||
100 | 100 | ||
101 | } | 101 | } |
102 | 102 | ||
103 | void ControlsDialog::accept() | 103 | void ControlsDialog::accept() |
104 | { | 104 | { |
105 | *b=spb->value(); | 105 | *b=spb->value(); |
106 | done(1); | 106 | done(1); |
107 | } | 107 | } |
108 | 108 | ||
109 | //=========================================================================== | 109 | //=========================================================================== |
110 | 110 | ||
111 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) | 111 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) |
112 | : QDialog(parent,0,true) | 112 | : QDialog(parent,0,true) |
113 | { | 113 | { |
114 | setCaption(caption); | 114 | setCaption(caption); |
115 | 115 | ||
116 | if ( parent ) | 116 | if ( parent ) |
117 | { | 117 | { |
118 | setPalette(parent->palette()); | 118 | setPalette(parent->palette()); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | 122 | ||
123 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; | 123 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; |
124 | 124 | ||
125 | setMinimumSize(180,80); | 125 | setMinimumSize(180,80); |
126 | int num=ImageViewer::LAST+1; | 126 | int num=ImageViewer::LAST+1; |
127 | if ( text[ImageViewer::ALPHA].isEmpty() ) | 127 | if ( text[ImageViewer::ALPHA].isEmpty() ) |
128 | num--; | 128 | num--; |
129 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); | 129 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); |
130 | QLabel *l; | 130 | QLabel *l; |
131 | int count=0; | 131 | int count=0; |
132 | for ( int i=0;i<num;i++ ) | 132 | for ( int i=0;i<num;i++ ) |
133 | { | 133 | { |
134 | if ( i==1 ) | 134 | if ( i==1 ) |
135 | { | 135 | { |
136 | QFrame *frm=new QFrame(this); | 136 | QFrame *frm=new QFrame(this); |
137 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); | 137 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); |
138 | gl->addMultiCellWidget(frm,i,i,0,1); | 138 | gl->addMultiCellWidget(frm,i,i,0,1); |
139 | } | 139 | } |
140 | else | 140 | else |
141 | { | 141 | { |
142 | l=new QLabel( tr( labels[count] )+":",this); | 142 | l=new QLabel( tr( labels[count] )+":",this); |
143 | gl->addWidget(l,i,0,AlignLeft); | 143 | gl->addWidget(l,i,0,AlignLeft); |
144 | l=new QLabel(text[count],this); | 144 | l=new QLabel(text[count],this); |
145 | gl->addWidget(l,i,1,AlignRight); | 145 | gl->addWidget(l,i,1,AlignRight); |
146 | count++; | 146 | count++; |
147 | } | 147 | } |
148 | 148 | ||
149 | } | 149 | } |
150 | 150 | ||
151 | } | 151 | } |
152 | 152 | ||
153 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) | 153 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) |
154 | { | 154 | { |
155 | InfoDialog *dlg=new InfoDialog(caption,text,parent); | 155 | InfoDialog *dlg=new InfoDialog(caption,text,parent); |
156 | dlg->exec(); | 156 | dlg->exec(); |
157 | delete dlg; | 157 | delete dlg; |
158 | } | 158 | } |
159 | 159 | ||
160 | //=========================================================================== | 160 | //=========================================================================== |
161 | 161 | ||
162 | 162 | ||
163 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 163 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
164 | { | 164 | { |
165 | vb = new QVBoxLayout( this ); | 165 | vb = new QVBoxLayout( this ); |
166 | 166 | ||
167 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); | 167 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); |
168 | pic=new ImageWidget(image); | 168 | pic=new ImageWidget(image); |
169 | image->addChild(pic); | 169 | image->addChild(pic); |
170 | 170 | ||
171 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 171 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
172 | 172 | ||
173 | vb->addWidget( image ); | 173 | vb->addWidget( image ); |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | void ImagePane::setPixmap( const QPixmap &pm ) | 177 | void ImagePane::setPixmap( const QPixmap &pm ) |
178 | { | 178 | { |
179 | pic->setPixmap( pm ); | 179 | pic->setPixmap( pm ); |
180 | pic->resize(pm.width(),pm.height()); | 180 | pic->resize(pm.width(),pm.height()); |
181 | image->updateScrollBars (); | 181 | image->updateScrollBars (); |
182 | pic->repaint(false); | 182 | pic->repaint(false); |
183 | } | 183 | } |
184 | 184 | ||
185 | void ImagePane::imageClicked() | 185 | void ImagePane::imageClicked() |
186 | { | 186 | { |
187 | emit clicked(); | 187 | emit clicked(); |
188 | } | 188 | } |
189 | //=========================================================================== | 189 | //=========================================================================== |
190 | /* | 190 | /* |
191 | Draws the portion of the scaled pixmap that needs to be updated | 191 | Draws the portion of the scaled pixmap that needs to be updated |
192 | */ | 192 | */ |
193 | 193 | ||
194 | void ImageWidget::paintEvent( QPaintEvent *e ) | 194 | void ImageWidget::paintEvent( QPaintEvent *e ) |
195 | { | 195 | { |
196 | QPainter painter(this); | 196 | QPainter painter(this); |
197 | 197 | ||
198 | painter.setClipRect(e->rect()); | 198 | painter.setClipRect(e->rect()); |
199 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); | 199 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); |
200 | 200 | ||
201 | if ( pixmap.size() != QSize( 0, 0 ) ) | 201 | if ( pixmap.size() != QSize( 0, 0 ) ) |
202 | { // is an image loaded? | 202 | { // is an image loaded? |
203 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 203 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 207 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
208 | { | 208 | { |
209 | emit clicked(); | 209 | emit clicked(); |
210 | } | 210 | } |
211 | 211 | ||
212 | //=========================================================================== | 212 | //=========================================================================== |
213 | 213 | ||
214 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | 214 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) |
215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) | 215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
216 | { | 216 | { |
217 | setCaption( tr("Image Viewer") ); | 217 | setCaption( tr("Image Viewer") ); |
218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
219 | 219 | ||
220 | 220 | ||
221 | Config cfg("Image Viewer"); | 221 | Config cfg("Image Viewer"); |
222 | cfg.setGroup("Image Viewer"); | 222 | cfg.setGroup("Image Viewer"); |
223 | 223 | ||
224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
225 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 225 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
226 | 226 | ||
227 | isFullScreen = FALSE; | 227 | isFullScreen = FALSE; |
228 | 228 | ||
229 | setToolBarsMovable( FALSE ); | 229 | setToolBarsMovable( FALSE ); |
230 | 230 | ||
231 | toolBar = new QToolBar( this ); | 231 | toolBar = new QToolBar( this ); |
232 | toolBar->setHorizontalStretchable( TRUE ); | 232 | toolBar->setHorizontalStretchable( TRUE ); |
233 | 233 | ||
234 | menuBar = new QMenuBar( toolBar ); | 234 | menuBar = new QMenuBar( toolBar ); |
235 | 235 | ||
236 | current=menuBar; | 236 | current=menuBar; |
237 | 237 | ||
238 | 238 | ||
239 | 239 | ||
240 | fileMenuFile = new QPopupMenu(this); | 240 | fileMenuFile = new QPopupMenu(this); |
241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
242 | fileMenuFile->insertItem(tr("Open"), | 242 | fileMenuFile->insertItem(tr("Open"), |
243 | this, SLOT(openFile()), 0); | 243 | this, SLOT(openFile()), 0); |
244 | 244 | ||
245 | viewMenuFile = new QPopupMenu( this ); | 245 | viewMenuFile = new QPopupMenu( this ); |
246 | //menubarFile->insertItem( tr("View"), viewMenu ); | 246 | //menubarFile->insertItem( tr("View"), viewMenu ); |
247 | viewMenuFile->insertItem( tr("Thumbnail View"), | 247 | viewMenuFile->insertItem( tr("Thumbnail View"), |
248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
249 | 249 | ||
250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
251 | 251 | ||
252 | 252 | ||
253 | 253 | ||
254 | 254 | ||
255 | optionsMenuFile = new QPopupMenu( this); | 255 | optionsMenuFile = new QPopupMenu( this); |
256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
258 | QString::null, 0, this, 0 ); | 258 | QString::null, 0, this, 0 ); |
259 | slideAction->setToggleAction( TRUE ); | 259 | slideAction->setToggleAction( TRUE ); |
260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
261 | slideAction->addTo( optionsMenuFile); | 261 | slideAction->addTo( optionsMenuFile); |
262 | // slideAction->addTo( toolBar ); | 262 | // slideAction->addTo( toolBar ); |
263 | 263 | ||
264 | 264 | ||
265 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 265 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
266 | optionsMenuFile->insertSeparator(); | 266 | optionsMenuFile->insertSeparator(); |
267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
269 | 269 | ||
270 | QStrList fmt = QImage::outputFormats(); | 270 | QStrList fmt = QImage::outputFormats(); |
271 | 271 | ||
272 | 272 | ||
273 | fileMenuView = new QPopupMenu( this ); | 273 | fileMenuView = new QPopupMenu( this ); |
274 | //menubarView->insertItem( tr("File"),fileMenu ); | 274 | //menubarView->insertItem( tr("File"),fileMenu ); |
275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
276 | fileMenuView->insertSeparator(); | 276 | fileMenuView->insertSeparator(); |
277 | 277 | ||
278 | viewMenuView = new QPopupMenu(this ); | 278 | viewMenuView = new QPopupMenu(this ); |
279 | viewMenuView->setCheckable ( true ); | 279 | viewMenuView->setCheckable ( true ); |
280 | 280 | ||
281 | //menubarView->insertItem( tr("View"),viewMenu ); | 281 | //menubarView->insertItem( tr("View"),viewMenu ); |
282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
284 | 284 | ||
285 | stack = new QWidgetStack( this ); | 285 | stack = new QWidgetStack( this ); |
286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
287 | setCentralWidget( stack ); | 287 | setCentralWidget( stack ); |
288 | 288 | ||
289 | 289 | ||
290 | imagePanel = new ImagePane( stack ); | 290 | imagePanel = new ImagePane( stack ); |
291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
292 | 292 | ||
293 | 293 | ||
294 | ImageFileSelector::CURRENT_VIEW cv; | 294 | ImageFileSelector::CURRENT_VIEW cv; |
295 | if(showThumbView) | 295 | if(showThumbView) |
296 | cv=ImageFileSelector::THUMBNAIL; | 296 | cv=ImageFileSelector::THUMBNAIL; |
297 | else | 297 | else |
298 | cv=ImageFileSelector::DETAILED; | 298 | cv=ImageFileSelector::DETAILED; |
299 | 299 | ||
300 | qDebug("cv = %d",cv); | 300 | qDebug("cv = %d",cv); |
301 | 301 | ||
302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
303 | 303 | ||
304 | //switchThumbView(); | 304 | //switchThumbView(); |
305 | 305 | ||
306 | 306 | ||
307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
308 | //fileSelector->setNewVisible(FALSE); | 308 | //fileSelector->setNewVisible(FALSE); |
309 | //fileSelector->setCloseVisible(FALSE); | 309 | //fileSelector->setCloseVisible(FALSE); |
310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
311 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 311 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), |
312 | this, SLOT( openFile( const DocLnk & ) ) ); | 312 | this, SLOT( openFile(const DocLnk&) ) ); |
313 | 313 | ||
314 | imageList = fileSelector->fileList(); | 314 | imageList = fileSelector->fileList(); |
315 | slideAction->setEnabled( imageList.count() != 0); | 315 | slideAction->setEnabled( imageList.count() != 0); |
316 | 316 | ||
317 | iconToolBar = new QToolBar(this); | 317 | iconToolBar = new QToolBar(this); |
318 | 318 | ||
319 | QAction *a; | 319 | QAction *a; |
320 | 320 | ||
321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
323 | a->addTo( fileMenuView); | 323 | a->addTo( fileMenuView); |
324 | a->addTo( iconToolBar ); | 324 | a->addTo( iconToolBar ); |
325 | 325 | ||
326 | 326 | ||
327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
329 | a->addTo( iconToolBar ); | 329 | a->addTo( iconToolBar ); |
330 | a->addTo( viewMenuView ); | 330 | a->addTo( viewMenuView ); |
331 | 331 | ||
332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
334 | a->addTo( iconToolBar ); | 334 | a->addTo( iconToolBar ); |
335 | a->addTo( viewMenuView ); | 335 | a->addTo( viewMenuView ); |
336 | 336 | ||
337 | 337 | ||
338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); | 338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); |
339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
340 | //a->addTo( iconToolBar ); | 340 | //a->addTo( iconToolBar ); |
341 | a->addTo( viewMenuView ); | 341 | a->addTo( viewMenuView ); |
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | viewMenuView->insertSeparator(); | 345 | viewMenuView->insertSeparator(); |
346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
348 | viewMenuView->insertSeparator(); | 348 | viewMenuView->insertSeparator(); |
349 | 349 | ||
350 | 350 | ||
351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
353 | sss->addTo( iconToolBar ); | 353 | sss->addTo( iconToolBar ); |
354 | sss->addTo( viewMenuView ); | 354 | sss->addTo( viewMenuView ); |
355 | 355 | ||
356 | sss->setOn(isSized); | 356 | sss->setOn(isSized); |
357 | viewMenuView->insertSeparator(); | 357 | viewMenuView->insertSeparator(); |
358 | 358 | ||
359 | 359 | ||
360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
361 | QString::null, 0, this, 0 ); | 361 | QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
363 | a->addTo( iconToolBar ); | 363 | a->addTo( iconToolBar ); |
364 | a->addTo( viewMenuView); | 364 | a->addTo( viewMenuView); |
365 | 365 | ||
366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
367 | QString::null, 0, this, 0 ); | 367 | QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
369 | a->addTo( iconToolBar ); | 369 | a->addTo( iconToolBar ); |
370 | a->addTo( viewMenuView); | 370 | a->addTo( viewMenuView); |
371 | 371 | ||
372 | 372 | ||
373 | Config config( "ImageViewer" ); | 373 | Config config( "ImageViewer" ); |
374 | config.setGroup( "SlideShow" ); | 374 | config.setGroup( "SlideShow" ); |
375 | slideDelay = config.readNumEntry( "Delay", 2); | 375 | slideDelay = config.readNumEntry( "Delay", 2); |
376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
377 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 377 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
378 | 378 | ||
379 | config.setGroup("Default"); | 379 | config.setGroup("Default"); |
380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
382 | slideTimer = new QTimer( this ); | 382 | slideTimer = new QTimer( this ); |
383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
384 | 384 | ||
385 | switchToFileSelector(); | 385 | switchToFileSelector(); |
386 | 386 | ||
387 | setMouseTracking( TRUE ); | 387 | setMouseTracking( TRUE ); |
388 | 388 | ||
389 | 389 | ||
390 | } | 390 | } |
391 | 391 | ||
392 | ImageViewer::~ImageViewer() | 392 | ImageViewer::~ImageViewer() |
393 | { | 393 | { |
394 | Config cfg("Image Viewer"); | 394 | Config cfg("Image Viewer"); |
395 | cfg.setGroup("Image Viewer"); | 395 | cfg.setGroup("Image Viewer"); |
396 | 396 | ||
397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
398 | cfg.writeEntry("SizeToScreen",(int)isSized); | 398 | cfg.writeEntry("SizeToScreen",(int)isSized); |
399 | 399 | ||
400 | cfg.setGroup( "SlideShow" ); | 400 | cfg.setGroup( "SlideShow" ); |
401 | cfg.writeEntry( "Delay", slideDelay); | 401 | cfg.writeEntry( "Delay", slideDelay); |
402 | cfg.writeEntry( "Repeat", slideRepeat ); | 402 | cfg.writeEntry( "Repeat", slideRepeat ); |
403 | cfg.writeEntry("Reverse", slideReverse); | 403 | cfg.writeEntry("Reverse", slideReverse); |
404 | 404 | ||
405 | cfg.setGroup("Default"); | 405 | cfg.setGroup("Default"); |
406 | cfg.writeEntry("Rotate", rotateOnLoad); | 406 | cfg.writeEntry("Rotate", rotateOnLoad); |
407 | cfg.writeEntry("FastLoad", fastLoad); | 407 | cfg.writeEntry("FastLoad", fastLoad); |
408 | 408 | ||
409 | delete imagePanel; // in case it is fullscreen | 409 | delete imagePanel; // in case it is fullscreen |
410 | } | 410 | } |
411 | 411 | ||
412 | void ImageViewer::help() { | 412 | void ImageViewer::help() { |
413 | 413 | ||
414 | } | 414 | } |
415 | 415 | ||
416 | 416 | ||
417 | void ImageViewer::settings() | 417 | void ImageViewer::settings() |
418 | { | 418 | { |
419 | SettingsDialog dlg( this, 0, TRUE ); | 419 | SettingsDialog dlg( this, 0, TRUE ); |
420 | dlg.setDelay( slideDelay ); | 420 | dlg.setDelay( slideDelay ); |
421 | dlg.setRepeat( slideRepeat ); | 421 | dlg.setRepeat( slideRepeat ); |
422 | dlg.setReverse( slideReverse ); | 422 | dlg.setReverse( slideReverse ); |
423 | dlg.setRotate(rotateOnLoad); | 423 | dlg.setRotate(rotateOnLoad); |
424 | dlg.setFastLoad(fastLoad); | 424 | dlg.setFastLoad(fastLoad); |
425 | 425 | ||
426 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 426 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
427 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 427 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
428 | slideDelay = dlg.delay(); | 428 | slideDelay = dlg.delay(); |
429 | slideRepeat = dlg.repeat(); | 429 | slideRepeat = dlg.repeat(); |
430 | slideReverse = dlg.reverse(); | 430 | slideReverse = dlg.reverse(); |
431 | rotateOnLoad = dlg.rotate(); | 431 | rotateOnLoad = dlg.rotate(); |
432 | fastLoad = dlg.fastLoad(); | 432 | fastLoad = dlg.fastLoad(); |
433 | 433 | ||
434 | Config config( "ImageViewer" ); | 434 | Config config( "ImageViewer" ); |
435 | config.setGroup( "SlideShow" ); | 435 | config.setGroup( "SlideShow" ); |
436 | config.writeEntry( "Delay", slideDelay ); | 436 | config.writeEntry( "Delay", slideDelay ); |
437 | config.writeEntry( "Repeat", slideRepeat ); | 437 | config.writeEntry( "Repeat", slideRepeat ); |
438 | config.writeEntry("Reverse", slideReverse); | 438 | config.writeEntry("Reverse", slideReverse); |
439 | 439 | ||
440 | config.setGroup("Default"); | 440 | config.setGroup("Default"); |
441 | config.writeEntry("Rotate", rotateOnLoad); | 441 | config.writeEntry("Rotate", rotateOnLoad); |
442 | config.writeEntry("FastLoad", fastLoad); | 442 | config.writeEntry("FastLoad", fastLoad); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | void ImageViewer::switchSizeToScreen() | 446 | void ImageViewer::switchSizeToScreen() |
447 | { | 447 | { |
448 | isSized=!isSized; | 448 | isSized=!isSized; |
449 | sss->setOn(isSized); | 449 | sss->setOn(isSized); |
450 | updateImage(); | 450 | updateImage(); |
451 | } | 451 | } |
452 | 452 | ||
453 | void ImageViewer::updateImage() | 453 | void ImageViewer::updateImage() |
454 | { | 454 | { |
455 | if ( isSized ) { | 455 | if ( isSized ) { |
456 | imagePanel->setPixmap(pmScaled); | 456 | imagePanel->setPixmap(pmScaled); |
457 | } else { | 457 | } else { |
458 | imagePanel->setPixmap(pm); | 458 | imagePanel->setPixmap(pm); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | 461 | ||
462 | void ImageViewer::switchThumbView() | 462 | void ImageViewer::switchThumbView() |
463 | { | 463 | { |
464 | 464 | ||
465 | showThumbView=!showThumbView; | 465 | showThumbView=!showThumbView; |
466 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 466 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
467 | fileSelector->switchView(); | 467 | fileSelector->switchView(); |
468 | 468 | ||
469 | } | 469 | } |
470 | 470 | ||
471 | void ImageViewer::switchToFileSelector() | 471 | void ImageViewer::switchToFileSelector() |
472 | { | 472 | { |
473 | stack->raiseWidget(fileSelector); | 473 | stack->raiseWidget(fileSelector); |
474 | menuBar->clear(); | 474 | menuBar->clear(); |
475 | menuBar->insertItem( tr("File"), fileMenuFile ); | 475 | menuBar->insertItem( tr("File"), fileMenuFile ); |
476 | menuBar->insertItem( tr("View"), viewMenuFile ); | 476 | menuBar->insertItem( tr("View"), viewMenuFile ); |
477 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 477 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
478 | iconToolBar->hide(); | 478 | iconToolBar->hide(); |
479 | imagePanel->disable(); | 479 | imagePanel->disable(); |
480 | slideShow(false); | 480 | slideShow(false); |
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | void ImageViewer::switchToImageView() | 484 | void ImageViewer::switchToImageView() |
485 | { | 485 | { |
486 | stack->raiseWidget(imagePanel); | 486 | stack->raiseWidget(imagePanel); |
487 | 487 | ||
488 | menuBar->clear(); | 488 | menuBar->clear(); |
489 | menuBar->insertItem( tr("File"), fileMenuView ); | 489 | menuBar->insertItem( tr("File"), fileMenuView ); |
490 | menuBar->insertItem( tr("View"), viewMenuView ); | 490 | menuBar->insertItem( tr("View"), viewMenuView ); |
491 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); | 491 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); |
492 | iconToolBar->show(); | 492 | iconToolBar->show(); |
493 | 493 | ||
494 | imagePanel->setPosition(0,0); | 494 | imagePanel->setPosition(0,0); |
495 | 495 | ||
496 | } | 496 | } |
497 | 497 | ||
498 | 498 | ||
499 | void ImageViewer::setDocument(const QString& fileref) | 499 | void ImageViewer::setDocument(const QString& fileref) |
500 | { | 500 | { |
501 | delayLoad = fileref; | 501 | delayLoad = fileref; |
502 | switchToImageView(); | 502 | switchToImageView(); |
503 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 503 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
504 | } | 504 | } |
505 | 505 | ||
506 | void ImageViewer::doDelayedLoad() | 506 | void ImageViewer::doDelayedLoad() |
507 | { | 507 | { |
508 | show(delayLoad); | 508 | show(delayLoad); |
509 | } | 509 | } |
510 | 510 | ||
511 | void ImageViewer::show() | 511 | void ImageViewer::show() |
512 | { | 512 | { |
513 | normalView(); | 513 | normalView(); |
514 | QMainWindow::show(); | 514 | QMainWindow::show(); |
515 | } | 515 | } |
516 | 516 | ||
517 | void ImageViewer::show(const QString& fileref) | 517 | void ImageViewer::show(const QString& fileref) |
518 | { | 518 | { |
519 | // qDebug("Show "+fileref); | 519 | // qDebug("Show "+fileref); |
520 | bFromDocView = TRUE; | 520 | bFromDocView = TRUE; |
521 | closeFileSelector(); | 521 | closeFileSelector(); |
522 | DocLnk link(fileref); | 522 | DocLnk link(fileref); |
523 | if ( link.isValid() ) { | 523 | if ( link.isValid() ) { |
524 | openFile(link); | 524 | openFile(link); |
525 | } else { | 525 | } else { |
526 | filename = fileref; | 526 | filename = fileref; |
527 | updateCaption( fileref ); | 527 | updateCaption( fileref ); |
528 | loadImage( fileref ); | 528 | loadImage( fileref ); |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | void ImageViewer::openFile() { | 532 | void ImageViewer::openFile() { |
533 | MimeTypes types; | 533 | MimeTypes types; |
534 | QStringList image; | 534 | QStringList image; |
535 | image << "image/*"; | 535 | image << "image/*"; |
536 | types.insert("Images", image); | 536 | types.insert("Images", image); |
537 | 537 | ||
538 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 538 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
539 | DocLnk link(str); | 539 | DocLnk link(str); |
540 | // if ( link.isValid() ) | 540 | // if ( link.isValid() ) |
541 | openFile(link); | 541 | openFile(link); |
542 | 542 | ||
543 | } | 543 | } |
544 | 544 | ||
545 | void ImageViewer::openFile( const DocLnk &link ) | 545 | void ImageViewer::openFile( const DocLnk &link ) |
546 | { | 546 | { |
547 | closeFileSelector(); | 547 | closeFileSelector(); |
548 | // DocLnk link(file); | 548 | // DocLnk link(file); |
549 | qDebug("open "+link.name()); | 549 | qDebug("open "+link.name()); |
550 | updateCaption( link.name() ); | 550 | updateCaption( link.name() ); |
551 | loadImage( link.file() ); | 551 | loadImage( link.file() ); |
552 | if (slideTimer->isActive()) { | 552 | if (slideTimer->isActive()) { |
553 | slideTimer->start(slideDelay * 1000, FALSE); | 553 | slideTimer->start(slideDelay * 1000, FALSE); |
554 | } | 554 | } |
555 | 555 | ||
556 | } | 556 | } |
557 | 557 | ||
558 | void ImageViewer::open() | 558 | void ImageViewer::open() |
559 | { | 559 | { |
560 | switchToFileSelector(); | 560 | switchToFileSelector(); |
561 | } | 561 | } |
562 | 562 | ||
563 | void ImageViewer::closeFileSelector() | 563 | void ImageViewer::closeFileSelector() |
564 | { | 564 | { |
565 | switchToImageView(); | 565 | switchToImageView(); |
566 | } | 566 | } |
567 | 567 | ||
568 | void ImageViewer::updateCaption( QString name ) | 568 | void ImageViewer::updateCaption( QString name ) |
569 | { | 569 | { |
570 | int sep = name.findRev( '/' ); | 570 | int sep = name.findRev( '/' ); |
571 | if ( sep >= 0 ) | 571 | if ( sep >= 0 ) |
572 | name = name.mid( sep+1 ); | 572 | name = name.mid( sep+1 ); |
573 | setCaption( name + tr(" - Image Viewer") ); | 573 | setCaption( name + tr(" - Image Viewer") ); |
574 | } | 574 | } |
575 | 575 | ||
576 | /* | 576 | /* |
577 | This function loads an image from a file. | 577 | This function loads an image from a file. |
578 | */ | 578 | */ |
579 | 579 | ||
580 | void ImageViewer::loadImage( const char *fileName ) | 580 | void ImageViewer::loadImage( const char *fileName ) |
581 | { | 581 | { |
582 | filename = fileName; | 582 | filename = fileName; |
583 | if ( filename ) { | 583 | if ( filename ) { |
584 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 584 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
585 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); | 585 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); |
586 | qApp->processEvents(); | 586 | qApp->processEvents(); |
587 | bool ok = image.load(filename, 0); | 587 | bool ok = image.load(filename, 0); |
588 | if ( ok ) { | 588 | if ( ok ) { |
589 | ok = reconvertImage(); | 589 | ok = reconvertImage(); |
590 | updateImageInfo(filename); | 590 | updateImageInfo(filename); |
591 | } | 591 | } |
592 | if ( !ok ) { | 592 | if ( !ok ) { |
593 | pm.resize(0,0); // couldn't load image | 593 | pm.resize(0,0); // couldn't load image |
594 | update(); | 594 | update(); |
595 | } | 595 | } |
596 | QApplication::restoreOverrideCursor(); // restore original cursor | 596 | QApplication::restoreOverrideCursor(); // restore original cursor |
597 | } | 597 | } |
598 | 598 | ||
599 | // fastLoad ? ", Fast" : "", | 599 | // fastLoad ? ", Fast" : "", |
600 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); | 600 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); |
601 | 601 | ||
602 | 602 | ||
603 | // matrix.reset(); | 603 | // matrix.reset(); |
604 | rotated90 = FALSE; | 604 | rotated90 = FALSE; |
605 | 605 | ||
606 | if (rotateOnLoad) { | 606 | if (rotateOnLoad) { |
607 | rotated90 = TRUE; | 607 | rotated90 = TRUE; |
608 | rot90(); | 608 | rot90(); |
609 | // matrix.rotate( -90.0 ); | 609 | // matrix.rotate( -90.0 ); |
610 | } | 610 | } |
611 | 611 | ||
612 | switchToImageView(); | 612 | switchToImageView(); |
613 | updateImage(); | 613 | updateImage(); |
614 | 614 | ||
615 | } | 615 | } |
616 | 616 | ||
617 | bool ImageViewer::loadSelected() | 617 | bool ImageViewer::loadSelected() |
618 | { | 618 | { |
619 | bool ok = false; | 619 | bool ok = false; |
620 | if ( stack->visibleWidget() == fileSelector ) | 620 | if ( stack->visibleWidget() == fileSelector ) |
621 | { | 621 | { |
622 | const DocLnk *link = fileSelector->selected(); | 622 | const DocLnk *link = fileSelector->selected(); |
623 | if ( link ) | 623 | if ( link ) |
624 | { | 624 | { |
625 | if ( link->file() != filename ) | 625 | if ( link->file() != filename ) |
626 | { | 626 | { |
627 | updateCaption( link->name() ); | 627 | updateCaption( link->name() ); |
628 | filename = link->file(); | 628 | filename = link->file(); |
629 | qApp->processEvents(); | 629 | qApp->processEvents(); |
630 | ok = image.load(filename, 0); | 630 | ok = image.load(filename, 0); |
631 | if ( ok ) | 631 | if ( ok ) |
632 | { | 632 | { |
633 | updateImageInfo(filename); | 633 | updateImageInfo(filename); |
634 | ok = reconvertImage(); | 634 | ok = reconvertImage(); |
635 | } | 635 | } |
636 | if ( !ok ) | 636 | if ( !ok ) |
637 | pm.resize(0,0); | 637 | pm.resize(0,0); |
638 | } | 638 | } |
639 | } | 639 | } |
640 | } | 640 | } |
641 | if ( !image.isNull() ) | 641 | if ( !image.isNull() ) |
642 | { | 642 | { |
643 | ok = true; | 643 | ok = true; |
644 | closeFileSelector(); | 644 | closeFileSelector(); |
645 | } | 645 | } |
646 | 646 | ||
647 | return ok; | 647 | return ok; |
648 | } | 648 | } |
649 | 649 | ||
650 | bool ImageViewer::reconvertImage() | 650 | bool ImageViewer::reconvertImage() |
651 | { | 651 | { |
652 | bool success = FALSE; | 652 | bool success = FALSE; |
653 | 653 | ||
654 | if ( image.isNull() ) return FALSE; | 654 | if ( image.isNull() ) return FALSE; |
655 | 655 | ||
656 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 656 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
657 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) | 657 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) |
658 | { | 658 | { |
659 | pmScaled = QPixmap(); | 659 | pmScaled = QPixmap(); |
660 | scale(); | 660 | scale(); |
661 | success = TRUE; // load successful | 661 | success = TRUE; // load successful |
662 | } | 662 | } |
663 | else | 663 | else |
664 | { | 664 | { |
665 | pm.resize(0,0); // couldn't load image | 665 | pm.resize(0,0); // couldn't load image |
666 | } | 666 | } |
667 | QApplication::restoreOverrideCursor(); // restore original cursor | 667 | QApplication::restoreOverrideCursor(); // restore original cursor |
668 | 668 | ||
669 | return success; // TRUE if loaded OK | 669 | return success; // TRUE if loaded OK |
670 | } | 670 | } |
671 | 671 | ||
672 | 672 | ||
673 | int ImageViewer::calcHeight() | 673 | int ImageViewer::calcHeight() |
674 | { | 674 | { |
675 | if ( !isFullScreen ) | 675 | if ( !isFullScreen ) |
676 | return imagePanel->paneHeight(); | 676 | return imagePanel->paneHeight(); |
677 | else | 677 | else |
678 | return qApp->desktop()->height(); | 678 | return qApp->desktop()->height(); |
679 | } | 679 | } |
680 | /* | 680 | /* |
681 | This functions scales the pixmap in the member variable "pm" to fit the | 681 | This functions scales the pixmap in the member variable "pm" to fit the |
682 | widget size and puts the resulting pixmap in the member variable "pmScaled". | 682 | widget size and puts the resulting pixmap in the member variable "pmScaled". |
683 | */ | 683 | */ |
684 | void ImageViewer::scale() | 684 | void ImageViewer::scale() |
685 | { | 685 | { |
686 | int h = calcHeight(); | 686 | int h = calcHeight(); |
687 | if ( image.isNull() ) return; | 687 | if ( image.isNull() ) return; |
688 | 688 | ||
689 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 689 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
690 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) | 690 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) |
691 | { // no need to scale if widget | 691 | { // no need to scale if widget |
692 | pmScaled = pm; // size equals pixmap size | 692 | pmScaled = pm; // size equals pixmap size |
693 | } | 693 | } |
694 | else | 694 | else |
695 | { | 695 | { |
696 | double hs = (double)h / (double)image.height(); | 696 | double hs = (double)h / (double)image.height(); |