17 #include <qapplication.h> 19 #include <q3textedit.h> 22 #include <Q3GridLayout> 23 #include <QFocusEvent> 25 #include <Q3PopupMenu> 27 #include <QDesktopWidget> 34 #include "../config.h" 35 #include "../backend/photo.h" 36 #include "../backend/tools/imageTools.h" 41 #if defined(Q_OS_MACX) 42 #include "/Developer/Headers/FlatCarbon/MacWindows.h" 49 #define SPI_GETDROPSHADOW 0x1024 50 #define SPI_SETDROPSHADOW 0x1025 55 QWidget* parent,
const char* name ) :
57 Qt::WStyle_Customize |
58 #if defined(Q_OS_MACX)
61 Qt::WStyle_NoBorder | Qt::WType_Popup )
66 #if defined(Q_OS_MACX) 67 ChangeWindowAttributes( (OpaqueWindowPtr*)winId(), kWindowNoShadowAttribute, kWindowNoAttributes );
74 SystemParametersInfo( SPI_SETDROPSHADOW, 0, NULL, 0 );
80 setWindowFlags(Qt::WNoAutoErase);
85 QRect appRec = qApp->mainWidget()->frameGeometry();
86 int finalWidth, finalHeight;
87 int actualFinalWidth, actualFinalHeight;
103 QFontMetrics fm( qApp->font() );
106 if(finalHeight + idealTextSize + 2*
EDIT_MARGIN > appRec.height() )
108 finalHeight = appRec.height() - idealTextSize - 2*
EDIT_MARGIN;
115 finalHeight = (appRec.height() - 2*
EDIT_MARGIN) / 2;
117 idealTextSize = finalHeight;
121 actualFinalHeight = finalHeight + idealTextSize + 2*
EDIT_MARGIN;
124 #if defined(Q_OS_MACX) 125 actualFinalHeight+=2;
142 QString calibrationString( qApp->translate(
"PhotoDescEdit",
"This is the photo description calibration string.") );
143 QFontMetrics fm( qApp->font() );
145 if(finalWidth + idealTextSize + 2*
EDIT_MARGIN > appRec.width() )
147 finalWidth = appRec.width() - idealTextSize - 2*
EDIT_MARGIN;
156 idealTextSize = finalWidth;
159 actualFinalWidth = finalWidth + idealTextSize + 2*
EDIT_MARGIN;
165 int fullWidth, fullHeight;
169 scaled(finalWidth,finalHeight, Qt::IgnoreAspectRatio ));
178 int actualWidth, actualHeight;
180 paddedSSImage.width(), paddedSSImage.height(),
181 actualWidth, actualHeight );
184 int leftOffset = (paddedSSImage.width() - actualWidth) / 2;
185 int topOffset = (paddedSSImage.height() - actualHeight) / 2;
186 QImage SSImage( actualWidth, actualHeight, paddedSSImage.depth() );
189 for(x=0; x<actualWidth; x++)
191 for(y=0; y<actualHeight; y++)
193 SSImage.setPixel( x, y, QColor(Qt::red).rgb() );
194 SSImage.setPixel( x, y, paddedSSImage.pixel(x+leftOffset, y+topOffset) );
197 imageLarge =
new QImage(SSImage.smoothScale(finalWidth,finalHeight, Qt::IgnoreAspectRatio ));
209 tmpTextEdit.setLineWidth( 0 );
210 tmpTextEdit.setMargin( 0 );
211 tmpTextEdit.setMidLineWidth( 0 );
212 tmpTextEdit.setFrameStyle( Q3Frame::NoFrame | Q3Frame::Plain );
214 tmpTextEdit.setWrapPolicy( Q3TextEdit::AtWordOrDocumentBoundary );
215 tmpTextEdit.constPolish();
216 tmpTextEdit.polish();
218 tmpTextEdit.setWordWrap( Q3TextEdit::FixedPixelWidth );
220 tmpTextEdit.setWrapColumnOrWidth( finalWidth );
223 tmpTextEdit.updateScrollBars();
224 tmpTextEdit.constPolish();
225 tmpTextEdit.polish();
229 if(tmpTextEdit.lines() > 4)
231 tmpTextEdit.setWrapColumnOrWidth( finalWidth - tmpTextEdit.verticalScrollBar()->width() );
232 tmpTextEdit.updateScrollBars();
233 tmpTextEdit.constPolish();
234 tmpTextEdit.polish();
239 QFontMetrics fm( qApp->font() );
240 if(tmpTextEdit.lines() >
idealTextSize / (fm.leading() + fm.height()) )
242 tmpTextEdit.setWrapColumnOrWidth(
idealTextSize - tmpTextEdit.verticalScrollBar()->width() );
243 tmpTextEdit.updateScrollBars();
244 tmpTextEdit.constPolish();
245 tmpTextEdit.polish();
251 textRectangle =
new QImage( QPixmap::grabWidget(&tmpTextEdit).convertToImage() );
262 finalPos = QPoint( initCenterX - actualFinalWidth/2, initCenterY - actualFinalHeight/2 );
265 if(
finalPos.x() + actualFinalWidth > appRec.x() + appRec.width() )
266 finalPos.setX( appRec.x() + appRec.width()- actualFinalWidth );
270 if(
finalPos.y() + actualFinalHeight > appRec.y() + appRec.height() )
271 finalPos.setY( appRec.y() + appRec.height()- actualFinalHeight );
280 backgroundImage =
new QPixmap( QPixmap::grabWindow(QApplication::desktop()->winId(),
282 right-
left, bottom-top) );
283 setBackgroundMode( Qt::NoBackground );
289 buffer =
new QPixmap( backgroundImage->width(), backgroundImage->height() );
291 mainGrid =
new Q3GridLayout(
this, 1, 2, 0 );
297 staticFrame->setBackgroundMode( Qt::NoBackground );
302 staticPhoto->setBackgroundMode( Qt::NoBackground );
307 photoDesc->setWrapPolicy( Q3TextEdit::AtWordOrDocumentBoundary );
308 photoDesc->setFrameStyle( Q3Frame::NoFrame );
312 photoDesc->setFrameStyle( QFrame::StyledPanel | Q3Frame::Plain );
315 connect(
photoDesc, SIGNAL( finished() ),
322 QColor darkBlue(35, 75, 139);
323 bw1->setPaletteBackgroundColor( darkBlue );
324 bw2->setPaletteBackgroundColor( darkBlue );
325 bw3->setPaletteBackgroundColor( darkBlue );
326 bw4->setPaletteBackgroundColor( darkBlue );
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 );
358 staticGrid->addMultiCellWidget( bw1, 0, 0, 0, 3 );
361 staticGrid->addMultiCellWidget( bw4, 2, 2, 0, 3 );
382 timer =
new QTimer();
383 connect(
timer, SIGNAL(timeout()),
this, SLOT(
animate()) );
413 int inc = (int)(ms/(
delay+1));
426 double alpha = ((double)
step) / 100.0;
430 QColor darkBlue(35, 75, 139);
449 QPainter bufferPainter(
buffer );
455 bufferPainter.fillRect( newX -
left,
467 bufferPainter.fillRect( newX -
left, newY -
top,
480 QPixmap(
imageLarge->scaled( imageW, imageH ) ) );
511 #if defined(Q_OS_WIN) 515 SystemParametersInfo( SPI_SETDROPSHADOW, 0, NULL, 0 );
520 qApp->mainWidget()->repaint(
false);
560 Q3IconViewItem* item = iconView->findItem( iconView->viewport()->mapFromGlobal( QCursor::pos() )+=QPoint( iconView->contentsX(), iconView->contentsY() ) );
561 if(item != NULL && item !=
ppw )
574 setHScrollBarMode( Q3ScrollView::AlwaysOff );
575 setTextFormat( Qt::PlainText );
582 repaint( rect(),
false );
588 if( e->key() == Qt::Key_Escape )
593 else if( (e->state() & Qt::ControlModifier) && e->key() == Qt::Key_A )
599 Q3TextEdit::keyPressEvent( e );
614 connect( ((QObject*)
contextMenu), SIGNAL(aboutToHide()),
622 disconnect( ((QObject*)
contextMenu), SIGNAL(aboutToHide()),
QPixmap * buffer
buffer we'll iteratively update and use for the label which shows the animation taking place ...
QString getImageFilename()
Gets the image filename.
QWidget * staticFrame
frame which contains static widget
QImage * textRectangle
text area widget used to computing painting surface
TextEdit(QWidget *parent=0, const char *name=0)
int idealTextSize
ultimate text dimension
QString getThumbnailFilename()
Gets the thumbnail filename.
Q3GridLayout * staticGrid
Static Widgets
TextEdit * photoDesc
photo description
QImage * imageLarge
beginning and end pixmaps
int initDelay
Animation Stuff
void setDescription(QString val)
Sets the description.
Extension of iconview, used to list all photos in a subalbum. supports drag-n-drop within iconview...
Q3PopupMenu * createPopupMenu(const QPoint &pos)
void disappear()
this method is called by the acceptAndClose and rejectAndClose slots and actually initiates the closi...
QLabel * staticPhoto
photo being displayed
QLabel * animationLabel
Animating Widgets
int left
bounaries of entire animation
void animate()
this method is iteratively called and animates the opening/closing of the image
QString getSlideshowFilename()
Gets the slideshow filename.
void focusOutEvent(QFocusEvent *)
PhotoPreviewWidget * ppw
photo preview widget pointer
void keyPressEvent(QKeyEvent *e)
QString getDescription()
Gets the description.
PhotoDescEdit(PhotoPreviewWidget *ppw, bool useAnimation, QWidget *parent=0, const char *name=0)
QPixmap * backgroundImage
this pixmap contains the screen contents for the entire region which we will be painting on top of ...
Q3PopupMenu * contextMenu
bool dropShadowsEnabled
are drop shadows enabled in windows (xp)?
bool useAnimation
actually animate the opening/closing process?