Skip to content

Commit

Permalink
Allow clicking hyperlinks in HTML text edit widget
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 5, 2018
1 parent 7e6f423 commit 3c7b74f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/gui/editorwidgets/qgstexteditwrapper.cpp
Expand Up @@ -85,7 +85,7 @@ QWidget *QgsTextEditWrapper::createWidget( QWidget *parent )
{
if ( config( QStringLiteral( "UseHtml" ) ).toBool() )
{
return new QTextEdit( parent );
return new QTextBrowser( parent );
}
else
{
Expand All @@ -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 );

Expand Down Expand Up @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/editorwidgets/qgstexteditwrapper.h
Expand Up @@ -20,7 +20,7 @@

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

SIP_NO_FILE
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3c7b74f

Please sign in to comment.