Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

helpWindow.cpp

Go to the documentation of this file.
00001 //==============================================
00002 //  copyright            : (C) 2003-2005 by Will Stokes
00003 //==============================================
00004 //  This program is free software; you can redistribute it
00005 //  and/or modify it under the terms of the GNU General
00006 //  Public License as published by the Free Software
00007 //  Foundation; either version 2 of the License, or
00008 //  (at your option) any later version.
00009 //==============================================
00010 
00011 //Systemwide includes
00012 #include <qfile.h>
00013 #include <qtextstream.h>
00014 #include <qstringlist.h>
00015 
00016 #include <qlabel.h>
00017 #include <qpushbutton.h>
00018 #include <qlayout.h>
00019 #include <qsizegrip.h>
00020 #include <qkeysequence.h>
00021 
00022 //Projectwide includes
00023 #include "helpWindow.h"
00024 #include "contents.h"
00025 #include "whatsNew.h"
00026 #include "importing.h"
00027 #include "annotating.h"
00028 #include "framing.h"
00029 #include "enhancing.h"
00030 #include "proTools.h"
00031 #include "manipulating.h"
00032 #include "loadSave.h"
00033 #include "shortcuts.h"
00034 
00035 #include "../ALabel.h"
00036 #include "../../config.h"
00037 
00038 //==============================================
00039 HelpWindow::HelpWindow( QWidget* parent, const char* name ) : QDialog(parent,name)
00040 {
00041   //determine necessary encoding for reading and writing to html files
00042   QTextStream::Encoding fileEncoding;
00043   QString savingCharSet;
00044   QString loadingCharSet;
00045 
00046   //Mac OSX -> Use UTF16
00047   #if defined(Q_OS_MACX)
00048   fileEncoding = QTextStream::Unicode;
00049   savingCharSet = "utf16";
00050   loadingCharSet = "UTF-16";
00051   
00052   //Other UNIX or Windows with Unicode support -> Use UTF8
00053   #elif !defined(Q_WS_WIN) || (defined(Q_WS_WIN) && defined(UNICODE))
00054   fileEncoding = QTextStream::UnicodeUTF8;
00055   savingCharSet = "utf8";
00056   loadingCharSet = "UTF-8";
00057 
00058   //Windows without Unicode support (Win95/98/ME) -> Use Latin-1
00059   #else
00060   fileEncoding = QTextStream::Latin1;
00061   savingCharSet = "latin-1";
00062   loadingCharSet = "latin-1";
00063   #endif
00064   //-------------------------------------------------------------
00065   //generate html pages
00066   WhatsNew::generateHTML    (fileEncoding, savingCharSet);
00067   Importing::generateHTML   (fileEncoding, savingCharSet);
00068   Annotating::generateHTML  (fileEncoding, savingCharSet);
00069   Framing::generateHTML     (fileEncoding, savingCharSet);
00070   Enhancing::generateHTML   (fileEncoding, savingCharSet);
00071   ProTools::generateHTML    (fileEncoding, savingCharSet);
00072   Manipulating::generateHTML(fileEncoding, savingCharSet);
00073   LoadSave::generateHTML    (fileEncoding, savingCharSet);
00074   Shortcuts::generateHTML   (fileEncoding, savingCharSet);
00075   
00076   resize( 800, 400 );
00077   setPaletteBackgroundColor( QColor(255,255,255) );
00078 
00079   //set window title
00080   setCaption( tr("Album Shaper: Help"));
00081   //--
00082   //create billboard widget
00083   billboard = new ALabel( this, "helpBillboard", NULL,
00084                                   APPEAR_IMMEDIATELY, SLIDE_OUT_LEFT );
00085   billboard->setPixmap( QPixmap( QString(IMAGE_PATH)+"helpImages/helpBillboard.png") );
00086   currentPage = BILLBOARD;
00087   connect( billboard, SIGNAL(pixmapRemoved()),
00088            this, SLOT(showFirstSelection()) );
00089 
00090   //construct special mime source factory for loading html files for the contents and content frames
00091   loadingMimeSource = new QMimeSourceFactory();
00092   loadingMimeSource->setExtensionType("html",QString("text/html;charset=%1").arg(loadingCharSet) );
00093 
00094   //create contents widget
00095   Contents* contents = new Contents(fileEncoding, savingCharSet, loadingMimeSource, this);
00096   connect( contents, SIGNAL(setPage(HELP_PAGE)),
00097            this, SLOT(setPage(HELP_PAGE)) );
00098 
00099   //create widget for holding content
00100   content = new QTextBrowser( this );
00101   content->setHScrollBarMode( QScrollView::Auto );
00102   content->setVScrollBarMode( QScrollView::Auto );
00103   content->setMimeSourceFactory( loadingMimeSource );
00104   
00105   //PLATFORM_SPECIFIC_CODE
00106   //mac os x puts in a size grip that can interfere with the updates icon, in order
00107   //to avoid this we manually place the size grip ourselves
00108   //windows users expect a grip too, but qt doesn't put one in by default. we'll add
00109   //it for them too. :-)
00110 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
00111   content->setCornerWidget( new QSizeGrip(this) );
00112 #endif
00113     
00114   content->hide();
00115   //--
00116   //place items in grid layout
00117   QGridLayout* grid = new QGridLayout( this, 4, 3, 0);
00118   grid->addMultiCellWidget( billboard, 0,2, 0,0, Qt::AlignHCenter | Qt::AlignTop );
00119   grid->addWidget( contents, 1,1 );
00120   grid->addMultiCellWidget( content, 0,2, 2,2 );
00121 
00122   grid->setRowSpacing( 0, QMAX(billboard->sizeHint().height() - 
00123                                contents->minimumSizeHint().height(), 0)/2 );
00124   grid->setColSpacing( 1, contents->minimumSizeHint().width() );
00125   grid->setRowStretch( 1, 1 );
00126   grid->setColStretch( 2, 1 );
00127   //--
00128   //PLATFORM_SPECIFIC_CODE - Close Button
00129 #if (!defined(Q_OS_WIN) && !defined(Q_OS_MACX))
00130   QPushButton* closeButton = new QPushButton( tr("Close"), this );
00131   closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00132   closeButton->setDefault(true);
00133   connect( closeButton, SIGNAL(clicked()), SLOT(close()) );
00134   grid->addMultiCellWidget( closeButton, 3,3, 0,2, Qt::AlignCenter );
00135 #endif  
00136   //--
00137 }
00138 //==============================================
00139 HelpWindow::~HelpWindow()
00140 {
00141   delete loadingMimeSource;
00142   loadingMimeSource = NULL;
00143 }
00144 //==============================================
00145 void HelpWindow::closeEvent( QCloseEvent* e)
00146 {
00147   QWidget::closeEvent( e );
00148   emit closed();
00149 }
00150 //==============================================
00151 void HelpWindow::reject()
00152 {
00153   QDialog::reject();
00154   emit closed();
00155 }
00156 //==============================================
00157 void HelpWindow::setPage(HELP_PAGE page)
00158 {
00159   //if billboard stillshown first remove it.
00160   if( currentPage == BILLBOARD )
00161   {
00162     billboard->removePixmap();
00163     currentPage = page;
00164     
00165     //show page only once billboard has finished sliding away to the left
00166   }
00167   else
00168   {
00169     currentPage = page;
00170     showCurrentPage();
00171   }
00172 }
00173 //==============================================
00174 void HelpWindow::showFirstSelection()
00175 {
00176   content->show();
00177   showCurrentPage();
00178 }
00179 //==============================================
00180 void HelpWindow::showCurrentPage()
00181 {
00182   if( currentPage == KEYBOARD_SHORTCUTS )
00183     content->setSource( Shortcuts::filename() );
00184   else if( currentPage == WHATS_NEW )
00185     content->setSource( WhatsNew::filename() );
00186 
00187   else if( currentPage == IMPORTING_AND_ORGANIZING )
00188     content->setSource( Importing::filename() );
00189   else if( currentPage == ANNOTATING_ALBUMS )
00190     content->setSource( Annotating::filename() );
00191   else if( currentPage == FRAMING )
00192     content->setSource( Framing::filename() );
00193   else if( currentPage == ENHANCING )
00194     content->setSource( Enhancing::filename() );
00195   else if( currentPage == PRO_TOOLS )
00196     content->setSource( ProTools::filename() );
00197   else if( currentPage == MANIPULATING )
00198     content->setSource( Manipulating::filename() );
00199   else if( currentPage == SAVING_AND_LOADING )
00200     content->setSource( LoadSave::filename() );
00201   else
00202     content->setText("");
00203   
00204   content->setFocus();
00205 }
00206 //==============================================
00207 
00208 

Generated on Sat Apr 2 05:44:04 2005 for AlbumShaper by  doxygen 1.3.9.1