00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qfile.h>
00013
#include <qstringlist.h>
00014
00015
00016
#include "contents.h"
00017
#include "../../config.h"
00018
00019 #define LINK_COLOR "#0a92dd"
00020 #define CURR_COLOR "#0e3980"
00021
00022
00023 Contents::Contents( QTextStream::Encoding type,
00024 QString saveCharSet, QMimeSourceFactory* loadingMimeSource,
00025
QWidget* parent,
const char* name ) :
QTextBrowser(parent,name)
00026 {
00027 this->type = type;
00028 this->saveCharSet = saveCharSet;
00029 this->setMimeSourceFactory( loadingMimeSource );
00030
00031
00032
currentPage =
BILLBOARD;
00033
generateHTML(type, saveCharSet);
00034
00035
00036 setHScrollBarMode( QScrollView::AlwaysOff );
00037 setVScrollBarMode( QScrollView::AlwaysOff );
00038 setFrameStyle( QFrame::NoFrame );
00039 setSource(
filename() );
00040
00041
00042
00043
int minH = heightForWidth( 1000 );
00044
int w;
00045
for(w=1; w<1000; w++)
00046 {
00047
if(heightForWidth(w) == minH )
break;
00048 }
00049
00050
optimalSize = QSize( w, heightForWidth(w) );
00051
00052
00053 connect(
this, SIGNAL(anchorClicked(
const QString&,
const QString&)),
00054
this, SLOT(
handleAnchorClick(
const QString&,
const QString&)) );
00055
00056 }
00057
00058 QSize
Contents::minimumSizeHint()
const
00059
{
00060
return optimalSize;
00061 }
00062
00063 void Contents::handleAnchorClick(
const QString &name,
const QString&)
00064 {
00065
HELP_PAGE nextPage =
INVALID;
00066
00067
00068
if( name.isNull() )
return;
00069
else if(name.compare(
"WHATS_NEW") == 0)
00070 nextPage =
WHATS_NEW;
00071
else if(name.compare(
"IMPORTING_AND_ORGANIZING") == 0)
00072 nextPage =
IMPORTING_AND_ORGANIZING;
00073
else if(name.compare(
"ANNOTATING_ALBUMS") == 0)
00074 nextPage =
ANNOTATING_ALBUMS;
00075
else if(name.compare(
"FRAMING") == 0)
00076 nextPage =
FRAMING;
00077
else if(name.compare(
"ENHANCING") == 0)
00078 nextPage =
ENHANCING;
00079
else if(name.compare(
"PRO_TOOLS") == 0)
00080 nextPage =
PRO_TOOLS;
00081
else if(name.compare(
"MANIPULATING") == 0)
00082 nextPage =
MANIPULATING;
00083
else if(name.compare(
"SAVING_AND_LOADING") == 0)
00084 nextPage =
SAVING_AND_LOADING;
00085
else if(name.compare(
"KEYBOARD_SHORTCUTS") == 0)
00086 nextPage =
KEYBOARD_SHORTCUTS;
00087
00088
if(nextPage !=
INVALID)
00089 {
00090
currentPage = nextPage;
00091
generateHTML(
type,
saveCharSet);
00092 reload();
00093 emit
setPage(
currentPage );
00094 }
00095 }
00096
00097 QString
Contents::filename()
00098 {
00099
return QString(
"%1/helpContents.html").arg(
TEMP_DIR);
00100 }
00101
00102 void Contents::generateHTML(QTextStream::Encoding type, QString charSet)
00103 {
00104
00105 QFile file(
filename() );
00106
if(file.open(IO_WriteOnly))
00107 {
00108
00109 QTextStream stream;
00110 stream.setEncoding( type );
00111 stream.setDevice( &file );
00112
00113 stream <<
"<html><head>\n";
00114 stream <<
"<meta http-equiv='Content-Type' content='text/html; charset=" << charSet <<
"'>\n";
00115 stream <<
"</head><body>\n";
00116 stream <<
"<center><table><tr><td>\n";
00117 stream <<
"<font face='Arial, sans-serif' size='+1'><b>\n";
00118
00119
printLink( stream, QString(tr(
"What's New")),
WHATS_NEW,
"WHATS_NEW" );
00120
00121 stream <<
"<p>" << tr(
"Tutorials:") <<
"\n";
00122
00123 stream <<
"<font size='+0'><ul>\n";
00124
00125 stream <<
"<li>\n";
00126
printLink( stream, QString(tr(
"Import & Organize")),
00127
IMPORTING_AND_ORGANIZING,
"IMPORTING_AND_ORGANIZING" );
00128
00129 stream <<
"<li>\n";
00130
printLink( stream, QString(tr(
"Annotating Albums")),
00131
ANNOTATING_ALBUMS,
"ANNOTATING_ALBUMS" );
00132
00133 stream <<
"<li>" << tr(
"Editing Photos:") <<
"\n";
00134
00135 stream <<
"<ol>\n";
00136 stream <<
"<li>\n";
00137
printLink( stream, QString(tr(
"Framing")),
00138
FRAMING,
"FRAMING" );
00139
00140 stream <<
"<li>\n";
00141
printLink( stream, QString(tr(
"Fix it Fast")),
00142
ENHANCING,
"ENHANCING" );
00143
00144 stream <<
"<li>\n";
00145
printLink( stream, QString(tr(
"Pro Tools")),
00146
PRO_TOOLS,
"PRO_TOOLS" );
00147
00148 stream <<
"<li>\n";
00149
printLink( stream, QString(tr(
"Manipulations")),
00150
MANIPULATING,
"MANIPULATING" );
00151 stream <<
"</ol>\n";
00152
00153 stream <<
"<li>\n";
00154
printLink( stream, QString(tr(
"Saving & Loading")),
00155
SAVING_AND_LOADING,
"SAVING_AND_LOADING" );
00156
00157 stream <<
"</ul></font>\n";
00158
00159
printLink( stream, QString(tr(
"Keyboard Shortcuts")),
KEYBOARD_SHORTCUTS,
"KEYBOARD_SHORTCUTS" );
00160
00161 stream <<
"</b></font>\n";
00162 stream <<
"</td></tr></table></center>\n";
00163 stream <<
"</body></html>\n";
00164 file.close();
00165 }
00166 }
00167
00168 void Contents::printLink( QTextStream& stream, QString text, HELP_PAGE anchor, QString anchorString )
00169 {
00170
if(
currentPage != anchor )
00171 {
00172 stream <<
"<font color='" <<
LINK_COLOR <<
"'>";
00173 stream <<
"<a name='" << anchorString <<
"'>";
00174 }
00175
else
00176 {
00177 stream <<
"<font color='" <<
CURR_COLOR <<
"'>";
00178 }
00179
00180 stream << text <<
"\n";
00181
00182
if(
currentPage != anchor )
00183 {
00184 stream <<
"</a>";
00185 }
00186 stream <<
"</font>\n";
00187 }
00188