00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qlayout.h>
00013
#include <qlabel.h>
00014
#include <qfont.h>
00015
#include <qiconset.h>
00016
#include <qpixmap.h>
00017
#include <qtabwidget.h>
00018
#include <qtextbrowser.h>
00019
#include <qpushbutton.h>
00020
#include <qstringlist.h>
00021
#include <qdatetime.h>
00022
#include <qfile.h>
00023
#include <qdir.h>
00024
#include <qdom.h>
00025
#include <qstringlist.h>
00026
#include <qmovie.h>
00027
#include <qapplication.h>
00028
#include <qframe.h>
00029
00030
00031
#include "about.h"
00032
#include "../titleWidget.h"
00033
#include "../window.h"
00034
#include "../../config.h"
00035
#include "../../configuration/configuration.h"
00036
00037 #define DEFAULT_WIDTH 600
00038 #define DEFAULT_HEIGHT 500
00039
00040 #define UNSET 0
00041 #define GET_RELEASES 1
00042 #define GET_NEW_IMPROVEMENTS 2
00043 #define GET_UPCOMING_FEATURES 3
00044
00045
00046 About::About(
int mode,
QWidget* parent,
const char* name ) :
QDialog(parent,name)
00047 {
00048
displayMode = mode;
00049
00050 QColor white(255, 255, 255);
00051 QColor darkBlue(35, 75, 139);
00052 QColor black(0, 0, 0);
00053
00054
00055
getMode =
UNSET;
00056
00057
00058 setCaption( tr(
"About Album Shaper"));
00059
00060
00061
QFrame* logoFrame =
new QFrame(
this );
00062 logoFrame->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
00063
albumShaperLogo =
new QLabel( logoFrame );
00064
albumShaperLogo->setPixmap( QPixmap( QString(
IMAGE_PATH)+
"miscImages/albumShaper.png" ) );
00065
00066
00067
releases = NULL;
00068
if(((
Window*)(qApp->mainWidget()))->getConfig()->getBool(
"alerts",
"showSoftwareUpdateAlerts"))
00069 {
00070
00071
http.setHost(
"albumshaper.sourceforge.net" );
00072 connect( &
http, SIGNAL(done(
bool)),
this, SLOT(
fileFetched(
bool)) );
00073
00074
00075
00076
00077
getMode =
GET_RELEASES;
00078
http.get(
"/webService/releases.xml");
00079 }
00080
00081
00082 QDate currentDate = QDate::currentDate();
00083
int copyYearFirst = QMIN( currentDate.year(), 2003 );
00084
int copyYearLast = QMAX( currentDate.year(), 2004 );
00085
00086
00087
progDesc =
new QLabel( QString(
"Album Shaper " +
00088 QString(
ALBUMSHAPER_VERSION) +
00089
", © %1-%2 Will Stokes").arg(copyYearFirst).arg(copyYearLast),
00090 logoFrame );
00091
00092
progURL =
new QLabel(
"http://albumshaper.sourceforge.net", logoFrame );
00093
00094
00095 QFont textFont =
progDesc->font();
00096 textFont.setWeight(QFont::Bold);
00097
progDesc->setFont( textFont );
00098
progURL->setFont( textFont );
00099
00100
00101
tabWidget =
new QTabWidget(
this );
00102
00103
00104
credits =
new QTextBrowser(
this );
00105
credits->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00106
credits->mimeSourceFactory()->setFilePath( QStringList(
TEXT_PATH) );
00107
credits->setSource(
"about.html");
00108
tabWidget->addTab(
credits,
00109 QIconSet( QPixmap(QString(
IMAGE_PATH)+
"tabIcons/credits.png") ),
00110 tr(
"Credits") );
00111
00112
00113
history =
new QTextBrowser(
this);
00114
history->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00115
history->mimeSourceFactory()->setFilePath( QStringList(
TEXT_PATH) );
00116
history->setSource(
"history.html");
00117
tabWidget->addTab(
history,
00118 QIconSet( QPixmap(QString(
IMAGE_PATH)+
"tabIcons/history.png") ),
00119 tr(
"History") );
00120
00121
00122
closeButton =
new QPushButton(
00123
00124 #ifndef Q_OS_MACX
00125 QPixmap(QString(
IMAGE_PATH)+
"buttonIcons/button_ok.png"),
00126 #endif
00127 tr(
"Close"),
00128
this );
00129
closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00130
closeButton->setDefault(
true);
00131 connect(
closeButton, SIGNAL(clicked()), SLOT(close()) );
00132
00133 logoFrame->setPaletteBackgroundColor( darkBlue );
00134
progDesc->setPaletteForegroundColor( white );
00135
progDesc->setPaletteBackgroundColor( darkBlue );
00136
progURL->setPaletteForegroundColor( white );
00137
progURL->setPaletteBackgroundColor( darkBlue );
00138
tabWidget->setPaletteForegroundColor( black );
00139
00140 QGridLayout* logoGrid =
new QGridLayout( logoFrame, 4, 3, 0);
00141 logoGrid->setSpacing(
WIDGET_SPACING);
00142 logoGrid->addWidget(
albumShaperLogo, 0, 1, Qt::AlignCenter );
00143 logoGrid->addWidget(
progDesc, 2, 1, Qt::AlignCenter );
00144 logoGrid->addWidget(
progURL, 3, 1, Qt::AlignCenter );
00145
00146
grid =
new QGridLayout(
this, 3, 1, 0);
00147
grid->setSpacing(
WIDGET_SPACING);
00148
grid->addWidget( logoFrame, 0, 0 );
00149
grid->addWidget(
tabWidget, 1, 0 );
00150
grid->addWidget(
closeButton, 2, 0, Qt::AlignCenter );
00151 resize(
DEFAULT_WIDTH,
DEFAULT_HEIGHT );
00152
00153
00154
if( currentDate.year() > 2003 && currentDate.month() == 4 && currentDate.day() <= 3)
00155 {
00156 QLabel* cakeLogo =
new QLabel(logoFrame);
00157 cakeLogo->setPixmap( QPixmap( QString(
IMAGE_PATH)+
"miscImages/birthdayL.png" ) );
00158 QLabel* cakeLogo2 =
new QLabel(logoFrame);
00159 cakeLogo2->setPixmap( QPixmap( QString(
IMAGE_PATH)+
"miscImages/birthdayR.png" ) );
00160 QLabel* cakeMessage =
new QLabel( QString( tr(
"Happy Birthday Album Shaper!") +
00161 QString(
" %1 ").arg(currentDate.year() - 2003) +
00162 ( currentDate.year()-2003 == 1 ? tr(
"Year Old!") : tr(
"Years Old!")) ), logoFrame );
00163 cakeMessage->setFont(textFont);
00164 cakeMessage->setPaletteForegroundColor( white );
00165
00166 logoGrid->addWidget( cakeLogo, 0, 0, Qt::AlignCenter );
00167 logoGrid->addWidget( cakeLogo2, 0, 2, Qt::AlignCenter );
00168 logoGrid->addMultiCellWidget( cakeMessage, 1, 1, 0, 2, Qt::AlignCenter );
00169 }
00170
00171
00172 this->show();
00173 setFixedSize(size());
00174
00175 }
00176
00177 About::~About()
00178 {
00179
delete releases;
00180
releases = NULL;
00181 }
00182
00183 void About::fileFetched(
bool error)
00184 {
00185
00186
00187
if(error)
00188 {
00189
getMode =
UNSET;
00190
return;
00191 }
00192
00193
00194
if(
getMode ==
GET_RELEASES)
00195 {
00196
00197 QFile fetchedDoc(
TEMP_DIR + QString(
"/releases.xml") );
00198
if(fetchedDoc.open(IO_WriteOnly))
00199 {
00200
00201
00202 QTextStream stream( &fetchedDoc );
00203 stream.setEncoding( QTextStream::UnicodeUTF8 );
00204 stream << QString(
http.readAll() );
00205 fetchedDoc.close();
00206
00207
00208
00209
if( !fetchedDoc.open( IO_ReadOnly ) )
00210 {
00211
getMode =
UNSET;
00212
return;
00213 }
00214
00215
00216 QDomDocument xmlDom;
00217
if( !xmlDom.setContent( &fetchedDoc ) )
00218 {
00219 fetchedDoc.close();
00220
getMode =
UNSET;
00221
return;
00222 }
00223
00224
00225 fetchedDoc.close();
00226
00227
00228
releases =
new QStringList();
00229 QDomElement root = xmlDom.documentElement();
00230 QDomNode node = root.firstChild();
00231 QDomText val;
00232
bool thisVersionFound =
false;
00233
while( !node.isNull() )
00234 {
00235
if( node.isElement() && node.nodeName() ==
"release" )
00236 {
00237 val = node.firstChild().toText();
00238
if(!val.isNull())
00239 {
00240
00241
releases->append( QString(val.nodeValue()) );
00242
00243
00244
if( QString(val.nodeValue()).compare( QString(
ALBUMSHAPER_VERSION) ) == 0 )
00245 thisVersionFound =
true;
00246
00247 }
00248 }
00249 node = node.nextSibling();
00250 }
00251
00252
00253
if(thisVersionFound &&
releases->first().compare( QString(
ALBUMSHAPER_VERSION) ) != 0 )
00254 {
00255
00256 QFile fetchedDoc(
TEMP_DIR + QString(
"/newImprovements.html") );
00257
if(fetchedDoc.open(IO_WriteOnly))
00258 {
00259 QTextStream stream( &fetchedDoc ); stream.setEncoding( QTextStream::UnicodeUTF8 );
00260 stream <<
"<html><body bgcolor=\"white\" text=\"black\">\n";
00261 stream <<
"<b><font size=\"+1\">" << tr(
"New improvements to Album Shaper are available in a new release!") <<
"<br><hr></font></b>";
00262 fetchedDoc.close();
00263 }
00264
00265
getMode =
GET_NEW_IMPROVEMENTS;
00266
http.get(
"/webService/" +
releases->first() +
"_changelog.html");
00267 }
00268
00269
else
00270 {
00271
newImprovements =
new QTextBrowser(
this );
00272
newImprovements->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00273
newImprovements->mimeSourceFactory()->setFilePath( QStringList(
TEXT_PATH) );
00274
00275
00276
if(!thisVersionFound)
00277 {
00278
newImprovements->setSource(
"bleedingEdge.html");
00279 }
00280
else
00281 {
00282
newImprovements->setSource(
"noUpdates.html");
00283 }
00284
00285
tabWidget->addTab(
newImprovements,
00286 QIconSet( QPixmap(QString(
IMAGE_PATH)+
"tabIcons/newImprovements.png") ),
00287 tr(
"Software Updates") );
00288
00289
if(
displayMode ==
UPDATES)
00290
tabWidget->setCurrentPage(
tabWidget->indexOf(
newImprovements ) );
00291
00292
getMode =
GET_UPCOMING_FEATURES;
00293
http.get(
"/webService/upcomingFeatures.html");
00294 }
00295
00296
00297 QDir rootDir(
TEMP_DIR );
00298 rootDir.remove(
"releases.xml");
00299
00300 }
00301
else
00302 {
00303
getMode =
UNSET;
00304 }
00305 }
00306
00307
else if(
getMode ==
GET_NEW_IMPROVEMENTS)
00308 {
00309
00310 QFile fetchedDoc(
TEMP_DIR + QString(
"/newImprovements.html") );
00311
if(fetchedDoc.open(IO_WriteOnly | IO_Append))
00312 {
00313
00314 QTextStream stream( &fetchedDoc );
00315 stream.setEncoding( QTextStream::UnicodeUTF8 );
00316 stream << QString(
http.readAll() );
00317 fetchedDoc.close();
00318
00319
00320
releases->pop_front();
00321
00322
00323
if(
releases->isEmpty() ||
00324
releases->first().compare( QString(
ALBUMSHAPER_VERSION) ) == 0 )
00325 {
00326
00327
if(fetchedDoc.open(IO_WriteOnly | IO_Append))
00328 {
00329
00330 QTextStream stream( &fetchedDoc );
00331 stream.setEncoding( QTextStream::UnicodeUTF8 );
00332 stream <<
"</body></html>";
00333 fetchedDoc.close();
00334
00335
newImprovements =
new QTextBrowser(
this);
00336
newImprovements->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00337
newImprovements->mimeSourceFactory()->setFilePath(
TEMP_DIR );
00338
newImprovements->setSource(
"newImprovements.html" );
00339
tabWidget->addTab(
newImprovements,
00340 QIconSet( QPixmap(QString(
IMAGE_PATH)+
"tabIcons/newImprovements.png") ),
00341 tr(
"Software Updates") );
00342
tabWidget->setCurrentPage(
tabWidget->indexOf(
newImprovements ) );;
00343
00344
00345
getMode =
GET_UPCOMING_FEATURES;
00346
http.get(
"/webService/upcomingFeatures.html");
00347 }
00348
else
00349 {
00350
getMode =
UNSET;
00351 }
00352 }
00353
00354
else
00355 {
00356
http.get(
"/webService/" +
releases->first() +
"_changelog.html");
00357 }
00358 }
00359
else
00360 {
00361
getMode =
UNSET;
00362 }
00363 }
00364
00365
00366
else if(
getMode ==
GET_UPCOMING_FEATURES)
00367 {
00368
00369 QFile fetchedDoc(
TEMP_DIR + QString(
"/upcomingFeatures.html") );
00370
if(fetchedDoc.open(IO_WriteOnly))
00371 {
00372
00373 QTextStream stream( &fetchedDoc );
00374 stream.setEncoding( QTextStream::UnicodeUTF8 );
00375 stream << QString(
http.readAll() );
00376 fetchedDoc.close();
00377
00378
00379
upcomingFeatures =
new QTextBrowser(
this);
00380
upcomingFeatures->setFrameStyle( QFrame::Panel | QFrame::Sunken );
00381
upcomingFeatures->mimeSourceFactory()->setFilePath(
TEMP_DIR );
00382
upcomingFeatures->setSource(
"upcomingFeatures.html" );
00383
tabWidget->addTab(
upcomingFeatures,
00384 QIconSet( QPixmap(QString(
IMAGE_PATH)+
"tabIcons/upcomingFeatures.png") ),
00385 tr(
"Upcoming Features") );
00386
00387
if(
displayMode ==
UPCOMING)
00388
tabWidget->setCurrentPage(
tabWidget->indexOf(
upcomingFeatures ) );
00389
00390
00391 QDir rootDir(
TEMP_DIR );
00392 rootDir.remove(
"upcomingFeatures.html");
00393 }
00394
00395
getMode =
UNSET;
00396 }
00397
00398 }
00399
00400 void About::closeEvent( QCloseEvent* e)
00401 {
00402 QWidget::closeEvent( e );
00403 emit
closed();
00404 }
00405
00406 void About::reject()
00407 {
00408 QDialog::reject();
00409 emit
closed();
00410 }
00411