#include <mosaicOptionsDialog.h>
Inheritance diagram for MosaicOptionsDialog:


Definition at line 32 of file mosaicOptionsDialog.h.
Public Member Functions | |
| MosaicOptionsDialog (QWidget *parent=0) | |
| Constructs layout. | |
| MosaicOptions * | getOptions () |
| returns a populate options object | |
Private Slots | |
| void | updateTileSizePreview () |
| void | updateImagesFromOptions () |
| void | browse () |
Private Member Functions | |
| QSize | determineTileSize () |
| QStringList | determineFilesList () |
| void | appendImagesInPath (QStringList &files, QString path, int depth) |
Private Attributes | |
| QLabel * | tileSizePreview |
| QComboBox * | tileSizes |
| QSpinBox * | tileWidth |
| QLabel * | tileSizeX |
| QSpinBox * | tileHeight |
| QRadioButton * | tileType_albumPhotos |
| QRadioButton * | tileType_solidColors |
| QRadioButton * | tileType_imagesFrom |
| QLineEdit * | locationVal |
| ClickableLabel * | browseButton |
|
|
Constructs layout.
Definition at line 45 of file mosaicOptionsDialog.cpp. References browse(), browseButton, Configuration::getString(), IMAGE_PATH, locationVal, Configuration::resetSetting(), ClickableLabel::setPixmap(), tileHeight, tileSizePreview, tileSizes, tileSizeX, tileType_albumPhotos, tileType_imagesFrom, tileType_solidColors, tileWidth, updateImagesFromOptions(), updateTileSizePreview(), and WIDGET_SPACING. 00045 : QDialog(parent,NULL,true) 00046 { 00047 //-------------- 00048 //Tile size options: 00049 QFrame* tileSizeOptions = new QFrame(this); 00050 00051 QLabel* tileSizeLabel = new QLabel( tr("Tile size:"), this ); 00052 tileSizes = new QComboBox( tileSizeOptions ); 00053 tileSizes->insertItem( tr("Tiny") ); 00054 tileSizes->insertItem( tr("Small") ); 00055 tileSizes->insertItem( tr("Medium") ); 00056 tileSizes->insertItem( tr("Large") ); 00057 tileSizes->insertItem( tr("Huge") ); 00058 tileSizes->insertItem( tr("Custom") ); 00059 00060 tileSizePreview = new QLabel( "(? x ?)", tileSizeOptions ); 00061 tileWidth = new QSpinBox( 1, 500, 1, tileSizeOptions ); 00062 tileSizeX = new QLabel( "x", tileSizeOptions ); 00063 tileHeight = new QSpinBox( 1, 500, 1, tileSizeOptions ); 00064 00065 //set defaults 00066 tileWidth->setValue( 40 ); 00067 tileHeight->setValue( 40 ); 00068 00069 //default to small 00070 tileSizes->setCurrentItem( 1 ); 00071 updateTileSizePreview(); 00072 00073 //update custom controls when selection changes in the future 00074 connect( tileSizes, SIGNAL(activated(int)), this, SLOT(updateTileSizePreview()) ); 00075 00076 QGridLayout* tileSizeGrid = new QGridLayout( tileSizeOptions, 1, 6, 0 ); 00077 tileSizeGrid->addWidget( tileSizes, 1, 0 ); 00078 tileSizeGrid->addWidget( tileSizePreview, 1, 1 ); 00079 tileSizeGrid->addWidget( tileWidth, 1, 2 ); 00080 tileSizeGrid->addWidget( tileSizeX, 1, 3 ); 00081 tileSizeGrid->addWidget( tileHeight, 1, 4 ); 00082 tileSizeGrid->setColStretch( 5, 1 ); 00083 tileSizeGrid->setSpacing( WIDGET_SPACING ); 00084 //-------------- 00085 //Tile type options: 00086 QFrame* tileTypeOptions = new QFrame(this); 00087 00088 QLabel* tileTypeLabel = new QLabel( tr("Base tiles on:"), this ); 00089 //------------------------------ 00090 tileType_albumPhotos = new QRadioButton( tr("Album photos"), tileTypeOptions ); 00091 tileType_albumPhotos->setChecked(true); 00092 //------------------------------ 00093 tileType_solidColors = new QRadioButton( tr("Solid colors"), tileTypeOptions ); 00094 //------------------------------ 00095 tileType_imagesFrom = new QRadioButton( tr("Images from:"), tileTypeOptions ); 00096 00097 locationVal = new QLineEdit( tileTypeOptions ); 00098 00099 Configuration* config = ((Window*)qApp->mainWidget())->getConfig(); 00100 QString path = config->getString( "loadSave", "addPhotoDir" ); 00101 QDir testPath(path); 00102 if(!testPath.exists()) 00103 { 00104 config->resetSetting( "loadSave", "addPhotoDir" ); 00105 path = config->getString( "loadSave", "addPhotoDir" ); 00106 } 00107 locationVal->setText( path ); 00108 locationVal->setCursorPosition(0); 00109 00110 browseButton = new ClickableLabel( tileTypeOptions ); 00111 browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") ); 00112 connect( browseButton, SIGNAL(clicked()), SLOT(browse()) ); 00113 00114 //in the future enable/disable the images from line edit and browse button when 00115 //the thrid option is selected/unselected. also force this to take place now as well 00116 connect( tileType_imagesFrom, SIGNAL(stateChanged(int)), 00117 this, SLOT(updateImagesFromOptions()) ); 00118 updateImagesFromOptions(); 00119 //------------------------------ 00120 00121 QButtonGroup* typeGroup = new QButtonGroup( tileTypeOptions ); 00122 typeGroup->hide(); 00123 typeGroup->insert( tileType_albumPhotos ); 00124 typeGroup->insert( tileType_solidColors ); 00125 typeGroup->insert( tileType_imagesFrom ); 00126 00127 QGridLayout* tileTypeGrid = new QGridLayout( tileTypeOptions, 3, 3, 0 ); 00128 tileTypeGrid->addMultiCellWidget( tileType_albumPhotos, 0,0, 0,2 ); 00129 tileTypeGrid->addMultiCellWidget( tileType_solidColors, 1,1, 0,2 ); 00130 tileTypeGrid->addWidget( tileType_imagesFrom, 2,0 ); 00131 tileTypeGrid->addWidget( locationVal, 2,1 ); 00132 tileTypeGrid->addWidget( browseButton, 2,2 ); 00133 00134 tileTypeGrid->setColSpacing(1, 300); 00135 tileTypeGrid->setColStretch(1, 1); 00136 tileTypeGrid->setSpacing( WIDGET_SPACING ); 00137 //-------------- 00138 //Dialog buttons: 00139 QFrame* buttonsFrame = new QFrame( this, "dialogButtons" ); 00140 00141 QPushButton* applyButton = new QPushButton( tr("Apply"), buttonsFrame ); 00142 applyButton->setDefault(true); 00143 applyButton->setFocus(); 00144 connect( applyButton, SIGNAL(clicked()), SLOT(accept()) ); 00145 00146 QPushButton* cancelButton = new QPushButton( tr("Cancel"), buttonsFrame ); 00147 connect( cancelButton, SIGNAL(clicked()), SLOT(reject()) ); 00148 00149 QGridLayout* buttonsGrid = new QGridLayout( buttonsFrame, 1, 2, 0 ); 00150 buttonsGrid->addWidget( applyButton, 0, 0 ); 00151 buttonsGrid->addWidget( cancelButton, 0, 1 ); 00152 buttonsGrid->setSpacing( WIDGET_SPACING ); 00153 //-------------- 00154 //Top level grid 00155 QGridLayout* mainGrid = new QGridLayout( this, 5, 2, 0 ); 00156 00157 mainGrid->setRowStretch( 0, 1 ); 00158 mainGrid->addWidget( tileSizeLabel, 1,0, Qt::AlignRight | Qt::AlignVCenter ); 00159 mainGrid->addWidget( tileSizeOptions, 1,1 ); 00160 mainGrid->addWidget( tileTypeLabel, 2,0, Qt::AlignRight | Qt::AlignVCenter ); 00161 mainGrid->addWidget( tileTypeOptions, 2,1 ); 00162 mainGrid->setRowStretch( 3, 1 ); 00163 mainGrid->addMultiCellWidget( buttonsFrame, 4,4, 0,1, Qt::AlignHCenter ); 00164 mainGrid->setSpacing( WIDGET_SPACING ); 00165 mainGrid->setMargin( WIDGET_SPACING ); 00166 //-------------- 00167 //Window caption 00168 setCaption( tr("Mosaic Options") ); 00169 //------------------------------- 00170 //set window to not be resizeable 00171 this->show(); 00172 // setFixedSize(size()); 00173 //------------------------------- 00174 }
|
|
||||||||||||||||
|
Definition at line 219 of file mosaicOptionsDialog.cpp. References getImageSize(), and MAX_DEPTH. Referenced by determineFilesList(). 00220 {
00221 // cout << "appending files in " << path << "\n";
00222 QDir tmpDir;
00223 tmpDir.setPath( path );
00224
00225 //add all iamges
00226 tmpDir.setFilter( QDir::Files | QDir::Readable );
00227 tmpDir.setNameFilter( "*.gif;*.jpg;*.jpeg;*.png;*.xpm;*.GIF;*.JPG;*.JPEG;*.PNG;*.XPM" );
00228 QStringList images = tmpDir.entryList();
00229 QStringList::iterator it;
00230 QSize imageRes;
00231 for(it = images.begin(); it != images.end(); it++ )
00232 {
00233 //check we can get a decent resolution out of the file
00234 getImageSize( tmpDir.absFilePath( *it ), imageRes );
00235 if( imageRes.width() <= 0 || imageRes.height() <= 0 ) continue;
00236
00237 // cout << "appending " << *it << "\n";
00238 files.append( tmpDir.absFilePath( *it ) );
00239
00240 //break out if we have too many files
00241 if( files.count() >= MAX_FILES ) break;
00242 }
00243
00244 //recurse on all directories (but not symbolic links) - but only go down three levels
00245 if( depth < MAX_DEPTH && files.count() < MAX_FILES )
00246 {
00247 tmpDir.setFilter( QDir::Dirs | QDir::Readable | QDir::NoSymLinks );
00248 tmpDir.setNameFilter( "*" );
00249 QStringList directores = tmpDir.entryList();
00250 for(it = directores.begin(); it != directores.end(); it++ )
00251 {
00252 QString dir = *it;
00253 if( dir.compare( "." ) == 0 || dir.compare( ".." ) == 0 ) continue;
00254
00255 appendImagesInPath( files, tmpDir.absFilePath( *it ), depth+1 );
00256 }
00257 }
00258 }
|
|
|
Definition at line 289 of file mosaicOptionsDialog.cpp. References locationVal. Referenced by MosaicOptionsDialog(). 00290 {
00291 //get directory from user
00292 QString dirName = QFileDialog::getExistingDirectory( locationVal->text(), this, NULL, tr("Images directory") );
00293
00294 if(!dirName.isNull())
00295 locationVal->setText( dirName );
00296 }
|
|
|
Definition at line 198 of file mosaicOptionsDialog.cpp. References appendImagesInPath(), Album::getThumbnailFilenames(), locationVal, tileType_albumPhotos, and tileType_solidColors. Referenced by getOptions(). 00199 {
00200 //Album photos
00201 if( tileType_albumPhotos->isChecked() )
00202 {
00203 Album* albm = ((Window*)qApp->mainWidget())->getTitle()->getAlbum();
00204 return albm->getThumbnailFilenames();
00205 }
00206
00207 //Solid colors - return empty list
00208 else if ( tileType_solidColors->isChecked() ) { return QStringList(); }
00209 //Images from...
00210 else
00211 {
00212 QStringList files;
00213 QString path = locationVal->text();
00214 appendImagesInPath( files, path, 0 );
00215 return files;
00216 }
00217 }
|
|
|
Definition at line 188 of file mosaicOptionsDialog.cpp. References tileHeight, tileSizes, and tileWidth. Referenced by getOptions(), and updateTileSizePreview(). 00189 {
00190 if( tileSizes->currentItem() == 0 ) return QSize( 20, 20 );
00191 else if( tileSizes->currentItem() == 1 ) return QSize( 40, 40 );
00192 else if( tileSizes->currentItem() == 2 ) return QSize( 65, 65 );
00193 else if( tileSizes->currentItem() == 3 ) return QSize( 100, 100 );
00194 else if( tileSizes->currentItem() == 4 ) return QSize( 150, 150 );
00195 else return QSize( tileWidth->value(), tileHeight->value() );
00196 }
|
|
|
returns a populate options object
Definition at line 176 of file mosaicOptionsDialog.cpp. References determineFilesList(), and determineTileSize(). Referenced by EditingInterface::applyEffect(). 00177 {
00178 //construct a list of files based on the user selection
00179 QStringList files = determineFilesList();
00180
00181 //get selected tile size
00182 QSize tileSize = determineTileSize();
00183
00184 //return a populated mosaic options object
00185 return new MosaicOptions( files, tileSize, ((Window*)qApp->mainWidget())->getStatus() );
00186 }
|
|
|
Definition at line 282 of file mosaicOptionsDialog.cpp. References browseButton, locationVal, ClickableLabel::setEnabled(), and tileType_imagesFrom. Referenced by MosaicOptionsDialog(). 00283 {
00284 bool enabled = tileType_imagesFrom->isChecked();
00285 locationVal->setEnabled( enabled );
00286 browseButton->setEnabled( enabled );
00287 }
|
|
|
Definition at line 260 of file mosaicOptionsDialog.cpp. References determineTileSize(), tileHeight, tileSizePreview, tileSizes, tileSizeX, and tileWidth. Referenced by MosaicOptionsDialog(). 00261 {
00262 //get selected tile size
00263 QSize tileSize = determineTileSize();
00264
00265 //show/hide custom controls
00266 bool customSelected = tileSizes->currentItem() == tileSizes->count()-1;
00267
00268 tileSizePreview->setShown( !customSelected );
00269 tileWidth->setShown ( customSelected );
00270 tileSizeX->setShown ( customSelected );
00271 tileHeight->setShown( customSelected );
00272
00273 //update tile size preview text
00274 if( !customSelected )
00275 {
00276 tileSizePreview->setText( QString("(%1 x %2)").arg( tileSize.width() ).arg( tileSize.height() ) );
00277 }
00278
00279 //update preview image
00280 }
|
|
|
Definition at line 58 of file mosaicOptionsDialog.h. Referenced by MosaicOptionsDialog(), and updateImagesFromOptions(). |
|
|
Definition at line 57 of file mosaicOptionsDialog.h. Referenced by browse(), determineFilesList(), MosaicOptionsDialog(), and updateImagesFromOptions(). |
|
|
Definition at line 52 of file mosaicOptionsDialog.h. Referenced by determineTileSize(), MosaicOptionsDialog(), and updateTileSizePreview(). |
|
|
Definition at line 48 of file mosaicOptionsDialog.h. Referenced by MosaicOptionsDialog(), and updateTileSizePreview(). |
|
|
Definition at line 49 of file mosaicOptionsDialog.h. Referenced by determineTileSize(), MosaicOptionsDialog(), and updateTileSizePreview(). |
|
|
Definition at line 51 of file mosaicOptionsDialog.h. Referenced by MosaicOptionsDialog(), and updateTileSizePreview(). |
|
|
Definition at line 54 of file mosaicOptionsDialog.h. Referenced by determineFilesList(), and MosaicOptionsDialog(). |
|
|
Definition at line 56 of file mosaicOptionsDialog.h. Referenced by MosaicOptionsDialog(), and updateImagesFromOptions(). |
|
|
Definition at line 55 of file mosaicOptionsDialog.h. Referenced by determineFilesList(), and MosaicOptionsDialog(). |
|
|
Definition at line 50 of file mosaicOptionsDialog.h. Referenced by determineTileSize(), MosaicOptionsDialog(), and updateTileSizePreview(). |
1.3.9.1