|
AlbumShaper
1.0a3
|
#include <about.h>


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 | |
| QGridLayout * | grid |
| QMovie * | albumShaperAgingImage |
| QLabel * | albumShaperLogo |
| QLabel * | progDesc |
| QLabel * | progURL |
| QTabWidget * | tabWidget |
| QTextBrowser * | credits |
| QTextBrowser * | history |
| QTextBrowser * | newImprovements |
| QTextBrowser * | upcomingFeatures |
| QPushButton * | closeButton |
| Close button. | |
| QStringList * | releases |
| QHttp | http |
| int | getMode |
| int | displayMode |
| About::About | ( | int | mode, |
| QWidget * | parent = 0, |
||
| const char * | name = 0 |
||
| ) |
Definition at line 46 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.
: QDialog(parent,name) { displayMode = mode; //-------------------------------------------------------------- QColor white(255, 255, 255); QColor darkBlue(35, 75, 139); QColor black(0, 0, 0); //-------------------------------------------------------------- //by default not getting anything getMode = UNSET; //-- //set window title setCaption( tr("About Album Shaper")); //-- //application logo QFrame* logoFrame = new QFrame( this ); logoFrame->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); albumShaperLogo = new QLabel( logoFrame ); albumShaperLogo->setPixmap( QPixmap( QString(IMAGE_PATH)+"miscImages/albumShaper.png" ) ); //-- //if user chooses to get product updates information releases = NULL; if(((Window*)(qApp->mainWidget()))->getConfig()->getBool( "alerts", "showSoftwareUpdateAlerts")) { //set http host http.setHost( "albumshaper.sourceforge.net" ); connect( &http, SIGNAL(done(bool)), this, SLOT(fileFetched(bool)) ); //-- //attempt to get releases list from website. this lets us find out if this //copy of Album Shaper is outdated, and also allows us to know what //changelogs to get. getMode = GET_RELEASES; http.get( "/webService/releases.xml"); } //-- //text labels QDate currentDate = QDate::currentDate(); int copyYearFirst = QMIN( currentDate.year(), 2003 ); int copyYearLast = QMAX( currentDate.year(), 2004 ); progDesc = new QLabel( QString("Album Shaper " + QString(ALBUMSHAPER_VERSION) + ", © %1-%2 Will Stokes").arg(copyYearFirst).arg(copyYearLast), logoFrame ); progURL = new QLabel( "http://albumshaper.sourceforge.net", logoFrame ); QFont textFont = progDesc->font(); textFont.setWeight(QFont::Bold); progDesc->setFont( textFont ); progURL->setFont( textFont ); //-- //tab widget which contains credits, changelog, etc tabWidget = new QTabWidget( this ); //-- //create credits tab credits = new QTextBrowser( this ); credits->setFrameStyle( QFrame::Panel | QFrame::Sunken ); credits->mimeSourceFactory()->setFilePath( QStringList(TEXT_PATH) ); credits->setSource( "about.html"); tabWidget->addTab(credits, QIconSet( QPixmap(QString(IMAGE_PATH)+"tabIcons/credits.png") ), tr("Credits") ); //-- //create history tab history = new QTextBrowser(this); history->setFrameStyle( QFrame::Panel | QFrame::Sunken ); history->mimeSourceFactory()->setFilePath( QStringList(TEXT_PATH) ); history->setSource( "history.html"); tabWidget->addTab(history, QIconSet( QPixmap(QString(IMAGE_PATH)+"tabIcons/history.png") ), tr("History") ); //-- //create close button closeButton = new QPushButton( //PLATFORM_SPECIFIC_CODE #ifndef Q_OS_MACX QPixmap(QString(IMAGE_PATH)+"buttonIcons/button_ok.png"), #endif tr("Close"), this ); closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); closeButton->setDefault(true); connect( closeButton, SIGNAL(clicked()), SLOT(close()) ); //-- logoFrame->setPaletteBackgroundColor( darkBlue ); progDesc->setPaletteForegroundColor( white ); progDesc->setPaletteBackgroundColor( darkBlue ); progURL->setPaletteForegroundColor( white ); progURL->setPaletteBackgroundColor( darkBlue ); tabWidget->setPaletteForegroundColor( black ); //-- QGridLayout* logoGrid = new QGridLayout( logoFrame, 4, 3, 0); logoGrid->setSpacing(WIDGET_SPACING); logoGrid->addWidget( albumShaperLogo, 0, 1, Qt::AlignCenter ); logoGrid->addWidget( progDesc, 2, 1, Qt::AlignCenter ); logoGrid->addWidget( progURL, 3, 1, Qt::AlignCenter ); grid = new QGridLayout( this, 3, 1, 0); grid->setSpacing(WIDGET_SPACING); grid->addWidget( logoFrame, 0, 0 ); grid->addWidget( tabWidget, 1, 0 ); grid->addWidget( closeButton, 2, 0, Qt::AlignCenter ); resize( DEFAULT_WIDTH, DEFAULT_HEIGHT ); //-- //show secret images around Album Shaper's birthday (first release date - 4/3/2003) if( currentDate.year() > 2003 && currentDate.month() == 4 && currentDate.day() <= 3) { QLabel* cakeLogo = new QLabel(logoFrame); cakeLogo->setPixmap( QPixmap( QString(IMAGE_PATH)+"miscImages/birthdayL.png" ) ); QLabel* cakeLogo2 = new QLabel(logoFrame); cakeLogo2->setPixmap( QPixmap( QString(IMAGE_PATH)+"miscImages/birthdayR.png" ) ); QLabel* cakeMessage = new QLabel( QString( tr("Happy Birthday Album Shaper!") + QString(" %1 ").arg(currentDate.year() - 2003) + ( currentDate.year()-2003 == 1 ? tr("Year Old!") : tr("Years Old!")) ), logoFrame ); cakeMessage->setFont(textFont); cakeMessage->setPaletteForegroundColor( white ); //-- logoGrid->addWidget( cakeLogo, 0, 0, Qt::AlignCenter ); logoGrid->addWidget( cakeLogo2, 0, 2, Qt::AlignCenter ); logoGrid->addMultiCellWidget( cakeMessage, 1, 1, 0, 2, Qt::AlignCenter ); } //------------------------------- //set window to not be resizeable this->show(); setFixedSize(size()); //------------------------------- }
| About::~About | ( | ) |
| void About::closed | ( | ) | [signal] |
Referenced by closeEvent(), and reject().
| void About::closeEvent | ( | QCloseEvent * | e | ) | [private] |
Definition at line 400 of file about.cpp.
References closed().
{
QWidget::closeEvent( e );
emit closed();
}
| void About::fileFetched | ( | bool | error | ) | [private, slot] |
Definition at line 183 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().
{
//------------------------------------------------------------
//if unable to get file bail
if(error)
{
getMode = UNSET;
return;
}
//------------------------------------------------------------
//getting releases?
if(getMode == GET_RELEASES)
{
//write releases to temp file
QFile fetchedDoc( TEMP_DIR + QString("/releases.xml") );
if(fetchedDoc.open(IO_WriteOnly))
{
//----------------------------
//write to file
QTextStream stream( &fetchedDoc );
stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << QString( http.readAll() );
fetchedDoc.close();
//----------------------------
//parse xml file, construct string list of releases
//open file, bail if unable to
if( !fetchedDoc.open( IO_ReadOnly ) )
{
getMode = UNSET;
return;
}
//parse dom
QDomDocument xmlDom;
if( !xmlDom.setContent( &fetchedDoc ) )
{
fetchedDoc.close();
getMode = UNSET;
return;
}
//close file
fetchedDoc.close();
//construct stringlist of releases
releases = new QStringList();
QDomElement root = xmlDom.documentElement();
QDomNode node = root.firstChild();
QDomText val;
bool thisVersionFound = false;
while( !node.isNull() )
{
if( node.isElement() && node.nodeName() == "release" )
{
val = node.firstChild().toText();
if(!val.isNull())
{
//append release #
releases->append( QString(val.nodeValue()) );
//is release this version?
if( QString(val.nodeValue()).compare( QString(ALBUMSHAPER_VERSION) ) == 0 )
thisVersionFound = true;
}
}
node = node.nextSibling();
}
//else if this version is not first on list but it was found in list then newer releases exist
if(thisVersionFound && releases->first().compare( QString(ALBUMSHAPER_VERSION) ) != 0 )
{
//create new improvements file with beginning html and body tags
QFile fetchedDoc( TEMP_DIR + QString("/newImprovements.html") );
if(fetchedDoc.open(IO_WriteOnly))
{
QTextStream stream( &fetchedDoc ); stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << "<html><body bgcolor=\"white\" text=\"black\">\n";
stream << "<b><font size=\"+1\">" << tr("New improvements to Album Shaper are available in a new release!") << "<br><hr></font></b>";
fetchedDoc.close();
}
getMode = GET_NEW_IMPROVEMENTS;
http.get( "/webService/" + releases->first() + "_changelog.html");
}
//else we're up to date! move on to checking for new features in cvs!
else
{
newImprovements = new QTextBrowser( this );
newImprovements->setFrameStyle( QFrame::Panel | QFrame::Sunken );
newImprovements->mimeSourceFactory()->setFilePath( QStringList(TEXT_PATH) );
//bleeding edge message
if(!thisVersionFound)
{
newImprovements->setSource( "bleedingEdge.html");
}
else
{
newImprovements->setSource( "noUpdates.html");
}
tabWidget->addTab(newImprovements,
QIconSet( QPixmap(QString(IMAGE_PATH)+"tabIcons/newImprovements.png") ),
tr("Software Updates") );
if(displayMode == UPDATES)
tabWidget->setCurrentPage( tabWidget->indexOf( newImprovements ) );
getMode = GET_UPCOMING_FEATURES;
http.get( "/webService/upcomingFeatures.html");
}
//----------------------------
//delete file
QDir rootDir( TEMP_DIR );
rootDir.remove("releases.xml");
//----------------------------
}
else
{
getMode = UNSET;
}
}
//------------------------------------------------------------
else if(getMode == GET_NEW_IMPROVEMENTS)
{
//write additional changelog information to disk
QFile fetchedDoc( TEMP_DIR + QString("/newImprovements.html") );
if(fetchedDoc.open(IO_WriteOnly | IO_Append))
{
//write to file
QTextStream stream( &fetchedDoc );
stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << QString( http.readAll() );
fetchedDoc.close();
//pop of release from stack
releases->pop_front();
//if stack empty then or we've goten up to this version add new tab with changes
if(releases->isEmpty() ||
releases->first().compare( QString(ALBUMSHAPER_VERSION) ) == 0 )
{
//tack on the end body and html tags
if(fetchedDoc.open(IO_WriteOnly | IO_Append))
{
//write to file
QTextStream stream( &fetchedDoc );
stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << "</body></html>";
fetchedDoc.close();
newImprovements = new QTextBrowser(this);
newImprovements->setFrameStyle( QFrame::Panel | QFrame::Sunken );
newImprovements->mimeSourceFactory()->setFilePath( TEMP_DIR );
newImprovements->setSource( "newImprovements.html" );
tabWidget->addTab(newImprovements,
QIconSet( QPixmap(QString(IMAGE_PATH)+"tabIcons/newImprovements.png") ),
tr("Software Updates") );
tabWidget->setCurrentPage( tabWidget->indexOf( newImprovements ) );;
//move on to checking for upcoming features
getMode = GET_UPCOMING_FEATURES;
http.get( "/webService/upcomingFeatures.html");
}
else
{
getMode = UNSET;
}
}
//if not empty then get even more new features!
else
{
http.get( "/webService/" + releases->first() + "_changelog.html");
}
}
else
{
getMode = UNSET;
}
}
//------------------------------------------------------------
//getting upcoming features?
else if(getMode == GET_UPCOMING_FEATURES)
{
//write upcoming features to temp file
QFile fetchedDoc( TEMP_DIR + QString("/upcomingFeatures.html") );
if(fetchedDoc.open(IO_WriteOnly))
{
//write to file
QTextStream stream( &fetchedDoc );
stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << QString( http.readAll() );
fetchedDoc.close();
//add tab
upcomingFeatures = new QTextBrowser(this);
upcomingFeatures->setFrameStyle( QFrame::Panel | QFrame::Sunken );
upcomingFeatures->mimeSourceFactory()->setFilePath( TEMP_DIR );
upcomingFeatures->setSource( "upcomingFeatures.html" );
tabWidget->addTab(upcomingFeatures,
QIconSet( QPixmap(QString(IMAGE_PATH)+"tabIcons/upcomingFeatures.png") ),
tr("Upcoming Features") );
if(displayMode == UPCOMING)
tabWidget->setCurrentPage( tabWidget->indexOf( upcomingFeatures ) );
//delete file
QDir rootDir( TEMP_DIR );
rootDir.remove("upcomingFeatures.html");
}
getMode = UNSET;
}
//------------------------------------------------------------
}
| void About::reject | ( | ) | [private, slot] |
Definition at line 406 of file about.cpp.
References closed().
{
QDialog::reject();
emit closed();
}
QMovie* About::albumShaperAgingImage [private] |
QLabel* About::albumShaperLogo [private] |
QPushButton* About::closeButton [private] |
QTextBrowser* About::credits [private] |
int About::displayMode [private] |
Definition at line 78 of file about.h.
Referenced by About(), and fileFetched().
int About::getMode [private] |
Definition at line 75 of file about.h.
Referenced by About(), and fileFetched().
QGridLayout* About::grid [private] |
QTextBrowser* About::history [private] |
QHttp About::http [private] |
Definition at line 72 of file about.h.
Referenced by About(), and fileFetched().
QTextBrowser* About::newImprovements [private] |
Definition at line 63 of file about.h.
Referenced by fileFetched().
QLabel* About::progDesc [private] |
QLabel* About::progURL [private] |
QStringList* About::releases [private] |
Definition at line 69 of file about.h.
Referenced by About(), fileFetched(), and ~About().
QTabWidget* About::tabWidget [private] |
Definition at line 59 of file about.h.
Referenced by About(), and fileFetched().
QTextBrowser* About::upcomingFeatures [private] |
Definition at line 64 of file about.h.
Referenced by fileFetched().
1.7.5.1