author | mickeyl <mickeyl> | 2003-10-27 20:26:56 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-27 20:26:56 (UTC) |
commit | 1fed961e25a6afd4070d8873b431aba8342406c3 (patch) (unidiff) | |
tree | 8ef9a1b3ad5cf50406ac500ccfb77cff60b77796 | |
parent | 651d29249946e7221fc85580453750d9e4be4fb0 (diff) | |
download | opie-1fed961e25a6afd4070d8873b431aba8342406c3.zip opie-1fed961e25a6afd4070d8873b431aba8342406c3.tar.gz opie-1fed961e25a6afd4070d8873b431aba8342406c3.tar.bz2 |
merge noncore/multimedia/showimg
- opieplayer2 and opierec generate lots of conflicts in merge
I'll gladly leave that to the experts ljp and Harlekin ;)
-rw-r--r-- | noncore/multimedia/showimg/main.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 90 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.pro | 4 |
4 files changed, 50 insertions, 55 deletions
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp index c28cc85..efb1c68 100644 --- a/noncore/multimedia/showimg/main.cpp +++ b/noncore/multimedia/showimg/main.cpp | |||
@@ -1,33 +1,27 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "showimg.h" | 21 | #include "showimg.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | int main( int argc, char **argv ) | 25 | #include <opie/oapplicationfactory.h> |
26 | { | ||
27 | QPEApplication a( argc, argv ); | ||
28 | |||
29 | ImageViewer w(0, "new window", Qt::WResizeNoErase ); | ||
30 | a.showMainDocumentWidget(&w); | ||
31 | 26 | ||
32 | return a.exec(); | 27 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) \ No newline at end of file |
33 | } | ||
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index d6f0733..56bdecf 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -1,679 +1,681 @@ | |||
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 <qpe/qpemenubar.h> | 39 | #include <qpe/qpemenubar.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 | const char *labels[]={"File Name","Format","File Size","Size","Colors","Alpha"}; | 121 | |
122 | |||
123 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; | ||
122 | 124 | ||
123 | setMinimumSize(180,80); | 125 | setMinimumSize(180,80); |
124 | int num=ImageViewer::LAST+1; | 126 | int num=ImageViewer::LAST+1; |
125 | if ( text[ImageViewer::ALPHA].isEmpty() ) | 127 | if ( text[ImageViewer::ALPHA].isEmpty() ) |
126 | num--; | 128 | num--; |
127 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); | 129 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); |
128 | QLabel *l; | 130 | QLabel *l; |
129 | int count=0; | 131 | int count=0; |
130 | for ( int i=0;i<num;i++ ) | 132 | for ( int i=0;i<num;i++ ) |
131 | { | 133 | { |
132 | if ( i==1 ) | 134 | if ( i==1 ) |
133 | { | 135 | { |
134 | QFrame *frm=new QFrame(this); | 136 | QFrame *frm=new QFrame(this); |
135 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); | 137 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); |
136 | gl->addMultiCellWidget(frm,i,i,0,1); | 138 | gl->addMultiCellWidget(frm,i,i,0,1); |
137 | } | 139 | } |
138 | else | 140 | else |
139 | { | 141 | { |
140 | l=new QLabel(tr(labels[count])+":",this); | 142 | l=new QLabel( tr( labels[count] )+":",this); |
141 | gl->addWidget(l,i,0,AlignLeft); | 143 | gl->addWidget(l,i,0,AlignLeft); |
142 | l=new QLabel(text[count],this); | 144 | l=new QLabel(text[count],this); |
143 | gl->addWidget(l,i,1,AlignRight); | 145 | gl->addWidget(l,i,1,AlignRight); |
144 | count++; | 146 | count++; |
145 | } | 147 | } |
146 | 148 | ||
147 | } | 149 | } |
148 | 150 | ||
149 | } | 151 | } |
150 | 152 | ||
151 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) | 153 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) |
152 | { | 154 | { |
153 | InfoDialog *dlg=new InfoDialog(caption,text,parent); | 155 | InfoDialog *dlg=new InfoDialog(caption,text,parent); |
154 | dlg->exec(); | 156 | dlg->exec(); |
155 | delete dlg; | 157 | delete dlg; |
156 | } | 158 | } |
157 | 159 | ||
158 | //=========================================================================== | 160 | //=========================================================================== |
159 | 161 | ||
160 | 162 | ||
161 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 163 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
162 | { | 164 | { |
163 | vb = new QVBoxLayout( this ); | 165 | vb = new QVBoxLayout( this ); |
164 | 166 | ||
165 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); | 167 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); |
166 | pic=new ImageWidget(image); | 168 | pic=new ImageWidget(image); |
167 | image->addChild(pic); | 169 | image->addChild(pic); |
168 | 170 | ||
169 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 171 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
170 | 172 | ||
171 | vb->addWidget( image ); | 173 | vb->addWidget( image ); |
172 | 174 | ||
173 | } | 175 | } |
174 | 176 | ||
175 | void ImagePane::setPixmap( const QPixmap &pm ) | 177 | void ImagePane::setPixmap( const QPixmap &pm ) |
176 | { | 178 | { |
177 | pic->setPixmap( pm ); | 179 | pic->setPixmap( pm ); |
178 | pic->resize(pm.width(),pm.height()); | 180 | pic->resize(pm.width(),pm.height()); |
179 | image->updateScrollBars (); | 181 | image->updateScrollBars (); |
180 | pic->repaint(false); | 182 | pic->repaint(false); |
181 | } | 183 | } |
182 | 184 | ||
183 | void ImagePane::imageClicked() | 185 | void ImagePane::imageClicked() |
184 | { | 186 | { |
185 | emit clicked(); | 187 | emit clicked(); |
186 | } | 188 | } |
187 | //=========================================================================== | 189 | //=========================================================================== |
188 | /* | 190 | /* |
189 | 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 |
190 | */ | 192 | */ |
191 | 193 | ||
192 | void ImageWidget::paintEvent( QPaintEvent *e ) | 194 | void ImageWidget::paintEvent( QPaintEvent *e ) |
193 | { | 195 | { |
194 | QPainter painter(this); | 196 | QPainter painter(this); |
195 | 197 | ||
196 | painter.setClipRect(e->rect()); | 198 | painter.setClipRect(e->rect()); |
197 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); | 199 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); |
198 | 200 | ||
199 | if ( pixmap.size() != QSize( 0, 0 ) ) | 201 | if ( pixmap.size() != QSize( 0, 0 ) ) |
200 | { // is an image loaded? | 202 | { // is an image loaded? |
201 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 203 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
202 | } | 204 | } |
203 | } | 205 | } |
204 | 206 | ||
205 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 207 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
206 | { | 208 | { |
207 | emit clicked(); | 209 | emit clicked(); |
208 | } | 210 | } |
209 | 211 | ||
210 | //=========================================================================== | 212 | //=========================================================================== |
211 | 213 | ||
212 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | 214 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) |
213 | : QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE ) | 215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
214 | { | 216 | { |
215 | setCaption( tr("Image Viewer") ); | 217 | setCaption( tr("Image Viewer") ); |
216 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
217 | 219 | ||
218 | 220 | ||
219 | Config cfg("Image Viewer"); | 221 | Config cfg("Image Viewer"); |
220 | cfg.setGroup("Image Viewer"); | 222 | cfg.setGroup("Image Viewer"); |
221 | 223 | ||
222 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
223 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 225 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
224 | 226 | ||
225 | isFullScreen = FALSE; | 227 | isFullScreen = FALSE; |
226 | 228 | ||
227 | setToolBarsMovable( FALSE ); | 229 | setToolBarsMovable( FALSE ); |
228 | 230 | ||
229 | toolBar = new QPEToolBar( this ); | 231 | toolBar = new QPEToolBar( this ); |
230 | toolBar->setHorizontalStretchable( TRUE ); | 232 | toolBar->setHorizontalStretchable( TRUE ); |
231 | 233 | ||
232 | menuBar = new QPEMenuBar( toolBar ); | 234 | menuBar = new QPEMenuBar( toolBar ); |
233 | 235 | ||
234 | current=menuBar; | 236 | current=menuBar; |
235 | 237 | ||
236 | 238 | ||
237 | 239 | ||
238 | fileMenuFile = new QPopupMenu(this); | 240 | fileMenuFile = new QPopupMenu(this); |
239 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
240 | fileMenuFile->insertItem(tr("Open"), | 242 | fileMenuFile->insertItem(tr("Open"), |
241 | this, SLOT(openFile()), 0); | 243 | this, SLOT(openFile()), 0); |
242 | 244 | ||
243 | viewMenuFile = new QPopupMenu( this ); | 245 | viewMenuFile = new QPopupMenu( this ); |
244 | //menubarFile->insertItem( tr("View"), viewMenu ); | 246 | //menubarFile->insertItem( tr("View"), viewMenu ); |
245 | viewMenuFile->insertItem( tr("Thumbnail View"), | 247 | viewMenuFile->insertItem( tr("Thumbnail View"), |
246 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
247 | 249 | ||
248 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
249 | 251 | ||
250 | 252 | ||
251 | 253 | ||
252 | 254 | ||
253 | optionsMenuFile = new QPopupMenu( this); | 255 | optionsMenuFile = new QPopupMenu( this); |
254 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
255 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
256 | QString::null, 0, this, 0 ); | 258 | QString::null, 0, this, 0 ); |
257 | slideAction->setToggleAction( TRUE ); | 259 | slideAction->setToggleAction( TRUE ); |
258 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
259 | slideAction->addTo( optionsMenuFile); | 261 | slideAction->addTo( optionsMenuFile); |
260 | // slideAction->addTo( toolBar ); | 262 | // slideAction->addTo( toolBar ); |
261 | 263 | ||
262 | 264 | ||
263 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 265 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
264 | optionsMenuFile->insertSeparator(); | 266 | optionsMenuFile->insertSeparator(); |
265 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
266 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
267 | 269 | ||
268 | QStrList fmt = QImage::outputFormats(); | 270 | QStrList fmt = QImage::outputFormats(); |
269 | 271 | ||
270 | 272 | ||
271 | fileMenuView = new QPopupMenu( this ); | 273 | fileMenuView = new QPopupMenu( this ); |
272 | //menubarView->insertItem( tr("File"),fileMenu ); | 274 | //menubarView->insertItem( tr("File"),fileMenu ); |
273 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
274 | fileMenuView->insertSeparator(); | 276 | fileMenuView->insertSeparator(); |
275 | 277 | ||
276 | viewMenuView = new QPopupMenu(this ); | 278 | viewMenuView = new QPopupMenu(this ); |
277 | viewMenuView->setCheckable ( true ); | 279 | viewMenuView->setCheckable ( true ); |
278 | 280 | ||
279 | //menubarView->insertItem( tr("View"),viewMenu ); | 281 | //menubarView->insertItem( tr("View"),viewMenu ); |
280 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
281 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
282 | 284 | ||
283 | stack = new QWidgetStack( this ); | 285 | stack = new QWidgetStack( this ); |
284 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
285 | setCentralWidget( stack ); | 287 | setCentralWidget( stack ); |
286 | 288 | ||
287 | 289 | ||
288 | imagePanel = new ImagePane( stack ); | 290 | imagePanel = new ImagePane( stack ); |
289 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
290 | 292 | ||
291 | 293 | ||
292 | ImageFileSelector::CURRENT_VIEW cv; | 294 | ImageFileSelector::CURRENT_VIEW cv; |
293 | if(showThumbView) | 295 | if(showThumbView) |
294 | cv=ImageFileSelector::THUMBNAIL; | 296 | cv=ImageFileSelector::THUMBNAIL; |
295 | else | 297 | else |
296 | cv=ImageFileSelector::DETAILED; | 298 | cv=ImageFileSelector::DETAILED; |
297 | 299 | ||
298 | qDebug("cv = %d",cv); | 300 | qDebug("cv = %d",cv); |
299 | 301 | ||
300 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
301 | 303 | ||
302 | //switchThumbView(); | 304 | //switchThumbView(); |
303 | 305 | ||
304 | 306 | ||
305 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
306 | //fileSelector->setNewVisible(FALSE); | 308 | //fileSelector->setNewVisible(FALSE); |
307 | //fileSelector->setCloseVisible(FALSE); | 309 | //fileSelector->setCloseVisible(FALSE); |
308 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
309 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 311 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), |
310 | this, SLOT( openFile( const DocLnk & ) ) ); | 312 | this, SLOT( openFile( const DocLnk & ) ) ); |
311 | 313 | ||
312 | imageList = fileSelector->fileList(); | 314 | imageList = fileSelector->fileList(); |
313 | slideAction->setEnabled( imageList.count() != 0); | 315 | slideAction->setEnabled( imageList.count() != 0); |
314 | 316 | ||
315 | iconToolBar = new QPEToolBar(this); | 317 | iconToolBar = new QPEToolBar(this); |
316 | 318 | ||
317 | QAction *a; | 319 | QAction *a; |
318 | 320 | ||
319 | 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 ); |
320 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
321 | a->addTo( fileMenuView); | 323 | a->addTo( fileMenuView); |
322 | a->addTo( iconToolBar ); | 324 | a->addTo( iconToolBar ); |
323 | 325 | ||
324 | 326 | ||
325 | 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); |
326 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
327 | a->addTo( iconToolBar ); | 329 | a->addTo( iconToolBar ); |
328 | a->addTo( viewMenuView ); | 330 | a->addTo( viewMenuView ); |
329 | 331 | ||
330 | 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 ); |
331 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
332 | a->addTo( iconToolBar ); | 334 | a->addTo( iconToolBar ); |
333 | a->addTo( viewMenuView ); | 335 | a->addTo( viewMenuView ); |
334 | 336 | ||
335 | 337 | ||
336 | 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); |
337 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
338 | //a->addTo( iconToolBar ); | 340 | //a->addTo( iconToolBar ); |
339 | a->addTo( viewMenuView ); | 341 | a->addTo( viewMenuView ); |
340 | 342 | ||
341 | 343 | ||
342 | 344 | ||
343 | viewMenuView->insertSeparator(); | 345 | viewMenuView->insertSeparator(); |
344 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
345 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
346 | viewMenuView->insertSeparator(); | 348 | viewMenuView->insertSeparator(); |
347 | 349 | ||
348 | 350 | ||
349 | 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); |
350 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
351 | sss->addTo( iconToolBar ); | 353 | sss->addTo( iconToolBar ); |
352 | sss->addTo( viewMenuView ); | 354 | sss->addTo( viewMenuView ); |
353 | 355 | ||
354 | sss->setOn(isSized); | 356 | sss->setOn(isSized); |
355 | viewMenuView->insertSeparator(); | 357 | viewMenuView->insertSeparator(); |
356 | 358 | ||
357 | 359 | ||
358 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
359 | QString::null, 0, this, 0 ); | 361 | QString::null, 0, this, 0 ); |
360 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
361 | a->addTo( iconToolBar ); | 363 | a->addTo( iconToolBar ); |
362 | a->addTo( viewMenuView); | 364 | a->addTo( viewMenuView); |
363 | 365 | ||
364 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
365 | QString::null, 0, this, 0 ); | 367 | QString::null, 0, this, 0 ); |
366 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
367 | a->addTo( iconToolBar ); | 369 | a->addTo( iconToolBar ); |
368 | a->addTo( viewMenuView); | 370 | a->addTo( viewMenuView); |
369 | 371 | ||
370 | 372 | ||
371 | Config config( "ImageViewer" ); | 373 | Config config( "ImageViewer" ); |
372 | config.setGroup( "SlideShow" ); | 374 | config.setGroup( "SlideShow" ); |
373 | slideDelay = config.readNumEntry( "Delay", 2); | 375 | slideDelay = config.readNumEntry( "Delay", 2); |
374 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
375 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 377 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
376 | 378 | ||
377 | config.setGroup("Default"); | 379 | config.setGroup("Default"); |
378 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
379 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
380 | slideTimer = new QTimer( this ); | 382 | slideTimer = new QTimer( this ); |
381 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
382 | 384 | ||
383 | switchToFileSelector(); | 385 | switchToFileSelector(); |
384 | 386 | ||
385 | setMouseTracking( TRUE ); | 387 | setMouseTracking( TRUE ); |
388 | |||
386 | 389 | ||
387 | |||
388 | } | 390 | } |
389 | 391 | ||
390 | ImageViewer::~ImageViewer() | 392 | ImageViewer::~ImageViewer() |
391 | { | 393 | { |
392 | Config cfg("Image Viewer"); | 394 | Config cfg("Image Viewer"); |
393 | cfg.setGroup("Image Viewer"); | 395 | cfg.setGroup("Image Viewer"); |
394 | 396 | ||
395 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
396 | cfg.writeEntry("SizeToScreen",(int)isSized); | 398 | cfg.writeEntry("SizeToScreen",(int)isSized); |
397 | 399 | ||
398 | cfg.setGroup( "SlideShow" ); | 400 | cfg.setGroup( "SlideShow" ); |
399 | cfg.writeEntry( "Delay", slideDelay); | 401 | cfg.writeEntry( "Delay", slideDelay); |
400 | cfg.writeEntry( "Repeat", slideRepeat ); | 402 | cfg.writeEntry( "Repeat", slideRepeat ); |
401 | cfg.writeEntry("Reverse", slideReverse); | 403 | cfg.writeEntry("Reverse", slideReverse); |
402 | 404 | ||
403 | cfg.setGroup("Default"); | 405 | cfg.setGroup("Default"); |
404 | cfg.writeEntry("Rotate", rotateOnLoad); | 406 | cfg.writeEntry("Rotate", rotateOnLoad); |
405 | cfg.writeEntry("FastLoad", fastLoad); | 407 | cfg.writeEntry("FastLoad", fastLoad); |
406 | 408 | ||
407 | delete imagePanel; // in case it is fullscreen | 409 | delete imagePanel; // in case it is fullscreen |
408 | } | 410 | } |
409 | 411 | ||
410 | void ImageViewer::help() { | 412 | void ImageViewer::help() { |
411 | 413 | ||
412 | } | 414 | } |
413 | 415 | ||
414 | 416 | ||
415 | void ImageViewer::settings() | 417 | void ImageViewer::settings() |
416 | { | 418 | { |
417 | SettingsDialog dlg( this, 0, TRUE ); | 419 | SettingsDialog dlg( this, 0, TRUE ); |
418 | dlg.setDelay( slideDelay ); | 420 | dlg.setDelay( slideDelay ); |
419 | dlg.setRepeat( slideRepeat ); | 421 | dlg.setRepeat( slideRepeat ); |
420 | dlg.setReverse( slideReverse ); | 422 | dlg.setReverse( slideReverse ); |
421 | dlg.setRotate(rotateOnLoad); | 423 | dlg.setRotate(rotateOnLoad); |
422 | dlg.setFastLoad(fastLoad); | 424 | dlg.setFastLoad(fastLoad); |
423 | 425 | ||
424 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 426 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
425 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 427 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
426 | slideDelay = dlg.delay(); | 428 | slideDelay = dlg.delay(); |
427 | slideRepeat = dlg.repeat(); | 429 | slideRepeat = dlg.repeat(); |
428 | slideReverse = dlg.reverse(); | 430 | slideReverse = dlg.reverse(); |
429 | rotateOnLoad = dlg.rotate(); | 431 | rotateOnLoad = dlg.rotate(); |
430 | fastLoad = dlg.fastLoad(); | 432 | fastLoad = dlg.fastLoad(); |
431 | 433 | ||
432 | Config config( "ImageViewer" ); | 434 | Config config( "ImageViewer" ); |
433 | config.setGroup( "SlideShow" ); | 435 | config.setGroup( "SlideShow" ); |
434 | config.writeEntry( "Delay", slideDelay ); | 436 | config.writeEntry( "Delay", slideDelay ); |
435 | config.writeEntry( "Repeat", slideRepeat ); | 437 | config.writeEntry( "Repeat", slideRepeat ); |
436 | config.writeEntry("Reverse", slideReverse); | 438 | config.writeEntry("Reverse", slideReverse); |
437 | 439 | ||
438 | config.setGroup("Default"); | 440 | config.setGroup("Default"); |
439 | config.writeEntry("Rotate", rotateOnLoad); | 441 | config.writeEntry("Rotate", rotateOnLoad); |
440 | config.writeEntry("FastLoad", fastLoad); | 442 | config.writeEntry("FastLoad", fastLoad); |
441 | } | 443 | } |
442 | } | 444 | } |
443 | 445 | ||
444 | void ImageViewer::switchSizeToScreen() | 446 | void ImageViewer::switchSizeToScreen() |
445 | { | 447 | { |
446 | isSized=!isSized; | 448 | isSized=!isSized; |
447 | sss->setOn(isSized); | 449 | sss->setOn(isSized); |
448 | updateImage(); | 450 | updateImage(); |
449 | } | 451 | } |
450 | 452 | ||
451 | void ImageViewer::updateImage() | 453 | void ImageViewer::updateImage() |
452 | { | 454 | { |
453 | if ( isSized ) { | 455 | if ( isSized ) { |
454 | imagePanel->setPixmap(pmScaled); | 456 | imagePanel->setPixmap(pmScaled); |
455 | } else { | 457 | } else { |
456 | imagePanel->setPixmap(pm); | 458 | imagePanel->setPixmap(pm); |
457 | } | 459 | } |
458 | } | 460 | } |
459 | 461 | ||
460 | void ImageViewer::switchThumbView() | 462 | void ImageViewer::switchThumbView() |
461 | { | 463 | { |
462 | 464 | ||
463 | showThumbView=!showThumbView; | 465 | showThumbView=!showThumbView; |
464 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 466 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
465 | fileSelector->switchView(); | 467 | fileSelector->switchView(); |
466 | 468 | ||
467 | } | 469 | } |
468 | 470 | ||
469 | void ImageViewer::switchToFileSelector() | 471 | void ImageViewer::switchToFileSelector() |
470 | { | 472 | { |
471 | stack->raiseWidget(fileSelector); | 473 | stack->raiseWidget(fileSelector); |
472 | menuBar->clear(); | 474 | menuBar->clear(); |
473 | menuBar->insertItem( tr("File"), fileMenuFile ); | 475 | menuBar->insertItem( tr("File"), fileMenuFile ); |
474 | menuBar->insertItem( tr("View"), viewMenuFile ); | 476 | menuBar->insertItem( tr("View"), viewMenuFile ); |
475 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 477 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
476 | iconToolBar->hide(); | 478 | iconToolBar->hide(); |
477 | imagePanel->disable(); | 479 | imagePanel->disable(); |
478 | slideShow(false); | 480 | slideShow(false); |
479 | 481 | ||
480 | } | 482 | } |
481 | 483 | ||
482 | void ImageViewer::switchToImageView() | 484 | void ImageViewer::switchToImageView() |
483 | { | 485 | { |
484 | stack->raiseWidget(imagePanel); | 486 | stack->raiseWidget(imagePanel); |
485 | 487 | ||
486 | menuBar->clear(); | 488 | menuBar->clear(); |
487 | menuBar->insertItem( tr("File"), fileMenuView ); | 489 | menuBar->insertItem( tr("File"), fileMenuView ); |
488 | menuBar->insertItem( tr("View"), viewMenuView ); | 490 | menuBar->insertItem( tr("View"), viewMenuView ); |
489 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); | 491 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); |
490 | iconToolBar->show(); | 492 | iconToolBar->show(); |
491 | 493 | ||
492 | imagePanel->setPosition(0,0); | 494 | imagePanel->setPosition(0,0); |
493 | 495 | ||
494 | } | 496 | } |
495 | 497 | ||
496 | 498 | ||
497 | void ImageViewer::setDocument(const QString& fileref) | 499 | void ImageViewer::setDocument(const QString& fileref) |
498 | { | 500 | { |
499 | delayLoad = fileref; | 501 | delayLoad = fileref; |
500 | switchToImageView(); | 502 | switchToImageView(); |
501 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 503 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
502 | } | 504 | } |
503 | 505 | ||
504 | void ImageViewer::doDelayedLoad() | 506 | void ImageViewer::doDelayedLoad() |
505 | { | 507 | { |
506 | show(delayLoad); | 508 | show(delayLoad); |
507 | } | 509 | } |
508 | 510 | ||
509 | void ImageViewer::show() | 511 | void ImageViewer::show() |
510 | { | 512 | { |
511 | normalView(); | 513 | normalView(); |
512 | QMainWindow::show(); | 514 | QMainWindow::show(); |
513 | } | 515 | } |
514 | 516 | ||
515 | void ImageViewer::show(const QString& fileref) | 517 | void ImageViewer::show(const QString& fileref) |
516 | { | 518 | { |
517 | // qDebug("Show "+fileref); | 519 | // qDebug("Show "+fileref); |
518 | bFromDocView = TRUE; | 520 | bFromDocView = TRUE; |
519 | closeFileSelector(); | 521 | closeFileSelector(); |
520 | DocLnk link(fileref); | 522 | DocLnk link(fileref); |
521 | if ( link.isValid() ) { | 523 | if ( link.isValid() ) { |
522 | openFile(link); | 524 | openFile(link); |
523 | } else { | 525 | } else { |
524 | filename = fileref; | 526 | filename = fileref; |
525 | updateCaption( fileref ); | 527 | updateCaption( fileref ); |
526 | loadImage( fileref ); | 528 | loadImage( fileref ); |
527 | } | 529 | } |
528 | } | 530 | } |
529 | 531 | ||
530 | void ImageViewer::openFile() { | 532 | void ImageViewer::openFile() { |
531 | MimeTypes types; | 533 | MimeTypes types; |
532 | QStringList image; | 534 | QStringList image; |
533 | image << "image/*"; | 535 | image << "image/*"; |
534 | types.insert("Images", image); | 536 | types.insert("Images", image); |
535 | 537 | ||
536 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 538 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
537 | DocLnk link(str); | 539 | DocLnk link(str); |
538 | // if ( link.isValid() ) | 540 | // if ( link.isValid() ) |
539 | openFile(link); | 541 | openFile(link); |
540 | 542 | ||
541 | } | 543 | } |
542 | 544 | ||
543 | void ImageViewer::openFile( const DocLnk &link ) | 545 | void ImageViewer::openFile( const DocLnk &link ) |
544 | { | 546 | { |
545 | closeFileSelector(); | 547 | closeFileSelector(); |
546 | // DocLnk link(file); | 548 | // DocLnk link(file); |
547 | qDebug("open "+link.name()); | 549 | qDebug("open "+link.name()); |
548 | updateCaption( link.name() ); | 550 | updateCaption( link.name() ); |
549 | loadImage( link.file() ); | 551 | loadImage( link.file() ); |
550 | if (slideTimer->isActive()) { | 552 | if (slideTimer->isActive()) { |
551 | slideTimer->start(slideDelay * 1000, FALSE); | 553 | slideTimer->start(slideDelay * 1000, FALSE); |
552 | } | 554 | } |
553 | 555 | ||
554 | } | 556 | } |
555 | 557 | ||
556 | void ImageViewer::open() | 558 | void ImageViewer::open() |
557 | { | 559 | { |
558 | switchToFileSelector(); | 560 | switchToFileSelector(); |
559 | } | 561 | } |
560 | 562 | ||
561 | void ImageViewer::closeFileSelector() | 563 | void ImageViewer::closeFileSelector() |
562 | { | 564 | { |
563 | switchToImageView(); | 565 | switchToImageView(); |
564 | } | 566 | } |
565 | 567 | ||
566 | void ImageViewer::updateCaption( QString name ) | 568 | void ImageViewer::updateCaption( QString name ) |
567 | { | 569 | { |
568 | int sep = name.findRev( '/' ); | 570 | int sep = name.findRev( '/' ); |
569 | if ( sep >= 0 ) | 571 | if ( sep >= 0 ) |
570 | name = name.mid( sep+1 ); | 572 | name = name.mid( sep+1 ); |
571 | setCaption( name + tr(" - Image Viewer") ); | 573 | setCaption( name + tr(" - Image Viewer") ); |
572 | } | 574 | } |
573 | 575 | ||
574 | /* | 576 | /* |
575 | This function loads an image from a file. | 577 | This function loads an image from a file. |
576 | */ | 578 | */ |
577 | 579 | ||
578 | void ImageViewer::loadImage( const char *fileName ) | 580 | void ImageViewer::loadImage( const char *fileName ) |
579 | { | 581 | { |
580 | filename = fileName; | 582 | filename = fileName; |
581 | if ( filename ) { | 583 | if ( filename ) { |
582 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 584 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
583 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); | 585 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); |
584 | qApp->processEvents(); | 586 | qApp->processEvents(); |
585 | bool ok = image.load(filename, 0); | 587 | bool ok = image.load(filename, 0); |
586 | if ( ok ) { | 588 | if ( ok ) { |
587 | ok = reconvertImage(); | 589 | ok = reconvertImage(); |
588 | updateImageInfo(filename); | 590 | updateImageInfo(filename); |
589 | } | 591 | } |
590 | if ( !ok ) { | 592 | if ( !ok ) { |
591 | pm.resize(0,0); // couldn't load image | 593 | pm.resize(0,0); // couldn't load image |
592 | update(); | 594 | update(); |
593 | } | 595 | } |
594 | QApplication::restoreOverrideCursor(); // restore original cursor | 596 | QApplication::restoreOverrideCursor(); // restore original cursor |
595 | } | 597 | } |
596 | 598 | ||
597 | // fastLoad ? ", Fast" : "", | 599 | // fastLoad ? ", Fast" : "", |
598 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); | 600 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); |
599 | 601 | ||
600 | 602 | ||
601 | // matrix.reset(); | 603 | // matrix.reset(); |
602 | rotated90 = FALSE; | 604 | rotated90 = FALSE; |
603 | 605 | ||
604 | if (rotateOnLoad) { | 606 | if (rotateOnLoad) { |
605 | rotated90 = TRUE; | 607 | rotated90 = TRUE; |
606 | rot90(); | 608 | rot90(); |
607 | // matrix.rotate( -90.0 ); | 609 | // matrix.rotate( -90.0 ); |
608 | } | 610 | } |
609 | 611 | ||
610 | switchToImageView(); | 612 | switchToImageView(); |
611 | updateImage(); | 613 | updateImage(); |
612 | 614 | ||
613 | } | 615 | } |
614 | 616 | ||
615 | bool ImageViewer::loadSelected() | 617 | bool ImageViewer::loadSelected() |
616 | { | 618 | { |
617 | bool ok = false; | 619 | bool ok = false; |
618 | if ( stack->visibleWidget() == fileSelector ) | 620 | if ( stack->visibleWidget() == fileSelector ) |
619 | { | 621 | { |
620 | const DocLnk *link = fileSelector->selected(); | 622 | const DocLnk *link = fileSelector->selected(); |
621 | if ( link ) | 623 | if ( link ) |
622 | { | 624 | { |
623 | if ( link->file() != filename ) | 625 | if ( link->file() != filename ) |
624 | { | 626 | { |
625 | updateCaption( link->name() ); | 627 | updateCaption( link->name() ); |
626 | filename = link->file(); | 628 | filename = link->file(); |
627 | qApp->processEvents(); | 629 | qApp->processEvents(); |
628 | ok = image.load(filename, 0); | 630 | ok = image.load(filename, 0); |
629 | if ( ok ) | 631 | if ( ok ) |
630 | { | 632 | { |
631 | updateImageInfo(filename); | 633 | updateImageInfo(filename); |
632 | ok = reconvertImage(); | 634 | ok = reconvertImage(); |
633 | } | 635 | } |
634 | if ( !ok ) | 636 | if ( !ok ) |
635 | pm.resize(0,0); | 637 | pm.resize(0,0); |
636 | } | 638 | } |
637 | } | 639 | } |
638 | } | 640 | } |
639 | if ( !image.isNull() ) | 641 | if ( !image.isNull() ) |
640 | { | 642 | { |
641 | ok = true; | 643 | ok = true; |
642 | closeFileSelector(); | 644 | closeFileSelector(); |
643 | } | 645 | } |
644 | 646 | ||
645 | return ok; | 647 | return ok; |
646 | } | 648 | } |
647 | 649 | ||
648 | bool ImageViewer::reconvertImage() | 650 | bool ImageViewer::reconvertImage() |
649 | { | 651 | { |
650 | bool success = FALSE; | 652 | bool success = FALSE; |
651 | 653 | ||
652 | if ( image.isNull() ) return FALSE; | 654 | if ( image.isNull() ) return FALSE; |
653 | 655 | ||
654 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 656 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
655 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) | 657 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) |
656 | { | 658 | { |
657 | pmScaled = QPixmap(); | 659 | pmScaled = QPixmap(); |
658 | scale(); | 660 | scale(); |
659 | success = TRUE; // load successful | 661 | success = TRUE; // load successful |
660 | } | 662 | } |
661 | else | 663 | else |
662 | { | 664 | { |
663 | pm.resize(0,0); // couldn't load image | 665 | pm.resize(0,0); // couldn't load image |
664 | } | 666 | } |
665 | QApplication::restoreOverrideCursor(); // restore original cursor | 667 | QApplication::restoreOverrideCursor(); // restore original cursor |
666 | 668 | ||
667 | return success; // TRUE if loaded OK | 669 | return success; // TRUE if loaded OK |
668 | } | 670 | } |
669 | 671 | ||
670 | 672 | ||
671 | int ImageViewer::calcHeight() | 673 | int ImageViewer::calcHeight() |
672 | { | 674 | { |
673 | if ( !isFullScreen ) | 675 | if ( !isFullScreen ) |
674 | return imagePanel->paneHeight(); | 676 | return imagePanel->paneHeight(); |
675 | else | 677 | else |
676 | return qApp->desktop()->height(); | 678 | return qApp->desktop()->height(); |
677 | } | 679 | } |
678 | /* | 680 | /* |
679 | 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,225 +684,225 @@ int ImageViewer::calcHeight() | |||
682 | void ImageViewer::scale() | 684 | void ImageViewer::scale() |
683 | { | 685 | { |
684 | int h = calcHeight(); | 686 | int h = calcHeight(); |
685 | if ( image.isNull() ) return; | 687 | if ( image.isNull() ) return; |
686 | 688 | ||
687 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 689 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
688 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) | 690 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) |
689 | { // no need to scale if widget | 691 | { // no need to scale if widget |
690 | pmScaled = pm; // size equals pixmap size | 692 | pmScaled = pm; // size equals pixmap size |
691 | } | 693 | } |
692 | else | 694 | else |
693 | { | 695 | { |
694 | double hs = (double)h / (double)image.height(); | 696 | double hs = (double)h / (double)image.height(); |
695 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); | 697 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); |
696 | double scaleFactor = (hs > ws) ? ws : hs; | 698 | double scaleFactor = (hs > ws) ? ws : hs; |
697 | int smoothW = (int)(scaleFactor * image.width()); | 699 | int smoothW = (int)(scaleFactor * image.width()); |
698 | int smoothH = (int)(scaleFactor * image.height()); | 700 | int smoothH = (int)(scaleFactor * image.height()); |
699 | 701 | ||
700 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); | 702 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); |
701 | } | 703 | } |
702 | QApplication::restoreOverrideCursor(); // restore original cursor | 704 | QApplication::restoreOverrideCursor(); // restore original cursor |
703 | } | 705 | } |
704 | 706 | ||
705 | /* | 707 | /* |
706 | The resize event handler, if a valid pixmap was loaded it will call | 708 | The resize event handler, if a valid pixmap was loaded it will call |
707 | scale() to fit the pixmap to the new widget size. | 709 | scale() to fit the pixmap to the new widget size. |
708 | */ | 710 | */ |
709 | 711 | ||
710 | void ImageViewer::resizeEvent( QResizeEvent * ) | 712 | void ImageViewer::resizeEvent( QResizeEvent * ) |
711 | { | 713 | { |
712 | 714 | ||
713 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image | 715 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image |
714 | return; | 716 | return; |
715 | 717 | ||
716 | int h = calcHeight(); | 718 | int h = calcHeight(); |
717 | 719 | ||
718 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) | 720 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) |
719 | { // if new size, | 721 | { // if new size, |
720 | scale(); // scale pmScaled to window | 722 | scale(); // scale pmScaled to window |
721 | } | 723 | } |
722 | if ( image.hasAlphaBuffer() ) | 724 | if ( image.hasAlphaBuffer() ) |
723 | erase(); | 725 | erase(); |
724 | } | 726 | } |
725 | 727 | ||
726 | 728 | ||
727 | void ImageViewer::hFlip() | 729 | void ImageViewer::hFlip() |
728 | { | 730 | { |
729 | // matrix.scale( -1.0, 1.0 ); | 731 | // matrix.scale( -1.0, 1.0 ); |
730 | 732 | ||
731 | setImage(image.mirror(TRUE,FALSE)); | 733 | setImage(image.mirror(TRUE,FALSE)); |
732 | } | 734 | } |
733 | 735 | ||
734 | void ImageViewer::vFlip() | 736 | void ImageViewer::vFlip() |
735 | { | 737 | { |
736 | // matrix.scale( 1.0, -1.0 ); | 738 | // matrix.scale( 1.0, -1.0 ); |
737 | setImage(image.mirror(FALSE,TRUE)); | 739 | setImage(image.mirror(FALSE,TRUE)); |
738 | } | 740 | } |
739 | 741 | ||
740 | void ImageViewer::rot180() | 742 | void ImageViewer::rot180() |
741 | { | 743 | { |
742 | // matrix.rotate( 180.0 ); | 744 | // matrix.rotate( 180.0 ); |
743 | setImage(image.mirror(TRUE,TRUE)); | 745 | setImage(image.mirror(TRUE,TRUE)); |
744 | } | 746 | } |
745 | 747 | ||
746 | void ImageViewer::rot90() | 748 | void ImageViewer::rot90() |
747 | { | 749 | { |
748 | QImage oldimage; | 750 | QImage oldimage; |
749 | oldimage = image.convertDepth(32); | 751 | oldimage = image.convertDepth(32); |
750 | // matrix.rotate( -90.0 ); | 752 | // matrix.rotate( -90.0 ); |
751 | setImage(rotate(oldimage,Rotate90)); | 753 | setImage(rotate(oldimage,Rotate90)); |
752 | 754 | ||
753 | } | 755 | } |
754 | void ImageViewer::rot270() | 756 | void ImageViewer::rot270() |
755 | { | 757 | { |
756 | 758 | ||
757 | QImage oldimage; | 759 | QImage oldimage; |
758 | oldimage = image.convertDepth(32); | 760 | oldimage = image.convertDepth(32); |
759 | // matrix.rotate(90.0); | 761 | // matrix.rotate(90.0); |
760 | setImage(rotate(oldimage,Rotate270)); | 762 | setImage(rotate(oldimage,Rotate270)); |
761 | 763 | ||
762 | } | 764 | } |
763 | 765 | ||
764 | void ImageViewer::blackAndWhite() | 766 | void ImageViewer::blackAndWhite() |
765 | { | 767 | { |
766 | 768 | ||
767 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); | 769 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); |
768 | setImage(toGray(image,false)); | 770 | setImage(toGray(image,false)); |
769 | } | 771 | } |
770 | 772 | ||
771 | void ImageViewer::displayControlsDialog() | 773 | void ImageViewer::displayControlsDialog() |
772 | { | 774 | { |
773 | int w=80; | 775 | int w=80; |
774 | int h=w; | 776 | int h=w; |
775 | QImage small; | 777 | QImage small; |
776 | 778 | ||
777 | if ( image.width()<w ||image.height()<h ) | 779 | if ( image.width()<w ||image.height()<h ) |
778 | small=image.smoothScale(w,h); | 780 | small=image.smoothScale(w,h); |
779 | else | 781 | else |
780 | small=image.copy(0,0,w,h); | 782 | small=image.copy(0,0,w,h); |
781 | 783 | ||
782 | int newB=0; | 784 | int newB=0; |
783 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); | 785 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); |
784 | dlg->exec(); | 786 | dlg->exec(); |
785 | if ( newB ) { | 787 | if ( newB ) { |
786 | intensity(image,(float)newB/100); | 788 | intensity(image,(float)newB/100); |
787 | setImage(image); | 789 | setImage(image); |
788 | } | 790 | } |
789 | 791 | ||
790 | } | 792 | } |
791 | 793 | ||
792 | 794 | ||
793 | void ImageViewer::displayInfoDialog() | 795 | void ImageViewer::displayInfoDialog() |
794 | { | 796 | { |
795 | 797 | ||
796 | QStringList ls; | 798 | QStringList ls; |
797 | 799 | ||
798 | for ( int i=0;i<LAST;i++ ) | 800 | for ( int i=0;i<LAST;i++ ) |
799 | ls.append(imageInfo[i]); | 801 | ls.append(imageInfo[i]); |
800 | 802 | ||
801 | InfoDialog::displayInfo("Image Viewer",ls,this); | 803 | InfoDialog::displayInfo("Image Viewer",ls,this); |
802 | } | 804 | } |
803 | void ImageViewer::normalView() | 805 | void ImageViewer::normalView() |
804 | { | 806 | { |
805 | if ( !imagePanel->parentWidget() ) | 807 | if ( !imagePanel->parentWidget() ) |
806 | { | 808 | { |
807 | 809 | ||
808 | isFullScreen = FALSE; | 810 | isFullScreen = FALSE; |
809 | stack->addWidget( imagePanel, 1 ); | 811 | stack->addWidget( imagePanel, 1 ); |
810 | switchToImageView(); | 812 | switchToImageView(); |
811 | if ( isSized ) | 813 | if ( isSized ) |
812 | scale(); | 814 | scale(); |
813 | 815 | ||
814 | updateImage(); | 816 | updateImage(); |
815 | 817 | ||
816 | } | 818 | } |
817 | } | 819 | } |
818 | 820 | ||
819 | void ImageViewer::stopSlideShow() { | 821 | void ImageViewer::stopSlideShow() { |
820 | if (slideTimer->isActive()) | 822 | if (slideTimer->isActive()) |
821 | slideTimer->stop(); | 823 | slideTimer->stop(); |
822 | } | 824 | } |
823 | 825 | ||
824 | void ImageViewer::fullScreen() | 826 | void ImageViewer::fullScreen() |
825 | { | 827 | { |
826 | // Full-screen option | 828 | // Full-screen option |
827 | // contributed by Robert Wittams <robert@wittams.com> | 829 | // contributed by Robert Wittams <robert@wittams.com> |
828 | if ( imagePanel->parentWidget() && loadSelected() ) | 830 | if ( imagePanel->parentWidget() && loadSelected() ) |
829 | { | 831 | { |
830 | isFullScreen = TRUE; | 832 | isFullScreen = TRUE; |
831 | imagePanel->reparent(0,QPoint(0,0)); | 833 | imagePanel->reparent(0,QPoint(0,0)); |
832 | imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 834 | imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
833 | 835 | ||
834 | if ( isSized ) | 836 | if ( isSized ) |
835 | scale(); | 837 | scale(); |
836 | updateImage(); | 838 | updateImage(); |
837 | imagePanel->showFullScreen(); | 839 | imagePanel->showFullScreen(); |
838 | } | 840 | } |
839 | } | 841 | } |
840 | 842 | ||
841 | void ImageViewer::setImage(const QImage& newimage) | 843 | void ImageViewer::setImage(const QImage& newimage) |
842 | { | 844 | { |
843 | image = newimage; | 845 | image = newimage; |
844 | reconvertImage(); | 846 | reconvertImage(); |
845 | updateImage(); | 847 | updateImage(); |
846 | } | 848 | } |
847 | 849 | ||
848 | void ImageViewer::updateImageInfo(QString &filePath) | 850 | void ImageViewer::updateImageInfo(QString &filePath) |
849 | { | 851 | { |
850 | 852 | ||
851 | for ( int i=0;i<LAST;i++ ) | 853 | for ( int i=0;i<LAST;i++ ) |
852 | { | 854 | { |
853 | imageInfo[i]=""; | 855 | imageInfo[i]=""; |
854 | } | 856 | } |
855 | 857 | ||
856 | imageInfo[FORMAT]=QImage::imageFormat (filePath ); | 858 | imageInfo[FORMAT]=QImage::imageFormat (filePath ); |
857 | QFileInfo fi(filePath); | 859 | QFileInfo fi(filePath); |
858 | imageInfo[PATH]=fi.fileName(); | 860 | imageInfo[PATH]=fi.fileName(); |
859 | imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; | 861 | imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; |
860 | QString message("%1x%2"); | 862 | QString message("%1x%2"); |
861 | imageInfo[SIZE]=QString("%1x%2"); | 863 | imageInfo[SIZE]=QString("%1x%2"); |
862 | imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); | 864 | imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); |
863 | if ( image.numColors() > 0 ) | 865 | if ( image.numColors() > 0 ) |
864 | { | 866 | { |
865 | imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); | 867 | imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); |
866 | } | 868 | } |
867 | else if ( image.depth() >= 16 ) | 869 | else if ( image.depth() >= 16 ) |
868 | { | 870 | { |
869 | imageInfo[COLORS]=tr(" True color"); | 871 | imageInfo[COLORS]=tr(" True color"); |
870 | } | 872 | } |
871 | if ( image.hasAlphaBuffer() ) | 873 | if ( image.hasAlphaBuffer() ) |
872 | { | 874 | { |
873 | if ( image.depth() == 8 ) | 875 | if ( image.depth() == 8 ) |
874 | { | 876 | { |
875 | int i; | 877 | int i; |
876 | bool alpha[256]; | 878 | bool alpha[256]; |
877 | int nalpha=0; | 879 | int nalpha=0; |
878 | 880 | ||
879 | for ( i=0; i<256; i++ ) | 881 | for ( i=0; i<256; i++ ) |
880 | alpha[i] = FALSE; | 882 | alpha[i] = FALSE; |
881 | 883 | ||
882 | for ( i=0; i<image.numColors(); i++ ) | 884 | for ( i=0; i<image.numColors(); i++ ) |
883 | { | 885 | { |
884 | int alevel = image.color(i) >> 24; | 886 | int alevel = image.color(i) >> 24; |
885 | if ( !alpha[alevel] ) | 887 | if ( !alpha[alevel] ) |
886 | { | 888 | { |
887 | alpha[alevel] = TRUE; | 889 | alpha[alevel] = TRUE; |
888 | nalpha++; | 890 | nalpha++; |
889 | } | 891 | } |
890 | } | 892 | } |
891 | imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); | 893 | imageInfo[ALPHA]=tr("%1 alpha levels").arg(nalpha); |
892 | } | 894 | } |
893 | else | 895 | else |
894 | { | 896 | { |
895 | imageInfo[ALPHA]=tr("8-bit alpha channel"); | 897 | imageInfo[ALPHA]=tr("8-bit alpha channel"); |
896 | } | 898 | } |
897 | } | 899 | } |
898 | 900 | ||
899 | } | 901 | } |
900 | 902 | ||
901 | void ImageViewer::closeEvent( QCloseEvent *e ) | 903 | void ImageViewer::closeEvent( QCloseEvent *e ) |
902 | { | 904 | { |
903 | if ( stack->visibleWidget() == imagePanel && !bFromDocView ) | 905 | if ( stack->visibleWidget() == imagePanel && !bFromDocView ) |
904 | { | 906 | { |
905 | e->ignore(); | 907 | e->ignore(); |
906 | open(); | 908 | open(); |
diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h index 8555ff0..abbd976 100644 --- a/noncore/multimedia/showimg/showimg.h +++ b/noncore/multimedia/showimg/showimg.h | |||
@@ -113,96 +113,97 @@ class ImagePane : public QWidget | |||
113 | { | 113 | { |
114 | Q_OBJECT | 114 | Q_OBJECT |
115 | public: | 115 | public: |
116 | ImagePane( QWidget *parent=0 ); | 116 | ImagePane( QWidget *parent=0 ); |
117 | ~ImagePane() { } | 117 | ~ImagePane() { } |
118 | 118 | ||
119 | //void showStatus(); | 119 | //void showStatus(); |
120 | //void hideStatus(); | 120 | //void hideStatus(); |
121 | //QLabel *statusLabel() | 121 | //QLabel *statusLabel() |
122 | //{ | 122 | //{ |
123 | // return status; | 123 | // return status; |
124 | //} | 124 | //} |
125 | void setPixmap( const QPixmap &pm ); | 125 | void setPixmap( const QPixmap &pm ); |
126 | 126 | ||
127 | 127 | ||
128 | int paneWidth() const { | 128 | int paneWidth() const { |
129 | return image->visibleWidth(); | 129 | return image->visibleWidth(); |
130 | } | 130 | } |
131 | 131 | ||
132 | int paneHeight() const { | 132 | int paneHeight() const { |
133 | return image->visibleHeight(); | 133 | return image->visibleHeight(); |
134 | } | 134 | } |
135 | 135 | ||
136 | void setPosition(int x, int y) { | 136 | void setPosition(int x, int y) { |
137 | image->setContentsPos (x,y ); | 137 | image->setContentsPos (x,y ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void disable() { | 140 | void disable() { |
141 | pic->hide(); | 141 | pic->hide(); |
142 | } | 142 | } |
143 | 143 | ||
144 | signals: | 144 | signals: |
145 | void clicked(); | 145 | void clicked(); |
146 | 146 | ||
147 | private: | 147 | private: |
148 | QScrollView *image; | 148 | QScrollView *image; |
149 | ImageWidget *pic; | 149 | ImageWidget *pic; |
150 | QVBoxLayout *vb; | 150 | QVBoxLayout *vb; |
151 | 151 | ||
152 | private slots: | 152 | private slots: |
153 | void imageClicked(); | 153 | void imageClicked(); |
154 | }; | 154 | }; |
155 | 155 | ||
156 | 156 | ||
157 | class ImageViewer : public QMainWindow | 157 | class ImageViewer : public QMainWindow |
158 | { | 158 | { |
159 | Q_OBJECT | 159 | Q_OBJECT |
160 | public: | 160 | public: |
161 | static QString appName() { return QString::fromLatin1("showimg"); } | ||
161 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); | 162 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); |
162 | ~ImageViewer(); | 163 | ~ImageViewer(); |
163 | 164 | ||
164 | void loadImage( const char *fileName ); | 165 | void loadImage( const char *fileName ); |
165 | void show(const QString& fileref); | 166 | void show(const QString& fileref); |
166 | void show(); | 167 | void show(); |
167 | 168 | ||
168 | 169 | ||
169 | enum INFO_STRINGS { | 170 | enum INFO_STRINGS { |
170 | PATH, | 171 | PATH, |
171 | FORMAT, | 172 | FORMAT, |
172 | FILE_SIZE, | 173 | FILE_SIZE, |
173 | SIZE, | 174 | SIZE, |
174 | COLORS, | 175 | COLORS, |
175 | ALPHA, | 176 | ALPHA, |
176 | LAST | 177 | LAST |
177 | }; | 178 | }; |
178 | 179 | ||
179 | enum RotateDirection { | 180 | enum RotateDirection { |
180 | Rotate90, Rotate180, Rotate270 | 181 | Rotate90, Rotate180, Rotate270 |
181 | }; | 182 | }; |
182 | 183 | ||
183 | 184 | ||
184 | static QImage rotate(QImage &img, RotateDirection r); | 185 | static QImage rotate(QImage &img, RotateDirection r); |
185 | static QImage& intensity(QImage &image, float percent); | 186 | static QImage& intensity(QImage &image, float percent); |
186 | static QImage& toGray(QImage &image, bool fast = false); | 187 | static QImage& toGray(QImage &image, bool fast = false); |
187 | bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view | 188 | bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view |
188 | 189 | ||
189 | protected: | 190 | protected: |
190 | void resizeEvent( QResizeEvent * ); | 191 | void resizeEvent( QResizeEvent * ); |
191 | void closeEvent( QCloseEvent * ); | 192 | void closeEvent( QCloseEvent * ); |
192 | 193 | ||
193 | private: | 194 | private: |
194 | int imageIndex(void); | 195 | int imageIndex(void); |
195 | 196 | ||
196 | void updateCaption( QString name ); | 197 | void updateCaption( QString name ); |
197 | bool loadSelected(); | 198 | bool loadSelected(); |
198 | void scale(); | 199 | void scale(); |
199 | bool reconvertImage(); | 200 | bool reconvertImage(); |
200 | int calcHeight(); | 201 | int calcHeight(); |
201 | void setImage(const QImage& newimage); | 202 | void setImage(const QImage& newimage); |
202 | void updateImageInfo(QString &filePath); | 203 | void updateImageInfo(QString &filePath); |
203 | void switchToFileSelector(); | 204 | void switchToFileSelector(); |
204 | void switchToImageView(); | 205 | void switchToImageView(); |
205 | 206 | ||
206 | void updateImage(); | 207 | void updateImage(); |
207 | 208 | ||
208 | private slots: | 209 | private slots: |
diff --git a/noncore/multimedia/showimg/showimg.pro b/noncore/multimedia/showimg/showimg.pro index d369e62..e8d753b 100644 --- a/noncore/multimedia/showimg/showimg.pro +++ b/noncore/multimedia/showimg/showimg.pro | |||
@@ -1,31 +1,29 @@ | |||
1 | TEMPLATE = app | 1 | CONFIG += qt warn_on release quick-app |
2 | CONFIG += qt warn_on release | ||
3 | DESTDIR = $(OPIEDIR)/bin | ||
4 | HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h | 2 | HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h |
5 | SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp | 3 | SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp |
6 | TARGET = showimg | 4 | TARGET = showimg |
7 | INCLUDEPATH += $(OPIEDIR)/include | 5 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 6 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopie | 7 | LIBS += -lqpe -lopie |
10 | 8 | ||
11 | TRANSLATIONS = ../../../i18n/de/showimg.ts \ | 9 | TRANSLATIONS = ../../../i18n/de/showimg.ts \ |
12 | ../../../i18n/nl/showimg.ts \ | 10 | ../../../i18n/nl/showimg.ts \ |
13 | ../../../i18n/xx/showimg.ts \ | 11 | ../../../i18n/xx/showimg.ts \ |
14 | ../../../i18n/en/showimg.ts \ | 12 | ../../../i18n/en/showimg.ts \ |
15 | ../../../i18n/es/showimg.ts \ | 13 | ../../../i18n/es/showimg.ts \ |
16 | ../../../i18n/fr/showimg.ts \ | 14 | ../../../i18n/fr/showimg.ts \ |
17 | ../../../i18n/hu/showimg.ts \ | 15 | ../../../i18n/hu/showimg.ts \ |
18 | ../../../i18n/ja/showimg.ts \ | 16 | ../../../i18n/ja/showimg.ts \ |
19 | ../../../i18n/ko/showimg.ts \ | 17 | ../../../i18n/ko/showimg.ts \ |
20 | ../../../i18n/no/showimg.ts \ | 18 | ../../../i18n/no/showimg.ts \ |
21 | ../../../i18n/pl/showimg.ts \ | 19 | ../../../i18n/pl/showimg.ts \ |
22 | ../../../i18n/pt/showimg.ts \ | 20 | ../../../i18n/pt/showimg.ts \ |
23 | ../../../i18n/pt_BR/showimg.ts \ | 21 | ../../../i18n/pt_BR/showimg.ts \ |
24 | ../../../i18n/sl/showimg.ts \ | 22 | ../../../i18n/sl/showimg.ts \ |
25 | ../../../i18n/zh_CN/showimg.ts \ | 23 | ../../../i18n/zh_CN/showimg.ts \ |
26 | ../../../i18n/zh_TW/showimg.ts \ | 24 | ../../../i18n/zh_TW/showimg.ts \ |
27 | ../../../i18n/da/showimg.ts | 25 | ../../../i18n/da/showimg.ts |
28 | 26 | ||
29 | 27 | ||
30 | 28 | ||
31 | include ( $(OPIEDIR)/include.pro ) | 29 | include ( $(OPIEDIR)/include.pro ) |