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->setFrameStyle( QFrame::NoFrame );
00104   content->setMimeSourceFactory( loadingMimeSource );
00105   
00106   //PLATFORM_SPECIFIC_CODE
00107   //mac os x puts in a size grip that can interfere with the updates icon, in order
00108   //to avoid this we manually place the size grip ourselves
00109   //windows users expect a grip too, but qt doesn't put one in by default. we'll add
00110   //it for them too. :-)
00111 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
00112   content->setCornerWidget( new QSizeGrip(this) );
00113 #endif
00114     
00115   content->hide();
00116   //--
00117   //place items in grid layout
00118   QGridLayout* grid = new QGridLayout( this, 4, 3, 0);
00119   grid->addMultiCellWidget( billboard, 0,2, 0,0, Qt::AlignHCenter | Qt::AlignTop );
00120   grid->addWidget( contents, 1,1 );
00121   grid->addMultiCellWidget( content, 0,2, 2,2 );
00122 
00123   grid->setRowSpacing( 0, QMAX(billboard->sizeHint().height() - 
00124                                contents->minimumSizeHint().height(), 0)/2 );
00125   grid->setColSpacing( 1, contents->minimumSizeHint().width() );
00126   grid->setRowStretch( 1, 1 );
00127   grid->setColStretch( 2, 1 );
00128   //--
00129   //PLATFORM_SPECIFIC_CODE - Close Button
00130 #if (!defined(Q_OS_WIN) && !defined(Q_OS_MACX))
00131   QPushButton* closeButton = new QPushButton( tr("Close"), this );
00132   closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
00133   closeButton->setDefault(true);
00134   connect( closeButton, SIGNAL(clicked()), SLOT(close()) );
00135   grid->addMultiCellWidget( closeButton, 3,3, 0,2, Qt::AlignCenter );
00136 #endif  
00137   //--
00138 }
00139 //==============================================
00140 HelpWindow::~HelpWindow()
00141 {
00142   delete loadingMimeSource;
00143   loadingMimeSource = NULL;
00144 }
00145 //==============================================
00146 void HelpWindow::closeEvent( QCloseEvent* e)
00147 {
00148   QWidget::closeEvent( e );
00149   emit closed();
00150 }
00151 //==============================================
00152 void HelpWindow::reject()
00153 {
00154   QDialog::reject();
00155   emit closed();
00156 }
00157 //==============================================
00158 void HelpWindow::setPage(HELP_PAGE page)
00159 {
00160   //if billboard stillshown first remove it.
00161   if( currentPage == BILLBOARD )
00162   {
00163     billboard->removePixmap();
00164     currentPage = page;
00165     
00166     //show page only once billboard has finished sliding away to the left
00167   }
00168   else
00169   {
00170     currentPage = page;
00171     showCurrentPage();
00172   }
00173 }
00174 //==============================================
00175 void HelpWindow::showFirstSelection()
00176 {
00177   content->show();
00178   showCurrentPage();
00179 }
00180 //==============================================
00181 void HelpWindow::showCurrentPage()
00182 {
00183   if( currentPage == KEYBOARD_SHORTCUTS )
00184     content->setSource( Shortcuts::filename() );
00185   else if( currentPage == WHATS_NEW )
00186     content->setSource( WhatsNew::filename() );
00187 
00188   else if( currentPage == IMPORTING_AND_ORGANIZING )
00189     content->setSource( Importing::filename() );
00190   else if( currentPage == ANNOTATING_ALBUMS )
00191     content->setSource( Annotating::filename() );
00192   else if( currentPage == FRAMING )
00193     content->setSource( Framing::filename() );
00194   else if( currentPage == ENHANCING )
00195     content->setSource( Enhancing::filename() );
00196   else if( currentPage == PRO_TOOLS )
00197     content->setSource( ProTools::filename() );
00198   else if( currentPage == MANIPULATING )
00199     content->setSource( Manipulating::filename() );
00200   else if( currentPage == SAVING_AND_LOADING )
00201     content->setSource( LoadSave::filename() );
00202   else
00203     content->setText("");
00204   
00205   content->setFocus();
00206 }
00207 //==============================================
00208 
00209 

Generated on Wed Jan 24 05:38:05 2007 for AlbumShaper by  doxygen 1.5.1