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