author | drw <drw> | 2004-03-02 15:45:42 (UTC) |
---|---|---|
committer | drw <drw> | 2004-03-02 15:45:42 (UTC) |
commit | 270a76fbf653df353476ddf17835d532ceb6b6c2 (patch) (unidiff) | |
tree | f967cf572a6f8f3742fb2612137d50594220dc32 | |
parent | e31fe9d73c6cd9be80bb18ca45ad3618192f718f (diff) | |
download | opie-270a76fbf653df353476ddf17835d532ceb6b6c2.zip opie-270a76fbf653df353476ddf17835d532ceb6b6c2.tar.gz opie-270a76fbf653df353476ddf17835d532ceb6b6c2.tar.bz2 |
ShowImg: libopie -> libopie2
-rw-r--r-- | noncore/multimedia/showimg/config.in | 2 | ||||
-rw-r--r-- | noncore/multimedia/showimg/main.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/showimg/opie-showimg.control | 2 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.pro | 2 |
5 files changed, 11 insertions, 10 deletions
diff --git a/noncore/multimedia/showimg/config.in b/noncore/multimedia/showimg/config.in index 36e8cf0..808c841 100644 --- a/noncore/multimedia/showimg/config.in +++ b/noncore/multimedia/showimg/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config SHOWIMG | 1 | config SHOWIMG |
2 | boolean "opie-showimg (image viewer)" | 2 | boolean "opie-showimg (image viewer)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI |
diff --git a/noncore/multimedia/showimg/main.cpp b/noncore/multimedia/showimg/main.cpp index 1c864e9..b61cffb 100644 --- a/noncore/multimedia/showimg/main.cpp +++ b/noncore/multimedia/showimg/main.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "showimg.h" | 21 | #include "showimg.h" |
22 | 22 | ||
23 | 23 | ||
24 | #include <opie/oapplicationfactory.h> | 24 | #include <opie2/oapplicationfactory.h> |
25 | 25 | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) \ No newline at end of file | 26 | OPIE_EXPORT_APP( OApplicationFactory<ImageViewer> ) |
diff --git a/noncore/multimedia/showimg/opie-showimg.control b/noncore/multimedia/showimg/opie-showimg.control index 1e54383..2fbfabc 100644 --- a/noncore/multimedia/showimg/opie-showimg.control +++ b/noncore/multimedia/showimg/opie-showimg.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-showimg | 1 | Package: opie-showimg |
2 | Files: plugins/application/libshowimg.so* bin/showimg apps/Applications/showimg.desktop pics/imageviewer | 2 | Files: plugins/application/libshowimg.so* bin/showimg apps/Applications/showimg.desktop pics/imageviewer |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal | 7 | Depends: task-opie-minimal,libopiecore2, libopieui2 |
8 | Description: Image Viewer | 8 | Description: Image Viewer |
9 | The image viewer for the Opie environment. Supports | 9 | The image viewer for the Opie environment. Supports |
10 | all graphics formats are compiled into Qt/Embedded (eg. PNG). | 10 | all graphics formats are compiled into Qt/Embedded (eg. PNG). |
11 | Version: $QPE_VERSION$EXTRAVERSION | 11 | Version: $QPE_VERSION$EXTRAVERSION |
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 82eac33..6c0c4db 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -1,781 +1,782 @@ | |||
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 <opie2/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 <math.h> | ||
36 | #include <qmenubar.h> | ||
37 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | |||
38 | #include <qaction.h> | 37 | #include <qaction.h> |
39 | #include <qfiledialog.h> | 38 | #include <qfiledialog.h> |
39 | #include <qmenubar.h> | ||
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | 41 | ||
42 | #include <math.h> | ||
42 | 43 | ||
43 | 44 | ||
44 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) | 45 | ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent) |
45 | : QDialog(parent,0,true) | 46 | : QDialog(parent,0,true) |
46 | { | 47 | { |
47 | setCaption(caption); | 48 | setCaption(caption); |
48 | 49 | ||
49 | if ( parent ) { | 50 | if ( parent ) { |
50 | setPalette(parent->palette()); | 51 | setPalette(parent->palette()); |
51 | } | 52 | } |
52 | 53 | ||
53 | b=brightness; | 54 | b=brightness; |
54 | img=image; | 55 | img=image; |
55 | 56 | ||
56 | setMinimumSize(140,80); | 57 | setMinimumSize(140,80); |
57 | 58 | ||
58 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); | 59 | QGridLayout *gl= new QGridLayout(this,2,2,4,4); |
59 | 60 | ||
60 | pixmap =new ImageWidget(this);; | 61 | pixmap =new ImageWidget(this);; |
61 | QPixmap pm; | 62 | QPixmap pm; |
62 | pm.convertFromImage(img); | 63 | pm.convertFromImage(img); |
63 | pixmap->setPixmap(pm); | 64 | pixmap->setPixmap(pm); |
64 | pixmap->setMinimumSize(pm.width(),pm.height()); | 65 | pixmap->setMinimumSize(pm.width(),pm.height()); |
65 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); | 66 | gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); |
66 | QLabel *l=new QLabel(tr("Brightness")+":",this); | 67 | QLabel *l=new QLabel(tr("Brightness")+":",this); |
67 | gl->addWidget(l,1,0,AlignLeft); | 68 | gl->addWidget(l,1,0,AlignLeft); |
68 | spb=new QSpinBox(-100,100,2,this); | 69 | spb=new QSpinBox(-100,100,2,this); |
69 | gl->addWidget(spb,1,1,AlignRight); | 70 | gl->addWidget(spb,1,1,AlignRight); |
70 | 71 | ||
71 | spb->setValue(0); | 72 | spb->setValue(0); |
72 | 73 | ||
73 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); | 74 | connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); |
74 | 75 | ||
75 | } | 76 | } |
76 | 77 | ||
77 | void ControlsDialog::bValueChanged(int value) | 78 | void ControlsDialog::bValueChanged(int value) |
78 | { | 79 | { |
79 | QImage nImage=img; | 80 | QImage nImage=img; |
80 | nImage.detach(); | 81 | nImage.detach(); |
81 | ImageViewer::intensity(nImage, (float)value/100); | 82 | ImageViewer::intensity(nImage, (float)value/100); |
82 | QPixmap pm; | 83 | QPixmap pm; |
83 | pm.convertFromImage(nImage); | 84 | pm.convertFromImage(nImage); |
84 | pixmap->setPixmap(pm); | 85 | pixmap->setPixmap(pm); |
85 | pixmap->repaint(false); | 86 | pixmap->repaint(false); |
86 | 87 | ||
87 | 88 | ||
88 | } | 89 | } |
89 | 90 | ||
90 | void ControlsDialog::accept() | 91 | void ControlsDialog::accept() |
91 | { | 92 | { |
92 | *b=spb->value(); | 93 | *b=spb->value(); |
93 | done(1); | 94 | done(1); |
94 | } | 95 | } |
95 | 96 | ||
96 | //=========================================================================== | 97 | //=========================================================================== |
97 | 98 | ||
98 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) | 99 | InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent) |
99 | : QDialog(parent,0,true) | 100 | : QDialog(parent,0,true) |
100 | { | 101 | { |
101 | setCaption(caption); | 102 | setCaption(caption); |
102 | 103 | ||
103 | if ( parent ) | 104 | if ( parent ) |
104 | { | 105 | { |
105 | setPalette(parent->palette()); | 106 | setPalette(parent->palette()); |
106 | } | 107 | } |
107 | 108 | ||
108 | 109 | ||
109 | 110 | ||
110 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; | 111 | QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") }; |
111 | 112 | ||
112 | setMinimumSize(180,80); | 113 | setMinimumSize(180,80); |
113 | int num=ImageViewer::LAST+1; | 114 | int num=ImageViewer::LAST+1; |
114 | if ( text[ImageViewer::ALPHA].isEmpty() ) | 115 | if ( text[ImageViewer::ALPHA].isEmpty() ) |
115 | num--; | 116 | num--; |
116 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); | 117 | QGridLayout *gl= new QGridLayout(this,num,2,4,2); |
117 | QLabel *l; | 118 | QLabel *l; |
118 | int count=0; | 119 | int count=0; |
119 | for ( int i=0;i<num;i++ ) | 120 | for ( int i=0;i<num;i++ ) |
120 | { | 121 | { |
121 | if ( i==1 ) | 122 | if ( i==1 ) |
122 | { | 123 | { |
123 | QFrame *frm=new QFrame(this); | 124 | QFrame *frm=new QFrame(this); |
124 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); | 125 | frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); |
125 | gl->addMultiCellWidget(frm,i,i,0,1); | 126 | gl->addMultiCellWidget(frm,i,i,0,1); |
126 | } | 127 | } |
127 | else | 128 | else |
128 | { | 129 | { |
129 | l=new QLabel( tr( labels[count] )+":",this); | 130 | l=new QLabel( tr( labels[count] )+":",this); |
130 | gl->addWidget(l,i,0,AlignLeft); | 131 | gl->addWidget(l,i,0,AlignLeft); |
131 | l=new QLabel(text[count],this); | 132 | l=new QLabel(text[count],this); |
132 | gl->addWidget(l,i,1,AlignRight); | 133 | gl->addWidget(l,i,1,AlignRight); |
133 | count++; | 134 | count++; |
134 | } | 135 | } |
135 | 136 | ||
136 | } | 137 | } |
137 | 138 | ||
138 | } | 139 | } |
139 | 140 | ||
140 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) | 141 | void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) |
141 | { | 142 | { |
142 | InfoDialog *dlg=new InfoDialog(caption,text,parent); | 143 | InfoDialog *dlg=new InfoDialog(caption,text,parent); |
143 | dlg->exec(); | 144 | dlg->exec(); |
144 | delete dlg; | 145 | delete dlg; |
145 | } | 146 | } |
146 | 147 | ||
147 | //=========================================================================== | 148 | //=========================================================================== |
148 | 149 | ||
149 | 150 | ||
150 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 151 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
151 | { | 152 | { |
152 | vb = new QVBoxLayout( this ); | 153 | vb = new QVBoxLayout( this ); |
153 | 154 | ||
154 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); | 155 | image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); |
155 | pic=new ImageWidget(image); | 156 | pic=new ImageWidget(image); |
156 | image->addChild(pic); | 157 | image->addChild(pic); |
157 | 158 | ||
158 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 159 | connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
159 | 160 | ||
160 | vb->addWidget( image ); | 161 | vb->addWidget( image ); |
161 | 162 | ||
162 | } | 163 | } |
163 | 164 | ||
164 | void ImagePane::setPixmap( const QPixmap &pm ) | 165 | void ImagePane::setPixmap( const QPixmap &pm ) |
165 | { | 166 | { |
166 | pic->setPixmap( pm ); | 167 | pic->setPixmap( pm ); |
167 | pic->resize(pm.width(),pm.height()); | 168 | pic->resize(pm.width(),pm.height()); |
168 | image->updateScrollBars (); | 169 | image->updateScrollBars (); |
169 | pic->repaint(false); | 170 | pic->repaint(false); |
170 | } | 171 | } |
171 | 172 | ||
172 | void ImagePane::imageClicked() | 173 | void ImagePane::imageClicked() |
173 | { | 174 | { |
174 | emit clicked(); | 175 | emit clicked(); |
175 | } | 176 | } |
176 | //=========================================================================== | 177 | //=========================================================================== |
177 | /* | 178 | /* |
178 | Draws the portion of the scaled pixmap that needs to be updated | 179 | Draws the portion of the scaled pixmap that needs to be updated |
179 | */ | 180 | */ |
180 | 181 | ||
181 | void ImageWidget::paintEvent( QPaintEvent *e ) | 182 | void ImageWidget::paintEvent( QPaintEvent *e ) |
182 | { | 183 | { |
183 | QPainter painter(this); | 184 | QPainter painter(this); |
184 | 185 | ||
185 | painter.setClipRect(e->rect()); | 186 | painter.setClipRect(e->rect()); |
186 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); | 187 | painter.fillRect(0,0,width(),height(),QColor(0,0,0)); |
187 | 188 | ||
188 | if ( pixmap.size() != QSize( 0, 0 ) ) | 189 | if ( pixmap.size() != QSize( 0, 0 ) ) |
189 | { // is an image loaded? | 190 | { // is an image loaded? |
190 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 191 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
191 | } | 192 | } |
192 | } | 193 | } |
193 | 194 | ||
194 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 195 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
195 | { | 196 | { |
196 | emit clicked(); | 197 | emit clicked(); |
197 | } | 198 | } |
198 | 199 | ||
199 | //=========================================================================== | 200 | //=========================================================================== |
200 | 201 | ||
201 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | 202 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int /*wFlags*/ ) |
202 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) | 203 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
203 | { | 204 | { |
204 | setCaption( tr("Image Viewer") ); | 205 | setCaption( tr("Image Viewer") ); |
205 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 206 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
206 | 207 | ||
207 | 208 | ||
208 | Config cfg("Image Viewer"); | 209 | Config cfg("Image Viewer"); |
209 | cfg.setGroup("Image Viewer"); | 210 | cfg.setGroup("Image Viewer"); |
210 | 211 | ||
211 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 212 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
212 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 213 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
213 | 214 | ||
214 | isFullScreen = FALSE; | 215 | isFullScreen = FALSE; |
215 | 216 | ||
216 | setToolBarsMovable( FALSE ); | 217 | setToolBarsMovable( FALSE ); |
217 | 218 | ||
218 | toolBar = new QToolBar( this ); | 219 | toolBar = new QToolBar( this ); |
219 | toolBar->setHorizontalStretchable( TRUE ); | 220 | toolBar->setHorizontalStretchable( TRUE ); |
220 | 221 | ||
221 | menuBar = new QMenuBar( toolBar ); | 222 | menuBar = new QMenuBar( toolBar ); |
222 | 223 | ||
223 | current=menuBar; | 224 | current=menuBar; |
224 | 225 | ||
225 | 226 | ||
226 | 227 | ||
227 | fileMenuFile = new QPopupMenu(this); | 228 | fileMenuFile = new QPopupMenu(this); |
228 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 229 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
229 | fileMenuFile->insertItem(tr("Open"), | 230 | fileMenuFile->insertItem(tr("Open"), |
230 | this, SLOT(openFile()), 0); | 231 | this, SLOT(openFile()), 0); |
231 | 232 | ||
232 | viewMenuFile = new QPopupMenu( this ); | 233 | viewMenuFile = new QPopupMenu( this ); |
233 | //menubarFile->insertItem( tr("View"), viewMenu ); | 234 | //menubarFile->insertItem( tr("View"), viewMenu ); |
234 | viewMenuFile->insertItem( tr("Thumbnail View"), | 235 | viewMenuFile->insertItem( tr("Thumbnail View"), |
235 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 236 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
236 | 237 | ||
237 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 238 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
238 | 239 | ||
239 | 240 | ||
240 | 241 | ||
241 | 242 | ||
242 | optionsMenuFile = new QPopupMenu( this); | 243 | optionsMenuFile = new QPopupMenu( this); |
243 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 244 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
244 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 245 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
245 | QString::null, 0, this, 0 ); | 246 | QString::null, 0, this, 0 ); |
246 | slideAction->setToggleAction( TRUE ); | 247 | slideAction->setToggleAction( TRUE ); |
247 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 248 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
248 | slideAction->addTo( optionsMenuFile); | 249 | slideAction->addTo( optionsMenuFile); |
249 | // slideAction->addTo( toolBar ); | 250 | // slideAction->addTo( toolBar ); |
250 | 251 | ||
251 | 252 | ||
252 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 253 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
253 | optionsMenuFile->insertSeparator(); | 254 | optionsMenuFile->insertSeparator(); |
254 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 255 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
255 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 256 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
256 | 257 | ||
257 | QStrList fmt = QImage::outputFormats(); | 258 | QStrList fmt = QImage::outputFormats(); |
258 | 259 | ||
259 | 260 | ||
260 | fileMenuView = new QPopupMenu( this ); | 261 | fileMenuView = new QPopupMenu( this ); |
261 | //menubarView->insertItem( tr("File"),fileMenu ); | 262 | //menubarView->insertItem( tr("File"),fileMenu ); |
262 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 263 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
263 | fileMenuView->insertSeparator(); | 264 | fileMenuView->insertSeparator(); |
264 | 265 | ||
265 | viewMenuView = new QPopupMenu(this ); | 266 | viewMenuView = new QPopupMenu(this ); |
266 | viewMenuView->setCheckable ( true ); | 267 | viewMenuView->setCheckable ( true ); |
267 | 268 | ||
268 | //menubarView->insertItem( tr("View"),viewMenu ); | 269 | //menubarView->insertItem( tr("View"),viewMenu ); |
269 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 270 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
270 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 271 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
271 | 272 | ||
272 | stack = new QWidgetStack( this ); | 273 | stack = new QWidgetStack( this ); |
273 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 274 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
274 | setCentralWidget( stack ); | 275 | setCentralWidget( stack ); |
275 | 276 | ||
276 | 277 | ||
277 | imagePanel = new ImagePane( stack ); | 278 | imagePanel = new ImagePane( stack ); |
278 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 279 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
279 | 280 | ||
280 | 281 | ||
281 | ImageFileSelector::CURRENT_VIEW cv; | 282 | ImageFileSelector::CURRENT_VIEW cv; |
282 | if(showThumbView) | 283 | if(showThumbView) |
283 | cv=ImageFileSelector::THUMBNAIL; | 284 | cv=ImageFileSelector::THUMBNAIL; |
284 | else | 285 | else |
285 | cv=ImageFileSelector::DETAILED; | 286 | cv=ImageFileSelector::DETAILED; |
286 | 287 | ||
287 | qDebug("cv = %d",cv); | 288 | qDebug("cv = %d",cv); |
288 | 289 | ||
289 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 290 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
290 | 291 | ||
291 | //switchThumbView(); | 292 | //switchThumbView(); |
292 | 293 | ||
293 | 294 | ||
294 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 295 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
295 | //fileSelector->setNewVisible(FALSE); | 296 | //fileSelector->setNewVisible(FALSE); |
296 | //fileSelector->setCloseVisible(FALSE); | 297 | //fileSelector->setCloseVisible(FALSE); |
297 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 298 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
298 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), | 299 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), |
299 | this, SLOT( openFile(const DocLnk&) ) ); | 300 | this, SLOT( openFile(const DocLnk&) ) ); |
300 | 301 | ||
301 | imageList = fileSelector->fileList(); | 302 | imageList = fileSelector->fileList(); |
302 | slideAction->setEnabled( imageList.count() != 0); | 303 | slideAction->setEnabled( imageList.count() != 0); |
303 | 304 | ||
304 | iconToolBar = new QToolBar(this); | 305 | iconToolBar = new QToolBar(this); |
305 | 306 | ||
306 | QAction *a; | 307 | QAction *a; |
307 | 308 | ||
308 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 309 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
309 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 310 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
310 | a->addTo( fileMenuView); | 311 | a->addTo( fileMenuView); |
311 | a->addTo( iconToolBar ); | 312 | a->addTo( iconToolBar ); |
312 | 313 | ||
313 | 314 | ||
314 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 315 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
315 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 316 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
316 | a->addTo( iconToolBar ); | 317 | a->addTo( iconToolBar ); |
317 | a->addTo( viewMenuView ); | 318 | a->addTo( viewMenuView ); |
318 | 319 | ||
319 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 320 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
320 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
321 | a->addTo( iconToolBar ); | 322 | a->addTo( iconToolBar ); |
322 | a->addTo( viewMenuView ); | 323 | a->addTo( viewMenuView ); |
323 | 324 | ||
324 | 325 | ||
325 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); | 326 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); |
326 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 327 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
327 | //a->addTo( iconToolBar ); | 328 | //a->addTo( iconToolBar ); |
328 | a->addTo( viewMenuView ); | 329 | a->addTo( viewMenuView ); |
329 | 330 | ||
330 | 331 | ||
331 | 332 | ||
332 | viewMenuView->insertSeparator(); | 333 | viewMenuView->insertSeparator(); |
333 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 334 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
334 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 335 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
335 | viewMenuView->insertSeparator(); | 336 | viewMenuView->insertSeparator(); |
336 | 337 | ||
337 | 338 | ||
338 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 339 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
339 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 340 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
340 | sss->addTo( iconToolBar ); | 341 | sss->addTo( iconToolBar ); |
341 | sss->addTo( viewMenuView ); | 342 | sss->addTo( viewMenuView ); |
342 | 343 | ||
343 | sss->setOn(isSized); | 344 | sss->setOn(isSized); |
344 | viewMenuView->insertSeparator(); | 345 | viewMenuView->insertSeparator(); |
345 | 346 | ||
346 | 347 | ||
347 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 348 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
348 | QString::null, 0, this, 0 ); | 349 | QString::null, 0, this, 0 ); |
349 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 350 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
350 | a->addTo( iconToolBar ); | 351 | a->addTo( iconToolBar ); |
351 | a->addTo( viewMenuView); | 352 | a->addTo( viewMenuView); |
352 | 353 | ||
353 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 354 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
354 | QString::null, 0, this, 0 ); | 355 | QString::null, 0, this, 0 ); |
355 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 356 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
356 | a->addTo( iconToolBar ); | 357 | a->addTo( iconToolBar ); |
357 | a->addTo( viewMenuView); | 358 | a->addTo( viewMenuView); |
358 | 359 | ||
359 | 360 | ||
360 | Config config( "ImageViewer" ); | 361 | Config config( "ImageViewer" ); |
361 | config.setGroup( "SlideShow" ); | 362 | config.setGroup( "SlideShow" ); |
362 | slideDelay = config.readNumEntry( "Delay", 2); | 363 | slideDelay = config.readNumEntry( "Delay", 2); |
363 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 364 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
364 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 365 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
365 | 366 | ||
366 | config.setGroup("Default"); | 367 | config.setGroup("Default"); |
367 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 368 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
368 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 369 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
369 | slideTimer = new QTimer( this ); | 370 | slideTimer = new QTimer( this ); |
370 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 371 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
371 | 372 | ||
372 | switchToFileSelector(); | 373 | switchToFileSelector(); |
373 | 374 | ||
374 | setMouseTracking( TRUE ); | 375 | setMouseTracking( TRUE ); |
375 | 376 | ||
376 | 377 | ||
377 | } | 378 | } |
378 | 379 | ||
379 | ImageViewer::~ImageViewer() | 380 | ImageViewer::~ImageViewer() |
380 | { | 381 | { |
381 | Config cfg("Image Viewer"); | 382 | Config cfg("Image Viewer"); |
382 | cfg.setGroup("Image Viewer"); | 383 | cfg.setGroup("Image Viewer"); |
383 | 384 | ||
384 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 385 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
385 | cfg.writeEntry("SizeToScreen",(int)isSized); | 386 | cfg.writeEntry("SizeToScreen",(int)isSized); |
386 | 387 | ||
387 | cfg.setGroup( "SlideShow" ); | 388 | cfg.setGroup( "SlideShow" ); |
388 | cfg.writeEntry( "Delay", slideDelay); | 389 | cfg.writeEntry( "Delay", slideDelay); |
389 | cfg.writeEntry( "Repeat", slideRepeat ); | 390 | cfg.writeEntry( "Repeat", slideRepeat ); |
390 | cfg.writeEntry("Reverse", slideReverse); | 391 | cfg.writeEntry("Reverse", slideReverse); |
391 | 392 | ||
392 | cfg.setGroup("Default"); | 393 | cfg.setGroup("Default"); |
393 | cfg.writeEntry("Rotate", rotateOnLoad); | 394 | cfg.writeEntry("Rotate", rotateOnLoad); |
394 | cfg.writeEntry("FastLoad", fastLoad); | 395 | cfg.writeEntry("FastLoad", fastLoad); |
395 | 396 | ||
396 | delete imagePanel; // in case it is fullscreen | 397 | delete imagePanel; // in case it is fullscreen |
397 | } | 398 | } |
398 | 399 | ||
399 | void ImageViewer::help() { | 400 | void ImageViewer::help() { |
400 | 401 | ||
401 | } | 402 | } |
402 | 403 | ||
403 | 404 | ||
404 | void ImageViewer::settings() | 405 | void ImageViewer::settings() |
405 | { | 406 | { |
406 | SettingsDialog dlg( this, 0, TRUE ); | 407 | SettingsDialog dlg( this, 0, TRUE ); |
407 | dlg.setDelay( slideDelay ); | 408 | dlg.setDelay( slideDelay ); |
408 | dlg.setRepeat( slideRepeat ); | 409 | dlg.setRepeat( slideRepeat ); |
409 | dlg.setReverse( slideReverse ); | 410 | dlg.setReverse( slideReverse ); |
410 | dlg.setRotate(rotateOnLoad); | 411 | dlg.setRotate(rotateOnLoad); |
411 | dlg.setFastLoad(fastLoad); | 412 | dlg.setFastLoad(fastLoad); |
412 | 413 | ||
413 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { | 414 | if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) { |
414 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); | 415 | qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"); |
415 | slideDelay = dlg.delay(); | 416 | slideDelay = dlg.delay(); |
416 | slideRepeat = dlg.repeat(); | 417 | slideRepeat = dlg.repeat(); |
417 | slideReverse = dlg.reverse(); | 418 | slideReverse = dlg.reverse(); |
418 | rotateOnLoad = dlg.rotate(); | 419 | rotateOnLoad = dlg.rotate(); |
419 | fastLoad = dlg.fastLoad(); | 420 | fastLoad = dlg.fastLoad(); |
420 | 421 | ||
421 | Config config( "ImageViewer" ); | 422 | Config config( "ImageViewer" ); |
422 | config.setGroup( "SlideShow" ); | 423 | config.setGroup( "SlideShow" ); |
423 | config.writeEntry( "Delay", slideDelay ); | 424 | config.writeEntry( "Delay", slideDelay ); |
424 | config.writeEntry( "Repeat", slideRepeat ); | 425 | config.writeEntry( "Repeat", slideRepeat ); |
425 | config.writeEntry("Reverse", slideReverse); | 426 | config.writeEntry("Reverse", slideReverse); |
426 | 427 | ||
427 | config.setGroup("Default"); | 428 | config.setGroup("Default"); |
428 | config.writeEntry("Rotate", rotateOnLoad); | 429 | config.writeEntry("Rotate", rotateOnLoad); |
429 | config.writeEntry("FastLoad", fastLoad); | 430 | config.writeEntry("FastLoad", fastLoad); |
430 | } | 431 | } |
431 | } | 432 | } |
432 | 433 | ||
433 | void ImageViewer::switchSizeToScreen() | 434 | void ImageViewer::switchSizeToScreen() |
434 | { | 435 | { |
435 | isSized=!isSized; | 436 | isSized=!isSized; |
436 | sss->setOn(isSized); | 437 | sss->setOn(isSized); |
437 | updateImage(); | 438 | updateImage(); |
438 | } | 439 | } |
439 | 440 | ||
440 | void ImageViewer::updateImage() | 441 | void ImageViewer::updateImage() |
441 | { | 442 | { |
442 | if ( isSized ) { | 443 | if ( isSized ) { |
443 | imagePanel->setPixmap(pmScaled); | 444 | imagePanel->setPixmap(pmScaled); |
444 | } else { | 445 | } else { |
445 | imagePanel->setPixmap(pm); | 446 | imagePanel->setPixmap(pm); |
446 | } | 447 | } |
447 | } | 448 | } |
448 | 449 | ||
449 | void ImageViewer::switchThumbView() | 450 | void ImageViewer::switchThumbView() |
450 | { | 451 | { |
451 | 452 | ||
452 | showThumbView=!showThumbView; | 453 | showThumbView=!showThumbView; |
453 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 454 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
454 | fileSelector->switchView(); | 455 | fileSelector->switchView(); |
455 | 456 | ||
456 | } | 457 | } |
457 | 458 | ||
458 | void ImageViewer::switchToFileSelector() | 459 | void ImageViewer::switchToFileSelector() |
459 | { | 460 | { |
460 | stack->raiseWidget(fileSelector); | 461 | stack->raiseWidget(fileSelector); |
461 | menuBar->clear(); | 462 | menuBar->clear(); |
462 | menuBar->insertItem( tr("File"), fileMenuFile ); | 463 | menuBar->insertItem( tr("File"), fileMenuFile ); |
463 | menuBar->insertItem( tr("View"), viewMenuFile ); | 464 | menuBar->insertItem( tr("View"), viewMenuFile ); |
464 | menuBar->insertItem( tr("Options"), optionsMenuFile ); | 465 | menuBar->insertItem( tr("Options"), optionsMenuFile ); |
465 | iconToolBar->hide(); | 466 | iconToolBar->hide(); |
466 | imagePanel->disable(); | 467 | imagePanel->disable(); |
467 | slideShow(false); | 468 | slideShow(false); |
468 | 469 | ||
469 | } | 470 | } |
470 | 471 | ||
471 | void ImageViewer::switchToImageView() | 472 | void ImageViewer::switchToImageView() |
472 | { | 473 | { |
473 | stack->raiseWidget(imagePanel); | 474 | stack->raiseWidget(imagePanel); |
474 | 475 | ||
475 | menuBar->clear(); | 476 | menuBar->clear(); |
476 | menuBar->insertItem( tr("File"), fileMenuView ); | 477 | menuBar->insertItem( tr("File"), fileMenuView ); |
477 | menuBar->insertItem( tr("View"), viewMenuView ); | 478 | menuBar->insertItem( tr("View"), viewMenuView ); |
478 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); | 479 | viewMenuView->setItemEnabled(BLACKANDWHITE,true); |
479 | iconToolBar->show(); | 480 | iconToolBar->show(); |
480 | 481 | ||
481 | imagePanel->setPosition(0,0); | 482 | imagePanel->setPosition(0,0); |
482 | 483 | ||
483 | } | 484 | } |
484 | 485 | ||
485 | 486 | ||
486 | void ImageViewer::setDocument(const QString& fileref) | 487 | void ImageViewer::setDocument(const QString& fileref) |
487 | { | 488 | { |
488 | delayLoad = fileref; | 489 | delayLoad = fileref; |
489 | switchToImageView(); | 490 | switchToImageView(); |
490 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 491 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
491 | } | 492 | } |
492 | 493 | ||
493 | void ImageViewer::doDelayedLoad() | 494 | void ImageViewer::doDelayedLoad() |
494 | { | 495 | { |
495 | show(delayLoad); | 496 | show(delayLoad); |
496 | } | 497 | } |
497 | 498 | ||
498 | void ImageViewer::show() | 499 | void ImageViewer::show() |
499 | { | 500 | { |
500 | normalView(); | 501 | normalView(); |
501 | QMainWindow::show(); | 502 | QMainWindow::show(); |
502 | } | 503 | } |
503 | 504 | ||
504 | void ImageViewer::show(const QString& fileref) | 505 | void ImageViewer::show(const QString& fileref) |
505 | { | 506 | { |
506 | // qDebug("Show "+fileref); | 507 | // qDebug("Show "+fileref); |
507 | bFromDocView = TRUE; | 508 | bFromDocView = TRUE; |
508 | closeFileSelector(); | 509 | closeFileSelector(); |
509 | DocLnk link(fileref); | 510 | DocLnk link(fileref); |
510 | if ( link.isValid() ) { | 511 | if ( link.isValid() ) { |
511 | openFile(link); | 512 | openFile(link); |
512 | } else { | 513 | } else { |
513 | filename = fileref; | 514 | filename = fileref; |
514 | updateCaption( fileref ); | 515 | updateCaption( fileref ); |
515 | loadImage( fileref ); | 516 | loadImage( fileref ); |
516 | } | 517 | } |
517 | } | 518 | } |
518 | 519 | ||
519 | void ImageViewer::openFile() { | 520 | void ImageViewer::openFile() { |
520 | MimeTypes types; | 521 | MimeTypes types; |
521 | QStringList image; | 522 | QStringList image; |
522 | image << "image/*"; | 523 | image << "image/*"; |
523 | types.insert("Images", image); | 524 | types.insert("Images", image); |
524 | 525 | ||
525 | QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); | 526 | QString str = Opie::OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 ); |
526 | DocLnk link(str); | 527 | DocLnk link(str); |
527 | // if ( link.isValid() ) | 528 | // if ( link.isValid() ) |
528 | openFile(link); | 529 | openFile(link); |
529 | 530 | ||
530 | } | 531 | } |
531 | 532 | ||
532 | void ImageViewer::openFile( const DocLnk &link ) | 533 | void ImageViewer::openFile( const DocLnk &link ) |
533 | { | 534 | { |
534 | closeFileSelector(); | 535 | closeFileSelector(); |
535 | // DocLnk link(file); | 536 | // DocLnk link(file); |
536 | qDebug("open "+link.name()); | 537 | qDebug("open "+link.name()); |
537 | updateCaption( link.name() ); | 538 | updateCaption( link.name() ); |
538 | loadImage( link.file() ); | 539 | loadImage( link.file() ); |
539 | if (slideTimer->isActive()) { | 540 | if (slideTimer->isActive()) { |
540 | slideTimer->start(slideDelay * 1000, FALSE); | 541 | slideTimer->start(slideDelay * 1000, FALSE); |
541 | } | 542 | } |
542 | 543 | ||
543 | } | 544 | } |
544 | 545 | ||
545 | void ImageViewer::open() | 546 | void ImageViewer::open() |
546 | { | 547 | { |
547 | switchToFileSelector(); | 548 | switchToFileSelector(); |
548 | } | 549 | } |
549 | 550 | ||
550 | void ImageViewer::closeFileSelector() | 551 | void ImageViewer::closeFileSelector() |
551 | { | 552 | { |
552 | switchToImageView(); | 553 | switchToImageView(); |
553 | } | 554 | } |
554 | 555 | ||
555 | void ImageViewer::updateCaption( QString name ) | 556 | void ImageViewer::updateCaption( QString name ) |
556 | { | 557 | { |
557 | int sep = name.findRev( '/' ); | 558 | int sep = name.findRev( '/' ); |
558 | if ( sep >= 0 ) | 559 | if ( sep >= 0 ) |
559 | name = name.mid( sep+1 ); | 560 | name = name.mid( sep+1 ); |
560 | setCaption( name + tr(" - Image Viewer") ); | 561 | setCaption( name + tr(" - Image Viewer") ); |
561 | } | 562 | } |
562 | 563 | ||
563 | /* | 564 | /* |
564 | This function loads an image from a file. | 565 | This function loads an image from a file. |
565 | */ | 566 | */ |
566 | 567 | ||
567 | void ImageViewer::loadImage( const char *fileName ) | 568 | void ImageViewer::loadImage( const char *fileName ) |
568 | { | 569 | { |
569 | filename = fileName; | 570 | filename = fileName; |
570 | if ( filename ) { | 571 | if ( filename ) { |
571 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 572 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
572 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); | 573 | //imagePanel->statusLabel()->setText( tr("Loading image...") ); |
573 | qApp->processEvents(); | 574 | qApp->processEvents(); |
574 | bool ok = image.load(filename, 0); | 575 | bool ok = image.load(filename, 0); |
575 | if ( ok ) { | 576 | if ( ok ) { |
576 | ok = reconvertImage(); | 577 | ok = reconvertImage(); |
577 | updateImageInfo(filename); | 578 | updateImageInfo(filename); |
578 | } | 579 | } |
579 | if ( !ok ) { | 580 | if ( !ok ) { |
580 | pm.resize(0,0); // couldn't load image | 581 | pm.resize(0,0); // couldn't load image |
581 | update(); | 582 | update(); |
582 | } | 583 | } |
583 | QApplication::restoreOverrideCursor(); // restore original cursor | 584 | QApplication::restoreOverrideCursor(); // restore original cursor |
584 | } | 585 | } |
585 | 586 | ||
586 | // fastLoad ? ", Fast" : "", | 587 | // fastLoad ? ", Fast" : "", |
587 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); | 588 | // fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1); |
588 | 589 | ||
589 | 590 | ||
590 | // matrix.reset(); | 591 | // matrix.reset(); |
591 | rotated90 = FALSE; | 592 | rotated90 = FALSE; |
592 | 593 | ||
593 | if (rotateOnLoad) { | 594 | if (rotateOnLoad) { |
594 | rotated90 = TRUE; | 595 | rotated90 = TRUE; |
595 | rot90(); | 596 | rot90(); |
596 | // matrix.rotate( -90.0 ); | 597 | // matrix.rotate( -90.0 ); |
597 | } | 598 | } |
598 | 599 | ||
599 | switchToImageView(); | 600 | switchToImageView(); |
600 | updateImage(); | 601 | updateImage(); |
601 | 602 | ||
602 | } | 603 | } |
603 | 604 | ||
604 | bool ImageViewer::loadSelected() | 605 | bool ImageViewer::loadSelected() |
605 | { | 606 | { |
606 | bool ok = false; | 607 | bool ok = false; |
607 | if ( stack->visibleWidget() == fileSelector ) | 608 | if ( stack->visibleWidget() == fileSelector ) |
608 | { | 609 | { |
609 | const DocLnk *link = fileSelector->selected(); | 610 | const DocLnk *link = fileSelector->selected(); |
610 | if ( link ) | 611 | if ( link ) |
611 | { | 612 | { |
612 | if ( link->file() != filename ) | 613 | if ( link->file() != filename ) |
613 | { | 614 | { |
614 | updateCaption( link->name() ); | 615 | updateCaption( link->name() ); |
615 | filename = link->file(); | 616 | filename = link->file(); |
616 | qApp->processEvents(); | 617 | qApp->processEvents(); |
617 | ok = image.load(filename, 0); | 618 | ok = image.load(filename, 0); |
618 | if ( ok ) | 619 | if ( ok ) |
619 | { | 620 | { |
620 | updateImageInfo(filename); | 621 | updateImageInfo(filename); |
621 | ok = reconvertImage(); | 622 | ok = reconvertImage(); |
622 | } | 623 | } |
623 | if ( !ok ) | 624 | if ( !ok ) |
624 | pm.resize(0,0); | 625 | pm.resize(0,0); |
625 | } | 626 | } |
626 | } | 627 | } |
627 | } | 628 | } |
628 | if ( !image.isNull() ) | 629 | if ( !image.isNull() ) |
629 | { | 630 | { |
630 | ok = true; | 631 | ok = true; |
631 | closeFileSelector(); | 632 | closeFileSelector(); |
632 | } | 633 | } |
633 | 634 | ||
634 | return ok; | 635 | return ok; |
635 | } | 636 | } |
636 | 637 | ||
637 | bool ImageViewer::reconvertImage() | 638 | bool ImageViewer::reconvertImage() |
638 | { | 639 | { |
639 | bool success = FALSE; | 640 | bool success = FALSE; |
640 | 641 | ||
641 | if ( image.isNull() ) return FALSE; | 642 | if ( image.isNull() ) return FALSE; |
642 | 643 | ||
643 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 644 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
644 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) | 645 | if ( pm.convertFromImage(image /*, conversion_flags */ ) ) |
645 | { | 646 | { |
646 | pmScaled = QPixmap(); | 647 | pmScaled = QPixmap(); |
647 | scale(); | 648 | scale(); |
648 | success = TRUE; // load successful | 649 | success = TRUE; // load successful |
649 | } | 650 | } |
650 | else | 651 | else |
651 | { | 652 | { |
652 | pm.resize(0,0); // couldn't load image | 653 | pm.resize(0,0); // couldn't load image |
653 | } | 654 | } |
654 | QApplication::restoreOverrideCursor(); // restore original cursor | 655 | QApplication::restoreOverrideCursor(); // restore original cursor |
655 | 656 | ||
656 | return success; // TRUE if loaded OK | 657 | return success; // TRUE if loaded OK |
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | int ImageViewer::calcHeight() | 661 | int ImageViewer::calcHeight() |
661 | { | 662 | { |
662 | if ( !isFullScreen ) | 663 | if ( !isFullScreen ) |
663 | return imagePanel->paneHeight(); | 664 | return imagePanel->paneHeight(); |
664 | else | 665 | else |
665 | return qApp->desktop()->height(); | 666 | return qApp->desktop()->height(); |
666 | } | 667 | } |
667 | /* | 668 | /* |
668 | This functions scales the pixmap in the member variable "pm" to fit the | 669 | This functions scales the pixmap in the member variable "pm" to fit the |
669 | widget size and puts the resulting pixmap in the member variable "pmScaled". | 670 | widget size and puts the resulting pixmap in the member variable "pmScaled". |
670 | */ | 671 | */ |
671 | void ImageViewer::scale() | 672 | void ImageViewer::scale() |
672 | { | 673 | { |
673 | int h = calcHeight(); | 674 | int h = calcHeight(); |
674 | if ( image.isNull() ) return; | 675 | if ( image.isNull() ) return; |
675 | 676 | ||
676 | QApplication::setOverrideCursor( waitCursor ); // this might take time | 677 | QApplication::setOverrideCursor( waitCursor ); // this might take time |
677 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) | 678 | if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) |
678 | { // no need to scale if widget | 679 | { // no need to scale if widget |
679 | pmScaled = pm; // size equals pixmap size | 680 | pmScaled = pm; // size equals pixmap size |
680 | } | 681 | } |
681 | else | 682 | else |
682 | { | 683 | { |
683 | double hs = (double)h / (double)image.height(); | 684 | double hs = (double)h / (double)image.height(); |
684 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); | 685 | double ws = (double)imagePanel->paneWidth() / (double)image.width(); |
685 | double scaleFactor = (hs > ws) ? ws : hs; | 686 | double scaleFactor = (hs > ws) ? ws : hs; |
686 | int smoothW = (int)(scaleFactor * image.width()); | 687 | int smoothW = (int)(scaleFactor * image.width()); |
687 | int smoothH = (int)(scaleFactor * image.height()); | 688 | int smoothH = (int)(scaleFactor * image.height()); |
688 | 689 | ||
689 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); | 690 | pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); |
690 | } | 691 | } |
691 | QApplication::restoreOverrideCursor(); // restore original cursor | 692 | QApplication::restoreOverrideCursor(); // restore original cursor |
692 | } | 693 | } |
693 | 694 | ||
694 | /* | 695 | /* |
695 | The resize event handler, if a valid pixmap was loaded it will call | 696 | The resize event handler, if a valid pixmap was loaded it will call |
696 | scale() to fit the pixmap to the new widget size. | 697 | scale() to fit the pixmap to the new widget size. |
697 | */ | 698 | */ |
698 | 699 | ||
699 | void ImageViewer::resizeEvent( QResizeEvent * ) | 700 | void ImageViewer::resizeEvent( QResizeEvent * ) |
700 | { | 701 | { |
701 | 702 | ||
702 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image | 703 | if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image |
703 | return; | 704 | return; |
704 | 705 | ||
705 | int h = calcHeight(); | 706 | int h = calcHeight(); |
706 | 707 | ||
707 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) | 708 | if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) |
708 | { // if new size, | 709 | { // if new size, |
709 | scale(); // scale pmScaled to window | 710 | scale(); // scale pmScaled to window |
710 | } | 711 | } |
711 | if ( image.hasAlphaBuffer() ) | 712 | if ( image.hasAlphaBuffer() ) |
712 | erase(); | 713 | erase(); |
713 | } | 714 | } |
714 | 715 | ||
715 | 716 | ||
716 | void ImageViewer::hFlip() | 717 | void ImageViewer::hFlip() |
717 | { | 718 | { |
718 | // matrix.scale( -1.0, 1.0 ); | 719 | // matrix.scale( -1.0, 1.0 ); |
719 | 720 | ||
720 | setImage(image.mirror(TRUE,FALSE)); | 721 | setImage(image.mirror(TRUE,FALSE)); |
721 | } | 722 | } |
722 | 723 | ||
723 | void ImageViewer::vFlip() | 724 | void ImageViewer::vFlip() |
724 | { | 725 | { |
725 | // matrix.scale( 1.0, -1.0 ); | 726 | // matrix.scale( 1.0, -1.0 ); |
726 | setImage(image.mirror(FALSE,TRUE)); | 727 | setImage(image.mirror(FALSE,TRUE)); |
727 | } | 728 | } |
728 | 729 | ||
729 | void ImageViewer::rot180() | 730 | void ImageViewer::rot180() |
730 | { | 731 | { |
731 | // matrix.rotate( 180.0 ); | 732 | // matrix.rotate( 180.0 ); |
732 | setImage(image.mirror(TRUE,TRUE)); | 733 | setImage(image.mirror(TRUE,TRUE)); |
733 | } | 734 | } |
734 | 735 | ||
735 | void ImageViewer::rot90() | 736 | void ImageViewer::rot90() |
736 | { | 737 | { |
737 | QImage oldimage; | 738 | QImage oldimage; |
738 | oldimage = image.convertDepth(32); | 739 | oldimage = image.convertDepth(32); |
739 | // matrix.rotate( -90.0 ); | 740 | // matrix.rotate( -90.0 ); |
740 | setImage(rotate(oldimage,Rotate90)); | 741 | setImage(rotate(oldimage,Rotate90)); |
741 | 742 | ||
742 | } | 743 | } |
743 | void ImageViewer::rot270() | 744 | void ImageViewer::rot270() |
744 | { | 745 | { |
745 | 746 | ||
746 | QImage oldimage; | 747 | QImage oldimage; |
747 | oldimage = image.convertDepth(32); | 748 | oldimage = image.convertDepth(32); |
748 | // matrix.rotate(90.0); | 749 | // matrix.rotate(90.0); |
749 | setImage(rotate(oldimage,Rotate270)); | 750 | setImage(rotate(oldimage,Rotate270)); |
750 | 751 | ||
751 | } | 752 | } |
752 | 753 | ||
753 | void ImageViewer::blackAndWhite() | 754 | void ImageViewer::blackAndWhite() |
754 | { | 755 | { |
755 | 756 | ||
756 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); | 757 | viewMenuView->setItemEnabled(BLACKANDWHITE,false); |
757 | setImage(toGray(image,false)); | 758 | setImage(toGray(image,false)); |
758 | } | 759 | } |
759 | 760 | ||
760 | void ImageViewer::displayControlsDialog() | 761 | void ImageViewer::displayControlsDialog() |
761 | { | 762 | { |
762 | int w=80; | 763 | int w=80; |
763 | int h=w; | 764 | int h=w; |
764 | QImage small; | 765 | QImage small; |
765 | 766 | ||
766 | if ( image.width()<w ||image.height()<h ) | 767 | if ( image.width()<w ||image.height()<h ) |
767 | small=image.smoothScale(w,h); | 768 | small=image.smoothScale(w,h); |
768 | else | 769 | else |
769 | small=image.copy(0,0,w,h); | 770 | small=image.copy(0,0,w,h); |
770 | 771 | ||
771 | int newB=0; | 772 | int newB=0; |
772 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); | 773 | ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); |
773 | dlg->exec(); | 774 | dlg->exec(); |
774 | if ( newB ) { | 775 | if ( newB ) { |
775 | intensity(image,(float)newB/100); | 776 | intensity(image,(float)newB/100); |
776 | setImage(image); | 777 | setImage(image); |
777 | } | 778 | } |
778 | 779 | ||
779 | } | 780 | } |
780 | 781 | ||
781 | 782 | ||
diff --git a/noncore/multimedia/showimg/showimg.pro b/noncore/multimedia/showimg/showimg.pro index 76b020e..94fb162 100644 --- a/noncore/multimedia/showimg/showimg.pro +++ b/noncore/multimedia/showimg/showimg.pro | |||
@@ -1,9 +1,9 @@ | |||
1 | CONFIG += qt warn_on release quick-app | 1 | CONFIG += qt warn_on release quick-app |
2 | HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h | 2 | HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h |
3 | SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp | 3 | SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp |
4 | TARGET = showimg | 4 | TARGET = showimg |
5 | INCLUDEPATH += $(OPIEDIR)/include | 5 | INCLUDEPATH += $(OPIEDIR)/include |
6 | DEPENDPATH += $(OPIEDIR)/include | 6 | DEPENDPATH += $(OPIEDIR)/include |
7 | LIBS += -lqpe -lopie | 7 | LIBS += -lqpe -lopiecore2 -l opieui2 |
8 | 8 | ||
9 | include ( $(OPIEDIR)/include.pro ) | 9 | include ( $(OPIEDIR)/include.pro ) |