AlbumShaper 1.0a3
MosaicOptionsDialog Class Reference

Interface for choosing mosiac effect options. More...

#include <mosaicOptionsDialog.h>

Inheritance diagram for MosaicOptionsDialog:
Collaboration diagram for MosaicOptionsDialog:

Public Member Functions

 MosaicOptionsDialog (QWidget *parent=0)
 Constructs layout.
 
MosaicOptionsgetOptions ()
 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

QLabeltileSizePreview
 
QComboBox * tileSizes
 
QSpinBox * tileWidth
 
QLabeltileSizeX
 
QSpinBox * tileHeight
 
QRadioButton * tileType_albumPhotos
 
QRadioButton * tileType_solidColors
 
QRadioButton * tileType_imagesFrom
 
QLineEdit * locationVal
 
ClickableLabelbrowseButton
 

Detailed Description

Interface for choosing mosiac effect options.

Definition at line 34 of file mosaicOptionsDialog.h.

Constructor & Destructor Documentation

◆ MosaicOptionsDialog()

MosaicOptionsDialog::MosaicOptionsDialog ( QWidget * parent = 0)

Constructs layout.

Definition at line 48 of file mosaicOptionsDialog.cpp.

48 : QDialog(parent,NULL,true)
49{
50 //--------------
51 //Tile size options:
52 Q3Frame* tileSizeOptions = new Q3Frame(this);
53
54 QLabel* tileSizeLabel = new QLabel( tr("Tile size:"), this );
55 tileSizes = new QComboBox( tileSizeOptions );
56 tileSizes->insertItem( tr("Tiny") );
57 tileSizes->insertItem( tr("Small") );
58 tileSizes->insertItem( tr("Medium") );
59 tileSizes->insertItem( tr("Large") );
60 tileSizes->insertItem( tr("Huge") );
61 tileSizes->insertItem( tr("Custom") );
62
63 tileSizePreview = new QLabel( "(? x ?)", tileSizeOptions );
64 tileWidth = new QSpinBox( 1, 500, 1, tileSizeOptions );
65 tileSizeX = new QLabel( "x", tileSizeOptions );
66 tileHeight = new QSpinBox( 1, 500, 1, tileSizeOptions );
67
68 //set defaults
69 tileWidth->setValue( 40 );
70 tileHeight->setValue( 40 );
71
72 //default to small
73 tileSizes->setCurrentItem( 1 );
75
76 //update custom controls when selection changes in the future
77 connect( tileSizes, SIGNAL(activated(int)), this, SLOT(updateTileSizePreview()) );
78
79 Q3GridLayout* tileSizeGrid = new Q3GridLayout( tileSizeOptions, 1, 6, 0 );
80 tileSizeGrid->addWidget( tileSizes, 1, 0 );
81 tileSizeGrid->addWidget( tileSizePreview, 1, 1 );
82 tileSizeGrid->addWidget( tileWidth, 1, 2 );
83 tileSizeGrid->addWidget( tileSizeX, 1, 3 );
84 tileSizeGrid->addWidget( tileHeight, 1, 4 );
85 tileSizeGrid->setColStretch( 5, 1 );
86 tileSizeGrid->setSpacing( WIDGET_SPACING );
87 //--------------
88 //Tile type options:
89 Q3Frame* tileTypeOptions = new Q3Frame(this);
90
91 QLabel* tileTypeLabel = new QLabel( tr("Base tiles on:"), this );
92 //------------------------------
93 tileType_albumPhotos = new QRadioButton( tr("Album photos"), tileTypeOptions );
94 tileType_albumPhotos->setChecked(true);
95 //------------------------------
96 tileType_solidColors = new QRadioButton( tr("Solid colors"), tileTypeOptions );
97 //------------------------------
98 tileType_imagesFrom = new QRadioButton( tr("Images from:"), tileTypeOptions );
99
100 locationVal = new QLineEdit( tileTypeOptions );
101
102 Configuration* config = ((Window*)qApp->mainWidget())->getConfig();
103 QString path = config->getString( "loadSave", "addPhotoDir" );
104 QDir testPath(path);
105 if(!testPath.exists())
106 {
107 config->resetSetting( "loadSave", "addPhotoDir" );
108 path = config->getString( "loadSave", "addPhotoDir" );
109 }
110 locationVal->setText( path );
111 locationVal->setCursorPosition(0);
112
113 browseButton = new ClickableLabel( tileTypeOptions );
114 browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") );
115 connect( browseButton, SIGNAL(clicked()), SLOT(browse()) );
116
117 //in the future enable/disable the images from line edit and browse button when
118 //the thrid option is selected/unselected. also force this to take place now as well
119 connect( tileType_imagesFrom, SIGNAL(stateChanged(int)),
120 this, SLOT(updateImagesFromOptions()) );
122 //------------------------------
123
124 Q3ButtonGroup* typeGroup = new Q3ButtonGroup( tileTypeOptions );
125 typeGroup->hide();
126 typeGroup->insert( tileType_albumPhotos );
127 typeGroup->insert( tileType_solidColors );
128 typeGroup->insert( tileType_imagesFrom );
129
130 Q3GridLayout* tileTypeGrid = new Q3GridLayout( tileTypeOptions, 3, 3, 0 );
131 tileTypeGrid->addMultiCellWidget( tileType_albumPhotos, 0,0, 0,2 );
132 tileTypeGrid->addMultiCellWidget( tileType_solidColors, 1,1, 0,2 );
133 tileTypeGrid->addWidget( tileType_imagesFrom, 2,0 );
134 tileTypeGrid->addWidget( locationVal, 2,1 );
135 tileTypeGrid->addWidget( browseButton, 2,2 );
136
137 tileTypeGrid->setColSpacing(1, 300);
138 tileTypeGrid->setColStretch(1, 1);
139 tileTypeGrid->setSpacing( WIDGET_SPACING );
140 //--------------
141 //Dialog buttons:
142 Q3Frame* buttonsFrame = new Q3Frame( this, "dialogButtons" );
143
144 QPushButton* applyButton = new QPushButton( tr("Apply"), buttonsFrame );
145 applyButton->setDefault(true);
146 applyButton->setFocus();
147 connect( applyButton, SIGNAL(clicked()), SLOT(accept()) );
148
149 QPushButton* cancelButton = new QPushButton( tr("Cancel"), buttonsFrame );
150 connect( cancelButton, SIGNAL(clicked()), SLOT(reject()) );
151
152 Q3GridLayout* buttonsGrid = new Q3GridLayout( buttonsFrame, 1, 2, 0 );
153 buttonsGrid->addWidget( applyButton, 0, 0 );
154 buttonsGrid->addWidget( cancelButton, 0, 1 );
155 buttonsGrid->setSpacing( WIDGET_SPACING );
156 //--------------
157 //Top level grid
158 Q3GridLayout* mainGrid = new Q3GridLayout( this, 5, 2, 0 );
159
160 mainGrid->setRowStretch( 0, 1 );
161 mainGrid->addWidget( tileSizeLabel, 1,0, Qt::AlignRight | Qt::AlignVCenter );
162 mainGrid->addWidget( tileSizeOptions, 1,1 );
163 mainGrid->addWidget( tileTypeLabel, 2,0, Qt::AlignRight | Qt::AlignVCenter );
164 mainGrid->addWidget( tileTypeOptions, 2,1 );
165 mainGrid->setRowStretch( 3, 1 );
166 mainGrid->addMultiCellWidget( buttonsFrame, 4,4, 0,1, Qt::AlignHCenter );
167 mainGrid->setSpacing( WIDGET_SPACING );
168 mainGrid->setMargin( WIDGET_SPACING );
169 //--------------
170 //Window caption
171 setCaption( tr("Mosaic Options") );
172 //-------------------------------
173 //set window to not be resizeable
174 this->show();
175// setFixedSize(size());
176 //-------------------------------
177}
A clickable label.
void setPixmap(const QPixmap &p)
Configuration object manages all user-specific application settings.
void resetSetting(QString group, QString key)
Resets a setting to it's default value.
QString getString(QString group, QString key)
Fetch string setting.
QRadioButton * tileType_solidColors
ClickableLabel * browseButton
QRadioButton * tileType_imagesFrom
QRadioButton * tileType_albumPhotos
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget.
Definition window.h:40
QString IMAGE_PATH
Definition config.cpp:18
#define WIDGET_SPACING
Definition config.h:31

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.

Member Function Documentation

◆ appendImagesInPath()

void MosaicOptionsDialog::appendImagesInPath ( QStringList & files,
QString path,
int depth )
private

Definition at line 222 of file mosaicOptionsDialog.cpp.

223{
224// cout << "appending files in " << path << "\n";
225 QDir tmpDir;
226 tmpDir.setPath( path );
227
228 //add all iamges
229 tmpDir.setFilter( QDir::Files | QDir::Readable );
230 tmpDir.setNameFilter( "*.gif;*.jpg;*.jpeg;*.png;*.xpm;*.GIF;*.JPG;*.JPEG;*.PNG;*.XPM" );
231 QStringList images = tmpDir.entryList();
232 QStringList::iterator it;
233 QSize imageRes;
234 for(it = images.begin(); it != images.end(); it++ )
235 {
236 //check we can get a decent resolution out of the file
237 getImageSize( tmpDir.absFilePath( *it ), imageRes );
238 if( imageRes.width() <= 0 || imageRes.height() <= 0 ) continue;
239
240// cout << "appending " << *it << "\n";
241 files.append( tmpDir.absFilePath( *it ) );
242
243 //break out if we have too many files
244 if( files.count() >= MAX_FILES ) break;
245 }
246
247 //recurse on all directories (but not symbolic links) - but only go down three levels
248 if( depth < MAX_DEPTH && files.count() < MAX_FILES )
249 {
250 tmpDir.setFilter( QDir::Dirs | QDir::Readable | QDir::NoSymLinks );
251 tmpDir.setNameFilter( "*" );
252 QStringList directores = tmpDir.entryList();
253 for(it = directores.begin(); it != directores.end(); it++ )
254 {
255 QString dir = *it;
256 if( dir.compare( "." ) == 0 || dir.compare( ".." ) == 0 ) continue;
257
258 appendImagesInPath( files, tmpDir.absFilePath( *it ), depth+1 );
259 }
260 }
261}
void appendImagesInPath(QStringList &files, QString path, int depth)
bool getImageSize(const char *filename, QSize &size)
Get image dimensions.
#define MAX_FILES
#define MAX_DEPTH

References appendImagesInPath(), getImageSize(), MAX_DEPTH, and MAX_FILES.

Referenced by appendImagesInPath(), and determineFilesList().

◆ browse

void MosaicOptionsDialog::browse ( )
privateslot

Definition at line 292 of file mosaicOptionsDialog.cpp.

293{
294 //get directory from user
295 QString dirName = Q3FileDialog::getExistingDirectory( locationVal->text(), this, NULL, tr("Images directory") );
296
297 if(!dirName.isNull())
298 locationVal->setText( dirName );
299}

References locationVal.

Referenced by MosaicOptionsDialog().

◆ determineFilesList()

QStringList MosaicOptionsDialog::determineFilesList ( )
private

Definition at line 201 of file mosaicOptionsDialog.cpp.

202{
203 //Album photos
204 if( tileType_albumPhotos->isChecked() )
205 {
206 Album* albm = ((Window*)qApp->mainWidget())->getTitle()->getAlbum();
207 return albm->getThumbnailFilenames();
208 }
209
210 //Solid colors - return empty list
211 else if ( tileType_solidColors->isChecked() ) { return QStringList(); }
212 //Images from...
213 else
214 {
215 QStringList files;
216 QString path = locationVal->text();
217 appendImagesInPath( files, path, 0 );
218 return files;
219 }
220}
An album contains Subalbums.
Definition album.h:53
QStringList getThumbnailFilenames()
Returns a list of the most up to date thumbnail filesnames.
Definition album.cpp:1426

References appendImagesInPath(), Album::getThumbnailFilenames(), locationVal, tileType_albumPhotos, and tileType_solidColors.

Referenced by getOptions().

◆ determineTileSize()

QSize MosaicOptionsDialog::determineTileSize ( )
private

Definition at line 191 of file mosaicOptionsDialog.cpp.

192{
193 if( tileSizes->currentItem() == 0 ) return QSize( 20, 20 );
194 else if( tileSizes->currentItem() == 1 ) return QSize( 40, 40 );
195 else if( tileSizes->currentItem() == 2 ) return QSize( 65, 65 );
196 else if( tileSizes->currentItem() == 3 ) return QSize( 100, 100 );
197 else if( tileSizes->currentItem() == 4 ) return QSize( 150, 150 );
198 else return QSize( tileWidth->value(), tileHeight->value() );
199}

References tileHeight, tileSizes, and tileWidth.

Referenced by getOptions(), and updateTileSizePreview().

◆ getOptions()

MosaicOptions * MosaicOptionsDialog::getOptions ( )

returns a populate options object

Definition at line 179 of file mosaicOptionsDialog.cpp.

180{
181 //construct a list of files based on the user selection
182 QStringList files = determineFilesList();
183
184 //get selected tile size
185 QSize tileSize = determineTileSize();
186
187 //return a populated mosaic options object
188 return new MosaicOptions( files, tileSize, ((Window*)qApp->mainWidget())->getStatus() );
189}

References determineFilesList(), and determineTileSize().

Referenced by EditingInterface::applyEffect().

◆ updateImagesFromOptions

void MosaicOptionsDialog::updateImagesFromOptions ( )
privateslot

Definition at line 285 of file mosaicOptionsDialog.cpp.

286{
287 bool enabled = tileType_imagesFrom->isChecked();
288 locationVal->setEnabled( enabled );
289 browseButton->setEnabled( enabled );
290}
void setEnabled(bool val)

References browseButton, locationVal, ClickableLabel::setEnabled(), and tileType_imagesFrom.

Referenced by MosaicOptionsDialog().

◆ updateTileSizePreview

void MosaicOptionsDialog::updateTileSizePreview ( )
privateslot

Definition at line 263 of file mosaicOptionsDialog.cpp.

264{
265 //get selected tile size
266 QSize tileSize = determineTileSize();
267
268 //show/hide custom controls
269 bool customSelected = tileSizes->currentItem() == tileSizes->count()-1;
270
271 tileSizePreview->setShown( !customSelected );
272 tileWidth->setShown ( customSelected );
273 tileSizeX->setShown ( customSelected );
274 tileHeight->setShown( customSelected );
275
276 //update tile size preview text
277 if( !customSelected )
278 {
279 tileSizePreview->setText( QString("(%1 x %2)").arg( tileSize.width() ).arg( tileSize.height() ) );
280 }
281
282 //update preview image
283}

References determineTileSize(), tileHeight, tileSizePreview, tileSizes, tileSizeX, and tileWidth.

Referenced by MosaicOptionsDialog().

Member Data Documentation

◆ browseButton

ClickableLabel* MosaicOptionsDialog::browseButton
private

Definition at line 60 of file mosaicOptionsDialog.h.

Referenced by MosaicOptionsDialog(), and updateImagesFromOptions().

◆ locationVal

QLineEdit* MosaicOptionsDialog::locationVal
private

◆ tileHeight

QSpinBox* MosaicOptionsDialog::tileHeight
private

◆ tileSizePreview

QLabel* MosaicOptionsDialog::tileSizePreview
private

Definition at line 50 of file mosaicOptionsDialog.h.

Referenced by MosaicOptionsDialog(), and updateTileSizePreview().

◆ tileSizes

QComboBox* MosaicOptionsDialog::tileSizes
private

◆ tileSizeX

QLabel* MosaicOptionsDialog::tileSizeX
private

Definition at line 53 of file mosaicOptionsDialog.h.

Referenced by MosaicOptionsDialog(), and updateTileSizePreview().

◆ tileType_albumPhotos

QRadioButton* MosaicOptionsDialog::tileType_albumPhotos
private

Definition at line 56 of file mosaicOptionsDialog.h.

Referenced by determineFilesList(), and MosaicOptionsDialog().

◆ tileType_imagesFrom

QRadioButton* MosaicOptionsDialog::tileType_imagesFrom
private

Definition at line 58 of file mosaicOptionsDialog.h.

Referenced by MosaicOptionsDialog(), and updateImagesFromOptions().

◆ tileType_solidColors

QRadioButton* MosaicOptionsDialog::tileType_solidColors
private

Definition at line 57 of file mosaicOptionsDialog.h.

Referenced by determineFilesList(), and MosaicOptionsDialog().

◆ tileWidth

QSpinBox* MosaicOptionsDialog::tileWidth
private

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