-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 | |||
@@ -9,25 +9,19 @@ | |||
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 | |||
@@ -13,33 +13,33 @@ | |||
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> |
@@ -62,111 +62,113 @@ ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightne | |||
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 | ||
@@ -197,214 +199,214 @@ void ImageWidget::paintEvent( QPaintEvent *e ) | |||
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() { |
@@ -450,33 +452,33 @@ void ImageViewer::switchSizeToScreen() | |||
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() |
@@ -484,33 +486,33 @@ void ImageViewer::switchToImageView() | |||
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 | { |
@@ -519,129 +521,129 @@ void ImageViewer::show(const QString& fileref) | |||
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 | ||
@@ -714,33 +716,33 @@ void ImageViewer::resizeEvent( QResizeEvent * ) | |||
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() |
@@ -794,33 +796,33 @@ 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 |
@@ -829,46 +831,46 @@ void ImageViewer::fullScreen() | |||
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 | { |
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 | |||
@@ -145,32 +145,33 @@ 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 |
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,19 +1,17 @@ | |||
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 \ |