summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/showimg/ImageFileSelector.cpp72
-rw-r--r--noncore/multimedia/showimg/ImageFileSelector.h65
-rw-r--r--noncore/multimedia/showimg/settingsdialog.cpp88
-rw-r--r--noncore/multimedia/showimg/settingsdialog.h49
-rw-r--r--noncore/multimedia/showimg/settingsdialogbase.cpp106
-rw-r--r--noncore/multimedia/showimg/settingsdialogbase.h45
-rw-r--r--noncore/multimedia/showimg/showimg.cpp279
-rw-r--r--noncore/multimedia/showimg/showimg.h104
-rw-r--r--noncore/multimedia/showimg/showimg.pro34
9 files changed, 658 insertions, 184 deletions
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp
index 347300f..7872c09 100644
--- a/noncore/multimedia/showimg/ImageFileSelector.cpp
+++ b/noncore/multimedia/showimg/ImageFileSelector.cpp
@@ -1,277 +1,271 @@
1 1
2 2
3#include "qpe/global.h" 3#include "qpe/global.h"
4#include "qpe/applnk.h" 4#include "qpe/applnk.h"
5#include "qpe/lnkproperties.h" 5#include "qpe/lnkproperties.h"
6#include "qpe/applnk.h" 6#include "qpe/applnk.h"
7#include "qpe/qpeapplication.h" 7#include "qpe/qpeapplication.h"
8 8
9#include <stdlib.h> 9#include <stdlib.h>
10 10
11#include <qdir.h> 11#include <qdir.h>
12#include <qwidget.h> 12#include <qwidget.h>
13#include <qheader.h> 13#include <qheader.h>
14#include <qimage.h> 14#include <qimage.h>
15#include <qpixmap.h> 15#include <qpixmap.h>
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qfileinfo.h> 17#include <qfileinfo.h>
18#include <qpainter.h> 18#include <qpainter.h>
19#include <qscrollview.h> 19#include <qscrollview.h>
20 20
21#include "ImageFileSelector.h" 21#include "ImageFileSelector.h"
22 22
23 23
24 24ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w)
25 25 : QWidget( parent ),fl(f)
26
27ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) : QWidget( parent ),fl(f)
28{ 26{
29 setBackgroundMode(NoBackground); 27 setBackgroundMode(NoBackground);
30 if ( w!=-1 ) 28 if ( w!=-1 )
31 setMinimumSize(w,p.height()+24); 29 setMinimumSize(w,p.height()+24);
32 else 30 else
33 setMinimumSize(p.width(),p.height()+24); 31 setMinimumSize(p.width(),p.height()+24);
34 description=new QLabel(text,this); 32 description=new QLabel(text,this);
35 description->setBackgroundColor(colorGroup().base()); 33 description->setBackgroundColor(colorGroup().base());
36 description->setAlignment(AlignCenter); 34 description->setAlignment(AlignCenter);
37 description->setGeometry(0,height()-24,width(),24); 35 description->setGeometry(0,height()-24,width(),24);
38 pixmap=p; 36 pixmap=p;
39} 37}
40 38
41void ThumbWidget::resizeEvent(QResizeEvent *e) 39void ThumbWidget::resizeEvent(QResizeEvent *)
42{ 40{
43 description->setGeometry(0,height()-24,width(),24); 41 description->setGeometry(0,height()-24,width(),24);
44} 42}
45 43
46void ThumbWidget::paintEvent( QPaintEvent *e ) 44void ThumbWidget::paintEvent( QPaintEvent *e )
47{ 45{
48 QPainter painter(this); 46 QPainter painter(this);
49 47
50 painter.setClipRect(e->rect()); 48 painter.setClipRect(e->rect());
51 painter.fillRect(0,0,width(),height(),QColor(255,255,255)); 49 painter.fillRect(0,0,width(),height(),QColor(255,255,255));
52 painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); 50 painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap);
53 51
54} 52}
55 53
56void ThumbWidget::mouseReleaseEvent(QMouseEvent* event) 54void ThumbWidget::mouseReleaseEvent(QMouseEvent* )
57{ 55{
58 emit clicked(fl); 56 emit clicked(fl);
59} 57}
60 58
61 59
62 60
63 61ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f)
64ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f): QListViewItem( parent ), fl( f ) 62 : QListViewItem( parent ), fl( f )
65{ 63{
66 setText( 0, f.name() ); 64 setText( 0, f.name() );
67 QFileInfo fi(f.file()); 65 QFileInfo fi(f.file());
68 setText( 1, (fi.extension()).upper() ); 66 setText( 1, (fi.extension()).upper() );
69 setPixmap( 0, f.pixmap() ); 67 setPixmap( 0, f.pixmap() );
70 68
71 69
72} 70}
73 71
74 72
75ImageFileSelectorItem::~ImageFileSelectorItem() 73ImageFileSelectorItem::~ImageFileSelectorItem()
76{ 74{
77 75
78} 76}
79 77
80 78
81ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char *name ):QWidgetStack(parent) 79ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * )
80 : QWidgetStack(parent)
82{ 81{
83 82
84 detailed=new QListView(this); 83 detailed=new QListView(this);
85 84
86 detailed->addColumn (tr("Title")); 85 detailed->addColumn (tr("Title"));
87 detailed->addColumn (tr("Type")); 86 detailed->addColumn (tr("Type"));
88 detailed->setAllColumnsShowFocus( true ); 87 detailed->setAllColumnsShowFocus( true );
89 88
90 tList.setAutoDelete(true); 89 tList.setAutoDelete(true);
91 90
92 thumb =new QScrollView(this); 91 thumb =new QScrollView(this);
93 thumb->setVScrollBarMode (QScrollView::Auto ); 92 thumb->setVScrollBarMode (QScrollView::Auto );
94 thumb->viewport()->setBackgroundColor(colorGroup().base()); 93 thumb->viewport()->setBackgroundColor(colorGroup().base());
95 94
96 background=new QWidget(0); 95 background=new QWidget(0);
97 background->setBackgroundColor(colorGroup().base()); 96 background->setBackgroundColor(colorGroup().base());
98 thumb->addChild(background); 97 thumb->addChild(background);
99 gl = new QGridLayout(background,1,2,4,4); 98 gl = new QGridLayout(background,1,2,4,4);
100 99
101 100
102 101
103 connect( detailed, SIGNAL( mouseButtonClicked( int, QListViewItem *, const QPoint &, int ) ), 102 connect( detailed, SIGNAL( mouseButtonClicked( int, QListViewItem *, const QPoint &, int ) ),
104 this, SLOT( fileClicked( int, QListViewItem *, const QPoint &, int ) ) ); 103 this, SLOT( fileClicked( int, QListViewItem *, const QPoint &, int ) ) );
105 connect( detailed, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint &, int ) ), 104 connect( detailed, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint &, int ) ),
106 this, SLOT( filePressed( int, QListViewItem *, const QPoint &, int ) ) ); 105 this, SLOT( filePressed( int, QListViewItem *, const QPoint &, int ) ) );
107 connect( detailed, SIGNAL( returnPressed( QListViewItem * ) ), 106 connect( detailed, SIGNAL( returnPressed( QListViewItem * ) ),
108 this, SLOT( fileClicked( QListViewItem * ) ) ); 107 this, SLOT( fileClicked( QListViewItem * ) ) );
109 108
110 cView=UNKNOWN; 109 cView=UNKNOWN;
111 setView(scv); 110 setView(scv);
112 reread(); 111 reread();
113 112
114} 113}
115ImageFileSelector::~ImageFileSelector() 114ImageFileSelector::~ImageFileSelector()
116{ 115{
117 116
118} 117}
119 118
120 119
121void ImageFileSelector::switchView() 120void ImageFileSelector::switchView()
122{ 121{
123 CURRENT_VIEW v=cView; 122 CURRENT_VIEW v=cView;
124 123
125 if ( v==DETAILED ) 124 if ( v==DETAILED )
126 v=THUMBNAIL; 125 v=THUMBNAIL;
127 else 126 else
128 v=DETAILED; 127 v=DETAILED;
129 setView(v); 128 setView(v);
130} 129}
131 130
132void ImageFileSelector::setView(CURRENT_VIEW v) 131void ImageFileSelector::setView(CURRENT_VIEW v)
133{ 132{
134 133
135 if ( v==cView ) 134 if ( v==cView )
136 return; 135 return;
137 cView=v; 136 cView=v;
138 137
139 if ( cView!=DETAILED ) 138 if ( cView!=DETAILED )
140 { 139 {
141 raiseWidget(thumb); 140 raiseWidget(thumb);
142 updateSizes(); 141 updateSizes();
143 } 142 }
144 else 143 else
145 { 144 {
146 raiseWidget(detailed); 145 raiseWidget(detailed);
147 updateSizes(); 146 updateSizes();
148 } 147 }
149 148
150 149
151} 150}
152 151
153void ImageFileSelector::resizeEvent(QResizeEvent *) 152void ImageFileSelector::resizeEvent(QResizeEvent *)
154{ 153{
155 updateSizes(); 154 updateSizes();
156} 155}
157 156
158void ImageFileSelector::updateSizes() 157void ImageFileSelector::updateSizes()
159{ 158{
160 int ww=(detailed->width()-detailed->frameWidth()*2); 159 int ww=(detailed->width()-detailed->frameWidth()*2);
161 double w=(double)ww*0.70; 160 double w=(double)ww*0.70;
162 detailed->setColumnWidth(0,(int)w); 161 detailed->setColumnWidth(0,(int)w);
163 detailed->setColumnWidth(1,ww-(int)w); 162 detailed->setColumnWidth(1,ww-(int)w);
164 background->setMinimumWidth(thumb->visibleWidth()); 163 background->setMinimumWidth(thumb->visibleWidth());
165 thumb->updateScrollBars(); 164 thumb->updateScrollBars();
166} 165}
167 166
168void ImageFileSelector::reread(bool purgeCache) 167void ImageFileSelector::reread(bool)
169{ 168{
169// qDebug("reread");
170 ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem(); 170 ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem();
171 QString oldFile; 171 QString oldFile;
172 if ( item ) 172 if ( item )
173 oldFile = item->file().file(); 173 oldFile = item->file().file();
174 detailed->clear(); 174 detailed->clear();
175 tList.clear(); 175 tList.clear();
176 DocLnkSet files; 176 DocLnkSet files;
177 Global::findDocuments(&files, "image/*"); 177 Global::findDocuments(&files, "image/*");
178 count = files.children().count(); 178 count = files.children().count();
179 QListIterator<DocLnk> dit( files.children() ); 179 QListIterator<DocLnk> dit( files.children() );
180 int y=0; 180// int y=0;
181 int x=4; 181// int x=4;
182 int totalHeight=4; 182// int totalHeight=4;
183 ThumbWidget *l=0; 183 ThumbWidget *l=0;
184 int width=80; 184 int width=80;
185 gl->expand(dit.count()/2,2); 185 gl->expand(dit.count()/2,2);
186
187 int i,j; 186 int i,j;
188
189 i=j=0; 187 i=j=0;
190
191 detailed->setUpdatesEnabled(false); 188 detailed->setUpdatesEnabled(false);
192 thumb->setUpdatesEnabled(false); 189 thumb->setUpdatesEnabled(false);
193 for ( ; dit.current(); ++dit ) 190
194 { 191 for ( ; dit.current(); ++dit ) {
195 item = new ImageFileSelectorItem( detailed, **dit ); 192 item = new ImageFileSelectorItem( detailed, **dit );
196 if ( item->file().file() == oldFile ) 193 if ( item->file().file() == oldFile )
197 detailed->setCurrentItem( item ); 194 detailed->setCurrentItem( item );
198 } 195 }
199 196
200 QListViewItemIterator it( detailed ); 197 QListViewItemIterator it( detailed );
201 ImageFileSelectorItem *ii; 198 ImageFileSelectorItem *ii;
202 // iterate through all items of the listview 199 // iterate through all items of the listview
203 for ( ; it.current(); ++it ) 200 for ( ; it.current(); ++it ) {
204 {
205 ii=(ImageFileSelectorItem *)it.current(); 201 ii=(ImageFileSelectorItem *)it.current();
206 QImage img(ii->file().file()); 202 QImage img( ii->file().file() );
207 img=img.smoothScale(64,64); 203 if( !img.isNull()) {
208 QPixmap pix; 204 img=img.smoothScale(64,64);
209 pix.convertFromImage(img); 205 QPixmap pix;
210 l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); 206 pix.convertFromImage(img);
211 l->setBackgroundColor(colorGroup().base()); 207 l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width);
212 gl->addWidget(l,j,i); 208 l->setBackgroundColor(colorGroup().base());
213 i++; 209 gl->addWidget(l,j,i);
214 if ( i==2 ) 210 i++;
215 { 211 if ( i==2 ) {
216 i=0; 212 i=0;
217 j++; 213 j++;
214 }
215 tList.append(l);
216 connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &)));
218 } 217 }
219 tList.append(l);
220 connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &)));
221
222 } 218 }
223 219
224
225
226 if ( !detailed->selectedItem() ) 220 if ( !detailed->selectedItem() )
227 detailed->setCurrentItem( detailed->firstChild() ); 221 detailed->setCurrentItem( detailed->firstChild() );
228 222
229 detailed->setUpdatesEnabled(true); 223 detailed->setUpdatesEnabled(true);
230 thumb->setUpdatesEnabled(true); 224 thumb->setUpdatesEnabled(true);
231 detailed->update(); 225 detailed->update();
232 thumb->update(); 226 thumb->update();
233
234} 227}
235 228
236int ImageFileSelector::fileCount() 229int ImageFileSelector::fileCount()
237{ 230{
238 return count; 231 return count;
239} 232}
240const DocLnk * ImageFileSelector::selected() 233const DocLnk * ImageFileSelector::selected()
241{ 234{
235 qDebug("image selected");
242 ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); 236 ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem();
243 if ( item ) 237 if ( item )
244 return new DocLnk( item->file() ); 238 return new DocLnk( item->file() );
245 return 0; 239 return 0;
246} 240}
247 241
248 242
249 243
250void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) 244void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int )
251{ 245{
252 if ( !i ) 246 if ( !i )
253 return; 247 return;
254 if ( button == Qt::LeftButton ) 248 if ( button == Qt::LeftButton )
255 { 249 {
256 fileClicked( i ); 250 fileClicked( i );
257 } 251 }
258} 252}
259 // pressed to get 'right down' 253 // pressed to get 'right down'
260void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) 254void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int )
261{ 255{
262 256
263} 257}
264void ImageFileSelector::fileClicked( QListViewItem *i) 258void ImageFileSelector::fileClicked( QListViewItem *i)
265{ 259{
266 if ( !i ) 260 if ( !i )
267 return; 261 return;
268 emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); 262 emit fileSelected( ( (ImageFileSelectorItem*)i )->file() );
269 emit closeMe(); 263 emit closeMe();
270} 264}
271 265
272void ImageFileSelector::thumbClicked(const DocLnk &f) 266void ImageFileSelector::thumbClicked(const DocLnk &f)
273{ 267{
274 emit fileSelected( f ); 268 emit fileSelected( f );
275 emit closeMe(); 269 emit closeMe();
276} 270}
277 271
diff --git a/noncore/multimedia/showimg/ImageFileSelector.h b/noncore/multimedia/showimg/ImageFileSelector.h
index 2c346c4..798ebcc 100644
--- a/noncore/multimedia/showimg/ImageFileSelector.h
+++ b/noncore/multimedia/showimg/ImageFileSelector.h
@@ -1,135 +1,134 @@
1#ifndef IMAGEFILE_SELECTOR_H 1#ifndef IMAGEFILE_SELECTOR_H
2#define IMAGEFILE_SELECTOR_H 2#define IMAGEFILE_SELECTOR_H
3 3
4 4
5#include <qtoolbutton.h> 5#include <qtoolbutton.h>
6#include <qlistview.h> 6#include <qlistview.h>
7#include <qwidgetstack.h> 7#include <qwidgetstack.h>
8#include <qlayout.h> 8#include <qlayout.h>
9 9
10#include "qpe/filemanager.h" 10#include "qpe/filemanager.h"
11#include "qpe/applnk.h" 11#include "qpe/applnk.h"
12 12
13class QScrollView; 13class QScrollView;
14class QLabel; 14class QLabel;
15//class QValueList;
15 16
16class ThumbWidget : public QWidget 17class ThumbWidget : public QWidget
17{ 18{
18 Q_OBJECT 19 Q_OBJECT
19 public: 20public:
20 ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent=0,int width=-1); 21 ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent=0,int width=-1);
21 ~ThumbWidget() 22 ~ThumbWidget() { }
22 {
23
24 }
25 23
26 DocLnk file() const 24 DocLnk file() const {
27 {
28 return fl; 25 return fl;
29 } 26 }
30 27
31 28
32 signals: 29 signals:
33 void clicked(const DocLnk &); 30 void clicked(const DocLnk &);
34 31
35protected: 32protected:
36 void paintEvent( QPaintEvent * ); 33 void paintEvent( QPaintEvent * );
37 void resizeEvent(QResizeEvent *); 34 void resizeEvent(QResizeEvent *);
38 35
39 void mouseReleaseEvent(QMouseEvent* event); 36 void mouseReleaseEvent(QMouseEvent* event);
40 37
41private: 38private:
42 QPixmap pixmap; 39 QPixmap pixmap;
43 QLabel *description; 40 QLabel *description;
44 DocLnk fl; 41 DocLnk fl;
45}; 42};
46 43
47 44
45
46
47class ImageFileSelectorItem : public QListViewItem
48{
49public:
50 ImageFileSelectorItem( QListView *parent, const DocLnk& f );
51 ~ImageFileSelectorItem();
52
53 DocLnk file() const {
54 return fl;
55 }
56private:
57 DocLnk fl;
58};
59
48class ImageFileSelector : public QWidgetStack 60class ImageFileSelector : public QWidgetStack
49{ 61{
50 Q_OBJECT 62 Q_OBJECT
51 63
52 public: 64public:
53 65
54 enum CURRENT_VIEW 66 enum CURRENT_VIEW {
55 {
56 THUMBNAIL, 67 THUMBNAIL,
57 DETAILED, 68 DETAILED,
58 UNKNOWN 69 UNKNOWN
59 }; 70 };
60 71
61 72
62 ImageFileSelector(CURRENT_VIEW scv=DETAILED, QWidget *parent=0, const char *name=0 ); 73 ImageFileSelector(CURRENT_VIEW scv=DETAILED, QWidget *parent=0, const char *name=0 );
63 ~ImageFileSelector(); 74 ~ImageFileSelector();
64 75
65 void reread(bool purgeCache=false); 76 void reread(bool purgeCache=false);
66 int fileCount(); 77 int fileCount();
67 const DocLnk *selected(); 78 const DocLnk *selected();
68 79
69 void setView(CURRENT_VIEW v); 80 void setView(CURRENT_VIEW v);
70 81
71 CURRENT_VIEW view() 82 CURRENT_VIEW view() {
72 {
73 return cView; 83 return cView;
74 } 84 }
75 85
86 QValueList<DocLnk> fileList() const {
87 ((ImageFileSelector*)this)->fileCount(); // ensure all loaded when this is extended
88 QValueList<DocLnk> list;
89 ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->firstChild();
90 while (item) {
91 list.append(item->file());
92 item = (ImageFileSelectorItem *)item->nextSibling();
93 }
94 return list;
95 }
76 96
77public slots: 97public slots:
78 98
79 void switchView(); 99 void switchView();
80 100
81signals: 101signals:
82 void fileSelected( const DocLnk & ); 102 void fileSelected( const DocLnk & );
83 void closeMe(); 103 void closeMe();
84 104
85protected: 105protected:
86 106
87 void resizeEvent(QResizeEvent *); 107 void resizeEvent(QResizeEvent *);
88 108
89 109
90private slots: 110private slots:
91 void fileClicked( int, QListViewItem *, const QPoint &, int ); 111 void fileClicked( int, QListViewItem *, const QPoint &, int );
92 // pressed to get 'right down' 112 // pressed to get 'right down'
93 void filePressed( int, QListViewItem *, const QPoint &, int ); 113 void filePressed( int, QListViewItem *, const QPoint &, int );
94 void fileClicked( QListViewItem *); 114 void fileClicked( QListViewItem *);
95 void thumbClicked(const DocLnk &); 115 void thumbClicked(const DocLnk &);
96 116
97private: 117private:
98 118
99 void updateSizes(); 119 void updateSizes();
100 120
101 121
102 CURRENT_VIEW cView; 122 CURRENT_VIEW cView;
103 int count; 123 int count;
104 124
105 QListView *detailed; 125 QListView *detailed;
106 QScrollView *thumb; 126 QScrollView *thumb;
107 QList<ThumbWidget> tList; 127 QList<ThumbWidget> tList;
108 QWidget *background; 128 QWidget *background;
109 QGridLayout *gl; 129 QGridLayout *gl;
110 130
111}; 131};
112
113
114class ImageFileSelectorItem : public QListViewItem
115{
116public:
117 ImageFileSelectorItem( QListView *parent, const DocLnk& f );
118 ~ImageFileSelectorItem();
119
120 DocLnk file() const
121 {
122 return fl;
123 }
124
125
126private:
127 DocLnk fl;
128};
129
130
131
132
133#endif // IMAGEFILE_SELECTOR_H 132#endif // IMAGEFILE_SELECTOR_H
134 133
135 134
diff --git a/noncore/multimedia/showimg/settingsdialog.cpp b/noncore/multimedia/showimg/settingsdialog.cpp
new file mode 100644
index 0000000..55d555a
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialog.cpp
@@ -0,0 +1,88 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "settingsdialog.h"
22#include <qslider.h>
23#include <qlabel.h>
24#include <qcheckbox.h>
25#include <qradiobutton.h>
26#include <qbuttongroup.h>
27
28SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f )
29 : SettingsDialogBase( parent, name, modal, f )
30{
31 connect( delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delayChanged(int)) );
32}
33
34void SettingsDialog::setDelay( int d )
35{
36 delaySlider->setValue( d );
37 delayChanged( d );
38}
39
40int SettingsDialog::delay() const
41{
42 return delaySlider->value();
43}
44
45void SettingsDialog::setRepeat( bool r )
46{
47 repeatCheck->setChecked( r );
48}
49
50bool SettingsDialog::repeat() const
51{
52 return repeatCheck->isChecked();
53}
54
55void SettingsDialog::delayChanged( int d )
56{
57 delayText->setText( QString::number( d ) + " s" );
58}
59
60void SettingsDialog::setReverse(bool r)
61{
62 reverseCheck->setChecked(r);
63}
64
65bool SettingsDialog::reverse() const
66{
67 return reverseCheck->isChecked();
68}
69
70void SettingsDialog::setRotate(bool r)
71{
72 rotateCheck->setChecked(r);
73}
74
75bool SettingsDialog::rotate() const
76{
77 return rotateCheck->isChecked();
78}
79
80void SettingsDialog::setFastLoad(bool f)
81{
82 fastLoadCheck->setChecked(f);
83}
84
85bool SettingsDialog::fastLoad() const
86{
87 return fastLoadCheck->isChecked();
88}
diff --git a/noncore/multimedia/showimg/settingsdialog.h b/noncore/multimedia/showimg/settingsdialog.h
new file mode 100644
index 0000000..0f47990
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialog.h
@@ -0,0 +1,49 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#ifndef SETTINGSDIALOG_H
22#define SETTINGSDIALOG_H
23
24#include "settingsdialogbase.h"
25
26class SettingsDialog : public SettingsDialogBase
27{
28 Q_OBJECT
29public:
30
31 SettingsDialog( QWidget * parent=0, const char * name=0, bool modal=FALSE, WFlags f=0 );
32
33 void setDelay( int d );
34 int delay() const;
35 void setRepeat( bool r );
36 bool repeat() const;
37 void setReverse( bool r );
38 bool reverse() const;
39 void setRotate(bool r);
40 bool rotate() const;
41 void setFastLoad(bool f);
42 bool fastLoad() const;
43
44private slots:
45 void delayChanged( int );
46};
47
48
49#endif
diff --git a/noncore/multimedia/showimg/settingsdialogbase.cpp b/noncore/multimedia/showimg/settingsdialogbase.cpp
new file mode 100644
index 0000000..e0c5bb0
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialogbase.cpp
@@ -0,0 +1,106 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'settingsdialogbase.ui'
3**
4** Created: Sun Nov 3 07:29:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "settingsdialogbase.h"
10
11#include <qcheckbox.h>
12#include <qgroupbox.h>
13#include <qlabel.h>
14#include <qpushbutton.h>
15#include <qslider.h>
16#include <qlayout.h>
17#include <qvariant.h>
18#include <qtooltip.h>
19#include <qwhatsthis.h>
20
21/*
22 * Constructs a SettingsDialogBase which is a child of 'parent', with the
23 * name 'name' and widget flags set to 'f'
24 *
25 * The dialog will by default be modeless, unless you set 'modal' to
26 * TRUE to construct a modal dialog.
27 */
28SettingsDialogBase::SettingsDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl )
29 : QDialog( parent, name, modal, fl )
30{
31 if ( !name )
32 setName( "SettingsDialogBase" );
33 resize( 246, 201 );
34 setCaption( tr( "Preferences" ) );
35 SettingsDialogBaseLayout = new QVBoxLayout( this );
36 SettingsDialogBaseLayout->setSpacing( 6 );
37 SettingsDialogBaseLayout->setMargin( 6 );
38
39 GroupBox1 = new QGroupBox( this, "GroupBox1" );
40 GroupBox1->setTitle( tr( "Slide Show" ) );
41 GroupBox1->setColumnLayout(0, Qt::Vertical );
42 GroupBox1->layout()->setSpacing( 0 );
43 GroupBox1->layout()->setMargin( 0 );
44 GroupBox1Layout = new QVBoxLayout( GroupBox1->layout() );
45 GroupBox1Layout->setAlignment( Qt::AlignTop );
46 GroupBox1Layout->setSpacing( 6 );
47 GroupBox1Layout->setMargin( 11 );
48
49 Layout3 = new QGridLayout;
50 Layout3->setSpacing( 6 );
51 Layout3->setMargin( 0 );
52
53 TextLabel1 = new QLabel( GroupBox1, "TextLabel1" );
54 TextLabel1->setText( tr( "Delay between pictures" ) );
55
56 Layout3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
57
58 delaySlider = new QSlider( GroupBox1, "delaySlider" );
59 delaySlider->setMinValue( 2 );
60 delaySlider->setMaxValue( 60 );
61 delaySlider->setLineStep( 2 );
62 delaySlider->setOrientation( QSlider::Horizontal );
63 delaySlider->setTickmarks( QSlider::Right );
64 delaySlider->setTickInterval( 10);
65
66 Layout3->addWidget( delaySlider, 1, 0 );
67
68 delayText = new QLabel( GroupBox1, "delayText" );
69 delayText->setMinimumSize( QSize( 25, 0 ) );
70 delayText->setText( tr( "s" ) );
71 delayText->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
72
73 Layout3->addWidget( delayText, 1, 1 );
74 GroupBox1Layout->addLayout( Layout3 );
75
76 repeatCheck = new QCheckBox( GroupBox1, "repeatCheck" );
77 repeatCheck->setText( tr( "Repeat slideshow" ) );
78 GroupBox1Layout->addWidget( repeatCheck );
79
80 reverseCheck = new QCheckBox( GroupBox1, "reverseCheck" );
81 reverseCheck->setText( tr( "Show pictures in reverse" ) );
82 GroupBox1Layout->addWidget( reverseCheck );
83 SettingsDialogBaseLayout->addWidget( GroupBox1 );
84
85 rotateCheck = new QCheckBox( this, "rotateCheck" );
86 rotateCheck->setText( tr( "Load pictures rotated 90 degrees" ) );
87 SettingsDialogBaseLayout->addWidget( rotateCheck );
88
89 fastLoadCheck = new QCheckBox( this, "fastLoadCheck" );
90 fastLoadCheck->setText( tr( "Fast load pictures" ) );
91 SettingsDialogBaseLayout->addWidget( fastLoadCheck );
92 fastLoadCheck->hide(); //FIXME
93// QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
94// layout->addItem( spacer, 10, 0 );
95
96
97}
98
99/*
100 * Destroys the object and frees any allocated resources
101 */
102SettingsDialogBase::~SettingsDialogBase()
103{
104 // no need to delete child widgets, Qt does it all for us
105}
106
diff --git a/noncore/multimedia/showimg/settingsdialogbase.h b/noncore/multimedia/showimg/settingsdialogbase.h
new file mode 100644
index 0000000..9594ec6
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialogbase.h
@@ -0,0 +1,45 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'settingsdialogbase.ui'
3**
4** Created: Sun Nov 3 07:29:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef SETTINGSDIALOGBASE_H
10#define SETTINGSDIALOGBASE_H
11
12#include <qvariant.h>
13#include <qdialog.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QCheckBox;
18class QGroupBox;
19class QLabel;
20class QSlider;
21
22class SettingsDialogBase : public QDialog
23{
24 Q_OBJECT
25
26public:
27 SettingsDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
28 ~SettingsDialogBase();
29
30 QGroupBox* GroupBox1;
31 QLabel* TextLabel1;
32 QSlider* delaySlider;
33 QLabel* delayText;
34 QCheckBox* repeatCheck;
35 QCheckBox* reverseCheck;
36 QCheckBox* rotateCheck;
37 QCheckBox* fastLoadCheck;
38
39protected:
40 QVBoxLayout* SettingsDialogBaseLayout;
41 QVBoxLayout* GroupBox1Layout;
42 QGridLayout* Layout3;
43};
44
45#endif // SETTINGSDIALOGBASE_H
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp
index d7d53ec..0fbffe7 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -1,550 +1,657 @@
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"
28
27 29
30#include <opie/ofiledialog.h>
31
32#include <qpe/qpeapplication.h>
28#include <qpe/config.h> 33#include <qpe/config.h>
29#include <qpe/resource.h> 34#include <qpe/resource.h>
30#include <qpe/fileselector.h> 35#include <qpe/fileselector.h>
31#include <qpe/applnk.h> 36#include <qpe/applnk.h>
32#include <qfileinfo.h> 37#include <qfileinfo.h>
33#include <math.h> 38#include <math.h>
34#include <qpe/qpemenubar.h> 39#include <qpe/qpemenubar.h>
35#include <qwidgetstack.h> 40#include <qwidgetstack.h>
36#include <qpe/qpetoolbar.h> 41#include <qpe/qpetoolbar.h>
37#include <qaction.h> 42#include <qaction.h>
38#include <qfiledialog.h> 43#include <qfiledialog.h>
39#include <qmessagebox.h> 44#include <qmessagebox.h>
40#include <qpopupmenu.h> 45#include <qpopupmenu.h>
41#include <qscrollview.h> 46#include <qscrollview.h>
42#include <qlabel.h> 47#include <qlabel.h>
43#include <qpainter.h> 48#include <qpainter.h>
44#include <qkeycode.h> 49#include <qkeycode.h>
45#include <qapplication.h> 50#include <qapplication.h>
46#include <qclipboard.h> 51#include <qclipboard.h>
47#include <qtimer.h> 52#include <qtimer.h>
48#include <qspinbox.h> 53#include <qspinbox.h>
49 54
50 55
51 56
52ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent):QDialog(parent,0,true) 57ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent)
58 : QDialog(parent,0,true)
53{ 59{
54 setCaption(caption); 60 setCaption(caption);
55 61
56 if ( parent ) 62 if ( parent ) {
57 {
58 setPalette(parent->palette()); 63 setPalette(parent->palette());
59 } 64 }
60 65
61 b=brightness; 66 b=brightness;
62 img=image; 67 img=image;
63 68
64 setMinimumSize(140,80); 69 setMinimumSize(140,80);
65 70
66 QGridLayout *gl= new QGridLayout(this,2,2,4,4); 71 QGridLayout *gl= new QGridLayout(this,2,2,4,4);
67 72
68 pixmap =new ImageWidget(this);; 73 pixmap =new ImageWidget(this);;
69 QPixmap pm; 74 QPixmap pm;
70 pm.convertFromImage(img); 75 pm.convertFromImage(img);
71 pixmap->setPixmap(pm); 76 pixmap->setPixmap(pm);
72 pixmap->setMinimumSize(pm.width(),pm.height()); 77 pixmap->setMinimumSize(pm.width(),pm.height());
73 gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter); 78 gl->addMultiCellWidget(pixmap,0,0,0,2,AlignCenter);
74 QLabel *l=new QLabel(tr("Brightness")+":",this); 79 QLabel *l=new QLabel(tr("Brightness")+":",this);
75 gl->addWidget(l,1,0,AlignLeft); 80 gl->addWidget(l,1,0,AlignLeft);
76 spb=new QSpinBox(-100,100,2,this); 81 spb=new QSpinBox(-100,100,2,this);
77 gl->addWidget(spb,1,1,AlignRight); 82 gl->addWidget(spb,1,1,AlignRight);
78 83
79 spb->setValue(0); 84 spb->setValue(0);
80 85
81 connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int))); 86 connect(spb,SIGNAL(valueChanged(int)),this, SLOT(bValueChanged(int)));
82 87
83} 88}
84 89
85void ControlsDialog::bValueChanged(int value) 90void ControlsDialog::bValueChanged(int value)
86{ 91{
87 QImage nImage=img; 92 QImage nImage=img;
88 nImage.detach(); 93 nImage.detach();
89 ImageViewer::intensity(nImage, (float)value/100); 94 ImageViewer::intensity(nImage, (float)value/100);
90 QPixmap pm; 95 QPixmap pm;
91 pm.convertFromImage(nImage); 96 pm.convertFromImage(nImage);
92 pixmap->setPixmap(pm); 97 pixmap->setPixmap(pm);
93 pixmap->repaint(false); 98 pixmap->repaint(false);
94 99
95 100
96} 101}
97 102
98void ControlsDialog::accept() 103void ControlsDialog::accept()
99{ 104{
100 *b=spb->value(); 105 *b=spb->value();
101 done(1); 106 done(1);
102} 107}
103 108
109//===========================================================================
104 110
105 111InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent)
106InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent):QDialog(parent,0,true) 112 : QDialog(parent,0,true)
107{ 113{
108 setCaption(caption); 114 setCaption(caption);
109 115
110 if ( parent ) 116 if ( parent )
111 { 117 {
112 setPalette(parent->palette()); 118 setPalette(parent->palette());
113 } 119 }
114 120
115 const char *labels[]={"File Name","Format","File Size","Size","Colors","Alpha"}; 121 const char *labels[]={"File Name","Format","File Size","Size","Colors","Alpha"};
116 122
117 setMinimumSize(180,80); 123 setMinimumSize(180,80);
118 int num=ImageViewer::LAST+1; 124 int num=ImageViewer::LAST+1;
119 if ( text[ImageViewer::ALPHA].isEmpty() ) 125 if ( text[ImageViewer::ALPHA].isEmpty() )
120 num--; 126 num--;
121 QGridLayout *gl= new QGridLayout(this,num,2,4,2); 127 QGridLayout *gl= new QGridLayout(this,num,2,4,2);
122 QLabel *l; 128 QLabel *l;
123 int count=0; 129 int count=0;
124 for ( int i=0;i<num;i++ ) 130 for ( int i=0;i<num;i++ )
125 { 131 {
126 if ( i==1 ) 132 if ( i==1 )
127 { 133 {
128 QFrame *frm=new QFrame(this); 134 QFrame *frm=new QFrame(this);
129 frm->setFrameStyle(QFrame::HLine|QFrame::Sunken); 135 frm->setFrameStyle(QFrame::HLine|QFrame::Sunken);
130 gl->addMultiCellWidget(frm,i,i,0,1); 136 gl->addMultiCellWidget(frm,i,i,0,1);
131 } 137 }
132 else 138 else
133 { 139 {
134 l=new QLabel(tr(labels[count])+":",this); 140 l=new QLabel(tr(labels[count])+":",this);
135 gl->addWidget(l,i,0,AlignLeft); 141 gl->addWidget(l,i,0,AlignLeft);
136 l=new QLabel(text[count],this); 142 l=new QLabel(text[count],this);
137 gl->addWidget(l,i,1,AlignRight); 143 gl->addWidget(l,i,1,AlignRight);
138 count++; 144 count++;
139 } 145 }
140 146
141 } 147 }
142 148
143} 149}
144 150
145void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent) 151void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent)
146{ 152{
147 InfoDialog *dlg=new InfoDialog(caption,text,parent); 153 InfoDialog *dlg=new InfoDialog(caption,text,parent);
148 dlg->exec(); 154 dlg->exec();
149 delete dlg; 155 delete dlg;
150} 156}
151 157
158//===========================================================================
159
152 160
153ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) 161ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
154{ 162{
155 vb = new QVBoxLayout( this ); 163 vb = new QVBoxLayout( this );
156 164
157 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity); 165 image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity);
158 pic=new ImageWidget(image); 166 pic=new ImageWidget(image);
159 image->addChild(pic); 167 image->addChild(pic);
160 168
161 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() )); 169 connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() ));
162 170
163 vb->addWidget( image ); 171 vb->addWidget( image );
164 172
165} 173}
166 174
167void ImagePane::setPixmap( const QPixmap &pm ) 175void ImagePane::setPixmap( const QPixmap &pm )
168{ 176{
169 pic->setPixmap( pm ); 177 pic->setPixmap( pm );
170 pic->resize(pm.width(),pm.height()); 178 pic->resize(pm.width(),pm.height());
171 image->updateScrollBars (); 179 image->updateScrollBars ();
172 pic->repaint(false); 180 pic->repaint(false);
173} 181}
174 182
175void ImagePane::imageClicked() 183void ImagePane::imageClicked()
176{ 184{
177 emit clicked(); 185 emit clicked();
178} 186}
179//=========================================================================== 187//===========================================================================
180/* 188/*
181 Draws the portion of the scaled pixmap that needs to be updated 189 Draws the portion of the scaled pixmap that needs to be updated
182*/ 190*/
183 191
184void ImageWidget::paintEvent( QPaintEvent *e ) 192void ImageWidget::paintEvent( QPaintEvent *e )
185{ 193{
186 QPainter painter(this); 194 QPainter painter(this);
187 195
188 painter.setClipRect(e->rect()); 196 painter.setClipRect(e->rect());
189 painter.fillRect(0,0,width(),height(),QColor(0,0,0)); 197 painter.fillRect(0,0,width(),height(),QColor(0,0,0));
190 198
191 if ( pixmap.size() != QSize( 0, 0 ) ) 199 if ( pixmap.size() != QSize( 0, 0 ) )
192 { // is an image loaded? 200 { // is an image loaded?
193 painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); 201 painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap);
194 } 202 }
195} 203}
196 204
197void ImageWidget::mouseReleaseEvent(QMouseEvent *) 205void ImageWidget::mouseReleaseEvent(QMouseEvent *)
198{ 206{
199 emit clicked(); 207 emit clicked();
200} 208}
201 209
202//=========================================================================== 210//===========================================================================
203 211
204ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) 212ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
205: QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE ) 213: QMainWindow( parent, name, wFlags ), filename( 0 ), bFromDocView( FALSE )
206{ 214{
207 setCaption( tr("Image Viewer") ); 215 setCaption( tr("Image Viewer") );
208 setIcon( Resource::loadPixmap( "ImageViewer" ) ); 216 setIcon( Resource::loadPixmap( "ImageViewer" ) );
209 217
210 218
211 Config cfg("Image Viewer"); 219 Config cfg("Image Viewer");
212 cfg.setGroup("Image Viewer"); 220 cfg.setGroup("Image Viewer");
213 221
214 showThumbView=cfg.readBoolEntry("ShowThumbnails",false); 222 showThumbView=cfg.readBoolEntry("ShowThumbnails",false);
215 isSized=cfg.readBoolEntry("SizeToScreen",true); 223 isSized=cfg.readBoolEntry("SizeToScreen",true);
216 224
217 isFullScreen = FALSE; 225 isFullScreen = FALSE;
218 226
219 setToolBarsMovable( FALSE ); 227 setToolBarsMovable( FALSE );
220 228
221 toolBar = new QPEToolBar( this ); 229 toolBar = new QPEToolBar( this );
222 toolBar->setHorizontalStretchable( TRUE ); 230 toolBar->setHorizontalStretchable( TRUE );
223 231
224 menuBar = new QPEMenuBar( toolBar ); 232 menuBar = new QPEMenuBar( toolBar );
225 233
226 current=menuBar; 234 current=menuBar;
227 235
228 236
229 237
230 fileMenuFile = new QPopupMenu(this); 238 fileMenuFile = new QPopupMenu(this);
231 //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); 239 //menuBarmenubarFile->insertItem( tr("File"), fileMenu );
232 fileMenuFile->insertItem(tr("Open"), this, SLOT(openFile()), 0); 240 fileMenuFile->insertItem(tr("Open"),
241 this, SLOT(openFile()), 0);
233 242
234 viewMenuFile = new QPopupMenu( this ); 243 viewMenuFile = new QPopupMenu( this );
235 //menubarFile->insertItem( tr("View"), viewMenu ); 244 //menubarFile->insertItem( tr("View"), viewMenu );
236 viewMenuFile->insertItem( tr("Thumbnail View"), this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); 245 viewMenuFile->insertItem( tr("Thumbnail View"),
246 this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS );
237 247
238 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 248 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
239 249
240 250
241 251
242 252
243 optionsMenuFile = new QPopupMenu( this); 253 optionsMenuFile = new QPopupMenu( this);
244 //menubarFile->insertItem( tr("Options"),optionsMenu ); 254 //menubarFile->insertItem( tr("Options"),optionsMenu );
245 optionsMenuFile->insertItem( tr("Slideshow") ); 255 slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ),
246 optionsMenuFile->insertSeparator(); 256 QString::null, 0, this, 0 );
247 optionsMenuFile->insertItem( tr("Preferences..")); 257 slideAction->setToggleAction( TRUE );
248 optionsMenuFile->insertItem( tr("Help")); 258 connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) );
249 259 slideAction->addTo( optionsMenuFile);
260// slideAction->addTo( toolBar );
250 261
251 262
263// optionsMenuFile->insertItem( tr("Slideshow") );
264 optionsMenuFile->insertSeparator();
265 optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0);
266// optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0);
252 267
253 QStrList fmt = QImage::outputFormats(); 268 QStrList fmt = QImage::outputFormats();
254 269
255 270
256 fileMenuView = new QPopupMenu( this ); 271 fileMenuView = new QPopupMenu( this );
257 //menubarView->insertItem( tr("File"),fileMenu ); 272 //menubarView->insertItem( tr("File"),fileMenu );
258 fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); 273 fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 );
259 fileMenuView->insertSeparator(); 274 fileMenuView->insertSeparator();
260 275
261 viewMenuView = new QPopupMenu(this ); 276 viewMenuView = new QPopupMenu(this );
262 viewMenuView->setCheckable ( true ); 277 viewMenuView->setCheckable ( true );
263 278
264 //menubarView->insertItem( tr("View"),viewMenu ); 279 //menubarView->insertItem( tr("View"),viewMenu );
265 viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); 280 viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0);
266 viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); 281 viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0);
267 282
268 stack = new QWidgetStack( this ); 283 stack = new QWidgetStack( this );
269 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); 284 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
270 setCentralWidget( stack ); 285 setCentralWidget( stack );
271 286
272 287
273 imagePanel = new ImagePane( stack ); 288 imagePanel = new ImagePane( stack );
274 connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); 289 connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView()));
275 290
276 291
277 ImageFileSelector::CURRENT_VIEW cv; 292 ImageFileSelector::CURRENT_VIEW cv;
278 if(showThumbView) 293 if(showThumbView)
279 cv=ImageFileSelector::THUMBNAIL; 294 cv=ImageFileSelector::THUMBNAIL;
280 else 295 else
281 cv=ImageFileSelector::DETAILED; 296 cv=ImageFileSelector::DETAILED;
282 297
283 qDebug("cv = %d",cv); 298 qDebug("cv = %d",cv);
284 299
285 fileSelector = new ImageFileSelector( cv,stack, "fs"); 300 fileSelector = new ImageFileSelector( cv,stack, "fs");
286 301
287 //switchThumbView(); 302 //switchThumbView();
288 303
289 304
290 //fileSelector = new ImageFileSelector("image/*", stack, "fs"); 305 //fileSelector = new ImageFileSelector("image/*", stack, "fs");
291 //fileSelector->setNewVisible(FALSE); 306 //fileSelector->setNewVisible(FALSE);
292 //fileSelector->setCloseVisible(FALSE); 307 //fileSelector->setCloseVisible(FALSE);
293 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); 308 connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) );
294 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); 309 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
310 this, SLOT( openFile( const DocLnk & ) ) );
311
312 imageList = fileSelector->fileList();
313 slideAction->setEnabled( imageList.count() != 0);
295 314
296 iconToolBar = new QPEToolBar(this); 315 iconToolBar = new QPEToolBar(this);
297 316
298 QAction *a; 317 QAction *a;
299 318
300 a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); 319 a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
301 connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); 320 connect( a, SIGNAL( activated() ), this, SLOT( open() ) );
302 a->addTo( fileMenuView); 321 a->addTo( fileMenuView);
303 a->addTo( iconToolBar ); 322 a->addTo( iconToolBar );
304 323
305 324
306 a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); 325 a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0);
307 connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); 326 connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) );
308 a->addTo( iconToolBar ); 327 a->addTo( iconToolBar );
309 a->addTo( viewMenuView ); 328 a->addTo( viewMenuView );
310 329
311 a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); 330 a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 );
312 connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); 331 connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) );
313 a->addTo( iconToolBar ); 332 a->addTo( iconToolBar );
314 a->addTo( viewMenuView ); 333 a->addTo( viewMenuView );
315 334
316 335
317 a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); 336 a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0);
318 connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); 337 connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) );
319 //a->addTo( iconToolBar ); 338 //a->addTo( iconToolBar );
320 a->addTo( viewMenuView ); 339 a->addTo( viewMenuView );
321 340
322 341
323 342
324 viewMenuView->insertSeparator(); 343 viewMenuView->insertSeparator();
325 viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); 344 viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0);
326 viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); 345 viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE);
327 viewMenuView->insertSeparator(); 346 viewMenuView->insertSeparator();
328 347
329 348
330 sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); 349 sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true);
331 connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); 350 connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) );
332 sss->addTo( iconToolBar ); 351 sss->addTo( iconToolBar );
333 sss->addTo( viewMenuView ); 352 sss->addTo( viewMenuView );
334 353
335 sss->setOn(isSized); 354 sss->setOn(isSized);
336 viewMenuView->insertSeparator(); 355 viewMenuView->insertSeparator();
337 356
338 357
339 a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); 358 a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ),
359 QString::null, 0, this, 0 );
340 connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); 360 connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) );
341 a->addTo( iconToolBar ); 361 a->addTo( iconToolBar );
342 a->addTo( viewMenuView); 362 a->addTo( viewMenuView);
343 363
364 a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ),
365 QString::null, 0, this, 0 );
366 connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) );
367 a->addTo( iconToolBar );
368 a->addTo( viewMenuView);
369
370
371 Config config( "ImageViewer" );
372 config.setGroup( "SlideShow" );
373 slideDelay = config.readNumEntry( "Delay", 2);
374 slideRepeat = config.readBoolEntry( "Repeat", FALSE );
375 slideReverse = config.readBoolEntry("Reverse", FALSE);
376
377 config.setGroup("Default");
378 rotateOnLoad = config.readBoolEntry("Rotate", FALSE);
379 fastLoad = config.readBoolEntry("FastLoad", TRUE);
380 slideTimer = new QTimer( this );
381 connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) );
382
344 switchToFileSelector(); 383 switchToFileSelector();
345 384
346 setMouseTracking( TRUE ); 385 setMouseTracking( TRUE );
347 386
348 387
349} 388}
350 389
351ImageViewer::~ImageViewer() 390ImageViewer::~ImageViewer()
352{ 391{
353 Config cfg("Image Viewer"); 392 Config cfg("Image Viewer");
354 cfg.setGroup("Image Viewer"); 393 cfg.setGroup("Image Viewer");
355 394
356 cfg.writeEntry("ShowThumbnails",(int)showThumbView); 395 cfg.writeEntry("ShowThumbnails",(int)showThumbView);
357 cfg.writeEntry("SizeToScreen",(int)isSized); 396 cfg.writeEntry("SizeToScreen",(int)isSized);
358 397
398 cfg.setGroup( "SlideShow" );
399 cfg.writeEntry( "Delay", slideDelay);
400 cfg.writeEntry( "Repeat", slideRepeat );
401 cfg.writeEntry("Reverse", slideReverse);
402
403 cfg.setGroup("Default");
404 cfg.writeEntry("Rotate", rotateOnLoad);
405 cfg.writeEntry("FastLoad", fastLoad);
406
359 delete imagePanel; // in case it is fullscreen 407 delete imagePanel; // in case it is fullscreen
360} 408}
361 409
410void ImageViewer::help() {
411
412}
413
414
415void ImageViewer::settings()
416{
417 SettingsDialog dlg( this, 0, TRUE );
418 dlg.setDelay( slideDelay );
419 dlg.setRepeat( slideRepeat );
420 dlg.setReverse( slideReverse );
421 dlg.setRotate(rotateOnLoad);
422 dlg.setFastLoad(fastLoad);
423
424 if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) {
425 qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>");
426 slideDelay = dlg.delay();
427 slideRepeat = dlg.repeat();
428 slideReverse = dlg.reverse();
429 rotateOnLoad = dlg.rotate();
430 fastLoad = dlg.fastLoad();
431
432 Config config( "ImageViewer" );
433 config.setGroup( "SlideShow" );
434 config.writeEntry( "Delay", slideDelay );
435 config.writeEntry( "Repeat", slideRepeat );
436 config.writeEntry("Reverse", slideReverse);
437
438 config.setGroup("Default");
439 config.writeEntry("Rotate", rotateOnLoad);
440 config.writeEntry("FastLoad", fastLoad);
441 }
442}
443
362void ImageViewer::switchSizeToScreen() 444void ImageViewer::switchSizeToScreen()
363{ 445{
364 isSized=!isSized; 446 isSized=!isSized;
365 sss->setOn(isSized); 447 sss->setOn(isSized);
366 updateImage(); 448 updateImage();
367} 449}
368 450
369void ImageViewer::updateImage() 451void ImageViewer::updateImage()
370{ 452{
371 if ( isSized ) 453 if ( isSized ) {
372 {
373 imagePanel->setPixmap(pmScaled); 454 imagePanel->setPixmap(pmScaled);
374 } 455 } else {
375 else
376 {
377 imagePanel->setPixmap(pm); 456 imagePanel->setPixmap(pm);
378 } 457 }
379} 458}
380 459
381void ImageViewer::switchThumbView() 460void ImageViewer::switchThumbView()
382{ 461{
383 462
384 showThumbView=!showThumbView; 463 showThumbView=!showThumbView;
385 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); 464 viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
386 fileSelector->switchView(); 465 fileSelector->switchView();
387 466
388} 467}
389 468
390void ImageViewer::switchToFileSelector() 469void ImageViewer::switchToFileSelector()
391{ 470{
392 stack->raiseWidget(fileSelector); 471 stack->raiseWidget(fileSelector);
393 menuBar->clear(); 472 menuBar->clear();
394 menuBar->insertItem( tr("File"), fileMenuFile ); 473 menuBar->insertItem( tr("File"), fileMenuFile );
395 menuBar->insertItem( tr("View"), viewMenuFile ); 474 menuBar->insertItem( tr("View"), viewMenuFile );
396 menuBar->insertItem( tr("Options"), optionsMenuFile ); 475 menuBar->insertItem( tr("Options"), optionsMenuFile );
397 iconToolBar->hide(); 476 iconToolBar->hide();
398 imagePanel->disable(); 477 imagePanel->disable();
478 slideShow(false);
399 479
400} 480}
401 481
402void ImageViewer::switchToImageView() 482void ImageViewer::switchToImageView()
403{ 483{
404 stack->raiseWidget(imagePanel); 484 stack->raiseWidget(imagePanel);
405 485
406 menuBar->clear(); 486 menuBar->clear();
407 menuBar->insertItem( tr("File"), fileMenuView ); 487 menuBar->insertItem( tr("File"), fileMenuView );
408 menuBar->insertItem( tr("View"), viewMenuView ); 488 menuBar->insertItem( tr("View"), viewMenuView );
409 viewMenuView->setItemEnabled(BLACKANDWHITE,true); 489 viewMenuView->setItemEnabled(BLACKANDWHITE,true);
410 iconToolBar->show(); 490 iconToolBar->show();
411 491
412 imagePanel->setPosition(0,0); 492 imagePanel->setPosition(0,0);
413 493
414} 494}
415 495
416 496
417void ImageViewer::setDocument(const QString& fileref) 497void ImageViewer::setDocument(const QString& fileref)
418{ 498{
419 delayLoad = fileref; 499 delayLoad = fileref;
420 switchToImageView(); 500 switchToImageView();
421 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); 501 QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) );
422} 502}
423 503
424void ImageViewer::doDelayedLoad() 504void ImageViewer::doDelayedLoad()
425{ 505{
426 show(delayLoad); 506 show(delayLoad);
427} 507}
428 508
429void ImageViewer::show() 509void ImageViewer::show()
430{ 510{
431 normalView(); 511 normalView();
432 QMainWindow::show(); 512 QMainWindow::show();
433} 513}
434 514
435void ImageViewer::show(const QString& fileref) 515void ImageViewer::show(const QString& fileref)
436{ 516{
517// qDebug("Show "+fileref);
437 bFromDocView = TRUE; 518 bFromDocView = TRUE;
438 closeFileSelector(); 519 closeFileSelector();
439 DocLnk link(fileref); 520 DocLnk link(fileref);
440 if ( link.isValid() ) 521 if ( link.isValid() ) {
441 {
442 openFile(link); 522 openFile(link);
443 } 523 } else {
444 else
445 {
446 filename = fileref; 524 filename = fileref;
447 updateCaption( fileref ); 525 updateCaption( fileref );
448 loadImage( fileref ); 526 loadImage( fileref );
449 } 527 }
450} 528}
451 529
452void ImageViewer::openFile( const DocLnk &file ) 530void ImageViewer::openFile() {
531 MimeTypes types;
532 QStringList image;
533 image << "image/*";
534 types.insert("Images", image);
535
536 QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 );
537 DocLnk link(str);
538 if ( link.isValid() )
539 openFile(link);
540
541}
542
543void ImageViewer::openFile( const DocLnk &link )
453{ 544{
454 closeFileSelector(); 545 closeFileSelector();
455 DocLnk link(file); 546// DocLnk link(file);
547 qDebug("open "+link.name());
456 updateCaption( link.name() ); 548 updateCaption( link.name() );
457 loadImage( link.file() ); 549 loadImage( link.file() );
550 if (slideTimer->isActive()) {
551 slideTimer->start(slideDelay * 1000, FALSE);
552 }
553
458} 554}
459 555
460void ImageViewer::open() 556void ImageViewer::open()
461{ 557{
462 switchToFileSelector(); 558 switchToFileSelector();
463} 559}
464 560
465void ImageViewer::closeFileSelector() 561void ImageViewer::closeFileSelector()
466{ 562{
467 switchToImageView(); 563 switchToImageView();
468} 564}
469 565
470void ImageViewer::updateCaption( QString name ) 566void ImageViewer::updateCaption( QString name )
471{ 567{
472 int sep = name.findRev( '/' ); 568 int sep = name.findRev( '/' );
473 if ( sep >= 0 ) 569 if ( sep >= 0 )
474 name = name.mid( sep+1 ); 570 name = name.mid( sep+1 );
475 setCaption( name + tr(" - Image Viewer") ); 571 setCaption( name + tr(" - Image Viewer") );
476} 572}
477 573
478/* 574/*
479 This function loads an image from a file. 575 This function loads an image from a file.
480*/ 576*/
481 577
482void ImageViewer::loadImage( const char *fileName ) 578void ImageViewer::loadImage( const char *fileName )
483{ 579{
484 filename = fileName; 580 filename = fileName;
485 if ( filename ) 581 if ( filename ) {
486 {
487 QApplication::setOverrideCursor( waitCursor ); // this might take time 582 QApplication::setOverrideCursor( waitCursor ); // this might take time
488 //imagePanel->statusLabel()->setText( tr("Loading image...") ); 583 //imagePanel->statusLabel()->setText( tr("Loading image...") );
489 qApp->processEvents(); 584 qApp->processEvents();
490 bool ok = image.load(filename, 0); 585 bool ok = image.load(filename, 0);
491 if ( ok ) 586 if ( ok ) {
492 {
493 ok = reconvertImage(); 587 ok = reconvertImage();
494 updateImageInfo(filename); 588 updateImageInfo(filename);
495 } 589 }
496 if ( !ok ) 590 if ( !ok ) {
497 {
498 pm.resize(0,0); // couldn't load image 591 pm.resize(0,0); // couldn't load image
499 update(); 592 update();
500 } 593 }
501 QApplication::restoreOverrideCursor(); // restore original cursor 594 QApplication::restoreOverrideCursor(); // restore original cursor
502 } 595 }
596
597// fastLoad ? ", Fast" : "",
598// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1);
599
600
601// matrix.reset();
602 rotated90 = FALSE;
603
604 if (rotateOnLoad) {
605 rotated90 = TRUE;
606 rot90();
607// matrix.rotate( -90.0 );
608 }
609
503 switchToImageView(); 610 switchToImageView();
504 updateImage(); 611 updateImage();
505 612
506} 613}
507 614
508bool ImageViewer::loadSelected() 615bool ImageViewer::loadSelected()
509{ 616{
510 bool ok = false; 617 bool ok = false;
511 if ( stack->visibleWidget() == fileSelector ) 618 if ( stack->visibleWidget() == fileSelector )
512 { 619 {
513 const DocLnk *link = fileSelector->selected(); 620 const DocLnk *link = fileSelector->selected();
514 if ( link ) 621 if ( link )
515 { 622 {
516 if ( link->file() != filename ) 623 if ( link->file() != filename )
517 { 624 {
518 updateCaption( link->name() ); 625 updateCaption( link->name() );
519 filename = link->file(); 626 filename = link->file();
520 qApp->processEvents(); 627 qApp->processEvents();
521 ok = image.load(filename, 0); 628 ok = image.load(filename, 0);
522 if ( ok ) 629 if ( ok )
523 { 630 {
524 updateImageInfo(filename); 631 updateImageInfo(filename);
525 ok = reconvertImage(); 632 ok = reconvertImage();
526 } 633 }
527 if ( !ok ) 634 if ( !ok )
528 pm.resize(0,0); 635 pm.resize(0,0);
529 } 636 }
530 } 637 }
531 } 638 }
532 if ( !image.isNull() ) 639 if ( !image.isNull() )
533 { 640 {
534 ok = true; 641 ok = true;
535 closeFileSelector(); 642 closeFileSelector();
536 } 643 }
537 644
538 return ok; 645 return ok;
539} 646}
540 647
541bool ImageViewer::reconvertImage() 648bool ImageViewer::reconvertImage()
542{ 649{
543 bool success = FALSE; 650 bool success = FALSE;
544 651
545 if ( image.isNull() ) return FALSE; 652 if ( image.isNull() ) return FALSE;
546 653
547 QApplication::setOverrideCursor( waitCursor ); // this might take time 654 QApplication::setOverrideCursor( waitCursor ); // this might take time
548 if ( pm.convertFromImage(image /*, conversion_flags */ ) ) 655 if ( pm.convertFromImage(image /*, conversion_flags */ ) )
549 { 656 {
550 pmScaled = QPixmap(); 657 pmScaled = QPixmap();
@@ -574,184 +681,191 @@ int ImageViewer::calcHeight()
574*/ 681*/
575void ImageViewer::scale() 682void ImageViewer::scale()
576{ 683{
577 int h = calcHeight(); 684 int h = calcHeight();
578 if ( image.isNull() ) return; 685 if ( image.isNull() ) return;
579 686
580 QApplication::setOverrideCursor( waitCursor ); // this might take time 687 QApplication::setOverrideCursor( waitCursor ); // this might take time
581 if ( imagePanel->paneWidth() == pm.width() && h == pm.height() ) 688 if ( imagePanel->paneWidth() == pm.width() && h == pm.height() )
582 { // no need to scale if widget 689 { // no need to scale if widget
583 pmScaled = pm; // size equals pixmap size 690 pmScaled = pm; // size equals pixmap size
584 } 691 }
585 else 692 else
586 { 693 {
587 double hs = (double)h / (double)image.height(); 694 double hs = (double)h / (double)image.height();
588 double ws = (double)imagePanel->paneWidth() / (double)image.width(); 695 double ws = (double)imagePanel->paneWidth() / (double)image.width();
589 double scaleFactor = (hs > ws) ? ws : hs; 696 double scaleFactor = (hs > ws) ? ws : hs;
590 int smoothW = (int)(scaleFactor * image.width()); 697 int smoothW = (int)(scaleFactor * image.width());
591 int smoothH = (int)(scaleFactor * image.height()); 698 int smoothH = (int)(scaleFactor * image.height());
592 699
593 pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ ); 700 pmScaled.convertFromImage( image.smoothScale( smoothW, smoothH ) /*, conversion_flags */ );
594 } 701 }
595 QApplication::restoreOverrideCursor(); // restore original cursor 702 QApplication::restoreOverrideCursor(); // restore original cursor
596} 703}
597 704
598/* 705/*
599 The resize event handler, if a valid pixmap was loaded it will call 706 The resize event handler, if a valid pixmap was loaded it will call
600 scale() to fit the pixmap to the new widget size. 707 scale() to fit the pixmap to the new widget size.
601*/ 708*/
602 709
603void ImageViewer::resizeEvent( QResizeEvent * ) 710void ImageViewer::resizeEvent( QResizeEvent * )
604{ 711{
605 712
606 if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image 713 if ( pm.size() == QSize( 0, 0 ) ) // we couldn't load the image
607 return; 714 return;
608 715
609 int h = calcHeight(); 716 int h = calcHeight();
610 717
611 if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() ) 718 if ( imagePanel->paneWidth() != pmScaled.width() || h != pmScaled.height() )
612 { // if new size, 719 { // if new size,
613 scale(); // scale pmScaled to window 720 scale(); // scale pmScaled to window
614 } 721 }
615 if ( image.hasAlphaBuffer() ) 722 if ( image.hasAlphaBuffer() )
616 erase(); 723 erase();
617} 724}
618 725
619 726
620void ImageViewer::hFlip() 727void ImageViewer::hFlip()
621{ 728{
729// matrix.scale( -1.0, 1.0 );
730
622 setImage(image.mirror(TRUE,FALSE)); 731 setImage(image.mirror(TRUE,FALSE));
623} 732}
624 733
625void ImageViewer::vFlip() 734void ImageViewer::vFlip()
626{ 735{
736// matrix.scale( 1.0, -1.0 );
627 setImage(image.mirror(FALSE,TRUE)); 737 setImage(image.mirror(FALSE,TRUE));
628} 738}
629 739
630void ImageViewer::rot180() 740void ImageViewer::rot180()
631{ 741{
632 742// matrix.rotate( 180.0 );
633 setImage(image.mirror(TRUE,TRUE)); 743 setImage(image.mirror(TRUE,TRUE));
634} 744}
635 745
636void ImageViewer::rot90() 746void ImageViewer::rot90()
637{ 747{
638 QImage oldimage; 748 QImage oldimage;
639 oldimage = image.convertDepth(32); 749 oldimage = image.convertDepth(32);
750// matrix.rotate( -90.0 );
640 setImage(rotate(oldimage,Rotate90)); 751 setImage(rotate(oldimage,Rotate90));
641 752
642} 753}
643void ImageViewer::rot270() 754void ImageViewer::rot270()
644{ 755{
645 756
646 QImage oldimage; 757 QImage oldimage;
647 oldimage = image.convertDepth(32); 758 oldimage = image.convertDepth(32);
759// matrix.rotate(90.0);
648 setImage(rotate(oldimage,Rotate270)); 760 setImage(rotate(oldimage,Rotate270));
649 761
650} 762}
651 763
652void ImageViewer::blackAndWhite() 764void ImageViewer::blackAndWhite()
653{ 765{
654 766
655 viewMenuView->setItemEnabled(BLACKANDWHITE,false); 767 viewMenuView->setItemEnabled(BLACKANDWHITE,false);
656 setImage(toGray(image,false)); 768 setImage(toGray(image,false));
657
658
659} 769}
660 770
661void ImageViewer::displayControlsDialog() 771void ImageViewer::displayControlsDialog()
662{ 772{
663 int w=80; 773 int w=80;
664 int h=w; 774 int h=w;
665 QImage small; 775 QImage small;
666 776
667 if ( image.width()<w ||image.height()<h ) 777 if ( image.width()<w ||image.height()<h )
668 small=image.smoothScale(w,h); 778 small=image.smoothScale(w,h);
669 else 779 else
670 small=image.copy(0,0,w,h); 780 small=image.copy(0,0,w,h);
671 781
672 int newB=0; 782 int newB=0;
673 ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this); 783 ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this);
674 dlg->exec(); 784 dlg->exec();
675 if ( newB ) 785 if ( newB ) {
676 {
677 intensity(image,(float)newB/100); 786 intensity(image,(float)newB/100);
678 setImage(image); 787 setImage(image);
679 } 788 }
680 789
681} 790}
682 791
683 792
684void ImageViewer::displayInfoDialog() 793void ImageViewer::displayInfoDialog()
685{ 794{
686 795
687 QStringList ls; 796 QStringList ls;
688 797
689 for ( int i=0;i<LAST;i++ ) 798 for ( int i=0;i<LAST;i++ )
690 ls.append(imageInfo[i]); 799 ls.append(imageInfo[i]);
691 800
692 InfoDialog::displayInfo("Image Viewer",ls,this); 801 InfoDialog::displayInfo("Image Viewer",ls,this);
693} 802}
694void ImageViewer::normalView() 803void ImageViewer::normalView()
695{ 804{
696 if ( !imagePanel->parentWidget() ) 805 if ( !imagePanel->parentWidget() )
697 { 806 {
698 807
699 isFullScreen = FALSE; 808 isFullScreen = FALSE;
700 stack->addWidget( imagePanel, 1 ); 809 stack->addWidget( imagePanel, 1 );
701 switchToImageView(); 810 switchToImageView();
702 if ( isSized ) 811 if ( isSized )
703 scale(); 812 scale();
704 813
705 updateImage(); 814 updateImage();
706 815
707 } 816 }
708} 817}
709 818
819void ImageViewer::stopSlideShow() {
820 if (slideTimer->isActive())
821 slideTimer->stop();
822}
823
710void ImageViewer::fullScreen() 824void ImageViewer::fullScreen()
711{ 825{
712 // Full-screen option 826 // Full-screen option
713 // contributed by Robert Wittams <robert@wittams.com> 827 // contributed by Robert Wittams <robert@wittams.com>
714 if ( imagePanel->parentWidget() && loadSelected() ) 828 if ( imagePanel->parentWidget() && loadSelected() )
715 { 829 {
716 isFullScreen = TRUE; 830 isFullScreen = TRUE;
717 imagePanel->reparent(0,QPoint(0,0)); 831 imagePanel->reparent(0,QPoint(0,0));
718 imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height()); 832 imagePanel->resize(qApp->desktop()->width(), qApp->desktop()->height());
719 833
720 if ( isSized ) 834 if ( isSized )
721 scale(); 835 scale();
722 updateImage(); 836 updateImage();
723 imagePanel->showFullScreen(); 837 imagePanel->showFullScreen();
724 } 838 }
725} 839}
726 840
727void ImageViewer::setImage(const QImage& newimage) 841void ImageViewer::setImage(const QImage& newimage)
728{ 842{
729 image = newimage; 843 image = newimage;
730 reconvertImage(); 844 reconvertImage();
731 updateImage(); 845 updateImage();
732} 846}
733 847
734void ImageViewer::updateImageInfo(QString &filePath) 848void ImageViewer::updateImageInfo(QString &filePath)
735{ 849{
736 850
737 for ( int i=0;i<LAST;i++ ) 851 for ( int i=0;i<LAST;i++ )
738 { 852 {
739 imageInfo[i]=""; 853 imageInfo[i]="";
740 } 854 }
741 855
742 imageInfo[FORMAT]=QImage::imageFormat (filePath ); 856 imageInfo[FORMAT]=QImage::imageFormat (filePath );
743 QFileInfo fi(filePath); 857 QFileInfo fi(filePath);
744 imageInfo[PATH]=fi.fileName(); 858 imageInfo[PATH]=fi.fileName();
745 imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)"; 859 imageInfo[FILE_SIZE]=QString::number(fi.size())+" (bytes)";
746 QString message("%1x%2"); 860 QString message("%1x%2");
747 imageInfo[SIZE]=QString("%1x%2"); 861 imageInfo[SIZE]=QString("%1x%2");
748 imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height()); 862 imageInfo[SIZE]=imageInfo[SIZE].arg(image.width()).arg(image.height());
749 if ( image.numColors() > 0 ) 863 if ( image.numColors() > 0 )
750 { 864 {
751 imageInfo[COLORS]=tr("%1 colors").arg(image.numColors()); 865 imageInfo[COLORS]=tr("%1 colors").arg(image.numColors());
752 } 866 }
753 else if ( image.depth() >= 16 ) 867 else if ( image.depth() >= 16 )
754 { 868 {
755 imageInfo[COLORS]=tr(" True color"); 869 imageInfo[COLORS]=tr(" True color");
756 } 870 }
757 if ( image.hasAlphaBuffer() ) 871 if ( image.hasAlphaBuffer() )
@@ -989,56 +1103,147 @@ QImage ImageViewer::rotate(QImage &img, RotateDirection r)
989 { 1103 {
990 srcData = (unsigned char *)img.scanLine(y); 1104 srcData = (unsigned char *)img.scanLine(y);
991 for ( x=0; x < img.width(); ++x ) 1105 for ( x=0; x < img.width(); ++x )
992 { 1106 {
993 destData = (unsigned char *)dest.scanLine(x); 1107 destData = (unsigned char *)dest.scanLine(x);
994 destData[img.height()-y-1] = srcData[x]; 1108 destData[img.height()-y-1] = srcData[x];
995 } 1109 }
996 } 1110 }
997 break; 1111 break;
998 case Rotate180: 1112 case Rotate180:
999 dest.create(img.width(), img.height(), img.depth()); 1113 dest.create(img.width(), img.height(), img.depth());
1000 dest.setNumColors(img.numColors()); 1114 dest.setNumColors(img.numColors());
1001 srcTable = (unsigned int *)img.colorTable(); 1115 srcTable = (unsigned int *)img.colorTable();
1002 destTable = (unsigned int *)dest.colorTable(); 1116 destTable = (unsigned int *)dest.colorTable();
1003 for ( x=0; x < img.numColors(); ++x ) 1117 for ( x=0; x < img.numColors(); ++x )
1004 destTable[x] = srcTable[x]; 1118 destTable[x] = srcTable[x];
1005 for ( y=0; y < img.height(); ++y ) 1119 for ( y=0; y < img.height(); ++y )
1006 { 1120 {
1007 srcData = (unsigned char *)img.scanLine(y); 1121 srcData = (unsigned char *)img.scanLine(y);
1008 destData = (unsigned char *)dest.scanLine(img.height()-y-1); 1122 destData = (unsigned char *)dest.scanLine(img.height()-y-1);
1009 for ( x=0; x < img.width(); ++x ) 1123 for ( x=0; x < img.width(); ++x )
1010 destData[img.width()-x-1] = srcData[x]; 1124 destData[img.width()-x-1] = srcData[x];
1011 } 1125 }
1012 break; 1126 break;
1013 case Rotate270: 1127 case Rotate270:
1014 dest.create(img.height(), img.width(), img.depth()); 1128 dest.create(img.height(), img.width(), img.depth());
1015 dest.setNumColors(img.numColors()); 1129 dest.setNumColors(img.numColors());
1016 srcTable = (unsigned int *)img.colorTable(); 1130 srcTable = (unsigned int *)img.colorTable();
1017 destTable = (unsigned int *)dest.colorTable(); 1131 destTable = (unsigned int *)dest.colorTable();
1018 for ( x=0; x < img.numColors(); ++x ) 1132 for ( x=0; x < img.numColors(); ++x )
1019 destTable[x] = srcTable[x]; 1133 destTable[x] = srcTable[x];
1020 for ( y=0; y < img.height(); ++y ) 1134 for ( y=0; y < img.height(); ++y )
1021 { 1135 {
1022 srcData = (unsigned char *)img.scanLine(y); 1136 srcData = (unsigned char *)img.scanLine(y);
1023 for ( x=0; x < img.width(); ++x ) 1137 for ( x=0; x < img.width(); ++x )
1024 { 1138 {
1025 destData = (unsigned char *)dest.scanLine(img.width()-x-1); 1139 destData = (unsigned char *)dest.scanLine(img.width()-x-1);
1026 destData[y] = srcData[x]; 1140 destData[y] = srcData[x];
1027 } 1141 }
1028 } 1142 }
1029 break; 1143 break;
1030 default: 1144 default:
1031 dest = img; 1145 dest = img;
1032 break; 1146 break;
1033 } 1147 }
1034 1148
1035 } 1149 }
1036 return (dest); 1150 return (dest);
1151}
1152
1153void ImageViewer::slideShow( bool on )
1154{
1155 if (on) {
1156 if (!imageList.isEmpty()) {
1157 slideTimer->start(slideDelay * 1000, FALSE);
1158 filename = ""; // force restart
1159 slideReverse ? prevImage() : nextImage();
1160 }
1161 } else {
1162 slideTimer->stop();
1163 slideAction->setOn( false);
1164 }
1165}
1166
1167void ImageViewer::slideUpdate()
1168{
1169 bool final_image = slideReverse ? prevImage() : nextImage();
1170
1171 if (final_image && !slideRepeat) {
1172 slideTimer->stop();
1173 slideAction->setOn(FALSE);
1174 }
1175}
1037 1176
1177//
1178// Display the image after the current one in the image list.
1179// Return TRUE if the next call to nextImage() will wrap around to the
1180// first image in the list (ie. we're now viewing the last image in the list).
1181//
1182bool ImageViewer::nextImage(void)
1183{
1184 int idx = 0;
1185
1186 if (imageList.count() > 0) {
1187 idx = imageIndex();
1188 if (idx != -1) {
1189 if (idx == int(imageList.count() - 1)) {
1190 idx = 0;
1191 } else {
1192 idx++;
1193 }
1194 } else {
1195 idx = 0;
1196 }
1197 openFile(imageList[idx]);
1198 }
1038 1199
1200 return idx == int(imageList.count() - 1) ? TRUE : FALSE;
1039} 1201}
1040 1202
1203//
1204// Display the image preceeding the current one in the image list.
1205// Return TRUE if the next call to prevImage() will wrap around to the last
1206// image in the list (ie. we're now viewing the first image in the list).
1207//
1208bool ImageViewer::prevImage(void)
1209{
1210 int idx = -1;
1211
1212 if (imageList.count() > 0) {
1213 idx = imageIndex();
1214 if (idx != -1) {
1215 if (idx == 0) {
1216 idx = imageList.count() - 1;
1217 } else {
1218 idx--;
1219 }
1220 } else {
1221 idx = imageList.count() - 1;
1222 }
1223 openFile(imageList[idx]);
1224 }
1041 1225
1226 return idx == 0 ? TRUE : FALSE;
1227}
1042 1228
1229//
1230// Return the index into the imageList of the currently viewed
1231// image (ie. ImageViewer::filename in ImageViewer::imageList).
1232//
1233int ImageViewer::imageIndex(void)
1234{
1235 QValueListConstIterator<DocLnk> i;
1236 int index;
1043 1237
1238 if (imageList.count() == 0) {
1239 return -1;
1240 }
1044 1241
1242 for (index = 0, i = imageList.begin(); i != imageList.end(); ++i, index++) {
1243 if ((*i).file() == filename) {
1244 return index;
1245 }
1246 }
1247
1248 return -1;
1249}
diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h
index 0d3bc7d..8555ff0 100644
--- a/noncore/multimedia/showimg/showimg.h
+++ b/noncore/multimedia/showimg/showimg.h
@@ -1,298 +1,288 @@
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#ifndef SHOWIMG_H 21#ifndef SHOWIMG_H
22#define SHOWIMG_H 22#define SHOWIMG_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qimage.h> 26#include <qimage.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qscrollview.h> 29#include <qscrollview.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qstringlist.h> 31#include <qstringlist.h>
32#include <qvaluelist.h>
33#include <qwmatrix.h>
32 34
35
36class QAction;
33class QPEToolBar; 37class QPEToolBar;
34class QPEMenuBar; 38class QPEMenuBar;
35class QPopupMenu; 39class QPopupMenu;
36class QWidgetStack; 40class QWidgetStack;
37class FileSelector; 41class FileSelector;
38class DocLnk; 42class DocLnk;
39class QLabel; 43class QLabel;
40class QAction; 44class QAction;
41class QSpinBox; 45class QSpinBox;
42class ImageFileSelector; 46class ImageFileSelector;
43 47class QTimer;
44 48
45 49
46class ImageWidget : public QWidget 50class ImageWidget : public QWidget
47{ 51{
48 Q_OBJECT 52 Q_OBJECT
49 public: 53 public:
50 ImageWidget( 54 ImageWidget( QWidget *parent=0 )
51 QWidget *parent=0 55 : QWidget( parent ) {
52 ) : QWidget( parent )
53 {
54 setBackgroundMode(NoBackground); 56 setBackgroundMode(NoBackground);
55 } 57 }
56 ~ImageWidget() 58 ~ImageWidget() { }
57 {
58
59 }
60 59
61 void setPixmap( const QPixmap &pm ) 60 void setPixmap( const QPixmap &pm ) {
62 {
63 pixmap = pm; 61 pixmap = pm;
64 show(); 62 show();
65 } 63 }
66 64
67 signals: 65signals:
68 void clicked(); 66 void clicked();
69 67
70protected: 68protected:
71 void paintEvent( QPaintEvent * ); 69 void paintEvent( QPaintEvent * );
72 void mouseReleaseEvent(QMouseEvent* event); 70 void mouseReleaseEvent(QMouseEvent* event);
73 71
74private: 72private:
75 QPixmap pixmap; 73 QPixmap pixmap;
76}; 74};
77 75
78class InfoDialog:public QDialog 76class InfoDialog:public QDialog
79{ 77{
80 Q_OBJECT 78 Q_OBJECT
81 79
82 public: 80public:
83 81
84 static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); 82 static void displayInfo(const QString &caption, const QStringList text, QWidget *parent);
85 83
86private: 84private:
87 85
88 InfoDialog(const QString &caption,const QStringList text, QWidget *parent); 86 InfoDialog(const QString &caption,const QStringList text, QWidget *parent);
89 87
90}; 88};
91 89
92class ControlsDialog:public QDialog 90class ControlsDialog:public QDialog
93{ 91{
94 Q_OBJECT 92 Q_OBJECT
95 93
96 public: 94public:
97 ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent); 95 ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent);
98 96
99 97
100private slots: 98private slots:
101 99
102 void bValueChanged(int); 100 void bValueChanged(int);
103 void accept(); 101 void accept();
104 102
105 103
106private: 104private:
107 ImageWidget *pixmap; 105 ImageWidget *pixmap;
108 QSpinBox *spb; 106 QSpinBox *spb;
109 QImage img; 107 QImage img;
110 int *b; 108 int *b;
111}; 109};
112 110
113 111
114class ImagePane : public QWidget 112class ImagePane : public QWidget
115{ 113{
116 Q_OBJECT 114 Q_OBJECT
117 public: 115public:
118 ImagePane( QWidget *parent=0 ); 116 ImagePane( QWidget *parent=0 );
119 ~ImagePane() 117 ~ImagePane() { }
120 {
121
122 }
123 118
124 //void showStatus(); 119 //void showStatus();
125 //void hideStatus(); 120 //void hideStatus();
126 //QLabel *statusLabel() 121 //QLabel *statusLabel()
127 //{ 122 //{
128 // return status; 123 // return status;
129 //} 124 //}
130 void setPixmap( const QPixmap &pm ); 125 void setPixmap( const QPixmap &pm );
131 126
132 127
133 int paneWidth() const 128 int paneWidth() const {
134 {
135 return image->visibleWidth(); 129 return image->visibleWidth();
136 } 130 }
137 131
138 int paneHeight() const 132 int paneHeight() const {
139 {
140 return image->visibleHeight(); 133 return image->visibleHeight();
141 } 134 }
142 135
143 void setPosition(int x, int y) 136 void setPosition(int x, int y) {
144 {
145 image->setContentsPos (x,y ); 137 image->setContentsPos (x,y );
146 } 138 }
147 139
148 void disable() 140 void disable() {
149 {
150 pic->hide(); 141 pic->hide();
151 } 142 }
152 143
153 signals: 144signals:
154 void clicked(); 145 void clicked();
155 146
156private: 147private:
157 QScrollView *image; 148 QScrollView *image;
158 ImageWidget *pic; 149 ImageWidget *pic;
159 QVBoxLayout *vb; 150 QVBoxLayout *vb;
160 151
161private slots: 152private slots:
162 void imageClicked(); 153 void imageClicked();
163}; 154};
164 155
165 156
166class ImageViewer : public QMainWindow 157class ImageViewer : public QMainWindow
167{ 158{
168 Q_OBJECT 159 Q_OBJECT
169 public: 160public:
170 ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); 161 ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 );
171 ~ImageViewer(); 162 ~ImageViewer();
172 163
173 void loadImage( const char *fileName ); 164 void loadImage( const char *fileName );
174 void show(const QString& fileref); 165 void show(const QString& fileref);
175 void show(); 166 void show();
176 167
177 168
178 enum INFO_STRINGS 169 enum INFO_STRINGS {
179 {
180 PATH, 170 PATH,
181 FORMAT, 171 FORMAT,
182 FILE_SIZE, 172 FILE_SIZE,
183 SIZE, 173 SIZE,
184 COLORS, 174 COLORS,
185 ALPHA, 175 ALPHA,
186 LAST 176 LAST
187 }; 177 };
188 178
189 enum RotateDirection 179 enum RotateDirection {
190 {
191 Rotate90, Rotate180, Rotate270 180 Rotate90, Rotate180, Rotate270
192 }; 181 };
193 182
194 183
195 static QImage rotate(QImage &img, RotateDirection r); 184 static QImage rotate(QImage &img, RotateDirection r);
196 static QImage& intensity(QImage &image, float percent); 185 static QImage& intensity(QImage &image, float percent);
197 static QImage& toGray(QImage &image, bool fast = false); 186 static QImage& toGray(QImage &image, bool fast = false);
187 bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view
198 188
199protected: 189protected:
200 void resizeEvent( QResizeEvent * ); 190 void resizeEvent( QResizeEvent * );
201 void closeEvent( QCloseEvent * ); 191 void closeEvent( QCloseEvent * );
202 192
203private: 193private:
194 int imageIndex(void);
195
204 void updateCaption( QString name ); 196 void updateCaption( QString name );
205 bool loadSelected(); 197 bool loadSelected();
206 void scale(); 198 void scale();
207 bool reconvertImage(); 199 bool reconvertImage();
208 int calcHeight(); 200 int calcHeight();
209 void setImage(const QImage& newimage); 201 void setImage(const QImage& newimage);
210 void updateImageInfo(QString &filePath); 202 void updateImageInfo(QString &filePath);
211 void switchToFileSelector(); 203 void switchToFileSelector();
212 void switchToImageView(); 204 void switchToImageView();
213 205
214 void updateImage(); 206 void updateImage();
215 207
216
217
218
219private slots: 208private slots:
220 209
210 void slideShow( bool on );
211 void help();
212 void slideUpdate();
213 bool nextImage();
214 bool prevImage();
215 void settings();
216
221 void switchThumbView(); 217 void switchThumbView();
222 void switchSizeToScreen(); 218 void switchSizeToScreen();
223 void setDocument(const QString& fileref); 219 void setDocument(const QString& fileref);
224 void doDelayedLoad(); 220 void doDelayedLoad();
225 void openFile( const DocLnk &file ); 221 void openFile( const DocLnk &file );
226 //void openFile(); 222 void openFile();
227 void open(); 223 void open();
228 void closeFileSelector(); 224 void closeFileSelector();
229 void hFlip(); 225 void hFlip();
230 void vFlip(); 226 void vFlip();
231 void rot180(); 227 void rot180();
232 void rot90(); 228 void rot90();
233 void rot270(); 229 void rot270();
234 void normalView(); 230 void normalView();
235 void fullScreen(); 231 void fullScreen();
232 void stopSlideShow();
236 void blackAndWhite(); 233 void blackAndWhite();
237 void displayInfoDialog(); 234 void displayInfoDialog();
238 void displayControlsDialog(); 235 void displayControlsDialog();
239
240
241
242
243
244
245
246
247
248
249private: 236private:
250 237 QWMatrix matrix;
251 238 bool rotated90;
252 239 enum MENU_ITEMS {
253
254 enum MENU_ITEMS
255 {
256 SHOW_THUMBNAILS, 240 SHOW_THUMBNAILS,
257 SIZE_TO_SCREEN, 241 SIZE_TO_SCREEN,
258 BLACKANDWHITE 242 BLACKANDWHITE
259 }; 243 };
260 244
261
262
263 QString filename; 245 QString filename;
264 QString delayLoad; 246 QString delayLoad;
265 QImage image; // the loaded image 247 QImage image; // the loaded image
266 QPixmap pm; // the converted pixmap 248 QPixmap pm; // the converted pixmap
267 QPixmap pmScaled; // the scaled pixmap 249 QPixmap pmScaled; // the scaled pixmap
268 QPEToolBar *toolBar; 250 QPEToolBar *toolBar;
269 QPEToolBar *iconToolBar; 251 QPEToolBar *iconToolBar;
270 QPEMenuBar *menuBar; 252 QPEMenuBar *menuBar;
271 QPEMenuBar *current; 253 QPEMenuBar *current;
272 254
273 255
274 QPopupMenu *fileMenuFile; 256 QPopupMenu *fileMenuFile;
275 QPopupMenu *viewMenuFile; 257 QPopupMenu *viewMenuFile;
276 QPopupMenu *optionsMenuFile; 258 QPopupMenu *optionsMenuFile;
277 QPopupMenu *fileMenuView; 259 QPopupMenu *fileMenuView;
278 QPopupMenu *viewMenuView; 260 QPopupMenu *viewMenuView;
279 261
280 QAction *sss; // scale to screen size 262 QAction *sss; // scale to screen size
281 263
282 QLabel *lab; 264 QLabel *lab;
283 ImagePane *imagePanel; 265 ImagePane *imagePanel;
284 QWidgetStack *stack; 266 QWidgetStack *stack;
285 //FileSelector *fileSelector; 267 //FileSelector *fileSelector;
286 ImageFileSelector *fileSelector; 268 ImageFileSelector *fileSelector;
287 bool isFullScreen; 269 bool isFullScreen;
288 bool isSized; // true if image is to be resized to fit the window size 270 bool isSized; // true if image is to be resized to fit the window size
289 bool bFromDocView; // a flag to indicate whether or not we were 271 bool bFromDocView; // a flag to indicate whether or not we were
290 // launched from the document view... 272 // launched from the document view...
291 273
292 bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view 274 int slideDelay;
275 bool slideRepeat;
276 bool slideReverse; // show slideshow in reverse order
277 bool rotateOnLoad; // rotate by 90 degrees on loading
278 bool fastLoad;
279 QTimer *slideTimer;
280 QValueList<DocLnk> imageList;
281 QAction *slideAction;
282
293 283
294 QString imageInfo[LAST]; 284 QString imageInfo[LAST];
295}; 285};
296 286
297 287
298#endif // SHOWIMG_H 288#endif // SHOWIMG_H
diff --git a/noncore/multimedia/showimg/showimg.pro b/noncore/multimedia/showimg/showimg.pro
index 2b6241f..4ff4746 100644
--- a/noncore/multimedia/showimg/showimg.pro
+++ b/noncore/multimedia/showimg/showimg.pro
@@ -1,27 +1,25 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3DESTDIR = $(OPIEDIR)/bin 3DESTDIR = $(OPIEDIR)/bin
4 HEADERS = showimg.h ImageFileSelector.h 4HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h
5 SOURCES = main.cpp \ 5SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp
6 showimg.cpp\
7 ImageFileSelector.cpp
8TARGET = showimg 6TARGET = showimg
9INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
10DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
11LIBS += -lqpe 9LIBS += -lqpe -lopie
12REQUIRES = showimg 10REQUIRES = showimg
13 11
14TRANSLATIONS = ../../../i18n/de/showimg.ts \ 12TRANSLATIONS = ../../../i18n/de/showimg.ts \
15 ../../../i18n/en/showimg.ts \ 13 ../../../i18n/en/showimg.ts \
16 ../../../i18n/es/showimg.ts \ 14 ../../../i18n/es/showimg.ts \
17 ../../../i18n/fr/showimg.ts \ 15 ../../../i18n/fr/showimg.ts \
18 ../../../i18n/hu/showimg.ts \ 16 ../../../i18n/hu/showimg.ts \
19 ../../../i18n/ja/showimg.ts \ 17 ../../../i18n/ja/showimg.ts \
20 ../../../i18n/ko/showimg.ts \ 18 ../../../i18n/ko/showimg.ts \
21 ../../../i18n/no/showimg.ts \ 19 ../../../i18n/no/showimg.ts \
22 ../../../i18n/pl/showimg.ts \ 20 ../../../i18n/pl/showimg.ts \
23 ../../../i18n/pt/showimg.ts \ 21 ../../../i18n/pt/showimg.ts \
24 ../../../i18n/pt_BR/showimg.ts \ 22 ../../../i18n/pt_BR/showimg.ts \
25 ../../../i18n/sl/showimg.ts \ 23 ../../../i18n/sl/showimg.ts \
26 ../../../i18n/zh_CN/showimg.ts \ 24 ../../../i18n/zh_CN/showimg.ts \
27 ../../../i18n/zh_TW/showimg.ts 25 ../../../i18n/zh_TW/showimg.ts