Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

SaveDialog Class Reference

#include <saveDialog.h>

Inheritance diagram for SaveDialog:

Inheritance graph
[legend]
Collaboration diagram for SaveDialog:

Collaboration graph
[legend]
List of all members.

Detailed Description

Save dialog widget.

Definition at line 37 of file saveDialog.h.

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

bool selectThemeAndPath (QString titleMessage, QString defaultPath, QString &theme, QString &path)
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
QLabel * locationLabel
QLabel * themeScreenShot
QLabel * themePreviewLabel
QLabel * themesLabel
QLabel * screenShotLabel
QLineEdit * locationVal
QListBox * themesList
QTextBrowser * themeFeatures
QPushButton * saveButton
QPushButton * cancelButton
QPushButton * themeScreenPrev
QPushButton * themeScreenNext
QPushButton * browseButton
int previewNum
int numPreviews


Constructor & Destructor Documentation

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

Definition at line 38 of file saveDialog.cpp.

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

Referenced by selectThemeAndPath().

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


Member Function Documentation

void SaveDialog::browse  )  [private, slot]
 

Definition at line 249 of file saveDialog.cpp.

References locationVal.

Referenced by SaveDialog().

00250 {
00251   QString dirName = QFileDialog::getSaveFileName( locationVal->text(),
00252                                                                           NULL,
00253                                                                           this,
00254                                                                           NULL,
00255                                                                           "Save as" );
00256   
00257   
00258   if(!dirName.isNull())
00259     locationVal->setText( dirName );
00260 }

void SaveDialog::cancel  )  [private, slot]
 

Definition at line 218 of file saveDialog.cpp.

Referenced by SaveDialog().

00219 {
00220   reject();
00221 }

void SaveDialog::dialogClosed  )  [signal]
 

QString SaveDialog::getPath  ) 
 

Definition at line 267 of file saveDialog.cpp.

References locationVal.

Referenced by selectThemeAndPath().

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

QString SaveDialog::getTheme  ) 
 

Definition at line 262 of file saveDialog.cpp.

References themesList.

Referenced by selectThemeAndPath().

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

void SaveDialog::nextScreenShot  )  [private, slot]
 

Definition at line 236 of file saveDialog.cpp.

References numPreviews, previewNum, screenShotLabel, THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, and themesList.

Referenced by SaveDialog().

00237 {
00238   previewNum++;
00239   themeScreenPrev->setEnabled(true);
00240   if(previewNum == numPreviews)
00241   {
00242     themeScreenNext->setEnabled(false);
00243   }
00244   
00245   screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
00246   themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
00247 }

void SaveDialog::prevScreenShot  )  [private, slot]
 

Definition at line 223 of file saveDialog.cpp.

References numPreviews, previewNum, screenShotLabel, THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, and themesList.

Referenced by SaveDialog().

00224 {
00225   previewNum--;
00226   themeScreenNext->setEnabled(true);
00227   if(previewNum == 1)
00228   {
00229     themeScreenPrev->setEnabled(false);
00230   }
00231   
00232   screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
00233   themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
00234 }

void SaveDialog::save  )  [private, slot]
 

Definition at line 213 of file saveDialog.cpp.

Referenced by SaveDialog().

00214 {
00215   accept();
00216 }

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

Definition at line 272 of file saveDialog.cpp.

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

Referenced by TitleWidget::saveAsAlbum().

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

bool SaveDialog::themeAvailable QString  theme  )  [static]
 

Definition at line 292 of file saveDialog.cpp.

References THEMES_PATH.

Referenced by TitleWidget::saveAlbum().

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

void SaveDialog::updatePreview  )  [private, slot]
 

Definition at line 178 of file saveDialog.cpp.

References IMAGE_PATH, numPreviews, previewNum, screenShotLabel, themeFeatures, THEMES_PATH, themeScreenNext, themeScreenPrev, themeScreenShot, and themesList.

Referenced by SaveDialog().

00179 {
00180   previewNum = 1;
00181   int i=1;
00182   QDir localDir( THEMES_PATH );
00183   while( localDir.exists( QString( themesList->currentText() + "/preview%1.png").arg(i) ) )
00184   {
00185     i++;
00186   }
00187   numPreviews = i-1;
00188 
00189   //update theme description if provided
00190   if(localDir.exists( themesList->currentText() + "/description.html" ))
00191   {
00192     themeFeatures->setSource( themesList->currentText() + "/description.html" );
00193   }
00194   
00195   //update preview image to provide one or default otherwise
00196   if(localDir.exists( themesList->currentText() + "/preview1.png") )
00197   {
00198     screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
00199     themeScreenShot->setPixmap( QPixmap(THEMES_PATH + themesList->currentText() + "/preview1.png") );
00200     themeScreenPrev->setEnabled(false);
00201     themeScreenNext->setEnabled(true);
00202   }
00203   else
00204   {
00205     screenShotLabel->setText( "" );
00206     themeScreenShot->setPixmap( QPixmap(QString(IMAGE_PATH)+"themePreview.png") );
00207     themeScreenPrev->setEnabled(false);
00208     themeScreenNext->setEnabled(false);
00209   }
00210 
00211 }


Member Data Documentation

QPushButton * SaveDialog::browseButton [private]
 

Definition at line 72 of file saveDialog.h.

Referenced by SaveDialog().

QFrame * SaveDialog::buttonsFrame [private]
 

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout * SaveDialog::buttonsGrid [private]
 

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

QPushButton * SaveDialog::cancelButton [private]
 

Definition at line 72 of file saveDialog.h.

Referenced by SaveDialog().

QFrame* SaveDialog::locationFrame [private]
 

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout* SaveDialog::locationGrid [private]
 

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

QLabel* SaveDialog::locationLabel [private]
 

Definition at line 68 of file saveDialog.h.

Referenced by SaveDialog().

QLineEdit* SaveDialog::locationVal [private]
 

Definition at line 69 of file saveDialog.h.

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

QGridLayout * SaveDialog::mainGrid [private]
 

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

int SaveDialog::numPreviews [private]
 

Definition at line 74 of file saveDialog.h.

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

int SaveDialog::previewNum [private]
 

Definition at line 73 of file saveDialog.h.

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

QPushButton* SaveDialog::saveButton [private]
 

Definition at line 72 of file saveDialog.h.

Referenced by SaveDialog().

QLabel * SaveDialog::screenShotLabel [private]
 

Definition at line 68 of file saveDialog.h.

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

QTextBrowser* SaveDialog::themeFeatures [private]
 

Definition at line 71 of file saveDialog.h.

Referenced by SaveDialog(), and updatePreview().

QFrame * SaveDialog::themePreviewFrame [private]
 

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout * SaveDialog::themePreviewGrid [private]
 

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

QLabel * SaveDialog::themePreviewLabel [private]
 

Definition at line 68 of file saveDialog.h.

Referenced by SaveDialog().

QPushButton * SaveDialog::themeScreenNext [private]
 

Definition at line 72 of file saveDialog.h.

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

QPushButton * SaveDialog::themeScreenPrev [private]
 

Definition at line 72 of file saveDialog.h.

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

QLabel * SaveDialog::themeScreenShot [private]
 

Definition at line 68 of file saveDialog.h.

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

QFrame * SaveDialog::themeSelectionFrame [private]
 

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

QGridLayout * SaveDialog::themeSelectionGrid [private]
 

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

QLabel * SaveDialog::themesLabel [private]
 

Definition at line 68 of file saveDialog.h.

Referenced by SaveDialog().

QListBox* SaveDialog::themesList [private]
 

Definition at line 70 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 Thu Nov 13 00:11:15 2003 for AlbumShaper by doxygen 1.3.4