From 3965a08b7b9de4b4b79b18513b7e5222d4fa3cd7 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 26 Mar 2011 16:06:11 +0200 Subject: [PATCH] GUI: Open online-help instead of local help. Local help does not currently work (ticket #2316) and building it is a bit painful in Windows. Hence it was decided on ticket #2677 and at IRC that we open on-line help from GUI until the local help issue is solved. --- gui/gui.pro | 4 -- gui/helpwindow.cpp | 92 ---------------------------------------- gui/helpwindow.h | 56 ------------------------ gui/helpwindow.ui | 103 --------------------------------------------- gui/mainwindow.cpp | 39 ++++------------- gui/mainwindow.h | 7 +-- 6 files changed, 9 insertions(+), 292 deletions(-) delete mode 100644 gui/helpwindow.cpp delete mode 100644 gui/helpwindow.h delete mode 100644 gui/helpwindow.ui diff --git a/gui/gui.pro b/gui/gui.pro index a238a6262..77ea29a9a 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -31,7 +31,6 @@ FORMS = main.ui \ projectfile.ui \ about.ui \ logview.ui \ - helpwindow.ui \ stats.ui TRANSLATIONS = cppcheck_fi.ts \ @@ -76,7 +75,6 @@ HEADERS += mainwindow.h \ csvreport.h \ logview.h \ filelist.h \ - helpwindow.h \ statsdialog.h \ checkstatistics.h @@ -105,7 +103,6 @@ SOURCES += main.cpp \ csvreport.cpp \ logview.cpp \ filelist.cpp \ - helpwindow.cpp \ statsdialog.cpp \ checkstatistics.cpp @@ -115,4 +112,3 @@ win32 { HEADERS += ../cli/resource.h LIBS += -lshlwapi } - diff --git a/gui/helpwindow.cpp b/gui/helpwindow.cpp deleted file mode 100644 index d3e3f249f..000000000 --- a/gui/helpwindow.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "helpwindow.h" -#include "ui_helpwindow.h" - -#include -#include -#include -#include - -/** @brief Help browser */ -class HelpBrowser : public QTextBrowser -{ -public: - HelpBrowser(QHelpEngine *helpEngine, QWidget *parent = 0) - : QTextBrowser(parent), helpEngine(helpEngine) - { - } - - QVariant loadResource(int type, const QUrl &url) - { - if (url.scheme() == "qthelp") - return QVariant(helpEngine->fileData(url)); - else - return QTextBrowser::loadResource(type, url); - } - -private: - QHelpEngine *helpEngine; -}; - - - -HelpWindow::HelpWindow(QWidget *parent) : - QWidget(parent), - m_ui(new Ui::HelpWindow) -{ - m_ui->setupUi(this); - helpEngine = NULL; -} - -bool HelpWindow::load(const QString &helpFile) -{ - helpEngine = new QHelpEngine(helpFile, this); - if (!helpEngine->setupData()) - { - return false; - } - - 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() -{ - delete helpEngine; - delete m_ui; -} - diff --git a/gui/helpwindow.h b/gui/helpwindow.h deleted file mode 100644 index 8bb224bed..000000000 --- a/gui/helpwindow.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Cppcheck - A tool for static C/C++ code analysis - * Copyright (C) 2007-2011 Daniel Marjamäki and Cppcheck team. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef HELPWINDOW_H -#define HELPWINDOW_H - -#include - -namespace Ui -{ -class HelpWindow; -} - -class QHelpEngine; - -/// @addtogroup GUI -/// @{ - -/** - * @brief Help Window - */ -class HelpWindow : public QWidget -{ - Q_OBJECT -public: - HelpWindow(QWidget *parent = 0); - ~HelpWindow(); - - /** - * load a *.qhc file and setup GUI. the file must exist. - * @return false if loading failed - */ - bool load(const QString &helpFile); - -private: - Ui::HelpWindow *m_ui; - - QHelpEngine *helpEngine; -}; - -#endif // HELPWINDOW_H diff --git a/gui/helpwindow.ui b/gui/helpwindow.ui deleted file mode 100644 index 8567b29e6..000000000 --- a/gui/helpwindow.ui +++ /dev/null @@ -1,103 +0,0 @@ - - - HelpWindow - - - - 0 - 0 - 714 - 454 - - - - Cppcheck Help - - - - - - - - Go back - - - Back - - - - :/images/go-previous.png:/images/go-previous.png - - - - 22 - 22 - - - - - - - - Go forward - - - Forward - - - - :/images/go-next.png:/images/go-next.png - - - - 22 - 22 - - - - - - - - Start - - - Home - - - - :/images/go-home.png:/images/go-home.png - - - - 22 - 22 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 1901b0a08..38e98c834 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -#include "mainwindow.h" #include #include #include @@ -27,6 +26,9 @@ #include #include #include +#include +#include +#include "mainwindow.h" #include "aboutdialog.h" #include "threadhandler.h" #include "fileviewdialog.h" @@ -36,14 +38,14 @@ #include "statsdialog.h" #include "logview.h" #include "filelist.h" -#include "helpwindow.h" + +static const QString OnlineHelpURL("http://cppcheck.sf.net/manual.pdf"); MainWindow::MainWindow() : mSettings(new QSettings("Cppcheck", "Cppcheck-GUI", this)), mApplications(new ApplicationList(this)), mTranslation(new TranslationHandler(this)), mLogView(NULL), - mHelpWindow(NULL), mProject(NULL), mExiting(false) { @@ -122,7 +124,6 @@ MainWindow::MainWindow() : MainWindow::~MainWindow() { delete mLogView; - delete mHelpWindow; delete mProject; } @@ -514,9 +515,6 @@ void MainWindow::closeEvent(QCloseEvent *event) // Check that we aren't checking files if (!mThread->IsChecking()) { - delete mHelpWindow; - mHelpWindow = NULL; - SaveSettings(); event->accept(); } @@ -695,33 +693,12 @@ void MainWindow::StopChecking() void MainWindow::OpenHelpContents() { - OpenHtmlHelpContents(); + OpenOnlineHelp(); } -void MainWindow::OpenHtmlHelpContents() +void MainWindow::OpenOnlineHelp() { - 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; - if (!mHelpWindow->load(fname)) - { - delete mHelpWindow; - mHelpWindow = NULL; - QMessageBox::warning(this, tr("Cppcheck Help"), tr("Failed to load help file")); - return; - } - } - - mHelpWindow->show(); - if (!mHelpWindow->isActiveWindow()) - mHelpWindow->activateWindow(); + QDesktopServices::openUrl(QUrl(OnlineHelpURL)); } void MainWindow::OpenProjectFile() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 9e3361c05..04cefede7 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -336,7 +336,7 @@ protected: /** * @brief Show help contents */ - void OpenHtmlHelpContents(); + void OpenOnlineHelp(); /** * @brief Enable or disable project file actions. @@ -400,11 +400,6 @@ protected: */ LogView *mLogView; - /** - * @brief Help window.. - */ - HelpWindow *mHelpWindow; - /** * @brief Project (file). */