00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <qwidget.h>
00013 #include <qmenubar.h>
00014 #include <qpopupmenu.h>
00015 #include <qlayout.h>
00016 #include <qlabel.h>
00017 #include <qfont.h>
00018 #include <qpixmap.h>
00019 #include <qmovie.h>
00020 #include <qimage.h>
00021 #include <qtoolbutton.h>
00022 #include <qfileinfo.h>
00023 #include <qlineedit.h>
00024 #include <qapplication.h>
00025 #include <qdir.h>
00026 #include <qcursor.h>
00027 #include <qfiledialog.h>
00028 #include <qtooltip.h>
00029 #include <qiconset.h>
00030 #include <qdatetime.h>
00031
00032 #include <math.h>
00033
00034
00035 #include "window.h"
00036 #include "titleWidget.h"
00037 #include "layoutWidget.h"
00038 #include "subalbumsWidget.h"
00039 #include "subalbumWidget.h"
00040 #include "statusWidget.h"
00041 #include "ALabel.h"
00042 #include "subalbumPreviewWidget.h"
00043 #include "recentAlbumMenuItem.h"
00044
00045 #include "dialogs/albumStatistics.h"
00046 #include "dialogs/about.h"
00047 #include "help/helpWindow.h"
00048 #include "dialogs/questionDialog.h"
00049 #include "dialogs/alertDialog.h"
00050 #include "dialogs/saveDialog.h"
00051
00052 #include "../config.h"
00053 #include "../backend/album.h"
00054 #include "../backend/subalbum.h"
00055 #include "../backend/photo.h"
00056 #include "../backend/tools/fileTools.h"
00057 #include "../backend/tools/guiTools.h"
00058 #include "../configuration/configurationWidget.h"
00059 #include "../configuration/configuration.h"
00060
00061
00062 TitleWidget::TitleWidget(QWidget *parent,
00063 const char* name ) : QFrame(parent,name)
00064 {
00065 tmpDirErrorMessage = tr("Error! Unable to create temp directory!");
00066 tmpDirErrorDesc = tr("Album Shaper was unable to create the necessary temp directory required: ");
00067
00068 QColor white(255, 255, 255);
00069 QColor lightBlue(193, 210, 238);
00070 QColor darkBlue(35, 75, 139);
00071 QColor black(0, 0, 0);
00072
00074 window = (Window*)parent;
00075
00077 busy = false;
00078
00079
00080 detectModifications = true;
00081
00083 albumStats = NULL;
00084 settingsWindow = NULL;
00085 about = NULL;
00086 helpWindow = NULL;
00087
00088
00089 albm = new Album( createTmpDir() );
00090 if(albm->getTmpDir().isNull() )
00091 {
00092 AlertDialog alert( tmpDirErrorMessage, tmpDirErrorDesc + window->getConfig()->getString( "loadSave", "tempImageDirectory" ),
00093 "alertIcons/warning.png", this );
00094 alert.exec();
00095 quitApplication();
00096 }
00097
00098
00099 int i;
00100 QString recentName, recentLocation, recentPhotoCount;
00101 for(i = 0; i<recentAlbums.getMaxItems(); i++)
00102 {
00103
00104 recentName = window->getConfig()->getString( "recentAlbums", QString("%1_name").arg(i) );
00105 recentLocation = window->getConfig()->getString("recentAlbums", QString("%1_location").arg(i) );
00106 recentPhotoCount = window->getConfig()->getString("recentAlbums", QString("%1_photoCount").arg(i) );
00107
00108
00109 if(recentLocation.compare("-1") == 0)
00110 break;
00111
00112
00113 recentAlbums.insertEntry( recentName, recentLocation, recentPhotoCount );
00114 }
00115
00116
00117 menu = new QMenuBar( this, "menuBar" );
00118
00119
00120 file = new QPopupMenu( this, "fileMenu" );
00121 NEW_ALBUM = file->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/new.png") ),
00122 tr("&New"), this, SLOT(newAlbum()), CTRL+Key_N );
00123
00124 OPEN_ALBUM = file->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/open.png") ),
00125 tr("&Open..."), this, SLOT(loadAlbum()), CTRL+Key_O );
00126
00127 openRecent = new QPopupMenu( this, "openRecentMenu" );
00128 refreshOpenRecentMenu();
00129 file->insertItem( tr("Open Recent"), openRecent );
00130
00131 file->insertSeparator();
00132
00133 SAVE_ALBUM = file->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/save.png") ),
00134 tr("&Save"), this, SLOT(saveAlbum()), CTRL+Key_S );
00135
00136 SAVEAS_ALBUM = file->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/saveas.png") ),
00137 tr("&Save As..."), this, SLOT(saveAsAlbum()), CTRL+SHIFT+Key_S );
00138
00139 REVERT_TO_SAVED_ALBUM = file->insertItem( tr("Revert to Saved"), this, SLOT(revertToSaved()) );
00140 file->setItemEnabled( REVERT_TO_SAVED_ALBUM, false );
00141
00142 file->insertSeparator();
00143
00144 QPopupMenu* exportAs = new QPopupMenu( this, "exportAs" );
00145 EXPORT_SMALL_WEB_GALLERY = exportAs->insertItem( tr("Small Web Gallery"),
00146 this, SLOT(exportSmallWebGallery()) );
00147 EXPORT_LARGE_IMAGES = exportAs->insertItem( tr("Images for Printing"),
00148 this, SLOT(exportLargeImages()) );
00149
00150 file->insertItem( tr("Export..."), exportAs );
00151
00152 file->insertSeparator();
00153
00154 file->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/quit.png") ),
00155 tr("&Quit"), this, SLOT(quitApplication()), CTRL+Key_Q);
00156
00157
00158 menu->insertItem( tr("&File"), file );
00159
00160
00161 photoMenu = new QPopupMenu( this, "phooMenu" );
00162
00163 REMOVE_DESCRIPTIONS = photoMenu->insertItem( tr("Remove Description"), this, SLOT(removeSelectedPhotoDesc()) );
00164 REVERT_PHOTOS = photoMenu->insertItem( tr("Revert to Original"), this, SLOT(revertPhotos()) );
00165
00166 menu->insertItem( tr("&Photos"), photoMenu );
00167
00168
00169 tools = new QPopupMenu( this, "toolsMenu" );
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 tools->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/albumStatistics.png") ),
00180 tr("Album Statistics"), this, SLOT(albumStatistics()), CTRL+Key_I );
00181
00182 tools->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/settings.png") ),
00183 tr("Settings"), this, SLOT(settings()) );
00184
00185 menu->insertItem( tr("&Tools"), tools );
00186
00187
00188
00189 #if defined(Q_OS_MACX)
00190 windowMenu = new QPopupMenu( this, "windoMenu" );
00191 WINDOW_MINIMIZE = windowMenu->insertItem( tr("&Minimize"), (QWidget*)window, SLOT(showMinimized()), CTRL+Key_M );
00192 menu->insertItem( tr("&Window"), windowMenu );
00193 #endif
00194
00195
00196 helpMenu = new QPopupMenu( this, "helpMenu" );
00197 helpMenu->insertItem( tr("Album Shaper Help"), this, SLOT(help()), CTRL+Key_Question );
00198
00199 helpMenu->insertItem( QIconSet( QPixmap(QString(IMAGE_PATH)+"menuIcons/about.png") ),
00200 tr("About"), this, SLOT(aboutProgram()) );
00201 menu->insertSeparator();
00202 menu->insertItem( tr("&Help"), helpMenu );
00203
00204
00205 mainFrame = new QFrame( this, "mainFrame" );
00206 mainFrame->setPaletteBackgroundColor( darkBlue );
00207
00208
00209 albumAnnotationFrame = new QFrame( mainFrame, "albumAnnotationFrame" );
00210 albumAnnotationFrame->setLineWidth(2);
00211 albumAnnotationFrame->setMidLineWidth(0);
00212 albumAnnotationFrame->setFrameStyle( QFrame::Panel | QFrame::Plain );
00213 albumAnnotationFrame->setPaletteForegroundColor( white );
00214 albumAnnotationFrame->setPaletteBackgroundColor( darkBlue );
00215
00216 QFrame* albumImageFrame = new QFrame( albumAnnotationFrame, "albumImageFrame" );
00217 albumImage = new ALabel( albumImageFrame, "albumImage",
00218 new QPixmap( QString(IMAGE_PATH)+"buttonIcons/removeImage.png") );
00219 connect( albumImage, SIGNAL(mouseRelease()),
00220 this, SLOT(unsetAlbumImage()) );
00221
00222
00223 this->setAcceptDrops(true);
00224
00225 albumName = new QLabel( tr("Album Name:"), albumAnnotationFrame, "albumName" );
00226 albumNameVal = new QLineEdit( albumAnnotationFrame, "albumNameVal" );
00227 connect( albumNameVal, SIGNAL(textChanged( const QString&)),
00228 SLOT( storeAnnotations()) );
00229
00230 albumDescription = new QLabel( tr("Description:"), albumAnnotationFrame, "albumDescription" );
00231 albumDescriptionVal = new QLineEdit( albumAnnotationFrame, "albumDescriptionVal" );
00232 connect( albumDescriptionVal, SIGNAL(textChanged( const QString&)),
00233 SLOT( storeAnnotations()) );
00234
00235 albumAuthor = new QLabel( tr("Author:"), albumAnnotationFrame, "albumAuthor" );
00236 albumAuthorVal = new QLineEdit( albumAnnotationFrame, "albumAuthorVal" );
00237 connect( albumAuthorVal, SIGNAL(textChanged( const QString&)),
00238 SLOT( storeAnnotations()) );
00239
00240
00241 subalbumAnnotationFrame = new QFrame( mainFrame, "subalbumAnnotationFrame" );
00242 subalbumAnnotationFrame->setLineWidth(2);
00243 subalbumAnnotationFrame->setMidLineWidth(0);
00244 subalbumAnnotationFrame->setFrameStyle( QFrame::Panel | QFrame::Plain );
00245 subalbumAnnotationFrame->setPaletteForegroundColor( white );
00246 subalbumAnnotationFrame->setPaletteBackgroundColor( darkBlue );
00247
00248 QFrame* subalbumImageFrame = new QFrame( subalbumAnnotationFrame, "subalbumImageFrame" );
00249 subalbumImage = new ALabel( subalbumImageFrame, "subalbumImage",
00250 new QPixmap( QString(IMAGE_PATH)+"buttonIcons/removeImage.png") );
00251
00252 connect( subalbumImage, SIGNAL(mouseRelease()),
00253 this, SLOT(unsetSubalbumImage()) );
00254
00255 subalbumName = new QLabel( tr("Collection Name:"), subalbumAnnotationFrame );
00256 subalbumNameVal = new QLineEdit( subalbumAnnotationFrame );
00257 connect( subalbumNameVal, SIGNAL(textChanged( const QString&)),
00258 SLOT( storeAnnotations()) );
00259
00260 subalbumDescription = new QLabel( tr("Description:"), subalbumAnnotationFrame );
00261 subalbumDescriptionVal = new QLineEdit( subalbumAnnotationFrame );
00262 connect( subalbumDescriptionVal, SIGNAL(textChanged( const QString&)),
00263 SLOT( storeAnnotations()) );
00264
00265
00266 QFont labelFont = albumName->font();
00267 labelFont.setWeight(QFont::Bold);
00268
00269 albumName->setFont( labelFont );
00270 albumName->setPaletteForegroundColor( white );
00271 albumName->setPaletteBackgroundColor( darkBlue );
00272
00273 albumNameVal->setFont( labelFont );
00274 albumNameVal->setPaletteForegroundColor( black );
00275 albumNameVal->setPaletteBackgroundColor( lightBlue );
00276 albumNameVal->setFrameShape ( QFrame::NoFrame );
00277
00278 albumDescription->setFont( labelFont );
00279 albumDescription->setPaletteForegroundColor( white );
00280 albumDescription->setPaletteBackgroundColor( darkBlue );
00281
00282 albumDescriptionVal->setFont( labelFont );
00283 albumDescriptionVal->setPaletteForegroundColor( black );
00284 albumDescriptionVal->setPaletteBackgroundColor( lightBlue );
00285 albumDescriptionVal->setFrameShape ( QFrame::NoFrame );
00286
00287 albumAuthor->setFont( labelFont );
00288 albumAuthor->setPaletteForegroundColor( white );
00289 albumAuthor->setPaletteBackgroundColor( darkBlue );
00290
00291 albumAuthorVal->setFont( labelFont );
00292 albumAuthorVal->setPaletteForegroundColor( black );
00293 albumAuthorVal->setPaletteBackgroundColor( lightBlue );
00294 albumAuthorVal->setFrameShape ( QFrame::NoFrame );
00295
00296 subalbumName->setFont( labelFont );
00297 subalbumName->setPaletteForegroundColor( white );
00298 subalbumName->setPaletteBackgroundColor( darkBlue );
00299
00300 subalbumNameVal->setFont( labelFont );
00301 subalbumNameVal->setPaletteForegroundColor( black );
00302 subalbumNameVal->setPaletteBackgroundColor( lightBlue );
00303 subalbumNameVal->setFrameShape ( QFrame::NoFrame );
00304
00305 subalbumDescription->setFont( labelFont );
00306 subalbumDescription->setPaletteForegroundColor( white );
00307 subalbumDescription->setPaletteBackgroundColor( darkBlue );
00308
00309 subalbumDescriptionVal->setFont( labelFont );
00310 subalbumDescriptionVal->setPaletteForegroundColor( black );
00311 subalbumDescriptionVal->setPaletteBackgroundColor( lightBlue );
00312 subalbumDescriptionVal->setFrameShape ( QFrame::NoFrame );
00313
00314
00315
00316
00317 QGridLayout* albumImageGrid = new QGridLayout( albumImageFrame, 1, 1 );
00318 albumImageGrid->addWidget( albumImage, 0, 0 );
00319 albumImageGrid->setRowSpacing( 0, REP_IMAGE_HEIGHT );
00320
00321 albumAnnotationGrid = new QGridLayout( albumAnnotationFrame, 3, 3);
00322 albumAnnotationGrid->setMargin(WIDGET_SPACING);
00323 albumAnnotationGrid->setSpacing(WIDGET_SPACING);
00324
00325 albumAnnotationGrid->addMultiCellWidget( albumImageFrame, 0, 2, 0, 0 );
00326
00327 albumAnnotationGrid->addWidget ( albumName, 0, 1, Qt::AlignLeft);
00328 albumAnnotationGrid->addWidget ( albumDescription, 1, 1, Qt::AlignLeft);
00329 albumAnnotationGrid->addWidget ( albumAuthor, 2, 1, Qt::AlignLeft);
00330
00331 albumAnnotationGrid->setColStretch(2, 1);
00332 albumAnnotationGrid->addWidget( albumNameVal, 0, 2);
00333 albumAnnotationGrid->addWidget( albumDescriptionVal, 1, 2);
00334 albumAnnotationGrid->addWidget( albumAuthorVal, 2, 2);
00335
00336
00337 QGridLayout* subalbumImageGrid = new QGridLayout( subalbumImageFrame, 1, 1 );
00338 subalbumImageGrid->addWidget( subalbumImage, 0, 0 );
00339 subalbumImageGrid->setRowSpacing( 0, REP_IMAGE_HEIGHT );
00340
00341 subalbumAnnotationGrid = new QGridLayout( subalbumAnnotationFrame, 5, 5);
00342 subalbumAnnotationGrid->setMargin(WIDGET_SPACING);
00343 subalbumAnnotationGrid->setSpacing(WIDGET_SPACING);
00344
00345 subalbumAnnotationGrid->addMultiCellWidget( subalbumImageFrame, 0, 2, 0, 0);
00346
00347 subalbumAnnotationGrid->setRowStretch(2, 1);
00348 subalbumAnnotationGrid->addWidget ( subalbumName, 0, 1, Qt::AlignLeft);
00349 subalbumAnnotationGrid->addWidget ( subalbumDescription, 1, 1, Qt::AlignLeft);
00350
00351 subalbumAnnotationGrid->setColStretch(2, 1);
00352 subalbumAnnotationGrid->addWidget( subalbumNameVal, 0, 2);
00353 subalbumAnnotationGrid->addWidget( subalbumDescriptionVal, 1, 2);
00354
00355
00356 mainGrid = new QGridLayout( mainFrame, 1, 2);
00357 mainGrid->setMargin(WIDGET_SPACING);
00358 mainGrid->setSpacing(WIDGET_SPACING);
00359
00360 mainGrid->addWidget ( albumAnnotationFrame, 0, 0);
00361 mainGrid->setColStretch(0, 1);
00362
00363 mainGrid->addWidget ( subalbumAnnotationFrame, 0, 1);
00364 mainGrid->setColStretch(1, 1);
00365
00366 QVBoxLayout* vb = new QVBoxLayout(this);
00367 this->layout()->setMenuBar( menu );
00368 vb->addWidget(mainFrame);
00369
00370 }
00371
00372 void TitleWidget::useAnimation(bool val)
00373 {
00374
00375 if(val)
00376 {
00377 albumImage->setAnimationMethods( SLIDE_IN_LEFT, SLIDE_OUT_LEFT,
00378 FADE_TRANSITION, FADE_TRANSITION);
00379 subalbumImage->setAnimationMethods( SLIDE_IN_LEFT, SLIDE_OUT_LEFT,
00380 FADE_TRANSITION, FADE_TRANSITION);
00381 }
00382
00383 else
00384 {
00385 albumImage->setAnimationMethods();
00386 subalbumImage->setAnimationMethods();
00387 }
00388 }
00389
00390 TitleWidget::~TitleWidget()
00391 {
00392
00393 delete albm;
00394 albm = NULL;
00395 }
00396
00397 void TitleWidget::storeAnnotations()
00398 {
00399
00400 if( !detectModifications ) return;
00401
00402
00403 albm->setName ( albumNameVal->text() );
00404 albm->setDescription ( albumDescriptionVal->text() );
00405 albm->setAuthor ( albumAuthorVal->text() );
00406
00407
00408 Subalbum* collection = window->getLayout()->getSubalbums()->getSelectedSubalbum();
00409 if(collection != NULL )
00410 {
00411
00412 QString oldName = collection->getName();
00413
00414
00415 collection->setName( subalbumNameVal->text() );
00416 collection->setDescription( subalbumDescriptionVal->text() );
00417
00418
00419 if(oldName.compare( collection->getName() ) != 0)
00420 emit subalbumNameChanged();
00421 }
00422 }
00423
00424 void TitleWidget::updateAlbumAnnotations()
00425 {
00426
00427 detectModifications = false;
00428
00429
00430
00431
00432 if( albm->getRepresentativeImage(LARGE) != NULL)
00433 albumImage->setPixmap( *albm->getRepresentativeImage(SMALL) );
00434 else
00435 albumImage->removePixmap();
00436
00437 albumNameVal->setText( albm->getName() );
00438 albumNameVal->setCursorPosition(0);
00439 albumDescriptionVal->setText( albm->getDescription() );
00440 albumDescriptionVal->setCursorPosition(0);
00441 albumAuthorVal->setText( albm->getAuthor() );
00442 albumAuthorVal->setCursorPosition(0);
00443
00444
00445 detectModifications = true;
00446 }
00447
00448 void TitleWidget::refreshCollectionAnnotations(Subalbum* collection)
00449 {
00450
00451 detectModifications = false;
00452
00453
00454 if( collection == NULL )
00455 {
00456 subalbumAnnotationFrame->hide();
00457 subalbumImage->removePixmap(true);
00458 }
00459 else
00460 {
00461 subalbumAnnotationFrame->show();
00462
00463
00464 if( collection->getRepresentativeImage(LARGE) != NULL)
00465 subalbumImage->setPixmap( *collection->getRepresentativeImage(SMALL) );
00466 else
00467 subalbumImage->removePixmap();
00468
00469 subalbumNameVal->setText( collection->getName() );
00470 subalbumNameVal->setCursorPosition(0);
00471 subalbumDescriptionVal->setText( collection->getDescription() );
00472 subalbumDescriptionVal->setCursorPosition(0);
00473 }
00474
00475
00476 detectModifications = true;
00477 }
00478
00479 void TitleWidget::setAlbum( Album* val)
00480 {
00481
00482 delete albm;
00483 albm = val;
00484 }
00485
00486 Album* TitleWidget::getAlbum()
00487 {
00488 return albm;
00489 }
00490
00491 void TitleWidget::setAlbumImage()
00492 {
00493
00494
00495 SubalbumWidget* sw = window->getLayout()->getSubalbum();
00496 if(sw == NULL)
00497 return;
00498
00499
00500 setAlbumImage( sw->getSelectedPhoto() );
00501 }
00502
00503 void TitleWidget::setAlbumImage(Photo* selectedPhoto)
00504 {
00505 if(selectedPhoto == NULL)
00506 return;
00507
00508
00509 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00510 albm->setRepresentativeImages( selectedPhoto->getImageFilename() );
00511
00512
00513 albumImage->setPixmap( *albm->getRepresentativeImage(SMALL) );
00514 qApp->restoreOverrideCursor();
00515
00516 }
00517
00518 void TitleWidget::unsetAlbumImage()
00519 {
00520 albm->setRepresentativeImages( QString::null );
00521 }
00522
00523 void TitleWidget::setSubalbumImage()
00524 {
00525
00526
00527 SubalbumWidget* sw = window->getLayout()->getSubalbum();
00528 if(sw == NULL)
00529 return;
00530
00531
00532 setSubalbumImage( sw->getSelectedPhoto() );
00533 }
00534
00535 void TitleWidget::setSubalbumImage(Photo* selectedPhoto)
00536 {
00537 if(selectedPhoto == NULL)
00538 return;
00539
00540
00541
00542 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00543 SubalbumWidget* sw = window->getLayout()->getSubalbum();
00544 sw->getSubalbum()->setRepresentativeImage( selectedPhoto->getThumbnailFilename() );
00545
00546
00547 subalbumImage->setPixmap( *sw->getSubalbum()->getRepresentativeImage(SMALL) );
00548 SubalbumPreviewWidget* item = (SubalbumPreviewWidget*)window->getLayout()->getSubalbums()->getCurrentSelection();
00549 item->setPixmap( *sw->getSubalbum()->getRepresentativeImage(MEDIUM), false );
00550 qApp->restoreOverrideCursor();
00551
00552 }
00553
00554 void TitleWidget::unsetSubalbumImage()
00555 {
00556 SubalbumPreviewWidget* item = (SubalbumPreviewWidget*)window->getLayout()->getSubalbums()->getCurrentSelection();
00557 if(item != NULL && ((SubalbumPreviewWidget*)item)->getSubalbum() != NULL)
00558 {
00559 Subalbum* subalbm = ((SubalbumPreviewWidget*)item)->getSubalbum();
00560 subalbm->setRepresentativeImage( QString::null );
00561 item->setPixmap( *subalbm->getRepresentativeImage(MEDIUM), false );
00562 }
00563 }
00564
00565 void TitleWidget::refresh()
00566 {
00567
00568
00569
00570
00571 window->refresh();
00572
00573
00574
00575 updateAlbumAnnotations();
00576 }
00577
00578 void TitleWidget::newAlbum()
00579 {
00580
00581
00582 if( albm->albumModified() && window->getConfig()->getBool( "alerts", "showDestructiveAlerts" ) )
00583 {
00584 QuestionDialog sure( tr("New album?"),
00585 tr("Warning, unsaved modifications to the current album exist. Creating a new album will result in lost work. Are you sure you want to do this?"),
00586 "alertIcons/warning.png",
00587 this );
00588 if(!sure.exec())
00589 return;
00590 }
00591
00592
00593 delete albm;
00594
00595
00596 albm = new Album( createTmpDir() );
00597
00598 if(albm->getTmpDir().isNull() )
00599 {
00600 AlertDialog alert( tmpDirErrorMessage, tmpDirErrorDesc + window->getConfig()->getString( "loadSave", "tempImageDirectory" ),
00601 "alertIcons/warning.png", this );
00602 alert.exec();
00603 quitApplication();
00604 }
00605
00606
00607 albumImage->removePixmap();
00608 subalbumImage->removePixmap(true);
00609
00610
00611 file->setItemEnabled( REVERT_TO_SAVED_ALBUM, false );
00612
00613
00614 window->getLayout()->getSubalbum()->setSubalbum( NULL );
00615 refresh();
00616
00617 albm->setModified(false);
00618 }
00619
00620 void TitleWidget::loadAlbum()
00621 {
00623 if(!proceedWithLoad())
00624 return;
00625
00626 QString path = window->getConfig()->getString( "loadSave", "loadSaveDir" );
00627 QDir testPath(path);
00628 if(!testPath.exists())
00629 {
00630 window->getConfig()->resetSetting( "loadSave", "loadSaveDir" );
00631 path = window->getConfig()->getString( "loadSave", "loadSaveDir" );
00632 }
00633
00634 QString albumXML = QFileDialog::getOpenFileName( path,
00635 tr("XML Files (*.xml)"),
00636 this,
00637 "open file dialog",
00638 tr("Choose an album to load") );
00639
00640
00641 if(albumXML.isNull()) return;
00642
00643
00644 loadAlbum( albumXML );
00645 }
00646
00647 void TitleWidget::loadRecentAlbum(int index)
00648 {
00650 if(!proceedWithLoad())
00651 return;
00652
00653 QString recentName, recentLocation, recentPhotoCount;
00654 recentAlbums.getEntry( index, recentName, recentLocation, recentPhotoCount );
00655 loadAlbum( QDir::convertSeparators( recentLocation + "/Album.xml") );
00656 }
00657
00658 bool TitleWidget::proceedWithLoad()
00659 {
00660
00661
00662 if( albm->albumModified() && window->getConfig()->getBool( "alerts", "showDestructiveAlerts" ) )
00663 {
00664 QuestionDialog sure( tr("Load album?"),
00665 tr("Warning, unsaved modifications to the current album exist. Loading a new album will result in lost work. Are you sure you want to do this?"),
00666 "alertIcons/warning.png",
00667 this );
00668 if(!sure.exec())
00669 return false;
00670 }
00671
00672 return true;
00673 }
00674
00675 void TitleWidget::revertToSaved()
00676 {
00677
00678
00679 if( !albm->albumModified() )
00680 return;
00681
00683
00684
00685 if( window->getConfig()->getBool( "alerts", "showDestructiveAlerts" ) )
00686 {
00687 QuestionDialog sure( tr("Revert to Saved?"),
00688 tr("Warning, unsaved modifications to the current album exist. These changes will be lost if you revert to the album's last saved form. Are you sure you want to do this?"),
00689 "alertIcons/warning.png",
00690 this );
00691 if(!sure.exec())
00692 return;
00693 }
00694
00695
00696 loadAlbum( QDir::convertSeparators( albm->getSaveLocation() + "/Album.xml") );
00697 }
00698
00699 void TitleWidget::exportSmallWebGallery()
00700 {
00701
00702 if(!SaveDialog::themeAvailable( getAlbum()->getTheme() ))
00703 {
00704 AlertDialog alert( tr("Previous theme not available!"),
00705 QString(tr("Theme previously used to save this album not available on this machine. Before exporting the %1 theme must be installed, or the album must be resaved using a differnt theme.")).arg( getAlbum()->getTheme() ),
00706 "alertIcons/warning.png", this );
00707 alert.exec();
00708 return;
00709 }
00710
00711
00712
00713 QString dialogTitle = tr( "Album Shaper: Export Small Web Gallery" );
00714
00715
00716 QString newDir;
00717 if(getAlbum()->prevSave())
00718 { newDir = QDir( getAlbum()->getSaveLocation() ).dirName() + "_WEB"; }
00719 else
00720 { newDir = getAlbum()->getName() + "_WEB"; }
00721 newDir = fixFilename( newDir );
00722
00723
00724 QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
00725 fd->setCaption( tr("Export Location") );
00726 fd->setMode( QFileDialog::DirectoryOnly );
00727 fd->setDir( window->getConfig()->getString( "loadSave", "loadSaveDir" ) );
00728
00729
00730 if ( !fd->exec() == QDialog::Accepted ) { return; }
00731
00732
00733 QString exportPath = QDir::convertSeparators( fd->selectedFile() + "/" + newDir );
00734
00735
00736 if( getAlbum()->prevSave() && getAlbum()->getSaveLocation().compare( exportPath ) == 0 )
00737 {
00738 QString errorMessage = tr("Error! Cannot export to album location on disk!");
00739 QString errorDesc = tr("Exporting small web galleries to the same location the album is stored will corrupt it and is not allowed. Try using the default location when exporting images, or chose a different directory.");
00740 AlertDialog alert( errorMessage, errorDesc,
00741 "alertIcons/warning.png", this );
00742 alert.exec();
00743 return;
00744 }
00745
00746
00747 QDir tmpDir;
00748 if(tmpDir.exists( exportPath ) )
00749 {
00750 QString warningMessage =
00751 QString(tr("Warning! A directory named %1 already exists in %2. Continue with export?")).arg
00752 ( newDir ).arg( fd->selectedFile() );
00753
00754 QuestionDialog sure( tr("Directory Exists!"),
00755 warningMessage, "alertIcons/warning.png",
00756 this );
00757 if(!sure.exec()) { return; }
00758 }
00759
00760 else
00761 {
00762 if( !tmpDir.mkdir( exportPath ) )
00763 {
00764 AlertDialog alert( tr("Error creating directory!"),
00765 tr("Unable to create directory to export images to.Perhaps you are running out of disk space or you don't have sufficient privledges?"),
00766 "alertIcons/warning.png", this );
00767 alert.exec();
00768 return;
00769 }
00770 }
00771
00772
00773 setBusy(true);
00774 window->getLayout()->getSubalbums()->updateButtons(false);
00775 if(window->getLayout()->getSubalbum() != NULL)
00776 window->getLayout()->getSubalbum()->updateButtons(false);
00777 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00778
00779
00780 int numPhotos = getAlbum()->getNumPhotos();
00781 QString exportMessage = tr( "Exporting %1 photos to web gallery" );
00782 window->getStatus()->showProgressBar( exportMessage.arg(numPhotos), numPhotos );
00783 qApp->processEvents();
00784
00785
00786 getAlbum()->exportCompressedWebAlbum(window->getStatus(), exportPath, exportMessage);
00787
00788
00789 window->getStatus()->setStatus( tr("Exporting photos complete.") );
00790
00791
00792 setBusy(false);
00793 window->getLayout()->getSubalbums()->updateButtons(true);
00794 if(window->getLayout()->getSubalbum() != NULL)
00795 window->getLayout()->getSubalbum()->updateButtons(true);
00796 qApp->restoreOverrideCursor();
00797 }
00798
00799 void TitleWidget::exportLargeImages()
00800 {
00801
00802 QString dialogTitle = tr( "Album Shaper: Export Large Images" );
00803
00804
00805 QString newDir;
00806 if(getAlbum()->prevSave())
00807 { newDir = QDir( getAlbum()->getSaveLocation() ).dirName() + "_IMAGES"; }
00808 else
00809 { newDir = getAlbum()->getName() + "_IMAGES"; }
00810 newDir = fixFilename( newDir );
00811
00812
00813 QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
00814 fd->setCaption( tr("Export Location") );
00815 fd->setMode( QFileDialog::DirectoryOnly );
00816 fd->setDir( window->getConfig()->getString( "loadSave", "loadSaveDir" ) );
00817
00818
00819 if ( !fd->exec() == QDialog::Accepted ) { return; }
00820
00821
00822 QString exportPath = QDir::convertSeparators( fd->selectedFile() + "/" + newDir );
00823
00824
00825 if( getAlbum()->prevSave() && getAlbum()->getSaveLocation().compare( exportPath ) == 0 )
00826 {
00827 QString errorMessage = tr("Error! Cannot export to album location on disk!");
00828 QString errorDesc = tr("Exporting large images to the same location the album is stored will corrupt it and is not allowed. Try using the default location when exporting images, or chose a different directory.");
00829 AlertDialog alert( errorMessage, errorDesc,
00830 "alertIcons/warning.png", this );
00831 alert.exec();
00832 return;
00833 }
00834
00835
00836 QDir tmpDir;
00837 if(tmpDir.exists( exportPath ) )
00838 {
00839 QString warningMessage =
00840 QString(tr("Warning! A directory named %1 already exists in %2. Continue with export?")).arg
00841 ( newDir ).arg( fd->selectedFile() );
00842
00843 QuestionDialog sure( tr("Directory Exists!"),
00844 warningMessage, "alertIcons/warning.png",
00845 this );
00846 if(!sure.exec()) { return; }
00847 }
00848
00849 else
00850 {
00851 if( !tmpDir.mkdir( exportPath ) )
00852 {
00853 AlertDialog alert( tr("Error creating directory!"),
00854 tr("Unable to create directory to export images to.Perhaps you are running out of disk space or you don't have sufficient privledges?"),
00855 "alertIcons/warning.png", this );
00856 alert.exec();
00857 return;
00858 }
00859 }
00860
00861
00862 setBusy(true);
00863 window->getLayout()->getSubalbums()->updateButtons(false);
00864 if(window->getLayout()->getSubalbum() != NULL)
00865 window->getLayout()->getSubalbum()->updateButtons(false);
00866 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00867
00868
00869 int numPhotos = getAlbum()->getNumPhotos();
00870 QString exportMessage = tr( "Exporting %1 photos" );
00871 window->getStatus()->showProgressBar( exportMessage.arg(numPhotos), numPhotos );
00872 qApp->processEvents();
00873
00874
00875 getAlbum()->exportLargeImages(window->getStatus(), exportPath, exportMessage);
00876
00877
00878 window->getStatus()->setStatus( tr("Exporting photos complete.") );
00879
00880
00881 setBusy(false);
00882 window->getLayout()->getSubalbums()->updateButtons(true);
00883 if(window->getLayout()->getSubalbum() != NULL)
00884 window->getLayout()->getSubalbum()->updateButtons(true);
00885 qApp->restoreOverrideCursor();
00886 }
00887
00888 void TitleWidget::loadAlbum(QString albumXML)
00889 {
00890
00891 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
00892 setBusy(true);
00893 window->getLayout()->getSubalbums()->updateButtons(false);
00894 if(window->getLayout()->getSubalbum() != NULL)
00895 window->getLayout()->getSubalbum()->updateButtons(false);
00896
00897
00898 QDir lastDir = QDir( QFileInfo(albumXML).dirPath() );
00899 lastDir.cdUp();
00900 window->getConfig()->setString( "loadSave", "loadSaveDir", lastDir.path() );
00901
00902
00903 delete albm;
00904
00905 albm = new Album( createTmpDir( QFileInfo(albumXML).dirPath() ), false );
00906 if(albm->getTmpDir().isNull() )
00907 {
00908 AlertDialog alert( tmpDirErrorMessage, tmpDirErrorDesc + window->getConfig()->getString( "loadSave", "tempImageDirectory" ),
00909 "alertIcons/warning.png", this );
00910 alert.exec();
00911 quitApplication();
00912 }
00913
00914
00915 int errorCode = albm->importFromDisk(window->getStatus(), albumXML,
00916 window->getConfig()->getBool( "loadSave", "disableCheckPhotoMods" ) );
00917
00918
00919 if(albm->getFirstSubalbum() == NULL)
00920 {
00921 subalbumAnnotationFrame->hide();
00922 subalbumImage->removePixmap(true);
00923 }
00924
00925
00926 window->getLayout()->getSubalbum()->setSubalbum( NULL );
00927 refresh();
00928
00929
00930 albm->setModified(false);
00931
00932
00933 recentAlbums.insertEntry( albm->getName(), albm->getSaveLocation(),
00934 QString("%1").arg(albm->getNumPhotos()), false );
00935 refreshOpenRecentMenu();
00936
00937
00938 qApp->restoreOverrideCursor();
00939 setBusy(false);
00940 window->getLayout()->getSubalbums()->updateButtons(true);
00941 if(window->getLayout()->getSubalbum() != NULL)
00942 window->getLayout()->getSubalbum()->updateButtons(true);
00943
00944
00945 if(errorCode == ALBUM_LOADED)
00946 {
00947
00948 file->setItemEnabled( REVERT_TO_SAVED_ALBUM, true );
00949
00950
00951 updateMenus();
00952 }
00953
00954 else
00955 {
00956 QString errorMessage, errorDescription;
00957 if(errorCode == ALBUM_READ_ERROR)
00958 {
00959 errorMessage = tr("Unable to open file!");
00960 errorDescription = tr("An error was encountered attempting to load the XML file. Perhaps you do not have read access?");
00961 }
00962 else if(errorCode == ALBUM_XML_ERROR)
00963 {
00964 errorMessage = tr("Unable to construct DOM!");
00965 errorDescription = tr("The XML file you selected is not valid XML.");
00966 }
00967 else
00968 {
00969 errorMessage = tr("Unknown loading error!");
00970 errorDescription = tr("An unknown error was encountered loading the specified file.");
00971 }
00972
00973 AlertDialog alert( errorMessage, errorDescription, "alertIcons/warning.png", this );
00974 alert.exec();
00975 }
00976 }
00977
00978 void TitleWidget::saveAlbum()
00979 {
00980
00981
00982 if(!getAlbum()->prevSave())
00983 {
00984 saveAsAlbum();
00985 return;
00986 }
00987
00988
00989
00990 if(!SaveDialog::themeAvailable( getAlbum()->getTheme() ))
00991 {
00992 AlertDialog alert( tr("Previous theme not available!"),
00993 tr("Theme previously used to save this album not available on this machine. Click ok to open the save-as dialog to save an alternative theme."),
00994 "alertIcons/warning.png", this );
00995 alert.exec();
00996 saveAsAlbum();
00997 return;
00998 }
00999
01000
01001 setBusy(true);
01002 window->getLayout()->getSubalbums()->updateButtons(false);
01003 if(window->getLayout()->getSubalbum() != NULL)
01004 window->getLayout()->getSubalbum()->updateButtons(false);
01005 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
01006
01007 getAlbum()->exportToDisk(window->getStatus());
01008
01009 window->getConfig()->setString( "loadSave", "lastUsedTheme", getAlbum()->getTheme() );
01010
01011
01012 recentAlbums.insertEntry( albm->getName(), albm->getSaveLocation(),
01013 QString("%1").arg(albm->getNumPhotos()), false );
01014 refreshOpenRecentMenu();
01015
01016
01017 file->setItemEnabled( REVERT_TO_SAVED_ALBUM, true );
01018
01019
01020 setBusy(false);
01021 window->getLayout()->getSubalbums()->updateButtons(true);
01022 if(window->getLayout()->getSubalbum() != NULL)
01023 window->getLayout()->getSubalbum()->updateButtons(true);
01024 qApp->restoreOverrideCursor();
01025 }
01026
01027 void TitleWidget::saveAsAlbum()
01028 {
01029
01030 QString dialogTitle = tr( "Album Shaper: Save As" );
01031 QString defaultPath;
01032
01033 if(getAlbum()->prevSave())
01034 defaultPath = getAlbum()->getSaveLocation();
01035 else
01036 {
01037 defaultPath = getAlbum()->getName();
01038 defaultPath.replace( QChar(' '), "_" );
01039 defaultPath.replace( "<", "" );
01040 defaultPath.replace( ">", "" );
01041 defaultPath.replace( "&", "and" );
01042 defaultPath.replace( "\"", "" );
01043 defaultPath.replace( "\'", "" );
01044 defaultPath.replace( "?", "" );
01045 defaultPath = QDir::convertSeparators
01046 ( window->getConfig()->getString( "loadSave", "loadSaveDir" ) + "/" + defaultPath );
01047 }
01048
01049
01050 QString theme, savePath;
01051
01052
01053 if(getAlbum()->getTheme().compare("-1") != 0)
01054 theme = getAlbum()->getTheme();
01055 else
01056 {
01057 if(window->getConfig()->getString( "loadSave", "defaultTheme" ).compare( "Last Used" ) == 0)
01058 theme = window->getConfig()->getString( "loadSave", "lastUsedTheme" );
01059 else
01060 theme = window->getConfig()->getString( "loadSave", "defaultTheme" );
01061 }
01062
01063 if( !SaveDialog::selectThemeAndPath( dialogTitle, defaultPath, theme, savePath ) )
01064 return;
01065
01066
01067 QDir d(savePath);
01068 if(!d.exists())
01069 {
01070 if(!d.mkdir(savePath))
01071 {
01072 AlertDialog alert( tr("Error creating directory!"),
01073 tr("Unable to create directory to save album in. Perhaps you are running out of disk space or you don't have sufficient privledges?"),
01074 "alertIcons/warning.png", this );
01075 alert.exec();
01076 return;
01077 }
01078 }
01079 else
01080 {
01081 if(!d.isReadable())
01082 {
01083 AlertDialog alert( tr("Destination directory not readable!"),
01084 tr("The destination directory is not readable. Perhaps you don't have sufficient privledges?"),
01085 "alertIcons/warning.png", this );
01086 alert.exec();
01087 return;
01088 }
01089 }
01090
01091
01092 QDir lastDir = QDir( savePath );
01093 lastDir.cdUp();
01094 window->getConfig()->setString( "loadSave", "loadSaveDir", lastDir.path() );
01095 window->getConfig()->setString( "loadSave", "lastUsedTheme", theme );
01096
01097
01098 setBusy(true);
01099 window->getLayout()->getSubalbums()->updateButtons(false);
01100 if(window->getLayout()->getSubalbum() != NULL)
01101 window->getLayout()->getSubalbum()->updateButtons(false);
01102 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
01103
01104
01105 getAlbum()->exportToDisk(window->getStatus(), savePath, theme);
01106 window->getConfig()->setString( "misc", "defaultAuthor", albumAuthorVal->text() );
01107
01108
01109 recentAlbums.insertEntry( albm->getName(), albm->getSaveLocation(),
01110 QString("%1").arg(albm->getNumPhotos()), false );
01111 refreshOpenRecentMenu();
01112
01113
01114 file->setItemEnabled( REVERT_TO_SAVED_ALBUM, true );
01115
01116
01117 setBusy(false);
01118 window->getLayout()->getSubalbums()->updateButtons(true);
01119 if(window->getLayout()->getSubalbum() != NULL)
01120 window->getLayout()->getSubalbum()->updateButtons(true);
01121 qApp->restoreOverrideCursor();
01122 }
01123
01124 void TitleWidget::albumStatistics()
01125 {
01126
01127 if(albumStats == NULL)
01128 {
01129 albumStats = new AlbumStatistics(albm);
01130 connect( albumStats, SIGNAL(closed()),
01131 this, SLOT(albumStatisticsClosed()));
01132 albumStats->show();
01133 centerWindow(albumStats);
01134 }
01135
01136 albumStats->raise();
01137 albumStats->setActiveWindow();
01138 }
01139
01140 void TitleWidget::removeSelectedPhotoDesc()
01141 {
01142
01143 if(window->getLayout()->getSubalbum() == NULL ||
01144 !window->getLayout()->getSubalbum()->anyPhotosSelected())
01145 return;
01146
01147
01148 if( window->getConfig()->getBool( "alerts", "showDestructiveAlerts" ) )
01149 {
01150 QuestionDialog sure( tr("Remove Selected Photo Descriptions?"),
01151 tr("This action cannot be undone. Are you sure you want to proceed?"),
01152 "alertIcons/warning.png",
01153 this );
01154 if(!sure.exec())
01155 return;
01156 }
01157
01158
01159 window->getLayout()->getSubalbum()->stripDescriptionsFromSelectedPhotos();
01160 }
01161
01162 void TitleWidget::revertPhotos()
01163 {
01164 window->getLayout()->revertPhotos();
01165 }
01166
01167 void TitleWidget::settings()
01168 {
01169
01170 if(settingsWindow == NULL)
01171 {
01172 settingsWindow = new ConfigurationWidget( window->getConfig() );
01173 connect( settingsWindow, SIGNAL(closed()),
01174 this, SLOT(settingsWindowClosed()));
01175 settingsWindow->show();
01176 centerWindow(settingsWindow);
01177 }
01178
01179 settingsWindow->raise();
01180 settingsWindow->setActiveWindow();
01181 }
01182
01183 void TitleWidget::aboutProgram(int mode)
01184 {
01185
01186 if(about == NULL)
01187 {
01188 about = new About(mode);
01189 connect( about, SIGNAL(closed()),
01190 this, SLOT(aboutClosed()));
01191 about->show();
01192 centerWindow(about);
01193 }
01194
01195 about->raise();
01196 about->setActiveWindow();
01197 }
01198
01199 void TitleWidget::help()
01200 {
01201
01202 if(helpWindow == NULL)
01203 {
01204 helpWindow = new HelpWindow(0);
01205 connect( helpWindow, SIGNAL(closed()),
01206 this, SLOT(helpClosed()));
01207 helpWindow->show();
01208 centerWindow(helpWindow);
01209 }
01210
01211 helpWindow->raise();
01212 helpWindow->setActiveWindow();
01213 }
01214
01215 void TitleWidget::albumStatisticsClosed()
01216 {
01217 delete albumStats;
01218 albumStats = NULL;
01219 }
01220
01221 void TitleWidget::aboutClosed()
01222 {
01223 delete about;
01224 about = NULL;
01225 }
01226
01227 void TitleWidget::helpClosed()
01228 {
01229 delete helpWindow;
01230 helpWindow = NULL;
01231 }
01232
01233 void TitleWidget::settingsWindowClosed()
01234 {
01235 delete settingsWindow;
01236 settingsWindow = NULL;
01237 }
01238
01239 bool TitleWidget::getBusy()
01240 {
01241 return busy;
01242 }
01243
01244 void TitleWidget::setBusy(bool val)
01245 {
01246 busy = val;
01247
01248
01249 if(busy)
01250 {
01251 file->setItemEnabled(NEW_ALBUM, false);
01252 file->setItemEnabled(OPEN_ALBUM, false);
01253 file->setItemEnabled(SAVE_ALBUM, false);
01254 file->setItemEnabled(SAVEAS_ALBUM, false);
01255 }
01256 else
01257 {
01258 file->setItemEnabled(NEW_ALBUM, true);
01259 file->setItemEnabled(OPEN_ALBUM, true);
01260 file->setItemEnabled(SAVE_ALBUM, true);
01261 file->setItemEnabled(SAVEAS_ALBUM, true);
01262 }
01263 }
01264
01265 void TitleWidget::quitApplication()
01266 {
01267 window->close();
01268 }
01269
01270 void TitleWidget::dragEnterEvent( QDragEnterEvent* e)
01271 {
01272 e->accept(true);
01273 }
01274
01275 void TitleWidget::dropEvent( QDropEvent* e )
01276 {
01277
01278
01279 repaint(false);
01280 qApp->processEvents();
01281
01282
01283 if(e->source()->parentWidget() != window->getLayout()->getSubalbum()->getPhotos())
01284 return;
01285
01286 if( e->pos().x() < (width() / 2) )
01287 setAlbumImage();
01288 else
01289 setSubalbumImage();
01290 }
01291
01292 QString TitleWidget::createTmpDir(QString albumPath)
01293 {
01294
01295
01296
01297
01298
01299 if(!albumPath.isNull())
01300 {
01301 QDir rootDir( albumPath );
01302 if(rootDir.exists( "tmp" ) || rootDir.mkdir( "tmp" ))
01303 return QDir::convertSeparators( albumPath + "/tmp" );
01304 }
01305
01306
01307 QDate date = QDate::currentDate();
01308 QTime time = QTime::currentTime();
01309 QString baseDir = window->getConfig()->getString( "loadSave", "tempImageDirectory" );
01310
01311 QDir testPath(baseDir);
01312 if(!testPath.exists())
01313 {
01314 window->getConfig()->resetSetting( "loadSave", "tempImageDirectory" );
01315 baseDir = window->getConfig()->getString( "loadSave", "tempImageDirectory" );
01316 }
01317
01318 QString tmpDir = QString("albumshaper_tmp%1%2%3%4%5%6%7").arg( date.year() ).arg( date.month() ).arg
01319 ( date.day() ).arg( time.hour() ).arg( time.minute() ).arg( time.second() ).arg( time.msec() );
01320
01321 QDir rootDir( baseDir );
01322 if(rootDir.exists() && (rootDir.exists( tmpDir ) || rootDir.mkdir( tmpDir) ) )
01323 {
01324
01325
01326
01327
01328 return QDir::convertSeparators( baseDir + "/" + tmpDir );
01329 }
01330 else
01331 {
01332
01333 return QString::null;
01334 }
01335 }
01336
01337
01338 #if defined(Q_OS_MACX)
01339 void TitleWidget::windowStateChanged(bool state)
01340 {
01341
01342 windowMenu->setItemEnabled(WINDOW_MINIMIZE, state);
01343 }
01344 #else
01345 void TitleWidget::windowStateChanged(bool)
01346 {
01347
01348 }
01349 #endif
01350
01351 void TitleWidget::clearOpenRecentMenu()
01352 {
01353
01354 recentAlbums.clearList();
01355
01356
01357 refreshOpenRecentMenu();
01358 }
01359
01360 void TitleWidget::refreshOpenRecentMenu()
01361 {
01362
01363 openRecent->clear();
01364
01365
01366 int i;
01367 int numEntries = recentAlbums.numEntries();
01368 QString recentName, recentLocation, recentPhotoCount;
01369 for(i = 0; i<numEntries; i++)
01370 {
01371 Key key;
01372 if(i == 0) key = Key_1;
01373 else if(i == 1) key = Key_2;
01374 else if(i == 2) key = Key_3;
01375 else if(i == 3) key = Key_4;
01376 else if(i == 4) key = Key_5;
01377 else if(i == 5) key = Key_6;
01378 else if(i == 6) key = Key_7;
01379 else if(i == 7) key = Key_8;
01380 else if(i == 8) key = Key_9;
01381 else key = Key_unknown;
01382
01383
01384 recentAlbums.getEntry( i, recentName, recentLocation, recentPhotoCount );
01385
01386 int recentItem;
01387 QDir tempDir;
01388
01389
01390
01391 #if defined(Q_OS_MACX)
01392 QString albumImageLocation = QDir::convertSeparators( recentLocation + "/img/album.jpg" );
01393
01394
01395 if(recentPhotoCount.compare("-1") == 0)
01396 recentPhotoCount = "";
01397 else
01398 recentPhotoCount = " (" + recentPhotoCount + ")";
01399
01400
01401 if( tempDir.exists( albumImageLocation ) )
01402 {
01403
01404 QImage scaledAlbumImage;
01405 scaleImage( albumImageLocation, scaledAlbumImage, 32, 32 );
01406
01407
01408 QPixmap scaledAlbumImagePixmap;
01409 scaledAlbumImagePixmap.convertFromImage( scaledAlbumImage );
01410
01411 recentItem = openRecent->insertItem( QIconSet( scaledAlbumImagePixmap ),
01412 QString("%1%2").arg(recentName).
01413 arg(recentPhotoCount),
01414 this, SLOT(loadRecentAlbum(int)) );
01415 }
01416
01417 else
01418 {
01419
01420 recentItem = openRecent->insertItem( QString("%1%2").arg(recentName).
01421 arg(recentPhotoCount),
01422 this, SLOT(loadRecentAlbum(int)) );
01423 }
01424
01425
01426 if( key != Key_unknown )
01427 openRecent->setAccel( CTRL+key, recentItem );
01428
01429
01430
01431
01432 #else
01433 recentItem = openRecent->insertItem( new RecentAlbumMenuItem(recentName,
01434 recentLocation,
01435 recentPhotoCount) );
01436 openRecent->connectItem( recentItem, this, SLOT(loadRecentAlbum(int)) );
01437 if( key != Key_unknown )
01438 openRecent->setAccel( CTRL+key, recentItem );
01439 #endif
01440
01441
01442 openRecent->setItemParameter( recentItem, i );
01443
01444
01445 if( !tempDir.exists( QDir::convertSeparators(recentLocation + "/Album.xml") ) )
01446 openRecent->setItemEnabled( recentItem, false );
01447 }
01448
01449
01450
01451 if(numEntries > 0) { openRecent->insertSeparator(); }
01452
01453 int CLEAR_MENU = openRecent->insertItem( tr("Clear Menu"), this, SLOT(clearOpenRecentMenu()) );
01454
01455 if(numEntries == 0)
01456 openRecent->setItemEnabled( CLEAR_MENU, false );
01457 }
01458
01459 RecentAlbums* TitleWidget::getRecentAlbums()
01460 {
01461 return &recentAlbums;
01462 }
01463
01464 void TitleWidget::updateMenus(bool anySelected, bool anyRevertable)
01465 {
01466
01467
01468
01469
01470
01471 photoMenu->setItemEnabled( REMOVE_DESCRIPTIONS, anySelected );
01472
01473
01474 photoMenu->setItemEnabled( REVERT_PHOTOS, anyRevertable );
01475 }
01476