From ce392857bc680ef0dd895ccb2e02909389c26a33 Mon Sep 17 00:00:00 2001 From: ubbo Date: Mon, 5 Dec 2011 23:19:46 +0000 Subject: add functonality for opening online help in qtextbrowser tab git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@656 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- gpg4usb.pro | 6 ++++-- helppage.cpp | 17 +++++++++++++++++ helppage.h | 20 ++++++++++++++++++++ mainwindow.cpp | 3 ++- textedit.cpp | 9 +++++++++ textedit.h | 9 +++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 helppage.cpp create mode 100644 helppage.h diff --git a/gpg4usb.pro b/gpg4usb.pro index c7917db..772dda1 100644 --- a/gpg4usb.pro +++ b/gpg4usb.pro @@ -35,7 +35,8 @@ HEADERS += attachments.h \ verifynotification.h \ verifydetailsdialog.h \ verifykeydetailbox.h \ - wizard.h + wizard.h \ + helppage.h SOURCES += attachments.cpp \ gpgcontext.cpp \ @@ -58,7 +59,8 @@ SOURCES += attachments.cpp \ verifynotification.cpp \ verifydetailsdialog.cpp \ verifykeydetailbox.cpp \ - wizard.cpp + wizard.cpp \ + helppage.cpp RC_FILE = gpg4usb.rc diff --git a/helppage.cpp b/helppage.cpp new file mode 100644 index 0000000..144b044 --- /dev/null +++ b/helppage.cpp @@ -0,0 +1,17 @@ +#include "helppage.h" + +HelpPage::HelpPage(const QString path, QWidget *parent) : + QWidget(parent) +{ + + QTextBrowser* browser = new QTextBrowser(); + QVBoxLayout* mainLayout = new QVBoxLayout(); + mainLayout->setSpacing(0); + mainLayout->addWidget(browser); + mainLayout->setContentsMargins(0,0,0,0); + setLayout(mainLayout); + //setAttribute(Qt::WA_DeleteOnClose); + browser->setSource(path); + browser->setFocus(); + +} diff --git a/helppage.h b/helppage.h new file mode 100644 index 0000000..c5bdc49 --- /dev/null +++ b/helppage.h @@ -0,0 +1,20 @@ +#ifndef HELPPAGE_H +#define HELPPAGE_H + +#include +#include +#include + +class HelpPage : public QWidget +{ + Q_OBJECT +public: + explicit HelpPage(const QString path, QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // HELPPAGE_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 75879f8..f1c56bb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -564,7 +564,8 @@ void MainWindow::openTranslate() { } void MainWindow::openTutorial() { - QDesktopServices::openUrl(QUrl("http://gpg4usb.cpunk.de/docu.html")); + //QDesktopServices::openUrl(QUrl("http://gpg4usb.cpunk.de/docu.html")); + edit->newHelpTab("help", "http://gpg4usb.cpunk.de/docu.html"); } void MainWindow::startWizard() diff --git a/textedit.cpp b/textedit.cpp index 064fa94..5ad8976 100644 --- a/textedit.cpp +++ b/textedit.cpp @@ -53,6 +53,15 @@ void TextEdit::newTab() connect(page->getTextPage(), SIGNAL(modificationChanged(bool)), this, SLOT(showModified())); } +void TextEdit::newHelpTab(QString title, QString path) +{ + + HelpPage *page = new HelpPage(path); + tabWidget->addTab(page, title); + tabWidget->setCurrentIndex(tabWidget->count() - 1); + +} + void TextEdit::open() { QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open file"), diff --git a/textedit.h b/textedit.h index 8c162c1..67efd7e 100644 --- a/textedit.h +++ b/textedit.h @@ -23,6 +23,7 @@ #define __TEXTEDIT_H__ #include "editorpage.h" +#include "helppage.h" #include "quitdialog.h" QT_BEGIN_NAMESPACE @@ -128,6 +129,14 @@ public slots: */ void newTab(); + /** + * @details Adds a new tab with the given title and opens given html file. + * Increase Tab-Count by one + * @param title title for the tab + * @param path path for html file to show + */ + void newHelpTab(QString title, QString path); + /** * @details put a * in front of current tabs title, if current textedit is modified */ -- cgit v1.2.3