SaveDialog Class Reference

Save dialog widget. More...

#include <saveDialog.h>

Inheritance diagram for SaveDialog:
[legend]
Collaboration diagram for SaveDialog:
[legend]

List of all members.

Signals

void dialogClosed ()

Public Member Functions

 SaveDialog (QString actionMessage, QString defaultPath, QString defaultTheme, QWidget *parent=0, const char *name=0)
QString getTheme ()
QString getPath ()

Static Public Member Functions

static bool selectThemeAndPath (QString titleMessage, QString defaultPath, QString &theme, QString &path)
static bool themeAvailable (QString theme)

Private Slots

void updatePreview ()
void save ()
void cancel ()
void prevScreenShot ()
void nextScreenShot ()
void browse ()

Private Attributes

QFramelocationFrame
QFramethemeSelectionFrame
QFramethemePreviewFrame
QFramebuttonsFrame
QGridLayout * locationGrid
QGridLayout * themeSelectionGrid
QGridLayout * themePreviewGrid
QGridLayout * mainGrid
QGridLayout * buttonsGrid
QLabellocationLabel
QLabelthemeScreenShot
QLabelthemePreviewLabel
QLabelthemesLabel
QLabelscreenShotLabel
QLineEdit * locationVal
QListBox * themesList
QTextBrowserthemeFeatures
QPushButton * saveButton
QPushButton * cancelButton
ClickableLabelbrowseButton
ClickableLabelthemeScreenPrev
ClickableLabelthemeScreenNext
int previewNum
int numPreviews

Detailed Description

Save dialog widget.

Definition at line 32 of file saveDialog.h.


Constructor & Destructor Documentation

SaveDialog::SaveDialog ( QString  actionMessage,
QString  defaultPath,
QString  defaultTheme,
QWidget parent = 0,
const char *  name = 0 
)

Definition at line 31 of file saveDialog.cpp.

References browse(), browseButton, buttonsFrame, buttonsGrid, cancel(), cancelButton, IMAGE_PATH, locationFrame, locationGrid, locationLabel, locationVal, mainGrid, nextScreenShot(), prevScreenShot(), save(), saveButton, screenShotLabel, ClickableLabel::setPixmap(), themeFeatures, themePreviewFrame, themePreviewGrid, themePreviewLabel, THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, themeSelectionFrame, themeSelectionGrid, themesLabel, themesList, updatePreview(), and WIDGET_SPACING.

Referenced by selectThemeAndPath().

00036                                                        :
00037                                     QDialog(parent,name)
00038 {
00039   //set window title
00040   setCaption( actionMessage );
00041 
00042   //set the background of the widget to be white
00043 //  setPaletteBackgroundColor( QColor(255, 255, 255) );
00044 
00045 
00046   //create location frame and widgets
00047   locationFrame = new QFrame( this );
00048   locationLabel = new QLabel( tr("Save to:"), locationFrame );
00049 
00050   QFont boldFont = locationLabel->font();
00051   boldFont.setWeight(QFont::Bold);
00052   
00053   locationLabel->setFont( boldFont );
00054   locationVal = new QLineEdit( locationFrame );
00055   locationVal->setText( defaultPath );
00056   locationVal->setFont( boldFont );
00057 
00058   browseButton = new ClickableLabel( locationFrame );
00059   browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") );
00060   QToolTip::add( browseButton, tr("Browse to save destination") );
00061   connect( browseButton, SIGNAL(clicked()), SLOT(browse()) );
00062   locationGrid = new QGridLayout( locationFrame, 1, 3, 0 );
00063   locationGrid->addWidget( locationLabel, 0, 0 );
00064   locationGrid->addWidget( locationVal, 0, 1 );
00065   locationGrid->addWidget( browseButton, 0, 2);
00066   locationGrid->setColStretch( 1, 1 );
00067   locationGrid->setSpacing(WIDGET_SPACING); 
00068   
00069   //create theme selection frame and widgets
00070   themeSelectionFrame = new QFrame( this );
00071   themesLabel = new QLabel( tr("Themes:"), themeSelectionFrame );
00072   themesLabel->setFont( boldFont );
00073   themesList = new QListBox( themeSelectionFrame );
00074   QToolTip::add( themesList, tr("Select theme for saving album") );
00075   QDir localDir( THEMES_PATH );
00076   QStringList list = localDir.entryList( QDir::Dirs );
00077   bool itemsAdded = false;
00078   QStringList::Iterator file;
00079   for ( file = list.begin(); file != list.end(); ++file )
00080   {
00081     if(localDir.exists( QString(*file) + "/theme.xsl" ))
00082     {
00083       themesList->insertItem( *file );
00084       itemsAdded = true;
00085     }
00086   }
00087 
00088   //attempt to select default theme passed in, if not found select first theme in list
00089   bool themeFound = false;
00090   uint i=0;
00091   for(i=0; i<themesList->count(); i++)
00092   {
00093     if(themesList->text(i) == defaultTheme )
00094     {
00095       themeFound = true;
00096       themesList->setCurrentItem( i );
00097       break;
00098     }
00099   }
00100   if(!themeFound && itemsAdded )
00101   {
00102     themesList->setCurrentItem( 0 );
00103   }
00104 
00105   connect( themesList, SIGNAL( highlighted(int) ), this, SLOT( updatePreview() ) );
00106 
00107   themeSelectionGrid = new QGridLayout( themeSelectionFrame, 2, 1, 0 );
00108   themeSelectionGrid->addWidget( themesLabel, 0, 0 );
00109   themeSelectionGrid->addWidget( themesList, 1, 0 );
00110 
00111   //create theme preview frame and widgets
00112   themePreviewFrame = new QFrame( this );
00113   themePreviewLabel = new QLabel( tr("Theme Preview:"), themePreviewFrame );
00114   themePreviewLabel->setFont( boldFont );
00115   themeScreenShot = new QLabel( themePreviewFrame );
00116   screenShotLabel = new QLabel( themePreviewFrame );
00117   screenShotLabel->setFont( boldFont );
00118   
00119   themeScreenPrev = new ClickableLabel( themePreviewFrame );
00120   themeScreenPrev->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/previous.png") );
00121   QToolTip::add( themeScreenPrev, tr("View previous theme screenshot") );
00122   connect( themeScreenPrev, SIGNAL(clicked()), SLOT(prevScreenShot()) );
00123   
00124   themeScreenNext = new ClickableLabel( themePreviewFrame );
00125   themeScreenNext->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/next.png") );
00126   QToolTip::add( themeScreenNext, tr("View next theme screenshot") );
00127   connect( themeScreenNext, SIGNAL(clicked()), SLOT(nextScreenShot()) );
00128 
00129   themeFeatures = new QTextBrowser( themePreviewFrame );
00130   themeFeatures->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00131   themeFeatures->mimeSourceFactory()->setFilePath( QStringList(THEMES_PATH) );
00132   updatePreview();
00133 
00134   themePreviewGrid = new QGridLayout( themePreviewFrame, 5, 5, 0);
00135   themePreviewGrid->addMultiCellWidget( themePreviewLabel, 0,0, 0,4 );
00136 
00137   themePreviewGrid->addWidget( themeScreenPrev, 1, 0, Qt::AlignVCenter );
00138   themePreviewGrid->addColSpacing( 1, 10 );
00139   themePreviewGrid->setColStretch( 1, 1 );
00140   themePreviewGrid->addWidget( themeScreenShot, 1, 2 );
00141   themePreviewGrid->addColSpacing( 3, 10 );
00142   themePreviewGrid->setColStretch( 3, 1 );
00143   themePreviewGrid->addWidget( themeScreenNext, 1, 4, Qt::AlignVCenter );
00144   themePreviewGrid->addMultiCellWidget( screenShotLabel, 2, 2, 0, 4, Qt::AlignCenter );
00145   themePreviewGrid->addMultiCellWidget( themeFeatures, 4, 4, 0, 4 );
00146 
00147   //create buttons frame and widgets
00148   buttonsFrame = new QFrame( this );
00149   saveButton = new QPushButton( 
00150   //PLATFORM_SPECIFIC_CODE
00151  #ifndef Q_OS_MACX  
00152  QPixmap(QString(IMAGE_PATH)+"buttonIcons/save.png"),
00153  #endif
00154                                tr("Save"), buttonsFrame );
00155   saveButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00156   saveButton->setDefault(true);
00157   connect( saveButton, SIGNAL(clicked()), SLOT(save()) );
00158   cancelButton = new QPushButton( 
00159   //PLATFORM_SPECIFIC_CODE
00160   #ifndef Q_OS_MACX  
00161   QPixmap(QString(IMAGE_PATH)+"buttonIcons/button_cancel.png"),
00162   #endif
00163  tr("Cancel"), buttonsFrame
00164 );
00165   cancelButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00166   connect( cancelButton, SIGNAL(clicked()), SLOT(cancel()) );
00167   buttonsGrid = new QGridLayout( buttonsFrame, 1, 5, 0 );
00168   buttonsGrid->setColStretch( 0, 1 );
00169   buttonsGrid->addWidget( saveButton, 0, 1 );
00170   buttonsGrid->addColSpacing( 2, 10 );
00171   buttonsGrid->addWidget( cancelButton, 0, 3 );
00172   buttonsGrid->setColStretch( 4, 1 );
00173 
00174   //place top level frames in grid
00175   mainGrid = new QGridLayout( this, 3, 2, 0);
00176   mainGrid->addWidget( themeSelectionFrame, 0, 0 );
00177   mainGrid->addWidget( themePreviewFrame, 0, 1 );
00178   mainGrid->addMultiCellWidget( locationFrame, 1, 1, 0, 1 );
00179   mainGrid->addMultiCellWidget( buttonsFrame, 2, 2, 0, 1 );
00180 
00181   //allow image and description region of select theme to expand to fit window
00182   mainGrid->setColStretch( 1, 1 );
00183   mainGrid->setRowStretch( 1, 1 );
00184   mainGrid->setMargin(WIDGET_SPACING);
00185   mainGrid->setSpacing(WIDGET_SPACING); 
00186   
00187   //set window to not be resizeable
00188   this->show();
00189   setFixedSize(size());
}


Member Function Documentation

void SaveDialog::browse (  )  [private, slot]

Definition at line 253 of file saveDialog.cpp.

References locationVal.

Referenced by SaveDialog().

00254 {
00255   //get directory from user
00256   QString dirName = QFileDialog::getSaveFileName( locationVal->text(),
00257                                                   NULL, this, NULL, QString(tr("Save as")) );
00258 
00259   if(!dirName.isNull())
00260     locationVal->setText( dirName );
00261 }

void SaveDialog::cancel (  )  [private, slot]

Definition at line 228 of file saveDialog.cpp.

Referenced by SaveDialog().

00229 {
00230   reject();
00231 }

void SaveDialog::dialogClosed (  )  [signal]
QString SaveDialog::getPath (  ) 

Definition at line 268 of file saveDialog.cpp.

References locationVal.

Referenced by selectThemeAndPath().

00269 {
00270   return locationVal->text();
00271 }

QString SaveDialog::getTheme (  ) 

Definition at line 263 of file saveDialog.cpp.

References themesList.

Referenced by selectThemeAndPath().

00264 {
00265   return themesList->currentText();
00266 }

void SaveDialog::nextScreenShot (  )  [private, slot]

Definition at line 243 of file saveDialog.cpp.

References numPreviews, previewNum, screenShotLabel, ClickableLabel::setInvisible(), THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, and themesList.

Referenced by SaveDialog().

00244 {
00245   previewNum++;
00246   themeScreenPrev->setInvisible(false);
00247   themeScreenNext->setInvisible(previewNum == numPreviews);
00248 
00249   screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
00250   themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
00251 }

void SaveDialog::prevScreenShot (  )  [private, slot]

Definition at line 233 of file saveDialog.cpp.

References numPreviews, previewNum, screenShotLabel, ClickableLabel::setInvisible(), THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, and themesList.

Referenced by SaveDialog().

00234 {
00235   previewNum--;
00236   themeScreenNext->setInvisible(false);
00237   themeScreenPrev->setInvisible(previewNum == 1);
00238 
00239   screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
00240   themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
00241 }

void SaveDialog::save (  )  [private, slot]

Definition at line 223 of file saveDialog.cpp.

Referenced by SaveDialog().

00224 {
00225   accept();
00226 }

bool SaveDialog::selectThemeAndPath ( QString  titleMessage,
QString  defaultPath,
QString &  theme,
QString &  path 
) [static]

Definition at line 273 of file saveDialog.cpp.

References getPath(), getTheme(), and SaveDialog().

Referenced by TitleWidget::saveAsAlbum().

00277 {
00278   SaveDialog* dlg = new SaveDialog( titleMessage, defaultPath, theme );
00279   if( dlg->exec() == QDialog::Accepted )
00280   {
00281     theme = dlg->getTheme();
00282     path = dlg->getPath();
00283     delete dlg;
00284     return true;
00285   }
00286   else
00287   {
00288     delete dlg;
00289     return false;
00290   }
00291 }

bool SaveDialog::themeAvailable ( QString  theme  )  [static]

Definition at line 293 of file saveDialog.cpp.

References THEMES_PATH.

Referenced by TitleWidget::exportSmallWebGallery(), and TitleWidget::saveAlbum().

00294 {
00295   //walk through the themes directory searching
00296   //for a directory with the name of the theme
00297   //that also has a theme.xsl file inside it
00298   QDir localDir( THEMES_PATH );
00299   QStringList list = localDir.entryList( QDir::Dirs );
00300   QStringList::Iterator file;
00301   for ( file = list.begin(); file != list.end(); ++file )
00302   {
00303     if(localDir.exists( QString(*file) + "/theme.xsl") &&
00304       QString(*file) == theme)
00305       return true;
00306   }
00307   //theme not found
00308   return false;
00309 }

void SaveDialog::updatePreview (  )  [private, slot]

Definition at line 191 of file saveDialog.cpp.

References IMAGE_PATH, numPreviews, previewNum, screenShotLabel, ClickableLabel::setInvisible(), themeFeatures, THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, and themesList.

Referenced by SaveDialog().

00192 {
00193   previewNum = 1;
00194   int i=1;
00195   QDir localDir( THEMES_PATH );
00196   while( localDir.exists( QString( themesList->currentText() + "/preview%1.png").arg(i) ) ) { i++; }
00197   numPreviews = i-1;
00198 
00199   //update theme description if provided
00200   if(localDir.exists( themesList->currentText() + "/description.html" ))
00201   {
00202     themeFeatures->setSource( themesList->currentText() + "/description.html" );
00203   }
00204 
00205   //update preview image to provide one or default otherwise
00206   if(localDir.exists( themesList->currentText() + "/preview1.png") )
00207   {
00208     screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
00209     themeScreenShot->setPixmap( QPixmap(THEMES_PATH + themesList->currentText() + "/preview1.png") );
00210     themeScreenPrev->setInvisible( true );    
00211     themeScreenNext->setInvisible( previewNum == numPreviews );
00212   }
00213   else
00214   {
00215     screenShotLabel->setText( "" );
00216     themeScreenShot->setPixmap( QPixmap(QString(IMAGE_PATH)+"miscImages/themePreview.png") );
00217     themeScreenPrev->setInvisible( true );
00218     themeScreenNext->setInvisible( true );
00219   }
00220 
00221 }


Member Data Documentation

Definition at line 69 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 61 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout * SaveDialog::buttonsGrid [private]

Definition at line 62 of file saveDialog.h.

Referenced by SaveDialog().

QPushButton * SaveDialog::cancelButton [private]

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 61 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout* SaveDialog::locationGrid [private]

Definition at line 62 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 63 of file saveDialog.h.

Referenced by SaveDialog().

QLineEdit* SaveDialog::locationVal [private]

Definition at line 64 of file saveDialog.h.

Referenced by browse(), getPath(), and SaveDialog().

QGridLayout * SaveDialog::mainGrid [private]

Definition at line 62 of file saveDialog.h.

Referenced by SaveDialog().

int SaveDialog::numPreviews [private]

Definition at line 72 of file saveDialog.h.

Referenced by nextScreenShot(), prevScreenShot(), and updatePreview().

int SaveDialog::previewNum [private]

Definition at line 71 of file saveDialog.h.

Referenced by nextScreenShot(), prevScreenShot(), and updatePreview().

QPushButton* SaveDialog::saveButton [private]

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 63 of file saveDialog.h.

Referenced by nextScreenShot(), prevScreenShot(), SaveDialog(), and updatePreview().

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog(), and updatePreview().

Definition at line 61 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout * SaveDialog::themePreviewGrid [private]

Definition at line 62 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 63 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 69 of file saveDialog.h.

Referenced by nextScreenShot(), prevScreenShot(), SaveDialog(), and updatePreview().

Definition at line 69 of file saveDialog.h.

Referenced by nextScreenShot(), prevScreenShot(), SaveDialog(), and updatePreview().

Definition at line 63 of file saveDialog.h.

Referenced by nextScreenShot(), prevScreenShot(), SaveDialog(), and updatePreview().

Definition at line 61 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout * SaveDialog::themeSelectionGrid [private]

Definition at line 62 of file saveDialog.h.

Referenced by SaveDialog().

Definition at line 63 of file saveDialog.h.

Referenced by SaveDialog().

QListBox* SaveDialog::themesList [private]

Definition at line 65 of file saveDialog.h.

Referenced by getTheme(), nextScreenShot(), prevScreenShot(), SaveDialog(), and updatePreview().


The documentation for this class was generated from the following files:
Generated on Sun Dec 5 14:44:57 2010 for AlbumShaper by  doxygen 1.6.3