Open HTML help from Help-menu in Windows.

This commit is contained in:
Kimmo Varis 2010-02-23 17:29:49 +02:00
parent e38694ccfc
commit 279e66a1d6
4 changed files with 55 additions and 2 deletions

View File

@ -69,7 +69,7 @@ SOURCES += main.cpp \
win32 {
RC_FILE = cppcheck-gui.rc
HEADERS += ../cli/resource.h
LIBS += -lshlwapi
LIBS += -lshlwapi -lhtmlhelp
}
# run lrelease before build

View File

@ -66,7 +66,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="mMenuFile">
@ -101,8 +101,10 @@
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="mActionHelpContents"/>
<addaction name="mActionLicense"/>
<addaction name="mActionAuthors"/>
<addaction name="separator"/>
<addaction name="mActionAbout"/>
</widget>
<widget class="QMenu" name="mMenuCheck">
@ -312,6 +314,17 @@
<string>&amp;Toolbar</string>
</property>
</action>
<action name="mActionHelpContents">
<property name="text">
<string>&amp;Contents</string>
</property>
<property name="statusTip">
<string>Open the help contents</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -34,6 +34,12 @@
#include "report.h"
#include "../lib/filelister.h"
// HTMLHelp is only available in Windows
#ifdef WIN32
#include <windows.h>
#include <htmlhelp.h>
#endif
MainWindow::MainWindow() :
mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)),
mApplications(new ApplicationList(this)),
@ -74,6 +80,13 @@ MainWindow::MainWindow() :
connect(mUI.mResults, SIGNAL(GotResults()), this, SLOT(ResultsAdded()));
connect(mUI.mMenuView, SIGNAL(aboutToShow()), this, SLOT(AboutToShowViewMenu()));
#ifdef WIN32
connect(mUI.mActionHelpContents, SIGNAL(triggered()), this, SLOT(OpenHelpContents()));
#else
// Hide if not Windows
mUI.mActionHelpContents.setVisible(false);
#endif
CreateLanguageMenuItems();
LoadSettings();
@ -640,3 +653,19 @@ void MainWindow::StopChecking()
mThread->Stop();
mUI.mResults->DisableProgressbar();
}
void MainWindow::OpenHelpContents()
{
OpenHtmlHelpContents();
}
void MainWindow::OpenHtmlHelpContents()
{
#ifdef WIN32
QString file("/cppcheck.chm");
QString exeFolder = QDir::currentPath();
exeFolder += file;
exeFolder = QDir::toNativeSeparators(exeFolder);
HtmlHelp(NULL, exeFolder.utf16(), HH_DISPLAY_TOPIC, NULL);
#endif // WIN32
}

View File

@ -179,6 +179,12 @@ protected slots:
*/
void StopChecking();
/**
* @brief Open help file contents
*
*/
void OpenHelpContents();
protected:
/**
@ -268,6 +274,11 @@ protected:
*/
void FormatAndSetTitle(const QString &text = QString());
/**
* @brief Show help contents
*/
void OpenHtmlHelpContents();
/**
* @brief Program settings
*