AlbumShaper
1.0a3
|
Interface for choosing mosiac effect options. More...
#include <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 |
Interface for choosing mosiac effect options.
Definition at line 32 of file mosaicOptionsDialog.h.
MosaicOptionsDialog::MosaicOptionsDialog | ( | QWidget * | parent = 0 | ) |
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.
: QDialog(parent,NULL,true) { //-------------- //Tile size options: QFrame* tileSizeOptions = new QFrame(this); QLabel* tileSizeLabel = new QLabel( tr("Tile size:"), this ); tileSizes = new QComboBox( tileSizeOptions ); tileSizes->insertItem( tr("Tiny") ); tileSizes->insertItem( tr("Small") ); tileSizes->insertItem( tr("Medium") ); tileSizes->insertItem( tr("Large") ); tileSizes->insertItem( tr("Huge") ); tileSizes->insertItem( tr("Custom") ); tileSizePreview = new QLabel( "(? x ?)", tileSizeOptions ); tileWidth = new QSpinBox( 1, 500, 1, tileSizeOptions ); tileSizeX = new QLabel( "x", tileSizeOptions ); tileHeight = new QSpinBox( 1, 500, 1, tileSizeOptions ); //set defaults tileWidth->setValue( 40 ); tileHeight->setValue( 40 ); //default to small tileSizes->setCurrentItem( 1 ); updateTileSizePreview(); //update custom controls when selection changes in the future connect( tileSizes, SIGNAL(activated(int)), this, SLOT(updateTileSizePreview()) ); QGridLayout* tileSizeGrid = new QGridLayout( tileSizeOptions, 1, 6, 0 ); tileSizeGrid->addWidget( tileSizes, 1, 0 ); tileSizeGrid->addWidget( tileSizePreview, 1, 1 ); tileSizeGrid->addWidget( tileWidth, 1, 2 ); tileSizeGrid->addWidget( tileSizeX, 1, 3 ); tileSizeGrid->addWidget( tileHeight, 1, 4 ); tileSizeGrid->setColStretch( 5, 1 ); tileSizeGrid->setSpacing( WIDGET_SPACING ); //-------------- //Tile type options: QFrame* tileTypeOptions = new QFrame(this); QLabel* tileTypeLabel = new QLabel( tr("Base tiles on:"), this ); //------------------------------ tileType_albumPhotos = new QRadioButton( tr("Album photos"), tileTypeOptions ); tileType_albumPhotos->setChecked(true); //------------------------------ tileType_solidColors = new QRadioButton( tr("Solid colors"), tileTypeOptions ); //------------------------------ tileType_imagesFrom = new QRadioButton( tr("Images from:"), tileTypeOptions ); locationVal = new QLineEdit( tileTypeOptions ); Configuration* config = ((Window*)qApp->mainWidget())->getConfig(); QString path = config->getString( "loadSave", "addPhotoDir" ); QDir testPath(path); if(!testPath.exists()) { config->resetSetting( "loadSave", "addPhotoDir" ); path = config->getString( "loadSave", "addPhotoDir" ); } locationVal->setText( path ); locationVal->setCursorPosition(0); browseButton = new ClickableLabel( tileTypeOptions ); browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") ); connect( browseButton, SIGNAL(clicked()), SLOT(browse()) ); //in the future enable/disable the images from line edit and browse button when //the thrid option is selected/unselected. also force this to take place now as well connect( tileType_imagesFrom, SIGNAL(stateChanged(int)), this, SLOT(updateImagesFromOptions()) ); updateImagesFromOptions(); //------------------------------ QButtonGroup* typeGroup = new QButtonGroup( tileTypeOptions ); typeGroup->hide(); typeGroup->insert( tileType_albumPhotos ); typeGroup->insert( tileType_solidColors ); typeGroup->insert( tileType_imagesFrom ); QGridLayout* tileTypeGrid = new QGridLayout( tileTypeOptions, 3, 3, 0 ); tileTypeGrid->addMultiCellWidget( tileType_albumPhotos, 0,0, 0,2 ); tileTypeGrid->addMultiCellWidget( tileType_solidColors, 1,1, 0,2 ); tileTypeGrid->addWidget( tileType_imagesFrom, 2,0 ); tileTypeGrid->addWidget( locationVal, 2,1 ); tileTypeGrid->addWidget( browseButton, 2,2 ); tileTypeGrid->setColSpacing(1, 300); tileTypeGrid->setColStretch(1, 1); tileTypeGrid->setSpacing( WIDGET_SPACING ); //-------------- //Dialog buttons: QFrame* buttonsFrame = new QFrame( this, "dialogButtons" ); QPushButton* applyButton = new QPushButton( tr("Apply"), buttonsFrame ); applyButton->setDefault(true); applyButton->setFocus(); connect( applyButton, SIGNAL(clicked()), SLOT(accept()) ); QPushButton* cancelButton = new QPushButton( tr("Cancel"), buttonsFrame ); connect( cancelButton, SIGNAL(clicked()), SLOT(reject()) ); QGridLayout* buttonsGrid = new QGridLayout( buttonsFrame, 1, 2, 0 ); buttonsGrid->addWidget( applyButton, 0, 0 ); buttonsGrid->addWidget( cancelButton, 0, 1 ); buttonsGrid->setSpacing( WIDGET_SPACING ); //-------------- //Top level grid QGridLayout* mainGrid = new QGridLayout( this, 5, 2, 0 ); mainGrid->setRowStretch( 0, 1 ); mainGrid->addWidget( tileSizeLabel, 1,0, Qt::AlignRight | Qt::AlignVCenter ); mainGrid->addWidget( tileSizeOptions, 1,1 ); mainGrid->addWidget( tileTypeLabel, 2,0, Qt::AlignRight | Qt::AlignVCenter ); mainGrid->addWidget( tileTypeOptions, 2,1 ); mainGrid->setRowStretch( 3, 1 ); mainGrid->addMultiCellWidget( buttonsFrame, 4,4, 0,1, Qt::AlignHCenter ); mainGrid->setSpacing( WIDGET_SPACING ); mainGrid->setMargin( WIDGET_SPACING ); //-------------- //Window caption setCaption( tr("Mosaic Options") ); //------------------------------- //set window to not be resizeable this->show(); // setFixedSize(size()); //------------------------------- }
void MosaicOptionsDialog::appendImagesInPath | ( | QStringList & | files, |
QString | path, | ||
int | depth | ||
) | [private] |
Definition at line 219 of file mosaicOptionsDialog.cpp.
References getImageSize(), MAX_DEPTH, and MAX_FILES.
Referenced by determineFilesList().
{ // cout << "appending files in " << path << "\n"; QDir tmpDir; tmpDir.setPath( path ); //add all iamges tmpDir.setFilter( QDir::Files | QDir::Readable ); tmpDir.setNameFilter( "*.gif;*.jpg;*.jpeg;*.png;*.xpm;*.GIF;*.JPG;*.JPEG;*.PNG;*.XPM" ); QStringList images = tmpDir.entryList(); QStringList::iterator it; QSize imageRes; for(it = images.begin(); it != images.end(); it++ ) { //check we can get a decent resolution out of the file getImageSize( tmpDir.absFilePath( *it ), imageRes ); if( imageRes.width() <= 0 || imageRes.height() <= 0 ) continue; // cout << "appending " << *it << "\n"; files.append( tmpDir.absFilePath( *it ) ); //break out if we have too many files if( files.count() >= MAX_FILES ) break; } //recurse on all directories (but not symbolic links) - but only go down three levels if( depth < MAX_DEPTH && files.count() < MAX_FILES ) { tmpDir.setFilter( QDir::Dirs | QDir::Readable | QDir::NoSymLinks ); tmpDir.setNameFilter( "*" ); QStringList directores = tmpDir.entryList(); for(it = directores.begin(); it != directores.end(); it++ ) { QString dir = *it; if( dir.compare( "." ) == 0 || dir.compare( ".." ) == 0 ) continue; appendImagesInPath( files, tmpDir.absFilePath( *it ), depth+1 ); } } }
void MosaicOptionsDialog::browse | ( | ) | [private, slot] |
Definition at line 289 of file mosaicOptionsDialog.cpp.
References locationVal.
Referenced by MosaicOptionsDialog().
{ //get directory from user QString dirName = QFileDialog::getExistingDirectory( locationVal->text(), this, NULL, tr("Images directory") ); if(!dirName.isNull()) locationVal->setText( dirName ); }
QStringList MosaicOptionsDialog::determineFilesList | ( | ) | [private] |
Definition at line 198 of file mosaicOptionsDialog.cpp.
References appendImagesInPath(), Album::getThumbnailFilenames(), locationVal, tileType_albumPhotos, and tileType_solidColors.
Referenced by getOptions().
{ //Album photos if( tileType_albumPhotos->isChecked() ) { Album* albm = ((Window*)qApp->mainWidget())->getTitle()->getAlbum(); return albm->getThumbnailFilenames(); } //Solid colors - return empty list else if ( tileType_solidColors->isChecked() ) { return QStringList(); } //Images from... else { QStringList files; QString path = locationVal->text(); appendImagesInPath( files, path, 0 ); return files; } }
QSize MosaicOptionsDialog::determineTileSize | ( | ) | [private] |
Definition at line 188 of file mosaicOptionsDialog.cpp.
References tileHeight, tileSizes, and tileWidth.
Referenced by getOptions(), and updateTileSizePreview().
{ if( tileSizes->currentItem() == 0 ) return QSize( 20, 20 ); else if( tileSizes->currentItem() == 1 ) return QSize( 40, 40 ); else if( tileSizes->currentItem() == 2 ) return QSize( 65, 65 ); else if( tileSizes->currentItem() == 3 ) return QSize( 100, 100 ); else if( tileSizes->currentItem() == 4 ) return QSize( 150, 150 ); else return QSize( tileWidth->value(), tileHeight->value() ); }
MosaicOptions * MosaicOptionsDialog::getOptions | ( | ) |
returns a populate options object
Definition at line 176 of file mosaicOptionsDialog.cpp.
References determineFilesList(), and determineTileSize().
Referenced by EditingInterface::applyEffect().
{ //construct a list of files based on the user selection QStringList files = determineFilesList(); //get selected tile size QSize tileSize = determineTileSize(); //return a populated mosaic options object return new MosaicOptions( files, tileSize, ((Window*)qApp->mainWidget())->getStatus() ); }
void MosaicOptionsDialog::updateImagesFromOptions | ( | ) | [private, slot] |
Definition at line 282 of file mosaicOptionsDialog.cpp.
References browseButton, locationVal, ClickableLabel::setEnabled(), and tileType_imagesFrom.
Referenced by MosaicOptionsDialog().
{ bool enabled = tileType_imagesFrom->isChecked(); locationVal->setEnabled( enabled ); browseButton->setEnabled( enabled ); }
void MosaicOptionsDialog::updateTileSizePreview | ( | ) | [private, slot] |
Definition at line 260 of file mosaicOptionsDialog.cpp.
References determineTileSize(), tileHeight, tileSizePreview, tileSizes, tileSizeX, and tileWidth.
Referenced by MosaicOptionsDialog().
{ //get selected tile size QSize tileSize = determineTileSize(); //show/hide custom controls bool customSelected = tileSizes->currentItem() == tileSizes->count()-1; tileSizePreview->setShown( !customSelected ); tileWidth->setShown ( customSelected ); tileSizeX->setShown ( customSelected ); tileHeight->setShown( customSelected ); //update tile size preview text if( !customSelected ) { tileSizePreview->setText( QString("(%1 x %2)").arg( tileSize.width() ).arg( tileSize.height() ) ); } //update preview image }
ClickableLabel* MosaicOptionsDialog::browseButton [private] |
Definition at line 58 of file mosaicOptionsDialog.h.
Referenced by MosaicOptionsDialog(), and updateImagesFromOptions().
QLineEdit* MosaicOptionsDialog::locationVal [private] |
Definition at line 57 of file mosaicOptionsDialog.h.
Referenced by browse(), determineFilesList(), MosaicOptionsDialog(), and updateImagesFromOptions().
QSpinBox* MosaicOptionsDialog::tileHeight [private] |
Definition at line 52 of file mosaicOptionsDialog.h.
Referenced by determineTileSize(), MosaicOptionsDialog(), and updateTileSizePreview().
QLabel* MosaicOptionsDialog::tileSizePreview [private] |
Definition at line 48 of file mosaicOptionsDialog.h.
Referenced by MosaicOptionsDialog(), and updateTileSizePreview().
QComboBox* MosaicOptionsDialog::tileSizes [private] |
Definition at line 49 of file mosaicOptionsDialog.h.
Referenced by determineTileSize(), MosaicOptionsDialog(), and updateTileSizePreview().
QLabel* MosaicOptionsDialog::tileSizeX [private] |
Definition at line 51 of file mosaicOptionsDialog.h.
Referenced by MosaicOptionsDialog(), and updateTileSizePreview().
QRadioButton* MosaicOptionsDialog::tileType_albumPhotos [private] |
Definition at line 54 of file mosaicOptionsDialog.h.
Referenced by determineFilesList(), and MosaicOptionsDialog().
QRadioButton* MosaicOptionsDialog::tileType_imagesFrom [private] |
Definition at line 56 of file mosaicOptionsDialog.h.
Referenced by MosaicOptionsDialog(), and updateImagesFromOptions().
QRadioButton* MosaicOptionsDialog::tileType_solidColors [private] |
Definition at line 55 of file mosaicOptionsDialog.h.
Referenced by determineFilesList(), and MosaicOptionsDialog().
QSpinBox* MosaicOptionsDialog::tileWidth [private] |
Definition at line 50 of file mosaicOptionsDialog.h.
Referenced by determineTileSize(), MosaicOptionsDialog(), and updateTileSizePreview().