AlbumShaper  1.0a3
Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Attributes | List of all members
SaveDialog Class Reference

Save dialog widget. More...

#include <saveDialog.h>

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

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

Q3FramelocationFrame
 
Q3FramethemeSelectionFrame
 
Q3FramethemePreviewFrame
 
Q3FramebuttonsFrame
 
Q3GridLayout * locationGrid
 
Q3GridLayout * themeSelectionGrid
 
Q3GridLayout * themePreviewGrid
 
Q3GridLayout * mainGrid
 
Q3GridLayout * buttonsGrid
 
QLabellocationLabel
 
QLabelthemeScreenShot
 
QLabelthemePreviewLabel
 
QLabelthemesLabel
 
QLabelscreenShotLabel
 
QLineEdit * locationVal
 
Q3ListBox * themesList
 
Q3TextBrowserthemeFeatures
 
QPushButton * saveButton
 
QPushButton * cancelButton
 
ClickableLabelbrowseButton
 
ClickableLabelthemeScreenPrev
 
ClickableLabelthemeScreenNext
 
int previewNum
 
int numPreviews
 

Detailed Description

Save dialog widget.

Definition at line 36 of file saveDialog.h.

Constructor & Destructor Documentation

§ SaveDialog()

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

Definition at line 34 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().

38  :
39  QDialog(parent,name)
40 {
41  //set window title
42  setCaption( actionMessage );
43 
44  //set the background of the widget to be white
45 // setPaletteBackgroundColor( QColor(255, 255, 255) );
46 
47 
48  //create location frame and widgets
49  locationFrame = new Q3Frame( this );
50  locationLabel = new QLabel( tr("Save to:"), locationFrame );
51 
52  QFont boldFont = locationLabel->font();
53  boldFont.setWeight(QFont::Bold);
54 
55  locationLabel->setFont( boldFont );
56  locationVal = new QLineEdit( locationFrame );
57  locationVal->setText( defaultPath );
58  locationVal->setFont( boldFont );
59 
61  browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") );
62  QToolTip::add( browseButton, tr("Browse to save destination") );
63  connect( browseButton, SIGNAL(clicked()), SLOT(browse()) );
64  locationGrid = new Q3GridLayout( locationFrame, 1, 3, 0 );
65  locationGrid->addWidget( locationLabel, 0, 0 );
66  locationGrid->addWidget( locationVal, 0, 1 );
67  locationGrid->addWidget( browseButton, 0, 2);
68  locationGrid->setColStretch( 1, 1 );
69  locationGrid->setSpacing(WIDGET_SPACING);
70 
71  //create theme selection frame and widgets
72  themeSelectionFrame = new Q3Frame( this );
73  themesLabel = new QLabel( tr("Themes:"), themeSelectionFrame );
74  themesLabel->setFont( boldFont );
75  themesList = new Q3ListBox( themeSelectionFrame );
76  QToolTip::add( themesList, tr("Select theme for saving album") );
77  QDir localDir( THEMES_PATH );
78  QStringList list = localDir.entryList( QDir::Dirs );
79  bool itemsAdded = false;
80  QStringList::Iterator file;
81  for ( file = list.begin(); file != list.end(); ++file )
82  {
83  if(localDir.exists( QString(*file) + "/theme.xsl" ))
84  {
85  themesList->insertItem( *file );
86  itemsAdded = true;
87  }
88  }
89 
90  //attempt to select default theme passed in, if not found select first theme in list
91  bool themeFound = false;
92  uint i=0;
93  for(i=0; i<themesList->count(); i++)
94  {
95  if(themesList->text(i) == defaultTheme )
96  {
97  themeFound = true;
98  themesList->setCurrentItem( i );
99  break;
100  }
101  }
102  if(!themeFound && itemsAdded )
103  {
104  themesList->setCurrentItem( 0 );
105  }
106 
107  connect( themesList, SIGNAL( highlighted(int) ), this, SLOT( updatePreview() ) );
108 
109  themeSelectionGrid = new Q3GridLayout( themeSelectionFrame, 2, 1, 0 );
110  themeSelectionGrid->addWidget( themesLabel, 0, 0 );
111  themeSelectionGrid->addWidget( themesList, 1, 0 );
112 
113  //create theme preview frame and widgets
114  themePreviewFrame = new Q3Frame( this );
115  themePreviewLabel = new QLabel( tr("Theme Preview:"), themePreviewFrame );
116  themePreviewLabel->setFont( boldFont );
119  screenShotLabel->setFont( boldFont );
120 
122  themeScreenPrev->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/previous.png") );
123  QToolTip::add( themeScreenPrev, tr("View previous theme screenshot") );
124  connect( themeScreenPrev, SIGNAL(clicked()), SLOT(prevScreenShot()) );
125 
127  themeScreenNext->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/next.png") );
128  QToolTip::add( themeScreenNext, tr("View next theme screenshot") );
129  connect( themeScreenNext, SIGNAL(clicked()), SLOT(nextScreenShot()) );
130 
132  themeFeatures->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
133  themeFeatures->mimeSourceFactory()->setFilePath( QStringList(THEMES_PATH) );
134  updatePreview();
135 
136  themePreviewGrid = new Q3GridLayout( themePreviewFrame, 5, 5, 0);
137  themePreviewGrid->addMultiCellWidget( themePreviewLabel, 0,0, 0,4 );
138 
139  themePreviewGrid->addWidget( themeScreenPrev, 1, 0, Qt::AlignVCenter );
140  themePreviewGrid->addColSpacing( 1, 10 );
141  themePreviewGrid->setColStretch( 1, 1 );
142  themePreviewGrid->addWidget( themeScreenShot, 1, 2 );
143  themePreviewGrid->addColSpacing( 3, 10 );
144  themePreviewGrid->setColStretch( 3, 1 );
145  themePreviewGrid->addWidget( themeScreenNext, 1, 4, Qt::AlignVCenter );
146  themePreviewGrid->addMultiCellWidget( screenShotLabel, 2, 2, 0, 4, Qt::AlignCenter );
147  themePreviewGrid->addMultiCellWidget( themeFeatures, 4, 4, 0, 4 );
148 
149  //create buttons frame and widgets
150  buttonsFrame = new Q3Frame( this );
151  saveButton = new QPushButton(
152  //PLATFORM_SPECIFIC_CODE
153  #ifndef Q_OS_MACX
154  QPixmap(QString(IMAGE_PATH)+"buttonIcons/save.png"),
155  #endif
156  tr("Save"), buttonsFrame );
157  saveButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
158  saveButton->setDefault(true);
159  connect( saveButton, SIGNAL(clicked()), SLOT(save()) );
160  cancelButton = new QPushButton(
161  //PLATFORM_SPECIFIC_CODE
162  #ifndef Q_OS_MACX
163  QPixmap(QString(IMAGE_PATH)+"buttonIcons/button_cancel.png"),
164  #endif
165  tr("Cancel"), buttonsFrame
166 );
167  cancelButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
168  connect( cancelButton, SIGNAL(clicked()), SLOT(cancel()) );
169  buttonsGrid = new Q3GridLayout( buttonsFrame, 1, 5, 0 );
170  buttonsGrid->setColStretch( 0, 1 );
171  buttonsGrid->addWidget( saveButton, 0, 1 );
172  buttonsGrid->addColSpacing( 2, 10 );
173  buttonsGrid->addWidget( cancelButton, 0, 3 );
174  buttonsGrid->setColStretch( 4, 1 );
175 
176  //place top level frames in grid
177  mainGrid = new Q3GridLayout( this, 3, 2, 0);
178  mainGrid->addWidget( themeSelectionFrame, 0, 0 );
179  mainGrid->addWidget( themePreviewFrame, 0, 1 );
180  mainGrid->addMultiCellWidget( locationFrame, 1, 1, 0, 1 );
181  mainGrid->addMultiCellWidget( buttonsFrame, 2, 2, 0, 1 );
182 
183  //allow image and description region of select theme to expand to fit window
184  mainGrid->setColStretch( 1, 1 );
185  mainGrid->setRowStretch( 1, 1 );
186  mainGrid->setMargin(WIDGET_SPACING);
187  mainGrid->setSpacing(WIDGET_SPACING);
188 
189  //set window to not be resizeable
190  this->show();
191  setFixedSize(size());
192 }
Q3TextBrowser * themeFeatures
Definition: saveDialog.h:70
Q3Frame * themePreviewFrame
Definition: saveDialog.h:65
QLabel * screenShotLabel
Definition: saveDialog.h:67
void prevScreenShot()
Definition: saveDialog.cpp:236
void save()
Definition: saveDialog.cpp:226
void setPixmap(const QPixmap &p)
Q3Frame * locationFrame
Definition: saveDialog.h:65
void nextScreenShot()
Definition: saveDialog.cpp:246
QPushButton * cancelButton
Definition: saveDialog.h:71
QLabel * locationLabel
Definition: saveDialog.h:67
QString IMAGE_PATH
Definition: config.cpp:18
QLabel * themeScreenShot
Definition: saveDialog.h:67
A clickable label.
Q3Frame * themeSelectionFrame
Definition: saveDialog.h:65
Q3GridLayout * locationGrid
Definition: saveDialog.h:66
Q3Frame * buttonsFrame
Definition: saveDialog.h:65
ClickableLabel * themeScreenPrev
Definition: saveDialog.h:73
Q3GridLayout * themeSelectionGrid
Definition: saveDialog.h:66
void updatePreview()
Definition: saveDialog.cpp:194
Q3GridLayout * buttonsGrid
Definition: saveDialog.h:66
ClickableLabel * browseButton
Definition: saveDialog.h:73
void cancel()
Definition: saveDialog.cpp:231
#define WIDGET_SPACING
Definition: config.h:31
void browse()
Definition: saveDialog.cpp:256
QLabel * themePreviewLabel
Definition: saveDialog.h:67
Q3ListBox * themesList
Definition: saveDialog.h:69
QLabel * themesLabel
Definition: saveDialog.h:67
QPushButton * saveButton
Definition: saveDialog.h:71
Q3GridLayout * mainGrid
Definition: saveDialog.h:66
Q3GridLayout * themePreviewGrid
Definition: saveDialog.h:66
QString THEMES_PATH
Definition: config.cpp:21
QLineEdit * locationVal
Definition: saveDialog.h:68
ClickableLabel * themeScreenNext
Definition: saveDialog.h:73

Member Function Documentation

§ browse

void SaveDialog::browse ( )
privateslot

Definition at line 256 of file saveDialog.cpp.

References locationVal.

Referenced by SaveDialog().

257 {
258  //get directory from user
259  QString dirName = Q3FileDialog::getSaveFileName( locationVal->text(),
260  NULL, this, NULL, QString(tr("Save as")) );
261 
262  if(!dirName.isNull())
263  locationVal->setText( dirName );
264 }
QLineEdit * locationVal
Definition: saveDialog.h:68

§ cancel

void SaveDialog::cancel ( )
privateslot

Definition at line 231 of file saveDialog.cpp.

Referenced by SaveDialog().

232 {
233  reject();
234 }

§ dialogClosed

void SaveDialog::dialogClosed ( )
signal

§ getPath()

QString SaveDialog::getPath ( )

Definition at line 271 of file saveDialog.cpp.

References locationVal.

Referenced by selectThemeAndPath().

272 {
273  return locationVal->text();
274 }
QLineEdit * locationVal
Definition: saveDialog.h:68

§ getTheme()

QString SaveDialog::getTheme ( )

Definition at line 266 of file saveDialog.cpp.

References themesList.

Referenced by selectThemeAndPath().

267 {
268  return themesList->currentText();
269 }
Q3ListBox * themesList
Definition: saveDialog.h:69

§ nextScreenShot

void SaveDialog::nextScreenShot ( )
privateslot

Definition at line 246 of file saveDialog.cpp.

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

Referenced by SaveDialog().

247 {
248  previewNum++;
251 
252  screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
253  themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
254 }
QLabel * screenShotLabel
Definition: saveDialog.h:67
QLabel * themeScreenShot
Definition: saveDialog.h:67
ClickableLabel * themeScreenPrev
Definition: saveDialog.h:73
int numPreviews
Definition: saveDialog.h:76
int previewNum
Definition: saveDialog.h:75
Q3ListBox * themesList
Definition: saveDialog.h:69
void setInvisible(bool val)
QString THEMES_PATH
Definition: config.cpp:21
ClickableLabel * themeScreenNext
Definition: saveDialog.h:73

§ prevScreenShot

void SaveDialog::prevScreenShot ( )
privateslot

Definition at line 236 of file saveDialog.cpp.

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

Referenced by SaveDialog().

237 {
238  previewNum--;
241 
242  screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
243  themeScreenShot->setPixmap( QPixmap( QString(THEMES_PATH + themesList->currentText() + "/preview%1.png").arg(previewNum) ) );
244 }
QLabel * screenShotLabel
Definition: saveDialog.h:67
QLabel * themeScreenShot
Definition: saveDialog.h:67
ClickableLabel * themeScreenPrev
Definition: saveDialog.h:73
int numPreviews
Definition: saveDialog.h:76
int previewNum
Definition: saveDialog.h:75
Q3ListBox * themesList
Definition: saveDialog.h:69
void setInvisible(bool val)
QString THEMES_PATH
Definition: config.cpp:21
ClickableLabel * themeScreenNext
Definition: saveDialog.h:73

§ save

void SaveDialog::save ( )
privateslot

Definition at line 226 of file saveDialog.cpp.

Referenced by SaveDialog().

227 {
228  accept();
229 }

§ selectThemeAndPath()

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

Definition at line 276 of file saveDialog.cpp.

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

Referenced by TitleWidget::saveAsAlbum().

280 {
281  SaveDialog* dlg = new SaveDialog( titleMessage, defaultPath, theme );
282  if( dlg->exec() == QDialog::Accepted )
283  {
284  theme = dlg->getTheme();
285  path = dlg->getPath();
286  delete dlg;
287  return true;
288  }
289  else
290  {
291  delete dlg;
292  return false;
293  }
294 }
Save dialog widget.
Definition: saveDialog.h:36
QString getTheme()
Definition: saveDialog.cpp:266
QString getPath()
Definition: saveDialog.cpp:271
SaveDialog(QString actionMessage, QString defaultPath, QString defaultTheme, QWidget *parent=0, const char *name=0)
Definition: saveDialog.cpp:34

§ themeAvailable()

bool SaveDialog::themeAvailable ( QString  theme)
static

Definition at line 296 of file saveDialog.cpp.

References THEMES_PATH.

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

297 {
298  //walk through the themes directory searching
299  //for a directory with the name of the theme
300  //that also has a theme.xsl file inside it
301  QDir localDir( THEMES_PATH );
302  QStringList list = localDir.entryList( QDir::Dirs );
303  QStringList::Iterator file;
304  for ( file = list.begin(); file != list.end(); ++file )
305  {
306  if(localDir.exists( QString(*file) + "/theme.xsl") &&
307  QString(*file) == theme)
308  return true;
309  }
310  //theme not found
311  return false;
312 }
QString THEMES_PATH
Definition: config.cpp:21

§ updatePreview

void SaveDialog::updatePreview ( )
privateslot

Definition at line 194 of file saveDialog.cpp.

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

Referenced by SaveDialog().

195 {
196  previewNum = 1;
197  int i=1;
198  QDir localDir( THEMES_PATH );
199  while( localDir.exists( QString( themesList->currentText() + "/preview%1.png").arg(i) ) ) { i++; }
200  numPreviews = i-1;
201 
202  //update theme description if provided
203  if(localDir.exists( themesList->currentText() + "/description.html" ))
204  {
205  themeFeatures->setSource( themesList->currentText() + "/description.html" );
206  }
207 
208  //update preview image to provide one or default otherwise
209  if(localDir.exists( themesList->currentText() + "/preview1.png") )
210  {
211  screenShotLabel->setText( QString( tr("Screenshot") ) + QString( " %1/%2").arg(previewNum).arg(numPreviews) );
212  themeScreenShot->setPixmap( QPixmap(THEMES_PATH + themesList->currentText() + "/preview1.png") );
213  themeScreenPrev->setInvisible( true );
215  }
216  else
217  {
218  screenShotLabel->setText( "" );
219  themeScreenShot->setPixmap( QPixmap(QString(IMAGE_PATH)+"miscImages/themePreview.png") );
220  themeScreenPrev->setInvisible( true );
221  themeScreenNext->setInvisible( true );
222  }
223 
224 }
Q3TextBrowser * themeFeatures
Definition: saveDialog.h:70
QLabel * screenShotLabel
Definition: saveDialog.h:67
QString IMAGE_PATH
Definition: config.cpp:18
QLabel * themeScreenShot
Definition: saveDialog.h:67
ClickableLabel * themeScreenPrev
Definition: saveDialog.h:73
int numPreviews
Definition: saveDialog.h:76
int previewNum
Definition: saveDialog.h:75
Q3ListBox * themesList
Definition: saveDialog.h:69
void setInvisible(bool val)
QString THEMES_PATH
Definition: config.cpp:21
ClickableLabel * themeScreenNext
Definition: saveDialog.h:73

Member Data Documentation

§ browseButton

ClickableLabel* SaveDialog::browseButton
private

Definition at line 73 of file saveDialog.h.

Referenced by SaveDialog().

§ buttonsFrame

Q3Frame * SaveDialog::buttonsFrame
private

Definition at line 65 of file saveDialog.h.

Referenced by SaveDialog().

§ buttonsGrid

Q3GridLayout * SaveDialog::buttonsGrid
private

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

§ cancelButton

QPushButton * SaveDialog::cancelButton
private

Definition at line 71 of file saveDialog.h.

Referenced by SaveDialog().

§ locationFrame

Q3Frame* SaveDialog::locationFrame
private

Definition at line 65 of file saveDialog.h.

Referenced by SaveDialog().

§ locationGrid

Q3GridLayout* SaveDialog::locationGrid
private

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

§ locationLabel

QLabel* SaveDialog::locationLabel
private

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

§ locationVal

QLineEdit* SaveDialog::locationVal
private

Definition at line 68 of file saveDialog.h.

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

§ mainGrid

Q3GridLayout * SaveDialog::mainGrid
private

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

§ numPreviews

int SaveDialog::numPreviews
private

Definition at line 76 of file saveDialog.h.

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

§ previewNum

int SaveDialog::previewNum
private

Definition at line 75 of file saveDialog.h.

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

§ saveButton

QPushButton* SaveDialog::saveButton
private

Definition at line 71 of file saveDialog.h.

Referenced by SaveDialog().

§ screenShotLabel

QLabel * SaveDialog::screenShotLabel
private

Definition at line 67 of file saveDialog.h.

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

§ themeFeatures

Q3TextBrowser* SaveDialog::themeFeatures
private

Definition at line 70 of file saveDialog.h.

Referenced by SaveDialog(), and updatePreview().

§ themePreviewFrame

Q3Frame * SaveDialog::themePreviewFrame
private

Definition at line 65 of file saveDialog.h.

Referenced by SaveDialog().

§ themePreviewGrid

Q3GridLayout * SaveDialog::themePreviewGrid
private

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

§ themePreviewLabel

QLabel * SaveDialog::themePreviewLabel
private

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

§ themeScreenNext

ClickableLabel * SaveDialog::themeScreenNext
private

Definition at line 73 of file saveDialog.h.

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

§ themeScreenPrev

ClickableLabel * SaveDialog::themeScreenPrev
private

Definition at line 73 of file saveDialog.h.

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

§ themeScreenShot

QLabel * SaveDialog::themeScreenShot
private

Definition at line 67 of file saveDialog.h.

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

§ themeSelectionFrame

Q3Frame * SaveDialog::themeSelectionFrame
private

Definition at line 65 of file saveDialog.h.

Referenced by SaveDialog().

§ themeSelectionGrid

Q3GridLayout * SaveDialog::themeSelectionGrid
private

Definition at line 66 of file saveDialog.h.

Referenced by SaveDialog().

§ themesLabel

QLabel * SaveDialog::themesLabel
private

Definition at line 67 of file saveDialog.h.

Referenced by SaveDialog().

§ themesList

Q3ListBox* SaveDialog::themesList
private

Definition at line 69 of file saveDialog.h.

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


The documentation for this class was generated from the following files: