AlbumShaper  1.0a3
Public Member Functions | Private Slots | Private Attributes | List of all members
StatusWidget Class Reference

#include <statusWidget.h>

Inheritance diagram for StatusWidget:
Inheritance graph
[legend]
Collaboration diagram for StatusWidget:
Collaboration graph
[legend]

Public Member Functions

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

Private Slots

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

Private Attributes

Q3GridLayout * grid
 Layout widgets placed in. More...
 
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 More...
 
ClickableLabelupdateAvailable
 Update available label. More...
 

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.

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

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 fileFetched(bool error)
called once a file is fetched from the network
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
QLabel * message
Definition: statusWidget.h:82
Q3GridLayout * grid
Layout widgets placed in.
Definition: statusWidget.h:80
Q3Http http
http object for fetching releases file, used to check to see if installed copy is up to date ...
Definition: statusWidget.h:89
#define WIDGET_SPACING
Definition: config.h:31
void removeStatus()
Unset message.
QTimer * timer
Definition: statusWidget.h:86
ClickableLabel * updateAvailable
Update available label.
Definition: statusWidget.h:92
void checkForUpdates()
Check for updates.
Q3ProgressBar * progressBar
Definition: statusWidget.h:83

§ ~StatusWidget()

StatusWidget::~StatusWidget ( )

Deletes all objects.

Definition at line 86 of file statusWidget.cpp.

References timer.

87 {
88  delete timer;
89  timer = NULL;
90 }
QTimer * timer
Definition: statusWidget.h:86

Member Function Documentation

§ checkForUpdates()

void StatusWidget::checkForUpdates ( )

Check for updates.

Definition at line 230 of file statusWidget.cpp.

References http, and updateAvailable.

Referenced by StatusWidget().

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 }
Q3Http http
http object for fetching releases file, used to check to see if installed copy is up to date ...
Definition: statusWidget.h:89
ClickableLabel * updateAvailable
Update available label.
Definition: statusWidget.h:92

§ currentProgress()

int StatusWidget::currentProgress ( )

Returns current progress in steps.

Definition at line 117 of file statusWidget.cpp.

References curStep.

118 {
119  return curStep;
120 }

§ fileFetched

void StatusWidget::fileFetched ( bool  error)
privateslot

called once a file is fetched from the network

Definition at line 147 of file statusWidget.cpp.

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

Referenced by StatusWidget().

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 }
QString TEMP_DIR
Definition: config.cpp:23
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
QString IMAGE_PATH
Definition: config.cpp:18
Q3GridLayout * grid
Layout widgets placed in.
Definition: statusWidget.h:80
A clickable label.
Q3Http http
http object for fetching releases file, used to check to see if installed copy is up to date ...
Definition: statusWidget.h:89
#define ALBUMSHAPER_VERSION
Definition: config.h:21

§ grabInput()

void StatusWidget::grabInput ( )

§ incrementProgress()

void StatusWidget::incrementProgress ( )

§ releaseInput()

void StatusWidget::releaseInput ( )

§ removeStatus

void StatusWidget::removeStatus ( )
privateslot

Unset message.

Definition at line 141 of file statusWidget.cpp.

References message.

Referenced by StatusWidget().

142 {
143  //set status message to empty string
144  message->setText( "" );
145 }
QLabel * message
Definition: statusWidget.h:82

§ removeUpdatesIcon()

void StatusWidget::removeUpdatesIcon ( )

Remove program updates icon.

Definition at line 240 of file statusWidget.cpp.

References updateAvailable.

241 {
242  delete updateAvailable;
243  updateAvailable = NULL;
244 }
ClickableLabel * updateAvailable
Update available label.
Definition: statusWidget.h:92

§ setStatus()

void StatusWidget::setStatus ( QString  message)

Update message.

Definition at line 128 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().

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 }
QLabel * message
Definition: statusWidget.h:82
QTimer * timer
Definition: statusWidget.h:86
Q3ProgressBar * progressBar
Definition: statusWidget.h:83

§ showProgressBar()

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

Initializes the progress bar.

Definition at line 92 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().

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 }
QLabel * message
Definition: statusWidget.h:82
QTimer * timer
Definition: statusWidget.h:86
Q3ProgressBar * progressBar
Definition: statusWidget.h:83

§ updateProgress()

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

Updates the progress bar.

Definition at line 105 of file statusWidget.cpp.

References curStep, message, and progressBar.

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

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 }
QLabel * message
Definition: statusWidget.h:82
Q3ProgressBar * progressBar
Definition: statusWidget.h:83

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(), 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(), removeUpdatesIcon(), and StatusWidget().


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