Skip to content
Permalink
Browse files

Merge pull request #1540 from manisandro/composer_html_fixes

Recompute webpage viewport dimensions when resizing html frames
  • Loading branch information
nyalldawson committed Sep 22, 2014
2 parents 86cbc2e + 788575e commit d85f6251f2ad7495198f8d33cac6947a21d32f63
@@ -188,6 +188,9 @@ class QgsComposerHtml: QgsComposerMultiFrame
*/
void loadHtml();

/**Recalculates the frame sizes for the current viewport dimensions*/
void recalculateFrameSizes();

void refreshExpressionContext();

virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties );
@@ -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 )
@@ -187,6 +189,19 @@ void QgsComposerHtml::loadHtml()
qApp->processEvents();
}

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();
@@ -202,23 +217,11 @@ 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()
@@ -211,6 +211,8 @@ class CORE_EXPORT QgsComposerHtml: public QgsComposerMultiFrame
*/
void loadHtml();

/**Recalculates the frame sizes for the current viewport dimensions*/
void recalculateFrameSizes();
void refreshExpressionContext();

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

0 comments on commit d85f625

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