diff --git a/gui/gui.pro b/gui/gui.pro index 126767590..62c82abe4 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -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 diff --git a/gui/main.ui b/gui/main.ui index 0bed176d0..473f33dca 100644 --- a/gui/main.ui +++ b/gui/main.ui @@ -66,7 +66,7 @@ 0 0 640 - 22 + 21 @@ -101,8 +101,10 @@ &Help + + @@ -312,6 +314,17 @@ &Toolbar + + + &Contents + + + Open the help contents + + + F1 + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 94ebe082a..afe25f88b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -34,6 +34,12 @@ #include "report.h" #include "../lib/filelister.h" +// HTMLHelp is only available in Windows +#ifdef WIN32 +#include +#include +#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 +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 9cb9089c2..485a80410 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -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 *