00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
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
00042 QTextStream::Encoding fileEncoding;
00043 QString savingCharSet;
00044 QString loadingCharSet;
00045
00046
00047 #if defined(Q_OS_MACX)
00048 fileEncoding = QTextStream::Unicode;
00049 savingCharSet = "utf16";
00050 loadingCharSet = "UTF-16";
00051
00052
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
00059 #else
00060 fileEncoding = QTextStream::Latin1;
00061 savingCharSet = "latin-1";
00062 loadingCharSet = "latin-1";
00063 #endif
00064
00065
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
00080 setCaption( tr("Album Shaper: Help"));
00081
00082
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
00091 loadingMimeSource = new QMimeSourceFactory();
00092 loadingMimeSource->setExtensionType("html",QString("text/html;charset=%1").arg(loadingCharSet) );
00093
00094
00095 Contents* contents = new Contents(fileEncoding, savingCharSet, loadingMimeSource, this);
00096 connect( contents, SIGNAL(setPage(HELP_PAGE)),
00097 this, SLOT(setPage(HELP_PAGE)) );
00098
00099
00100 content = new QTextBrowser( this );
00101 content->setHScrollBarMode( QScrollView::Auto );
00102 content->setVScrollBarMode( QScrollView::Auto );
00103 content->setMimeSourceFactory( loadingMimeSource );
00104
00105
00106
00107
00108
00109
00110 #if defined(Q_OS_MACX) || defined(Q_OS_WIN)
00111 content->setCornerWidget( new QSizeGrip(this) );
00112 #endif
00113
00114 content->hide();
00115
00116
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
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
00160 if( currentPage == BILLBOARD )
00161 {
00162 billboard->removePixmap();
00163 currentPage = page;
00164
00165
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