Skip to content
Permalink
Browse files

Allow QWebView for photo widget

Fix #11306
  • Loading branch information
m-kuhn committed Oct 7, 2014
1 parent 121665e commit 17ca96fd26720c964e42123ce1196b01355424d9
Showing with 21 additions and 2 deletions.
  1. +18 −2 src/gui/editorwidgets/qgsphotowidgetwrapper.cpp
  2. +3 −0 src/gui/editorwidgets/qgsphotowidgetwrapper.h
@@ -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 )
{
@@ -53,7 +58,6 @@ void QgsPhotoWidgetWrapper::loadPixmap( const QString &fileName )

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


mPhotoLabel->setPixmap( pm );
mPhotoLabel->setMinimumSize( size );
}
@@ -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;
@@ -141,6 +153,10 @@ void QgsPhotoWidgetWrapper::setValue( const QVariant& value )
else
mLineEdit->setText( value.toString() );
}
else
{
loadPixmap( value.toString() );
}
}

void QgsPhotoWidgetWrapper::setEnabled( bool enabled )
@@ -21,6 +21,7 @@
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
#include <QWebView>


/**
@@ -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

0 comments on commit 17ca96f

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