comparison ui/mainwindow.cpp @ 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
parents 57371f2e8dae
children 879a634d0a40
comparison
equal deleted inserted replaced
939:574cd1fae1dc 940:7c89c5dc2200
27 #include <QImage> 27 #include <QImage>
28 #include <QCheckBox> 28 #include <QCheckBox>
29 #include <QButtonGroup> 29 #include <QButtonGroup>
30 #include <QToolButton> 30 #include <QToolButton>
31 #include <QStandardPaths> 31 #include <QStandardPaths>
32 #include <QDesktopServices>
32 33
33 #include "certificatelist.h" 34 #include "certificatelist.h"
34 #include "downloader.h" 35 #include "downloader.h"
35 #include "helpdialog.h" 36 #include "helpdialog.h"
36 #include "aboutdialog.h" 37 #include "aboutdialog.h"
79 # define SW_RESOURCE_VERSION "/users/aheinecke/development/TrustBridge-development" TB_ARCH_STRING ".sh" 80 # define SW_RESOURCE_VERSION "/users/aheinecke/development/TrustBridge-development" TB_ARCH_STRING ".sh"
80 # define SW_RESOURCE "/users/aheinecke/development/TrustBridge" TB_ARCH_STRING ".sh" 81 # define SW_RESOURCE "/users/aheinecke/development/TrustBridge" TB_ARCH_STRING ".sh"
81 # endif 82 # endif
82 #endif 83 #endif
83 84
85 /* Help installation path the path relative to the installation directory where
86 * the help is placed.*/
87 #ifdef WIN32
88 #define HELP_PATH "/doc/index.html"
89 #else
90 #define HELP_PATH "/../share/doc/trustbridge/index.html"
91 #endif
92
84 MainWindow::MainWindow(bool trayMode): 93 MainWindow::MainWindow(bool trayMode):
85 mTrayMode(trayMode) 94 mTrayMode(trayMode)
86 { 95 {
87 createActions(); 96 createActions();
88 createTrayIcon(); 97 createTrayIcon();
512 infoCenterLayout->addWidget(infoHeaderSeparator); 521 infoCenterLayout->addWidget(infoHeaderSeparator);
513 infoCenterLayout->addWidget(textDesc); 522 infoCenterLayout->addWidget(textDesc);
514 infoCenterLayout->insertSpacing(2, 10); 523 infoCenterLayout->insertSpacing(2, 10);
515 infoCenterLayout->insertSpacing(4, 10); 524 infoCenterLayout->insertSpacing(4, 10);
516 infoCenterLayout->insertSpacing(6, 10); 525 infoCenterLayout->insertSpacing(6, 10);
526
527 QHBoxLayout *helpButtonLayout = new QHBoxLayout();
528 QPushButton *helpButton = new QPushButton(tr("Show Help"));
529 connect(helpButton, SIGNAL(clicked()), this, SLOT(showHelp()));
530 helpButtonLayout->addWidget(helpButton);
531 helpButtonLayout->addStretch();
532 infoCenterLayout->addLayout(helpButtonLayout);
533
517 infoCenterLayout->insertStretch(8, 10); 534 infoCenterLayout->insertStretch(8, 10);
518 535
519 infoPanelLayout->addLayout(infoHeaderLayout); 536 infoPanelLayout->addLayout(infoHeaderLayout);
520 infoPanelLayout->addLayout(infoCenterLayout); 537 infoPanelLayout->addLayout(infoCenterLayout);
521 theWidget->setLayout(infoPanelLayout); 538 theWidget->setLayout(infoPanelLayout);
1373 if (mChangeCount != cnt) { 1390 if (mChangeCount != cnt) {
1374 mChangeCount = cnt; 1391 mChangeCount = cnt;
1375 emit changesChanged(QString("%1").arg(cnt)); 1392 emit changesChanged(QString("%1").arg(cnt));
1376 } 1393 }
1377 } 1394 }
1395
1396 void MainWindow::showHelp()
1397 {
1398 char *inst_dir = get_install_dir();
1399 if (!inst_dir) {
1400 qDebug() << "Failed to find install dir";
1401 return;
1402 }
1403 QString helpPath = QString::fromUtf8(inst_dir);
1404 helpPath += HELP_PATH;
1405 QFileInfo fiHelp(helpPath);
1406 qDebug() << "Opening help: " << fiHelp.absoluteFilePath();
1407 if (!fiHelp.exists()) {
1408 QMessageBox::warning(this, tr("Error!"), tr ("Failed to find the manual"));
1409 return;
1410 }
1411 QDesktopServices::openUrl(QUrl(fiHelp.absoluteFilePath()));
1412 free (inst_dir);
1413 return;
1414 }

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