AlbumShaper 1.0a3
StatusWidget Class Reference

#include <statusWidget.h>

Inheritance diagram for StatusWidget:
Collaboration 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

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

Detailed Description

Definition at line 32 of file statusWidget.h.

Constructor & Destructor Documentation

◆ StatusWidget()

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

Creates layout.

Definition at line 39 of file statusWidget.cpp.

40 : QWidget(parent,name)
41{
42 //create status message
43 message = new QLabel( this );
44 message->setText( "" );
45
46 //create timer object and setup signals
47 timer = new QTimer();
48 connect(timer, SIGNAL(timeout()), this, SLOT(removeStatus()) );
49
50 //create progress message and bar
51 progressBar = new Q3ProgressBar( this );
52 progressBar->setCenterIndicator(true);
53 progressBar->hide();
54 curStep = 0;
55
56 //-----------------------------------------------------------------
57 //setup http object to check for updates, only check for updates if they are enabled
58 updateAvailable = NULL;
59 http.setHost( "albumshaper.sourceforge.net" );
60 connect( &http, SIGNAL(done(bool)), this, SLOT(fileFetched(bool)) );
61 if(((Window*)parentWidget())->getConfig()->getBool( "alerts", "showSoftwareUpdateAlerts"))
62 {
64 }
65 //-----------------------------------------------------------------
66 //place progress frame and status message in main grid
67 grid = new Q3GridLayout( this, 1, 6, 0 );
68 grid->setSpacing(WIDGET_SPACING);
69 grid->setColSpacing( 0, WIDGET_SPACING );
70 grid->addWidget( message, 0, 1, Qt::AlignVCenter );
71 grid->addWidget( progressBar, 0, 2, Qt::AlignVCenter );
72 grid->setColStretch( 3, 1 );
73
74 //PLATFORM_SPECIFIC_CODE
75 //mac os x puts in a size grip that can interfere with the updates icon, in order
76 //to avoid this we manually place the size grip ourselves
77 //windows users expect a grip too, but qt doesn't put one in by default. we'll add
78 //it for them too. :-)
79 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
80 QSizeGrip* sizeGrip = new QSizeGrip( this );
81 grid->addWidget( sizeGrip, 0, 5, Qt::AlignBottom );
82 #endif
83
84}
void checkForUpdates()
Check for updates.
QLabel * message
ClickableLabel * updateAvailable
Update available label.
Q3GridLayout * grid
Layout widgets placed in.
Q3ProgressBar * progressBar
void fileFetched(bool error)
called once a file is fetched from the network
QTimer * timer
Q3Http http
http object for fetching releases file, used to check to see if installed copy is up to date
void removeStatus()
Unset message.
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget.
Definition window.h:40
#define WIDGET_SPACING
Definition config.h:31

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

◆ ~StatusWidget()

StatusWidget::~StatusWidget ( )

Deletes all objects.

Definition at line 86 of file statusWidget.cpp.

87{
88 delete timer;
89 timer = NULL;
90}

References timer.

Member Function Documentation

◆ checkForUpdates()

void StatusWidget::checkForUpdates ( )

Check for updates.

Definition at line 230 of file statusWidget.cpp.

231{
232 if(updateAvailable != NULL)
233 return;
234
235 //attempt to get releases list from website. this lets us find out if this
236 //copy of Album Shaper is outdated
237 http.get( "/webService/releases.xml");
238}

References http, and updateAvailable.

Referenced by StatusWidget().

◆ currentProgress()

int StatusWidget::currentProgress ( )

Returns current progress in steps.

Definition at line 117 of file statusWidget.cpp.

118{
119 return curStep;
120}

References curStep.

◆ fileFetched

void StatusWidget::fileFetched ( bool error)
privateslot

called once a file is fetched from the network

Definition at line 147 of file statusWidget.cpp.

148{
149 //------------------------------------------------------------
150 //if unable to get file bail
151 if(error)
152 {
153 return;
154 }
155 //------------------------------------------------------------
156 //write releases to temp file
157 QFile fetchedDoc( TEMP_DIR + QString("/releases.xml") );
158 if(fetchedDoc.open(QIODevice::WriteOnly))
159 {
160 //----------------------------
161 //write to file
162 Q3TextStream stream( &fetchedDoc );
163 stream.setEncoding( Q3TextStream::UnicodeUTF8 );
164 stream << QString( http.readAll() );
165 fetchedDoc.close();
166 //----------------------------
167 //parse xml file, construct string list of releases
168 //open file, bail if unable to
169 if( !fetchedDoc.open( QIODevice::ReadOnly ) )
170 {
171 return;
172 }
173
174 //parse dom
175 QDomDocument xmlDom;
176 if( !xmlDom.setContent( &fetchedDoc ) )
177 {
178 fetchedDoc.close();
179 return;
180 }
181
182 //close file
183 fetchedDoc.close();
184
185 //construct stringlist of releases
186 //actually, only get the first release since we don't need the others to determine if we
187 //are out of date
188
189 QStringList releases;
190 QDomElement root = xmlDom.documentElement();
191 QDomNode node = root.firstChild();
192 QDomText val;
193 bool thisVersionFound = false;
194 while( !node.isNull() )
195 {
196 if( node.isElement() && node.nodeName() == "release" )
197 {
198 val = node.firstChild().toText();
199 if(!val.isNull())
200 {
201 //append release #
202 releases.append( QString(val.nodeValue()) );
203
204 //is release this version?
205 if( QString(val.nodeValue()).compare( QString(ALBUMSHAPER_VERSION) ) == 0 )
206 thisVersionFound = true;
207 }
208 }
209 node = node.nextSibling();
210 }
211
212 //compare first release to this release, if strings not equal then we're outdated,
213 //update album shaper icon and start grabbing changelogs
214 if(thisVersionFound && releases.first().compare( QString(ALBUMSHAPER_VERSION) ) != 0)
215 {
216 ClickableLabel* uA = new ClickableLabel( this );
217 QMovie *m = new QMovie( QString(IMAGE_PATH)+"miscImages/updateAvailable.mng");
218 uA->setMovie(m);
219 QToolTip::add( uA, tr("Your copy of Album Shaper is not up to date! Click here for details") );
220 grid->addWidget( uA, 0, 4, Qt::AlignVCenter );
221 connect( uA, SIGNAL(clicked()),
222 ((Window*)parentWidget())->getTitle(), SLOT(aboutProgram()) );
223 uA->show();\
224 updateAvailable = uA;
225 }
226 }
227 //------------------------------------------------------------
228}
A clickable label.
QString IMAGE_PATH
Definition config.cpp:18
QString TEMP_DIR
Definition config.cpp:23
#define ALBUMSHAPER_VERSION
Definition config.h:21

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

Referenced by StatusWidget().

◆ grabInput()

◆ incrementProgress()

◆ releaseInput()

◆ removeStatus

void StatusWidget::removeStatus ( )
privateslot

Unset message.

Definition at line 141 of file statusWidget.cpp.

142{
143 //set status message to empty string
144 message->setText( "" );
145}

References message.

Referenced by StatusWidget().

◆ removeUpdatesIcon()

void StatusWidget::removeUpdatesIcon ( )

Remove program updates icon.

Definition at line 240 of file statusWidget.cpp.

241{
242 delete updateAvailable;
243 updateAvailable = NULL;
244}

References updateAvailable.

◆ setStatus()

void StatusWidget::setStatus ( QString message)

Update message.

Definition at line 128 of file statusWidget.cpp.

129{
130 timer->stop();
131
132 //hide progress bar
133 progressBar->hide();
134
135 //update status message
136 this->message->setText( message );
137
138 timer->start( 2000, TRUE );
139}

References message, 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().

◆ showProgressBar()

void StatusWidget::showProgressBar ( QString message,
int numSteps )

Initializes the progress bar.

Definition at line 92 of file statusWidget.cpp.

93{
94 //make sure timer is stopped so progress mess is never hidden
95 //this can occur if a new event is begun before the previous events message is removed after default delay
96 timer->stop();
97
98 //setup progress bar and show it
99 this->message->setText( message );
100 progressBar->setProgress( 0, numSteps );
101 progressBar->show();
102 curStep = 0;
103}

References curStep, message, 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().

◆ updateProgress()

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

Updates the progress bar.

Definition at line 105 of file statusWidget.cpp.

106{
107 curStep = progress;
108 progressBar->setProgress( progress );
109
110 //update message if provided
111 if(newMessage != QString::null)
112 {
113 this->message->setText( newMessage );
114 }
115}

References curStep, message, and progressBar.

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

Member Data Documentation

◆ curStep

int StatusWidget::curStep
private

◆ grid

Q3GridLayout* StatusWidget::grid
private

Layout widgets placed in.

Definition at line 80 of file statusWidget.h.

Referenced by fileFetched(), and StatusWidget().

◆ http

Q3Http StatusWidget::http
private

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

Definition at line 89 of file statusWidget.h.

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

◆ message

QLabel* StatusWidget::message
private

Definition at line 82 of file statusWidget.h.

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

◆ progressBar

Q3ProgressBar* StatusWidget::progressBar
private

◆ timer

QTimer* StatusWidget::timer
private

Definition at line 86 of file statusWidget.h.

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

◆ updateAvailable

ClickableLabel* StatusWidget::updateAvailable
private

Update available label.

Definition at line 92 of file statusWidget.h.

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


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