summaryrefslogtreecommitdiff
path: root/noncore/unsupported/showimg/showimg.h
Unidiff
Diffstat (limited to 'noncore/unsupported/showimg/showimg.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/showimg/showimg.h289
1 files changed, 289 insertions, 0 deletions
diff --git a/noncore/unsupported/showimg/showimg.h b/noncore/unsupported/showimg/showimg.h
new file mode 100644
index 0000000..9cf9bfd
--- a/dev/null
+++ b/noncore/unsupported/showimg/showimg.h
@@ -0,0 +1,289 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of 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 SHOWIMG_H
22#define SHOWIMG_H
23
24#include <qwidget.h>
25#include <qmainwindow.h>
26#include <qimage.h>
27#include <qlabel.h>
28#include <qlayout.h>
29#include <qscrollview.h>
30#include <qdialog.h>
31#include <qstringlist.h>
32#include <qvaluelist.h>
33#include <qwmatrix.h>
34
35
36class QAction;
37class QToolBar;
38class QMenuBar;
39class QPopupMenu;
40class QWidgetStack;
41class FileSelector;
42class DocLnk;
43class QLabel;
44class QAction;
45class QSpinBox;
46class ImageFileSelector;
47class QTimer;
48
49
50class ImageWidget : public QWidget
51{
52 Q_OBJECT
53 public:
54 ImageWidget( QWidget *parent=0 )
55 : QWidget( parent ) {
56 setBackgroundMode(NoBackground);
57 }
58 ~ImageWidget() { }
59
60 void setPixmap( const QPixmap &pm ) {
61 pixmap = pm;
62 show();
63 }
64
65signals:
66 void clicked();
67
68protected:
69 void paintEvent( QPaintEvent * );
70 void mouseReleaseEvent(QMouseEvent* event);
71
72private:
73 QPixmap pixmap;
74};
75
76class InfoDialog:public QDialog
77{
78 Q_OBJECT
79
80public:
81
82 static void displayInfo(const QString &caption, const QStringList text, QWidget *parent);
83
84private:
85
86 InfoDialog(const QString &caption,const QStringList text, QWidget *parent);
87
88};
89
90class ControlsDialog:public QDialog
91{
92 Q_OBJECT
93
94public:
95 ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent);
96
97
98private slots:
99
100 void bValueChanged(int);
101 void accept();
102
103
104private:
105 ImageWidget *pixmap;
106 QSpinBox *spb;
107 QImage img;
108 int *b;
109};
110
111
112class ImagePane : public QWidget
113{
114 Q_OBJECT
115public:
116 ImagePane( QWidget *parent=0 );
117 ~ImagePane() { }
118
119 //void showStatus();
120 //void hideStatus();
121 //QLabel *statusLabel()
122 //{
123 // return status;
124 //}
125 void setPixmap( const QPixmap &pm );
126
127
128 int paneWidth() const {
129 return image->visibleWidth();
130 }
131
132 int paneHeight() const {
133 return image->visibleHeight();
134 }
135
136 void setPosition(int x, int y) {
137 image->setContentsPos (x,y );
138 }
139
140 void disable() {
141 pic->hide();
142 }
143
144signals:
145 void clicked();
146
147private:
148 QScrollView *image;
149 ImageWidget *pic;
150 QVBoxLayout *vb;
151
152private slots:
153 void imageClicked();
154};
155
156
157class ImageViewer : public QMainWindow
158{
159 Q_OBJECT
160public:
161 static QString appName() { return QString::fromLatin1("showimg"); }
162 ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 );
163 ~ImageViewer();
164
165 void loadImage( const char *fileName );
166 void show(const QString& fileref);
167 void show();
168
169
170 enum INFO_STRINGS {
171 PATH,
172 FORMAT,
173 FILE_SIZE,
174 SIZE,
175 COLORS,
176 ALPHA,
177 LAST
178 };
179
180 enum RotateDirection {
181 Rotate90, Rotate180, Rotate270
182 };
183
184
185 static QImage rotate(QImage &img, RotateDirection r);
186 static QImage& intensity(QImage &image, float percent);
187 static QImage& toGray(QImage &image, bool fast = false);
188 bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view
189
190protected:
191 void resizeEvent( QResizeEvent * );
192 void closeEvent( QCloseEvent * );
193
194private:
195 int imageIndex(void);
196
197 void updateCaption( QString name );
198 bool loadSelected();
199 void scale();
200 bool reconvertImage();
201 int calcHeight();
202 void setImage(const QImage& newimage);
203 void updateImageInfo(QString &filePath);
204 void switchToFileSelector();
205 void switchToImageView();
206
207 void updateImage();
208
209private slots:
210
211 void slideShow( bool on );
212 void help();
213 void slideUpdate();
214 bool nextImage();
215 bool prevImage();
216 void settings();
217
218 void switchThumbView();
219 void switchSizeToScreen();
220 void setDocument(const QString& fileref);
221 void doDelayedLoad();
222 void openFile( const DocLnk &file );
223 void openFile();
224 void open();
225 void closeFileSelector();
226 void hFlip();
227 void vFlip();
228 void rot180();
229 void rot90();
230 void rot270();
231 void normalView();
232 void fullScreen();
233 void stopSlideShow();
234 void blackAndWhite();
235 void displayInfoDialog();
236 void displayControlsDialog();
237private:
238 QWMatrix matrix;
239 bool rotated90;
240 enum MENU_ITEMS {
241 SHOW_THUMBNAILS,
242 SIZE_TO_SCREEN,
243 BLACKANDWHITE
244 };
245
246 QString filename;
247 QString delayLoad;
248 QImage image; // the loaded image
249 QPixmap pm; // the converted pixmap
250 QPixmap pmScaled; // the scaled pixmap
251 QToolBar *toolBar;
252 QToolBar *iconToolBar;
253 QMenuBar *menuBar;
254 QMenuBar *current;
255
256
257 QPopupMenu *fileMenuFile;
258 QPopupMenu *viewMenuFile;
259 QPopupMenu *optionsMenuFile;
260 QPopupMenu *fileMenuView;
261 QPopupMenu *viewMenuView;
262
263 QAction *sss; // scale to screen size
264
265 QLabel *lab;
266 ImagePane *imagePanel;
267 QWidgetStack *stack;
268 //FileSelector *fileSelector;
269 ImageFileSelector *fileSelector;
270 bool isFullScreen;
271 bool isSized; // true if image is to be resized to fit the window size
272 bool bFromDocView; // a flag to indicate whether or not we were
273 // launched from the document view...
274
275 int slideDelay;
276 bool slideRepeat;
277 bool slideReverse; // show slideshow in reverse order
278 bool rotateOnLoad; // rotate by 90 degrees on loading
279 bool fastLoad;
280 QTimer *slideTimer;
281 QValueList<DocLnk> imageList;
282 QAction *slideAction;
283
284
285 QString imageInfo[LAST];
286};
287
288
289#endif // SHOWIMG_H