Diffstat (limited to 'noncore/unsupported/showimg/showimg.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/showimg/showimg.h | 289 |
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 | |||
36 | class QAction; | ||
37 | class QToolBar; | ||
38 | class QMenuBar; | ||
39 | class QPopupMenu; | ||
40 | class QWidgetStack; | ||
41 | class FileSelector; | ||
42 | class DocLnk; | ||
43 | class QLabel; | ||
44 | class QAction; | ||
45 | class QSpinBox; | ||
46 | class ImageFileSelector; | ||
47 | class QTimer; | ||
48 | |||
49 | |||
50 | class 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 | |||
65 | signals: | ||
66 | void clicked(); | ||
67 | |||
68 | protected: | ||
69 | void paintEvent( QPaintEvent * ); | ||
70 | void mouseReleaseEvent(QMouseEvent* event); | ||
71 | |||
72 | private: | ||
73 | QPixmap pixmap; | ||
74 | }; | ||
75 | |||
76 | class InfoDialog:public QDialog | ||
77 | { | ||
78 | Q_OBJECT | ||
79 | |||
80 | public: | ||
81 | |||
82 | static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); | ||
83 | |||
84 | private: | ||
85 | |||
86 | InfoDialog(const QString &caption,const QStringList text, QWidget *parent); | ||
87 | |||
88 | }; | ||
89 | |||
90 | class ControlsDialog:public QDialog | ||
91 | { | ||
92 | Q_OBJECT | ||
93 | |||
94 | public: | ||
95 | ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent); | ||
96 | |||
97 | |||
98 | private slots: | ||
99 | |||
100 | void bValueChanged(int); | ||
101 | void accept(); | ||
102 | |||
103 | |||
104 | private: | ||
105 | ImageWidget *pixmap; | ||
106 | QSpinBox *spb; | ||
107 | QImage img; | ||
108 | int *b; | ||
109 | }; | ||
110 | |||
111 | |||
112 | class ImagePane : public QWidget | ||
113 | { | ||
114 | Q_OBJECT | ||
115 | public: | ||
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 | |||
144 | signals: | ||
145 | void clicked(); | ||
146 | |||
147 | private: | ||
148 | QScrollView *image; | ||
149 | ImageWidget *pic; | ||
150 | QVBoxLayout *vb; | ||
151 | |||
152 | private slots: | ||
153 | void imageClicked(); | ||
154 | }; | ||
155 | |||
156 | |||
157 | class ImageViewer : public QMainWindow | ||
158 | { | ||
159 | Q_OBJECT | ||
160 | public: | ||
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 | |||
190 | protected: | ||
191 | void resizeEvent( QResizeEvent * ); | ||
192 | void closeEvent( QCloseEvent * ); | ||
193 | |||
194 | private: | ||
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 | |||
209 | private 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(); | ||
237 | private: | ||
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 | ||