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:
parent
c0c4d18120
commit
4d6b7bea2e
|
@ -52,30 +52,36 @@ 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);
|
helpEngine = new QHelpEngine(helpFile, this);
|
||||||
if (helpEngine->setupData())
|
if (!helpEngine->setupData())
|
||||||
{
|
{
|
||||||
QSplitter *helpPanel = new QSplitter(Qt::Horizontal);
|
return false;
|
||||||
HelpBrowser *helpBrowser = new HelpBrowser(helpEngine, this);
|
|
||||||
|
|
||||||
helpPanel->insertWidget(0, helpEngine->contentWidget());
|
|
||||||
helpPanel->insertWidget(1, helpBrowser);
|
|
||||||
helpPanel->setStretchFactor(1, 1);
|
|
||||||
|
|
||||||
m_ui->mainLayout->addWidget(helpPanel);
|
|
||||||
|
|
||||||
connect(helpEngine->contentWidget(), SIGNAL(linkActivated(const QUrl &)),
|
|
||||||
helpBrowser, SLOT(setSource(const QUrl &)));
|
|
||||||
|
|
||||||
connect(m_ui->backButton, SIGNAL(clicked()), helpBrowser, SLOT(backward()));
|
|
||||||
connect(m_ui->forwardButton, SIGNAL(clicked()), helpBrowser, SLOT(forward()));
|
|
||||||
connect(m_ui->homeButton, SIGNAL(clicked()), helpBrowser, SLOT(home()));
|
|
||||||
//connect(m_ui->zoomInButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomIn()));
|
|
||||||
//connect(m_ui->zoomOutButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomOut()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSplitter *helpPanel = new QSplitter(Qt::Horizontal);
|
||||||
|
HelpBrowser *helpBrowser = new HelpBrowser(helpEngine, this);
|
||||||
|
|
||||||
|
helpPanel->insertWidget(0, helpEngine->contentWidget());
|
||||||
|
helpPanel->insertWidget(1, helpBrowser);
|
||||||
|
helpPanel->setStretchFactor(1, 1);
|
||||||
|
|
||||||
|
m_ui->mainLayout->addWidget(helpPanel);
|
||||||
|
|
||||||
|
connect(helpEngine->contentWidget(), SIGNAL(linkActivated(const QUrl &)),
|
||||||
|
helpBrowser, SLOT(setSource(const QUrl &)));
|
||||||
|
|
||||||
|
connect(m_ui->backButton, SIGNAL(clicked()), helpBrowser, SLOT(backward()));
|
||||||
|
connect(m_ui->forwardButton, SIGNAL(clicked()), helpBrowser, SLOT(forward()));
|
||||||
|
connect(m_ui->homeButton, SIGNAL(clicked()), helpBrowser, SLOT(home()));
|
||||||
|
//connect(m_ui->zoomInButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomIn()));
|
||||||
|
//connect(m_ui->zoomOutButton, SIGNAL(clicked()), helpBrowser, SLOT(zoomOut()));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpWindow::~HelpWindow()
|
HelpWindow::~HelpWindow()
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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())
|
||||||
|
|
Loading…
Reference in New Issue