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