14 #include <q3popupmenu.h> 21 #include <qtoolbutton.h> 22 #include <qfileinfo.h> 23 #include <qlineedit.h> 24 #include <qapplication.h> 27 #include <q3filedialog.h> 30 #include <qdatetime.h> 32 #include <Q3GridLayout> 34 #include <QDragEnterEvent> 36 #include <Q3VBoxLayout> 58 #include "../config.h" 59 #include "../backend/album.h" 60 #include "../backend/subalbum.h" 61 #include "../backend/photo.h" 62 #include "../backend/tools/fileTools.h" 63 #include "../backend/tools/guiTools.h" 64 #include "../configuration/configurationWidget.h" 65 #include "../configuration/configuration.h" 69 const char* name ) :
Q3Frame(parent,name)
72 tmpDirErrorDesc = tr(
"Album Shaper was unable to create the necessary temp directory required: ");
74 QColor white(255, 255, 255);
75 QColor lightBlue(193, 210, 238);
76 QColor darkBlue(35, 75, 139);
77 QColor black(0, 0, 0);
99 "alertIcons/warning.png", this );
106 QString recentName, recentLocation, recentPhotoCount;
115 if(recentLocation.compare(
"-1") == 0)
123 menu =
new QMenuBar(
this,
"menuBar" );
126 file =
new Q3PopupMenu(
this,
"fileMenu" );
128 tr(
"&New"),
this, SLOT(
newAlbum()), Qt::CTRL+Qt::Key_N );
131 tr(
"&Open..."),
this, SLOT(
loadAlbum()), Qt::CTRL+Qt::Key_O );
133 openRecent =
new Q3PopupMenu(
this,
"openRecentMenu" );
138 file->insertSeparator();
141 tr(
"&Save"),
this, SLOT(
saveAlbum()), Qt::CTRL+Qt::Key_S );
144 tr(
"&Save As..."),
this, SLOT(
saveAsAlbum()), Qt::CTRL+Qt::SHIFT+Qt::Key_S );
149 file->insertSeparator();
151 Q3PopupMenu* exportAs =
new Q3PopupMenu(
this,
"exportAs" );
157 file->insertItem( tr(
"Export"), exportAs );
159 file->insertSeparator();
161 file->insertItem( QIcon( QPixmap(QString(
IMAGE_PATH)+
"menuIcons/quit.png") ),
165 menu->insertItem( tr(
"&File"),
file );
168 photoMenu =
new Q3PopupMenu(
this,
"phooMenu" );
176 tools =
new Q3PopupMenu(
this,
"toolsMenu" );
186 tools->insertItem( QIcon( QPixmap(QString(
IMAGE_PATH)+
"menuIcons/albumStatistics.png") ),
187 tr(
"Album Statistics"),
this, SLOT(
albumStatistics()), Qt::CTRL+Qt::Key_I );
189 tools->insertItem( QIcon( QPixmap(QString(
IMAGE_PATH)+
"menuIcons/settings.png") ),
190 tr(
"Settings"),
this, SLOT(
settings()) );
196 #if defined(Q_OS_MACX) 197 windowMenu =
new Q3PopupMenu(
this,
"windoMenu" );
198 WINDOW_MINIMIZE = windowMenu->insertItem( tr(
"&Minimize"), (
QWidget*)
window, SLOT(showMinimized()), Qt::CTRL+Qt::Key_M );
199 menu->insertItem( tr(
"&Window"), windowMenu );
203 helpMenu =
new Q3PopupMenu(
this,
"helpMenu" );
204 helpMenu->insertItem( tr(
"Album Shaper Help"),
this, SLOT(
help()), Qt::CTRL+Qt::Key_Question );
208 menu->insertSeparator();
213 mainFrame->setPaletteBackgroundColor( darkBlue );
225 new QPixmap( QString(
IMAGE_PATH)+
"buttonIcons/removeImage.png") );
230 this->setAcceptDrops(
true);
234 connect(
albumNameVal, SIGNAL(textChanged(
const QString&)),
257 new QPixmap( QString(
IMAGE_PATH)+
"buttonIcons/removeImage.png") );
274 labelFont.setWeight(QFont::Bold);
277 albumName->setPaletteForegroundColor( white );
278 albumName->setPaletteBackgroundColor( darkBlue );
296 albumAuthor->setPaletteBackgroundColor( darkBlue );
324 Q3GridLayout* albumImageGrid =
new Q3GridLayout( albumImageFrame, 1, 1 );
325 albumImageGrid->addWidget(
albumImage, 0, 0 );
344 Q3GridLayout* subalbumImageGrid =
new Q3GridLayout( subalbumImageFrame, 1, 1 );
373 Q3VBoxLayout* vb =
new Q3VBoxLayout(
this);
374 this->layout()->setMenuBar(
menu );
416 if(collection != NULL )
419 QString oldName = collection->
getName();
426 if(oldName.compare( collection->
getName() ) != 0)
461 if( collection == NULL )
512 if(selectedPhoto == NULL)
516 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
521 qApp->restoreOverrideCursor();
544 if(selectedPhoto == NULL)
549 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
557 qApp->restoreOverrideCursor();
592 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?"),
593 "alertIcons/warning.png",
608 "alertIcons/warning.png", this );
635 if(!testPath.exists())
641 QString albumXML = Q3FileDialog::getOpenFileName( path,
642 tr(
"XML Files (*.xml)"),
645 tr(
"Choose an album to load") );
648 if(albumXML.isNull())
return;
660 QString recentName, recentLocation, recentPhotoCount;
662 loadAlbum( QDir::convertSeparators( recentLocation +
"/Album.xml") );
672 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?"),
673 "alertIcons/warning.png",
695 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?"),
696 "alertIcons/warning.png",
711 AlertDialog alert( tr(
"Previous theme not available!"),
712 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() ),
713 "alertIcons/warning.png",
this );
720 QString dialogTitle = tr(
"Export Small Web Gallery" );
725 { newDir = QDir(
getAlbum()->getSaveLocation() ).dirName() +
"_WEB"; }
732 fd->setCaption( tr(
"Export Location") );
733 fd->setMode( Q3FileDialog::DirectoryOnly );
737 if ( !fd->exec() == QDialog::Accepted ) {
return; }
740 QString exportPath = QDir::convertSeparators( fd->selectedFile() +
"/" + newDir );
745 QString errorMessage = tr(
"Error! Cannot export to album location on disk!");
746 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.");
748 "alertIcons/warning.png",
this );
755 if(tmpDir.exists( exportPath ) )
757 QString warningMessage =
758 QString(tr(
"Warning! A directory named %1 already exists in %2. Continue with export?")).arg
759 ( newDir ).arg( fd->selectedFile() );
762 warningMessage,
"alertIcons/warning.png",
764 if(!sure.exec()) {
return; }
769 if( !tmpDir.mkdir( exportPath ) )
771 AlertDialog alert( tr(
"Error creating directory!"),
772 tr(
"Unable to create directory to export images to. Perhaps you are running out of disk space or you don't have sufficient privileges?"),
773 "alertIcons/warning.png",
this );
784 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
788 QString exportMessage = tr(
"Exporting %1 photos to web gallery" );
790 qApp->processEvents();
803 qApp->restoreOverrideCursor();
809 QString dialogTitle = tr(
"Export Large Images" );
814 { newDir = QDir(
getAlbum()->getSaveLocation() ).dirName() +
"_IMAGES"; }
821 fd->setCaption( tr(
"Export Location") );
822 fd->setMode( Q3FileDialog::DirectoryOnly );
826 if ( !fd->exec() == QDialog::Accepted ) {
return; }
829 QString exportPath = QDir::convertSeparators( fd->selectedFile() +
"/" + newDir );
834 QString errorMessage = tr(
"Error! Cannot export to album location on disk!");
835 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.");
837 "alertIcons/warning.png",
this );
844 if(tmpDir.exists( exportPath ) )
846 QString warningMessage =
847 QString(tr(
"Warning! A directory named %1 already exists in %2. Continue with export?")).arg
848 ( newDir ).arg( fd->selectedFile() );
851 warningMessage,
"alertIcons/warning.png",
853 if(!sure.exec()) {
return; }
858 if( !tmpDir.mkdir( exportPath ) )
860 AlertDialog alert( tr(
"Error creating directory!"),
861 tr(
"Unable to create directory to export images to.Perhaps you are running out of disk space or you don't have sufficient privileges?"),
862 "alertIcons/warning.png",
this );
873 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
877 QString exportMessage = tr(
"Exporting %1 photos" );
879 qApp->processEvents();
892 qApp->restoreOverrideCursor();
901 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
908 QDir lastDir = QDir( QFileInfo(albumXML).dirPath() );
919 "alertIcons/warning.png", this );
948 qApp->restoreOverrideCursor();
969 QString errorMessage, errorDescription;
972 errorMessage = tr(
"Unable to open file!");
973 errorDescription = tr(
"An error was encountered attempting to load the XML file. Perhaps you do not have read access?");
977 errorMessage = tr(
"Unable to construct DOM!");
978 errorDescription = tr(
"The XML file you selected is not valid XML.");
982 errorMessage = tr(
"Unknown loading error!");
983 errorDescription = tr(
"An unknown error was encountered loading the specified file.");
986 AlertDialog alert( errorMessage, errorDescription,
"alertIcons/warning.png",
this );
1005 AlertDialog alert( tr(
"Previous theme not available!"),
1006 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."),
1007 "alertIcons/warning.png",
this );
1018 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
1037 qApp->restoreOverrideCursor();
1043 QString dialogTitle = tr(
"Save As" );
1044 QString defaultPath;
1051 defaultPath.replace( QChar(
' '),
"_" );
1052 defaultPath.replace(
"<",
"" );
1053 defaultPath.replace(
">",
"" );
1054 defaultPath.replace(
"&",
"and" );
1055 defaultPath.replace(
"\"",
"" );
1056 defaultPath.replace(
"\'",
"" );
1057 defaultPath.replace(
"?",
"" );
1058 defaultPath = QDir::convertSeparators
1063 QString theme, savePath;
1083 if(!d.mkdir(savePath))
1085 AlertDialog alert( tr(
"Error creating directory!"),
1086 tr(
"Unable to create directory to save album in. Perhaps you are running out of disk space or you don't have sufficient privileges?"),
1087 "alertIcons/warning.png",
this );
1096 AlertDialog alert( tr(
"Destination directory not readable!"),
1097 tr(
"The destination directory is not readable. Perhaps you don't have sufficient privileges?"),
1098 "alertIcons/warning.png",
this );
1105 QDir lastDir = QDir( savePath );
1115 qApp->setOverrideCursor( QCursor(Qt::WaitCursor));
1134 qApp->restoreOverrideCursor();
1164 tr(
"This action cannot be undone. Are you sure you want to proceed?"),
1165 "alertIcons/warning.png",
1202 connect(
about, SIGNAL(closed()),
1209 about->setActiveWindow();
1293 qApp->processEvents();
1296 if(e->source() == NULL ||
1300 if( e->pos().x() < (
width() / 2) )
1313 if(!albumPath.isNull())
1315 QDir rootDir( albumPath );
1316 if(rootDir.exists(
"tmp" ) || rootDir.mkdir(
"tmp" ))
1317 return QDir::convertSeparators( albumPath +
"/tmp" );
1321 QDate date = QDate::currentDate();
1322 QTime time = QTime::currentTime();
1325 QDir testPath(baseDir);
1326 if(!testPath.exists())
1332 QString tmpDir = QString(
"albumshaper_tmp%1%2%3%4%5%6%7").arg( date.year() ).arg( date.month() ).arg
1333 ( date.day() ).arg( time.hour() ).arg( time.minute() ).arg( time.second() ).arg( time.msec() );
1335 QDir rootDir( baseDir );
1336 if(rootDir.exists() && (rootDir.exists( tmpDir ) || rootDir.mkdir( tmpDir) ) )
1342 return QDir::convertSeparators( baseDir +
"/" + tmpDir );
1347 return QString::null;
1352 #if defined(Q_OS_MACX) 1356 windowMenu->setItemEnabled(WINDOW_MINIMIZE, state);
1383 for(i = 0; i<maxItems; i++)
1386 if(i == 0) key = Qt::Key_1;
1387 else if(i == 1) key = Qt::Key_2;
1388 else if(i == 2) key = Qt::Key_3;
1389 else if(i == 3) key = Qt::Key_4;
1390 else if(i == 4) key = Qt::Key_5;
1391 else if(i == 5) key = Qt::Key_6;
1392 else if(i == 6) key = Qt::Key_7;
1393 else if(i == 7) key = Qt::Key_8;
1394 else if(i == 8) key = Qt::Key_9;
1395 else key = Qt::Key_unknown;
1398 QString recentName =
"recentName";
1399 QString recentLocation =
"recentLocation";
1400 QString recentPhotoCount =
"recentPhotoCount";
1404 #if defined(Q_OS_MACX) 1418 if( key != Qt::Key_unknown )
1454 QString recentName, recentLocation, recentPhotoCount;
1463 #if defined(Q_OS_MACX) 1464 QString albumImageLocation = QDir::convertSeparators( recentLocation +
"/img/album.jpg" );
1467 if(recentPhotoCount.compare(
"-1") == 0)
1468 recentPhotoCount =
"";
1470 recentPhotoCount =
" (" + recentPhotoCount +
")";
1473 if( tempDir.exists( albumImageLocation ) )
1476 QImage scaledAlbumImage;
1477 scaleImage( albumImageLocation, scaledAlbumImage, 32, 32 );
1480 QPixmap scaledAlbumImagePixmap;
1481 scaledAlbumImagePixmap.convertFromImage( scaledAlbumImage );
1484 QIcon( scaledAlbumImagePixmap ),
1485 QString(
"%1%2").arg(recentName).arg(recentPhotoCount) );
1493 QString(
"%1%2").arg(recentName).arg(recentPhotoCount) );
1507 if( !tempDir.exists( QDir::convertSeparators(recentLocation +
"/Album.xml") ) )
1513 i < numRecentMenuItems-2 )
1520 else if (i == numRecentMenuItems-2)
1527 else if (i == numRecentMenuItems-1)
bool albumModified()
Returns true if album has been modified since the last save operation.
void setDescription(QString val)
Sets the album description.
void setPixmap(const QPixmap &p)
animates setting an image
QString getDescription()
Gets the album description.
QString getName()
Gets the album name.
A configurable alert dialog that displays an alert/error message.
QString getImageFilename()
Gets the image filename.
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
void setRepresentativeImage(QString imageFilename)
sets a sized representative image
QString getSaveLocation()
Returns the current save location of all images.
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
StatusWidget * getStatus()
returns a pointer to the status widget
QString getString(QString group, QString key)
Fetch string setting.
bool getBool(QString group, QString key)
Fetch bool setting.
void resetSetting(QString group, QString key)
Resets a setting to it's default value.
QString getThumbnailFilename()
Gets the thumbnail filename.
void setString(QString group, QString key, QString value)
Sets a setting value, if group does not exist it is created, if setting does not exist it is also cre...
void setAuthor(QString val)
Sets the album author.
QPixmap * getRepresentativeImage(int size)
Returns the representative image.
void removePixmap(bool forceImmediate=false)
animates removing an image
int importFromDisk(StatusWidget *status, QString fileName, bool disableCheckPhotoMods)
Imports album from XML format, returning int indicates success or not.
static bool selectThemeAndPath(QString titleMessage, QString defaultPath, QString &theme, QString &path)
Configuration * getConfig()
get setting object
static bool themeAvailable(QString theme)
int getNumPhotos()
Returns the number of photos.
A subalbum contains photos.
void setModified(bool val=true)
Sets the album as modified.
void setRepresentativeImages(QString imageFilename)
Sets the representative image.
void insertEntry(QString name, QString location, QString photos="-1", bool insertAtBack=true)
This class maintains and handles saving and loading a list of recently viewed albums.
LayoutWidget * getLayout()
returns a pointer to the layout object
void setAnimationMethods(int setMethod=APPEAR_IMMEDIATELY, int removalMethod=DISAPPEAR_IMMEDIATELY, int resetMethod=APPEAR_IMMEDIATELY, int removalBeforeResetMethod=DISAPPEAR_IMMEDIATELY)
alter animation methods
QPixmap * getRepresentativeImage(int size)
gets a sized representative image
Subalbum * getFirstSubalbum()
Returns a pointer to the first Subalbum.
void getEntry(int index, QString &name, QString &location, QString &photoCount)
QString getDescription()
Gets the Subalbum description.
int exportLargeImages(StatusWidget *status, QString exportPath, QString exportMessage)
Export fullsize images (excludes slideshow and thumbnail images, album and collection iamges...
bool prevSave()
Returns true if album previously saved to disk.
QString getTmpDir()
Returns the temporary directory for use when modifying and adding new images.
QString getName()
Gets the Subalbum Name.
void setName(QString val)
Sets the Subalbum Name.
An album contains Subalbums.
int exportCompressedWebAlbum(StatusWidget *status, QString exportLocation, QString exportMessage)
Export a compressed web album (excludes full size images and xml data)
void setDescription(QString val)
Sets the Subalbum description.
QString getAuthor()
Gets the album author.
QString getTheme()
Returns currently selected theme.
void refresh()
refreshes the layout
void setName(QString val)
Sets the album name.
int exportToDisk(StatusWidget *status, QString dirName, QString themeName)
Exports album in XML and HTML format, along with resized images.
A configurable question dialog that returns true/false.