changeset 1001:0b7bb4f68f5a

(issue89) Add Help button
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 02 Sep 2014 10:43:51 +0200
parents c6c8f4ce48f8
children e9ff3107b885
files ui/administratorwindow.cpp ui/administratorwindow.h
diffstat 2 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ui/administratorwindow.cpp	Tue Sep 02 09:49:27 2014 +0200
+++ b/ui/administratorwindow.cpp	Tue Sep 02 10:43:51 2014 +0200
@@ -23,12 +23,17 @@
 #include <QFileDialog>
 #include <QStandardPaths>
 #include <QSortFilterProxyModel>
+#include <QDesktopServices>
+#include <QFileInfo>
 
 #include "certificatetabledelegate.h"
 #include "createinstallerdialog.h"
 #include "createcertlistdialog.h"
 #include "certificatediffdialog.h"
 #include "aboutdialog.h"
+#include "util.h"
+
+#define HELP_PATH "/doc/index.html"
 
 AdministratorWindow::AdministratorWindow() {
     setWindowTitle(tr("TrustBridge Administration"));
@@ -53,10 +58,13 @@
     menuBar->addMenu(menu);
     QAction *createInstaller = menu->addAction(tr("Create installer ..."));
     QAction *about = menu->addAction(tr("About TrustBridge"));
+    QAction *help = menu->addAction(tr("Help"));
+    help->setIcon(QIcon(":/img/show-help_16.png"));
     menu->addSeparator();
     QAction *quit = menu->addAction(tr("Quit"));
     connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller()));
     connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
+    connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
     connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
     setMenuBar(menuBar);
 }
@@ -298,3 +306,27 @@
     }
     return changed;
 }
+
+void AdministratorWindow::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;
+    }
+#ifdef Q_OS_WIN
+    QDesktopServices::openUrl(QUrl("file:///" + fiHelp.absoluteFilePath()));
+#else
+    QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath()));
+#endif
+    free (inst_dir);
+    return;
+}
--- a/ui/administratorwindow.h	Tue Sep 02 09:49:27 2014 +0200
+++ b/ui/administratorwindow.h	Tue Sep 02 10:43:51 2014 +0200
@@ -60,6 +60,7 @@
 private slots:
     void createInstaller();
     void showAbout();
+    void showHelp();
     void loadCertificateFile();
     void saveCertificateFile();
     void addCertificates();

http://wald.intevation.org/projects/trustbridge/