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

About window widget. More...

#include <about.h>

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

Signals

void closed ()
 

Public Member Functions

 About (int mode, QWidget *parent=0, const char *name=0)
 
 ~About ()
 

Private Slots

void fileFetched (bool error)
 
void reject ()
 

Private Member Functions

void closeEvent (QCloseEvent *e)
 

Private Attributes

Q3GridLayout * grid
 
QMovie * albumShaperAgingImage
 
QLabelalbumShaperLogo
 
QLabelprogDesc
 
QLabelprogURL
 
QTabWidget * tabWidget
 
Q3TextBrowsercredits
 
Q3TextBrowserhistory
 
Q3TextBrowsernewImprovements
 
Q3TextBrowserupcomingFeatures
 
QPushButton * closeButton
 Close button. More...
 
QStringList * releases
 
Q3Http http
 
int getMode
 
int displayMode
 

Detailed Description

About window widget.

Definition at line 38 of file about.h.

Constructor & Destructor Documentation

§ About()

About::About ( int  mode,
QWidget parent = 0,
const char *  name = 0 
)

Definition at line 50 of file about.cpp.

References ALBUMSHAPER_VERSION, albumShaperLogo, closeButton, credits, DEFAULT_HEIGHT, DEFAULT_WIDTH, displayMode, fileFetched(), GET_RELEASES, getMode, grid, history, http, IMAGE_PATH, progDesc, progURL, releases, tabWidget, TEXT_PATH, UNSET, and WIDGET_SPACING.

50  : QDialog(parent,name)
51 {
52  displayMode = mode;
53  //--------------------------------------------------------------
54  QColor white(255, 255, 255);
55  QColor darkBlue(35, 75, 139);
56  QColor black(0, 0, 0);
57  //--------------------------------------------------------------
58  //by default not getting anything
59  getMode = UNSET;
60  //--
61  //set window title
62  setCaption( tr("About Album Shaper"));
63  //--
64  //application logo
65  Q3Frame* logoFrame = new Q3Frame( this );
66  logoFrame->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
67  albumShaperLogo = new QLabel( logoFrame );
68  albumShaperLogo->setPixmap( QPixmap( QString(IMAGE_PATH)+"miscImages/albumShaper.png" ) );
69  //--
70  //if user chooses to get product updates information
71  releases = NULL;
72  if(((Window*)(qApp->mainWidget()))->getConfig()->getBool( "alerts", "showSoftwareUpdateAlerts"))
73  {
74  //set http host
75  http.setHost( "albumshaper.sourceforge.net" );
76  connect( &http, SIGNAL(done(bool)), this, SLOT(fileFetched(bool)) );
77  //--
78  //attempt to get releases list from website. this lets us find out if this
79  //copy of Album Shaper is outdated, and also allows us to know what
80  //changelogs to get.
82  http.get( "/webService/releases.xml");
83  }
84  //--
85  //text labels
86  QDate currentDate = QDate::currentDate();
87  int copyYearFirst = QMIN( currentDate.year(), 2003 );
88  int copyYearLast = QMAX( currentDate.year(), 2004 );
89 
90 
91  progDesc = new QLabel( QString("Album Shaper " +
92  QString(ALBUMSHAPER_VERSION) +
93  ", © %1-%2 Will Stokes").arg(copyYearFirst).arg(copyYearLast),
94  logoFrame );
95 
96  progURL = new QLabel( "http://albumshaper.sourceforge.net", logoFrame );
97 
98 
99  QFont textFont = progDesc->font();
100  textFont.setWeight(QFont::Bold);
101  progDesc->setFont( textFont );
102  progURL->setFont( textFont );
103  //--
104  //tab widget which contains credits, changelog, etc
105  tabWidget = new QTabWidget( this );
106  //--
107  //create credits tab
108  credits = new Q3TextBrowser( this );
109  credits->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
110  credits->mimeSourceFactory()->setFilePath( QStringList(TEXT_PATH) );
111  credits->setSource( "about.html");
112  tabWidget->addTab(credits,
113  QIcon( QPixmap(QString(IMAGE_PATH)+"tabIcons/credits.png") ),
114  tr("Credits") );
115  //--
116  //create history tab
117  history = new Q3TextBrowser(this);
118  history->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
119  history->mimeSourceFactory()->setFilePath( QStringList(TEXT_PATH) );
120  history->setSource( "history.html");
121  tabWidget->addTab(history,
122  QIcon( QPixmap(QString(IMAGE_PATH)+"tabIcons/history.png") ),
123  tr("History") );
124  //--
125  //create close button
126  closeButton = new QPushButton(
127  //PLATFORM_SPECIFIC_CODE
128  #ifndef Q_OS_MACX
129  QPixmap(QString(IMAGE_PATH)+"buttonIcons/button_ok.png"),
130  #endif
131  tr("Close"),
132  this );
133  closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
134  closeButton->setDefault(true);
135  connect( closeButton, SIGNAL(clicked()), SLOT(close()) );
136  //--
137  logoFrame->setPaletteBackgroundColor( darkBlue );
138  progDesc->setPaletteForegroundColor( white );
139  progDesc->setPaletteBackgroundColor( darkBlue );
140  progURL->setPaletteForegroundColor( white );
141  progURL->setPaletteBackgroundColor( darkBlue );
142  tabWidget->setPaletteForegroundColor( black );
143  //--
144  Q3GridLayout* logoGrid = new Q3GridLayout( logoFrame, 4, 3, 0);
145  logoGrid->setSpacing(WIDGET_SPACING);
146  logoGrid->addWidget( albumShaperLogo, 0, 1, Qt::AlignCenter );
147  logoGrid->addWidget( progDesc, 2, 1, Qt::AlignCenter );
148  logoGrid->addWidget( progURL, 3, 1, Qt::AlignCenter );
149 
150  grid = new Q3GridLayout( this, 3, 1, 0);
151  grid->setSpacing(WIDGET_SPACING);
152  grid->addWidget( logoFrame, 0, 0 );
153  grid->addWidget( tabWidget, 1, 0 );
154  grid->addWidget( closeButton, 2, 0, Qt::AlignCenter );
155  resize( DEFAULT_WIDTH, DEFAULT_HEIGHT );
156  //--
157  //show secret images around Album Shaper's birthday (first release date - 4/3/2003)
158  if( currentDate.year() > 2003 && currentDate.month() == 4 && currentDate.day() <= 3)
159  {
160  QLabel* cakeLogo = new QLabel(logoFrame);
161  cakeLogo->setPixmap( QPixmap( QString(IMAGE_PATH)+"miscImages/birthdayL.png" ) );
162  QLabel* cakeLogo2 = new QLabel(logoFrame);
163  cakeLogo2->setPixmap( QPixmap( QString(IMAGE_PATH)+"miscImages/birthdayR.png" ) );
164  QLabel* cakeMessage = new QLabel( QString( tr("Happy Birthday Album Shaper!") +
165  QString(" %1 ").arg(currentDate.year() - 2003) +
166  ( currentDate.year()-2003 == 1 ? tr("Year Old!") : tr("Years Old!")) ), logoFrame );
167  cakeMessage->setFont(textFont);
168  cakeMessage->setPaletteForegroundColor( white );
169  //--
170  logoGrid->addWidget( cakeLogo, 0, 0, Qt::AlignCenter );
171  logoGrid->addWidget( cakeLogo2, 0, 2, Qt::AlignCenter );
172  logoGrid->addMultiCellWidget( cakeMessage, 1, 1, 0, 2, Qt::AlignCenter );
173  }
174  //-------------------------------
175  //set window to not be resizeable
176  this->show();
177  setFixedSize(size());
178  //-------------------------------
179 }
Q3GridLayout * grid
Definition: about.h:56
QLabel * progDesc
Definition: about.h:61
QLabel * progURL
Definition: about.h:62
QLabel * albumShaperLogo
Definition: about.h:59
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
Definition: window.h:39
QString TEXT_PATH
Definition: config.cpp:20
QString IMAGE_PATH
Definition: config.cpp:18
QPushButton * closeButton
Close button.
Definition: about.h:72
int displayMode
Definition: about.h:83
#define GET_RELEASES
Definition: about.cpp:45
QStringList * releases
Definition: about.h:74
#define DEFAULT_HEIGHT
Definition: about.cpp:42
Q3Http http
Definition: about.h:77
#define WIDGET_SPACING
Definition: config.h:31
#define ALBUMSHAPER_VERSION
Definition: config.h:21
QTabWidget * tabWidget
Definition: about.h:64
void fileFetched(bool error)
Definition: about.cpp:187
int getMode
Definition: about.h:80
#define UNSET
Definition: about.cpp:44
#define DEFAULT_WIDTH
Definition: about.cpp:41
Q3TextBrowser * credits
Definition: about.h:66
Q3TextBrowser * history
Definition: about.h:67

§ ~About()

About::~About ( )

Definition at line 181 of file about.cpp.

References releases.

182 {
183  delete releases;
184  releases = NULL;
185 }
QStringList * releases
Definition: about.h:74

Member Function Documentation

§ closed

void About::closed ( )
signal

Referenced by closeEvent(), and reject().

§ closeEvent()

void About::closeEvent ( QCloseEvent *  e)
private

Definition at line 404 of file about.cpp.

References closed().

405 {
406  QWidget::closeEvent( e );
407  emit closed();
408 }
void closed()

§ fileFetched

void About::fileFetched ( bool  error)
privateslot

Definition at line 187 of file about.cpp.

References ALBUMSHAPER_VERSION, displayMode, GET_NEW_IMPROVEMENTS, GET_RELEASES, GET_UPCOMING_FEATURES, getMode, http, IMAGE_PATH, newImprovements, releases, tabWidget, TEMP_DIR, TEXT_PATH, UNSET, UPCOMING, upcomingFeatures, and UPDATES.

Referenced by About().

188 {
189  //------------------------------------------------------------
190  //if unable to get file bail
191  if(error)
192  {
193  getMode = UNSET;
194  return;
195  }
196  //------------------------------------------------------------
197  //getting releases?
198  if(getMode == GET_RELEASES)
199  {
200  //write releases to temp file
201  QFile fetchedDoc( TEMP_DIR + QString("/releases.xml") );
202  if(fetchedDoc.open(QIODevice::WriteOnly))
203  {
204  //----------------------------
205  //write to file
206  Q3TextStream stream( &fetchedDoc );
207  stream.setEncoding( Q3TextStream::UnicodeUTF8 );
208  stream << QString( http.readAll() );
209  fetchedDoc.close();
210  //----------------------------
211  //parse xml file, construct string list of releases
212  //open file, bail if unable to
213  if( !fetchedDoc.open( QIODevice::ReadOnly ) )
214  {
215  getMode = UNSET;
216  return;
217  }
218 
219  //parse dom
220  QDomDocument xmlDom;
221  if( !xmlDom.setContent( &fetchedDoc ) )
222  {
223  fetchedDoc.close();
224  getMode = UNSET;
225  return;
226  }
227 
228  //close file
229  fetchedDoc.close();
230 
231  //construct stringlist of releases
232  releases = new QStringList();
233  QDomElement root = xmlDom.documentElement();
234  QDomNode node = root.firstChild();
235  QDomText val;
236  bool thisVersionFound = false;
237  while( !node.isNull() )
238  {
239  if( node.isElement() && node.nodeName() == "release" )
240  {
241  val = node.firstChild().toText();
242  if(!val.isNull())
243  {
244  //append release #
245  releases->append( QString(val.nodeValue()) );
246 
247  //is release this version?
248  if( QString(val.nodeValue()).compare( QString(ALBUMSHAPER_VERSION) ) == 0 )
249  thisVersionFound = true;
250 
251  }
252  }
253  node = node.nextSibling();
254  }
255 
256  //else if this version is not first on list but it was found in list then newer releases exist
257  if(thisVersionFound && releases->first().compare( QString(ALBUMSHAPER_VERSION) ) != 0 )
258  {
259  //create new improvements file with beginning html and body tags
260  QFile fetchedDoc( TEMP_DIR + QString("/newImprovements.html") );
261  if(fetchedDoc.open(QIODevice::WriteOnly))
262  {
263  Q3TextStream stream( &fetchedDoc ); stream.setEncoding( Q3TextStream::UnicodeUTF8 );
264  stream << "<html><body bgcolor=\"white\" text=\"black\">\n";
265  stream << "<b><font size=\"+1\">" << tr("New improvements to Album Shaper are available in a new release!") << "<br><hr></font></b>";
266  fetchedDoc.close();
267  }
268 
270  http.get( "/webService/" + releases->first() + "_changelog.html");
271  }
272  //else we're up to date! move on to checking for new features in cvs!
273  else
274  {
275  newImprovements = new Q3TextBrowser( this );
276  newImprovements->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
277  newImprovements->mimeSourceFactory()->setFilePath( QStringList(TEXT_PATH) );
278 
279  //bleeding edge message
280  if(!thisVersionFound)
281  {
282  newImprovements->setSource( "bleedingEdge.html");
283  }
284  else
285  {
286  newImprovements->setSource( "noUpdates.html");
287  }
288 
289  tabWidget->addTab(newImprovements,
290  QIcon( QPixmap(QString(IMAGE_PATH)+"tabIcons/newImprovements.png") ),
291  tr("Software Updates") );
292 
293  if(displayMode == UPDATES)
294  tabWidget->setCurrentPage( tabWidget->indexOf( newImprovements ) );
295 
297  http.get( "/webService/upcomingFeatures.html");
298  }
299  //----------------------------
300  //delete file
301  QDir rootDir( TEMP_DIR );
302  rootDir.remove("releases.xml");
303  //----------------------------
304  }
305  else
306  {
307  getMode = UNSET;
308  }
309  }
310  //------------------------------------------------------------
311  else if(getMode == GET_NEW_IMPROVEMENTS)
312  {
313  //write additional changelog information to disk
314  QFile fetchedDoc( TEMP_DIR + QString("/newImprovements.html") );
315  if(fetchedDoc.open(QIODevice::WriteOnly | QIODevice::Append))
316  {
317  //write to file
318  Q3TextStream stream( &fetchedDoc );
319  stream.setEncoding( Q3TextStream::UnicodeUTF8 );
320  stream << QString( http.readAll() );
321  fetchedDoc.close();
322 
323  //pop of release from stack
324  releases->pop_front();
325 
326  //if stack empty then or we've goten up to this version add new tab with changes
327  if(releases->isEmpty() ||
328  releases->first().compare( QString(ALBUMSHAPER_VERSION) ) == 0 )
329  {
330  //tack on the end body and html tags
331  if(fetchedDoc.open(QIODevice::WriteOnly | QIODevice::Append))
332  {
333  //write to file
334  Q3TextStream stream( &fetchedDoc );
335  stream.setEncoding( Q3TextStream::UnicodeUTF8 );
336  stream << "</body></html>";
337  fetchedDoc.close();
338 
339  newImprovements = new Q3TextBrowser(this);
340  newImprovements->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
341  newImprovements->mimeSourceFactory()->setFilePath( TEMP_DIR );
342  newImprovements->setSource( "newImprovements.html" );
343  tabWidget->addTab(newImprovements,
344  QIcon( QPixmap(QString(IMAGE_PATH)+"tabIcons/newImprovements.png") ),
345  tr("Software Updates") );
346  tabWidget->setCurrentPage( tabWidget->indexOf( newImprovements ) );;
347 
348  //move on to checking for upcoming features
350  http.get( "/webService/upcomingFeatures.html");
351  }
352  else
353  {
354  getMode = UNSET;
355  }
356  }
357  //if not empty then get even more new features!
358  else
359  {
360  http.get( "/webService/" + releases->first() + "_changelog.html");
361  }
362  }
363  else
364  {
365  getMode = UNSET;
366  }
367  }
368  //------------------------------------------------------------
369  //getting upcoming features?
370  else if(getMode == GET_UPCOMING_FEATURES)
371  {
372  //write upcoming features to temp file
373  QFile fetchedDoc( TEMP_DIR + QString("/upcomingFeatures.html") );
374  if(fetchedDoc.open(QIODevice::WriteOnly))
375  {
376  //write to file
377  Q3TextStream stream( &fetchedDoc );
378  stream.setEncoding( Q3TextStream::UnicodeUTF8 );
379  stream << QString( http.readAll() );
380  fetchedDoc.close();
381 
382  //add tab
383  upcomingFeatures = new Q3TextBrowser(this);
384  upcomingFeatures->setFrameStyle( Q3Frame::Panel | Q3Frame::Sunken );
385  upcomingFeatures->mimeSourceFactory()->setFilePath( TEMP_DIR );
386  upcomingFeatures->setSource( "upcomingFeatures.html" );
387  tabWidget->addTab(upcomingFeatures,
388  QIcon( QPixmap(QString(IMAGE_PATH)+"tabIcons/upcomingFeatures.png") ),
389  tr("Upcoming Features") );
390 
391  if(displayMode == UPCOMING)
392  tabWidget->setCurrentPage( tabWidget->indexOf( upcomingFeatures ) );
393 
394  //delete file
395  QDir rootDir( TEMP_DIR );
396  rootDir.remove("upcomingFeatures.html");
397  }
398 
399  getMode = UNSET;
400  }
401  //------------------------------------------------------------
402 }
#define UPDATES
Definition: titleWidget.h:45
#define GET_NEW_IMPROVEMENTS
Definition: about.cpp:46
Q3TextBrowser * newImprovements
Definition: about.h:68
QString TEMP_DIR
Definition: config.cpp:23
QString TEXT_PATH
Definition: config.cpp:20
QString IMAGE_PATH
Definition: config.cpp:18
#define UPCOMING
Definition: titleWidget.h:46
int displayMode
Definition: about.h:83
#define GET_RELEASES
Definition: about.cpp:45
Q3TextBrowser * upcomingFeatures
Definition: about.h:69
QStringList * releases
Definition: about.h:74
Q3Http http
Definition: about.h:77
#define ALBUMSHAPER_VERSION
Definition: config.h:21
QTabWidget * tabWidget
Definition: about.h:64
#define GET_UPCOMING_FEATURES
Definition: about.cpp:47
int getMode
Definition: about.h:80
#define UNSET
Definition: about.cpp:44

§ reject

void About::reject ( )
privateslot

Definition at line 410 of file about.cpp.

References closed().

411 {
412  QDialog::reject();
413  emit closed();
414 }
void closed()

Member Data Documentation

§ albumShaperAgingImage

QMovie* About::albumShaperAgingImage
private

Definition at line 58 of file about.h.

§ albumShaperLogo

QLabel* About::albumShaperLogo
private

Definition at line 59 of file about.h.

Referenced by About().

§ closeButton

QPushButton* About::closeButton
private

Close button.

Definition at line 72 of file about.h.

Referenced by About().

§ credits

Q3TextBrowser* About::credits
private

Definition at line 66 of file about.h.

Referenced by About().

§ displayMode

int About::displayMode
private

Definition at line 83 of file about.h.

Referenced by About(), and fileFetched().

§ getMode

int About::getMode
private

Definition at line 80 of file about.h.

Referenced by About(), and fileFetched().

§ grid

Q3GridLayout* About::grid
private

Definition at line 56 of file about.h.

Referenced by About().

§ history

Q3TextBrowser* About::history
private

Definition at line 67 of file about.h.

Referenced by About().

§ http

Q3Http About::http
private

Definition at line 77 of file about.h.

Referenced by About(), and fileFetched().

§ newImprovements

Q3TextBrowser* About::newImprovements
private

Definition at line 68 of file about.h.

Referenced by fileFetched().

§ progDesc

QLabel* About::progDesc
private

Definition at line 61 of file about.h.

Referenced by About().

§ progURL

QLabel* About::progURL
private

Definition at line 62 of file about.h.

Referenced by About().

§ releases

QStringList* About::releases
private

Definition at line 74 of file about.h.

Referenced by About(), fileFetched(), and ~About().

§ tabWidget

QTabWidget* About::tabWidget
private

Definition at line 64 of file about.h.

Referenced by About(), and fileFetched().

§ upcomingFeatures

Q3TextBrowser* About::upcomingFeatures
private

Definition at line 69 of file about.h.

Referenced by fileFetched().


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