7
7
* Description : digiKam light table GUI
9
* Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
9
* Copyright (C) 2007-2008 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
58
58
#include "syncjob.h"
59
59
#include "thumbnailsize.h"
60
#include "rawcameradlg.h"
60
61
#include "lighttablepreview.h"
61
62
#include "lighttablewindowprivate.h"
62
63
#include "lighttablewindow.h"
155
156
d->autoSyncPreview = config->readBoolEntry("Auto Sync Preview", true);
156
157
d->fullScreenHideToolBar = config->readBoolEntry("FullScreen Hide ToolBar", false);
157
158
d->previewView->setLoadFullImageSize(config->readBoolEntry("Load Full Image size", false));
162
void LightTableWindow::refreshView()
164
d->leftSidebar->refreshTagsView();
165
d->rightSidebar->refreshTagsView();
160
168
void LightTableWindow::closeEvent(QCloseEvent* e)
178
186
QWidget* centralW = new QWidget(d->hSplitter);
179
187
QVBoxLayout *vlay = new QVBoxLayout(centralW);
180
188
d->vSplitter = new QSplitter(Qt::Vertical, centralW);
181
d->barView = new LightTableBar(d->vSplitter, ThumbBarView::Horizontal,
189
d->barView = new LightTableBar(d->vSplitter, ThumbBarView::Horizontal,
182
190
AlbumSettings::instance()->getExifRotate());
183
191
d->previewView = new LightTableView(d->vSplitter);
184
192
vlay->addWidget(d->vSplitter);
213
221
d->statusProgressBar = new StatusProgressBar(statusBar());
214
222
d->statusProgressBar->setAlignment(Qt::AlignCenter);
215
d->statusProgressBar->setMaximumHeight(fontMetrics().height()+2);
223
d->statusProgressBar->setMaximumHeight(fontMetrics().height()+2);
216
224
statusBar()->addWidget(d->statusProgressBar, 100);
218
226
d->rightZoomBar = new StatusZoomBar(statusBar());
219
227
d->rightZoomBar->setMaximumHeight(fontMetrics().height()+2);
220
228
statusBar()->addWidget(d->rightZoomBar, 1);
226
234
connect(d->statusProgressBar, SIGNAL(signalCancelButtonPressed()),
227
235
this, SLOT(slotProgressBarCancelButtonPressed()));
237
connect(ThemeEngine::instance(), SIGNAL(signalThemeChanged()),
238
this, SLOT(slotThemeChanged()));
229
240
// Thumbs bar connections ---------------------------------------
231
242
connect(d->barView, SIGNAL(signalSetItemOnLeftPanel(ImageInfo*)),
292
303
connect(d->previewView, SIGNAL(signalRightDroppedItems(const ImageInfoList&)),
293
304
this, SLOT(slotRightDroppedItems(const ImageInfoList&)));
295
306
connect(d->previewView, SIGNAL(signalToggleOnSyncPreview(bool)),
296
307
this, SLOT(slotToggleOnSyncPreview(bool)));
332
343
actionCollection(), "lighttable_last");
333
344
d->lastAction->setEnabled(false);
335
d->setItemLeftAction = new KAction(i18n("Show item on left panel"), "previous",
346
d->setItemLeftAction = new KAction(i18n("On Left"), "previous",
336
347
CTRL+Key_L, this, SLOT(slotSetItemLeft()),
337
348
actionCollection(), "lighttable_setitemleft");
338
349
d->setItemLeftAction->setEnabled(false);
350
d->setItemLeftAction->setWhatsThis(i18n("Show item on left panel"));
340
d->setItemRightAction = new KAction(i18n("Show item on right panel"), "next",
352
d->setItemRightAction = new KAction(i18n("On Right"), "next",
341
353
CTRL+Key_R, this, SLOT(slotSetItemRight()),
342
354
actionCollection(), "lighttable_setitemright");
343
355
d->setItemRightAction->setEnabled(false);
356
d->setItemRightAction->setWhatsThis(i18n("Show item on right panel"));
345
358
d->editItemAction = new KAction(i18n("Edit"), "editimage",
346
359
Key_F4, this, SLOT(slotEditItem()),
368
381
// -- Standard 'View' menu actions ---------------------------------------------
370
d->syncPreviewAction = new KToggleAction(i18n("Synchronize Preview"), "goto",
383
d->syncPreviewAction = new KToggleAction(i18n("Synchronize"), "goto",
371
384
CTRL+SHIFT+Key_Y, this,
372
385
SLOT(slotToggleSyncPreview()),
373
386
actionCollection(), "lighttable_syncpreview");
374
387
d->syncPreviewAction->setEnabled(false);
388
d->syncPreviewAction->setWhatsThis(i18n("Synchronize preview from left and right panels"));
376
d->navigateByPairAction = new KToggleAction(i18n("Navigate by Pair"), "kcmsystem",
390
d->navigateByPairAction = new KToggleAction(i18n("By Pair"), "kcmsystem",
377
391
CTRL+SHIFT+Key_P, this,
378
392
SLOT(slotToggleNavigateByPair()),
379
393
actionCollection(), "lighttable_navigatebypair");
380
394
d->navigateByPairAction->setEnabled(false);
395
d->navigateByPairAction->setWhatsThis(i18n("Navigate by pair with all items"));
382
397
d->zoomPlusAction = KStdAction::zoomIn(d->previewView, SLOT(slotIncreaseZoom()),
383
398
actionCollection(), "lighttable_zoomplus");
396
411
CTRL+SHIFT+Key_E, this, SLOT(slotFitToWindow()),
397
412
actionCollection(), "lighttable_zoomfit2window");
399
#if KDE_IS_VERSION(3,2,0)
400
d->fullScreenAction = KStdAction::fullScreen(this, SLOT(slotToggleFullScreen()),
401
actionCollection(), this, "lighttable_fullscreen");
403
d->fullScreenAction = new KToggleAction(i18n("Fullscreen"), "window_fullscreen",
414
// Do not use std KDE action for full screen because action text is too large for app. toolbar.
415
d->fullScreenAction = new KToggleAction(i18n("Full Screen"), "window_fullscreen",
404
416
CTRL+SHIFT+Key_F, this,
405
417
SLOT(slotToggleFullScreen()),
406
418
actionCollection(), "lighttable_fullscreen");
419
d->fullScreenAction->setWhatsThis(i18n("Toggle the window to full screen mode"));
409
d->slideShowAction = new KAction(i18n("Slide Show"), "slideshow", Key_F9,
421
d->slideShowAction = new KAction(i18n("Slide"), "slideshow", Key_F9,
410
422
this, SLOT(slotToggleSlideShow()),
411
423
actionCollection(),"lighttable_slideshow");
416
428
KStdAction::configureToolbars(this, SLOT(slotConfToolbars()), actionCollection());
417
429
KStdAction::preferences(this, SLOT(slotSetup()), actionCollection());
431
// -----------------------------------------------------------------------------------------
433
d->themeMenuAction = new KSelectAction(i18n("&Themes"), 0, actionCollection(), "theme_menu");
434
connect(d->themeMenuAction, SIGNAL(activated(const QString&)),
435
this, SLOT(slotChangeTheme(const QString&)));
437
d->themeMenuAction->setItems(ThemeEngine::instance()->themeNames());
419
440
// -- Standard 'Help' menu actions ---------------------------------------------
422
d->donateMoneyAction = new KAction(i18n("Donate Money..."),
443
d->donateMoneyAction = new KAction(i18n("Donate..."),
424
445
this, SLOT(slotDonateMoney()),
425
446
actionCollection(),
426
"lighttable_donatemoney");
447
"lighttable_donatemoney");
449
d->contributeAction = new KAction(i18n("Contribute..."),
451
this, SLOT(slotContribute()),
453
"lighttable_contribute");
455
d->rawCameraListAction = new KAction(i18n("RAW camera supported"),
459
SLOT(slotRawCameraList()),
461
"lighttable_rawcameralist");
428
464
// Provides a menu entry that allows showing/hiding the toolbar(s)
429
465
setStandardToolBarMenuEnabled(true);
434
470
// -- Rating actions ---------------------------------------------------------------
436
d->star0 = new KAction(i18n("Assign Rating \"No Star\""), CTRL+Key_0,
472
d->star0 = new KAction(i18n("Assign Rating \"No Stars\""), CTRL+Key_0,
437
473
d->barView, SLOT(slotAssignRatingNoStar()),
438
474
actionCollection(), "lighttable_ratenostar");
439
475
d->star1 = new KAction(i18n("Assign Rating \"One Star\""), CTRL+Key_1,
464
500
d->accelerators = new KAccel(this);
466
502
d->accelerators->insert("Exit fullscreen", i18n("Exit Fullscreen mode"),
467
i18n("Exit from fullscreen viewing mode"),
503
i18n("Exit fullscreen viewing mode"),
468
504
Key_Escape, this, SLOT(slotEscapePressed()),
473
509
Key_Space, this, SLOT(slotForward()),
512
d->accelerators->insert("Previous Image SHIFT+Key_Space", i18n("Previous Image"),
513
i18n("Load Previous Image"),
514
SHIFT+Key_Space, this, SLOT(slotBackward()),
476
517
d->accelerators->insert("Previous Image Key_Backspace", i18n("Previous Image"),
477
518
i18n("Load Previous Image"),
478
519
Key_Backspace, this, SLOT(slotBackward()),
492
533
i18n("Zoom in on image"),
493
534
Key_Plus, d->previewView, SLOT(slotIncreaseZoom()),
496
537
d->accelerators->insert("Zoom Plus Key_Minus", i18n("Zoom out"),
497
i18n("Zoom out of image"),
538
i18n("Zoom out from image"),
498
539
Key_Minus, d->previewView, SLOT(slotDecreaseZoom()),
564
604
refreshStatusBar();
567
607
void LightTableWindow::refreshStatusBar()
569
609
switch (d->barView->countItems())
572
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
573
i18n("No item on Light Table"));
612
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
613
i18n("No item on Light Table"));
576
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
577
i18n("1 item on Light Table"));
616
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
617
i18n("1 item on Light Table"));
580
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
620
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode,
581
621
i18n("%1 items on Light Table")
582
.arg(d->barView->countItems()));
622
.arg(d->barView->countItems()));
587
627
void LightTableWindow::slotItemsUpdated(const KURL::List& urls)
634
674
d->previewView->checkForSelection(d->barView->currentItemImageInfo());
635
675
d->barView->setOnLeftPanel(d->previewView->leftImageInfo());
637
677
LightTableBarItem *item = d->barView->findItemByInfo(d->previewView->leftImageInfo());
638
678
if (item) item->setOnLeftPanel(true);
640
680
if (d->navigateByPairAction->isChecked() && item)
642
682
LightTableBarItem* next = dynamic_cast<LightTableBarItem*>(item->next());
662
702
d->previewView->checkForSelection(d->barView->currentItemImageInfo());
663
703
d->barView->setOnRightPanel(d->previewView->rightImageInfo());
665
705
LightTableBarItem *item = d->barView->findItemByInfo(d->previewView->rightImageInfo());
666
706
if (item) item->setOnRightPanel(true);
685
725
d->zoomPlusAction->setEnabled(true);
686
726
d->zoomMinusAction->setEnabled(true);
687
727
d->navigateByPairAction->setEnabled(true);
728
d->slideShowAction->setEnabled(true);
689
730
LightTableBarItem* curr = d->barView->findItemByInfo(info);
732
773
d->zoomMinusAction->setEnabled(false);
733
774
d->syncPreviewAction->setEnabled(false);
734
775
d->navigateByPairAction->setEnabled(false);
776
d->slideShowAction->setEnabled(false);
737
779
d->previewView->checkForSelection(info);
740
782
// Deal with one (or more) items dropped onto the left panel
741
783
void LightTableWindow::slotLeftDroppedItems(const ImageInfoList& list)
745
787
loadImageInfos(list, info, true);
747
789
// We will check if first item from list is already stored in thumbbar
748
// Note that the thumbbar stores all ImageInfo reference
790
// Note that the thumbbar stores all ImageInfo reference
749
791
// in memory for preview object.
750
792
LightTableBarItem *item = d->barView->findItemByInfo(info);
753
795
slotSetItemOnLeftPanel(item->info());
754
796
// One approach is to make this item the current one, via
755
797
// d->barView->setSelectedItem(item);
756
// However, this is not good, because this also sets
798
// However, this is not good, because this also sets
757
799
// the right thumb to the same image.
758
// Therefore we use setLeftRightItems if there is more than
759
// one item in the list of dropped images.
800
// Therefore we use setLeftRightItems if there is more than
801
// one item in the list of dropped images.
761
setLeftRightItems(list);
764
805
// Deal with one (or more) items dropped onto the right panel
767
808
ImageInfo *info = *(list.begin());
768
809
// add the image to the existing images
769
810
loadImageInfos(list, info, true);
770
setLeftRightItems(list);
772
812
// We will check if first item from list is already stored in thumbbar
773
// Note that the thumbbar stores all ImageInfo reference
813
// Note that the thumbbar stores all ImageInfo reference
774
814
// in memory for preview object.
775
815
LightTableBarItem *item = d->barView->findItemByInfo(info);
784
824
// Set the images for the left and right panel.
785
void LightTableWindow::setLeftRightItems(const ImageInfoList &list)
825
void LightTableWindow::setLeftRightItems(const ImageInfoList &list, bool addTo)
787
827
ImageInfoList l = list;
793
ImageInfo *info = l.first();
795
LightTableBarItem *ltItem = dynamic_cast<LightTableBarItem*>(d->barView->findItemByInfo(info));
832
ImageInfo *info = l.first();
833
LightTableBarItem *ltItem = d->barView->findItemByInfo(info);
835
if (l.count() == 1 && !addTo)
800
837
// Just one item; this is used for the left panel.
801
838
d->barView->setOnLeftPanel(info);
810
847
// The first item is used for the left panel.
811
d->barView->setOnLeftPanel(info);
812
slotSetItemOnLeftPanel(info);
850
d->barView->setOnLeftPanel(info);
851
slotSetItemOnLeftPanel(info);
814
854
// The subsequent item is used for the right panel.
815
855
LightTableBarItem* next = dynamic_cast<LightTableBarItem*>(ltItem->next());
818
858
d->barView->setOnRightPanel(next->info());
819
859
slotSetItemOnRightPanel(next->info());
1097
1135
// See if there is an item next to the left one:
1098
1136
LightTableBarItem *ltItem = d->barView->findItemByInfo(new_linfo);
1099
LightTableBarItem* next = dynamic_cast<LightTableBarItem*>(ltItem->next());
1137
LightTableBarItem* next = 0;
1138
// re-check if ltItem is really set
1141
next = dynamic_cast<LightTableBarItem*>(ltItem->next());
1102
1145
new_rinfo = next->info();
1106
1149
// If there is no item to the right of new_linfo
1107
// then we can choose the first item for new_rinfo
1150
// then we can choose the last item for new_rinfo
1108
1151
// (as we made sure that there are at least two items)
1109
LightTableBarItem* first = dynamic_cast<LightTableBarItem*>(d->barView->firstItem());
1110
new_rinfo = first->info();
1152
LightTableBarItem* last = dynamic_cast<LightTableBarItem*>(d->barView->lastItem());
1153
new_rinfo = last->info();
1183
1226
ImageInfoList list = d->barView->itemsImageInfoList();
1185
1228
im->loadImageInfos(list, info, i18n("Light Table"), true);
1187
1230
if (im->isHidden())
1192
1235
im->setFocus();
1195
1238
void LightTableWindow::slotZoomTo100Percents()
1197
d->previewView->setLeftZoomFactor(1.0);
1198
d->previewView->setRightZoomFactor(1.0);
1240
d->previewView->toggleFitToWindowOr100();
1201
1243
void LightTableWindow::slotFitToWindow()
1210
1252
bool startWithCurrent = config->readBoolEntry("SlideShowStartCurrent", false);
1212
1254
SlideShowSettings settings;
1255
settings.exifRotate = AlbumSettings::instance()->getExifRotate();
1213
1256
settings.delay = config->readNumEntry("SlideShowDelay", 5) * 1000;
1214
1257
settings.printName = config->readBoolEntry("SlideShowPrintName", true);
1215
1258
settings.printDate = config->readBoolEntry("SlideShowPrintDate", false);
1224
1267
void LightTableWindow::slideShow(bool startWithCurrent, SlideShowSettings& settings)
1269
if (!d->barView->countItems()) return;
1227
1271
DMetadata meta;
1228
1273
d->cancelSlideShow = false;
1230
1275
d->statusProgressBar->progressBarMode(StatusProgressBar::CancelProgressBarMode,
1253
1298
kapp->processEvents();
1256
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode, QString());
1301
d->statusProgressBar->progressBarMode(StatusProgressBar::TextMode, QString());
1257
1302
refreshStatusBar();
1259
1304
if (!d->cancelSlideShow)
1261
1306
settings.exifRotate = AlbumSettings::instance()->getExifRotate();
1263
1308
SlideShow *slide = new SlideShow(settings);
1264
1309
if (startWithCurrent)
1265
1310
slide->setCurrent(d->barView->currentItemImageInfo()->kurl());
1289
1334
rightDock()->show();
1290
1335
topDock()->show();
1291
1336
bottomDock()->show();
1293
1338
QObject* obj = child("ToolBar","KToolBar");
1297
1342
KToolBar* toolBar = static_cast<KToolBar*>(obj);
1299
1344
if (d->fullScreenAction->isPlugged(toolBar) && d->removeFullScreenButton)
1300
1345
d->fullScreenAction->unplug(toolBar);
1302
1347
if (toolBar->isHidden())
1303
1348
showToolBars();
1312
1357
d->leftSidebar->restore();
1313
1358
d->rightSidebar->restore();
1317
d->leftSidebar->backup();
1318
d->rightSidebar->backup();
1362
d->leftSidebar->backup();
1363
d->rightSidebar->backup();
1321
1366
d->fullScreen = false;
1323
1368
else // go to fullscreen
1329
1374
leftDock()->hide();
1330
1375
rightDock()->hide();
1331
1376
bottomDock()->hide();
1333
1378
QObject* obj = child("ToolBar","KToolBar");
1337
1382
KToolBar* toolBar = static_cast<KToolBar*>(obj);
1339
1384
if (d->fullScreenHideToolBar)
1341
1386
hideToolBars();
1345
1390
showToolBars();
1347
1392
if ( !d->fullScreenAction->isPlugged(toolBar) )
1439
1484
KApplication::kApplication()->invokeBrowser("http://www.digikam.org/?q=donation");
1487
void LightTableWindow::slotContribute()
1489
KApplication::kApplication()->invokeBrowser("http://www.digikam.org/?q=contrib");
1442
1492
void LightTableWindow::slotEditKeys()
1444
1494
KKeyDialog dialog(true, this);
1523
1573
void LightTableWindow::slotToggleSyncPreview()
1525
d->previewView->setSyncPreview(d->syncPreviewAction->isChecked());
1575
d->previewView->setSyncPreview(d->syncPreviewAction->isChecked());
1528
1578
void LightTableWindow::slotToggleOnSyncPreview(bool t)
1571
1621
slotItemSelected(d->barView->currentItemImageInfo());
1624
void LightTableWindow::slotRawCameraList()
1626
RawCameraDlg dlg(this);
1630
void LightTableWindow::slotThemeChanged()
1632
QStringList themes(ThemeEngine::instance()->themeNames());
1633
int index = themes.findIndex(AlbumSettings::instance()->getCurrentTheme());
1635
index = themes.findIndex(i18n("Default"));
1637
d->themeMenuAction->setCurrentItem(index);
1640
void LightTableWindow::slotChangeTheme(const QString& theme)
1642
AlbumSettings::instance()->setCurrentTheme(theme);
1643
ThemeEngine::instance()->slotChangeTheme(theme);
1574
1646
} // namespace Digikam