Mercurial > trustbridge
comparison ui/administratorwindow.cpp @ 1001:0b7bb4f68f5a
(issue89) Add Help button
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 02 Sep 2014 10:43:51 +0200 |
parents | 75cd2fbf9ac6 |
children | bd2cb6bdb1c5 |
comparison
equal
deleted
inserted
replaced
1000:c6c8f4ce48f8 | 1001:0b7bb4f68f5a |
---|---|
21 #include <QCheckBox> | 21 #include <QCheckBox> |
22 #include <QHeaderView> | 22 #include <QHeaderView> |
23 #include <QFileDialog> | 23 #include <QFileDialog> |
24 #include <QStandardPaths> | 24 #include <QStandardPaths> |
25 #include <QSortFilterProxyModel> | 25 #include <QSortFilterProxyModel> |
26 #include <QDesktopServices> | |
27 #include <QFileInfo> | |
26 | 28 |
27 #include "certificatetabledelegate.h" | 29 #include "certificatetabledelegate.h" |
28 #include "createinstallerdialog.h" | 30 #include "createinstallerdialog.h" |
29 #include "createcertlistdialog.h" | 31 #include "createcertlistdialog.h" |
30 #include "certificatediffdialog.h" | 32 #include "certificatediffdialog.h" |
31 #include "aboutdialog.h" | 33 #include "aboutdialog.h" |
34 #include "util.h" | |
35 | |
36 #define HELP_PATH "/doc/index.html" | |
32 | 37 |
33 AdministratorWindow::AdministratorWindow() { | 38 AdministratorWindow::AdministratorWindow() { |
34 setWindowTitle(tr("TrustBridge Administration")); | 39 setWindowTitle(tr("TrustBridge Administration")); |
35 QString path = QStandardPaths::locate( | 40 QString path = QStandardPaths::locate( |
36 QStandardPaths::DataLocation, QString("current_certificates.txt")); | 41 QStandardPaths::DataLocation, QString("current_certificates.txt")); |
51 menuBar = new QMenuBar(this); | 56 menuBar = new QMenuBar(this); |
52 QMenu *menu = new QMenu(tr("Menu"), menuBar); | 57 QMenu *menu = new QMenu(tr("Menu"), menuBar); |
53 menuBar->addMenu(menu); | 58 menuBar->addMenu(menu); |
54 QAction *createInstaller = menu->addAction(tr("Create installer ...")); | 59 QAction *createInstaller = menu->addAction(tr("Create installer ...")); |
55 QAction *about = menu->addAction(tr("About TrustBridge")); | 60 QAction *about = menu->addAction(tr("About TrustBridge")); |
61 QAction *help = menu->addAction(tr("Help")); | |
62 help->setIcon(QIcon(":/img/show-help_16.png")); | |
56 menu->addSeparator(); | 63 menu->addSeparator(); |
57 QAction *quit = menu->addAction(tr("Quit")); | 64 QAction *quit = menu->addAction(tr("Quit")); |
58 connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller())); | 65 connect(createInstaller, SIGNAL(triggered()), this, SLOT(createInstaller())); |
59 connect(about, SIGNAL(triggered()), this, SLOT(showAbout())); | 66 connect(about, SIGNAL(triggered()), this, SLOT(showAbout())); |
67 connect(help, SIGNAL(triggered()), this, SLOT(showHelp())); | |
60 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit())); | 68 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit())); |
61 setMenuBar(menuBar); | 69 setMenuBar(menuBar); |
62 } | 70 } |
63 | 71 |
64 void AdministratorWindow::createContent() | 72 void AdministratorWindow::createContent() |
296 changed.append(cert); | 304 changed.append(cert); |
297 } | 305 } |
298 } | 306 } |
299 return changed; | 307 return changed; |
300 } | 308 } |
309 | |
310 void AdministratorWindow::showHelp() | |
311 { | |
312 char *inst_dir = get_install_dir(); | |
313 if (!inst_dir) { | |
314 qDebug() << "Failed to find install dir"; | |
315 return; | |
316 } | |
317 QString helpPath = QString::fromUtf8(inst_dir); | |
318 helpPath += HELP_PATH; | |
319 QFileInfo fiHelp(helpPath); | |
320 qDebug() << "Opening help: " << fiHelp.absoluteFilePath(); | |
321 if (!fiHelp.exists()) { | |
322 QMessageBox::warning(this, tr("Error!"), tr ("Failed to find the manual")); | |
323 return; | |
324 } | |
325 #ifdef Q_OS_WIN | |
326 QDesktopServices::openUrl(QUrl("file:///" + fiHelp.absoluteFilePath())); | |
327 #else | |
328 QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath())); | |
329 #endif | |
330 free (inst_dir); | |
331 return; | |
332 } |