AlbumShaper  1.0a3
scaledPreviewInterface.cpp
Go to the documentation of this file.
00001 //==============================================
00002 //  copyright            : (C) 2003-2005 by Will Stokes
00003 //==============================================
00004 //  This program is free software; you can redistribute it 
00005 //  and/or modify it under the terms of the GNU General 
00006 //  Public License as published by the Free Software 
00007 //  Foundation; either version 2 of the License, or  
00008 //  (at your option) any later version.         
00009 //==============================================
00010 
00011 //Systemwide includes
00012 #include <qapplication.h>
00013 
00014 //Projectwide includes
00015 #include "scaledPreviewInterface.h"
00016 #include "../../backend/tools/imageTools.h"
00017 
00018 //==============================================
00019 ScaledPreviewInterface::ScaledPreviewInterface( QString imageFilename, 
00020                                                 QWidget *parent, const char* name ) : 
00021                                                 SplitViewInterface (parent, name )
00022 {                  
00023   //store original image dimensions
00024   getImageSize( imageFilename, origImageSize );
00025   
00026   //resize image to current screen size for faster
00027   //scaling during resize events
00028   QRect screenSize = qApp->desktop()->availableGeometry();
00029   scaleImage( imageFilename, fullScreenImage, screenSize.width()/2, screenSize.height()/2 );
00030   //-----
00031 }
00032 //==============================================
00033 void ScaledPreviewInterface::resizeEvent( QResizeEvent * )
00034 {
00035   //if image has yet to be set return
00036   if( fullScreenImage.isNull() ) return;
00037 
00038   //generate orig image
00039   //set adjusted image to null so repain won't occur until it is reset
00040   setImages( fullScreenImage.scale( width(), height(), QImage::ScaleMin ),
00041              QImage() );
00042   
00043   //emit resized signal
00044   emit resized();
00045 }
00046 //==============================================
00047 QSize ScaledPreviewInterface::sizeHint() const
00048 {
00049   //a 500x375 is 4:3 aspect ratio which is fairly typical
00050   //we'll clamp the hight to 375 in the situation where an image is mucher taller than wide
00051   //(and hence computed height would be so big window won't fit on screen)  
00052   int w = 500;
00053   int h = QMIN( 375, (w*origImageSize.height())/origImageSize.width() );
00054 
00055   return QSize( w,h );
00056 }
00057 //==============================================
00058 QSize ScaledPreviewInterface::minimumSizeHint() const
00059 {
00060   QSize baseMinSize = SplitViewInterface::minimumSizeHint();
00061   int w = baseMinSize.width();
00062   int h = QMAX( baseMinSize.height(), (w*origImageSize.height())/origImageSize.width() );
00063   return QSize( w, h );
00064 }
00065 //==============================================