#include <statusWidget.h>
Inheritance diagram for StatusWidget:
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. | |
QLabel * | message |
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 | |
ClickableLabel * | updateAvailable |
Update available label. |
|
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 message->setFont( QFont( "Times", 12, QFont::Bold ) ); 00043 00044 //create timer object and setup signals 00045 timer = new QTimer(); 00046 connect(timer, SIGNAL(timeout()), this, SLOT(removeStatus()) ); 00047 00048 //create progress message and bar 00049 progressBar = new QProgressBar( this ); 00050 progressBar->setCenterIndicator(true); 00051 progressBar->hide(); 00052 curStep = 0; 00053 00054 //----------------------------------------------------------------- 00055 //setup http object to check for updates, only check for updates if they are enabled 00056 updateAvailable = NULL; 00057 http.setHost( "albumshaper.sourceforge.net" ); 00058 connect( &http, SIGNAL(done(bool)), this, SLOT(fileFetched(bool)) ); 00059 if(((Window*)parentWidget())->getConfig()->getBool( "alerts", "showSoftwareUpdateAlerts")) 00060 { 00061 checkForUpdates(); 00062 } 00063 //----------------------------------------------------------------- 00064 //place progress frame and status message in main grid 00065 grid = new QGridLayout( this, 1, 6, 0 ); 00066 grid->setSpacing(WIDGET_SPACING); 00067 grid->setColSpacing( 0, WIDGET_SPACING ); 00068 grid->addWidget( message, 0, 1, Qt::AlignVCenter ); 00069 grid->addWidget( progressBar, 0, 2, Qt::AlignVCenter ); 00070 grid->setColStretch( 3, 1 ); 00071 00072 //PLATFORM_SPECIFIC_CODE 00073 //mac os x puts in a size grip that can interfere with the updates icon, in order 00074 //to avoid this we manually place the size grip ourselves 00075 //windows users expect a grip too, but qt doesn't put one in by default. we'll add 00076 //it for them too. :-) 00077 #if defined(Q_OS_MACX) || defined(Q_OS_WIN) 00078 QSizeGrip* sizeGrip = new QSizeGrip( this ); 00079 grid->addWidget( sizeGrip, 0, 5, Qt::AlignBottom ); 00080 #endif 00081 00082 }
|
|
Deletes all objects.
Definition at line 84 of file statusWidget.cpp. References timer. 00085 { 00086 delete timer; 00087 timer = NULL; 00088 }
|
|
Check for updates.
Definition at line 227 of file statusWidget.cpp. References http, and updateAvailable. Referenced by StatusWidget(). 00228 { 00229 if(updateAvailable != NULL) 00230 return; 00231 00232 //attempt to get releases list from website. this lets us find out if this 00233 //copy of Album Shaper is outdated 00234 http.get( "/webService/releases.xml"); 00235 }
|
|
Returns current progress in steps.
Definition at line 115 of file statusWidget.cpp. 00116 {
00117 return curStep;
00118 }
|
|
called once a file is fetched from the network
Definition at line 145 of file statusWidget.cpp. References ALBUMSHAPER_VERSION, grid, http, IMAGE_PATH, TEMP_DIR, and updateAvailable. Referenced by StatusWidget(). 00146 { 00147 //------------------------------------------------------------ 00148 //if unable to get file bail 00149 if(error) 00150 { 00151 return; 00152 } 00153 //------------------------------------------------------------ 00154 //write releases to temp file 00155 QFile fetchedDoc( TEMP_DIR + QString("/releases.xml") ); 00156 if(fetchedDoc.open(IO_WriteOnly)) 00157 { 00158 //---------------------------- 00159 //write to file 00160 QTextStream stream( &fetchedDoc ); 00161 stream.setEncoding( QTextStream::UnicodeUTF8 ); 00162 stream << QString( http.readAll() ); 00163 fetchedDoc.close(); 00164 //---------------------------- 00165 //parse xml file, construct string list of releases 00166 //open file, bail if unable to 00167 if( !fetchedDoc.open( IO_ReadOnly ) ) 00168 { 00169 return; 00170 } 00171 00172 //parse dom 00173 QDomDocument xmlDom; 00174 if( !xmlDom.setContent( &fetchedDoc ) ) 00175 { 00176 fetchedDoc.close(); 00177 return; 00178 } 00179 00180 //close file 00181 fetchedDoc.close(); 00182 00183 //construct stringlist of releases 00184 //actually, only get the first release since we don't need the others to determine if we 00185 //are out of date 00186 00187 QStringList releases; 00188 QDomElement root = xmlDom.documentElement(); 00189 QDomNode node = root.firstChild(); 00190 QDomText val; 00191 bool thisVersionFound = false; 00192 while( !node.isNull() ) 00193 { 00194 if( node.isElement() && node.nodeName() == "release" ) 00195 { 00196 val = node.firstChild().toText(); 00197 if(!val.isNull()) 00198 { 00199 //append release # 00200 releases.append( QString(val.nodeValue()) ); 00201 00202 //is release this version? 00203 if( QString(val.nodeValue()).compare( QString(ALBUMSHAPER_VERSION) ) == 0 ) 00204 thisVersionFound = true; 00205 } 00206 } 00207 node = node.nextSibling(); 00208 } 00209 00210 //compare first release to this release, if strings not equal then we're outdated, 00211 //update album shaper icon and start grabbing changelogs 00212 if(thisVersionFound && releases.first().compare( QString(ALBUMSHAPER_VERSION) ) != 0) 00213 { 00214 ClickableLabel* uA = new ClickableLabel( this ); 00215 uA->setMovie( QMovie( QString(IMAGE_PATH)+"miscImages/updateAvailable.mng") ); 00216 QToolTip::add( uA, tr("Your copy of Album Shaper is not up to date! Click here for details") ); 00217 grid->addWidget( uA, 0, 4, Qt::AlignVCenter ); 00218 connect( uA, SIGNAL(clicked()), 00219 ((Window*)parentWidget())->getTitle(), SLOT(aboutProgram()) ); 00220 uA->show();\ 00221 updateAvailable = uA; 00222 } 00223 } 00224 //------------------------------------------------------------ 00225 }
|
|
Definition at line 243 of file statusWidget.cpp. Referenced by EditingInterface::adjustGrain(), EditingInterface::applyEffect(), EditingInterface::colorBalance(), EditingInterface::crop(), EditingInterface::enhanceContrast(), EditingInterface::finishCorrectTilt(), EditingInterface::removeRedeye(), EditingInterface::revertCurrentPhoto(), EditingInterface::rotateFlip(), and EditingInterface::tuneLevels(). 00244 { 00245 grabKeyboard(); 00246 grabMouse(); 00247 }
|
|
Updates the progress bar by one step.
Definition at line 120 of file statusWidget.cpp. References curStep, and progressBar. Referenced by blackWhiteEffect(), correctImageTilt(), embossEffect(), enhanceImageContrast(), Album::exportSubalbumImages(), findRegionOfInterest(), Subalbum::importFromDisk(), improveColorBalance(), oilPaintingEffect(), Album::removeStagnantOrigFiles(), Album::reorderSubalbumImages(), and sepiaEffect(). 00121 { 00122 curStep++; 00123 progressBar->setProgress( curStep ); 00124 }
|
|
Definition at line 249 of file statusWidget.cpp. Referenced by EditingInterface::adjustGrain(), EditingInterface::applyEffect(), EditingInterface::colorBalance(), EditingInterface::crop(), EditingInterface::enhanceContrast(), EditingInterface::finishCorrectTilt(), EditingInterface::removeRedeye(), EditingInterface::revertCurrentPhoto(), EditingInterface::rotateFlip(), and EditingInterface::tuneLevels(). 00250 { 00251 releaseKeyboard(); 00252 releaseMouse(); 00253 }
|
|
Unset message.
Definition at line 139 of file statusWidget.cpp. References message. Referenced by StatusWidget(). 00140 { 00141 //set status message to empty string 00142 message->setText( "" ); 00143 }
|
|
Remove program updates icon.
Definition at line 237 of file statusWidget.cpp. References updateAvailable. 00238 { 00239 delete updateAvailable; 00240 updateAvailable = NULL; 00241 }
|
|
Update message.
Definition at line 126 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(). 00127 { 00128 timer->stop(); 00129 00130 //hide progress bar 00131 progressBar->hide(); 00132 00133 //update status message 00134 this->message->setText( message ); 00135 00136 timer->start( 2000, TRUE ); 00137 }
|
|
Initializes the progress bar.
Definition at line 90 of file statusWidget.cpp. References curStep, progressBar, and timer. Referenced by SubalbumWidget::addImageAction(), blackWhiteEffect(), correctImageTilt(), embossEffect(), enhanceImageContrast(), TitleWidget::exportLargeImages(), TitleWidget::exportSmallWebGallery(), Album::exportToDisk(), Album::importFromDisk(), improveColorBalance(), oilPaintingEffect(), removeRedeyeRegions(), SubalbumWidget::rotate270ImageAction(), SubalbumWidget::rotate90ImageAction(), and sepiaEffect(). 00091 { 00092 //make sure timer is stopped so progress mess is never hidden 00093 //this can occur if a new event is begun before the previous events message is removed after default delay 00094 timer->stop(); 00095 00096 //setup progress bar and show it 00097 this->message->setText( message ); 00098 progressBar->setProgress( 0, numSteps ); 00099 progressBar->show(); 00100 curStep = 0; 00101 }
|
|
Updates the progress bar.
Definition at line 103 of file statusWidget.cpp. References curStep, message, and progressBar. Referenced by SubalbumWidget::addImageAction(), Album::exportCompressedWebAlbum(), Album::exportLargeImages(), SubalbumWidget::rotate270ImageAction(), and SubalbumWidget::rotate90ImageAction(). 00104 { 00105 curStep = progress; 00106 progressBar->setProgress( progress ); 00107 00108 //update message if provided 00109 if(newMessage != QString::null) 00110 { 00111 this->message->setText( newMessage ); 00112 } 00113 }
|
|
Definition at line 80 of file statusWidget.h. Referenced by incrementProgress(), showProgressBar(), StatusWidget(), and updateProgress(). |
|
Layout widgets placed in.
Definition at line 76 of file statusWidget.h. Referenced by fileFetched(), and StatusWidget(). |
|
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(). |
|
Definition at line 78 of file statusWidget.h. Referenced by removeStatus(), StatusWidget(), and updateProgress(). |
|
Definition at line 79 of file statusWidget.h. Referenced by incrementProgress(), setStatus(), showProgressBar(), StatusWidget(), and updateProgress(). |
|
Definition at line 82 of file statusWidget.h. Referenced by setStatus(), showProgressBar(), StatusWidget(), and ~StatusWidget(). |
|
Update available label.
Definition at line 88 of file statusWidget.h. Referenced by checkForUpdates(), fileFetched(), removeUpdatesIcon(), and StatusWidget(). |