Fix regressions
[kphotoalbum.git] / Viewer / ViewerWidget.h
blob1af545c1d25678ab61eb587209966ea6fe8e3ed6
1 /* Copyright (C) 2003-2006 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #ifndef VIEWER_H
20 #define VIEWER_H
22 #include <QStackedWidget>
23 #include <qimage.h>
24 #include <QPixmap>
25 #include <QMap>
26 #include "DB/ImageInfoPtr.h"
27 #include "DB/Result.h"
28 #include <config-kpa-exiv2.h>
30 class QKeyEvent;
31 class QResizeEvent;
32 class QWheelEvent;
33 class QContextMenuEvent;
34 class QStackedWidget;
35 class KActionCollection;
36 class QMenu;
37 class KAction;
39 namespace DB { class ImageInfo; class ResultId; }
40 namespace MainWindow { class ExternalPopup; class CategoryImagePopup; }
42 namespace Viewer
44 class VideoDisplay;
45 class ImageDisplay;
46 class TextDisplay;
47 class Display;
48 class SpeedDisplay;
49 class InfoBox;
51 class ViewerWidget :public QStackedWidget
53 Q_OBJECT
54 public:
55 enum UsageType { InlineViewer, ViewerWindow };
57 ViewerWidget( UsageType type = ViewerWindow,
58 QMap<Qt::Key, QPair<QString,QString> > *macroStore = 0);
59 ~ViewerWidget();
60 static ViewerWidget* latest();
61 void load( const QStringList& list, int index = 0 );
62 void infoBoxMove();
63 bool showingFullScreen() const;
64 void setShowFullScreen( bool on );
65 void show( bool slideShow );
66 KActionCollection* actions();
68 public slots:
69 virtual bool close(bool alsoDelete = false );
70 void updateInfoBox();
71 void test();
72 void moveInfoBox( int );
73 void stopPlayback();
75 signals:
76 void rotated();
77 void soughtTo( const DB::ResultId& id );
79 protected:
80 OVERRIDE void contextMenuEvent ( QContextMenuEvent * e );
81 OVERRIDE void resizeEvent( QResizeEvent* );
82 OVERRIDE void keyPressEvent( QKeyEvent* );
83 OVERRIDE void wheelEvent( QWheelEvent* event );
85 void moveInfoBox();
86 void setAsWallpaper(int mode);
88 void load();
89 void setupContextMenu();
90 void createShowContextMenu();
91 void createWallPaperMenu();
92 void createInvokeExternalMenu();
93 void createRotateMenu();
94 void createSkipMenu();
95 void createZoomMenu();
96 void createSlideShowMenu();
97 void createVideoMenu();
98 void createCategoryImageMenu();
99 void createFilterMenu();
100 void changeSlideShowInterval( int delta );
101 void createVideoViewer();
103 DB::ImageInfoPtr currentInfo() const;
104 friend class InfoBox;
106 private:
107 void showNextN(int);
108 void showPrevN(int);
109 int find_tag_in_list(const QStringList &list, QString &namefound);
111 protected slots:
112 void showNext();
113 void showNext10();
114 void showNext100();
115 void showNext1000();
116 void showPrev();
117 void showPrev10();
118 void showPrev100();
119 void showPrev1000();
120 void showFirst();
121 void showLast();
122 void deleteCurrent();
123 void removeCurrent();
124 void rotate90();
125 void rotate180();
126 void rotate270();
127 void toggleFullScreen();
128 void slotStartStopSlideShow();
129 void slotSlideShowNext();
130 void slotSlideShowNextFromTimer();
131 void slotSlideShowFaster();
132 void slotSlideShowSlower();
133 void editImage();
134 void filterNone();
135 void filterSelected();
136 void filterBW();
137 void filterContrastStretch();
138 void filterHistogramEqualization();
139 void filterMono();
140 void slotSetStackHead();
141 void updateCategoryConfig();
142 void slotSetWallpaperC();
143 void slotSetWallpaperT();
144 void slotSetWallpaperCT();
145 void slotSetWallpaperCM();
146 void slotSetWallpaperTM();
147 void slotSetWallpaperS();
148 void slotSetWallpaperCAF();
149 void populateExternalPopup();
150 void populateCategoryImagePopup();
151 void videoStopped();
152 void showExifViewer();
153 void zoomIn();
154 void zoomOut();
155 void zoomFull();
156 void zoomPixelForPixel();
158 /** Set the current window title (filename) and add the given detail */
159 void setCaptionWithDetail( const QString& detail );
161 private:
162 static ViewerWidget* _latest;
164 QList<KAction*> _forwardActions;
165 QList<KAction*> _backwardActions;
167 KAction* _startStopSlideShow;
168 KAction* _slideShowRunFaster;
169 KAction* _slideShowRunSlower;
170 KAction* _setStackHead;
171 KAction* _filterNone;
172 KAction* _filterSelected;
173 KAction* _filterBW;
174 KAction* _filterContrastStretch;
175 KAction* _filterHistogramEqualization;
176 KAction* _filterMono;
178 Display* _display;
179 ImageDisplay* _imageDisplay;
180 VideoDisplay* _videoDisplay;
181 TextDisplay* _textDisplay;
183 QStringList _list;
184 DB::Result _removed;
185 int _current;
186 QRect _textRect;
187 QMenu* _popup;
188 QMenu* _rotateMenu;
189 QMenu* _wallpaperMenu;
190 QMenu* _filterMenu;
191 MainWindow::ExternalPopup* _externalPopup;
192 MainWindow::CategoryImagePopup* _categoryImagePopup;
193 int _width, _height;
194 QPixmap _pixmap;
196 KAction* _delete;
197 #ifdef HAVE_EXIV2
198 KAction* _showExifViewer;
199 #endif
201 InfoBox* _infoBox;
202 QImage _currentImage;
204 bool _showingFullScreen;
206 int _slideShowPause;
207 SpeedDisplay* _speedDisplay;
208 KActionCollection* _actions;
209 bool _forward;
210 QTimer* _slideShowTimer;
211 bool _isRunningSlideShow;
213 QList<QAction*> _videoActions;
214 KAction* _stop;
215 KAction* _playPause;
216 bool _videoPlayerStoppedManually;
217 UsageType _type;
219 enum InputMode { InACategory, AlwaysStartWithCategory };
221 InputMode _currentInputMode;
222 QString _currentInput;
223 QString _currentCategory;
224 QString _currentInputList;
226 QString _lastFound;
227 QString _lastCategory;
228 QMap<Qt::Key, QPair<QString,QString> >* _inputMacros;
229 QMap<Qt::Key, QPair<QString,QString> >* _myInputMacros;
234 #endif /* VIEWER_H */