Mercurial > trustbridge
changeset 940:7c89c5dc2200
(issue89) Add ui to open help in browser
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 22 Aug 2014 19:56:04 +0200 (2014-08-22) |
parents | 574cd1fae1dc |
children | e66e23d340b9 |
files | ui/mainwindow.cpp ui/mainwindow.h |
diffstat | 2 files changed, 41 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Fri Aug 22 19:55:08 2014 +0200 +++ b/ui/mainwindow.cpp Fri Aug 22 19:56:04 2014 +0200 @@ -29,6 +29,7 @@ #include <QButtonGroup> #include <QToolButton> #include <QStandardPaths> +#include <QDesktopServices> #include "certificatelist.h" #include "downloader.h" @@ -81,6 +82,14 @@ # endif #endif +/* Help installation path the path relative to the installation directory where + * the help is placed.*/ +#ifdef WIN32 +#define HELP_PATH "/doc/index.html" +#else +#define HELP_PATH "/../share/doc/trustbridge/index.html" +#endif + MainWindow::MainWindow(bool trayMode): mTrayMode(trayMode) { @@ -514,6 +523,14 @@ infoCenterLayout->insertSpacing(2, 10); infoCenterLayout->insertSpacing(4, 10); infoCenterLayout->insertSpacing(6, 10); + + QHBoxLayout *helpButtonLayout = new QHBoxLayout(); + QPushButton *helpButton = new QPushButton(tr("Show Help")); + connect(helpButton, SIGNAL(clicked()), this, SLOT(showHelp())); + helpButtonLayout->addWidget(helpButton); + helpButtonLayout->addStretch(); + infoCenterLayout->addLayout(helpButtonLayout); + infoCenterLayout->insertStretch(8, 10); infoPanelLayout->addLayout(infoHeaderLayout); @@ -1375,3 +1392,23 @@ emit changesChanged(QString("%1").arg(cnt)); } } + +void MainWindow::showHelp() +{ + char *inst_dir = get_install_dir(); + if (!inst_dir) { + qDebug() << "Failed to find install dir"; + return; + } + QString helpPath = QString::fromUtf8(inst_dir); + helpPath += HELP_PATH; + QFileInfo fiHelp(helpPath); + qDebug() << "Opening help: " << fiHelp.absoluteFilePath(); + if (!fiHelp.exists()) { + QMessageBox::warning(this, tr("Error!"), tr ("Failed to find the manual")); + return; + } + QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath())); + free (inst_dir); + return; +}