Skip to content

Commit

Permalink
Allow QWebView for photo widget
Browse files Browse the repository at this point in the history
Fix #11306
  • Loading branch information
m-kuhn committed Oct 7, 2014
1 parent 121665e commit 17ca96f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/gui/editorwidgets/qgsphotowidgetwrapper.cpp
Expand Up @@ -38,6 +38,11 @@ void QgsPhotoWidgetWrapper::selectFileName()

void QgsPhotoWidgetWrapper::loadPixmap( const QString &fileName )
{
if ( mWebView )
{
mWebView->setUrl( fileName );
}

QPixmap pm( fileName );
if ( !pm.isNull() && mPhotoLabel )
{
Expand All @@ -53,7 +58,6 @@ void QgsPhotoWidgetWrapper::loadPixmap( const QString &fileName )

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


mPhotoLabel->setPixmap( pm );
mPhotoLabel->setMinimumSize( size );
}
Expand Down Expand Up @@ -98,9 +102,17 @@ void QgsPhotoWidgetWrapper::initWidget( QWidget* editor )
QWidget* container;

mLineEdit = qobject_cast<QLineEdit*>( editor );
mWebView = qobject_cast<QWebView*>( editor );

if ( mLineEdit )
container = qobject_cast<QWidget*>( mLineEdit->parent() );
{
container = mLineEdit->parentWidget();
}
else if ( mWebView )
{
container = mWebView->parentWidget();
mLineEdit = container->findChild<QLineEdit*>();
}
else
{
container = editor;
Expand Down Expand Up @@ -141,6 +153,10 @@ void QgsPhotoWidgetWrapper::setValue( const QVariant& value )
else
mLineEdit->setText( value.toString() );
}
else
{
loadPixmap( value.toString() );
}
}

void QgsPhotoWidgetWrapper::setEnabled( bool enabled )
Expand Down
3 changes: 3 additions & 0 deletions src/gui/editorwidgets/qgsphotowidgetwrapper.h
Expand Up @@ -21,6 +21,7 @@
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QWebView>


/**
Expand Down Expand Up @@ -60,6 +61,8 @@ class GUI_EXPORT QgsPhotoWidgetWrapper : public QgsEditorWidgetWrapper
private:
//! This label is used as a container to display the picture
QLabel* mPhotoLabel;
//! This webview is used as a container to display the picture
QWebView* mWebView;
//! The line edit containing the path to the picture
QLineEdit* mLineEdit;
//! The button to open the file chooser dialog
Expand Down

0 comments on commit 17ca96f

Please sign in to comment.