[PATCH] (issue89) Add Help button

Wald Commits scm-commit at wald.intevation.org
Tue Sep 2 10:44:46 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1409647431 -7200
# Node ID 0b7bb4f68f5acdfb5b2596a827706b9c011ddb0c
# Parent  c6c8f4ce48f8c04711afc90cf57e0c535fd8df11
(issue89) Add Help button

diff -r c6c8f4ce48f8 -r 0b7bb4f68f5a ui/administratorwindow.cpp
--- 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;
+}
diff -r c6c8f4ce48f8 -r 0b7bb4f68f5a ui/administratorwindow.h
--- 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();


More information about the Trustbridge-commits mailing list