Skip to content
Permalink
Browse files

Merge pull request #6753 from m-kuhn/textbrowser

Allow clicking hyperlinks in HTML text edit widget
  • Loading branch information
m-kuhn committed Apr 9, 2018
2 parents e627b84 + 5ad1633 commit bff8976f3a79caec2af690a8adb983e4f6146d02
Showing with 11 additions and 2 deletions.
  1. +9 −1 src/gui/editorwidgets/qgstexteditwrapper.cpp
  2. +2 −1 src/gui/editorwidgets/qgstexteditwrapper.h
@@ -85,7 +85,7 @@ QWidget *QgsTextEditWrapper::createWidget( QWidget *parent )
{
if ( config( QStringLiteral( "UseHtml" ) ).toBool() )
{
return new QTextEdit( parent );
return new QTextBrowser( parent );
}
else
{
@@ -100,6 +100,7 @@ QWidget *QgsTextEditWrapper::createWidget( QWidget *parent )

void QgsTextEditWrapper::initWidget( QWidget *editor )
{
mTextBrowser = qobject_cast<QTextBrowser *>( editor );
mTextEdit = qobject_cast<QTextEdit *>( editor );
mPlainTextEdit = qobject_cast<QPlainTextEdit *>( editor );
mLineEdit = qobject_cast<QLineEdit *>( editor );
@@ -223,7 +224,14 @@ void QgsTextEditWrapper::setWidgetValue( const QVariant &val )
if ( val != value() )
{
if ( config( QStringLiteral( "UseHtml" ) ).toBool() )
{
mTextEdit->setHtml( v );
if ( mTextBrowser )
{
mTextBrowser->setTextInteractionFlags( Qt::LinksAccessibleByMouse );
mTextBrowser->setOpenExternalLinks( true );
}
}
else
mTextEdit->setPlainText( v );
}
@@ -20,7 +20,7 @@

#include <QLineEdit>
#include <QPlainTextEdit>
#include <QTextEdit>
#include <QTextBrowser>
#include "qgis_gui.h"

SIP_NO_FILE
@@ -68,6 +68,7 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
void textChanged( const QString &text );

private:
QTextBrowser *mTextBrowser = nullptr;
QTextEdit *mTextEdit = nullptr;
QPlainTextEdit *mPlainTextEdit = nullptr;
QLineEdit *mLineEdit = nullptr;

0 comments on commit bff8976

Please sign in to comment.
You can’t perform that action at this time.