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

#include <photoDescEdit.h>

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

Public Slots

void hide ()
 

Public Member Functions

 PhotoDescEdit (PhotoPreviewWidget *ppw, bool useAnimation, QWidget *parent=0, const char *name=0)
 
 ~PhotoDescEdit ()
 

Private Slots

void animate ()
 this method is iteratively called and animates the opening/closing of the image More...
 
void disappear ()
 this method is called by the acceptAndClose and rejectAndClose slots and actually initiates the closing process More...
 

Private Attributes

bool useAnimation
 actually animate the opening/closing process? More...
 
PhotoPreviewWidgetppw
 photo preview widget pointer More...
 
QImage * imageLarge
 beginning and end pixmaps More...
 
QImage * textRectangle
 text area widget used to computing painting surface More...
 
QPoint initPos
 
QPoint finalPos
 
int left
 bounaries of entire animation More...
 
int right
 
int top
 
int bottom
 
int idealTextSize
 ultimate text dimension More...
 
QPixmap * backgroundImage
 this pixmap contains the screen contents for the entire region which we will be painting on top of More...
 
int smallWidth
 small size More...
 
int smallHeight
 
Q3GridLayout * mainGrid
 
More...
 
QLabelanimationLabel
 

Animating Widgets More...

 
QPixmap * buffer
 buffer we'll iteratively update and use for the label which shows the animation taking place More...
 
Q3GridLayout * staticGrid
 

Static Widgets More...

 
QWidgetstaticFrame
 frame which contains static widget More...
 
QLabelstaticPhoto
 photo being displayed More...
 
TextEditphotoDesc
 photo description More...
 
int initDelay
 

Animation Stuff More...

 
int accel
 
int minDelay
 
int step
 
int delay
 
int mode
 
bool dropShadowsEnabled
 are drop shadows enabled in windows (xp)? More...
 
QTimer * timer
 
QTime lastTime
 
QTime currentTime
 

Detailed Description

Definition at line 42 of file photoDescEdit.h.

Constructor & Destructor Documentation

§ PhotoDescEdit()

PhotoDescEdit::PhotoDescEdit ( PhotoPreviewWidget ppw,
bool  useAnimation,
QWidget parent = 0,
const char *  name = 0 
)

Definition at line 54 of file photoDescEdit.cpp.

References accel, animate(), animationLabel, APPEARING, backgroundImage, bottom, buffer, calcScaledImageDimensions(), delay, disappear(), dropShadowsEnabled, EDIT_MARGIN, finalPos, Photo::getDescription(), Photo::getImageFilename(), getImageSize(), PhotoPreviewWidget::getPhoto(), PhotoPreviewWidget::getPhotoPos(), Photo::getSlideshowFilename(), Photo::getThumbnailFilename(), idealTextSize, imageLarge, initDelay, initPos, lastTime, left, mainGrid, minDelay, mode, TextEdit::paintNow(), photoDesc, ppw, right, smallHeight, smallWidth, STATIC, staticFrame, staticGrid, staticPhoto, step, textRectangle, timer, top, and useAnimation.

55  :
56  QWidget(parent,name,
57  Qt::WStyle_Customize |
58 #if defined(Q_OS_MACX)
59  Qt::WStyle_Splash )
60 #else
61  Qt::WStyle_NoBorder | Qt::WType_Popup )
62 #endif
63 {
64  //PLATFORM_SPECIFIC_CODE
65  //disable drop shadow on mac os x
66  #if defined(Q_OS_MACX)
67  ChangeWindowAttributes( (OpaqueWindowPtr*)winId(), kWindowNoShadowAttribute, kWindowNoAttributes );
68  #endif
69 
70  //PLATFORM_SPECIFIC_CODE
71  //disable drop shadow on win xp
72  #if defined(Q_OS_WIN)
73  SystemParametersInfo( SPI_GETDROPSHADOW, 0, &dropShadowsEnabled, 0 );
74  SystemParametersInfo( SPI_SETDROPSHADOW, 0, NULL, 0 );
75  #endif
76 
77  this->ppw = ppw;
78  //-----------------------------------------------
79  //don't erase before painting, avoids flicker
80  setWindowFlags(Qt::WNoAutoErase);
81  //-----------------------------------------------
82  //determine small image size
84  //-------------------------------------------
85  QRect appRec = qApp->mainWidget()->frameGeometry();
86  int finalWidth, finalHeight;
87  int actualFinalWidth, actualFinalHeight;
88 
89  //image is wider than tall, place text and buttons below image
90  if(smallWidth > smallHeight )
91  {
92  finalWidth = 400;
93  finalHeight = (finalWidth * smallHeight) / smallWidth;
94 
95  //fix width
96  if(finalWidth +2*EDIT_MARGIN> appRec.width())
97  {
98  finalWidth = appRec.width() - 2*EDIT_MARGIN;
99  finalHeight = (finalWidth * smallHeight) / smallWidth;
100  }
101 
102  //fix height
103  QFontMetrics fm( qApp->font() );
104  idealTextSize = 4*fm.height() + 5*fm.leading() + 4;
105 
106  if(finalHeight + idealTextSize + 2*EDIT_MARGIN > appRec.height() )
107  {
108  finalHeight = appRec.height() - idealTextSize - 2*EDIT_MARGIN;
109  finalWidth = (finalHeight * smallWidth) / smallHeight;
110  }
111 
112  //sanity check
113  if(finalHeight < 0)
114  {
115  finalHeight = (appRec.height() - 2*EDIT_MARGIN) / 2;
116  finalWidth = (finalHeight * smallWidth) / smallHeight;
117  idealTextSize = finalHeight;
118  }
119 
120  actualFinalWidth = finalWidth + 2*EDIT_MARGIN;
121  actualFinalHeight = finalHeight + idealTextSize + 2*EDIT_MARGIN;
122 
123  //an additional fudge is necessary for MacOSX, not sure why
124 #if defined(Q_OS_MACX)
125  actualFinalHeight+=2;
126 #endif
127  }
128  //image is taller than wide, text and buttons will be placed to the right
129  else
130  {
131  finalHeight = 300;
132  finalWidth = (finalHeight * smallWidth) / smallHeight;
133 
134  //fix height
135  if(finalHeight + 2*EDIT_MARGIN > appRec.height())
136  {
137  finalHeight = appRec.height() - 2*EDIT_MARGIN;
138  finalWidth = (finalHeight * smallWidth) / smallHeight;
139  }
140 
141  //fix width
142  QString calibrationString( qApp->translate("PhotoDescEdit", "This is the photo description calibration string.") );
143  QFontMetrics fm( qApp->font() );
144  idealTextSize = fm.width( calibrationString );
145  if(finalWidth + idealTextSize + 2*EDIT_MARGIN > appRec.width() )
146  {
147  finalWidth = appRec.width() - idealTextSize - 2*EDIT_MARGIN;
148  finalHeight = (finalWidth * smallHeight) / smallWidth;
149  }
150 
151  //sanity check
152  if(finalWidth < 0)
153  {
154  finalWidth = (appRec.width() - 2*EDIT_MARGIN) / 2;
155  finalHeight = (finalWidth * smallHeight) / smallWidth;
156  idealTextSize = finalWidth;
157  }
158 
159  actualFinalWidth = finalWidth + idealTextSize + 2*EDIT_MARGIN;
160  actualFinalHeight = finalHeight + 2*EDIT_MARGIN;
161  }
162  //-----------------------------------------------
163  //setup scaled up image
164  //find full size photo dimensions, if unable to then use scaled up thumbnail image
165  int fullWidth, fullHeight;
166  if(!getImageSize( ppw->getPhoto()->getImageFilename(), fullWidth, fullHeight ) )
167  {
168  imageLarge = new QImage( QImage( ppw->getPhoto()->getThumbnailFilename()).
169  scaled(finalWidth,finalHeight, Qt::IgnoreAspectRatio ));
170  }
171  //else find cropped region of slideshow image using these dimensions
172  else
173  {
174  //load padded slideshow image
175  QImage paddedSSImage( ppw->getPhoto()->getSlideshowFilename() );
176 
177  //unpadded dimensions
178  int actualWidth, actualHeight;
179  calcScaledImageDimensions( fullWidth, fullHeight,
180  paddedSSImage.width(), paddedSSImage.height(),
181  actualWidth, actualHeight );
182 
183  //construct new image with padding removed
184  int leftOffset = (paddedSSImage.width() - actualWidth) / 2;
185  int topOffset = (paddedSSImage.height() - actualHeight) / 2;
186  QImage SSImage( actualWidth, actualHeight, paddedSSImage.depth() );
187 
188  int x, y;
189  for(x=0; x<actualWidth; x++)
190  {
191  for(y=0; y<actualHeight; y++)
192  {
193  SSImage.setPixel( x, y, QColor(Qt::red).rgb() );
194  SSImage.setPixel( x, y, paddedSSImage.pixel(x+leftOffset, y+topOffset) );
195  }
196  }
197  imageLarge = new QImage(SSImage.smoothScale(finalWidth,finalHeight, Qt::IgnoreAspectRatio ));
198  }
199  //-----------------------------------------------
200  //construct final text area pixmap used for morphing text region
201  TextEdit tmpTextEdit;
202  tmpTextEdit.setText( ppw->getPhoto()->getDescription() );
203 
204  if(smallWidth > smallHeight )
205  tmpTextEdit.resize( finalWidth, idealTextSize );
206  else
207  tmpTextEdit.resize( idealTextSize, finalHeight );
208 
209  tmpTextEdit.setLineWidth( 0 );
210  tmpTextEdit.setMargin( 0 );
211  tmpTextEdit.setMidLineWidth( 0 );
212  tmpTextEdit.setFrameStyle( Q3Frame::NoFrame | Q3Frame::Plain );
213 
214  tmpTextEdit.setWrapPolicy( Q3TextEdit::AtWordOrDocumentBoundary );
215  tmpTextEdit.constPolish();
216  tmpTextEdit.polish();
217 
218  tmpTextEdit.setWordWrap( Q3TextEdit::FixedPixelWidth );
219  if(smallWidth > smallHeight )
220  tmpTextEdit.setWrapColumnOrWidth( finalWidth );
221  else
222  tmpTextEdit.setWrapColumnOrWidth( idealTextSize );
223  tmpTextEdit.updateScrollBars();
224  tmpTextEdit.constPolish();
225  tmpTextEdit.polish();
226 
227  if(smallWidth > smallHeight )
228  {
229  if(tmpTextEdit.lines() > 4)
230  {
231  tmpTextEdit.setWrapColumnOrWidth( finalWidth - tmpTextEdit.verticalScrollBar()->width() );
232  tmpTextEdit.updateScrollBars();
233  tmpTextEdit.constPolish();
234  tmpTextEdit.polish();
235  }
236  }
237  else
238  {
239  QFontMetrics fm( qApp->font() );
240  if(tmpTextEdit.lines() > idealTextSize / (fm.leading() + fm.height()) )
241  {
242  tmpTextEdit.setWrapColumnOrWidth( idealTextSize - tmpTextEdit.verticalScrollBar()->width() );
243  tmpTextEdit.updateScrollBars();
244  tmpTextEdit.constPolish();
245  tmpTextEdit.polish();
246  }
247  }
248 
249  //paint to pixmap
250  tmpTextEdit.paintNow();
251  textRectangle = new QImage( QPixmap::grabWidget(&tmpTextEdit).convertToImage() );
252  //-----------------------------------------------
253  //set beginning and end positions
254  initPos = ppw->getPhotoPos();
255 
256  //offset by margin
257  initPos += QPoint( -EDIT_MARGIN, -EDIT_MARGIN );
258 
259  int initCenterX = initPos.x() + smallWidth/2;
260  int initCenterY = initPos.y() + smallHeight/2;
261 
262  finalPos = QPoint( initCenterX - actualFinalWidth/2, initCenterY - actualFinalHeight/2 );
263  if(finalPos.x() < appRec.x() )
264  finalPos.setX( appRec.x() );
265  if(finalPos.x() + actualFinalWidth > appRec.x() + appRec.width() )
266  finalPos.setX( appRec.x() + appRec.width()- actualFinalWidth );
267 
268  if(finalPos.y() < appRec.y() )
269  finalPos.setY( appRec.y() );
270  if(finalPos.y() + actualFinalHeight > appRec.y() + appRec.height() )
271  finalPos.setY( appRec.y() + appRec.height()- actualFinalHeight );
272  //-----------------------------------------------
273  //find bounding rectangle
274  left = QMIN( finalPos.x(), initPos.x() );
275  top = QMIN( finalPos.y(), initPos.y() );
276  right = QMAX( finalPos.x() + actualFinalWidth, initPos.x() + smallWidth );
277  bottom = QMAX( finalPos.y() + actualFinalHeight, initPos.y() + smallHeight );
278  //-----------------------------------------------
279  //grab window in region of interest, setup label and use this image
280  backgroundImage = new QPixmap( QPixmap::grabWindow(QApplication::desktop()->winId(),
281  left, top,
282  right-left, bottom-top) );
283  setBackgroundMode( Qt::NoBackground );
284  //-----------------------------------------------
285  //Setup animation widgets and place in main grid
286  animationLabel = new QLabel(this, "animationLabel", Qt::WNoAutoErase);
287  animationLabel->setPixmap( *backgroundImage );
288  animationLabel->setBackgroundMode( Qt::NoBackground );
289  buffer = new QPixmap( backgroundImage->width(), backgroundImage->height() );
290 
291  mainGrid = new Q3GridLayout( this, 1, 2, 0 );
292  mainGrid->addWidget(animationLabel, 0, 0 );
293  //-----------------------------------------------
294  //Setup static widgets
295  staticFrame = new QWidget(this);
296  staticFrame->hide();
297  staticFrame->setBackgroundMode( Qt::NoBackground );
298  mainGrid->addWidget(staticFrame, 0, 1 );
299 
300  staticPhoto = new QLabel( staticFrame, "staticPhoto", Qt::WNoAutoErase);
301  staticPhoto->setPixmap( QPixmap( *imageLarge) );
302  staticPhoto->setBackgroundMode( Qt::NoBackground );
303 
304  photoDesc = new TextEdit( staticFrame );
305  photoDesc->setText( ppw->getPhoto()->getDescription() );
306 
307  photoDesc->setWrapPolicy( Q3TextEdit::AtWordOrDocumentBoundary );
308  photoDesc->setFrameStyle( Q3Frame::NoFrame );
309  photoDesc->setLineWidth( 0 );
310  photoDesc->setMargin( 0 );
311  photoDesc->setMidLineWidth( 0 );
312  photoDesc->setFrameStyle( QFrame::StyledPanel | Q3Frame::Plain );
313 
314  //start disappearing once the text edit reports the user is finished
315  connect( photoDesc, SIGNAL( finished() ),
316  this, SLOT( disappear() ) );
317 
318  QWidget* bw1 = new QWidget(staticFrame);
319  QWidget* bw2 = new QWidget(staticFrame);
320  QWidget* bw3 = new QWidget(staticFrame);
321  QWidget* bw4 = new QWidget(staticFrame);
322  QColor darkBlue(35, 75, 139);
323  bw1->setPaletteBackgroundColor( darkBlue );
324  bw2->setPaletteBackgroundColor( darkBlue );
325  bw3->setPaletteBackgroundColor( darkBlue );
326  bw4->setPaletteBackgroundColor( darkBlue );
327 
328  //image is wider than tall, place text and buttons below image
329  if(smallWidth > smallHeight )
330  {
331  staticGrid = new Q3GridLayout( staticFrame, 4, 3);
332 
333  staticGrid->addWidget( staticPhoto, 1, 1 );
334  staticGrid->addWidget( photoDesc, 2, 1 );
335 
336  staticGrid->setColSpacing( 2, staticPhoto->width() );
337  staticGrid->setRowSpacing( 2, idealTextSize );
338 
339  staticGrid->addMultiCellWidget( bw1, 0, 0, 0, 2 );
340  staticGrid->addMultiCellWidget( bw2, 1, 2, 0, 0 );
341  staticGrid->addMultiCellWidget( bw3, 1, 2, 2, 2 );
342  staticGrid->addMultiCellWidget( bw4, 3, 3, 0, 2 );
343  staticGrid->setRowSpacing( 0, EDIT_MARGIN );
344  staticGrid->setRowSpacing( 3, EDIT_MARGIN );
345  staticGrid->setColSpacing( 0, EDIT_MARGIN );
346  staticGrid->setColSpacing( 2, EDIT_MARGIN );
347  }
348  else
349  {
350  staticGrid = new Q3GridLayout( staticFrame, 3, 4);
351 
352  staticGrid->addWidget( staticPhoto, 1, 1 );
353  staticGrid->addWidget( photoDesc, 1, 2 );
354 
355  staticGrid->setRowSpacing( 1, staticPhoto->height() );
356  staticGrid->setColSpacing( 2, idealTextSize );
357 
358  staticGrid->addMultiCellWidget( bw1, 0, 0, 0, 3 );
359  staticGrid->addWidget( bw2, 1, 0 );
360  staticGrid->addWidget( bw3, 1, 3 );
361  staticGrid->addMultiCellWidget( bw4, 2, 2, 0, 3 );
362  staticGrid->setRowSpacing( 0, EDIT_MARGIN );
363  staticGrid->setRowSpacing( 2, EDIT_MARGIN );
364  staticGrid->setColSpacing( 0, EDIT_MARGIN );
365  staticGrid->setColSpacing( 3, EDIT_MARGIN );
366  }
367  //-----------------------------------------------
368  //set delay defaults
369  initDelay = 130;
370  accel = 50;
371  minDelay = 1;
372 
373  this->useAnimation = useAnimation;
374  if(useAnimation)
375  step = 0;
376  else
377  step = 100;
378 
379  mode = STATIC;
380 
381  //create timer object and setup signals
382  timer = new QTimer();
383  connect(timer, SIGNAL(timeout()), this, SLOT(animate()) );
384  //---------------------------
385  //place widget in intial position
386  move( left, top );
387  show();
388 
389  //start appearing process
390  mode = APPEARING;
391  delay = initDelay;
392  lastTime.start();
393  animate();
394 }
QPixmap * buffer
buffer we&#39;ll iteratively update and use for the label which shows the animation taking place ...
Definition: photoDescEdit.h:99
QString getImageFilename()
Gets the image filename.
Definition: photo.cpp:192
QWidget * staticFrame
frame which contains static widget
void paintNow()
QImage * textRectangle
text area widget used to computing painting surface
Definition: photoDescEdit.h:72
Q3GridLayout * mainGrid
Definition: photoDescEdit.h:91
Photo * getPhoto()
Returns photo pointer.
#define APPEARING
Definition: photoDescEdit.h:34
int idealTextSize
ultimate text dimension
Definition: photoDescEdit.h:81
#define EDIT_MARGIN
QString getThumbnailFilename()
Gets the thumbnail filename.
Definition: photo.cpp:194
Q3GridLayout * staticGrid
Static Widgets
TextEdit * photoDesc
photo description
QImage * imageLarge
beginning and end pixmaps
Definition: photoDescEdit.h:69
int initDelay
Animation Stuff
void disappear()
this method is called by the acceptAndClose and rejectAndClose slots and actually initiates the closi...
int smallWidth
small size
Definition: photoDescEdit.h:88
QLabel * staticPhoto
photo being displayed
QLabel * animationLabel
Animating Widgets
Definition: photoDescEdit.h:96
bool getImageSize(const char *filename, QSize &size)
Get image dimensions.
Definition: imageTools.cpp:192
int left
bounaries of entire animation
Definition: photoDescEdit.h:78
#define STATIC
Definition: photoDescEdit.h:33
void animate()
this method is iteratively called and animates the opening/closing of the image
QTimer * timer
QString getSlideshowFilename()
Gets the slideshow filename.
Definition: photo.cpp:193
PhotoPreviewWidget * ppw
photo preview widget pointer
Definition: photoDescEdit.h:66
QString getDescription()
Gets the description.
Definition: photo.cpp:208
QPixmap * backgroundImage
this pixmap contains the screen contents for the entire region which we will be painting on top of ...
Definition: photoDescEdit.h:85
void calcScaledImageDimensions(int origWidth, int origHeight, int idealWidth, int idealHeight, int &width, int &height)
Computes scale of image dimensions while respecting aspect ratio, equivalent to a QImage::scaleMin wi...
Definition: imageTools.cpp:39
bool dropShadowsEnabled
are drop shadows enabled in windows (xp)?
bool useAnimation
actually animate the opening/closing process?
Definition: photoDescEdit.h:63

§ ~PhotoDescEdit()

PhotoDescEdit::~PhotoDescEdit ( )

Definition at line 396 of file photoDescEdit.cpp.

References backgroundImage, buffer, imageLarge, textRectangle, and timer.

397 {
398  delete textRectangle;
399  delete timer;
400  delete buffer;
401  delete backgroundImage;
402  delete imageLarge;
403 }
QPixmap * buffer
buffer we&#39;ll iteratively update and use for the label which shows the animation taking place ...
Definition: photoDescEdit.h:99
QImage * textRectangle
text area widget used to computing painting surface
Definition: photoDescEdit.h:72
QImage * imageLarge
beginning and end pixmaps
Definition: photoDescEdit.h:69
QTimer * timer
QPixmap * backgroundImage
this pixmap contains the screen contents for the entire region which we will be painting on top of ...
Definition: photoDescEdit.h:85

Member Function Documentation

§ animate

void PhotoDescEdit::animate ( )
privateslot

this method is iteratively called and animates the opening/closing of the image

Definition at line 405 of file photoDescEdit.cpp.

References accel, animationLabel, APPEARING, backgroundImage, buffer, currentTime, delay, DISAPPEARED, dropShadowsEnabled, EDIT_MARGIN, finalPos, hide(), idealTextSize, imageLarge, initPos, lastTime, left, minDelay, mode, photoDesc, smallHeight, smallWidth, STATIC, staticFrame, step, textRectangle, timer, and top.

Referenced by disappear(), and PhotoDescEdit().

406 {
407  //---------------------------------
408  //determine # of ms that have passed since last redraw
409  currentTime.start();
410  double ms = lastTime.msecsTo(currentTime);
411 
412  //determine increment
413  int inc = (int)(ms/(delay+1));
414 
415  //if increment is not zero then update last time
416  if(inc != 0)
417  {
419 
420  //update step
421  step = step + inc;
422  if(step > 100)
423  step = 100;
424 
425  //update position and size
426  double alpha = ((double)step) / 100.0;
427  int newX, newY;
428  int imageW, imageH;
429  int textDim;
430  QColor darkBlue(35, 75, 139);
431  if(mode == APPEARING)
432  {
433  newX = (int)((1-alpha)*initPos.x() + alpha*finalPos.x());
434  newY = (int)((1-alpha)*initPos.y() + alpha*finalPos.y());
435  imageW = (int)((1-alpha)*smallWidth + alpha*imageLarge->width());
436  imageH = (int)((1-alpha)*smallHeight + alpha*imageLarge->height());
437  textDim = (int) (alpha * idealTextSize);
438  }
439  else
440  {
441  newX = (int)(alpha*initPos.x() + (1-alpha)*finalPos.x());
442  newY = (int)(alpha*initPos.y() + (1-alpha)*finalPos.y());
443  imageW = (int)(alpha*smallWidth + (1-alpha)*imageLarge->width());
444  imageH = (int)(alpha*smallHeight + (1-alpha)*imageLarge->height());
445  textDim = (int) ((1-alpha) * idealTextSize);
446  }
447 
448  //draw background image to buffer
449  QPainter bufferPainter( buffer );
450  bufferPainter.drawPixmap(0,0, *backgroundImage );
451 
452  //draw selection and white text rectangles
453  if(smallWidth > smallHeight )
454  {
455  bufferPainter.fillRect( newX - left,
456  newY - top,
457  imageW + 2*EDIT_MARGIN,
458  imageH + 2*EDIT_MARGIN + textDim,
459  darkBlue );
460 
461  bufferPainter.drawPixmap( newX - left + EDIT_MARGIN,
462  newY - top + EDIT_MARGIN + imageH,
463  QPixmap( textRectangle->scaled( imageW, textDim ) ) );
464  }
465  else
466  {
467  bufferPainter.fillRect( newX - left, newY - top,
468  imageW + 2*EDIT_MARGIN + textDim,
469  imageH + 2*EDIT_MARGIN,
470  darkBlue );
471 
472  bufferPainter.drawPixmap( newX - left + EDIT_MARGIN + imageW,
473  newY - top + EDIT_MARGIN,
474  QPixmap( textRectangle->scaled( textDim, imageH ) ) );
475  }
476 
477  //draw scaled moved image to buffer
478  bufferPainter.drawPixmap( newX - left + EDIT_MARGIN,
479  newY - top + EDIT_MARGIN,
480  QPixmap( imageLarge->scaled( imageW, imageH ) ) );
481 
482  //set label to use buffer pixmap
483  animationLabel->setPixmap( *buffer );
484  }
485 
486  //not done restart timer
487  if(step < 100)
488  {
489  //update speed
490  delay = delay - accel;
491  if(delay < minDelay) delay = minDelay;
492 
493  //restart timer
494  timer->start( delay, TRUE );
495  }
496  else
497  {
498  if(mode == APPEARING)
499  {
500  animationLabel->hide();
501  staticFrame->show();
502 
503  //auto focus text area, put cursor at very end
504  photoDesc->setFocus();
505 
506  mode = STATIC;
507  }
508  else
509  {
510  //reenable drop shadows on windows xp if they were previously enabled
511  #if defined(Q_OS_WIN)
513  SystemParametersInfo( SPI_SETDROPSHADOW, 0, &dropShadowsEnabled, 0 );
514  else
515  SystemParametersInfo( SPI_SETDROPSHADOW, 0, NULL, 0 );
516  #endif //Q_OS_WIN
517 
518  mode = DISAPPEARED;
519  hide();
520  qApp->mainWidget()->repaint(false);
521  }
522  }
523 }
QPixmap * buffer
buffer we&#39;ll iteratively update and use for the label which shows the animation taking place ...
Definition: photoDescEdit.h:99
#define DISAPPEARED
Definition: photoDescEdit.h:36
QWidget * staticFrame
frame which contains static widget
QImage * textRectangle
text area widget used to computing painting surface
Definition: photoDescEdit.h:72
#define APPEARING
Definition: photoDescEdit.h:34
int idealTextSize
ultimate text dimension
Definition: photoDescEdit.h:81
#define EDIT_MARGIN
TextEdit * photoDesc
photo description
QImage * imageLarge
beginning and end pixmaps
Definition: photoDescEdit.h:69
int smallWidth
small size
Definition: photoDescEdit.h:88
QLabel * animationLabel
Animating Widgets
Definition: photoDescEdit.h:96
int left
bounaries of entire animation
Definition: photoDescEdit.h:78
#define STATIC
Definition: photoDescEdit.h:33
QTimer * timer
QPixmap * backgroundImage
this pixmap contains the screen contents for the entire region which we will be painting on top of ...
Definition: photoDescEdit.h:85
bool dropShadowsEnabled
are drop shadows enabled in windows (xp)?

§ disappear

void PhotoDescEdit::disappear ( )
privateslot

this method is called by the acceptAndClose and rejectAndClose slots and actually initiates the closing process

Definition at line 525 of file photoDescEdit.cpp.

References accel, animate(), animationLabel, DISAPPEARING, PhotoPreviewWidget::getPhoto(), initDelay, lastTime, minDelay, mode, photoDesc, ppw, Photo::setDescription(), PhotoPreviewWidget::setText(), staticFrame, step, textRectangle, and useAnimation.

Referenced by hide(), and PhotoDescEdit().

526 {
527  delete textRectangle;
528  textRectangle = new QImage( QPixmap::grabWidget(photoDesc).convertToImage() );
529 
530  ppw->getPhoto()->setDescription( photoDesc->text() );
531  ppw->setText( photoDesc->text() );
532 
533  //start disappearing process
534  staticFrame->hide();
535  animationLabel->show();
536 
537  initDelay = 130;
538  accel = 50;
539  minDelay = 1;
540 
541  if(useAnimation)
542  step = 0;
543  else
544  step = 100;
545 
546  mode = DISAPPEARING;
547  lastTime.start();
548  animate();
549 }
QWidget * staticFrame
frame which contains static widget
QImage * textRectangle
text area widget used to computing painting surface
Definition: photoDescEdit.h:72
void setText(const QString &text)
Photo * getPhoto()
Returns photo pointer.
TextEdit * photoDesc
photo description
int initDelay
Animation Stuff
#define DISAPPEARING
Definition: photoDescEdit.h:35
void setDescription(QString val)
Sets the description.
Definition: photo.cpp:210
QLabel * animationLabel
Animating Widgets
Definition: photoDescEdit.h:96
void animate()
this method is iteratively called and animates the opening/closing of the image
PhotoPreviewWidget * ppw
photo preview widget pointer
Definition: photoDescEdit.h:66
bool useAnimation
actually animate the opening/closing process?
Definition: photoDescEdit.h:63

§ hide

void PhotoDescEdit::hide ( )
slot

Definition at line 551 of file photoDescEdit.cpp.

References disappear(), DISAPPEARED, mode, ppw, and STATIC.

Referenced by animate().

552 {
553  if(mode == DISAPPEARED )
554  {
555  QWidget::hide();
556 
557  //check to see if mouse is over a new item,
558  //if so immediately set it as being moused over
559  Q3IconView* iconView = ppw->iconView();
560  Q3IconViewItem* item = iconView->findItem( iconView->viewport()->mapFromGlobal( QCursor::pos() )+=QPoint( iconView->contentsX(), iconView->contentsY() ) );
561  if(item != NULL && item != ppw )
562  {
563  ((PhotosIconView*)item->iconView())->repaintGroup( item );
564  }
565  }
566  else if(mode == STATIC)
567  {
568  disappear();
569  }
570 }
#define DISAPPEARED
Definition: photoDescEdit.h:36
Extension of iconview, used to list all photos in a subalbum. supports drag-n-drop within iconview...
void disappear()
this method is called by the acceptAndClose and rejectAndClose slots and actually initiates the closi...
#define STATIC
Definition: photoDescEdit.h:33
PhotoPreviewWidget * ppw
photo preview widget pointer
Definition: photoDescEdit.h:66

Member Data Documentation

§ accel

int PhotoDescEdit::accel
private

Definition at line 118 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ animationLabel

QLabel* PhotoDescEdit::animationLabel
private


Animating Widgets

label which shows moving and expanding photo on background

Definition at line 96 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ backgroundImage

QPixmap* PhotoDescEdit::backgroundImage
private

this pixmap contains the screen contents for the entire region which we will be painting on top of

Definition at line 85 of file photoDescEdit.h.

Referenced by animate(), PhotoDescEdit(), and ~PhotoDescEdit().

§ bottom

int PhotoDescEdit::bottom
private

Definition at line 78 of file photoDescEdit.h.

Referenced by PhotoDescEdit().

§ buffer

QPixmap* PhotoDescEdit::buffer
private

buffer we'll iteratively update and use for the label which shows the animation taking place

Definition at line 99 of file photoDescEdit.h.

Referenced by animate(), PhotoDescEdit(), and ~PhotoDescEdit().

§ currentTime

QTime PhotoDescEdit::currentTime
private

Definition at line 128 of file photoDescEdit.h.

Referenced by animate().

§ delay

int PhotoDescEdit::delay
private

Definition at line 118 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ dropShadowsEnabled

bool PhotoDescEdit::dropShadowsEnabled
private

are drop shadows enabled in windows (xp)?

Definition at line 124 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ finalPos

QPoint PhotoDescEdit::finalPos
private

Definition at line 75 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ idealTextSize

int PhotoDescEdit::idealTextSize
private

ultimate text dimension

Definition at line 81 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ imageLarge

QImage* PhotoDescEdit::imageLarge
private

beginning and end pixmaps

Definition at line 69 of file photoDescEdit.h.

Referenced by animate(), PhotoDescEdit(), and ~PhotoDescEdit().

§ initDelay

int PhotoDescEdit::initDelay
private


Animation Stuff

Definition at line 118 of file photoDescEdit.h.

Referenced by disappear(), and PhotoDescEdit().

§ initPos

QPoint PhotoDescEdit::initPos
private

Definition at line 75 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ lastTime

QTime PhotoDescEdit::lastTime
private

Definition at line 128 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ left

int PhotoDescEdit::left
private

bounaries of entire animation

Definition at line 78 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ mainGrid

Q3GridLayout* PhotoDescEdit::mainGrid
private


Definition at line 91 of file photoDescEdit.h.

Referenced by PhotoDescEdit().

§ minDelay

int PhotoDescEdit::minDelay
private

Definition at line 118 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ mode

int PhotoDescEdit::mode
private

Definition at line 121 of file photoDescEdit.h.

Referenced by animate(), disappear(), hide(), and PhotoDescEdit().

§ photoDesc

TextEdit* PhotoDescEdit::photoDesc
private

photo description

Definition at line 113 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ ppw

PhotoPreviewWidget* PhotoDescEdit::ppw
private

photo preview widget pointer

Definition at line 66 of file photoDescEdit.h.

Referenced by disappear(), hide(), and PhotoDescEdit().

§ right

int PhotoDescEdit::right
private

Definition at line 78 of file photoDescEdit.h.

Referenced by PhotoDescEdit().

§ smallHeight

int PhotoDescEdit::smallHeight
private

Definition at line 88 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ smallWidth

int PhotoDescEdit::smallWidth
private

small size

Definition at line 88 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ staticFrame

QWidget* PhotoDescEdit::staticFrame
private

frame which contains static widget

Definition at line 107 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ staticGrid

Q3GridLayout* PhotoDescEdit::staticGrid
private


Static Widgets

grid static widgets placed in

Definition at line 104 of file photoDescEdit.h.

Referenced by PhotoDescEdit().

§ staticPhoto

QLabel* PhotoDescEdit::staticPhoto
private

photo being displayed

Definition at line 110 of file photoDescEdit.h.

Referenced by PhotoDescEdit().

§ step

int PhotoDescEdit::step
private

Definition at line 118 of file photoDescEdit.h.

Referenced by animate(), disappear(), and PhotoDescEdit().

§ textRectangle

QImage* PhotoDescEdit::textRectangle
private

text area widget used to computing painting surface

Definition at line 72 of file photoDescEdit.h.

Referenced by animate(), disappear(), PhotoDescEdit(), and ~PhotoDescEdit().

§ timer

QTimer* PhotoDescEdit::timer
private

Definition at line 127 of file photoDescEdit.h.

Referenced by animate(), PhotoDescEdit(), and ~PhotoDescEdit().

§ top

int PhotoDescEdit::top
private

Definition at line 78 of file photoDescEdit.h.

Referenced by animate(), and PhotoDescEdit().

§ useAnimation

bool PhotoDescEdit::useAnimation
private

actually animate the opening/closing process?

Definition at line 63 of file photoDescEdit.h.

Referenced by disappear(), and PhotoDescEdit().


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