-rw-r--r-- | noncore/multimedia/showimg/ImageFileSelector.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp index 7872c09..d2b65a9 100644 --- a/noncore/multimedia/showimg/ImageFileSelector.cpp +++ b/noncore/multimedia/showimg/ImageFileSelector.cpp | |||
@@ -6,266 +6,266 @@ | |||
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 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) | 24 | ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) |
25 | : QWidget( parent ),fl(f) | 25 | : QWidget( parent ),fl(f) |
26 | { | 26 | { |
27 | setBackgroundMode(NoBackground); | 27 | setBackgroundMode(NoBackground); |
28 | if ( w!=-1 ) | 28 | if ( w!=-1 ) |
29 | setMinimumSize(w,p.height()+24); | 29 | setMinimumSize(w,p.height()+24); |
30 | else | 30 | else |
31 | setMinimumSize(p.width(),p.height()+24); | 31 | setMinimumSize(p.width(),p.height()+24); |
32 | description=new QLabel(text,this); | 32 | description=new QLabel(text,this); |
33 | description->setBackgroundColor(colorGroup().base()); | 33 | description->setBackgroundColor(colorGroup().base()); |
34 | description->setAlignment(AlignCenter); | 34 | description->setAlignment(AlignCenter); |
35 | description->setGeometry(0,height()-24,width(),24); | 35 | description->setGeometry(0,height()-24,width(),24); |
36 | pixmap=p; | 36 | pixmap=p; |
37 | } | 37 | } |
38 | 38 | ||
39 | void ThumbWidget::resizeEvent(QResizeEvent *) | 39 | void ThumbWidget::resizeEvent(QResizeEvent *) |
40 | { | 40 | { |
41 | description->setGeometry(0,height()-24,width(),24); | 41 | description->setGeometry(0,height()-24,width(),24); |
42 | } | 42 | } |
43 | 43 | ||
44 | void ThumbWidget::paintEvent( QPaintEvent *e ) | 44 | void ThumbWidget::paintEvent( QPaintEvent *e ) |
45 | { | 45 | { |
46 | QPainter painter(this); | 46 | QPainter painter(this); |
47 | 47 | ||
48 | painter.setClipRect(e->rect()); | 48 | painter.setClipRect(e->rect()); |
49 | painter.fillRect(0,0,width(),height(),QColor(255,255,255)); | 49 | painter.fillRect(0,0,width(),height(),QColor(255,255,255)); |
50 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); | 50 | painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap); |
51 | 51 | ||
52 | } | 52 | } |
53 | 53 | ||
54 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) | 54 | void ThumbWidget::mouseReleaseEvent(QMouseEvent* ) |
55 | { | 55 | { |
56 | emit clicked(fl); | 56 | emit clicked(fl); |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) | 61 | ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f) |
62 | : QListViewItem( parent ), fl( f ) | 62 | : QListViewItem( parent ), fl( f ) |
63 | { | 63 | { |
64 | setText( 0, f.name() ); | 64 | setText( 0, f.name() ); |
65 | QFileInfo fi(f.file()); | 65 | QFileInfo fi(f.file()); |
66 | setText( 1, (fi.extension()).upper() ); | 66 | setText( 1, (fi.extension()).upper() ); |
67 | setPixmap( 0, f.pixmap() ); | 67 | setPixmap( 0, f.pixmap() ); |
68 | 68 | ||
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | 72 | ||
73 | ImageFileSelectorItem::~ImageFileSelectorItem() | 73 | ImageFileSelectorItem::~ImageFileSelectorItem() |
74 | { | 74 | { |
75 | 75 | ||
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) | 79 | ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * ) |
80 | : QWidgetStack(parent) | 80 | : QWidgetStack(parent) |
81 | { | 81 | { |
82 | 82 | ||
83 | detailed=new QListView(this); | 83 | detailed=new QListView(this); |
84 | 84 | ||
85 | detailed->addColumn (tr("Title")); | 85 | detailed->addColumn (tr("Title")); |
86 | detailed->addColumn (tr("Type")); | 86 | detailed->addColumn (tr("Type")); |
87 | detailed->setAllColumnsShowFocus( true ); | 87 | detailed->setAllColumnsShowFocus( true ); |
88 | 88 | ||
89 | tList.setAutoDelete(true); | 89 | tList.setAutoDelete(true); |
90 | 90 | ||
91 | thumb =new QScrollView(this); | 91 | thumb =new QScrollView(this); |
92 | thumb->setVScrollBarMode (QScrollView::Auto ); | 92 | thumb->setVScrollBarMode (QScrollView::Auto ); |
93 | thumb->viewport()->setBackgroundColor(colorGroup().base()); | 93 | thumb->viewport()->setBackgroundColor(colorGroup().base()); |
94 | 94 | ||
95 | background=new QWidget(0); | 95 | background=new QWidget(0); |
96 | background->setBackgroundColor(colorGroup().base()); | 96 | background->setBackgroundColor(colorGroup().base()); |
97 | thumb->addChild(background); | 97 | thumb->addChild(background); |
98 | gl = new QGridLayout(background,1,2,4,4); | 98 | gl = new QGridLayout(background,1,2,4,4); |
99 | 99 | ||
100 | 100 | ||
101 | 101 | ||
102 | connect( detailed, SIGNAL( mouseButtonClicked( int, QListViewItem *, const QPoint &, int ) ), | 102 | connect( detailed, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
103 | this, SLOT( fileClicked( int, QListViewItem *, const QPoint &, int ) ) ); | 103 | this, SLOT( fileClicked(int,QListViewItem*,const QPoint&,int) ) ); |
104 | connect( detailed, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint &, int ) ), | 104 | connect( detailed, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
105 | this, SLOT( filePressed( int, QListViewItem *, const QPoint &, int ) ) ); | 105 | this, SLOT( filePressed(int,QListViewItem*,const QPoint&,int) ) ); |
106 | connect( detailed, SIGNAL( returnPressed( QListViewItem * ) ), | 106 | connect( detailed, SIGNAL( returnPressed(QListViewItem*) ), |
107 | this, SLOT( fileClicked( QListViewItem * ) ) ); | 107 | this, SLOT( fileClicked(QListViewItem*) ) ); |
108 | 108 | ||
109 | cView=UNKNOWN; | 109 | cView=UNKNOWN; |
110 | setView(scv); | 110 | setView(scv); |
111 | reread(); | 111 | reread(); |
112 | 112 | ||
113 | } | 113 | } |
114 | ImageFileSelector::~ImageFileSelector() | 114 | ImageFileSelector::~ImageFileSelector() |
115 | { | 115 | { |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void ImageFileSelector::switchView() | 120 | void ImageFileSelector::switchView() |
121 | { | 121 | { |
122 | CURRENT_VIEW v=cView; | 122 | CURRENT_VIEW v=cView; |
123 | 123 | ||
124 | if ( v==DETAILED ) | 124 | if ( v==DETAILED ) |
125 | v=THUMBNAIL; | 125 | v=THUMBNAIL; |
126 | else | 126 | else |
127 | v=DETAILED; | 127 | v=DETAILED; |
128 | setView(v); | 128 | setView(v); |
129 | } | 129 | } |
130 | 130 | ||
131 | void ImageFileSelector::setView(CURRENT_VIEW v) | 131 | void ImageFileSelector::setView(CURRENT_VIEW v) |
132 | { | 132 | { |
133 | 133 | ||
134 | if ( v==cView ) | 134 | if ( v==cView ) |
135 | return; | 135 | return; |
136 | cView=v; | 136 | cView=v; |
137 | 137 | ||
138 | if ( cView!=DETAILED ) | 138 | if ( cView!=DETAILED ) |
139 | { | 139 | { |
140 | raiseWidget(thumb); | 140 | raiseWidget(thumb); |
141 | updateSizes(); | 141 | updateSizes(); |
142 | } | 142 | } |
143 | else | 143 | else |
144 | { | 144 | { |
145 | raiseWidget(detailed); | 145 | raiseWidget(detailed); |
146 | updateSizes(); | 146 | updateSizes(); |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | void ImageFileSelector::resizeEvent(QResizeEvent *) | 152 | void ImageFileSelector::resizeEvent(QResizeEvent *) |
153 | { | 153 | { |
154 | updateSizes(); | 154 | updateSizes(); |
155 | } | 155 | } |
156 | 156 | ||
157 | void ImageFileSelector::updateSizes() | 157 | void ImageFileSelector::updateSizes() |
158 | { | 158 | { |
159 | int ww=(detailed->width()-detailed->frameWidth()*2); | 159 | int ww=(detailed->width()-detailed->frameWidth()*2); |
160 | double w=(double)ww*0.70; | 160 | double w=(double)ww*0.70; |
161 | detailed->setColumnWidth(0,(int)w); | 161 | detailed->setColumnWidth(0,(int)w); |
162 | detailed->setColumnWidth(1,ww-(int)w); | 162 | detailed->setColumnWidth(1,ww-(int)w); |
163 | background->setMinimumWidth(thumb->visibleWidth()); | 163 | background->setMinimumWidth(thumb->visibleWidth()); |
164 | thumb->updateScrollBars(); | 164 | thumb->updateScrollBars(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void ImageFileSelector::reread(bool) | 167 | void ImageFileSelector::reread(bool) |
168 | { | 168 | { |
169 | // qDebug("reread"); | 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 | int i,j; | 186 | int i,j; |
187 | i=j=0; | 187 | i=j=0; |
188 | detailed->setUpdatesEnabled(false); | 188 | detailed->setUpdatesEnabled(false); |
189 | thumb->setUpdatesEnabled(false); | 189 | thumb->setUpdatesEnabled(false); |
190 | 190 | ||
191 | for ( ; dit.current(); ++dit ) { | 191 | for ( ; dit.current(); ++dit ) { |
192 | item = new ImageFileSelectorItem( detailed, **dit ); | 192 | item = new ImageFileSelectorItem( detailed, **dit ); |
193 | if ( item->file().file() == oldFile ) | 193 | if ( item->file().file() == oldFile ) |
194 | detailed->setCurrentItem( item ); | 194 | detailed->setCurrentItem( item ); |
195 | } | 195 | } |
196 | 196 | ||
197 | QListViewItemIterator it( detailed ); | 197 | QListViewItemIterator it( detailed ); |
198 | ImageFileSelectorItem *ii; | 198 | ImageFileSelectorItem *ii; |
199 | // iterate through all items of the listview | 199 | // iterate through all items of the listview |
200 | for ( ; it.current(); ++it ) { | 200 | for ( ; it.current(); ++it ) { |
201 | ii=(ImageFileSelectorItem *)it.current(); | 201 | ii=(ImageFileSelectorItem *)it.current(); |
202 | QImage img( ii->file().file() ); | 202 | QImage img( ii->file().file() ); |
203 | if( !img.isNull()) { | 203 | if( !img.isNull()) { |
204 | img=img.smoothScale(64,64); | 204 | img=img.smoothScale(64,64); |
205 | QPixmap pix; | 205 | QPixmap pix; |
206 | pix.convertFromImage(img); | 206 | pix.convertFromImage(img); |
207 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); | 207 | l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width); |
208 | l->setBackgroundColor(colorGroup().base()); | 208 | l->setBackgroundColor(colorGroup().base()); |
209 | gl->addWidget(l,j,i); | 209 | gl->addWidget(l,j,i); |
210 | i++; | 210 | i++; |
211 | if ( i==2 ) { | 211 | if ( i==2 ) { |
212 | i=0; | 212 | i=0; |
213 | j++; | 213 | j++; |
214 | } | 214 | } |
215 | tList.append(l); | 215 | tList.append(l); |
216 | connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &))); | 216 | connect(l,SIGNAL(clicked(const DocLnk&)),this,SLOT(thumbClicked(const DocLnk&))); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | if ( !detailed->selectedItem() ) | 220 | if ( !detailed->selectedItem() ) |
221 | detailed->setCurrentItem( detailed->firstChild() ); | 221 | detailed->setCurrentItem( detailed->firstChild() ); |
222 | 222 | ||
223 | detailed->setUpdatesEnabled(true); | 223 | detailed->setUpdatesEnabled(true); |
224 | thumb->setUpdatesEnabled(true); | 224 | thumb->setUpdatesEnabled(true); |
225 | detailed->update(); | 225 | detailed->update(); |
226 | thumb->update(); | 226 | thumb->update(); |
227 | } | 227 | } |
228 | 228 | ||
229 | int ImageFileSelector::fileCount() | 229 | int ImageFileSelector::fileCount() |
230 | { | 230 | { |
231 | return count; | 231 | return count; |
232 | } | 232 | } |
233 | const DocLnk * ImageFileSelector::selected() | 233 | const DocLnk * ImageFileSelector::selected() |
234 | { | 234 | { |
235 | qDebug("image selected"); | 235 | qDebug("image selected"); |
236 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); | 236 | ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem(); |
237 | if ( item ) | 237 | if ( item ) |
238 | return new DocLnk( item->file() ); | 238 | return new DocLnk( item->file() ); |
239 | return 0; | 239 | return 0; |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | 243 | ||
244 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) | 244 | void ImageFileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) |
245 | { | 245 | { |
246 | if ( !i ) | 246 | if ( !i ) |
247 | return; | 247 | return; |
248 | if ( button == Qt::LeftButton ) | 248 | if ( button == Qt::LeftButton ) |
249 | { | 249 | { |
250 | fileClicked( i ); | 250 | fileClicked( i ); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | // pressed to get 'right down' | 253 | // pressed to get 'right down' |
254 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) | 254 | void ImageFileSelector::filePressed( int, QListViewItem *, const QPoint &, int ) |
255 | { | 255 | { |
256 | 256 | ||
257 | } | 257 | } |
258 | void ImageFileSelector::fileClicked( QListViewItem *i) | 258 | void ImageFileSelector::fileClicked( QListViewItem *i) |
259 | { | 259 | { |
260 | if ( !i ) | 260 | if ( !i ) |
261 | return; | 261 | return; |
262 | emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); | 262 | emit fileSelected( ( (ImageFileSelectorItem*)i )->file() ); |
263 | emit closeMe(); | 263 | emit closeMe(); |
264 | } | 264 | } |
265 | 265 | ||
266 | void ImageFileSelector::thumbClicked(const DocLnk &f) | 266 | void ImageFileSelector::thumbClicked(const DocLnk &f) |
267 | { | 267 | { |
268 | emit fileSelected( f ); | 268 | emit fileSelected( f ); |
269 | emit closeMe(); | 269 | emit closeMe(); |
270 | } | 270 | } |
271 | 271 | ||
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index ba76e57..02a1d91 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -215,194 +215,194 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | |||
215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) | 215 | : QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE ) |
216 | { | 216 | { |
217 | setCaption( tr("Image Viewer") ); | 217 | setCaption( tr("Image Viewer") ); |
218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 218 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
219 | 219 | ||
220 | 220 | ||
221 | Config cfg("Image Viewer"); | 221 | Config cfg("Image Viewer"); |
222 | cfg.setGroup("Image Viewer"); | 222 | cfg.setGroup("Image Viewer"); |
223 | 223 | ||
224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); | 224 | showThumbView=cfg.readBoolEntry("ShowThumbnails",false); |
225 | isSized=cfg.readBoolEntry("SizeToScreen",true); | 225 | isSized=cfg.readBoolEntry("SizeToScreen",true); |
226 | 226 | ||
227 | isFullScreen = FALSE; | 227 | isFullScreen = FALSE; |
228 | 228 | ||
229 | setToolBarsMovable( FALSE ); | 229 | setToolBarsMovable( FALSE ); |
230 | 230 | ||
231 | toolBar = new QToolBar( this ); | 231 | toolBar = new QToolBar( this ); |
232 | toolBar->setHorizontalStretchable( TRUE ); | 232 | toolBar->setHorizontalStretchable( TRUE ); |
233 | 233 | ||
234 | menuBar = new QMenuBar( toolBar ); | 234 | menuBar = new QMenuBar( toolBar ); |
235 | 235 | ||
236 | current=menuBar; | 236 | current=menuBar; |
237 | 237 | ||
238 | 238 | ||
239 | 239 | ||
240 | fileMenuFile = new QPopupMenu(this); | 240 | fileMenuFile = new QPopupMenu(this); |
241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); | 241 | //menuBarmenubarFile->insertItem( tr("File"), fileMenu ); |
242 | fileMenuFile->insertItem(tr("Open"), | 242 | fileMenuFile->insertItem(tr("Open"), |
243 | this, SLOT(openFile()), 0); | 243 | this, SLOT(openFile()), 0); |
244 | 244 | ||
245 | viewMenuFile = new QPopupMenu( this ); | 245 | viewMenuFile = new QPopupMenu( this ); |
246 | //menubarFile->insertItem( tr("View"), viewMenu ); | 246 | //menubarFile->insertItem( tr("View"), viewMenu ); |
247 | viewMenuFile->insertItem( tr("Thumbnail View"), | 247 | viewMenuFile->insertItem( tr("Thumbnail View"), |
248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); | 248 | this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS ); |
249 | 249 | ||
250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); | 250 | viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView ); |
251 | 251 | ||
252 | 252 | ||
253 | 253 | ||
254 | 254 | ||
255 | optionsMenuFile = new QPopupMenu( this); | 255 | optionsMenuFile = new QPopupMenu( this); |
256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); | 256 | //menubarFile->insertItem( tr("Options"),optionsMenu ); |
257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), | 257 | slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ), |
258 | QString::null, 0, this, 0 ); | 258 | QString::null, 0, this, 0 ); |
259 | slideAction->setToggleAction( TRUE ); | 259 | slideAction->setToggleAction( TRUE ); |
260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); | 260 | connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) ); |
261 | slideAction->addTo( optionsMenuFile); | 261 | slideAction->addTo( optionsMenuFile); |
262 | // slideAction->addTo( toolBar ); | 262 | // slideAction->addTo( toolBar ); |
263 | 263 | ||
264 | 264 | ||
265 | // optionsMenuFile->insertItem( tr("Slideshow") ); | 265 | // optionsMenuFile->insertItem( tr("Slideshow") ); |
266 | optionsMenuFile->insertSeparator(); | 266 | optionsMenuFile->insertSeparator(); |
267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); | 267 | optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0); |
268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); | 268 | // optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0); |
269 | 269 | ||
270 | QStrList fmt = QImage::outputFormats(); | 270 | QStrList fmt = QImage::outputFormats(); |
271 | 271 | ||
272 | 272 | ||
273 | fileMenuView = new QPopupMenu( this ); | 273 | fileMenuView = new QPopupMenu( this ); |
274 | //menubarView->insertItem( tr("File"),fileMenu ); | 274 | //menubarView->insertItem( tr("File"),fileMenu ); |
275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); | 275 | fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 ); |
276 | fileMenuView->insertSeparator(); | 276 | fileMenuView->insertSeparator(); |
277 | 277 | ||
278 | viewMenuView = new QPopupMenu(this ); | 278 | viewMenuView = new QPopupMenu(this ); |
279 | viewMenuView->setCheckable ( true ); | 279 | viewMenuView->setCheckable ( true ); |
280 | 280 | ||
281 | //menubarView->insertItem( tr("View"),viewMenu ); | 281 | //menubarView->insertItem( tr("View"),viewMenu ); |
282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 282 | viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 283 | viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
284 | 284 | ||
285 | stack = new QWidgetStack( this ); | 285 | stack = new QWidgetStack( this ); |
286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 286 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
287 | setCentralWidget( stack ); | 287 | setCentralWidget( stack ); |
288 | 288 | ||
289 | 289 | ||
290 | imagePanel = new ImagePane( stack ); | 290 | imagePanel = new ImagePane( stack ); |
291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 291 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
292 | 292 | ||
293 | 293 | ||
294 | ImageFileSelector::CURRENT_VIEW cv; | 294 | ImageFileSelector::CURRENT_VIEW cv; |
295 | if(showThumbView) | 295 | if(showThumbView) |
296 | cv=ImageFileSelector::THUMBNAIL; | 296 | cv=ImageFileSelector::THUMBNAIL; |
297 | else | 297 | else |
298 | cv=ImageFileSelector::DETAILED; | 298 | cv=ImageFileSelector::DETAILED; |
299 | 299 | ||
300 | qDebug("cv = %d",cv); | 300 | qDebug("cv = %d",cv); |
301 | 301 | ||
302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); | 302 | fileSelector = new ImageFileSelector( cv,stack, "fs"); |
303 | 303 | ||
304 | //switchThumbView(); | 304 | //switchThumbView(); |
305 | 305 | ||
306 | 306 | ||
307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); | 307 | //fileSelector = new ImageFileSelector("image/*", stack, "fs"); |
308 | //fileSelector->setNewVisible(FALSE); | 308 | //fileSelector->setNewVisible(FALSE); |
309 | //fileSelector->setCloseVisible(FALSE); | 309 | //fileSelector->setCloseVisible(FALSE); |
310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 310 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
311 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), | 311 | connect( fileSelector, SIGNAL( fileSelected(const DocLnk&) ), |
312 | this, SLOT( openFile( const DocLnk & ) ) ); | 312 | this, SLOT( openFile(const DocLnk&) ) ); |
313 | 313 | ||
314 | imageList = fileSelector->fileList(); | 314 | imageList = fileSelector->fileList(); |
315 | slideAction->setEnabled( imageList.count() != 0); | 315 | slideAction->setEnabled( imageList.count() != 0); |
316 | 316 | ||
317 | iconToolBar = new QToolBar(this); | 317 | iconToolBar = new QToolBar(this); |
318 | 318 | ||
319 | QAction *a; | 319 | QAction *a; |
320 | 320 | ||
321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 321 | a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
323 | a->addTo( fileMenuView); | 323 | a->addTo( fileMenuView); |
324 | a->addTo( iconToolBar ); | 324 | a->addTo( iconToolBar ); |
325 | 325 | ||
326 | 326 | ||
327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 327 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 328 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
329 | a->addTo( iconToolBar ); | 329 | a->addTo( iconToolBar ); |
330 | a->addTo( viewMenuView ); | 330 | a->addTo( viewMenuView ); |
331 | 331 | ||
332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 332 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
334 | a->addTo( iconToolBar ); | 334 | a->addTo( iconToolBar ); |
335 | a->addTo( viewMenuView ); | 335 | a->addTo( viewMenuView ); |
336 | 336 | ||
337 | 337 | ||
338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); | 338 | a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0); |
339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); | 339 | connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) ); |
340 | //a->addTo( iconToolBar ); | 340 | //a->addTo( iconToolBar ); |
341 | a->addTo( viewMenuView ); | 341 | a->addTo( viewMenuView ); |
342 | 342 | ||
343 | 343 | ||
344 | 344 | ||
345 | viewMenuView->insertSeparator(); | 345 | viewMenuView->insertSeparator(); |
346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); | 346 | viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0); |
347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); | 347 | viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE); |
348 | viewMenuView->insertSeparator(); | 348 | viewMenuView->insertSeparator(); |
349 | 349 | ||
350 | 350 | ||
351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); | 351 | sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true); |
352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); | 352 | connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) ); |
353 | sss->addTo( iconToolBar ); | 353 | sss->addTo( iconToolBar ); |
354 | sss->addTo( viewMenuView ); | 354 | sss->addTo( viewMenuView ); |
355 | 355 | ||
356 | sss->setOn(isSized); | 356 | sss->setOn(isSized); |
357 | viewMenuView->insertSeparator(); | 357 | viewMenuView->insertSeparator(); |
358 | 358 | ||
359 | 359 | ||
360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), | 360 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), |
361 | QString::null, 0, this, 0 ); | 361 | QString::null, 0, this, 0 ); |
362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 362 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
363 | a->addTo( iconToolBar ); | 363 | a->addTo( iconToolBar ); |
364 | a->addTo( viewMenuView); | 364 | a->addTo( viewMenuView); |
365 | 365 | ||
366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), | 366 | a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ), |
367 | QString::null, 0, this, 0 ); | 367 | QString::null, 0, this, 0 ); |
368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); | 368 | connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) ); |
369 | a->addTo( iconToolBar ); | 369 | a->addTo( iconToolBar ); |
370 | a->addTo( viewMenuView); | 370 | a->addTo( viewMenuView); |
371 | 371 | ||
372 | 372 | ||
373 | Config config( "ImageViewer" ); | 373 | Config config( "ImageViewer" ); |
374 | config.setGroup( "SlideShow" ); | 374 | config.setGroup( "SlideShow" ); |
375 | slideDelay = config.readNumEntry( "Delay", 2); | 375 | slideDelay = config.readNumEntry( "Delay", 2); |
376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); | 376 | slideRepeat = config.readBoolEntry( "Repeat", FALSE ); |
377 | slideReverse = config.readBoolEntry("Reverse", FALSE); | 377 | slideReverse = config.readBoolEntry("Reverse", FALSE); |
378 | 378 | ||
379 | config.setGroup("Default"); | 379 | config.setGroup("Default"); |
380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); | 380 | rotateOnLoad = config.readBoolEntry("Rotate", FALSE); |
381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); | 381 | fastLoad = config.readBoolEntry("FastLoad", TRUE); |
382 | slideTimer = new QTimer( this ); | 382 | slideTimer = new QTimer( this ); |
383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); | 383 | connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) ); |
384 | 384 | ||
385 | switchToFileSelector(); | 385 | switchToFileSelector(); |
386 | 386 | ||
387 | setMouseTracking( TRUE ); | 387 | setMouseTracking( TRUE ); |
388 | 388 | ||
389 | 389 | ||
390 | } | 390 | } |
391 | 391 | ||
392 | ImageViewer::~ImageViewer() | 392 | ImageViewer::~ImageViewer() |
393 | { | 393 | { |
394 | Config cfg("Image Viewer"); | 394 | Config cfg("Image Viewer"); |
395 | cfg.setGroup("Image Viewer"); | 395 | cfg.setGroup("Image Viewer"); |
396 | 396 | ||
397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); | 397 | cfg.writeEntry("ShowThumbnails",(int)showThumbView); |
398 | cfg.writeEntry("SizeToScreen",(int)isSized); | 398 | cfg.writeEntry("SizeToScreen",(int)isSized); |
399 | 399 | ||
400 | cfg.setGroup( "SlideShow" ); | 400 | cfg.setGroup( "SlideShow" ); |
401 | cfg.writeEntry( "Delay", slideDelay); | 401 | cfg.writeEntry( "Delay", slideDelay); |
402 | cfg.writeEntry( "Repeat", slideRepeat ); | 402 | cfg.writeEntry( "Repeat", slideRepeat ); |
403 | cfg.writeEntry("Reverse", slideReverse); | 403 | cfg.writeEntry("Reverse", slideReverse); |
404 | 404 | ||
405 | cfg.setGroup("Default"); | 405 | cfg.setGroup("Default"); |
406 | cfg.writeEntry("Rotate", rotateOnLoad); | 406 | cfg.writeEntry("Rotate", rotateOnLoad); |
407 | cfg.writeEntry("FastLoad", fastLoad); | 407 | cfg.writeEntry("FastLoad", fastLoad); |
408 | 408 | ||