7
7
* Description : image files selector dialog.
9
* Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
9
* Copyright (C) 2008-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
11
* This program is free software; you can redistribute it
12
12
* and/or modify it under the terms of the GNU General
56
class ImageDialogPreviewPrivate
56
class ImageDialogPreview::ImageDialogPreviewPrivate
61
ImageDialogPreviewPrivate()
61
ImageDialogPreviewPrivate() :
73
73
DMetadata metaIface;
75
ThumbnailLoadThread *thumbLoadThread;
75
ThumbnailLoadThread* thumbLoadThread;
78
ImageDialogPreview::ImageDialogPreview(QWidget *parent)
79
: KPreviewWidgetBase(parent),
80
d(new ImageDialogPreviewPrivate)
78
ImageDialogPreview::ImageDialogPreview(QWidget* parent)
79
: KPreviewWidgetBase(parent),
80
d(new ImageDialogPreviewPrivate)
82
82
d->thumbLoadThread = ThumbnailLoadThread::defaultThread();
84
QVBoxLayout *vlay = new QVBoxLayout(this);
84
QVBoxLayout* vlay = new QVBoxLayout(this);
85
85
d->imageLabel = new QLabel(this);
86
86
d->imageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
87
87
d->imageLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
139
140
d->metaIface.load(d->currentURL.toLocalFile());
140
141
PhotoInfoContainer info = d->metaIface.getPhotographInformation();
141
143
if (!info.isEmpty())
143
145
DToolTipStyleSheet cnt;
144
146
QString identify("<qt><center>");
145
147
QString make, model, dateTime, aperture, focalLength, exposureTime, sensitivity;
147
if (info.make.isEmpty()) make = cnt.unavailable;
148
else make = info.make;
150
if (info.model.isEmpty()) model = cnt.unavailable;
151
else model = info.model;
153
if (!info.dateTime.isValid()) dateTime = cnt.unavailable;
154
else dateTime = KGlobal::locale()->formatDateTime(info.dateTime, KLocale::ShortDate, true);
156
if (info.aperture.isEmpty()) aperture = cnt.unavailable;
157
else aperture = info.aperture;
159
if (info.focalLength.isEmpty()) focalLength = cnt.unavailable;
160
else focalLength = info.focalLength;
162
if (info.exposureTime.isEmpty()) exposureTime = cnt.unavailable;
163
else exposureTime = info.exposureTime;
165
if (info.sensitivity.isEmpty()) sensitivity = cnt.unavailable;
166
else sensitivity = i18n("%1 ISO", info.sensitivity);
149
if (info.make.isEmpty())
151
make = cnt.unavailable;
158
if (info.model.isEmpty())
160
model = cnt.unavailable;
167
if (!info.dateTime.isValid())
169
dateTime = cnt.unavailable;
173
dateTime = KGlobal::locale()->formatDateTime(info.dateTime, KLocale::ShortDate, true);
176
if (info.aperture.isEmpty())
178
aperture = cnt.unavailable;
182
aperture = info.aperture;
185
if (info.focalLength.isEmpty())
187
focalLength = cnt.unavailable;
191
focalLength = info.focalLength;
194
if (info.exposureTime.isEmpty())
196
exposureTime = cnt.unavailable;
200
exposureTime = info.exposureTime;
203
if (info.sensitivity.isEmpty())
205
sensitivity = cnt.unavailable;
209
sensitivity = i18n("%1 ISO", info.sensitivity);
168
212
identify += "<table cellspacing=0 cellpadding=0>";
169
213
identify += cnt.cellBeg + i18n("<i>Make:</i>") + cnt.cellMid + make + cnt.cellEnd;
230
278
ImageDialog::ImageDialog(QWidget* parent, const KUrl& url, bool singleSelect, const QString& caption)
231
: d(new ImageDialogPrivate)
279
: d(new ImageDialogPrivate)
233
281
d->singleSelect = singleSelect;
251
299
kDebug() << "file formats=" << d->fileFormats;
253
301
QPointer<KFileDialog> dlg = new KFileDialog(url, d->fileFormats, parent);
254
ImageDialogPreview *preview = new ImageDialogPreview(dlg);
302
ImageDialogPreview* preview = new ImageDialogPreview(dlg);
255
303
dlg->setPreviewWidget(preview);
256
304
dlg->setOperationMode(KFileDialog::Opening);
258
306
if (d->singleSelect)
260
308
dlg->setMode(KFile::File);
261
if (caption.isEmpty()) dlg->setCaption(i18n("Select an Image"));
262
else dlg->setWindowTitle(caption);
310
if (caption.isEmpty())
312
dlg->setCaption(i18n("Select an Image"));
316
dlg->setWindowTitle(caption);
264
320
d->url = dlg->selectedUrl();
268
324
dlg->setMode(KFile::Files);
269
if (caption.isEmpty()) dlg->setCaption(i18n("Select Images"));
270
else dlg->setWindowTitle(caption);
326
if (caption.isEmpty())
328
dlg->setCaption(i18n("Select Images"));
332
dlg->setWindowTitle(caption);
272
336
d->urls = dlg->selectedUrls();
302
367
KUrl::List ImageDialog::getImageURLs(QWidget* parent, const KUrl& url, const QString& caption)
304
369
ImageDialog dlg(parent, url, false, caption);
305
371
if (!dlg.urls().isEmpty())
306
373
return dlg.urls();
308
377
return KUrl::List();
312
381
KUrl ImageDialog::getImageURL(QWidget* parent, const KUrl& url, const QString& caption)
314
383
ImageDialog dlg(parent, url, true, caption);
315
385
if (dlg.url() != KUrl())
316
387
return dlg.url();
321
395
} // namespace Digikam