Skip to content
Permalink
Browse files

Allow clicking hyperlinks in HTML text edit widget

  • Loading branch information
m-kuhn committed Apr 5, 2018
1 parent 7e6f423 commit 3c7b74fae0f1faf6c416ccd8a197fa1a1e90439d
Showing with 8 additions and 4 deletions.
  1. +6 −2 src/gui/editorwidgets/qgstexteditwrapper.cpp
  2. +2 −2 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,7 +100,7 @@ QWidget *QgsTextEditWrapper::createWidget( QWidget *parent )

void QgsTextEditWrapper::initWidget( QWidget *editor )
{
mTextEdit = qobject_cast<QTextEdit *>( editor );
mTextEdit = qobject_cast<QTextBrowser *>( editor );
mPlainTextEdit = qobject_cast<QPlainTextEdit *>( editor );
mLineEdit = qobject_cast<QLineEdit *>( editor );

@@ -223,7 +223,11 @@ void QgsTextEditWrapper::setWidgetValue( const QVariant &val )
if ( val != value() )
{
if ( config( QStringLiteral( "UseHtml" ) ).toBool() )
{
mTextEdit->setHtml( v );
mTextEdit->setTextInteractionFlags( Qt::LinksAccessibleByMouse );
mTextEdit->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,7 +68,7 @@ class GUI_EXPORT QgsTextEditWrapper : public QgsEditorWidgetWrapper
void textChanged( const QString &text );

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

0 comments on commit 3c7b74f

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