DigiKam – digital photo management application
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

2095 行
75 KiB

  1. /* ============================================================
  2. *
  3. * This file is a part of digiKam project
  4. * http://www.digikam.org
  5. *
  6. * Date : 2002-16-10
  7. * Description : main digiKam interface implementation
  8. *
  9. * Copyright (C) 2002-2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
  10. * Copyright (C) 2006 by Tom Albers <tomalbers@kde.nl>
  11. * Copyright (C) 2002-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
  12. *
  13. * This program is free software; you can redistribute it
  14. * and/or modify it under the terms of the GNU General
  15. * Public License as published by the Free Software Foundation;
  16. * either version 2, or (at your option)
  17. * any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * ============================================================ */
  25. // TQt includes.
  26. #include <tqdatastream.h>
  27. #include <tqlabel.h>
  28. #include <tqstringlist.h>
  29. #include <tqtooltip.h>
  30. #include <tqwhatsthis.h>
  31. #include <tqsignalmapper.h>
  32. #include <tqdockarea.h>
  33. #include <tqhbox.h>
  34. // KDE includes.
  35. #include <tdeaboutdata.h>
  36. #include <tdelocale.h>
  37. #include <kstandarddirs.h>
  38. #include <kurl.h>
  39. #include <kstdaction.h>
  40. #include <tdestdaccel.h>
  41. #include <kkeydialog.h>
  42. #include <kedittoolbar.h>
  43. #include <kiconloader.h>
  44. #include <ktip.h>
  45. #include <tdeversion.h>
  46. #include <tdeapplication.h>
  47. #include <tdemenubar.h>
  48. #include <tdeglobalsettings.h>
  49. #include <tdefiledialog.h>
  50. #include <tdemessagebox.h>
  51. #include <twin.h>
  52. #include <kimageio.h>
  53. #include <dcopref.h>
  54. // libKipi includes.
  55. #include <libkipi/plugin.h>
  56. // LibKDcraw includes.
  57. #include <libkdcraw/version.h>
  58. #include <libkdcraw/kdcraw.h>
  59. #if KDCRAW_VERSION < 0x000106
  60. #include <libkdcraw/dcrawbinary.h>
  61. #endif
  62. // Local includes.
  63. #include "ddebug.h"
  64. #include "dlogoaction.h"
  65. #include "album.h"
  66. #include "albumlister.h"
  67. #include "albumthumbnailloader.h"
  68. #include "albumiconviewfilter.h"
  69. #include "cameratype.h"
  70. #include "cameraui.h"
  71. #include "setup.h"
  72. #include "setupplugins.h"
  73. #include "setupeditor.h"
  74. #include "setupicc.h"
  75. #include "rawcameradlg.h"
  76. #include "lighttablewindow.h"
  77. #include "imagewindow.h"
  78. #include "imageinfo.h"
  79. #include "thumbnailsize.h"
  80. #include "themeengine.h"
  81. #include "scanlib.h"
  82. #include "loadingcacheinterface.h"
  83. #include "imageattributeswatch.h"
  84. #include "batchthumbsgenerator.h"
  85. #include "batchalbumssyncmetadata.h"
  86. #include "dcopiface.h"
  87. #include "digikamappprivate.h"
  88. #include "digikamapp.h"
  89. #include "digikamapp.moc"
  90. using TDEIO::Job;
  91. using TDEIO::UDSEntryList;
  92. using TDEIO::UDSEntry;
  93. namespace Digikam
  94. {
  95. DigikamApp* DigikamApp::m_instance = 0;
  96. DigikamApp::DigikamApp()
  97. : TDEMainWindow( 0, "Digikam" )
  98. {
  99. d = new DigikamAppPriv;
  100. m_instance = this;
  101. d->config = kapp->config();
  102. d->config->setGroup("General Settings");
  103. if(d->config->readBoolEntry("Show Splash", true) &&
  104. !kapp->isRestored())
  105. {
  106. d->splashScreen = new SplashScreen("digikam-splash.png");
  107. d->splashScreen->show();
  108. }
  109. if(d->splashScreen)
  110. d->splashScreen->message(i18n("Initializing..."));
  111. // Register image formats (especially for TIFF )
  112. KImageIO::registerFormats();
  113. d->albumSettings = new AlbumSettings();
  114. d->albumSettings->readSettings();
  115. d->albumManager = new Digikam::AlbumManager();
  116. AlbumLister::instance();
  117. d->cameraMediaList = new TDEPopupMenu;
  118. connect(d->cameraMediaList, TQT_SIGNAL( aboutToShow() ),
  119. TQT_TQOBJECT(this), TQT_SLOT(slotCameraMediaMenu()));
  120. d->cameraList = new CameraList(TQT_TQOBJECT(this), locateLocal("appdata", "cameras.xml"));
  121. connect(d->cameraList, TQT_SIGNAL(signalCameraAdded(CameraType *)),
  122. TQT_TQOBJECT(this), TQT_SLOT(slotCameraAdded(CameraType *)));
  123. connect(d->cameraList, TQT_SIGNAL(signalCameraRemoved(CameraType *)),
  124. TQT_TQOBJECT(this), TQT_SLOT(slotCameraRemoved(CameraType *)));
  125. setupView();
  126. setupStatusBar();
  127. setupAccelerators();
  128. setupActions();
  129. applyMainWindowSettings(d->config);
  130. // Check ICC profiles repository availability
  131. if(d->splashScreen)
  132. d->splashScreen->message(i18n("Checking ICC repository"));
  133. d->validIccPath = SetupICC::iccRepositoryIsValid();
  134. #if KDCRAW_VERSION < 0x000106
  135. // Check witch dcraw version available
  136. if(d->splashScreen)
  137. d->splashScreen->message(i18n("Checking dcraw version"));
  138. KDcrawIface::DcrawBinary::instance()->checkSystem();
  139. #endif
  140. if(d->splashScreen)
  141. d->splashScreen->message(i18n("Scan Albums"));
  142. d->albumManager->setLibraryPath(d->albumSettings->getAlbumLibraryPath(), d->splashScreen);
  143. // Read albums from database
  144. if(d->splashScreen)
  145. d->splashScreen->message(i18n("Reading database"));
  146. d->albumManager->startScan();
  147. // Load KIPI Plugins.
  148. loadPlugins();
  149. // Load Themes
  150. populateThemes();
  151. setAutoSaveSettings();
  152. d->dcopIface = new DCOPIface(TQT_TQOBJECT(this), "camera");
  153. connect(d->dcopIface, TQT_SIGNAL(signalCameraAutoDetect()),
  154. TQT_TQOBJECT(this), TQT_SLOT(slotDcopCameraAutoDetect()));
  155. connect(d->dcopIface, TQT_SIGNAL(signalDownloadImages( const TQString & )),
  156. TQT_TQOBJECT(this), TQT_SLOT(slotDcopDownloadImages(const TQString &)));
  157. }
  158. DigikamApp::~DigikamApp()
  159. {
  160. ImageAttributesWatch::shutDown();
  161. // Close and delete image editor instance.
  162. if (ImageWindow::imagewindowCreated())
  163. ImageWindow::imagewindow()->close(true);
  164. // Close and delete light table instance.
  165. if (LightTableWindow::lightTableWindowCreated())
  166. LightTableWindow::lightTableWindow()->close(true);
  167. if (d->view)
  168. delete d->view;
  169. d->albumIconViewFilter->saveSettings();
  170. d->albumSettings->setRecurseAlbums(d->recurseAlbumsAction->isChecked());
  171. d->albumSettings->setRecurseTags(d->recurseTagsAction->isChecked());
  172. d->albumSettings->saveSettings();
  173. delete d->albumSettings;
  174. delete d->albumManager;
  175. delete AlbumLister::instance();
  176. ImageAttributesWatch::cleanUp();
  177. LoadingCacheInterface::cleanUp();
  178. #if KDCRAW_VERSION < 0x000106
  179. KDcrawIface::DcrawBinary::cleanUp();
  180. #endif
  181. AlbumThumbnailLoader::cleanUp();
  182. m_instance = 0;
  183. delete d;
  184. }
  185. DigikamApp* DigikamApp::getinstance()
  186. {
  187. return m_instance;
  188. }
  189. void DigikamApp::show()
  190. {
  191. // Remove Splashscreen.
  192. if(d->splashScreen)
  193. {
  194. d->splashScreen->finish(this);
  195. delete d->splashScreen;
  196. d->splashScreen = 0;
  197. }
  198. // Display application window.
  199. TDEMainWindow::show();
  200. // Report errors from ICC repository path.
  201. if(!d->validIccPath)
  202. {
  203. TQString message = i18n("<qt><p>ICC profiles path seems to be invalid.</p>"
  204. "<p>If you want to set it now, select \"Yes\", otherwise "
  205. "select \"No\". In this case, \"Color Management\" feature "
  206. "will be disabled until you solve this issue</p></qt>");
  207. if (KMessageBox::warningYesNo(this, message) == KMessageBox::Yes)
  208. {
  209. if (!setup(true))
  210. {
  211. d->config->setGroup("Color Management");
  212. d->config->writeEntry("EnableCM", false);
  213. d->config->sync();
  214. }
  215. }
  216. else
  217. {
  218. d->config->setGroup("Color Management");
  219. d->config->writeEntry("EnableCM", false);
  220. d->config->sync();
  221. }
  222. }
  223. #if KDCRAW_VERSION < 0x000106
  224. // Report errors from dcraw detection.
  225. KDcrawIface::DcrawBinary::instance()->checkReport();
  226. #endif
  227. // Init album icon view zoom factor.
  228. slotThumbSizeChanged(d->albumSettings->getDefaultIconSize());
  229. }
  230. const TQPtrList<TDEAction>& DigikamApp::menuImageActions()
  231. {
  232. return d->kipiImageActions;
  233. }
  234. const TQPtrList<TDEAction>& DigikamApp::menuBatchActions()
  235. {
  236. return d->kipiBatchActions;
  237. }
  238. const TQPtrList<TDEAction>& DigikamApp::menuAlbumActions()
  239. {
  240. return d->kipiAlbumActions;
  241. }
  242. const TQPtrList<TDEAction> DigikamApp::menuImportActions()
  243. {
  244. TQPtrList<TDEAction> importMenu;
  245. importMenu = d->kipiFileActionsImport;
  246. importMenu.append( d->albumImportAction );
  247. importMenu.append( d->addImagesAction );
  248. return importMenu;
  249. }
  250. const TQPtrList<TDEAction> DigikamApp::menuExportActions()
  251. {
  252. return d->kipiFileActionsExport;
  253. }
  254. void DigikamApp::autoDetect()
  255. {
  256. // Called from main if command line option is set
  257. if(d->splashScreen)
  258. d->splashScreen->message(i18n("Auto-detect camera"));
  259. TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotCameraAutoDetect()));
  260. }
  261. void DigikamApp::downloadFrom(const TQString &cameraGuiPath)
  262. {
  263. // Called from main if command line option is set
  264. if (!cameraGuiPath.isNull())
  265. {
  266. d->cameraGuiPath = cameraGuiPath;
  267. if(d->splashScreen)
  268. d->splashScreen->message(i18n("Opening Download Dialog"));
  269. TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotDownloadImages()));
  270. }
  271. }
  272. bool DigikamApp::queryClose()
  273. {
  274. if (ImageWindow::imagewindowCreated())
  275. {
  276. return ImageWindow::imagewindow()->queryClose();
  277. }
  278. else
  279. return true;
  280. }
  281. void DigikamApp::setupView()
  282. {
  283. if(d->splashScreen)
  284. d->splashScreen->message(i18n("Initializing Main View"));
  285. d->view = new DigikamView(this);
  286. setCentralWidget(d->view);
  287. d->view->applySettings();
  288. connect(d->view, TQT_SIGNAL(signalAlbumSelected(bool)),
  289. TQT_TQOBJECT(this), TQT_SLOT(slotAlbumSelected(bool)));
  290. connect(d->view, TQT_SIGNAL(signalTagSelected(bool)),
  291. TQT_TQOBJECT(this), TQT_SLOT(slotTagSelected(bool)));
  292. connect(d->view, TQT_SIGNAL(signalImageSelected(const TQPtrList<ImageInfo>&, bool, bool, const KURL::List&)),
  293. TQT_TQOBJECT(this), TQT_SLOT(slotImageSelected(const TQPtrList<ImageInfo>&, bool, bool, const KURL::List&)));
  294. }
  295. void DigikamApp::setupStatusBar()
  296. {
  297. d->statusProgressBar = new StatusProgressBar(statusBar());
  298. d->statusProgressBar->setAlignment(TQt::AlignLeft|TQt::AlignVCenter);
  299. d->statusProgressBar->setMaximumHeight(fontMetrics().height()+4);
  300. statusBar()->addWidget(d->statusProgressBar, 100, true);
  301. //------------------------------------------------------------------------------
  302. d->albumIconViewFilter = new AlbumIconViewFilter(statusBar());
  303. d->albumIconViewFilter->setMaximumHeight(fontMetrics().height()+4);
  304. statusBar()->addWidget(d->albumIconViewFilter, 100, true);
  305. //------------------------------------------------------------------------------
  306. d->statusZoomBar = new StatusZoomBar(statusBar());
  307. d->statusZoomBar->setMaximumHeight(fontMetrics().height()+4);
  308. statusBar()->addWidget(d->statusZoomBar, 1, true);
  309. //------------------------------------------------------------------------------
  310. d->statusNavigateBar = new StatusNavigateBar(statusBar());
  311. d->statusNavigateBar->setMaximumHeight(fontMetrics().height()+4);
  312. statusBar()->addWidget(d->statusNavigateBar, 1, true);
  313. //------------------------------------------------------------------------------
  314. connect(d->statusZoomBar, TQT_SIGNAL(signalZoomMinusClicked()),
  315. TQT_TQOBJECT(d->view), TQT_SLOT(slotZoomOut()));
  316. connect(d->statusZoomBar, TQT_SIGNAL(signalZoomPlusClicked()),
  317. TQT_TQOBJECT(d->view), TQT_SLOT(slotZoomIn()));
  318. connect(d->statusZoomBar, TQT_SIGNAL(signalZoomSliderChanged(int)),
  319. TQT_TQOBJECT(this), TQT_SLOT(slotZoomSliderChanged(int)));
  320. connect(d->view, TQT_SIGNAL(signalThumbSizeChanged(int)),
  321. TQT_TQOBJECT(this), TQT_SLOT(slotThumbSizeChanged(int)));
  322. connect(d->view, TQT_SIGNAL(signalZoomChanged(double, int)),
  323. TQT_TQOBJECT(this), TQT_SLOT(slotZoomChanged(double, int)));
  324. connect(d->view, TQT_SIGNAL(signalTogglePreview(bool)),
  325. TQT_TQOBJECT(this), TQT_SLOT(slotTogglePreview(bool)));
  326. connect(d->albumIconViewFilter, TQT_SIGNAL(signalResetTagFilters()),
  327. TQT_TQOBJECT(this), TQT_SIGNAL(signalResetTagFilters()));
  328. connect(d->statusNavigateBar, TQT_SIGNAL(signalFirstItem()),
  329. TQT_TQOBJECT(d->view), TQT_SLOT(slotFirstItem()));
  330. connect(d->statusNavigateBar, TQT_SIGNAL(signalNextItem()),
  331. TQT_TQOBJECT(d->view), TQT_SLOT(slotNextItem()));
  332. connect(d->statusNavigateBar, TQT_SIGNAL(signalPrevItem()),
  333. TQT_TQOBJECT(d->view), TQT_SLOT(slotPrevItem()));
  334. connect(d->statusNavigateBar, TQT_SIGNAL(signalLastItem()),
  335. TQT_TQOBJECT(d->view), TQT_SLOT(slotLastItem()));
  336. connect(d->statusProgressBar, TQT_SIGNAL(signalCancelButtonPressed()),
  337. TQT_TQOBJECT(this), TQT_SIGNAL(signalCancelButtonPressed()));
  338. }
  339. void DigikamApp::setupAccelerators()
  340. {
  341. d->accelerators = new TDEAccel(this);
  342. d->accelerators->insert("Exit Preview Mode", i18n("Exit Preview"),
  343. i18n("Exit preview mode"),
  344. Key_Escape, TQT_TQOBJECT(this), TQT_SIGNAL(signalEscapePressed()),
  345. false, true);
  346. d->accelerators->insert("Next Image Key_Space", i18n("Next Image"),
  347. i18n("Next Image"),
  348. Key_Space, TQT_TQOBJECT(this), TQT_SIGNAL(signalNextItem()),
  349. false, true);
  350. d->accelerators->insert("Previous Image SHIFT+Key_Space", i18n("Previous Image"),
  351. i18n("Previous Image"),
  352. SHIFT+Key_Space, TQT_TQOBJECT(this), TQT_SIGNAL(signalPrevItem()),
  353. false, true);
  354. d->accelerators->insert("Previous Image Key_Backspace", i18n("Previous Image"),
  355. i18n("Previous Image"),
  356. Key_Backspace, TQT_TQOBJECT(this), TQT_SIGNAL(signalPrevItem()),
  357. false, true);
  358. d->accelerators->insert("Next Image Key_Next", i18n("Next Image"),
  359. i18n("Next Image"),
  360. Key_Next, TQT_TQOBJECT(this), TQT_SIGNAL(signalNextItem()),
  361. false, true);
  362. d->accelerators->insert("Previous Image Key_Prior", i18n("Previous Image"),
  363. i18n("Previous Image"),
  364. Key_Prior, TQT_TQOBJECT(this), TQT_SIGNAL(signalPrevItem()),
  365. false, true);
  366. d->accelerators->insert("First Image Key_Home", i18n("First Image"),
  367. i18n("First Image"),
  368. Key_Home, TQT_TQOBJECT(this), TQT_SIGNAL(signalFirstItem()),
  369. false, true);
  370. d->accelerators->insert("Last Image Key_End", i18n("Last Image"),
  371. i18n("Last Image"),
  372. Key_End, TQT_TQOBJECT(this), TQT_SIGNAL(signalLastItem()),
  373. false, true);
  374. d->accelerators->insert("Copy Album Items Selection CTRL+Key_C", i18n("Copy Album Items Selection"),
  375. i18n("Copy Album Items Selection"),
  376. CTRL+Key_C, TQT_TQOBJECT(this), TQT_SIGNAL(signalCopyAlbumItemsSelection()),
  377. false, true);
  378. d->accelerators->insert("Paste Album Items Selection CTRL+Key_V", i18n("Paste Album Items Selection"),
  379. i18n("Paste Album Items Selection"),
  380. CTRL+Key_V, TQT_TQOBJECT(this), TQT_SIGNAL(signalPasteAlbumItemsSelection()),
  381. false, true);
  382. }
  383. void DigikamApp::setupActions()
  384. {
  385. // -----------------------------------------------------------------
  386. d->cameraMenuAction = new TDEActionMenu(i18n("&Camera"),
  387. "digitalcam",
  388. actionCollection(),
  389. "camera_menu");
  390. d->cameraMenuAction->setDelayed(false);
  391. // -----------------------------------------------------------------
  392. d->themeMenuAction = new TDESelectAction(i18n("&Themes"), 0, actionCollection(), "theme_menu");
  393. connect(d->themeMenuAction, TQT_SIGNAL(activated(const TQString&)),
  394. TQT_TQOBJECT(this), TQT_SLOT(slotChangeTheme(const TQString&)));
  395. connect(ThemeEngine::instance(), TQT_SIGNAL(signalThemeChanged()),
  396. TQT_TQOBJECT(this), TQT_SLOT(slotThemeChanged()));
  397. // -----------------------------------------------------------------
  398. d->backwardActionMenu = new TDEToolBarPopupAction(i18n("&Back"),
  399. "back",
  400. ALT+Key_Left,
  401. TQT_TQOBJECT(d->view),
  402. TQT_SLOT(slotAlbumHistoryBack()),
  403. actionCollection(),
  404. "album_back");
  405. d->backwardActionMenu->setEnabled(false);
  406. connect(d->backwardActionMenu->popupMenu(), TQT_SIGNAL(aboutToShow()),
  407. TQT_TQOBJECT(this), TQT_SLOT(slotAboutToShowBackwardMenu()));
  408. connect(d->backwardActionMenu->popupMenu(), TQT_SIGNAL(activated(int)),
  409. TQT_TQOBJECT(d->view), TQT_SLOT(slotAlbumHistoryBack(int)));
  410. d->forwardActionMenu = new TDEToolBarPopupAction(i18n("Forward"),
  411. "forward",
  412. ALT+Key_Right,
  413. TQT_TQOBJECT(d->view),
  414. TQT_SLOT(slotAlbumHistoryForward()),
  415. actionCollection(),
  416. "album_forward");
  417. d->forwardActionMenu->setEnabled(false);
  418. connect(d->forwardActionMenu->popupMenu(), TQT_SIGNAL(aboutToShow()),
  419. TQT_TQOBJECT(this), TQT_SLOT(slotAboutToShowForwardMenu()));
  420. connect(d->forwardActionMenu->popupMenu(), TQT_SIGNAL(activated(int)),
  421. TQT_TQOBJECT(d->view), TQT_SLOT(slotAlbumHistoryForward(int)));
  422. d->newAction = new TDEAction(i18n("&New..."),
  423. "albumfolder-new",
  424. TDEStdAccel::shortcut(TDEStdAccel::New),
  425. TQT_TQOBJECT(d->view),
  426. TQT_SLOT(slotNewAlbum()),
  427. actionCollection(),
  428. "album_new");
  429. d->newAction->setWhatsThis(i18n("Creates a new empty Album in the database."));
  430. d->albumSortAction = new TDESelectAction(i18n("&Sort Albums"),
  431. 0,
  432. 0,
  433. actionCollection(),
  434. "album_sort");
  435. connect(d->albumSortAction, TQT_SIGNAL(activated(int)),
  436. TQT_TQOBJECT(d->view), TQT_SLOT(slotSortAlbums(int)));
  437. // Use same list order as in albumsettings enum
  438. TQStringList sortActionList;
  439. sortActionList.append(i18n("By Folder"));
  440. sortActionList.append(i18n("By Collection"));
  441. sortActionList.append(i18n("By Date"));
  442. d->albumSortAction->setItems(sortActionList);
  443. d->recurseAlbumsAction = new TDEToggleAction(i18n("Include Album Sub-Tree"),
  444. 0,
  445. TQT_TQOBJECT(this),
  446. 0,
  447. actionCollection(),
  448. "albums_recursive");
  449. d->recurseAlbumsAction->setWhatsThis(i18n("Activate this option to recursively show all sub-albums below "
  450. "the current album."));
  451. connect(d->recurseAlbumsAction, TQT_SIGNAL(toggled(bool)),
  452. TQT_TQOBJECT(this), TQT_SLOT(slotRecurseAlbums(bool)));
  453. d->recurseTagsAction = new TDEToggleAction(i18n("Include Tag Sub-Tree"),
  454. 0,
  455. TQT_TQOBJECT(this),
  456. 0,
  457. actionCollection(),
  458. "tags_recursive");
  459. d->recurseTagsAction->setWhatsThis(i18n("Activate this option to show all images marked by the given tag "
  460. "and its all its sub-tags."));
  461. connect(d->recurseTagsAction, TQT_SIGNAL(toggled(bool)),
  462. TQT_TQOBJECT(this), TQT_SLOT(slotRecurseTags(bool)));
  463. d->deleteAction = new TDEAction(i18n("Delete"),
  464. "edit-delete",
  465. 0,
  466. TQT_TQOBJECT(d->view),
  467. TQT_SLOT(slotDeleteAlbum()),
  468. actionCollection(),
  469. "album_delete");
  470. d->addImagesAction = new TDEAction( i18n("Add Images..."),
  471. "albumfolder-importimages",
  472. CTRL+Key_I,
  473. TQT_TQOBJECT(this),
  474. TQT_SLOT(slotAlbumAddImages()),
  475. actionCollection(),
  476. "album_addImages");
  477. d->addImagesAction->setWhatsThis(i18n("Adds new items to the current Album."));
  478. d->albumImportAction = new TDEAction( i18n("Add Folders..."),
  479. "albumfolder-importdir",
  480. 0,
  481. TQT_TQOBJECT(d->view),
  482. TQT_SLOT(slotAlbumImportFolder()),
  483. actionCollection(),
  484. "album_importFolder");
  485. d->propsEditAction = new TDEAction( i18n("Properties..."),
  486. "albumfolder-properties",
  487. 0,
  488. TQT_TQOBJECT(d->view),
  489. TQT_SLOT(slotAlbumPropsEdit()),
  490. actionCollection(),
  491. "album_propsEdit");
  492. d->propsEditAction->setWhatsThis(i18n("Edit Album Properties and Collection information."));
  493. d->refreshAlbumAction = new TDEAction( i18n("Refresh"),
  494. "rebuild",
  495. Key_F5,
  496. TQT_TQOBJECT(d->view),
  497. TQT_SLOT(slotAlbumRefresh()),
  498. actionCollection(),
  499. "album_refresh");
  500. d->refreshAlbumAction->setWhatsThis(i18n("Refresh all album contents"));
  501. d->syncAlbumMetadataAction = new TDEAction( i18n("Synchronize Images with Database"),
  502. "rebuild",
  503. 0,
  504. TQT_TQOBJECT(d->view),
  505. TQT_SLOT(slotAlbumSyncPicturesMetadata()),
  506. actionCollection(),
  507. "album_syncmetadata");
  508. d->syncAlbumMetadataAction->setWhatsThis(i18n("Updates all image metadata of the current "
  509. "album with the contents of the digiKam database "
  510. "(image metadata will be over-written with data from the database)."));
  511. d->openInKonquiAction = new TDEAction( i18n("Open in File Manager"),
  512. "konqueror",
  513. 0,
  514. TQT_TQOBJECT(d->view),
  515. TQT_SLOT(slotAlbumOpenInKonqui()),
  516. actionCollection(),
  517. "album_openinkonqui");
  518. // -----------------------------------------------------------
  519. d->newTagAction = new TDEAction(i18n("New &Tag..."), "tag-new",
  520. 0, TQT_TQOBJECT(d->view), TQT_SLOT(slotNewTag()),
  521. actionCollection(), "tag_new");
  522. d->editTagAction = new TDEAction(i18n("Edit Tag Properties..."), "tag-properties",
  523. 0, TQT_TQOBJECT(d->view), TQT_SLOT(slotEditTag()),
  524. actionCollection(), "tag_edit");
  525. d->deleteTagAction = new TDEAction(i18n("Delete Tag"), "tag-delete",
  526. 0, TQT_TQOBJECT(d->view), TQT_SLOT(slotDeleteTag()),
  527. actionCollection(), "tag_delete");
  528. // -----------------------------------------------------------
  529. d->imagePreviewAction = new TDEToggleAction(i18n("View..."),
  530. "viewimage",
  531. Key_F3,
  532. TQT_TQOBJECT(d->view),
  533. TQT_SLOT(slotImagePreview()),
  534. actionCollection(),
  535. "image_view");
  536. d->imageViewAction = new TDEAction(i18n("Edit..."),
  537. "editimage",
  538. Key_F4,
  539. TQT_TQOBJECT(d->view),
  540. TQT_SLOT(slotImageEdit()),
  541. actionCollection(),
  542. "image_edit");
  543. d->imageViewAction->setWhatsThis(i18n("Open the selected item in the image editor."));
  544. d->imageLightTableAction = new TDEAction(i18n("Place onto Light Table"),
  545. "lighttable",
  546. CTRL+Key_L,
  547. TQT_TQOBJECT(d->view),
  548. TQT_SLOT(slotImageLightTable()),
  549. actionCollection(),
  550. "image_lighttable");
  551. d->imageLightTableAction->setWhatsThis(i18n("Place the selected items on the light table thumbbar."));
  552. d->imageAddLightTableAction = new TDEAction(i18n("Add to Light Table"),
  553. "lighttableadd",
  554. SHIFT+CTRL+Key_L,
  555. TQT_TQOBJECT(d->view),
  556. TQT_SLOT(slotImageAddToLightTable()),
  557. actionCollection(),
  558. "image_add_to_lighttable");
  559. d->imageAddLightTableAction->setWhatsThis(i18n("Add selected items to the light table thumbbar."));
  560. d->imageRenameAction = new TDEAction(i18n("Rename..."),
  561. "pencil",
  562. Key_F2,
  563. TQT_TQOBJECT(d->view),
  564. TQT_SLOT(slotImageRename()),
  565. actionCollection(),
  566. "image_rename");
  567. d->imageRenameAction->setWhatsThis(i18n("Change the filename of the currently selected item."));
  568. // Pop up dialog to ask user whether to move to trash
  569. d->imageDeleteAction = new TDEAction(i18n("Delete"),
  570. "edittrash",
  571. Key_Delete,
  572. TQT_TQOBJECT(d->view),
  573. TQT_SLOT(slotImageDelete()),
  574. actionCollection(),
  575. "image_delete");
  576. // Pop up dialog to ask user whether to permanently delete
  577. d->imageDeletePermanentlyAction = new TDEAction(i18n("Delete permanently"),
  578. "edit-delete",
  579. SHIFT+Key_Delete,
  580. TQT_TQOBJECT(d->view),
  581. TQT_SLOT(slotImageDeletePermanently()),
  582. actionCollection(),
  583. "image_delete_permanently");
  584. // These two actions are hidden, no menu entry, no toolbar entry, no shortcut.
  585. // Power users may add them.
  586. d->imageDeletePermanentlyDirectlyAction = new TDEAction(i18n("Delete permanently without confirmation"),
  587. "edit-delete",
  588. 0,
  589. TQT_TQOBJECT(d->view),
  590. TQT_SLOT(slotImageDeletePermanentlyDirectly()),
  591. actionCollection(),
  592. "image_delete_permanently_directly");
  593. d->imageTrashDirectlyAction = new TDEAction(i18n("Move to trash without confirmation"),
  594. "edittrash",
  595. 0,
  596. TQT_TQOBJECT(d->view),
  597. TQT_SLOT(slotImageTrashDirectly()),
  598. actionCollection(),
  599. "image_trash_directly");
  600. d->imageSortAction = new TDESelectAction(i18n("&Sort Images"),
  601. 0,
  602. 0,
  603. actionCollection(),
  604. "image_sort");
  605. connect(d->imageSortAction, TQT_SIGNAL(activated(int)),
  606. TQT_TQOBJECT(d->view), TQT_SLOT(slotSortImages(int)));
  607. // Use same list order as in albumsettings enum
  608. TQStringList sortImagesActionList;
  609. sortImagesActionList.append(i18n("By Name"));
  610. sortImagesActionList.append(i18n("By Path"));
  611. sortImagesActionList.append(i18n("By Date"));
  612. sortImagesActionList.append(i18n("By File Size"));
  613. sortImagesActionList.append(i18n("By Rating"));
  614. d->imageSortAction->setItems(sortImagesActionList);
  615. // -----------------------------------------------------------------
  616. TQSignalMapper *exifOrientationMapper = new TQSignalMapper( TQT_TQOBJECT(d->view) );
  617. connect(exifOrientationMapper, TQT_SIGNAL(mapped(int) ),
  618. TQT_TQOBJECT(d->view), TQT_SLOT(slotImageExifOrientation(int)));
  619. d->imageExifOrientationActionMenu = new TDEActionMenu(i18n("Adjust Exif orientation tag"),
  620. actionCollection(),
  621. "image_set_exif_orientation");
  622. d->imageExifOrientationActionMenu->setDelayed(false);
  623. d->imageSetExifOrientation1Action = new TDEAction(i18n("Normal"),
  624. 0,
  625. d->imageExifOrientationActionMenu,
  626. 0,
  627. actionCollection(),
  628. "image_set_exif_orientation_normal");
  629. d->imageSetExifOrientation2Action = new TDEAction(i18n("Flipped Horizontally"),
  630. 0,
  631. d->imageExifOrientationActionMenu,
  632. 0,
  633. actionCollection(),
  634. "image_set_exif_orientation_flipped_horizontal");
  635. d->imageSetExifOrientation3Action = new TDEAction(i18n("Rotated Upside Down"),
  636. 0,
  637. d->imageExifOrientationActionMenu,
  638. 0,
  639. actionCollection(),
  640. "image_set_exif_orientation_rotated_upside_down");
  641. d->imageSetExifOrientation4Action = new TDEAction(i18n("Flipped Vertically"),
  642. 0,
  643. d->imageExifOrientationActionMenu,
  644. 0,
  645. actionCollection(),
  646. "image_set_exif_orientation_flipped_vertically");
  647. d->imageSetExifOrientation5Action = new TDEAction(i18n("Rotated Right / Horiz. Flipped"),
  648. 0,
  649. d->imageExifOrientationActionMenu,
  650. 0,
  651. actionCollection(),
  652. "image_set_exif_orientation_rotated_right_hor_flipped");
  653. d->imageSetExifOrientation6Action = new TDEAction(i18n("Rotated Right"),
  654. 0,
  655. d->imageExifOrientationActionMenu,
  656. 0,
  657. actionCollection(),
  658. "image_set_exif_orientation_rotated_right");
  659. d->imageSetExifOrientation7Action = new TDEAction(i18n("Rotated Right / Vert. Flipped"),
  660. 0,
  661. d->imageExifOrientationActionMenu,
  662. 0,
  663. actionCollection(),
  664. "image_set_exif_orientation_rotated_right_ver_flipped");
  665. d->imageSetExifOrientation8Action = new TDEAction(i18n("Rotated Left"),
  666. 0,
  667. d->imageExifOrientationActionMenu,
  668. 0,
  669. actionCollection(),
  670. "image_set_exif_orientation_rotated_left");
  671. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation1Action);
  672. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation2Action);
  673. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation3Action);
  674. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation4Action);
  675. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation5Action);
  676. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation6Action);
  677. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation7Action);
  678. d->imageExifOrientationActionMenu->insert(d->imageSetExifOrientation8Action);
  679. connect(d->imageSetExifOrientation1Action, TQT_SIGNAL(activated()),
  680. exifOrientationMapper, TQT_SLOT(map()));
  681. connect(d->imageSetExifOrientation2Action, TQT_SIGNAL(activated()),
  682. exifOrientationMapper, TQT_SLOT(map()));
  683. connect(d->imageSetExifOrientation3Action, TQT_SIGNAL(activated()),
  684. exifOrientationMapper, TQT_SLOT(map()));
  685. connect(d->imageSetExifOrientation4Action, TQT_SIGNAL(activated()),
  686. exifOrientationMapper, TQT_SLOT(map()));
  687. connect(d->imageSetExifOrientation5Action, TQT_SIGNAL(activated()),
  688. exifOrientationMapper, TQT_SLOT(map()));
  689. connect(d->imageSetExifOrientation6Action, TQT_SIGNAL(activated()),
  690. exifOrientationMapper, TQT_SLOT(map()));
  691. connect(d->imageSetExifOrientation7Action, TQT_SIGNAL(activated()),
  692. exifOrientationMapper, TQT_SLOT(map()));
  693. connect(d->imageSetExifOrientation8Action, TQT_SIGNAL(activated()),
  694. exifOrientationMapper, TQT_SLOT(map()));
  695. exifOrientationMapper->setMapping(d->imageSetExifOrientation1Action, 1);
  696. exifOrientationMapper->setMapping(d->imageSetExifOrientation2Action, 2);
  697. exifOrientationMapper->setMapping(d->imageSetExifOrientation3Action, 3);
  698. exifOrientationMapper->setMapping(d->imageSetExifOrientation4Action, 4);
  699. exifOrientationMapper->setMapping(d->imageSetExifOrientation5Action, 5);
  700. exifOrientationMapper->setMapping(d->imageSetExifOrientation6Action, 6);
  701. exifOrientationMapper->setMapping(d->imageSetExifOrientation7Action, 7);
  702. exifOrientationMapper->setMapping(d->imageSetExifOrientation8Action, 8);
  703. // -----------------------------------------------------------------
  704. d->selectAllAction = new TDEAction(i18n("Select All"),
  705. 0,
  706. CTRL+Key_A,
  707. TQT_TQOBJECT(d->view),
  708. TQT_SLOT(slotSelectAll()),
  709. actionCollection(),
  710. "selectAll");
  711. d->selectNoneAction = new TDEAction(i18n("Select None"),
  712. 0,
  713. CTRL+SHIFT+Key_A,
  714. TQT_TQOBJECT(d->view),
  715. TQT_SLOT(slotSelectNone()),
  716. actionCollection(),
  717. "selectNone");
  718. d->selectInvertAction = new TDEAction(i18n("Invert Selection"),
  719. 0,
  720. CTRL+Key_Asterisk,
  721. TQT_TQOBJECT(d->view),
  722. TQT_SLOT(slotSelectInvert()),
  723. actionCollection(),
  724. "selectInvert");
  725. // -----------------------------------------------------------
  726. d->showMenuBarAction = KStdAction::showMenubar(TQT_TQOBJECT(this), TQT_SLOT(slotShowMenuBar()), actionCollection());
  727. KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT(slotEditKeys()), actionCollection());
  728. KStdAction::configureToolbars(TQT_TQOBJECT(this), TQT_SLOT(slotConfToolbars()), actionCollection());
  729. KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT(slotSetup()), actionCollection());
  730. // -----------------------------------------------------------
  731. d->zoomPlusAction = new TDEAction(i18n("Zoom In"),
  732. "zoom-in",
  733. CTRL+Key_Plus,
  734. TQT_TQOBJECT(d->view),
  735. TQT_SLOT(slotZoomIn()),
  736. actionCollection(),
  737. "album_zoomin");
  738. d->zoomMinusAction = new TDEAction(i18n("Zoom Out"),
  739. "zoom-out",
  740. CTRL+Key_Minus,
  741. TQT_TQOBJECT(d->view),
  742. TQT_SLOT(slotZoomOut()),
  743. actionCollection(),
  744. "album_zoomout");
  745. d->zoomTo100percents = new TDEAction(i18n("Zoom to 100%"),
  746. "zoom-original",
  747. ALT+CTRL+Key_0, // NOTE: Photoshop 7 use ALT+CTRL+0.
  748. TQT_TQOBJECT(d->view),
  749. TQT_SLOT(slotZoomTo100Percents()),
  750. actionCollection(),
  751. "album_zoomto100percents");
  752. d->zoomFitToWindowAction = new TDEAction(i18n("Fit to &Window"),
  753. "view_fit_window",
  754. CTRL+SHIFT+Key_E,
  755. TQT_TQOBJECT(d->view),
  756. TQT_SLOT(slotFitToWindow()),
  757. actionCollection(),
  758. "album_zoomfit2window");
  759. // Do not use std KDE action for full screen because action text is too large for app. toolbar.
  760. d->fullScreenAction = new TDEToggleAction(i18n("Full Screen"),
  761. "view-fullscreen",
  762. CTRL+SHIFT+Key_F,
  763. TQT_TQOBJECT(this),
  764. TQT_SLOT(slotToggleFullScreen()),
  765. actionCollection(),
  766. "full_screen");
  767. d->fullScreenAction->setWhatsThis(i18n("Switch the window to full screen mode"));
  768. d->slideShowAction = new TDEActionMenu(i18n("Slideshow"), "slideshow",
  769. actionCollection(), "slideshow");
  770. d->slideShowAction->setDelayed(false);
  771. d->slideShowAllAction = new TDEAction(i18n("All"), 0, Key_F9,
  772. TQT_TQOBJECT(d->view), TQT_SLOT(slotSlideShowAll()),
  773. actionCollection(), "slideshow_all");
  774. d->slideShowAction->insert(d->slideShowAllAction);
  775. d->slideShowSelectionAction = new TDEAction(i18n("Selection"), 0, ALT+Key_F9,
  776. TQT_TQOBJECT(d->view),
  777. TQT_SLOT(slotSlideShowSelection()),
  778. actionCollection(),
  779. "slideshow_selected");
  780. d->slideShowAction->insert(d->slideShowSelectionAction);
  781. d->slideShowRecursiveAction = new TDEAction(i18n("With All Sub-Albums"), 0, SHIFT+Key_F9,
  782. TQT_TQOBJECT(d->view),
  783. TQT_SLOT(slotSlideShowRecursive()),
  784. actionCollection(),
  785. "slideshow_recursive");
  786. d->slideShowAction->insert(d->slideShowRecursiveAction);
  787. d->quitAction = KStdAction::quit(TQT_TQOBJECT(this),
  788. TQT_SLOT(slotExit()),
  789. actionCollection(),
  790. "app_exit");
  791. d->rawCameraListAction = new TDEAction(i18n("Supported RAW Cameras"),
  792. "kdcraw",
  793. 0,
  794. TQT_TQOBJECT(this),
  795. TQT_SLOT(slotRawCameraList()),
  796. actionCollection(),
  797. "help_rawcameralist");
  798. d->kipiHelpAction = new TDEAction(i18n("Kipi Plugins Handbook"),
  799. "kipi",
  800. 0,
  801. TQT_TQOBJECT(this),
  802. TQT_SLOT(slotShowKipiHelp()),
  803. actionCollection(),
  804. "help_kipi");
  805. d->tipAction = KStdAction::tipOfDay(TQT_TQOBJECT(this),
  806. TQT_SLOT(slotShowTip()),
  807. actionCollection(),
  808. "help_tipofday");
  809. d->donateMoneyAction = new TDEAction(i18n("Donate..."),
  810. 0,
  811. 0,
  812. TQT_TQOBJECT(this),
  813. TQT_SLOT(slotDonateMoney()),
  814. actionCollection(),
  815. "help_donatemoney");
  816. d->contributeAction = new TDEAction(i18n("Contribute..."),
  817. 0, 0,
  818. TQT_TQOBJECT(this), TQT_SLOT(slotContribute()),
  819. actionCollection(),
  820. "help_contribute");
  821. new DLogoAction(actionCollection(), "logo_action" );
  822. // -- Rating actions ---------------------------------------------------------------
  823. d->rating0Star = new TDEAction(i18n("Assign Rating \"No Stars\""), CTRL+Key_0,
  824. TQT_TQOBJECT(d->view), TQT_SLOT(slotAssignRatingNoStar()),
  825. actionCollection(), "ratenostar");
  826. d->rating1Star = new TDEAction(i18n("Assign Rating \"One Star\""), CTRL+Key_1,
  827. TQT_TQOBJECT(d->view), TQT_SLOT(slotAssignRatingOneStar()),
  828. actionCollection(), "rateonestar");
  829. d->rating2Star = new TDEAction(i18n("Assign Rating \"Two Stars\""), CTRL+Key_2,
  830. TQT_TQOBJECT(d->view), TQT_SLOT(slotAssignRatingTwoStar()),
  831. actionCollection(), "ratetwostar");
  832. d->rating3Star = new TDEAction(i18n("Assign Rating \"Three Stars\""), CTRL+Key_3,
  833. TQT_TQOBJECT(d->view), TQT_SLOT(slotAssignRatingThreeStar()),
  834. actionCollection(), "ratethreestar");
  835. d->rating4Star = new TDEAction(i18n("Assign Rating \"Four Stars\""), CTRL+Key_4,
  836. TQT_TQOBJECT(d->view), TQT_SLOT(slotAssignRatingFourStar()),
  837. actionCollection(), "ratefourstar");
  838. d->rating5Star = new TDEAction(i18n("Assign Rating \"Five Stars\""), CTRL+Key_5,
  839. TQT_TQOBJECT(d->view), TQT_SLOT(slotAssignRatingFiveStar()),
  840. actionCollection(), "ratefivestar");
  841. // -----------------------------------------------------------
  842. TDEAction* findAction = KStdAction::find(TQT_TQOBJECT(d->view), TQT_SLOT(slotNewQuickSearch()),
  843. actionCollection(), "search_quick");
  844. findAction->setText(i18n("Search..."));
  845. findAction->setIconSet(BarIcon("filefind"));
  846. TDEAction* advFindAction = KStdAction::find(TQT_TQOBJECT(d->view), TQT_SLOT(slotNewAdvancedSearch()),
  847. actionCollection(), "search_advanced");
  848. advFindAction->setText(i18n("Advanced Search..."));
  849. advFindAction->setShortcut("Ctrl+Alt+F");
  850. new TDEAction(i18n("Light Table"), "idea", Key_L,
  851. TQT_TQOBJECT(d->view), TQT_SLOT(slotLightTable()), actionCollection(),
  852. "light_table");
  853. new TDEAction(i18n("Scan for New Images"), "reload_page", 0,
  854. TQT_TQOBJECT(this), TQT_SLOT(slotDatabaseRescan()), actionCollection(),
  855. "database_rescan");
  856. new TDEAction(i18n("Rebuild All Thumbnails..."), "reload_page", 0,
  857. TQT_TQOBJECT(this), TQT_SLOT(slotRebuildAllThumbs()), actionCollection(),
  858. "thumbs_rebuild");
  859. new TDEAction(i18n("Update Metadata Database..."), "reload_page", 0,
  860. TQT_TQOBJECT(this), TQT_SLOT(slotSyncAllPicturesMetadata()), actionCollection(),
  861. "sync_metadata");
  862. // -----------------------------------------------------------
  863. // Provides a menu entry that allows showing/hiding the toolbar(s)
  864. setStandardToolBarMenuEnabled(true);
  865. // Provides a menu entry that allows showing/hiding the statusbar
  866. createStandardStatusBarAction();
  867. // Load Cameras -- do this before the createGUI so that the cameras
  868. // are plugged into the toolbar at startup
  869. if (d->splashScreen)
  870. d->splashScreen->message(i18n("Loading cameras"));
  871. loadCameras();
  872. createGUI(TQString::fromLatin1( "digikamui.rc" ), false);
  873. // Initialize Actions ---------------------------------------
  874. d->deleteAction->setEnabled(false);
  875. d->addImagesAction->setEnabled(false);
  876. d->propsEditAction->setEnabled(false);
  877. d->openInKonquiAction->setEnabled(false);
  878. d->imageViewAction->setEnabled(false);
  879. d->imagePreviewAction->setEnabled(false);
  880. d->imageLightTableAction->setEnabled(false);
  881. d->imageAddLightTableAction->setEnabled(false);
  882. d->imageRenameAction->setEnabled(false);
  883. d->imageDeleteAction->setEnabled(false);
  884. d->imageExifOrientationActionMenu->setEnabled(false);
  885. d->slideShowSelectionAction->setEnabled(false);
  886. d->albumSortAction->setCurrentItem((int)d->albumSettings->getAlbumSortOrder());
  887. d->imageSortAction->setCurrentItem((int)d->albumSettings->getImageSortOrder());
  888. d->recurseAlbumsAction->setChecked(d->albumSettings->getRecurseAlbums());
  889. d->recurseTagsAction->setChecked(d->albumSettings->getRecurseTags());
  890. slotRecurseAlbums(d->recurseAlbumsAction->isChecked());
  891. slotRecurseTags(d->recurseTagsAction->isChecked());
  892. // Setting the filter condition also updates the tooltip.
  893. // (So `setRating` is called first, as otherwise the filter value is not respected).
  894. d->albumIconViewFilter->readSettings();
  895. }
  896. void DigikamApp::enableZoomPlusAction(bool val)
  897. {
  898. d->zoomPlusAction->setEnabled(val);
  899. d->statusZoomBar->setEnableZoomPlus(val);
  900. }
  901. void DigikamApp::enableZoomMinusAction(bool val)
  902. {
  903. d->zoomMinusAction->setEnabled(val);
  904. d->statusZoomBar->setEnableZoomMinus(val);
  905. }
  906. void DigikamApp::enableAlbumBackwardHistory(bool enable)
  907. {
  908. d->backwardActionMenu->setEnabled(enable);
  909. }
  910. void DigikamApp::enableAlbumForwardHistory(bool enable)
  911. {
  912. d->forwardActionMenu->setEnabled(enable);
  913. }
  914. void DigikamApp::slotAboutToShowBackwardMenu()
  915. {
  916. d->backwardActionMenu->popupMenu()->clear();
  917. TQStringList titles;
  918. d->view->getBackwardHistory(titles);
  919. if(!titles.isEmpty())
  920. {
  921. int id = 1;
  922. TQStringList::Iterator iter = titles.begin();
  923. for(; iter != titles.end(); ++iter,++id)
  924. {
  925. d->backwardActionMenu->popupMenu()->insertItem(*iter, id);
  926. }
  927. }
  928. }
  929. void DigikamApp::slotAboutToShowForwardMenu()
  930. {
  931. d->forwardActionMenu->popupMenu()->clear();
  932. TQStringList titles;
  933. d->view->getForwardHistory(titles);
  934. if(!titles.isEmpty())
  935. {
  936. int id = 1;
  937. TQStringList::Iterator iter = titles.begin();
  938. for(; iter != titles.end(); ++iter,++id)
  939. {
  940. d->forwardActionMenu->popupMenu()->insertItem(*iter, id);
  941. }
  942. }
  943. }
  944. void DigikamApp::slotAlbumSelected(bool val)
  945. {
  946. Album *album = d->albumManager->currentAlbum();
  947. if(album && !val)
  948. {
  949. // Not a PAlbum is selected
  950. d->deleteAction->setEnabled(false);
  951. d->addImagesAction->setEnabled(false);
  952. d->propsEditAction->setEnabled(false);
  953. d->openInKonquiAction->setEnabled(false);
  954. d->newAction->setEnabled(false);
  955. d->albumImportAction->setEnabled(false);
  956. }
  957. else if(!album && !val)
  958. {
  959. // Groupitem selected (Collection/date)
  960. d->deleteAction->setEnabled(false);
  961. d->addImagesAction->setEnabled(false);
  962. d->propsEditAction->setEnabled(false);
  963. d->openInKonquiAction->setEnabled(false);
  964. d->newAction->setEnabled(false);
  965. d->albumImportAction->setEnabled(false);
  966. TDEAction *action;
  967. for (action = d->kipiFileActionsImport.first(); action;
  968. action = d->kipiFileActionsImport.next())
  969. {
  970. action->setEnabled(false);
  971. }
  972. }
  973. else if(album && !album->isRoot() && album->type() == Album::PHYSICAL)
  974. {
  975. // Normal Album selected
  976. d->deleteAction->setEnabled(true);
  977. d->addImagesAction->setEnabled(true);
  978. d->propsEditAction->setEnabled(true);
  979. d->openInKonquiAction->setEnabled(true);
  980. d->newAction->setEnabled(true);
  981. d->albumImportAction->setEnabled(true);
  982. TDEAction *action;
  983. for (action = d->kipiFileActionsImport.first(); action;
  984. action = d->kipiFileActionsImport.next())
  985. {
  986. action->setEnabled(true);
  987. }
  988. }
  989. else if(album && album->isRoot() && album->type() == Album::PHYSICAL)
  990. {
  991. // Root Album selected
  992. d->deleteAction->setEnabled(false);
  993. d->addImagesAction->setEnabled(false);
  994. d->propsEditAction->setEnabled(false);
  995. if(album->type() == Album::PHYSICAL)
  996. {
  997. d->newAction->setEnabled(true);
  998. d->openInKonquiAction->setEnabled(true);
  999. d->albumImportAction->setEnabled(true);
  1000. }
  1001. else
  1002. {
  1003. d->newAction->setEnabled(false);
  1004. d->openInKonquiAction->setEnabled(false);
  1005. d->albumImportAction->setEnabled(false);
  1006. }
  1007. TDEAction *action;
  1008. for (action = d->kipiFileActionsImport.first(); action;
  1009. action = d->kipiFileActionsImport.next())
  1010. {
  1011. action->setEnabled(false);
  1012. }
  1013. }
  1014. }
  1015. void DigikamApp::slotTagSelected(bool val)
  1016. {
  1017. Album *album = d->albumManager->currentAlbum();
  1018. if (!album) return;
  1019. if(!val)
  1020. {
  1021. d->deleteTagAction->setEnabled(false);
  1022. d->editTagAction->setEnabled(false);
  1023. }
  1024. else if(!album->isRoot())
  1025. {
  1026. d->deleteTagAction->setEnabled(true);
  1027. d->editTagAction->setEnabled(true);
  1028. TDEAction *action;
  1029. for (action = d->kipiFileActionsImport.first(); action;
  1030. action = d->kipiFileActionsImport.next())
  1031. {
  1032. action->setEnabled(false);
  1033. }
  1034. }
  1035. else
  1036. {
  1037. d->deleteTagAction->setEnabled(false);
  1038. d->editTagAction->setEnabled(false);
  1039. TDEAction *action;
  1040. for (action = d->kipiFileActionsImport.first(); action;
  1041. action = d->kipiFileActionsImport.next())
  1042. {
  1043. action->setEnabled(false);
  1044. }
  1045. }
  1046. }
  1047. void DigikamApp::slotImageSelected(const TQPtrList<ImageInfo>& list, bool hasPrev, bool hasNext,
  1048. const KURL::List& listAll)
  1049. {
  1050. TQPtrList<ImageInfo> selection = list;
  1051. KURL::List all = listAll;
  1052. int num_images = listAll.count();
  1053. bool val = selection.isEmpty() ? false : true;
  1054. TQString text;
  1055. int index = 1;
  1056. d->imageViewAction->setEnabled(val);
  1057. d->imagePreviewAction->setEnabled(val);
  1058. d->imageLightTableAction->setEnabled(val);
  1059. d->imageAddLightTableAction->setEnabled(val);
  1060. d->imageRenameAction->setEnabled(val);
  1061. d->imageDeleteAction->setEnabled(val);
  1062. d->imageExifOrientationActionMenu->setEnabled(val);
  1063. d->slideShowSelectionAction->setEnabled(selection.count() != 0);
  1064. switch (selection.count())
  1065. {
  1066. case 0:
  1067. d->statusProgressBar->setText(i18n("No item selected"));
  1068. break;
  1069. case 1:
  1070. {
  1071. KURL first = selection.first()->kurl();
  1072. for (KURL::List::iterator it = all.begin();
  1073. it != all.end(); ++it)
  1074. {
  1075. if ((*it) == first)
  1076. break;
  1077. index++;
  1078. }
  1079. text = selection.first()->kurl().fileName()
  1080. + i18n(" (%1 of %2)")
  1081. .arg(TQString::number(index))
  1082. .arg(TQString::number(num_images));
  1083. d->statusProgressBar->setText(text);
  1084. break;
  1085. }
  1086. default:
  1087. d->statusProgressBar->setText(i18n("%1/%2 items selected")
  1088. .arg(selection.count()).arg(TQString::number(num_images)));
  1089. break;
  1090. }
  1091. d->statusNavigateBar->setNavigateBarState(hasPrev, hasNext);
  1092. }
  1093. void DigikamApp::slotProgressBarMode(int mode, const TQString& text)
  1094. {
  1095. d->statusProgressBar->progressBarMode(mode, text);
  1096. }
  1097. void DigikamApp::slotProgressValue(int count)
  1098. {
  1099. d->statusProgressBar->setProgressValue(count);
  1100. }
  1101. void DigikamApp::slotExit()
  1102. {
  1103. if (d->fullScreen)
  1104. {
  1105. slotToggleFullScreen();
  1106. TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(close()));
  1107. }
  1108. else
  1109. close();
  1110. }
  1111. TQString DigikamApp::convertToLocalUrl( const TQString& folder )
  1112. {
  1113. // This function is copied from k3b.
  1114. KURL url( folder );
  1115. if( !url.isLocalFile() )
  1116. {
  1117. #if KDE_IS_VERSION(3,4,91)
  1118. // Support for system:/ and media:/ (c) Stephan Kulow
  1119. KURL mlu = TDEIO::NetAccess::mostLocalURL( url, 0 );
  1120. if (mlu.isLocalFile())
  1121. return mlu.path();
  1122. DWarning() << folder << " mlu " << mlu << endl;
  1123. TQString path = mlu.path();
  1124. if ( mlu.protocol() == "system" && path.startsWith("/media") )
  1125. path = path.mid(7);
  1126. else if (mlu.protocol() == "media")
  1127. path = path.mid(1);
  1128. else
  1129. return folder; // nothing to see - go on
  1130. DDebug() << "parsed import path is: " << path << endl;
  1131. DCOPRef ref("kded", "mediamanager");
  1132. DCOPReply reply = ref.call("properties", path);
  1133. if (reply.isValid()) {
  1134. TQStringList slreply;
  1135. reply.get(slreply);
  1136. if ((slreply.count()>=9) && !slreply[9].isEmpty())
  1137. return slreply[9];
  1138. else
  1139. return slreply[6];
  1140. }
  1141. else
  1142. {
  1143. DWarning() << "dcop call failed\n";
  1144. }
  1145. return path;
  1146. #else
  1147. #ifndef UDS_LOCAL_PATH
  1148. #define UDS_LOCAL_PATH (72 | TDEIO::UDS_STRING)
  1149. #else
  1150. using namespace TDEIO;
  1151. #endif
  1152. TDEIO::UDSEntry e;
  1153. if( TDEIO::NetAccess::stat( url, e, 0 ) )
  1154. {
  1155. const TDEIO::UDSEntry::ConstIterator end = e.end();
  1156. for( TDEIO::UDSEntry::ConstIterator it = e.begin(); it != end; ++it )
  1157. {
  1158. if( (*it).m_uds == UDS_LOCAL_PATH && !(*it).m_str.isEmpty() )
  1159. return KURL::fromPathOrURL( (*it).m_str ).path();
  1160. }
  1161. }
  1162. #endif
  1163. }
  1164. return url.path();
  1165. }
  1166. void DigikamApp::slotDcopDownloadImages( const TQString& folder )
  1167. {
  1168. if (!folder.isNull())
  1169. {
  1170. // activate window when called by media menu and DCOP
  1171. if (isMinimized())
  1172. KWin::deIconifyWindow(winId());
  1173. KWin::activateWindow(winId());
  1174. slotDownloadImages(folder);
  1175. }
  1176. }
  1177. void DigikamApp::slotDcopCameraAutoDetect()
  1178. {
  1179. // activate window when called by media menu and DCOP
  1180. if (isMinimized())
  1181. KWin::deIconifyWindow(winId());
  1182. KWin::activateWindow(winId());
  1183. slotCameraAutoDetect();
  1184. }
  1185. void DigikamApp::slotDownloadImages( const TQString& folder)
  1186. {
  1187. if (!folder.isNull())
  1188. {
  1189. d->cameraGuiPath = folder;
  1190. TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotDownloadImages()));
  1191. }
  1192. }
  1193. void DigikamApp::slotDownloadImages()
  1194. {
  1195. if (d->cameraGuiPath.isNull())
  1196. return;
  1197. // Fetch the contents of the device. This is needed to make sure that the
  1198. // media:/device gets mounted.
  1199. TDEIO::ListJob *job = TDEIO::listDir(KURL(d->cameraGuiPath), false, false);
  1200. TDEIO::NetAccess::synchronousRun(job,0);
  1201. TQString localUrl = convertToLocalUrl(d->cameraGuiPath);
  1202. DDebug() << "slotDownloadImages: convertToLocalUrl " << d->cameraGuiPath << " to " << localUrl << endl;
  1203. if (localUrl.isNull())
  1204. return;
  1205. bool alreadyThere = false;
  1206. for (uint i = 0 ; i != actionCollection()->count() ; i++)
  1207. {
  1208. if (actionCollection()->action(i)->name() == d->cameraGuiPath)
  1209. alreadyThere = true;
  1210. }
  1211. if (!alreadyThere)
  1212. {
  1213. TDEAction *cAction = new TDEAction(
  1214. i18n("Browse %1").arg(KURL(d->cameraGuiPath).prettyURL()),
  1215. "camera-photo",
  1216. 0,
  1217. TQT_TQOBJECT(this),
  1218. TQT_SLOT(slotDownloadImages()),
  1219. actionCollection(),
  1220. d->cameraGuiPath.latin1() );
  1221. d->cameraMenuAction->insert(cAction, 0);
  1222. }
  1223. // the CameraUI will delete itself when it has finished
  1224. CameraUI* cgui = new CameraUI(this,
  1225. i18n("Images found in %1").arg(d->cameraGuiPath),
  1226. "directory browse","Fixed", localUrl, TQDateTime::currentDateTime());
  1227. cgui->show();
  1228. connect(cgui, TQT_SIGNAL(signalLastDestination(const KURL&)),
  1229. TQT_TQOBJECT(d->view), TQT_SLOT(slotSelectAlbum(const KURL&)));
  1230. connect(cgui, TQT_SIGNAL(signalAlbumSettingsChanged()),
  1231. TQT_TQOBJECT(this), TQT_SLOT(slotSetupChanged()));
  1232. }
  1233. void DigikamApp::slotCameraConnect()
  1234. {
  1235. CameraType* ctype = d->cameraList->find(TQString::fromUtf8(TQT_TQOBJECT(const_cast<TQT_BASE_OBJECT_NAME*>(sender()))->name()));
  1236. if (ctype)
  1237. {
  1238. // check not to open two dialogs for the same camera
  1239. if (ctype->currentCameraUI() && !ctype->currentCameraUI()->isClosed())
  1240. {
  1241. // show and raise dialog
  1242. if (ctype->currentCameraUI()->isMinimized())
  1243. KWin::deIconifyWindow(ctype->currentCameraUI()->winId());
  1244. KWin::activateWindow(ctype->currentCameraUI()->winId());
  1245. }
  1246. else
  1247. {
  1248. // the CameraUI will delete itself when it has finished
  1249. CameraUI* cgui = new CameraUI(this, ctype->title(), ctype->model(),
  1250. ctype->port(), ctype->path(), ctype->lastAccess());
  1251. ctype->setCurrentCameraUI(cgui);
  1252. cgui->show();
  1253. connect(cgui, TQT_SIGNAL(signalLastDestination(const KURL&)),
  1254. TQT_TQOBJECT(d->view), TQT_SLOT(slotSelectAlbum(const KURL&)));
  1255. connect(cgui, TQT_SIGNAL(signalAlbumSettingsChanged()),
  1256. TQT_TQOBJECT(this), TQT_SLOT(slotSetupChanged()));
  1257. }
  1258. }
  1259. }
  1260. void DigikamApp::slotCameraAdded(CameraType *ctype)
  1261. {
  1262. if (!ctype) return;
  1263. TDEAction *cAction = new TDEAction(ctype->title(), "camera-photo", 0,
  1264. TQT_TQOBJECT(this), TQT_SLOT(slotCameraConnect()),
  1265. actionCollection(),
  1266. ctype->title().utf8());
  1267. d->cameraMenuAction->insert(cAction, 0);
  1268. ctype->setAction(cAction);
  1269. }
  1270. void DigikamApp::slotCameraMediaMenu()
  1271. {
  1272. d->mediaItems.clear();
  1273. d->cameraMediaList->clear();
  1274. d->cameraMediaList->insertItem(i18n("No media devices found"), 0);
  1275. d->cameraMediaList->setItemEnabled(0, false);
  1276. KURL kurl("media:/");
  1277. TDEIO::ListJob *job = TDEIO::listDir(kurl, false, false);
  1278. connect( job, TQT_SIGNAL(entries(TDEIO::Job*,const TDEIO::UDSEntryList&)),
  1279. TQT_TQOBJECT(this), TQT_SLOT(slotCameraMediaMenuEntries(TDEIO::Job*,const TDEIO::UDSEntryList&)) );
  1280. }
  1281. void DigikamApp::slotCameraMediaMenuEntries( Job *, const UDSEntryList & list )
  1282. {
  1283. int i = 0;
  1284. for(TDEIO::UDSEntryList::ConstIterator it = list.begin() ; it != list.end() ; ++it)
  1285. {
  1286. TQString name;
  1287. TQString path;
  1288. for ( UDSEntry::const_iterator et = (*it).begin() ; et != (*it).end() ; ++et )
  1289. {
  1290. if ( (*et).m_uds == TDEIO::UDS_NAME)
  1291. name = ( *et ).m_str;
  1292. if ( (*et).m_uds == TDEIO::UDS_URL)
  1293. path = ( *et ).m_str;
  1294. //DDebug() << ( *et ).m_str << endl;
  1295. }
  1296. if (!name.isEmpty() && !path.isEmpty())
  1297. {
  1298. //DDebug() << "slotCameraMediaMenuEntries: Adding " << name << ", path " << path << endl;
  1299. if (i == 0)
  1300. d->cameraMediaList->clear();
  1301. d->mediaItems[i] = path;
  1302. d->cameraMediaList->insertItem(name, TQT_TQOBJECT(this), TQT_SLOT(slotDownloadImagesFromMedia(int)), 0, i);
  1303. d->cameraMediaList->setItemParameter(i, i);
  1304. i++;
  1305. }
  1306. }
  1307. }
  1308. void DigikamApp::slotDownloadImagesFromMedia( int id )
  1309. {
  1310. slotDownloadImages( d->mediaItems[id] );
  1311. }
  1312. void DigikamApp::slotCameraRemoved(CameraType *ctype)
  1313. {
  1314. if (!ctype) return;
  1315. TDEAction *cAction = ctype->action();
  1316. if (cAction)
  1317. d->cameraMenuAction->remove(cAction);
  1318. }
  1319. void DigikamApp::slotCameraAutoDetect()
  1320. {
  1321. bool retry = false;
  1322. CameraType* ctype = d->cameraList->autoDetect(retry);
  1323. if (!ctype && retry)
  1324. {
  1325. TQTimer::singleShot(0, TQT_TQOBJECT(this), TQT_SLOT(slotCameraAutoDetect()));
  1326. return;
  1327. }
  1328. if (ctype && ctype->action())
  1329. {
  1330. ctype->action()->activate();
  1331. }
  1332. }
  1333. void DigikamApp::slotSetup()
  1334. {
  1335. setup();
  1336. }
  1337. bool DigikamApp::setup(bool iccSetupPage)
  1338. {
  1339. Setup setup(this, 0, iccSetupPage ? Setup::IccProfiles : Setup::LastPageUsed);
  1340. // To show the number of KIPI plugins in the setup dialog.
  1341. KIPI::PluginLoader::PluginList list = d->kipiPluginLoader->pluginList();
  1342. setup.kipiPluginsPage()->initPlugins((int)list.count());
  1343. if (setup.exec() != TQDialog::Accepted)
  1344. return false;
  1345. setup.kipiPluginsPage()->applyPlugins();
  1346. slotSetupChanged();
  1347. return true;
  1348. }
  1349. void DigikamApp::slotSetupCamera()
  1350. {
  1351. Setup setup(this, 0, Setup::Camera);
  1352. // For to show the number of KIPI plugins in the setup dialog.
  1353. KIPI::PluginLoader::PluginList list = d->kipiPluginLoader->pluginList();
  1354. setup.kipiPluginsPage()->initPlugins((int)list.count());
  1355. if (setup.exec() != TQDialog::Accepted)
  1356. return;
  1357. setup.kipiPluginsPage()->applyPlugins();
  1358. slotSetupChanged();
  1359. }
  1360. void DigikamApp::slotSetupChanged()
  1361. {
  1362. // raw loading options might have changed
  1363. LoadingCacheInterface::cleanCache();
  1364. if(d->albumSettings->getAlbumLibraryPath() != d->albumManager->getLibraryPath())
  1365. d->view->clearHistory();
  1366. d->albumManager->setLibraryPath(d->albumSettings->getAlbumLibraryPath());
  1367. d->albumManager->startScan();
  1368. if(d->albumSettings->getShowFolderTreeViewItemsCount())
  1369. d->albumManager->refresh();
  1370. d->view->applySettings();
  1371. d->albumIconViewFilter->readSettings();
  1372. AlbumThumbnailLoader::instance()->setThumbnailSize(d->albumSettings->getDefaultTreeIconSize());
  1373. if (ImageWindow::imagewindowCreated())
  1374. ImageWindow::imagewindow()->applySettings();
  1375. if (LightTableWindow::lightTableWindowCreated())
  1376. LightTableWindow::lightTableWindow()->applySettings();
  1377. d->config->sync();
  1378. }
  1379. void DigikamApp::slotEditKeys()
  1380. {
  1381. KKeyDialog* dialog = new KKeyDialog();
  1382. dialog->insert( actionCollection(), i18n( "General" ) );
  1383. KIPI::PluginLoader::PluginList list = d->kipiPluginLoader->pluginList();
  1384. for( KIPI::PluginLoader::PluginList::Iterator it = list.begin() ; it != list.end() ; ++it )
  1385. {
  1386. KIPI::Plugin* plugin = (*it)->plugin();
  1387. if ( plugin )
  1388. dialog->insert( plugin->actionCollection(), (*it)->comment() );
  1389. }
  1390. dialog->configure();
  1391. delete dialog;
  1392. }
  1393. void DigikamApp::slotConfToolbars()
  1394. {
  1395. saveMainWindowSettings(TDEGlobal::config());
  1396. KEditToolbar *dlg = new KEditToolbar(actionCollection(), "digikamui.rc");
  1397. if(dlg->exec())
  1398. {
  1399. createGUI(TQString::fromLatin1( "digikamui.rc" ), false);
  1400. applyMainWindowSettings(TDEGlobal::config());
  1401. plugActionList( TQString::fromLatin1("file_actions_import"), d->kipiFileActionsImport );
  1402. plugActionList( TQString::fromLatin1("image_actions"), d->kipiImageActions );
  1403. plugActionList( TQString::fromLatin1("tool_actions"), d->kipiToolsActions );
  1404. plugActionList( TQString::fromLatin1("batch_actions"), d->kipiBatchActions );
  1405. plugActionList( TQString::fromLatin1("album_actions"), d->kipiAlbumActions );
  1406. plugActionList( TQString::fromLatin1("file_actions_export"), d->kipiFileActionsExport );
  1407. }
  1408. delete dlg;
  1409. }
  1410. void DigikamApp::slotToggleFullScreen()
  1411. {
  1412. if (d->fullScreen)
  1413. {
  1414. setWindowState( windowState() & ~WindowFullScreen );
  1415. menuBar()->show();
  1416. statusBar()->show();
  1417. topDock()->show();
  1418. bottomDock()->show();
  1419. leftDock()->show();
  1420. rightDock()->show();
  1421. d->view->showSideBars();
  1422. d->fullScreen = false;
  1423. }
  1424. else
  1425. {
  1426. TDEConfig* config = kapp->config();
  1427. config->setGroup("ImageViewer Settings");
  1428. bool fullScreenHideToolBar = config->readBoolEntry("FullScreen Hide ToolBar", false);
  1429. menuBar()->hide();
  1430. statusBar()->hide();
  1431. if (fullScreenHideToolBar)
  1432. topDock()->hide();
  1433. bottomDock()->hide();
  1434. leftDock()->hide();
  1435. rightDock()->hide();
  1436. d->view->hideSideBars();
  1437. showFullScreen();
  1438. d->fullScreen = true;
  1439. }
  1440. }
  1441. void DigikamApp::slotShowTip()
  1442. {
  1443. #if KDE_IS_VERSION(3,2,0)
  1444. TQStringList tipsFiles;
  1445. tipsFiles.append("digikam/tips");
  1446. tipsFiles.append("kipi/tips");
  1447. KTipDialog::showMultiTip(this, tipsFiles, true);
  1448. #else
  1449. KTipDialog::showTip(this, "digikam/tips", true);
  1450. #endif
  1451. }
  1452. void DigikamApp::slotShowKipiHelp()
  1453. {
  1454. TDEApplication::kApplication()->invokeHelp( TQString(), "kipi-plugins" );
  1455. }
  1456. void DigikamApp::slotRawCameraList()
  1457. {
  1458. RawCameraDlg dlg(this);
  1459. dlg.exec();
  1460. }
  1461. void DigikamApp::loadPlugins()
  1462. {
  1463. if(d->splashScreen)
  1464. d->splashScreen->message(i18n("Loading Kipi Plugins"));
  1465. TQStringList ignores;
  1466. d->kipiInterface = new DigikamKipiInterface( TQT_TQOBJECT(this), "Digikam_KIPI_interface" );
  1467. ignores.append( "HelloWorld" );
  1468. ignores.append( "KameraKlient" );
  1469. d->kipiPluginLoader = new KIPI::PluginLoader( ignores, d->kipiInterface );
  1470. connect( d->kipiPluginLoader, TQT_SIGNAL( replug() ),
  1471. TQT_TQOBJECT(this), TQT_SLOT( slotKipiPluginPlug() ) );
  1472. d->kipiPluginLoader->loadPlugins();
  1473. d->kipiInterface->slotCurrentAlbumChanged(d->albumManager->currentAlbum());
  1474. // Setting the initial menu options after all plugins have been loaded
  1475. d->view->slotAlbumSelected(d->albumManager->currentAlbum());
  1476. d->imagePluginsLoader = new ImagePluginLoader(TQT_TQOBJECT(this), d->splashScreen);
  1477. }
  1478. void DigikamApp::slotKipiPluginPlug()
  1479. {
  1480. unplugActionList( TQString::fromLatin1("file_actions_export") );
  1481. unplugActionList( TQString::fromLatin1("file_actions_import") );
  1482. unplugActionList( TQString::fromLatin1("image_actions") );
  1483. unplugActionList( TQString::fromLatin1("tool_actions") );
  1484. unplugActionList( TQString::fromLatin1("batch_actions") );
  1485. unplugActionList( TQString::fromLatin1("album_actions") );
  1486. d->kipiImageActions.clear();
  1487. d->kipiFileActionsExport.clear();
  1488. d->kipiFileActionsImport.clear();
  1489. d->kipiToolsActions.clear();
  1490. d->kipiBatchActions.clear();
  1491. d->kipiAlbumActions.clear();
  1492. KIPI::PluginLoader::PluginList list = d->kipiPluginLoader->pluginList();
  1493. int cpt = 0;
  1494. for( KIPI::PluginLoader::PluginList::Iterator it = list.begin() ; it != list.end() ; ++it )
  1495. {
  1496. KIPI::Plugin* plugin = (*it)->plugin();
  1497. if ( !plugin || !(*it)->shouldLoad() )
  1498. continue;
  1499. ++cpt;
  1500. plugin->setup( this );
  1501. TQPtrList<TDEAction>* popup = 0;
  1502. // Plugin category identification using TDEAction method based.
  1503. TDEActionPtrList actions = plugin->actions();
  1504. // List of obsolete kipi-plugins to not load.
  1505. TQStringList pluginActionsDisabled;
  1506. pluginActionsDisabled << TQString("raw_converter_single"); // Obsolete Since 0.9.5 and new Raw Import tool.
  1507. for( TDEActionPtrList::Iterator it2 = actions.begin(); it2 != actions.end(); ++it2 )
  1508. {
  1509. if ( plugin->category(*it2) == KIPI::IMAGESPLUGIN )
  1510. popup = &d->kipiImageActions;
  1511. else if ( plugin->category(*it2) == KIPI::EXPORTPLUGIN )
  1512. popup = &d->kipiFileActionsExport;
  1513. else if ( plugin->category(*it2) == KIPI::IMPORTPLUGIN )
  1514. popup = &d->kipiFileActionsImport;
  1515. else if ( plugin->category(*it2) == KIPI::TOOLSPLUGIN )
  1516. popup = &d->kipiToolsActions;
  1517. else if ( plugin->category(*it2) == KIPI::BATCHPLUGIN )
  1518. popup = &d->kipiBatchActions;
  1519. else if ( plugin->category(*it2) == KIPI::COLLECTIONSPLUGIN )
  1520. popup = &d->kipiAlbumActions;
  1521. TQString actionName((*it2)->name());
  1522. // Plug the KIPI plugins actions in according with the TDEAction method.
  1523. if (popup)
  1524. {
  1525. if (!pluginActionsDisabled.contains(actionName))
  1526. popup->append( *it2 );
  1527. else
  1528. DDebug() << "Plugin '" << actionName << "' disabled." << endl;
  1529. }
  1530. else
  1531. {
  1532. DDebug() << "No menu found for plugin '" << actionName << "' !!!" << endl;
  1533. }
  1534. }
  1535. plugin->actionCollection()->readShortcutSettings();
  1536. }
  1537. // Create GUI menu in according with plugins.
  1538. plugActionList( TQString::fromLatin1("file_actions_export"), d->kipiFileActionsExport );
  1539. plugActionList( TQString::fromLatin1("file_actions_import"), d->kipiFileActionsImport );
  1540. plugActionList( TQString::fromLatin1("image_actions"), d->kipiImageActions );
  1541. plugActionList( TQString::fromLatin1("tool_actions"), d->kipiToolsActions );
  1542. plugActionList( TQString::fromLatin1("batch_actions"), d->kipiBatchActions );
  1543. plugActionList( TQString::fromLatin1("album_actions"), d->kipiAlbumActions );
  1544. }
  1545. void DigikamApp::loadCameras()
  1546. {
  1547. d->cameraList->load();
  1548. d->cameraMenuAction->popupMenu()->insertSeparator();
  1549. d->cameraMenuAction->popupMenu()->insertItem(i18n("Browse Media"), d->cameraMediaList);
  1550. d->cameraMenuAction->popupMenu()->insertSeparator();
  1551. d->cameraMenuAction->insert(new TDEAction(i18n("Add Camera..."), 0,
  1552. TQT_TQOBJECT(this), TQT_SLOT(slotSetupCamera()),
  1553. actionCollection(),
  1554. "camera_add"));
  1555. }
  1556. void DigikamApp::populateThemes()
  1557. {
  1558. if(d->splashScreen)
  1559. d->splashScreen->message(i18n("Loading themes"));
  1560. ThemeEngine::instance()->scanThemes();
  1561. d->themeMenuAction->setItems(ThemeEngine::instance()->themeNames());
  1562. slotThemeChanged();
  1563. ThemeEngine::instance()->slotChangeTheme(d->themeMenuAction->currentText());
  1564. }
  1565. void DigikamApp::slotChangeTheme(const TQString& theme)
  1566. {
  1567. d->albumSettings->setCurrentTheme(theme);
  1568. ThemeEngine::instance()->slotChangeTheme(theme);
  1569. }
  1570. void DigikamApp::slotThemeChanged()
  1571. {
  1572. TQStringList themes(ThemeEngine::instance()->themeNames());
  1573. int index = themes.findIndex(d->albumSettings->getCurrentTheme());
  1574. if (index == -1)
  1575. index = themes.findIndex(i18n("Default"));
  1576. d->themeMenuAction->setCurrentItem(index);
  1577. }
  1578. void DigikamApp::slotDatabaseRescan()
  1579. {
  1580. ScanLib sLib;
  1581. sLib.startScan();
  1582. d->view->refreshView();
  1583. if (ImageWindow::imagewindowCreated())
  1584. ImageWindow::imagewindow()->refreshView();
  1585. if (LightTableWindow::lightTableWindowCreated())
  1586. LightTableWindow::lightTableWindow()->refreshView();
  1587. }
  1588. void DigikamApp::slotRebuildAllThumbs()
  1589. {
  1590. TQString msg = i18n("Rebuilding all image thumbnails can take some time.\n"
  1591. "Do you want to continue?");
  1592. int result = KMessageBox::warningContinueCancel(this, msg);
  1593. if (result != KMessageBox::Continue)
  1594. return;
  1595. BatchThumbsGenerator *thumbsGenerator = new BatchThumbsGenerator(this);
  1596. connect(thumbsGenerator, TQT_SIGNAL(signalRebuildAllThumbsDone()),
  1597. TQT_TQOBJECT(this), TQT_SLOT(slotRebuildAllThumbsDone()));
  1598. thumbsGenerator->exec();
  1599. }
  1600. void DigikamApp::slotRebuildAllThumbsDone()
  1601. {
  1602. d->view->applySettings();
  1603. }
  1604. void DigikamApp::slotSyncAllPicturesMetadata()
  1605. {
  1606. TQString msg = i18n("Updating the metadata database can take some time. \nDo you want to continue?");
  1607. int result = KMessageBox::warningContinueCancel(this, msg);
  1608. if (result != KMessageBox::Continue)
  1609. return;
  1610. BatchAlbumsSyncMetadata *syncMetadata = new BatchAlbumsSyncMetadata(this);
  1611. connect(syncMetadata, TQT_SIGNAL(signalComplete()),
  1612. TQT_TQOBJECT(this), TQT_SLOT(slotSyncAllPicturesMetadataDone()));
  1613. syncMetadata->exec();
  1614. }
  1615. void DigikamApp::slotSyncAllPicturesMetadataDone()
  1616. {
  1617. d->view->applySettings();
  1618. }
  1619. void DigikamApp::slotDonateMoney()
  1620. {
  1621. TDEApplication::kApplication()->invokeBrowser("http://www.digikam.org/?q=donation");
  1622. }
  1623. void DigikamApp::slotContribute()
  1624. {
  1625. TDEApplication::kApplication()->invokeBrowser("http://www.digikam.org/?q=contrib");
  1626. }
  1627. void DigikamApp::slotRecurseAlbums(bool checked)
  1628. {
  1629. AlbumLister::instance()->setRecurseAlbums(checked);
  1630. }
  1631. void DigikamApp::slotRecurseTags(bool checked)
  1632. {
  1633. AlbumLister::instance()->setRecurseTags(checked);
  1634. }
  1635. void DigikamApp::slotZoomSliderChanged(int size)
  1636. {
  1637. d->view->setThumbSize(size);
  1638. }
  1639. void DigikamApp::slotThumbSizeChanged(int size)
  1640. {
  1641. d->statusZoomBar->setZoomSliderValue(size);
  1642. d->statusZoomBar->setZoomTrackerText(i18n("Size: %1").arg(size));
  1643. }
  1644. void DigikamApp::slotZoomChanged(double zoom, int size)
  1645. {
  1646. d->statusZoomBar->setZoomSliderValue(size);
  1647. d->statusZoomBar->setZoomTrackerText(i18n("zoom: %1%").arg((int)(zoom*100.0)));
  1648. }
  1649. void DigikamApp::slotTogglePreview(bool t)
  1650. {
  1651. // NOTE: if 't' is true, we are in Preview Mode, else we are in AlbumView Mode
  1652. // This is require if ESC is pressed to go out of Preview Mode.
  1653. // imagePreviewAction is handled by F3 key only.
  1654. d->imagePreviewAction->setChecked(t);
  1655. // Here, we will toggle some menu actions depending of current Mode.
  1656. // Select menu.
  1657. d->selectAllAction->setEnabled(!t);
  1658. d->selectNoneAction->setEnabled(!t);
  1659. d->selectInvertAction->setEnabled(!t);
  1660. // View menu
  1661. d->albumSortAction->setEnabled(!t);
  1662. d->imageSortAction->setEnabled(!t);
  1663. d->zoomTo100percents->setEnabled(t);
  1664. d->zoomFitToWindowAction->setEnabled(t);
  1665. }
  1666. void DigikamApp::slotAlbumAddImages()
  1667. {
  1668. TQString path = KFileDialog::getExistingDirectory(TDEGlobalSettings::documentPath(), this,
  1669. i18n("Select folder to parse"));
  1670. if(path.isEmpty())
  1671. return;
  1672. // The folder contents will be parsed by Camera interface in "Directory Browse" mode.
  1673. downloadFrom(path);
  1674. }
  1675. void DigikamApp::slotShowMenuBar()
  1676. {
  1677. if (menuBar()->isVisible())
  1678. menuBar()->hide();
  1679. else
  1680. menuBar()->show();
  1681. }
  1682. } // namespace Digikam