Skip to content

Commit 17ca96f

Browse files
committed
Allow QWebView for photo widget
Fix #11306
1 parent 121665e commit 17ca96f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/gui/editorwidgets/qgsphotowidgetwrapper.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ void QgsPhotoWidgetWrapper::selectFileName()
3838

3939
void QgsPhotoWidgetWrapper::loadPixmap( const QString &fileName )
4040
{
41+
if ( mWebView )
42+
{
43+
mWebView->setUrl( fileName );
44+
}
45+
4146
QPixmap pm( fileName );
4247
if ( !pm.isNull() && mPhotoLabel )
4348
{
@@ -53,7 +58,6 @@ void QgsPhotoWidgetWrapper::loadPixmap( const QString &fileName )
5358

5459
pm = pm.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
5560

56-
5761
mPhotoLabel->setPixmap( pm );
5862
mPhotoLabel->setMinimumSize( size );
5963
}
@@ -98,9 +102,17 @@ void QgsPhotoWidgetWrapper::initWidget( QWidget* editor )
98102
QWidget* container;
99103

100104
mLineEdit = qobject_cast<QLineEdit*>( editor );
105+
mWebView = qobject_cast<QWebView*>( editor );
101106

102107
if ( mLineEdit )
103-
container = qobject_cast<QWidget*>( mLineEdit->parent() );
108+
{
109+
container = mLineEdit->parentWidget();
110+
}
111+
else if ( mWebView )
112+
{
113+
container = mWebView->parentWidget();
114+
mLineEdit = container->findChild<QLineEdit*>();
115+
}
104116
else
105117
{
106118
container = editor;
@@ -141,6 +153,10 @@ void QgsPhotoWidgetWrapper::setValue( const QVariant& value )
141153
else
142154
mLineEdit->setText( value.toString() );
143155
}
156+
else
157+
{
158+
loadPixmap( value.toString() );
159+
}
144160
}
145161

146162
void QgsPhotoWidgetWrapper::setEnabled( bool enabled )

src/gui/editorwidgets/qgsphotowidgetwrapper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QLabel>
2222
#include <QPushButton>
2323
#include <QLineEdit>
24+
#include <QWebView>
2425

2526

2627
/**
@@ -60,6 +61,8 @@ class GUI_EXPORT QgsPhotoWidgetWrapper : public QgsEditorWidgetWrapper
6061
private:
6162
//! This label is used as a container to display the picture
6263
QLabel* mPhotoLabel;
64+
//! This webview is used as a container to display the picture
65+
QWebView* mWebView;
6366
//! The line edit containing the path to the picture
6467
QLineEdit* mLineEdit;
6568
//! The button to open the file chooser dialog

0 commit comments

Comments
 (0)