AlbumShaper  1.0a3
Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Attributes
SaveDialog Class Reference

Save dialog widget. More...

#include <saveDialog.h>

Inheritance diagram for SaveDialog:
Inheritance graph
[legend]
Collaboration diagram for SaveDialog:
Collaboration graph
[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().

                                                       :
                                    QDialog(parent,name)
{
  //set window title
  setCaption( actionMessage );

  //set the background of the widget to be white
//  setPaletteBackgroundColor( QColor(255, 255, 255) );


  //create location frame and widgets
  locationFrame = new QFrame( this );
  locationLabel = new QLabel( tr("Save to:"), locationFrame );

  QFont boldFont = locationLabel->font();
  boldFont.setWeight(QFont::Bold);
  
  locationLabel->setFont( boldFont );
  locationVal = new QLineEdit( locationFrame );
  locationVal->setText( defaultPath );
  locationVal->setFont( boldFont );

  browseButton = new ClickableLabel( locationFrame );
  browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") );
  QToolTip::add( browseButton, tr("Browse to save destination") );
  connect( browseButton, SIGNAL(clicked()), SLOT(browse()) );
  locationGrid = new QGridLayout( locationFrame, 1, 3, 0 );
  locationGrid->addWidget( locationLabel, 0, 0 );
  locationGrid->addWidget( locationVal, 0, 1 );
  locationGrid->addWidget( browseButton, 0, 2);
  locationGrid->setColStretch( 1, 1 );
  locationGrid->setSpacing(WIDGET_SPACING); 
  
  //create theme selection frame and widgets
  themeSelectionFrame = new QFrame( this );
  themesLabel = new QLabel( tr("Themes:"), themeSelectionFrame );
  themesLabel->setFont( boldFont );
  themesList = new QListBox( themeSelectionFrame );
  QToolTip::add( themesList, tr("Select theme for saving album") );
  QDir localDir( THEMES_PATH );
  QStringList list = localDir.entryList( QDir::Dirs );
  bool itemsAdded = false;
  QStringList::Iterator file;
  for ( file = list.begin(); file != list.end(); ++file )
  {
    if(localDir.exists( QString(*file) + "/theme.xsl" ))
    {
      themesList->insertItem( *file );
      itemsAdded = true;
    }
  }

  //attempt to select default theme passed in, if not found select first theme in list
  bool themeFound = false;
  uint i=0;
  for(i=0; i<themesList->count(); i++)
  {
    if(themesList->text(i) == defaultTheme )
    {
      themeFound = true;
      themesList->setCurrentItem( i );
      break;
    }
  }
  if(!themeFound && itemsAdded )
  {
    themesList->setCurrentItem( 0 );
  }

  connect( themesList, SIGNAL( highlighted(int) ), this, SLOT( updatePreview() ) );

  themeSelectionGrid = new QGridLayout( themeSelectionFrame, 2, 1, 0 );
  themeSelectionGrid->addWidget( themesLabel, 0, 0 );
  themeSelectionGrid->addWidget( themesList, 1, 0 );

  //create theme preview frame and widgets
  themePreviewFrame = new QFrame( this );
  themePreviewLabel = new QLabel( tr("Theme Preview:"), themePreviewFrame );
  themePreviewLabel->setFont( boldFont );
  themeScreenShot = new QLabel( themePreviewFrame );
  screenShotLabel = new QLabel( themePreviewFrame );
  screenShotLabel->setFont( boldFont );
  
  themeScreenPrev = new ClickableLabel( themePreviewFrame );
  themeScreenPrev->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/previous.png") );
  QToolTip::add( themeScreenPrev, tr("View previous theme screenshot") );
  connect( themeScreenPrev, SIGNAL(clicked()), SLOT(prevScreenShot()) );
  
  themeScreenNext = new ClickableLabel( themePreviewFrame );
  themeScreenNext->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/next.png") );
  QToolTip::add( themeScreenNext, tr("View next theme screenshot") );
  connect( themeScreenNext, SIGNAL(clicked()), SLOT(nextScreenShot()) );

  themeFeatures = new QTextBrowser( themePreviewFrame );
  themeFeatures->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  themeFeatures->mimeSourceFactory()->setFilePath( QStringList(THEMES_PATH) );
  updatePreview();

  themePreviewGrid = new QGridLayout( themePreviewFrame, 5, 5, 0);
  themePreviewGrid->addMultiCellWidget( themePreviewLabel, 0,0, 0,4 );

  themePreviewGrid->addWidget( themeScreenPrev, 1, 0, Qt::AlignVCenter );
  themePreviewGrid->addColSpacing( 1, 10 );
  themePreviewGrid->setColStretch( 1, 1 );
  themePreviewGrid->addWidget( themeScreenShot, 1, 2 );
  themePreviewGrid->addColSpacing( 3, 10 );
  themePreviewGrid->setColStretch( 3, 1 );
  themePreviewGrid->addWidget( themeScreenNext, 1, 4, Qt::AlignVCenter );
  themePreviewGrid->addMultiCellWidget( screenShotLabel, 2, 2, 0, 4, Qt::AlignCenter );
  themePreviewGrid->addMultiCellWidget( themeFeatures, 4, 4, 0, 4 );

  //create buttons frame and widgets
  buttonsFrame = new QFrame( this );
  saveButton = new QPushButton( 
  //PLATFORM_SPECIFIC_CODE
 #ifndef Q_OS_MACX  
 QPixmap(QString(IMAGE_PATH)+"buttonIcons/save.png"),
 #endif
                               tr("Save"), buttonsFrame );
  saveButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
  saveButton->setDefault(true);
  connect( saveButton, SIGNAL(clicked()), SLOT(save()) );
  cancelButton = new QPushButton( 
  //PLATFORM_SPECIFIC_CODE
  #ifndef Q_OS_MACX  
  QPixmap(QString(IMAGE_PATH)+"buttonIcons/button_cancel.png"),
  #endif
 tr("Cancel"), buttonsFrame
);
  cancelButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
  connect( cancelButton, SIGNAL(clicked()), SLOT(cancel()) );
  buttonsGrid = new QGridLayout( buttonsFrame, 1, 5, 0 );
  buttonsGrid->setColStretch( 0, 1 );
  buttonsGrid->addWidget( saveButton, 0, 1 );
  buttonsGrid->addColSpacing( 2, 10 );
  buttonsGrid->addWidget( cancelButton, 0, 3 );
  buttonsGrid->setColStretch( 4, 1 );

  //place top level frames in grid
  mainGrid = new QGridLayout( this, 3, 2, 0);
  mainGrid->addWidget( themeSelectionFrame, 0, 0 );
  mainGrid->addWidget( themePreviewFrame, 0, 1 );
  mainGrid->addMultiCellWidget( locationFrame, 1, 1, 0, 1 );
  mainGrid->addMultiCellWidget( buttonsFrame, 2, 2, 0, 1 );

  //allow image and description region of select theme to expand to fit window
  mainGrid->setColStretch( 1, 1 );
  mainGrid->setRowStretch( 1, 1 );
  mainGrid->setMargin(WIDGET_SPACING);
  mainGrid->setSpacing(WIDGET_SPACING); 
  
  //set window to not be resizeable
  this->show();
  setFixedSize(size());
}

Member Function Documentation

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

Definition at line 253 of file saveDialog.cpp.

References locationVal.

Referenced by SaveDialog().

{
  //get directory from user
  QString dirName = QFileDialog::getSaveFileName( locationVal->text(),
                                                  NULL, this, NULL, QString(tr("Save as")) );

  if(!dirName.isNull())
    locationVal->setText( dirName );
}
void SaveDialog::cancel ( ) [private, slot]

Definition at line 228 of file saveDialog.cpp.

Referenced by SaveDialog().

{
  reject();
}
void SaveDialog::dialogClosed ( ) [signal]
QString SaveDialog::getPath ( )

Definition at line 268 of file saveDialog.cpp.

References locationVal.

Referenced by selectThemeAndPath().

{
  return locationVal->text();
}
QString SaveDialog::getTheme ( )

Definition at line 263 of file saveDialog.cpp.

References themesList.

Referenced by selectThemeAndPath().

{
  return themesList->currentText();
}
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().

{
  previewNum++;
  themeScreenPrev->setInvisible(false);
  themeScreenNext->setInvisible(previewNum == numPreviews);

  screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
  themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
}
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().

{
  previewNum--;
  themeScreenNext->setInvisible(false);
  themeScreenPrev->setInvisible(previewNum == 1);

  screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
  themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
}
void SaveDialog::save ( ) [private, slot]

Definition at line 223 of file saveDialog.cpp.

Referenced by SaveDialog().

{
  accept();
}
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().

{
  SaveDialog* dlg = new SaveDialog( titleMessage, defaultPath, theme );
  if( dlg->exec() == QDialog::Accepted )
  {
    theme = dlg->getTheme();
    path = dlg->getPath();
    delete dlg;
    return true;
  }
  else
  {
    delete dlg;
    return false;
  }
}
bool SaveDialog::themeAvailable ( QString  theme) [static]

Definition at line 293 of file saveDialog.cpp.

References THEMES_PATH.

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

{
  //walk through the themes directory searching
  //for a directory with the name of the theme
  //that also has a theme.xsl file inside it
  QDir localDir( THEMES_PATH );
  QStringList list = localDir.entryList( QDir::Dirs );
  QStringList::Iterator file;
  for ( file = list.begin(); file != list.end(); ++file )
  {
    if(localDir.exists( QString(*file) + "/theme.xsl") &&
      QString(*file) == theme)
      return true;
  }
  //theme not found
  return false;
}
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().

{
  previewNum = 1;
  int i=1;
  QDir localDir( THEMES_PATH );
  while( localDir.exists( QString( themesList->currentText() + "/preview%1.png").arg(i) ) ) { i++; }
  numPreviews = i-1;

  //update theme description if provided
  if(localDir.exists( themesList->currentText() + "/description.html" ))
  {
    themeFeatures->setSource( themesList->currentText() + "/description.html" );
  }

  //update preview image to provide one or default otherwise
  if(localDir.exists( themesList->currentText() + "/preview1.png") )
  {
    screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
    themeScreenShot->setPixmap( QPixmap(THEMES_PATH + themesList->currentText() + "/preview1.png") );
    themeScreenPrev->setInvisible( true );    
    themeScreenNext->setInvisible( previewNum == numPreviews );
  }
  else
  {
    screenShotLabel->setText( "" );
    themeScreenShot->setPixmap( QPixmap(QString(IMAGE_PATH)+"miscImages/themePreview.png") );
    themeScreenPrev->setInvisible( true );
    themeScreenNext->setInvisible( true );
  }

}

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: