Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

StatusWidget Class Reference

#include <statusWidget.h>

Inheritance diagram for StatusWidget:

Inheritance graph
[legend]
Collaboration diagram for StatusWidget:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 StatusWidget (QWidget *parent=0, const char *name=0)
 Creates layout.
 ~StatusWidget ()
 Deletes all objects.
void showProgressBar (QString message, int numSteps)
 Initializes the progress bar.
void updateProgress (int progress, QString newMessage=QString::null)
 Updates the progress bar.
int currentProgress ()
 Returns current progress in steps.
void incrementProgress ()
 Updates the progress bar by one step.
void setStatus (QString message)
 Update message.
void checkForUpdates ()
 Check for updates.
void removeUpdatesIcon ()
 Remove program updates icon.
void grabInput ()
void releaseInput ()

Private Slots

void fileFetched (bool error)
 called once a file is fetched from the network
void removeStatus ()
 Unset message.

Private Attributes

QGridLayout * grid
 Layout widgets placed in.
QLabelmessage
QProgressBar * progressBar
int curStep
QTimer * timer
QHttp http
 http object for fetching releases file, used to check to see if installed copy is up to date
ClickableLabelupdateAvailable
 Update available label.

Constructor & Destructor Documentation

StatusWidget::StatusWidget QWidget parent = 0,
const char *  name = 0
 

Creates layout.

Definition at line 36 of file statusWidget.cpp.

References checkForUpdates(), curStep, fileFetched(), grid, http, message, progressBar, removeStatus(), timer, updateAvailable, and WIDGET_SPACING.

00037                                             : QWidget(parent,name)
00038 {
00039  //create status message
00040   message = new QLabel( this );
00041   message->setText( "" );
00042   
00043   //create timer object and setup signals
00044   timer = new QTimer();
00045   connect(timer, SIGNAL(timeout()), this, SLOT(removeStatus()) );
00046 
00047   //create progress message and bar
00048   progressBar = new QProgressBar( this );
00049   progressBar->setCenterIndicator(true);
00050   progressBar->hide();
00051   curStep = 0;
00052 
00053   //-----------------------------------------------------------------
00054   //setup http object to check for updates, only check for updates if they are enabled
00055   updateAvailable = NULL;
00056   http.setHost( "albumshaper.sourceforge.net" );
00057   connect( &http, SIGNAL(done(bool)), this, SLOT(fileFetched(bool)) );
00058   if(((Window*)parentWidget())->getConfig()->getBool( "alerts", "showSoftwareUpdateAlerts"))
00059   {
00060     checkForUpdates();
00061   }
00062   //-----------------------------------------------------------------
00063   //place progress frame and status message in main grid
00064   grid = new QGridLayout( this, 1, 6, 0 );
00065   grid->setSpacing(WIDGET_SPACING);
00066   grid->setColSpacing( 0, WIDGET_SPACING );
00067   grid->addWidget( message, 0, 1, Qt::AlignVCenter );
00068   grid->addWidget( progressBar, 0, 2, Qt::AlignVCenter );
00069   grid->setColStretch( 3, 1 );
00070 
00071   //PLATFORM_SPECIFIC_CODE
00072   //mac os x puts in a size grip that can interfere with the updates icon, in order
00073   //to avoid this we manually place the size grip ourselves
00074   //windows users expect a grip too, but qt doesn't put one in by default. we'll add
00075   //it for them too. :-)
00076   #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
00077   QSizeGrip* sizeGrip = new QSizeGrip( this );
00078   grid->addWidget( sizeGrip, 0, 5, Qt::AlignBottom );
00079   #endif
00080 
00081 }

StatusWidget::~StatusWidget  ) 
 

Deletes all objects.

Definition at line 83 of file statusWidget.cpp.

References timer.

00084 {
00085   delete timer;
00086   timer = NULL;
00087 }


Member Function Documentation

void StatusWidget::checkForUpdates  ) 
 

Check for updates.

Definition at line 226 of file statusWidget.cpp.

References http, and updateAvailable.

Referenced by StatusWidget().

00227 {
00228   if(updateAvailable != NULL)
00229     return;
00230 
00231   //attempt to get releases list from website. this lets us find out if this
00232   //copy of Album Shaper is outdated
00233   http.get( "/webService/releases.xml");
00234 }

int StatusWidget::currentProgress  ) 
 

Returns current progress in steps.

Definition at line 114 of file statusWidget.cpp.

00115 {
00116   return curStep;
00117 }

void StatusWidget::fileFetched bool  error  )  [private, slot]
 

called once a file is fetched from the network

Definition at line 144 of file statusWidget.cpp.

References ALBUMSHAPER_VERSION, grid, http, IMAGE_PATH, TEMP_DIR, and updateAvailable.

Referenced by StatusWidget().

00145 {
00146   //------------------------------------------------------------
00147   //if unable to get file bail
00148   if(error)
00149   {
00150     return;
00151   }
00152   //------------------------------------------------------------
00153   //write releases to temp file
00154   QFile fetchedDoc( TEMP_DIR + QString("/releases.xml") );
00155   if(fetchedDoc.open(IO_WriteOnly))
00156   {
00157     //----------------------------
00158     //write to file
00159     QTextStream stream( &fetchedDoc );
00160     stream.setEncoding( QTextStream::UnicodeUTF8 );
00161     stream << QString( http.readAll() );
00162     fetchedDoc.close();
00163     //----------------------------
00164     //parse xml file, construct string list of releases
00165     //open file, bail if unable to
00166     if( !fetchedDoc.open( IO_ReadOnly ) )
00167     {
00168       return;
00169     }
00170 
00171     //parse dom
00172     QDomDocument xmlDom;
00173     if( !xmlDom.setContent( &fetchedDoc ) )
00174     {
00175       fetchedDoc.close();
00176       return;
00177     }
00178 
00179     //close file
00180     fetchedDoc.close();
00181 
00182     //construct stringlist of releases
00183     //actually, only get the first release since we don't need the others to determine if we
00184     //are out of date
00185 
00186     QStringList releases;
00187     QDomElement root = xmlDom.documentElement();
00188     QDomNode node = root.firstChild();
00189     QDomText val;
00190     bool thisVersionFound = false;
00191     while( !node.isNull() )
00192     {
00193       if( node.isElement() && node.nodeName() == "release" )
00194       {
00195         val = node.firstChild().toText();
00196         if(!val.isNull())
00197         {
00198           //append release #
00199           releases.append( QString(val.nodeValue()) );
00200 
00201           //is release this version?
00202           if( QString(val.nodeValue()).compare( QString(ALBUMSHAPER_VERSION) ) == 0 )
00203             thisVersionFound = true;
00204         }
00205       }
00206       node = node.nextSibling();
00207     }
00208 
00209     //compare first release to this release, if strings not equal then we're outdated,
00210     //update album shaper icon and start grabbing changelogs
00211     if(thisVersionFound && releases.first().compare( QString(ALBUMSHAPER_VERSION) ) != 0)
00212     {
00213       ClickableLabel* uA = new ClickableLabel( this );
00214       uA->setMovie( QMovie( QString(IMAGE_PATH)+"miscImages/updateAvailable.mng") );
00215       QToolTip::add( uA, tr("Your copy of Album Shaper is not up to date! Click here for details") );
00216       grid->addWidget( uA, 0, 4, Qt::AlignVCenter );
00217       connect( uA, SIGNAL(clicked()),
00218                     ((Window*)parentWidget())->getTitle(), SLOT(aboutProgram()) );
00219       uA->show();\
00220       updateAvailable = uA;
00221     }
00222   }
00223   //------------------------------------------------------------
00224 }

void StatusWidget::grabInput  ) 
 

Definition at line 242 of file statusWidget.cpp.

Referenced by EditingInterface::adjustGrain(), EditingInterface::applyEffect(), EditingInterface::colorBalance(), EditingInterface::crop(), EditingInterface::enhanceContrast(), EditingInterface::finishCorrectTilt(), TitleWidget::loadAlbum(), EditingInterface::removeRedeye(), EditingInterface::revertCurrentPhoto(), EditingInterface::rotateFlip(), and EditingInterface::tuneLevels().

00243 {
00244   grabKeyboard();
00245   grabMouse(); 
00246 }

void StatusWidget::incrementProgress  ) 
 

Updates the progress bar by one step.

Definition at line 119 of file statusWidget.cpp.

References curStep, and progressBar.

Referenced by blackWhiteEffect(), correctImageTilt(), embossEffect(), enhanceImageContrast(), Album::exportSubalbumImages(), findRegionOfInterest(), Subalbum::importFromDisk(), improveColorBalance(), mosaicEffect(), oilPaintingEffect(), Album::removeStagnantOrigFiles(), Album::reorderSubalbumImages(), and sepiaEffect().

00120 {
00121   curStep++;
00122   progressBar->setProgress( curStep );
00123 }

void StatusWidget::releaseInput  ) 
 

Definition at line 248 of file statusWidget.cpp.

Referenced by EditingInterface::adjustGrain(), EditingInterface::applyEffect(), EditingInterface::colorBalance(), EditingInterface::crop(), EditingInterface::enhanceContrast(), EditingInterface::finishCorrectTilt(), TitleWidget::loadAlbum(), EditingInterface::removeRedeye(), EditingInterface::revertCurrentPhoto(), EditingInterface::rotateFlip(), and EditingInterface::tuneLevels().

00249 {
00250   releaseKeyboard();
00251   releaseMouse();
00252 }

void StatusWidget::removeStatus  )  [private, slot]
 

Unset message.

Definition at line 138 of file statusWidget.cpp.

References message.

Referenced by StatusWidget().

00139 {
00140   //set status message to empty string
00141   message->setText( "" );
00142 }

void StatusWidget::removeUpdatesIcon  ) 
 

Remove program updates icon.

Definition at line 236 of file statusWidget.cpp.

References updateAvailable.

00237 {
00238   delete updateAvailable;
00239   updateAvailable = NULL;
00240 }

void StatusWidget::setStatus QString  message  ) 
 

Update message.

Definition at line 125 of file statusWidget.cpp.

References progressBar, and timer.

Referenced by SubalbumWidget::addImageAction(), EditingInterface::applyEffect(), correctImageTilt(), enhanceImageContrast(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), Album::exportToDisk(), Album::importFromDisk(), improveColorBalance(), removeRedeyeRegions(), SubalbumWidget::rotate270ImageAction(), and SubalbumWidget::rotate90ImageAction().

00126 {
00127   timer->stop();
00128 
00129   //hide progress bar
00130   progressBar->hide();
00131 
00132   //update status message
00133   this->message->setText( message );
00134 
00135   timer->start( 2000, TRUE );
00136 }

void StatusWidget::showProgressBar QString  message,
int  numSteps
 

Initializes the progress bar.

Definition at line 89 of file statusWidget.cpp.

References curStep, progressBar, and timer.

Referenced by SubalbumWidget::addImageAction(), EditingInterface::applyEffect(), blackWhiteEffect(), correctImageTilt(), embossEffect(), enhanceImageContrast(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), Album::exportToDisk(), Album::importFromDisk(), improveColorBalance(), mosaicEffect(), oilPaintingEffect(), removeRedeyeRegions(), SubalbumWidget::rotate270ImageAction(), SubalbumWidget::rotate90ImageAction(), and sepiaEffect().

00090 {
00091   //make sure timer is stopped so progress mess is never hidden
00092   //this can occur if a new event is begun before the previous events message is removed after default delay
00093   timer->stop();
00094   
00095   //setup progress bar and show it
00096   this->message->setText( message );
00097   progressBar->setProgress( 0, numSteps );
00098   progressBar->show();
00099   curStep = 0;
00100 }

void StatusWidget::updateProgress int  progress,
QString  newMessage = QString::null
 

Updates the progress bar.

Definition at line 102 of file statusWidget.cpp.

References curStep, message, and progressBar.

Referenced by SubalbumWidget::addImageAction(), Album::exportCompressedWebAlbum(), Album::exportLargeImages(), SubalbumWidget::rotate270ImageAction(), and SubalbumWidget::rotate90ImageAction().

00103 {
00104   curStep = progress;
00105   progressBar->setProgress( progress );
00106 
00107   //update message if provided
00108   if(newMessage != QString::null)
00109   {
00110     this->message->setText( newMessage );
00111   }
00112 }


Member Data Documentation

int StatusWidget::curStep [private]
 

Definition at line 80 of file statusWidget.h.

Referenced by incrementProgress(), showProgressBar(), StatusWidget(), and updateProgress().

QGridLayout* StatusWidget::grid [private]
 

Layout widgets placed in.

Definition at line 76 of file statusWidget.h.

Referenced by fileFetched(), and StatusWidget().

QHttp StatusWidget::http [private]
 

http object for fetching releases file, used to check to see if installed copy is up to date

Definition at line 85 of file statusWidget.h.

Referenced by checkForUpdates(), fileFetched(), and StatusWidget().

QLabel* StatusWidget::message [private]
 

Definition at line 78 of file statusWidget.h.

Referenced by removeStatus(), StatusWidget(), and updateProgress().

QProgressBar* StatusWidget::progressBar [private]
 

Definition at line 79 of file statusWidget.h.

Referenced by incrementProgress(), setStatus(), showProgressBar(), StatusWidget(), and updateProgress().

QTimer* StatusWidget::timer [private]
 

Definition at line 82 of file statusWidget.h.

Referenced by setStatus(), showProgressBar(), StatusWidget(), and ~StatusWidget().

ClickableLabel* StatusWidget::updateAvailable [private]
 

Update available label.

Definition at line 88 of file statusWidget.h.

Referenced by checkForUpdates(), fileFetched(), removeUpdatesIcon(), and StatusWidget().


The documentation for this class was generated from the following files:
Generated on Wed May 4 11:11:22 2005 for AlbumShaper by  doxygen 1.3.9.1