HelpWindow
::HelpWindow(QWidget *parent, Qt
::WFlags fl
){
setupUi( this );
setupActions();
setupToolbar();
openFile("index.html");
QString helpDir
= appDir.
currentPath() + "/doc/";
QString helpImages
= helpDir
+ "images";
helpPaths<<helpDir<<helpImages;
helpBrowser->setSearchPaths(helpPaths);
}
HelpWindow::~HelpWindow()
{
}
void HelpWindow::setupActions()
{
forwardAct
= new QAction(QIcon(":MyApp/images/forward_arrow.png"), tr
("Forward"),
this);
forwardAct->setStatusTip(tr("Go Forward"));
connect(forwardAct, SIGNAL(triggered()), this, SLOT(goForward()));
backAct
= new QAction(QIcon(":MyApp/images/back_arrow.png"), tr
("Back"),
this);
backAct->setStatusTip(tr("Go Back"));
connect(backAct, SIGNAL(triggered()), this, SLOT(goBack()));
homeAct
= new QAction(QIcon(":MyApp/images/home.png"), tr
("Home"),
this);
homeAct->setStatusTip(tr("Go Home"));
connect(homeAct, SIGNAL(triggered()), this, SLOT(helpBrowser->home()));
}
void HelpWindow::setupToolbar()
{
navToolBar = addToolBar(tr("Nav"));
navToolBar->addAction(backAct);
navToolBar->addAction(forwardAct);
navToolBar->addAction(homeAct);
}
void HelpWindow
::openFile(const QString &fileName
) {
QString fileToLoad
= appDir.
currentPath() + "/doc/"+fileName;
if (fileInfo.exists()) loadFile(fileToLoad);
}
void HelpWindow
::loadFile(const QString &fileName
) {
.arg(fileName).arg(file.errorString()));
return;
}
helpBrowser->setHtml(in.readAll());
}
void HelpWindow::goForward()
{
helpBrowser->forward();
}
void HelpWindow::goBack()
{
helpBrowser->backward();
}
HelpWindow::HelpWindow(QWidget *parent, Qt::WFlags fl)
: QMainWindow(parent, fl)
{
setupUi( this );
setupActions();
setupToolbar();
openFile("index.html");
QDir appDir;
QString helpDir = appDir.currentPath() + "/doc/";
QString helpImages = helpDir + "images";
QStringList helpPaths;
helpPaths<<helpDir<<helpImages;
helpBrowser->setSearchPaths(helpPaths);
}
HelpWindow::~HelpWindow()
{
}
void HelpWindow::setupActions()
{
forwardAct = new QAction(QIcon(":MyApp/images/forward_arrow.png"), tr("Forward"), this);
forwardAct->setStatusTip(tr("Go Forward"));
connect(forwardAct, SIGNAL(triggered()), this, SLOT(goForward()));
backAct = new QAction(QIcon(":MyApp/images/back_arrow.png"), tr("Back"), this);
backAct->setStatusTip(tr("Go Back"));
connect(backAct, SIGNAL(triggered()), this, SLOT(goBack()));
homeAct = new QAction(QIcon(":MyApp/images/home.png"), tr("Home"), this);
homeAct->setStatusTip(tr("Go Home"));
connect(homeAct, SIGNAL(triggered()), this, SLOT(helpBrowser->home()));
}
void HelpWindow::setupToolbar()
{
navToolBar = addToolBar(tr("Nav"));
navToolBar->addAction(backAct);
navToolBar->addAction(forwardAct);
navToolBar->addAction(homeAct);
}
void HelpWindow::openFile(const QString &fileName)
{
QDir appDir;
QString fileToLoad = appDir.currentPath() + "/doc/"+fileName;
QFileInfo fileInfo(fileToLoad);
if (fileInfo.exists()) loadFile(fileToLoad);
}
void HelpWindow::loadFile(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, "Program Help", QString("Cannot read file %1: \n%2. ")
.arg(fileName).arg(file.errorString()));
return;
}
QTextStream in(&file);
helpBrowser->setHtml(in.readAll());
}
void HelpWindow::goForward()
{
helpBrowser->forward();
}
void HelpWindow::goBack()
{
helpBrowser->backward();
}
To copy to clipboard, switch view to plain text mode
Bookmarks