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.
This commit is contained in:
parent
3c2d3ca3a4
commit
3965a08b7b
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "helpwindow.h"
|
||||
#include "ui_helpwindow.h"
|
||||
|
||||
#include <QtHelp>
|
||||
#include <QtHelp/QHelpEngine>
|
||||
#include <QTextBrowser>
|
||||
#include <QSplitter>
|
||||
|
||||
/** @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;
|
||||
}
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HELPWINDOW_H
|
||||
#define HELPWINDOW_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
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
|
|
@ -1,103 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HelpWindow</class>
|
||||
<widget class="QWidget" name="HelpWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>714</width>
|
||||
<height>454</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Cppcheck Help</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="toolbarlLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="backButton">
|
||||
<property name="toolTip">
|
||||
<string>Go back</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Back</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gui.qrc">
|
||||
<normaloff>:/images/go-previous.png</normaloff>:/images/go-previous.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="forwardButton">
|
||||
<property name="toolTip">
|
||||
<string>Go forward</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Forward</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gui.qrc">
|
||||
<normaloff>:/images/go-next.png</normaloff>:/images/go-next.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="homeButton">
|
||||
<property name="toolTip">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Home</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="gui.qrc">
|
||||
<normaloff>:/images/go-home.png</normaloff>:/images/go-home.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>22</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="mainLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="gui.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -16,7 +16,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
|
@ -27,6 +26,9 @@
|
|||
#include <QKeySequence>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#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()
|
||||
|
|
|
@ -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).
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue