AlbumShaper  1.0a3
subalbumWidget.cpp
Go to the documentation of this file.
1 //==============================================
2 // copyright : (C) 2003-2005 by Will Stokes
3 //==============================================
4 // This program is free software; you can redistribute it
5 // and/or modify it under the terms of the GNU General
6 // Public License as published by the Free Software
7 // Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //==============================================
10 
11 //Systemwide includes
12 #include <qlayout.h>
13 #include <qfont.h>
14 #include <q3frame.h>
15 #include <qpushbutton.h>
16 #include <qtoolbutton.h>
17 #include <qpixmap.h>
18 #include <q3filedialog.h>
19 #include <qcursor.h>
20 #include <qapplication.h>
21 #include <qtooltip.h>
22 #include <qfileinfo.h>
23 #include <q3accel.h>
24 //Added by qt3to4:
25 #include <QResizeEvent>
26 #include <Q3GridLayout>
27 
28 //Projectwide includes
29 #include "window.h"
30 #include "titleWidget.h"
31 #include "layoutWidget.h"
32 #include "subalbumWidget.h"
33 #include "subalbumsWidget.h"
34 #include "photoPreviewWidget.h"
35 #include "photosIconView.h"
36 #include "statusWidget.h"
37 
39 #include "dialogs/questionDialog.h"
40 #include "dialogs/alertDialog.h"
41 
42 #include "../config.h"
43 #include "../backend/subalbum.h"
44 #include "../backend/photo.h"
45 #include "../backend/tools/guiTools.h"
46 #include "../backend/tools/wallpaperTools.h"
47 #include "../configuration/configuration.h"
48 
49 #include "../backend/album.h"
50 
51 //==============================================
53  QWidget *parent,
54  const char* name ) :
55  QWidget(parent,name)
56 {
57  setWindowFlags(Qt::WNoAutoErase);
58 
59  //store subalbum pointer
60  subalbum = salbum;
61 
62  //store layout pointer
63  layout = (LayoutWidget*)parent;
64 
65  //create photo collection
66  photos = new PhotosIconView( this );
67 
68  //establish a top-down view such that the scrollbar is always placed on the right
69  photos->setArrangement( Q3IconView::LeftToRight );
70  photos->setVScrollBarMode( Q3ScrollView::Auto );
71 
72  //allow multiple photos to be selected with control and shift keys
73  photos->setSelectionMode( Q3IconView::Extended ) ;
74 
75  //set auto-scroll on for drag-n-drop
76  photos->setDragAutoScroll(true);
77  photos->setAcceptDrops(true);
78 
79  //connect selectionChanged signal to update buttons method
80  connect( photos, SIGNAL(selectionChanged()),
81  this, SLOT( selectionChangedEvent()) );
82 
83  //connect rightButtonClicked signal to update buttons method
84  connect( photos, SIGNAL(rightButtonClicked(Q3IconViewItem*, const QPoint&)),
85  this, SLOT(selectionChangedEvent()) );
86 
87  //connect itemhasMoved signal on iconview to reorder slot (phots have been rearranged)
88  connect( photos, SIGNAL(itemHasMoved()), SLOT(reorder()) );
89 
90  //connect addPhtos signal from iconview to actually add photos from disk (Drop from outside target, ie konqueror)
91  connect( photos, SIGNAL(addPhotos(QStringList)), SLOT(addImageAction(QStringList)) );
92 
93  //connect keyevent signals from iconview
94  connect( photos, SIGNAL(removeSelectedPhotos()), SLOT(removeImageAction()) );
95  connect( photos, SIGNAL(rotate90SelectedPhotos()), SLOT(rotate90ImageAction()) );
96  connect( photos, SIGNAL(rotate270SelectedPhotos()), SLOT(rotate270ImageAction()) );
97 
98  //connect key e press signal to edit slot
99  connect( photos, SIGNAL(editSelectedPhoto()),
100  layout, SLOT(editSelectedPhoto()) );
101  //connect double click signal to edit slot
102  connect( photos, SIGNAL( doubleClicked(Q3IconViewItem*) ),
103  layout, SLOT(editSelectedPhoto()) );
104 
105  //create all buttons
106  buttonsFrame = new Q3Frame(this);
107  if(subalbum == NULL) buttonsFrame->hide();
108 
109  QFont buttonFont( qApp->font() );
110  buttonFont.setBold(true);
111  buttonFont.setPointSize( 11 );
112 
113  addImage = new QToolButton( buttonsFrame );
114  addImage->setTextLabel(tr("Add Photo"));
115  addImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/add.png") );
116  addImage->setTextPosition(QToolButton::BesideIcon);
117  addImage->setFont( buttonFont );
118  addImage->setUsesTextLabel( true );
119  addImage->setEnabled( true );
120  QToolTip::add( addImage, tr("Add photos to selected collection") );
121  connect( addImage, SIGNAL(clicked()), SLOT(addImageAction()) );
122 
123  removeImage = new QToolButton( buttonsFrame );
124  removeImage->setTextLabel(tr("Remove Photo"));
125  removeImage->setIconSet( QPixmap(QString(IMAGE_PATH)+"buttonIcons/remove.png") );
126  removeImage->setTextPosition(QToolButton::BesideIcon);
127  removeImage->setFont( buttonFont );
128  removeImage->setUsesTextLabel( true );
129  removeImage->setEnabled( true );
130  QToolTip::add( removeImage, tr("Remove selected photos from collection") );
131  connect( removeImage, SIGNAL(clicked()), SLOT(removeImageAction()) );
132 
133  rotate90Image = new QToolButton( buttonsFrame );
134  rotate90Image->setTextLabel(tr("Rotate Right") );
135  QIcon rotate90Icon;
136  rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90.png",
137  QIcon::Automatic,
138  QIcon::Normal );
139  rotate90Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate90_disabled.png",
140  QIcon::Automatic,
141  QIcon::Disabled );
142  rotate90Image->setIconSet( rotate90Icon );
143 
144  rotate90Image->setTextPosition(QToolButton::BesideIcon);
145  rotate90Image->setFont( buttonFont );
146  rotate90Image->setUsesTextLabel( true );
147  QToolTip::add( rotate90Image, tr("Rotate selected photos clockwise") );
148  connect( rotate90Image, SIGNAL(clicked()), SLOT(rotate90ImageAction()) );
149 
150  rotate270Image = new QToolButton( buttonsFrame );
151  rotate270Image->setTextLabel(tr("Rotate Left") );
152  QIcon rotate270Icon;
153  rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270.png",
154  QIcon::Automatic,
155  QIcon::Normal );
156  rotate270Icon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/rotate270_disabled.png",
157  QIcon::Automatic,
158  QIcon::Disabled );
159  rotate270Image->setIconSet( rotate270Icon );
160 
161  rotate270Image->setTextPosition(QToolButton::BesideIcon);
162  rotate270Image->setFont( buttonFont );
163  rotate270Image->setUsesTextLabel( true );
164  QToolTip::add( rotate270Image, tr("Rotate selected photos counterclockwise") );
165  connect( rotate270Image, SIGNAL(clicked()), SLOT(rotate270ImageAction()) );
166 
167  //place all items in grid layout
168  buttonsGrid = new Q3GridLayout( buttonsFrame, 1, 7, 0 );
169  buttonsGrid->addWidget( addImage, 0, 1, Qt::AlignLeft );
170  buttonsGrid->addWidget( removeImage, 0, 2, Qt::AlignLeft );
171  buttonsGrid->addWidget( rotate90Image, 0, 3, Qt::AlignLeft );
172  buttonsGrid->addWidget( rotate270Image, 0, 4, Qt::AlignLeft );
173  buttonsGrid->setColStretch( 0, 1 );
174  buttonsGrid->setColStretch( 6, 1 );
175 
176  //If setting the desktop wallpaper is supported on this system then add this button as well
177  if( setWallpaperSupported() )
178  {
179  setDesktopBtn = new QToolButton( buttonsFrame );
180  setDesktopBtn->setUsesTextLabel( true );
181  setDesktopBtn->setTextLabel(tr("Wallpaper") );
182  QIcon setDesktopIcon;
183  setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper.png",
184  QIcon::Automatic,
185  QIcon::Normal );
186  setDesktopIcon.setPixmap( QString(IMAGE_PATH)+"buttonIcons/setDesktopWallpaper_disabled.png",
187  QIcon::Automatic,
188  QIcon::Disabled );
189  setDesktopBtn->setIconSet( setDesktopIcon );
190 
191  setDesktopBtn->setTextPosition(QToolButton::BesideIcon);
192  setDesktopBtn->setFont( buttonFont );
193  setDesktopBtn->setUsesTextLabel( true );
194 
195  QToolTip::add( setDesktopBtn, tr("Set desktop wallpaper to selected photo") );
196  connect( setDesktopBtn, SIGNAL( clicked() ), this, SLOT( setWallpaperAction() ) );
197  buttonsGrid->addWidget( setDesktopBtn, 0, 5, Qt::AlignLeft );
198  }
199  else
200  { setDesktopBtn = NULL; }
201 
202  mainGrid = new Q3GridLayout( this, 2, 1, 0 );
203  mainGrid->addMultiCellWidget( photos, 0, 0, 0, 1 );
204  mainGrid->addMultiCellWidget( buttonsFrame, 1, 1, 0, 1 );
205  mainGrid->setRowStretch( 0, 1 );
206 
207  //set the background of the widget to be light blue
208  setPaletteBackgroundColor( QColor(193, 210, 238) );
209 
210  //by default no selected images so disable all buttons besides add
211  removeImage->setEnabled(false);
212  rotate90Image->setEnabled(false);
213  rotate270Image->setEnabled(false);
214 
215  //hook-up keyboard shortcut for deselecting all photos
216  //iconview provides select all shortcut for us
217  Q3Accel *keyAccel = new Q3Accel( this );
218  keyAccel->connectItem( keyAccel->insertItem( Qt::CTRL + Qt::SHIFT + Qt::Key_A ),
219  this, SLOT(deselectAll()) );
220 }
221 //==============================================
223 {
224  //set new subalbum pointer
225  subalbum = salbum;
226 
227  //update photo listing
228  refreshPhotos();
229 
230  if(subalbum == NULL) { buttonsFrame->hide(); }
231  else
232  {
233  //disable/enable buttons as necessary
234  buttonsFrame->show();
236  }
237 }
238 //==============================================
240 {
241  //---------------
242  //get file list
243 
244  Configuration* config = ((Window*)qApp->mainWidget())->getConfig();
245  QString path = config->getString( "loadSave", "addPhotoDir" );
246  QDir testPath(path);
247  if(!testPath.exists())
248  {
249  config->resetSetting( "loadSave", "addPhotoDir" );
250  path = config->getString( "loadSave", "addPhotoDir" );
251  }
252 
253  AddPhotosDialog* fileDialog = new AddPhotosDialog( path );
254  bool setDescriptions;
255  QStringList fileNames = fileDialog->getFilenames( setDescriptions );
256 
257  if(!fileNames.empty())
258  {
259  //store this addPhoto location
260  QDir lastDir = QDir( QFileInfo(*fileNames.begin()).dirPath() );
261  config->setString( "loadSave", "addPhotoDir", lastDir.path() );
262  addImageAction( fileNames, setDescriptions );
263  }
264 }
265 //==============================================
266 void SubalbumWidget::addImageAction(QStringList fileNames, bool setDescriptions)
267 {
268  if(fileNames.empty())
269  return;
270 
271  //---------------
272  //set busy flag and deactivate menu's/buttons, and selecting photos
273  layout->getWindow()->getTitle()->setBusy(true);
274  layout->getSubalbums()->updateButtons(false);
275  updateButtons(false);
276  photos->setSelectionMode( Q3IconView::NoSelection ) ;
277 
278  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
279 
280  //setup progress bar
281  QString statusMessage = tr("Adding %1 photos:");
282 
283  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(fileNames.count()), fileNames.count() );
284  qApp->processEvents();
285 
286  //iterate through each file and add to album
287  QStringList::iterator it;
288  int num=0;
289  for(it = fileNames.begin(); it != fileNames.end(); it++ )
290  {
291  //update status message
292  layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(fileNames.count() - num) );
293 
294  //if item is a file, add photo
295  if(QFileInfo(*it).isFile() && subalbum->addPhoto(*it, setDescriptions))
296  {
298  photos->ensureItemVisible(p);
299  }
300  num++;
301  qApp->processEvents();
302  }
303  photos->arrangeItemsInGrid();
304 
305  //remove progress bar
306  layout->getWindow()->getStatus()->setStatus( tr("Adding photos complete.") );
307 
308  //notifty title widget that the album's photo count has possible changed
310 
311  //unset busy flag and activate menu's/buttons
312  layout->getWindow()->getTitle()->setBusy(false);
314  updateButtons(true);
315  photos->setSelectionMode( Q3IconView::Extended ) ;
316 
317  qApp->restoreOverrideCursor();
318 }
319 //==============================================
321 {
322  //set busy flag and deactivate menu's/buttons
323  layout->getWindow()->getTitle()->setBusy(true);
324  layout->getSubalbums()->updateButtons(false);
325  updateButtons(false);
326  photos->setSelectionMode( Q3IconView::NoSelection ) ;
327 
328  //if user has chosen to not receive destructive action warnings, or agrees to the action, then
329  //delete photo and refresh view
330  bool proceed = !((Window*)qApp->mainWidget())->getConfig()->getBool( "alerts", "showDestructiveAlerts" );
331  if(!proceed)
332  {
333  QuestionDialog sure( tr("Remove selected photos?"),
334  tr("Once removed photos cannot be restored. Furthermore upon resaving they are physically removed from your album."),
335  "alertIcons/warning.png",
336  this );
337  proceed = sure.exec();
338  }
339  if(proceed)
340  {
341  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
342  //iterate through all photos and remove those that are selected
343  Q3IconViewItem* current = photos->firstItem();
344  Q3IconViewItem* temp;
345 
346  while(current != NULL)
347  {
348  //if not selected move on
349  if(!current->isSelected())
350  {
351  current = current->nextItem();
352  continue;
353  }
354 
355  //get next pointer
356  temp = current->nextItem();
357 
358  //grab point to backend photo
359  Photo* phto = ((PhotoPreviewWidget*)current)->getPhoto();
360 
361  //delete photo widget
362  delete current;
363  current = temp;
364 
365  //delete backend photo
366  subalbum->removePhoto(phto);
367  }
368 
369  //cleanup arrangement in case items were deleted in the middle or front
370  photos->arrangeItemsInGrid();
371 
372  //unset busy flag and activate menu's/buttons
373  qApp->restoreOverrideCursor();
374  }
375 
376  layout->getWindow()->getTitle()->setBusy(false);
378  updateButtons(true);
379  photos->setSelectionMode( Q3IconView::Extended ) ;
380 
381  //update buttons and emit selection changed signal
383 }
384 //==============================================
386 {
387  //iterate over photos in current collection
388  Q3IconViewItem* current = photos->firstItem();
389  while(current != NULL)
390  {
391  //found a selected item!
392  if(current->isSelected())
393  {
394  ((PhotoPreviewWidget*)current)->getPhoto()->revertPhoto();
395  photos->ensureItemVisible(((PhotoPreviewWidget*)current));
396  ((PhotoPreviewWidget*)current)->updateImage();
397  qApp->processEvents();
398  }
399 
400  //move to next item
401  current = current->nextItem();
402  }
403 
404  //state of selected photos has changed
406 }
407 //==============================================
409 {
410  //get first selected photo, if no photo is selected then bail
411  Photo* phto = getSelectedPhoto();
412  if(phto == NULL) return;
413 
414  //set the wallpaper
415  setWallpaper( phto );
416 }
417 //==============================================
419 {
420  //set busy flag and deactivate menu's/buttons
421  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
422  layout->getWindow()->getTitle()->setBusy(true);
423  layout->getSubalbums()->updateButtons(false);
424  photos->setSelectionMode( Q3IconView::NoSelection ) ;
425  updateButtons(false);
426 
427  //setup progress bar
428  QString statusMessage = tr("Rotating %1 photos:");
429  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() );
430  qApp->processEvents();
431 
432  //rotate the selected photos
433  int num = 0;
434  Q3IconViewItem* current = photos->firstItem();
435  while(current != NULL)
436  {
437  if(current->isSelected())
438  {
439  //update status message
440  layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) );
441 
442  ((PhotoPreviewWidget*)current)->getPhoto()->rotate90();
443  photos->ensureItemVisible(((PhotoPreviewWidget*)current));
444  ((PhotoPreviewWidget*)current)->updateImage();
445  num++;
447  qApp->processEvents();
448  }
449 
450  //move to next item
451  current = current->nextItem();
452  }
453 
454  //state of selected photos has changed
456 
457  //hide progress bar
458  layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") );
459 
460  //not busy any more
461  layout->getWindow()->getTitle()->setBusy(false);
463  updateButtons(true);
464  photos->setSelectionMode( Q3IconView::Extended ) ;
465 
466  qApp->restoreOverrideCursor();
467 }
468 //==============================================
470 {
471  //set busy flag and deactivate menu's/buttons
472  qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
473  layout->getWindow()->getTitle()->setBusy(true);
474  layout->getSubalbums()->updateButtons(false);
475  photos->setSelectionMode( Q3IconView::NoSelection ) ;
476  updateButtons(false);
477 
478  //setup progress bar
479  QString statusMessage = tr("Rotating %1 photos:");
480  layout->getWindow()->getStatus()->showProgressBar( statusMessage.arg(photos->numSelected()), photos->numSelected() );
481  qApp->processEvents();
482 
483  //rotate the selected photos
484  int num = 0;
485  Q3IconViewItem* current = photos->firstItem();
486  while(current != NULL)
487  {
488  if(current->isSelected())
489  {
490  //update status message
491  layout->getWindow()->getStatus()->updateProgress( num, statusMessage.arg(photos->numSelected() - num) );
492 
493  ((PhotoPreviewWidget*)current)->getPhoto()->rotate270();
494  photos->ensureItemVisible(((PhotoPreviewWidget*)current));
495  ((PhotoPreviewWidget*)current)->updateImage();
496  num++;
498  qApp->processEvents();
499  }
500 
501  //move to next item
502  current = current->nextItem();
503  }
504 
505  //state of selected photos has changed
507 
508  //hide progress bar
509  layout->getWindow()->getStatus()->setStatus( tr("Rotating complete.") );
510 
511  //not busy any more
512  layout->getWindow()->getTitle()->setBusy(false);
514  updateButtons(true);
515  photos->setSelectionMode( Q3IconView::Extended ) ;
516  qApp->restoreOverrideCursor();
517 }
518 //==============================================
520 {
521  //remove all thumbnails
522  photos->clear();
523 
524  if(subalbum != NULL)
525  {
526  //insert photo thumbnails
527  Photo* currentPhoto = subalbum->getFirst();
528  while(currentPhoto != NULL)
529  {
530  new PhotoPreviewWidget( photos, currentPhoto );
531  currentPhoto = currentPhoto->getNext();
532  }
533 
534  photos->arrangeItemsInGrid();
535  }
536 }
537 //==============================================
539 {
540  Q3IconViewItem* current = photos->firstItem();
541  while(current != NULL)
542  {
543  ((PhotoPreviewWidget*)current)->updateImage();
544  ((PhotoPreviewWidget*)current)->updateDescription();
545  current = current->nextItem();
546  }
547 }
548 //==============================================
550 {
551  Q3IconViewItem* current = photos->firstItem();
552  while(current != NULL)
553  {
554  //found a selected item!
555  if(current->isSelected())
556  {
557  ((PhotoPreviewWidget*)current)->updateImage();
558  ((PhotoPreviewWidget*)current)->updateDescription();
559  }
560 
561  //move to next item
562  current = current->nextItem();
563  }
564 }
565 //==============================================
567 {
568  Q3IconViewItem* current = photos->firstItem();
569  while(current != NULL)
570  {
571  //found a selected item!
572  if(current->isSelected())
573  {
574  ((PhotoPreviewWidget*)current)->getPhoto()->setDescription("");
575  ((PhotoPreviewWidget*)current)->setText( "" );
576  }
577 
578  //move to next item
579  current = current->nextItem();
580  }
581 }
582 //==============================================
584 {
585  return subalbum;
586 }
587 //==============================================
589 {
590  //determine if one photo is selected
591  int numSelected = 0;
592  Q3IconViewItem* current = photos->firstItem();
593  Q3IconViewItem* selected = NULL;
594  while(current != NULL)
595  {
596  //found a selected item!
597  if(current->isSelected())
598  {
599  numSelected++;
600  selected = current;
601  }
602 
603  //if more than one found then bail!
604  if(numSelected > 1) return NULL;
605 
606  //move to next item
607  current = current->nextItem();
608  }
609 
610  //if one item is selected then return photo pointer
611  if(numSelected == 1) { return ((PhotoPreviewWidget*)selected)->getPhoto(); }
612  else { return NULL; }
613 }
614 //==============================================
616 {
617  //determine if one photo is selected
618  Q3IconViewItem* current = photos->firstItem();
619  while(current != NULL)
620  {
621  //found a selected item!
622  if(current->isSelected())
623  { return ((PhotoPreviewWidget*)current)->getPhoto(); }
624 
625  //move to next item
626  current = current->nextItem();
627  }
628 
629  //no selected items found
630  return NULL;
631 }
632 //==============================================
634 {
635  //select specified photo
636  Q3IconViewItem* current = photos->firstItem();
637  while(current != NULL)
638  {
639  if( ((PhotoPreviewWidget*)current)->getPhoto() == selection )
640  {
641  //deselect all
642  photos->selectAll(false);
643 
644  //select photo and make sure it is visible
645  current->setSelected(true);
646  photos->ensureItemVisible( current );
647 
648  return;
649  }
650 
651  //move on to next photo
652  current = current->nextItem();
653  }
654 }
655 //==============================================
657 {
658  Q3IconViewItem* current = photos->firstItem();
659  while(current != NULL)
660  {
661  if(current->isSelected())
662  return true;
663  current = current->nextItem();
664  }
665  return false;
666 }
667 //==============================================
669 {
670  Q3IconViewItem* current = photos->firstItem();
671  while(current != NULL)
672  {
673  if(current->isSelected())
674  {
675  if( ((PhotoPreviewWidget*)current)->getPhoto()->revertPossible() )
676  return true;
677  }
678  current = current->nextItem();
679  }
680  return false;
681 }
682 //==============================================
683 void SubalbumWidget::resizeEvent( QResizeEvent * )
684 {
685  photos->arrangeItemsInGrid();
686 }
687 //==============================================
689 {
690  return photos;
691 }
692 //==============================================
694 {
695  //so item has been moved, reorder linked list of items as necessary
696  photos->sort( true );
697  photos->arrangeItemsInGrid();
698 
699  //sync lists
701 }
702 //==============================================
704 {
705  //update rotate/add/remove buttons depending on whether or not any items are selected
706  updateButtons();
707 
708  //emit selection changed signal so other menu's etc an be updated as well
710 }
711 //==============================================
713 {
714  int numSelected = 0;
715  Q3IconViewItem* current = photos->firstItem();
716  while(current != NULL)
717  {
718  if(current->isSelected())
719  {
720  numSelected++;
721 
722  //there are effectively 3 states:
723  //1) no items selected -> disable all buttons besides addPhoto
724  //2) one itme selected -> enable all button, including set desktop wallpaper button
725  //3) more than one item selected -> enable all but edit button (since we don't know which photo to edit)
726  //thus once 2 selected photos are found we know we are in the multi select mode and can terminate the search
727  if(numSelected > 1)
728  break;
729  }
730 
731  //move to next item
732  current = current->nextItem();
733  }
734 
735  if(numSelected == 0)
736  {
737  removeImage->setEnabled(false);
738  rotate90Image->setEnabled(false);
739  rotate270Image->setEnabled(false);
740  if(setDesktopBtn) { setDesktopBtn->setEnabled(false); }
741  layout->setEditTabEnabled(false);
742  }
743  else
744  {
745  removeImage->setEnabled(true);
746  rotate90Image->setEnabled(true);
747  rotate270Image->setEnabled(true);
748  if(setDesktopBtn) { setDesktopBtn->setEnabled(true); }
749  layout->setEditTabEnabled(true);
750  }
751 
752  if(setDesktopBtn) { setDesktopBtn->setEnabled( numSelected == 1 ); }
753 }
754 //==============================================
756 {
757  if(!enable)
758  {
759  buttonsState = rotate90Image->isEnabled();
760  addImage->setEnabled(enable && true);
761  removeImage->setEnabled(enable && true);
762  rotate90Image->setEnabled(enable);
763  rotate270Image->setEnabled(enable);
764  if(setDesktopBtn)
765  {
766  wallpaperButtonState = setDesktopBtn->isEnabled();
767  setDesktopBtn->setEnabled(enable);
768  }
769  layout->setEditTabEnabled(enable);
770  }
771  else
772  {
773  addImage->setEnabled(enable && true);
774  removeImage->setEnabled(buttonsState && true);
775  rotate90Image->setEnabled(buttonsState);
776  rotate270Image->setEnabled(buttonsState);
777  if(setDesktopBtn) { setDesktopBtn->setEnabled(wallpaperButtonState); }
779  }
780 }
781 //==============================================
783 {
784  photos->selectAll(false);
785 }
786 //==============================================
void addImageAction()
Adds an image to the subalbum.
bool addPhoto(QString fileName, bool replaceDescription=false, Photo *newPhoto=NULL)
Adds a new photo to the Subalbum and appends it to the end, returns TRUE if successful.
Definition: subalbum.cpp:198
bool wallpaperButtonState
cached enabled/distable state of set wallpaper button
void refreshSelectedPhotos()
refreshes selected photos, selections are preserved
Q3Frame * buttonsFrame
void removeImageAction()
Remove an image from the subalbum.
QToolButton * addImage
"Add" button
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
Definition: photo.h:44
void rotate270ImageAction()
Rotate counter-clockwise selected images.
bool anySelectedPhotosRevertable()
Returns true if any selected photos are revertable.
void refreshAllPhotos()
refreshes all photos, selections are preserved
void setWallpaperAction()
set desktop wallpaper
void stripDescriptionsFromSelectedPhotos()
Strip descriptions from selected photos.
void resizeEvent(QResizeEvent *)
Photo * getSelectedPhoto()
Returns currently selected photo. If no or multiple photos selected returns NULL. ...
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
void updateMenus(bool anySelected=false, bool anyRevertable=false)
update begin presentation menu entry - disabled when no photos in album
void showProgressBar(QString message, int numSteps)
Initializes the progress bar.
StatusWidget * getStatus()
returns a pointer to the status widget
Definition: window.cpp:198
SubalbumWidget(Subalbum *salbum, QWidget *parent=0, const char *name=0)
Creates layout based on backend object.
QString getString(QString group, QString key)
Fetch string setting.
Displays photo thumbnail and description.
void resetSetting(QString group, QString key)
Resets a setting to it&#39;s default value.
bool setWallpaperSupported()
Does Album Shaper support setting the wallpaper on this system?
void setString(QString group, QString key, QString value)
Sets a setting value, if group does not exist it is created, if setting does not exist it is also cre...
void revertSelectedPhotos()
Revert selected photos to their original form.
Photo * getNext()
Returns next photo pointer.
Definition: photo.cpp:225
QToolButton * rotate270Image
"Rotate 270" button
void setBusy(bool val)
set program busy state
Displays list of subalbums and a particular subalbum layout.
Definition: layoutWidget.h:39
QString IMAGE_PATH
Definition: config.cpp:18
void setStatus(QString message)
Update message.
void setSelectedPhoto(Photo *selection)
Sets the selected photo to selection and ensures it is visible.
QStringList getFilenames(bool &setDescriptions)
returns the list of selected filenames, while setting setDescritions to the state the checkbox was le...
Photo * getFirstSelectedPhoto()
Returns first selected photo.
Simple dialog for browsing and select photos to add to a subalbum.
void selectedPhotoStateChanged()
void setSubalbum(Subalbum *salbum)
Resets the subalbum this subalbum widget is displaying.
Q3GridLayout * mainGrid
Grids widgets are placed in.
A subalbum contains photos.
Definition: subalbum.h:48
void setWallpaper(Photo *phto)
Sets desktop wallpaper using specified photo.
Q3GridLayout * buttonsGrid
Extension of iconview, used to list all photos in a subalbum. supports drag-n-drop within iconview...
bool buttonsState
cached enabled/disabled state of buttons
Photo * getFirst()
Returns first photo in subalbum.
Definition: subalbum.cpp:100
void refreshPhotos()
clears and reinserts all photos for the current collection the current selection is cleared ...
void updateButtons()
Activates/Deactives remove/rotate buttons depending on if an image is selected.
Configuration object manages all user-specific application settings.
Definition: configuration.h:24
QToolButton * removeImage
"Remove" button
Subalbum * getSubalbum()
returns a pointer to the backend subalbum
QToolButton * rotate90Image
"Rotate 90" button
Window * getWindow()
Returns a pointer to the window.
void updateButtons(bool enable)
Activates/Deactives create/delete buttons.
bool anyPhotosSelected()
Returns true if any phtos are selected.
void setEditTabEnabled(bool val)
void rotate90ImageAction()
Rotate clockwise selected images.
QToolButton * setDesktopBtn
Set desktop wallpaper button.
PhotosIconView * photos
Photos layout.
SubalbumsWidget * getSubalbums()
Returns a pointer to the subalbums.
void selectionChangedEvent()
handles changing selections
void syncPhotoList(PhotoPreviewWidget *item)
Syncs photo ordering with front end gui ordering.
Definition: subalbum.cpp:501
Q3IconView * getPhotos()
Returns pointer to icon view.
Subalbum * subalbum
Pointer to backend subalbum.
A configurable question dialog that returns true/false.
LayoutWidget * layout
Pointer to the parent layout widget.
void removePhoto(Photo *val)
Removes a specified photo.
Definition: subalbum.cpp:281
TitleWidget * getTitle()
returns a pointer to the title widget
Definition: window.cpp:188
Photo * getLast()
Returns last photo in subalbum.
Definition: subalbum.cpp:101
void updateProgress(int progress, QString newMessage=QString::null)
Updates the progress bar.