GUI: some fixes of help

* moved the help file to the application folder
 * use absolute path instead of relative path for helpfile
 * show warning messages if help file doesn't exist or fails to be loaded
This commit is contained in:
Daniel Marjamäki 2010-08-25 20:08:07 +02:00
parent c0c4d18120
commit 4d6b7bea2e
3 changed files with 49 additions and 21 deletions

View File

@ -52,12 +52,17 @@ HelpWindow::HelpWindow(QWidget *parent) :
m_ui(new Ui::HelpWindow) m_ui(new Ui::HelpWindow)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
helpEngine = NULL;
}
setVisible(true); bool HelpWindow::load(const QString &helpFile)
helpEngine = new QHelpEngine("help/online-help.qhc", this);
if (helpEngine->setupData())
{ {
helpEngine = new QHelpEngine(helpFile, this);
if (!helpEngine->setupData())
{
return false;
}
QSplitter *helpPanel = new QSplitter(Qt::Horizontal); QSplitter *helpPanel = new QSplitter(Qt::Horizontal);
HelpBrowser *helpBrowser = new HelpBrowser(helpEngine, this); HelpBrowser *helpBrowser = new HelpBrowser(helpEngine, this);
@ -75,7 +80,8 @@ HelpWindow::HelpWindow(QWidget *parent) :
connect(m_ui->homeButton, SIGNAL(clicked()), helpBrowser, SLOT(home())); connect(m_ui->homeButton, SIGNAL(clicked()), helpBrowser, SLOT(home()));
//connect(m_ui->zoomInButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomIn())); //connect(m_ui->zoomInButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomIn()));
//connect(m_ui->zoomOutButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomOut())); //connect(m_ui->zoomOutButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomOut()));
}
return true;
} }
HelpWindow::~HelpWindow() HelpWindow::~HelpWindow()

View File

@ -41,6 +41,12 @@ public:
HelpWindow(QWidget *parent = 0); HelpWindow(QWidget *parent = 0);
~HelpWindow(); ~HelpWindow();
/**
* load a *.qhc file and setup GUI. the file must exist.
* @return false if loading failed
*/
bool load(const QString &helpFile);
private: private:
Ui::HelpWindow *m_ui; Ui::HelpWindow *m_ui;

View File

@ -684,7 +684,23 @@ void MainWindow::OpenHelpContents()
void MainWindow::OpenHtmlHelpContents() void MainWindow::OpenHtmlHelpContents()
{ {
if (mHelpWindow == NULL) if (mHelpWindow == NULL)
{
const QString fname = qApp->applicationDirPath() + "/online-help.qhc";
if (!QFileInfo(fname).exists())
{
QMessageBox::warning(this, tr("Cppcheck Help"), tr("Failed to load help file (not found)"));
return;
}
mHelpWindow = new HelpWindow; mHelpWindow = new HelpWindow;
if (!mHelpWindow->load(fname))
{
delete mHelpWindow;
mHelpWindow = NULL;
QMessageBox::warning(this, tr("Cppcheck Help"), tr("Failed to load help file"));
return;
}
}
mHelpWindow->show(); mHelpWindow->show();
if (!mHelpWindow->isActiveWindow()) if (!mHelpWindow->isActiveWindow())