author | warmi <warmi> | 2002-08-15 03:19:48 (UTC) |
---|---|---|
committer | warmi <warmi> | 2002-08-15 03:19:48 (UTC) |
commit | 70d4827ec37cce74180c687eab53f9324756d739 (patch) (unidiff) | |
tree | e08a85c79bc82867e3e2ca08026867301f52ddbe | |
parent | acdedf093413a37a3e2c1ab5b12c1ab0a95b670b (diff) | |
download | opie-70d4827ec37cce74180c687eab53f9324756d739.zip opie-70d4827ec37cce74180c687eab53f9324756d739.tar.gz opie-70d4827ec37cce74180c687eab53f9324756d739.tar.bz2 |
Bunch of new GUI features ( brightness control, ability to view unscaled images ..)
Qte image handling issues are still not fixed though.
-rw-r--r-- | noncore/multimedia/showimg/showimg.h | 215 |
1 files changed, 185 insertions, 30 deletions
diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h index 71003b1..0d3bc7d 100644 --- a/noncore/multimedia/showimg/showimg.h +++ b/noncore/multimedia/showimg/showimg.h | |||
@@ -1,143 +1,298 @@ | |||
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> | ||
30 | #include <qdialog.h> | ||
31 | #include <qstringlist.h> | ||
29 | 32 | ||
30 | 33 | class QPEToolBar; | |
31 | class QMenuBar; | 34 | class QPEMenuBar; |
32 | class QPopupMenu; | 35 | class QPopupMenu; |
33 | class QWidgetStack; | 36 | class QWidgetStack; |
34 | class FileSelector; | 37 | class FileSelector; |
35 | class DocLnk; | 38 | class DocLnk; |
39 | class QLabel; | ||
40 | class QAction; | ||
41 | class QSpinBox; | ||
42 | class ImageFileSelector; | ||
43 | |||
36 | 44 | ||
37 | 45 | ||
38 | class ImageWidget : public QWidget | 46 | class ImageWidget : public QWidget |
39 | { | 47 | { |
40 | Q_OBJECT | 48 | Q_OBJECT |
41 | public: | 49 | public: |
42 | ImageWidget( QWidget *parent=0 ) : QWidget( parent ) { } | 50 | ImageWidget( |
43 | ~ImageWidget() { } | 51 | QWidget *parent=0 |
52 | ) : QWidget( parent ) | ||
53 | { | ||
54 | setBackgroundMode(NoBackground); | ||
55 | } | ||
56 | ~ImageWidget() | ||
57 | { | ||
58 | |||
59 | } | ||
44 | 60 | ||
45 | void setPixmap( const QPixmap &pm ) { pixmap = pm; } | 61 | void setPixmap( const QPixmap &pm ) |
62 | { | ||
63 | pixmap = pm; | ||
64 | show(); | ||
65 | } | ||
46 | 66 | ||
47 | signals: | 67 | signals: |
48 | void clicked(); | 68 | void clicked(); |
49 | 69 | ||
50 | protected: | 70 | protected: |
51 | void paintEvent( QPaintEvent * ); | 71 | void paintEvent( QPaintEvent * ); |
52 | void mouseReleaseEvent(QMouseEvent* event); | 72 | void mouseReleaseEvent(QMouseEvent* event); |
53 | 73 | ||
54 | private: | 74 | private: |
55 | QPixmap pixmap; | 75 | QPixmap pixmap; |
56 | }; | 76 | }; |
57 | 77 | ||
78 | class InfoDialog:public QDialog | ||
79 | { | ||
80 | Q_OBJECT | ||
81 | |||
82 | public: | ||
83 | |||
84 | static void displayInfo(const QString &caption, const QStringList text, QWidget *parent); | ||
85 | |||
86 | private: | ||
87 | |||
88 | InfoDialog(const QString &caption,const QStringList text, QWidget *parent); | ||
89 | |||
90 | }; | ||
91 | |||
92 | class ControlsDialog:public QDialog | ||
93 | { | ||
94 | Q_OBJECT | ||
95 | |||
96 | public: | ||
97 | ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent); | ||
98 | |||
99 | |||
100 | private slots: | ||
101 | |||
102 | void bValueChanged(int); | ||
103 | void accept(); | ||
104 | |||
105 | |||
106 | private: | ||
107 | ImageWidget *pixmap; | ||
108 | QSpinBox *spb; | ||
109 | QImage img; | ||
110 | int *b; | ||
111 | }; | ||
112 | |||
58 | 113 | ||
59 | class ImagePane : public QWidget | 114 | class ImagePane : public QWidget |
60 | { | 115 | { |
61 | Q_OBJECT | 116 | Q_OBJECT |
62 | public: | 117 | public: |
63 | ImagePane( QWidget *parent=0 ); | 118 | ImagePane( QWidget *parent=0 ); |
64 | ~ImagePane() { } | 119 | ~ImagePane() |
120 | { | ||
121 | |||
122 | } | ||
65 | 123 | ||
66 | void showStatus(); | 124 | //void showStatus(); |
67 | void hideStatus(); | 125 | //void hideStatus(); |
68 | QLabel *statusLabel() { return status; } | 126 | //QLabel *statusLabel() |
127 | //{ | ||
128 | // return status; | ||
129 | //} | ||
69 | void setPixmap( const QPixmap &pm ); | 130 | void setPixmap( const QPixmap &pm ); |
70 | 131 | ||
71 | signals: | 132 | |
133 | int paneWidth() const | ||
134 | { | ||
135 | return image->visibleWidth(); | ||
136 | } | ||
137 | |||
138 | int paneHeight() const | ||
139 | { | ||
140 | return image->visibleHeight(); | ||
141 | } | ||
142 | |||
143 | void setPosition(int x, int y) | ||
144 | { | ||
145 | image->setContentsPos (x,y ); | ||
146 | } | ||
147 | |||
148 | void disable() | ||
149 | { | ||
150 | pic->hide(); | ||
151 | } | ||
152 | |||
153 | signals: | ||
72 | void clicked(); | 154 | void clicked(); |
73 | 155 | ||
74 | private: | 156 | private: |
75 | ImageWidget*image; | 157 | QScrollView *image; |
76 | QLabel*status; | 158 | ImageWidget *pic; |
77 | QVBoxLayout *vb; | 159 | QVBoxLayout *vb; |
78 | 160 | ||
79 | private slots: | 161 | private slots: |
80 | void imageClicked(); | 162 | void imageClicked(); |
81 | }; | 163 | }; |
82 | 164 | ||
83 | 165 | ||
84 | class ImageViewer : public QMainWindow | 166 | class ImageViewer : public QMainWindow |
85 | { | 167 | { |
86 | Q_OBJECT | 168 | Q_OBJECT |
87 | public: | 169 | public: |
88 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); | 170 | ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 ); |
89 | ~ImageViewer(); | 171 | ~ImageViewer(); |
90 | 172 | ||
91 | void loadImage( const char *fileName ); | 173 | void loadImage( const char *fileName ); |
92 | void show(const QString& fileref); | 174 | void show(const QString& fileref); |
93 | void show(); | 175 | void show(); |
94 | 176 | ||
177 | |||
178 | enum INFO_STRINGS | ||
179 | { | ||
180 | PATH, | ||
181 | FORMAT, | ||
182 | FILE_SIZE, | ||
183 | SIZE, | ||
184 | COLORS, | ||
185 | ALPHA, | ||
186 | LAST | ||
187 | }; | ||
188 | |||
189 | enum RotateDirection | ||
190 | { | ||
191 | Rotate90, Rotate180, Rotate270 | ||
192 | }; | ||
193 | |||
194 | |||
195 | static QImage rotate(QImage &img, RotateDirection r); | ||
196 | static QImage& intensity(QImage &image, float percent); | ||
197 | static QImage& toGray(QImage &image, bool fast = false); | ||
198 | |||
95 | protected: | 199 | protected: |
96 | void resizeEvent( QResizeEvent * ); | 200 | void resizeEvent( QResizeEvent * ); |
97 | void mousePressEvent( QMouseEvent * ); | ||
98 | void mouseMoveEvent( QMouseEvent * ); | ||
99 | void closeEvent( QCloseEvent * ); | 201 | void closeEvent( QCloseEvent * ); |
100 | 202 | ||
101 | private: | 203 | private: |
102 | void updateCaption( QString name ); | 204 | void updateCaption( QString name ); |
103 | bool loadSelected(); | 205 | bool loadSelected(); |
104 | void scale(); | 206 | void scale(); |
105 | void convertEvent( QMouseEvent* e, int& x, int& y ); | ||
106 | bool reconvertImage(); | 207 | bool reconvertImage(); |
107 | int calcHeight(); | 208 | int calcHeight(); |
108 | void setImage(const QImage& newimage); | 209 | void setImage(const QImage& newimage); |
109 | void updateStatus(); | 210 | void updateImageInfo(QString &filePath); |
211 | void switchToFileSelector(); | ||
212 | void switchToImageView(); | ||
213 | |||
214 | void updateImage(); | ||
215 | |||
216 | |||
217 | |||
110 | 218 | ||
111 | private slots: | 219 | private slots: |
220 | |||
221 | void switchThumbView(); | ||
222 | void switchSizeToScreen(); | ||
112 | void setDocument(const QString& fileref); | 223 | void setDocument(const QString& fileref); |
113 | void doDelayedLoad(); | 224 | void doDelayedLoad(); |
114 | void openFile( const DocLnk &file ); | 225 | void openFile( const DocLnk &file ); |
226 | //void openFile(); | ||
115 | void open(); | 227 | void open(); |
116 | void closeFileSelector(); | 228 | void closeFileSelector(); |
117 | void hFlip(); | 229 | void hFlip(); |
118 | void vFlip(); | 230 | void vFlip(); |
119 | void rot180(); | 231 | void rot180(); |
120 | void rot90(); | 232 | void rot90(); |
233 | void rot270(); | ||
121 | void normalView(); | 234 | void normalView(); |
122 | void fullScreen(); | 235 | void fullScreen(); |
236 | void blackAndWhite(); | ||
237 | void displayInfoDialog(); | ||
238 | void displayControlsDialog(); | ||
239 | |||
240 | |||
241 | |||
242 | |||
243 | |||
244 | |||
245 | |||
246 | |||
247 | |||
123 | 248 | ||
124 | private: | 249 | private: |
250 | |||
251 | |||
252 | |||
253 | |||
254 | enum MENU_ITEMS | ||
255 | { | ||
256 | SHOW_THUMBNAILS, | ||
257 | SIZE_TO_SCREEN, | ||
258 | BLACKANDWHITE | ||
259 | }; | ||
260 | |||
261 | |||
262 | |||
125 | QString filename; | 263 | QString filename; |
126 | QString delayLoad; | 264 | QString delayLoad; |
127 | QImage image; // the loaded image | 265 | QImage image; // the loaded image |
128 | QPixmap pm; // the converted pixmap | 266 | QPixmap pm; // the converted pixmap |
129 | QPixmap pmScaled; // the scaled pixmap | 267 | QPixmap pmScaled; // the scaled pixmap |
130 | QMenuBar *menubar; | 268 | QPEToolBar *toolBar; |
269 | QPEToolBar *iconToolBar; | ||
270 | QPEMenuBar *menuBar; | ||
271 | QPEMenuBar *current; | ||
272 | |||
273 | |||
274 | QPopupMenu *fileMenuFile; | ||
275 | QPopupMenu *viewMenuFile; | ||
276 | QPopupMenu *optionsMenuFile; | ||
277 | QPopupMenu *fileMenuView; | ||
278 | QPopupMenu *viewMenuView; | ||
279 | |||
280 | QAction *sss; // scale to screen size | ||
281 | |||
282 | QLabel *lab; | ||
131 | ImagePane *imagePanel; | 283 | ImagePane *imagePanel; |
132 | QToolBar *toolBar; | ||
133 | QWidgetStack *stack; | 284 | QWidgetStack *stack; |
134 | FileSelector *fileSelector; | 285 | //FileSelector *fileSelector; |
135 | int pickx, picky; | 286 | ImageFileSelector *fileSelector; |
136 | int clickx, clicky; | ||
137 | bool isFullScreen; | 287 | bool isFullScreen; |
138 | bool bFromDocView; // a flag to indicate whether or not we were | 288 | bool isSized; // true if image is to be resized to fit the window size |
139 | // launched from the document view... | 289 | bool bFromDocView; // a flag to indicate whether or not we were |
290 | // launched from the document view... | ||
291 | |||
292 | bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view | ||
293 | |||
294 | QString imageInfo[LAST]; | ||
140 | }; | 295 | }; |
141 | 296 | ||
142 | 297 | ||
143 | #endif // SHOWIMG_H | 298 | #endif // SHOWIMG_H |