1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2006-06-13
* Description : A widget stack to embedded album content view
* or the current image preview.
*
* Copyright (C) 2006-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// TQt includes.
#include <tqfileinfo.h>
// KDE includes.
#include <kurl.h>
#include <tdehtmlview.h>
// Local includes.
#include "albumsettings.h"
#include "albumiconview.h"
#include "imagepreviewview.h"
#include "welcomepageview.h"
#include "mediaplayerview.h"
#include "albumwidgetstack.h"
#include "albumwidgetstack.moc"
namespace Digikam
{
class AlbumWidgetStackPriv
{
public:
AlbumWidgetStackPriv()
{
albumIconView = 0;
imagePreviewView = 0;
welcomePageView = 0;
mediaPlayerView = 0;
}
AlbumIconView *albumIconView;
ImagePreviewView *imagePreviewView;
WelcomePageView *welcomePageView;
MediaPlayerView *mediaPlayerView;
};
AlbumWidgetStack::AlbumWidgetStack(TQWidget *parent)
: TQWidgetStack(parent, 0, TQt::WDestructiveClose)
{
d = new AlbumWidgetStackPriv;
d->albumIconView = new AlbumIconView(this);
d->imagePreviewView = new ImagePreviewView(this);
d->welcomePageView = new WelcomePageView(this);
d->mediaPlayerView = new MediaPlayerView(this);
addWidget(d->albumIconView, PreviewAlbumMode);
addWidget(d->imagePreviewView, PreviewImageMode);
addWidget(d->welcomePageView->view(), WelcomePageMode);
addWidget(d->mediaPlayerView, MediaPlayerMode);
setPreviewMode(PreviewAlbumMode);
// -----------------------------------------------------------------
connect(d->imagePreviewView, TQ_SIGNAL(signalNextItem()),
this, TQ_SIGNAL(signalNextItem()));
connect(d->imagePreviewView, TQ_SIGNAL(signalPrevItem()),
this, TQ_SIGNAL(signalPrevItem()));
connect(d->imagePreviewView, TQ_SIGNAL(signalEditItem()),
this, TQ_SIGNAL(signalEditItem()));
connect(d->imagePreviewView, TQ_SIGNAL(signalDeleteItem()),
this, TQ_SIGNAL(signalDeleteItem()));
connect(d->imagePreviewView, TQ_SIGNAL(signalBack2Album()),
this, TQ_SIGNAL(signalBack2Album()));
connect(d->imagePreviewView, TQ_SIGNAL(signalSlideShow()),
this, TQ_SIGNAL(signalSlideShow()));
connect(d->imagePreviewView, TQ_SIGNAL(signalZoomFactorChanged(double)),
this, TQ_SLOT(slotZoomFactorChanged(double)));
connect(d->imagePreviewView, TQ_SIGNAL(signalInsert2LightTable()),
this, TQ_SIGNAL(signalInsert2LightTable()));
}
AlbumWidgetStack::~AlbumWidgetStack()
{
delete d;
}
void AlbumWidgetStack::slotEscapePreview()
{
if (previewMode() == MediaPlayerMode)
d->mediaPlayerView->escapePreview();
}
AlbumIconView* AlbumWidgetStack::albumIconView()
{
return d->albumIconView;
}
ImagePreviewView* AlbumWidgetStack::imagePreviewView()
{
return d->imagePreviewView;
}
void AlbumWidgetStack::setPreviewItem(ImageInfo* info, ImageInfo *previous, ImageInfo *next)
{
if (!info)
{
if (previewMode() == MediaPlayerMode)
d->mediaPlayerView->setMediaPlayerFromUrl(KURL());
else if (previewMode() == PreviewImageMode)
{
d->imagePreviewView->setImageInfo();
}
}
else
{
AlbumSettings *settings = AlbumSettings::instance();
TQString currentFileExtension = TQFileInfo(info->kurl().path()).extension(false);
TQString mediaplayerfilter = settings->getMovieFileFilter().lower() +
settings->getMovieFileFilter().upper() +
settings->getAudioFileFilter().lower() +
settings->getAudioFileFilter().upper();
if (mediaplayerfilter.contains(currentFileExtension) )
{
setPreviewMode(MediaPlayerMode);
d->mediaPlayerView->setMediaPlayerFromUrl(info->kurl());
}
else
{
// Stop media player if running...
if (previewMode() == MediaPlayerMode)
setPreviewItem();
d->imagePreviewView->setImageInfo(info, previous, next);
// NOTE: No need to toggle imediatly in PreviewImageMode here,
// because we will receive a signal for that when the image preview will be loaded.
// This will prevent a flicker effect with the old image preview loaded in stack.
}
}
}
int AlbumWidgetStack::previewMode(void)
{
return id(visibleWidget());
}
void AlbumWidgetStack::setPreviewMode(int mode)
{
if (mode != PreviewAlbumMode && mode != PreviewImageMode &&
mode != WelcomePageMode && mode != MediaPlayerMode)
return;
if (mode == PreviewAlbumMode || mode == WelcomePageMode)
{
d->albumIconView->setFocus();
setPreviewItem();
raiseWidget(mode);
emit signalToggledToPreviewMode(false);
}
else
{
raiseWidget(mode);
}
}
void AlbumWidgetStack::previewLoaded()
{
emit signalToggledToPreviewMode(true);
}
void AlbumWidgetStack::slotZoomFactorChanged(double z)
{
if (previewMode() == PreviewImageMode)
emit signalZoomFactorChanged(z);
}
void AlbumWidgetStack::slotItemsUpdated(const KURL::List& list)
{
// If item are updated from Icon View, and if we are in Preview Mode,
// We will check if the current item preview need to be reloaded.
if (previewMode() == PreviewAlbumMode ||
previewMode() == WelcomePageMode ||
previewMode() == MediaPlayerMode) // What we can do with media player ?
return;
if (list.contains(imagePreviewView()->getImageInfo()->kurl()))
d->imagePreviewView->reload();
}
void AlbumWidgetStack::increaseZoom()
{
d->imagePreviewView->slotIncreaseZoom();
}
void AlbumWidgetStack::decreaseZoom()
{
d->imagePreviewView->slotDecreaseZoom();
}
void AlbumWidgetStack::zoomTo100Percents()
{
d->imagePreviewView->setZoomFactor(1.0);
}
void AlbumWidgetStack::fitToWindow()
{
d->imagePreviewView->fitToWindow();
}
void AlbumWidgetStack::toggleFitToWindowOr100()
{
d->imagePreviewView->toggleFitToWindowOr100();
}
bool AlbumWidgetStack::maxZoom()
{
return d->imagePreviewView->maxZoom();
}
bool AlbumWidgetStack::minZoom()
{
return d->imagePreviewView->minZoom();
}
void AlbumWidgetStack::setZoomFactor(double z)
{
d->imagePreviewView->setZoomFactor(z);
}
void AlbumWidgetStack::setZoomFactorSnapped(double z)
{
d->imagePreviewView->setZoomFactorSnapped(z);
}
double AlbumWidgetStack::zoomFactor()
{
return d->imagePreviewView->zoomFactor();
}
double AlbumWidgetStack::zoomMin()
{
return d->imagePreviewView->zoomMin();
}
double AlbumWidgetStack::zoomMax()
{
return d->imagePreviewView->zoomMax();
}
} // namespace Digikam
|