Skip to content

Commit

Permalink
Recompute webpage viewport dimensions when resizing html frames (Fund…
Browse files Browse the repository at this point in the history
…ed by Sourcepole QGIS Enterprise)
  • Loading branch information
manisandro committed Aug 25, 2014
1 parent 88b13e8 commit aaa92cc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions src/core/composer/qgscomposerhtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ QgsComposerHtml::QgsComposerHtml( QgsComposition* c, bool createUndoCommands ):
{
mHtmlUnitsToMM = htmlUnitsToMM();
mWebPage = new QWebPage();
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
mWebPage->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
QObject::connect( mWebPage, SIGNAL( loadFinished( bool ) ), this, SLOT( frameLoaded( bool ) ) );
if ( mComposition )
Expand Down Expand Up @@ -181,6 +183,20 @@ void QgsComposerHtml::loadHtml()
qApp->processEvents();
}

renderCachedImage();
recalculateFrameSizes();
//trigger a repaint
emit contentsChanged();
}

void QgsComposerHtml::frameLoaded( bool ok )
{
Q_UNUSED( ok );
mLoaded = true;
}

void QgsComposerHtml::recalculateFrameSizes()
{
if ( frameCount() < 1 ) return;

QSize contentsSize = mWebPage->mainFrame()->contentsSize();
Expand All @@ -196,23 +212,10 @@ void QgsComposerHtml::loadHtml()
contentsSize.setWidth( maxFrameWidth * mHtmlUnitsToMM );

mWebPage->setViewportSize( contentsSize );
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
mWebPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
mSize.setWidth( contentsSize.width() / mHtmlUnitsToMM );
mSize.setHeight( contentsSize.height() / mHtmlUnitsToMM );

renderCachedImage();

recalculateFrameSizes();
QgsComposerMultiFrame::recalculateFrameSizes();
emit changed();
//trigger a repaint
emit contentsChanged();
}

void QgsComposerHtml::frameLoaded( bool ok )
{
Q_UNUSED( ok );
mLoaded = true;
}

void QgsComposerHtml::renderCachedImage()
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerhtml.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
* @see url
*/
void loadHtml();

void recalculateFrameSizes();
void refreshExpressionContext();

virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties );
Expand Down

0 comments on commit aaa92cc

Please sign in to comment.