author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Thu, 08 Apr 2010 14:19:33 +0300 | |
branch | RCL_3 |
changeset 7 | 3f74d0d4af4c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the ActiveQt framework of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:BSD$ |
|
10 |
** You may use this file under the terms of the BSD license as follows: |
|
11 |
** |
|
12 |
** "Redistribution and use in source and binary forms, with or without |
|
13 |
** modification, are permitted provided that the following conditions are |
|
14 |
** met: |
|
15 |
** * Redistributions of source code must retain the above copyright |
|
16 |
** notice, this list of conditions and the following disclaimer. |
|
17 |
** * Redistributions in binary form must reproduce the above copyright |
|
18 |
** notice, this list of conditions and the following disclaimer in |
|
19 |
** the documentation and/or other materials provided with the |
|
20 |
** distribution. |
|
21 |
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor |
|
22 |
** the names of its contributors may be used to endorse or promote |
|
23 |
** products derived from this software without specific prior written |
|
24 |
** permission. |
|
25 |
** |
|
26 |
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
27 |
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
28 |
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
29 |
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
30 |
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
31 |
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
32 |
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
33 |
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
34 |
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
35 |
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 |
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
|
37 |
** $QT_END_LICENSE$ |
|
38 |
** |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
/* |
|
43 |
ORIGINAL COPYRIGHT HEADER |
|
44 |
PictureFlow - animated image show widget |
|
45 |
http://pictureflow.googlecode.com |
|
46 |
||
47 |
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org) |
|
48 |
||
49 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
50 |
of this software and associated documentation files (the "Software"), to deal |
|
51 |
in the Software without restriction, including without limitation the rights |
|
52 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
53 |
copies of the Software, and to permit persons to whom the Software is |
|
54 |
furnished to do so, subject to the following conditions: |
|
55 |
||
56 |
The above copyright notice and this permission notice shall be included in |
|
57 |
all copies or substantial portions of the Software. |
|
58 |
||
59 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
60 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
61 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
62 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
63 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
64 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
65 |
THE SOFTWARE. |
|
66 |
*/ |
|
67 |
||
68 |
#ifndef PICTUREFLOW_H |
|
69 |
#define PICTUREFLOW_H |
|
70 |
||
71 |
#include <QWidget> |
|
72 |
||
73 |
class PictureFlowPrivate; |
|
74 |
||
75 |
/*! |
|
76 |
Class PictureFlow implements an image show widget with animation effect |
|
77 |
like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form |
|
78 |
of slides, one main slide is shown at the center with few slides on |
|
79 |
the left and right sides of the center slide. When the next or previous |
|
80 |
slide is brought to the front, the whole slides flow to the right or |
|
81 |
the right with smooth animation effect; until the new slide is finally |
|
82 |
placed at the center. |
|
83 |
||
84 |
*/ |
|
85 |
class PictureFlow : public QWidget |
|
86 |
{ |
|
87 |
Q_OBJECT |
|
88 |
||
89 |
Q_PROPERTY(int slideCount READ slideCount WRITE setSlideCount) |
|
90 |
Q_PROPERTY(int currentSlide READ currentSlide WRITE setCurrentSlide) |
|
91 |
Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize) |
|
92 |
Q_PROPERTY(int zoomFactor READ zoomFactor WRITE setZoomFactor) |
|
93 |
||
94 |
public: |
|
95 |
/*! |
|
96 |
Creates a new PictureFlow widget. |
|
97 |
*/ |
|
98 |
PictureFlow(QWidget* parent = 0); |
|
99 |
||
100 |
/*! |
|
101 |
Destroys the widget. |
|
102 |
*/ |
|
103 |
~PictureFlow(); |
|
104 |
||
105 |
/*! |
|
106 |
Returns the total number of slides. |
|
107 |
*/ |
|
108 |
int slideCount() const; |
|
109 |
||
110 |
/*! |
|
111 |
Sets the total number of slides. |
|
112 |
*/ |
|
113 |
void setSlideCount(int count); |
|
114 |
||
115 |
/*! |
|
116 |
Returns the dimension of each slide (in pixels). |
|
117 |
*/ |
|
118 |
QSize slideSize() const; |
|
119 |
||
120 |
/*! |
|
121 |
Sets the dimension of each slide (in pixels). |
|
122 |
*/ |
|
123 |
void setSlideSize(QSize size); |
|
124 |
||
125 |
/*! |
|
126 |
Sets the zoom factor (in percent). |
|
127 |
*/ |
|
128 |
void setZoomFactor(int zoom); |
|
129 |
||
130 |
/*! |
|
131 |
Returns the zoom factor (in percent). |
|
132 |
*/ |
|
133 |
int zoomFactor() const; |
|
134 |
||
135 |
/*! |
|
136 |
Clears any caches held to free up memory |
|
137 |
*/ |
|
138 |
void clearCaches(); |
|
139 |
||
140 |
/*! |
|
141 |
Returns QImage of specified slide. |
|
142 |
This function will be called only whenever necessary, e.g. the 100th slide |
|
143 |
will not be retrived when only the first few slides are visible. |
|
144 |
*/ |
|
145 |
virtual QImage slide(int index) const; |
|
146 |
||
147 |
/*! |
|
148 |
Sets an image for specified slide. If the slide already exists, |
|
149 |
it will be replaced. |
|
150 |
*/ |
|
151 |
virtual void setSlide(int index, const QImage& image); |
|
152 |
||
153 |
virtual void setSlideCaption(int index, QString caption); |
|
154 |
||
155 |
/*! |
|
156 |
Sets a pixmap for specified slide. If the slide already exists, |
|
157 |
it will be replaced. |
|
158 |
*/ |
|
159 |
virtual void setSlide(int index, const QPixmap& pixmap); |
|
160 |
||
161 |
/*! |
|
162 |
Returns the index of slide currently shown in the middle of the viewport. |
|
163 |
*/ |
|
164 |
int currentSlide() const; |
|
165 |
||
166 |
public slots: |
|
167 |
||
168 |
/*! |
|
169 |
Sets slide to be shown in the middle of the viewport. No animation |
|
170 |
effect will be produced, unlike using showSlide. |
|
171 |
*/ |
|
172 |
void setCurrentSlide(int index); |
|
173 |
||
174 |
/*! |
|
175 |
Clears images of all slides. |
|
176 |
*/ |
|
177 |
void clear(); |
|
178 |
||
179 |
/*! |
|
180 |
Rerender the widget. Normally this function will be automatically invoked |
|
181 |
whenever necessary, e.g. during the transition animation. |
|
182 |
*/ |
|
183 |
void render(); |
|
184 |
||
185 |
/*! |
|
186 |
Shows previous slide using animation effect. |
|
187 |
*/ |
|
188 |
void showPrevious(); |
|
189 |
||
190 |
/*! |
|
191 |
Shows next slide using animation effect. |
|
192 |
*/ |
|
193 |
void showNext(); |
|
194 |
||
195 |
/*! |
|
196 |
Go to specified slide using animation effect. |
|
197 |
*/ |
|
198 |
void showSlide(int index); |
|
199 |
||
200 |
signals: |
|
201 |
void itemActivated(int index); |
|
202 |
void inputReceived(); |
|
203 |
||
204 |
protected: |
|
205 |
void paintEvent(QPaintEvent *event); |
|
206 |
void keyPressEvent(QKeyEvent* event); |
|
207 |
void mouseMoveEvent(QMouseEvent* event); |
|
208 |
void mousePressEvent(QMouseEvent* event); |
|
209 |
void mouseReleaseEvent(QMouseEvent* event); |
|
210 |
void resizeEvent(QResizeEvent* event); |
|
211 |
void timerEvent(QTimerEvent* event); |
|
212 |
||
213 |
private: |
|
214 |
PictureFlowPrivate* d; |
|
215 |
}; |
|
216 |
||
217 |
#endif // PICTUREFLOW_H |