[PATCH 2/2] Open external links in default browser

Dirk Hohndel dirk at hohndel.org
Thu Dec 5 07:34:24 UTC 2013


Thanks, Sergey,

both for the patch to the manual and for this one, that will also
address an issue Willem was facing.

I'm always thrilled when people step up and start contributing again as
you have done the last few weeks!

/D

On Thu, 2013-12-05 at 14:02 +0200, Sergey Starosek wrote:
> Signed-off-by: Sergey Starosek <sergey.starosek at gmail.com>
> ---
>  qt-ui/mainwindow.cpp | 8 ++++++++
>  qt-ui/mainwindow.h   | 2 ++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
> index e049179..c9b003d 100644
> --- a/qt-ui/mainwindow.cpp
> +++ b/qt-ui/mainwindow.cpp
> @@ -17,6 +17,7 @@
>  #include <QWebView>
>  #include <QTableView>
>  #include <QDesktopWidget>
> +#include <QDesktopServices>
>  #include "divelistview.h"
>  #include "starwidget.h"
>  
> @@ -489,6 +490,8 @@ void MainWindow::on_actionUserManual_triggered()
>  {
>  	if(!helpView){
>  		helpView = new QWebView();
> +		helpView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
> +		connect(helpView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedSlot(QUrl)));
>  	}
>  	QString searchPath = getSubsurfaceDataPath("Documentation");
>  	if (searchPath != "") {
> @@ -500,6 +503,11 @@ void MainWindow::on_actionUserManual_triggered()
>  	helpView->show();
>  }
>  
> +void MainWindow::linkClickedSlot(QUrl url)
> +{
> +	QDesktopServices::openUrl(url);
> +}
> +
>  QString MainWindow::filter()
>  {
>  	QString f;
> diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
> index c0d5f24..d4e10e8 100644
> --- a/qt-ui/mainwindow.h
> +++ b/qt-ui/mainwindow.h
> @@ -9,6 +9,7 @@
>  
>  #include <QMainWindow>
>  #include <QAction>
> +#include <QUrl>
>  
>  #include "ui_mainwindow.h"
>  
> @@ -102,6 +103,7 @@ private slots:
>  	void initialUiSetup();
>  
>  	void on_actionImportCSV_triggered();
> +	void linkClickedSlot(QUrl url);
>  
>  protected:
>  	void closeEvent(QCloseEvent *);




More information about the subsurface mailing list