-rw-r--r-- | noncore/graphics/opie-eye/slave/jpeg_slave.cpp | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/slavereciever.cpp | 11 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/thumbnailtool.cpp | 3 |
3 files changed, 4 insertions, 13 deletions
diff --git a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp index 668ad13..0f41359 100644 --- a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp +++ b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp | |||
@@ -1,199 +1,196 @@ | |||
1 | #include "jpeg_slave.h" | 1 | #include "jpeg_slave.h" |
2 | #include "thumbnailtool.h" | 2 | #include "thumbnailtool.h" |
3 | 3 | ||
4 | PHUNK_VIEW_INTERFACE( "JPEG", JpegSlave ) | 4 | PHUNK_VIEW_INTERFACE( "JPEG", JpegSlave ) |
5 | 5 | ||
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <opie2/opieexif.h> | 8 | #include <opie2/opieexif.h> |
9 | #include <qpe/timestring.h> | 9 | #include <qpe/timestring.h> |
10 | using namespace Opie::Core; | 10 | using namespace Opie::Core; |
11 | using namespace Opie::MM; | 11 | using namespace Opie::MM; |
12 | 12 | ||
13 | /* QT */ | 13 | /* QT */ |
14 | #include <qobject.h> | 14 | #include <qobject.h> |
15 | #include <qimage.h> | 15 | #include <qimage.h> |
16 | static QDateTime parseDateTime( const QString& string ) | 16 | static QDateTime parseDateTime( const QString& string ) |
17 | { | 17 | { |
18 | QDateTime dt; | 18 | QDateTime dt; |
19 | if ( string.length() != 19 ) | 19 | if ( string.length() != 19 ) |
20 | return dt; | 20 | return dt; |
21 | 21 | ||
22 | QString year = string.left( 4 ); | 22 | QString year = string.left( 4 ); |
23 | QString month = string.mid( 5, 2 ); | 23 | QString month = string.mid( 5, 2 ); |
24 | QString day = string.mid( 8, 2 ); | 24 | QString day = string.mid( 8, 2 ); |
25 | QString hour = string.mid( 11, 2 ); | 25 | QString hour = string.mid( 11, 2 ); |
26 | QString minute = string.mid( 14, 2 ); | 26 | QString minute = string.mid( 14, 2 ); |
27 | QString seconds = string.mid( 18, 2 ); | 27 | QString seconds = string.mid( 18, 2 ); |
28 | 28 | ||
29 | bool ok; | 29 | bool ok; |
30 | bool allOk = true; | 30 | bool allOk = true; |
31 | int y = year.toInt( &ok ); | 31 | int y = year.toInt( &ok ); |
32 | allOk &= ok; | 32 | allOk &= ok; |
33 | 33 | ||
34 | int mo = month.toInt( &ok ); | 34 | int mo = month.toInt( &ok ); |
35 | allOk &= ok; | 35 | allOk &= ok; |
36 | 36 | ||
37 | int d = day.toInt( &ok ); | 37 | int d = day.toInt( &ok ); |
38 | allOk &= ok; | 38 | allOk &= ok; |
39 | 39 | ||
40 | int h = hour.toInt( &ok ); | 40 | int h = hour.toInt( &ok ); |
41 | allOk &= ok; | 41 | allOk &= ok; |
42 | 42 | ||
43 | int mi = minute.toInt( &ok ); | 43 | int mi = minute.toInt( &ok ); |
44 | allOk &= ok; | 44 | allOk &= ok; |
45 | 45 | ||
46 | int s = seconds.toInt( &ok ); | 46 | int s = seconds.toInt( &ok ); |
47 | allOk &= ok; | 47 | allOk &= ok; |
48 | 48 | ||
49 | if ( allOk ) { | 49 | if ( allOk ) { |
50 | dt.setDate( QDate( y, mo, d ) ); | 50 | dt.setDate( QDate( y, mo, d ) ); |
51 | dt.setTime( QTime( h, mi, s ) ); | 51 | dt.setTime( QTime( h, mi, s ) ); |
52 | } | 52 | } |
53 | 53 | ||
54 | return dt; | 54 | return dt; |
55 | } | 55 | } |
56 | 56 | ||
57 | JpegSlave::JpegSlave() | 57 | JpegSlave::JpegSlave() |
58 | : SlaveInterface( QStringList::split( " ", "jpeg jpg" ) ) | 58 | : SlaveInterface( QStringList::split( " ", "jpeg jpg" ) ) |
59 | {} | 59 | {} |
60 | 60 | ||
61 | JpegSlave::~JpegSlave() {} | 61 | JpegSlave::~JpegSlave() {} |
62 | 62 | ||
63 | QString JpegSlave::iconViewName( const QString& path) { | 63 | QString JpegSlave::iconViewName( const QString& path) { |
64 | ExifData ImageInfo; | 64 | ExifData ImageInfo; |
65 | if ( !ImageInfo.scan( path ) ) | 65 | if ( !ImageInfo.scan( path ) ) |
66 | return QString::null; | 66 | return QString::null; |
67 | 67 | ||
68 | QString tag; | 68 | QString tag; |
69 | tag = QObject::tr( "Comment: %1\n" ).arg( ImageInfo.getComment() ); | 69 | tag = QObject::tr( "Comment: %1\n" ).arg( ImageInfo.getComment() ); |
70 | { | 70 | { |
71 | // ODP fixme | 71 | // ODP fixme |
72 | QString timestring = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); | 72 | QString timestring = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); |
73 | tag += QObject::tr( "Date/Time: %1\n" ).arg( timestring ); | 73 | tag += QObject::tr( "Date/Time: %1\n" ).arg( timestring ); |
74 | } | 74 | } |
75 | tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) | 75 | tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) |
76 | .arg(ImageInfo.getHeight() ); | 76 | .arg(ImageInfo.getHeight() ); |
77 | 77 | ||
78 | tag += ExifData::color_mode_to_string( ImageInfo.getIsColor() ); | 78 | tag += ExifData::color_mode_to_string( ImageInfo.getIsColor() ); |
79 | 79 | ||
80 | tag += ExifData::compression_to_string( ImageInfo.getCompressionLevel() ); | 80 | tag += ExifData::compression_to_string( ImageInfo.getCompressionLevel() ); |
81 | 81 | ||
82 | return tag; | 82 | return tag; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | /* | 86 | /* |
87 | * messy messy string creation | 87 | * messy messy string creation |
88 | */ | 88 | */ |
89 | QString JpegSlave::fullImageInfo( const QString& path) { | 89 | QString JpegSlave::fullImageInfo( const QString& path) { |
90 | ExifData ImageInfo; | 90 | ExifData ImageInfo; |
91 | if ( !ImageInfo.scan( path ) ) | 91 | if ( !ImageInfo.scan( path ) ) |
92 | return QString::null; | 92 | return QString::null; |
93 | 93 | ||
94 | QString tag, tmp; | 94 | QString tag, tmp; |
95 | tag = QObject::tr( "<qt>Comment: %1\n" ).arg( ImageInfo.getComment() ); | 95 | tag = QObject::tr( "<qt>Comment: %1\n" ).arg( ImageInfo.getComment() ); |
96 | 96 | ||
97 | tmp = ImageInfo.getCameraMake(); | 97 | tmp = ImageInfo.getCameraMake(); |
98 | if ( tmp.length() ) | 98 | if ( tmp.length() ) |
99 | tag += QObject::tr( "Manufacturer: %1\n" ).arg( tmp ); | 99 | tag += QObject::tr( "Manufacturer: %1\n" ).arg( tmp ); |
100 | tmp = ImageInfo.getCameraModel(); | 100 | tmp = ImageInfo.getCameraModel(); |
101 | if ( tmp.length() ) | 101 | if ( tmp.length() ) |
102 | tag += QObject::tr( "Model: %1\n" ).arg( tmp ); | 102 | tag += QObject::tr( "Model: %1\n" ).arg( tmp ); |
103 | { | 103 | { |
104 | // ODP fixme | 104 | // ODP fixme |
105 | tmp = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); | 105 | tmp = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); |
106 | tag += QObject::tr( "Date/Time: %1\n" ).arg( tmp ); | 106 | tag += QObject::tr( "Date/Time: %1\n" ).arg( tmp ); |
107 | } | 107 | } |
108 | tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) | 108 | tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) |
109 | .arg(ImageInfo.getHeight() ); | 109 | .arg(ImageInfo.getHeight() ); |
110 | 110 | ||
111 | tag += ExifData::color_mode_to_string( ImageInfo.getIsColor() ); | 111 | tag += ExifData::color_mode_to_string( ImageInfo.getIsColor() ); |
112 | 112 | ||
113 | tag += ExifData::compression_to_string( ImageInfo.getCompressionLevel() ); | 113 | tag += ExifData::compression_to_string( ImageInfo.getCompressionLevel() ); |
114 | if ( ImageInfo.getOrientation() ) | 114 | if ( ImageInfo.getOrientation() ) |
115 | tag += QObject::tr( "Orientation: %1\n" ).arg(ImageInfo.getOrientation() ); | 115 | tag += QObject::tr( "Orientation: %1\n" ).arg(ImageInfo.getOrientation() ); |
116 | 116 | ||
117 | 117 | ||
118 | { | 118 | { |
119 | int flash_used = ImageInfo.getFlashUsed(); | 119 | int flash_used = ImageInfo.getFlashUsed(); |
120 | if ( flash_used >= 0 ) | 120 | if ( flash_used >= 0 ) |
121 | tag += QObject::tr( "Flash used\n" ); | 121 | tag += QObject::tr( "Flash used\n" ); |
122 | } | 122 | } |
123 | 123 | ||
124 | if ( ImageInfo.getFocalLength() ) { | 124 | if ( ImageInfo.getFocalLength() ) { |
125 | tag += QObject::tr( "Focal length: %1\n" ).arg( QString().sprintf( "%4.1f", ImageInfo.getFocalLength() ) ); | 125 | tag += QObject::tr( "Focal length: %1\n" ).arg( QString().sprintf( "%4.1f", ImageInfo.getFocalLength() ) ); |
126 | if ( ImageInfo.getCCDWidth() ) | 126 | if ( ImageInfo.getCCDWidth() ) |
127 | tag += QObject::tr( "35mm equivalent: %1\n" ).arg( (int)(ImageInfo.getFocalLength()/ImageInfo.getCCDWidth()*35 + 0.5) ); | 127 | tag += QObject::tr( "35mm equivalent: %1\n" ).arg( (int)(ImageInfo.getFocalLength()/ImageInfo.getCCDWidth()*35 + 0.5) ); |
128 | 128 | ||
129 | } | 129 | } |
130 | 130 | ||
131 | if ( ImageInfo.getCCDWidth() ) | 131 | if ( ImageInfo.getCCDWidth() ) |
132 | tag += QObject::tr( "CCD width: %1" ).arg( ImageInfo.getCCDWidth() ); | 132 | tag += QObject::tr( "CCD width: %1" ).arg( ImageInfo.getCCDWidth() ); |
133 | if ( ImageInfo.getExposureTime() ) { | 133 | if ( ImageInfo.getExposureTime() ) { |
134 | tmp = QString().sprintf("%4.2f", ImageInfo.getExposureTime() ); | 134 | tmp = QString().sprintf("%4.2f", ImageInfo.getExposureTime() ); |
135 | float exposureTime = ImageInfo.getExposureTime(); | 135 | float exposureTime = ImageInfo.getExposureTime(); |
136 | if ( exposureTime > 0 && exposureTime <= 0.5 ) | 136 | if ( exposureTime > 0 && exposureTime <= 0.5 ) |
137 | tmp += QString().sprintf(" (1/%d)", (int)(0.5 +1/exposureTime) ); | 137 | tmp += QString().sprintf(" (1/%d)", (int)(0.5 +1/exposureTime) ); |
138 | tag += QObject::tr( "Exposure time: %1\n" ).arg( tmp ); | 138 | tag += QObject::tr( "Exposure time: %1\n" ).arg( tmp ); |
139 | } | 139 | } |
140 | 140 | ||
141 | if ( ImageInfo.getApertureFNumber() ) | 141 | if ( ImageInfo.getApertureFNumber() ) |
142 | tag += QObject::tr( "Aperture: %1\n" ).arg( QString().sprintf("f/%3.1f", (double)ImageInfo.getApertureFNumber() ) ); | 142 | tag += QObject::tr( "Aperture: %1\n" ).arg( QString().sprintf("f/%3.1f", (double)ImageInfo.getApertureFNumber() ) ); |
143 | 143 | ||
144 | if ( ImageInfo.getDistance() ) { | 144 | if ( ImageInfo.getDistance() ) { |
145 | if ( ImageInfo.getDistance() < 0 ) | 145 | if ( ImageInfo.getDistance() < 0 ) |
146 | tag += QObject::tr( "Distance: %1\n" ).arg( QObject::tr( "Infinite" ) ); | 146 | tag += QObject::tr( "Distance: %1\n" ).arg( QObject::tr( "Infinite" ) ); |
147 | else | 147 | else |
148 | tag += QObject::tr( "Distance: %1\n" ).arg( QString().sprintf( "%5.2fm", (double)ImageInfo.getDistance() ) ); | 148 | tag += QObject::tr( "Distance: %1\n" ).arg( QString().sprintf( "%5.2fm", (double)ImageInfo.getDistance() ) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | if ( ImageInfo.getExposureBias() ) { | 151 | if ( ImageInfo.getExposureBias() ) { |
152 | tag += QObject::tr( "Exposure bias: %1\n", QString().sprintf("%4.2f", (double)ImageInfo.getExposureBias() ) ); | 152 | tag += QObject::tr( "Exposure bias: %1\n", QString().sprintf("%4.2f", (double)ImageInfo.getExposureBias() ) ); |
153 | } | 153 | } |
154 | 154 | ||
155 | if ( ImageInfo.getWhitebalance() != -1 ) | 155 | if ( ImageInfo.getWhitebalance() != -1 ) |
156 | tag += ExifData::white_balance_string( ImageInfo.getWhitebalance() ); | 156 | tag += ExifData::white_balance_string( ImageInfo.getWhitebalance() ); |
157 | 157 | ||
158 | 158 | ||
159 | if( ImageInfo.getMeteringMode() != -1 ) | 159 | if( ImageInfo.getMeteringMode() != -1 ) |
160 | tag += ExifData::metering_mode( ImageInfo.getMeteringMode() ); | 160 | tag += ExifData::metering_mode( ImageInfo.getMeteringMode() ); |
161 | 161 | ||
162 | if ( ImageInfo.getExposureProgram() ) | 162 | if ( ImageInfo.getExposureProgram() ) |
163 | tag += ExifData::exposure_program( ImageInfo.getExposureProgram() ); | 163 | tag += ExifData::exposure_program( ImageInfo.getExposureProgram() ); |
164 | if ( ImageInfo.getISOequivalent() ) | 164 | if ( ImageInfo.getISOequivalent() ) |
165 | tag += QObject::tr( "ISO equivalent: %1\n" ).arg( QString().sprintf("%2d", ImageInfo.getISOequivalent() ) ); | 165 | tag += QObject::tr( "ISO equivalent: %1\n" ).arg( QString().sprintf("%2d", ImageInfo.getISOequivalent() ) ); |
166 | 166 | ||
167 | tmp = ImageInfo.getUserComment(); | 167 | tmp = ImageInfo.getUserComment(); |
168 | if ( tmp.length() ) | 168 | if ( tmp.length() ) |
169 | tag += QObject::tr( "EXIF comment: %1" ).arg( tmp ); | 169 | tag += QObject::tr( "EXIF comment: %1" ).arg( tmp ); |
170 | 170 | ||
171 | tag += QObject::tr( "</qt>" ); | 171 | tag += QObject::tr( "</qt>" ); |
172 | 172 | ||
173 | 173 | ||
174 | 174 | ||
175 | return tag; | 175 | return tag; |
176 | } | 176 | } |
177 | 177 | ||
178 | QPixmap JpegSlave::pixmap( const QString& path, int wid, int hei) { | 178 | QPixmap JpegSlave::pixmap( const QString& path, int wid, int hei) { |
179 | ExifData ImageInfo; | 179 | ExifData ImageInfo; |
180 | /* | 180 | /* |
181 | */ | 181 | */ |
182 | if ( !ImageInfo.scan( path ) || ImageInfo.isNullThumbnail() ) { | 182 | if ( !ImageInfo.scan( path ) || ImageInfo.isNullThumbnail() ) { |
183 | QImage img; | 183 | QImage img; |
184 | QImageIO iio( path, 0l ); | 184 | QImageIO iio( path, 0l ); |
185 | if (wid < ImageInfo.getWidth() || hei<ImageInfo.getHeight()) { | 185 | if (wid < ImageInfo.getWidth() || hei<ImageInfo.getHeight()) { |
186 | odebug << "Scaling "<<ImageInfo.getWidth()<<"x"<<ImageInfo.getHeight() | ||
187 | << " to "<<wid<<"x"<<hei<< " ("<<path<<")"<<oendl; | ||
188 | QString str = QString( "Fast Shrink( 4 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); | 186 | QString str = QString( "Fast Shrink( 4 ) Scale( %1, %2, ScaleFree)" ).arg( wid ).arg( hei ); |
189 | iio.setParameters( str.latin1() );// will be strdupped anyway | 187 | iio.setParameters( str.latin1() );// will be strdupped anyway |
190 | } else { | 188 | } else { |
191 | odebug << "Not scaling "<<ImageInfo.getWidth()<<"x"<<ImageInfo.getHeight()<< " ("<<path<<")"<<oendl; | ||
192 | } | 189 | } |
193 | img = iio.read() ? iio.image() : QImage(); | 190 | img = iio.read() ? iio.image() : QImage(); |
194 | return ThumbNailTool::scaleImage( img, wid,hei ); | 191 | return ThumbNailTool::scaleImage( img, wid,hei ); |
195 | }else{ | 192 | }else{ |
196 | QImage img = ImageInfo.getThumbnail(); | 193 | QImage img = ImageInfo.getThumbnail(); |
197 | return ThumbNailTool::scaleImage( img, wid,hei ); | 194 | return ThumbNailTool::scaleImage( img, wid,hei ); |
198 | } | 195 | } |
199 | } | 196 | } |
diff --git a/noncore/graphics/opie-eye/slave/slavereciever.cpp b/noncore/graphics/opie-eye/slave/slavereciever.cpp index 941a5df..3b11c04 100644 --- a/noncore/graphics/opie-eye/slave/slavereciever.cpp +++ b/noncore/graphics/opie-eye/slave/slavereciever.cpp | |||
@@ -1,238 +1,235 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "slavereciever.h" | 5 | #include "slavereciever.h" |
6 | #include "slaveiface.h" | 6 | #include "slaveiface.h" |
7 | 7 | ||
8 | /* OPIE */ | 8 | /* OPIE */ |
9 | #include <opie2/odebug.h> | 9 | #include <opie2/odebug.h> |
10 | #include <qpe/qcopenvelope_qws.h> | 10 | #include <qpe/qcopenvelope_qws.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
13 | 13 | ||
14 | /* QT */ | 14 | /* QT */ |
15 | #include <qtimer.h> | 15 | #include <qtimer.h> |
16 | 16 | ||
17 | static SlaveObjects* _slaveObj = 0; | 17 | static SlaveObjects* _slaveObj = 0; |
18 | 18 | ||
19 | QDataStream & operator << (QDataStream & str, bool b) | 19 | QDataStream & operator << (QDataStream & str, bool b) |
20 | { | 20 | { |
21 | str << Q_INT8(b); | 21 | str << Q_INT8(b); |
22 | return str; | 22 | return str; |
23 | } | 23 | } |
24 | 24 | ||
25 | QDataStream & operator >> (QDataStream & str, bool & b) | 25 | QDataStream & operator >> (QDataStream & str, bool & b) |
26 | { | 26 | { |
27 | Q_INT8 l; | 27 | Q_INT8 l; |
28 | str >> l; | 28 | str >> l; |
29 | b = bool(l); | 29 | b = bool(l); |
30 | return str; | 30 | return str; |
31 | } | 31 | } |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 35 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
36 | return s << inf.file << inf.pixmap << inf.width << inf.height; | 36 | return s << inf.file << inf.pixmap << inf.width << inf.height; |
37 | } | 37 | } |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * GUI sends no QPIxmap!!! | 40 | * GUI sends no QPIxmap!!! |
41 | */ | 41 | */ |
42 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 42 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
43 | s >> inf.file >> inf.width >> inf.height; | 43 | s >> inf.file >> inf.width >> inf.height; |
44 | owarn << "Recieved " << inf.file.latin1() << " " << inf.width << " " << inf.height << "" << oendl; | ||
45 | return s; | 44 | return s; |
46 | } | 45 | } |
47 | QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { | 46 | QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { |
48 | return s << i.kind << i.file << i.info; | 47 | return s << i.kind << i.file << i.info; |
49 | } | 48 | } |
50 | QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { | 49 | QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { |
51 | s >> i.kind >> i.file >> i.info; | 50 | s >> i.kind >> i.file >> i.info; |
52 | return s; | 51 | return s; |
53 | } | 52 | } |
54 | 53 | ||
55 | 54 | ||
56 | 55 | ||
57 | SlaveObjects* slaveObjects() { | 56 | SlaveObjects* slaveObjects() { |
58 | if ( !_slaveObj ) | 57 | if ( !_slaveObj ) |
59 | _slaveObj = new SlaveObjects; | 58 | _slaveObj = new SlaveObjects; |
60 | return _slaveObj; | 59 | return _slaveObj; |
61 | } | 60 | } |
62 | 61 | ||
63 | SlaveReciever::SlaveReciever( QObject* par) | 62 | SlaveReciever::SlaveReciever( QObject* par) |
64 | : QObject( par ), m_refs( 0 ) | 63 | : QObject( par ), m_refs( 0 ) |
65 | { | 64 | { |
66 | m_inf = new QTimer(this); | 65 | m_inf = new QTimer(this); |
67 | connect(m_inf,SIGNAL(timeout()), | 66 | connect(m_inf,SIGNAL(timeout()), |
68 | this, SLOT(slotImageInfo())); | 67 | this, SLOT(slotImageInfo())); |
69 | m_pix = new QTimer(this); | 68 | m_pix = new QTimer(this); |
70 | connect(m_pix,SIGNAL(timeout()), | 69 | connect(m_pix,SIGNAL(timeout()), |
71 | this, SLOT(slotThumbNail())); | 70 | this, SLOT(slotThumbNail())); |
72 | 71 | ||
73 | m_out = new QTimer(this); | 72 | m_out = new QTimer(this); |
74 | connect(m_out,SIGNAL(timeout()), | 73 | connect(m_out,SIGNAL(timeout()), |
75 | this, SLOT(slotSend())); | 74 | this, SLOT(slotSend())); |
76 | 75 | ||
77 | SlaveObjects *obj = slaveObjects(); // won't be changed | 76 | SlaveObjects *obj = slaveObjects(); // won't be changed |
78 | SlaveMap::Iterator it; | 77 | SlaveMap::Iterator it; |
79 | SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! | 78 | SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! |
80 | for(it = map->begin(); it != map->end(); ++it ) { | 79 | for(it = map->begin(); it != map->end(); ++it ) { |
81 | obj->insert( it.key(), (*it.data())() ); | 80 | obj->insert( it.key(), (*it.data())() ); |
82 | } | 81 | } |
83 | } | 82 | } |
84 | 83 | ||
85 | SlaveReciever::~SlaveReciever() { | 84 | SlaveReciever::~SlaveReciever() { |
86 | } | 85 | } |
87 | 86 | ||
88 | void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { | 87 | void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { |
89 | owarn << "String is " << string.data() << "" << oendl; | ||
90 | QDataStream stream(ar, IO_ReadOnly ); | 88 | QDataStream stream(ar, IO_ReadOnly ); |
91 | QStringList lst; | 89 | QStringList lst; |
92 | static ImageInfo inf; | 90 | static ImageInfo inf; |
93 | static PixmapInfo pix; | 91 | static PixmapInfo pix; |
94 | 92 | ||
95 | if ( string == "thumbInfo(QString)" ) { | 93 | if ( string == "thumbInfo(QString)" ) { |
96 | stream >> inf.file; | 94 | stream >> inf.file; |
97 | inf.kind = false; | 95 | inf.kind = false; |
98 | m_inList.append(inf); | 96 | m_inList.append(inf); |
99 | }else if ( string == "thumbInfos(QStringList)" ) { | 97 | }else if ( string == "thumbInfos(QStringList)" ) { |
100 | stream >> lst; | 98 | stream >> lst; |
101 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 99 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
102 | owarn << "Adding thumbinfo for file "+ *it << oendl; | ||
103 | inf.file = (*it); | 100 | inf.file = (*it); |
104 | inf.kind = false; | 101 | inf.kind = false; |
105 | m_inList.append(inf); | 102 | m_inList.append(inf); |
106 | } | 103 | } |
107 | }else if ( string == "fullInfo(QString)" ) { | 104 | }else if ( string == "fullInfo(QString)" ) { |
108 | inf.kind = true; | 105 | inf.kind = true; |
109 | stream >> inf.file; | 106 | stream >> inf.file; |
110 | m_inList.append(inf); | 107 | m_inList.append(inf); |
111 | }else if ( string == "fullInfos(QStringList)" ) { | 108 | }else if ( string == "fullInfos(QStringList)" ) { |
112 | stream >> lst; | 109 | stream >> lst; |
113 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 110 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
114 | owarn << "Adding fullInfo for"+ *it << oendl; | ||
115 | inf.file = (*it); | 111 | inf.file = (*it); |
116 | inf.kind = true; | 112 | inf.kind = true; |
117 | m_inList.append(inf); | 113 | m_inList.append(inf); |
118 | } | 114 | } |
119 | }else if ( string == "pixmapInfo(QString,int,int)" ) { | 115 | }else if ( string == "pixmapInfo(QString,int,int)" ) { |
120 | stream >> pix.file >> pix.width >> pix.height; | 116 | stream >> pix.file >> pix.width >> pix.height; |
121 | m_inPix.append(pix); | 117 | m_inPix.append(pix); |
122 | }else if ( string == "pixmapInfos(PixmapInfos)" ) { | 118 | }else if ( string == "pixmapInfos(PixmapInfos)" ) { |
123 | PixmapList list; | 119 | PixmapList list; |
124 | stream >> list; | 120 | stream >> list; |
125 | for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { | 121 | for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { |
126 | owarn << "Got " << (*it).width << " " << (*it).height << " " + (*it).file << oendl; | ||
127 | m_inPix.append(*it); | 122 | m_inPix.append(*it); |
128 | } | 123 | } |
129 | }else if ( string == "refUp()" ) { | 124 | }else if ( string == "refUp()" ) { |
130 | m_refs++; | 125 | m_refs++; |
131 | }else if ( string == "refDown()" ) { | 126 | }else if ( string == "refDown()" ) { |
132 | m_refs--; | 127 | m_refs--; |
133 | } | 128 | } |
134 | 129 | ||
135 | if (!m_inf->isActive() && !m_inList.isEmpty() ) | 130 | if (!m_inf->isActive() && !m_inList.isEmpty() ) |
136 | m_inf->start(5); | 131 | m_inf->start(5); |
137 | 132 | ||
138 | if (!m_pix->isActive() && !m_inPix.isEmpty() ) | 133 | if (!m_pix->isActive() && !m_inPix.isEmpty() ) |
139 | m_pix->start(5); | 134 | m_pix->start(5); |
140 | 135 | ||
141 | if ( m_refs ) | 136 | if ( m_refs ) |
142 | QPEApplication::setKeepRunning(); | 137 | QPEApplication::setKeepRunning(); |
143 | else | 138 | else |
144 | qApp->quit(); | 139 | qApp->quit(); |
145 | 140 | ||
146 | } | 141 | } |
147 | 142 | ||
148 | PixmapList SlaveReciever::outPix()const { | 143 | PixmapList SlaveReciever::outPix()const { |
149 | return m_outPix; | 144 | return m_outPix; |
150 | } | 145 | } |
151 | 146 | ||
152 | StringList SlaveReciever::outInf()const{ | 147 | StringList SlaveReciever::outInf()const{ |
153 | return m_outList; | 148 | return m_outList; |
154 | } | 149 | } |
155 | 150 | ||
156 | void SlaveReciever::slotImageInfo() { | 151 | void SlaveReciever::slotImageInfo() { |
157 | ImageInfo inf = m_inList.first(); | 152 | ImageInfo inf = m_inList.first(); |
158 | m_inList.remove( inf ); | 153 | m_inList.remove( inf ); |
159 | 154 | ||
160 | static SlaveObjects::Iterator it; | 155 | static SlaveObjects::Iterator it; |
161 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! | 156 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! |
162 | for(it = map->begin(); it != map->end(); ++it ) { | 157 | for(it = map->begin(); it != map->end(); ++it ) { |
163 | if( (*it)->supports(inf.file ) ) { | 158 | if( (*it)->supports(inf.file ) ) { |
164 | /* full image info */ | 159 | /* full image info */ |
165 | if (inf.kind ) | 160 | if (inf.kind ) |
166 | inf.info = (*it)->fullImageInfo( inf.file ); | 161 | inf.info = (*it)->fullImageInfo( inf.file ); |
167 | else | 162 | else |
168 | inf.info = (*it)->iconViewName( inf.file ); | 163 | inf.info = (*it)->iconViewName( inf.file ); |
169 | m_outList.append( inf ); | 164 | m_outList.append( inf ); |
170 | break; | 165 | break; |
171 | } | 166 | } |
172 | } | 167 | } |
173 | 168 | ||
174 | if (m_inList.isEmpty() ) | 169 | if (m_inList.isEmpty() ) |
175 | m_inf->stop(); | 170 | m_inf->stop(); |
176 | if (!m_out->isActive() && !m_outList.isEmpty() ) | 171 | if (!m_out->isActive() && !m_outList.isEmpty() ) |
177 | m_out->start( 100 ); | 172 | m_out->start( 100 ); |
178 | } | 173 | } |
179 | 174 | ||
180 | void SlaveReciever::slotThumbNail() { | 175 | void SlaveReciever::slotThumbNail() { |
181 | PixmapInfo inf = m_inPix.first(); | 176 | PixmapInfo inf = m_inPix.first(); |
182 | m_inPix.remove( inf ); | 177 | m_inPix.remove( inf ); |
183 | 178 | ||
184 | static SlaveObjects::Iterator it; | 179 | static SlaveObjects::Iterator it; |
185 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! | 180 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! |
186 | for(it = map->begin(); it != map->end(); ++it ) { | 181 | for(it = map->begin(); it != map->end(); ++it ) { |
187 | SlaveInterface* iface = it.data(); | 182 | SlaveInterface* iface = it.data(); |
188 | if( iface->supports(inf.file ) ) { | 183 | if( iface->supports(inf.file ) ) { |
189 | /* pixmap */ | 184 | /* pixmap */ |
190 | owarn << "Asking for thumbNail in size " << inf.width << " " << inf.height << " for "+inf.file << oendl; | ||
191 | if (inf.width>256||inf.height>256) { | 185 | if (inf.width>256||inf.height>256) { |
192 | owarn << "Scaling thumbnail to 64x64 'cause " << inf.width<<"x"<<inf.height<< | 186 | owarn << "Scaling thumbnail to 64x64 'cause " << inf.width<<"x"<<inf.height<< |
193 | " may be nonsense"; | 187 | " may be nonsense"; |
194 | inf.pixmap = iface->pixmap(inf.file, 64, 64); | 188 | inf.pixmap = iface->pixmap(inf.file, 64, 64); |
195 | }else { | 189 | }else { |
196 | inf.pixmap = iface->pixmap(inf.file, inf.width, inf.height); | 190 | inf.pixmap = iface->pixmap(inf.file, inf.width, inf.height); |
197 | } | 191 | } |
198 | m_outPix.append( inf ); | 192 | m_outPix.append( inf ); |
199 | break; | 193 | break; |
200 | } | 194 | } |
201 | } | 195 | } |
202 | 196 | ||
203 | 197 | ||
204 | 198 | ||
205 | if(m_inPix.isEmpty() ) | 199 | if(m_inPix.isEmpty() ) |
206 | m_pix->stop(); | 200 | m_pix->stop(); |
207 | if(!m_out->isActive() && !m_outPix.isEmpty() ) | 201 | if(!m_out->isActive() && !m_outPix.isEmpty() ) |
208 | m_out->start(100); | 202 | m_out->start(100); |
209 | } | 203 | } |
210 | 204 | ||
211 | void SlaveReciever::slotSend() { | 205 | void SlaveReciever::slotSend() { |
212 | 206 | ||
213 | m_out->stop(); | 207 | m_out->stop(); |
214 | 208 | ||
215 | owarn << "Sending " << outPix().count() << " " << outInf().count() << "" << oendl; | ||
216 | /* queue it and send */ | 209 | /* queue it and send */ |
217 | /* if this ever gets a service introduce request queues | 210 | /* if this ever gets a service introduce request queues |
218 | * so we can differinatate between different clients | 211 | * so we can differinatate between different clients |
219 | */ | 212 | */ |
220 | if (! m_outPix.isEmpty() ) { | 213 | if (! m_outPix.isEmpty() ) { |
221 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" ); | 214 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" ); |
222 | answer << outPix(); | 215 | answer << outPix(); |
216 | #if 0 | ||
223 | for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) { | 217 | for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) { |
224 | owarn << "Sending out " << (*it).file.latin1() << " " << (*it).width << " " << (*it).height << "" << oendl; | 218 | owarn << "Sending out " << (*it).file.latin1() << " " << (*it).width << " " << (*it).height << "" << oendl; |
225 | } | 219 | } |
220 | #endif | ||
226 | } | 221 | } |
227 | if ( !m_outList.isEmpty() ) { | 222 | if ( !m_outList.isEmpty() ) { |
228 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" ); | 223 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" ); |
229 | answer << outInf(); | 224 | answer << outInf(); |
225 | #if 0 | ||
230 | for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) { | 226 | for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) { |
231 | owarn << "Sending out2 " + (*it).file << oendl; | 227 | owarn << "Sending out2 " + (*it).file << oendl; |
232 | } | 228 | } |
229 | #endif | ||
233 | } | 230 | } |
234 | 231 | ||
235 | m_outList.clear(); | 232 | m_outList.clear(); |
236 | m_outPix.clear(); | 233 | m_outPix.clear(); |
237 | } | 234 | } |
238 | 235 | ||
diff --git a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp index d2e169c..62bb1e6 100644 --- a/noncore/graphics/opie-eye/slave/thumbnailtool.cpp +++ b/noncore/graphics/opie-eye/slave/thumbnailtool.cpp | |||
@@ -1,66 +1,63 @@ | |||
1 | #include "thumbnailtool.h" | 1 | #include "thumbnailtool.h" |
2 | 2 | ||
3 | /* OPIE */ | 3 | /* OPIE */ |
4 | #include <opie2/odebug.h> | 4 | #include <opie2/odebug.h> |
5 | using namespace Opie::Core; | 5 | using namespace Opie::Core; |
6 | 6 | ||
7 | /* QT */ | 7 | /* QT */ |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qimage.h> | 10 | #include <qimage.h> |
11 | #include <qpixmap.h> | 11 | #include <qpixmap.h> |
12 | #include <qstring.h> | 12 | #include <qstring.h> |
13 | 13 | ||
14 | static bool makeThumbDir( const QFileInfo& inf, bool make = false) { | 14 | static bool makeThumbDir( const QFileInfo& inf, bool make = false) { |
15 | QDir dir( inf.dirPath()+ "/.opie-eye" ); | 15 | QDir dir( inf.dirPath()+ "/.opie-eye" ); |
16 | if ( !dir.exists() ) | 16 | if ( !dir.exists() ) |
17 | if ( make ) | 17 | if ( make ) |
18 | return dir.mkdir(QString::null); | 18 | return dir.mkdir(QString::null); |
19 | else | 19 | else |
20 | return false; | 20 | return false; |
21 | return true; | 21 | return true; |
22 | } | 22 | } |
23 | 23 | ||
24 | 24 | ||
25 | /* | 25 | /* |
26 | * check if the Opie opie-eye dir exists | 26 | * check if the Opie opie-eye dir exists |
27 | * check if a thumbnail exists | 27 | * check if a thumbnail exists |
28 | * load the thumbnail | 28 | * load the thumbnail |
29 | * /foo/bar/imagefoo.gif | 29 | * /foo/bar/imagefoo.gif |
30 | * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif | 30 | * check for a png in /foo/bar/.opie-eye/%dx%d-imagefoo.gif |
31 | */ | 31 | */ |
32 | QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) { | 32 | QPixmap ThumbNailTool::getThumb( const QString& path, int width, int height ) { |
33 | QFileInfo inf( path ); | 33 | QFileInfo inf( path ); |
34 | owarn << "Get Thumb" << oendl; | ||
35 | if ( !makeThumbDir( inf ) ) { | 34 | if ( !makeThumbDir( inf ) ) { |
36 | QPixmap pix; | 35 | QPixmap pix; |
37 | return pix; | 36 | return pix; |
38 | } | 37 | } |
39 | QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); | 38 | QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); |
40 | owarn << inf.dirPath()+str << oendl; | ||
41 | return QPixmap( inf.dirPath()+str,"PNG" ); | 39 | return QPixmap( inf.dirPath()+str,"PNG" ); |
42 | 40 | ||
43 | } | 41 | } |
44 | 42 | ||
45 | void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) { | 43 | void ThumbNailTool::putThumb( const QString& path, const QPixmap& pix, int width, int height ) { |
46 | QFileInfo inf( path ); | 44 | QFileInfo inf( path ); |
47 | makeThumbDir( inf, true ); | 45 | makeThumbDir( inf, true ); |
48 | QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); | 46 | QString str = QString( "/.opie-eye/%1x%2-%3" ).arg( width ).arg( height ).arg( inf.fileName() ); |
49 | owarn << inf.dirPath()+str << oendl; | ||
50 | pix.save( inf.dirPath()+str, "PNG" ); | 47 | pix.save( inf.dirPath()+str, "PNG" ); |
51 | } | 48 | } |
52 | 49 | ||
53 | 50 | ||
54 | QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) { | 51 | QPixmap ThumbNailTool::scaleImage( QImage& img, int w, int h ) { |
55 | double hs = (double)h / (double)img.height() ; | 52 | double hs = (double)h / (double)img.height() ; |
56 | double ws = (double)w / (double)img.width() ; | 53 | double ws = (double)w / (double)img.width() ; |
57 | double scaleFactor = (hs > ws) ? ws : hs; | 54 | double scaleFactor = (hs > ws) ? ws : hs; |
58 | int smoothW = (int)(scaleFactor * img.width()); | 55 | int smoothW = (int)(scaleFactor * img.width()); |
59 | int smoothH = (int)(scaleFactor * img.height()); | 56 | int smoothH = (int)(scaleFactor * img.height()); |
60 | QPixmap pixmap; | 57 | QPixmap pixmap; |
61 | if ( img.width() <= w && img.height() <= h ) | 58 | if ( img.width() <= w && img.height() <= h ) |
62 | pixmap.convertFromImage( img ); | 59 | pixmap.convertFromImage( img ); |
63 | else | 60 | else |
64 | pixmap.convertFromImage( img.smoothScale( smoothW, smoothH) ); | 61 | pixmap.convertFromImage( img.smoothScale( smoothW, smoothH) ); |
65 | return pixmap; | 62 | return pixmap; |
66 | } | 63 | } |