Implement pdf rendering (#5250)

* First PDF creation support

* Reimplement info box

* Set title and make overlay frame margins more unified

* Remove a style sheet that was never meant to be applied to Project Tree

* Update RiuDraggableOverlayFrame when changing content

* Default page layout in Preferences

* undo removal of elision

* Remove friend class assignment in cafCategoryMapper

* the required methods have been made public

* Fix up after review

* Remove spurious const on by-value return

* Fix compile errors on Linux

* Fix size adjustment of legends with plot resizing
This commit is contained in:
Gaute Lindkvist
2019-12-18 12:25:19 +01:00
committed by GitHub
parent f339b52907
commit 47b93dc0d1
57 changed files with 1675 additions and 559 deletions

View File

@@ -20,15 +20,18 @@
#include <QGraphicsDropShadowEffect>
#include <QLabel>
#include <QPainter>
#include <QResizeEvent>
#include <QVBoxLayout>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuDraggableOverlayFrame::RiuDraggableOverlayFrame( QWidget* parent, QWidget* widgetToSnapTo, const QColor& backgroundColor )
RiuDraggableOverlayFrame::RiuDraggableOverlayFrame( QWidget* parent, const int snapMargins, const QColor& backgroundColor )
: QFrame( parent )
, m_anchorCorner( AnchorCorner::TopLeft )
{
RiuWidgetDragger* dragger = new RiuWidgetDragger( this, widgetToSnapTo );
m_widgetDragger = new RiuWidgetDragger( this, snapMargins );
QPalette pal = this->palette();
pal.setColor( QPalette::Window, backgroundColor );
@@ -40,22 +43,84 @@ RiuDraggableOverlayFrame::RiuDraggableOverlayFrame( QWidget* parent, QWidget* wi
dropShadowEffect->setBlurRadius( 3.0 );
dropShadowEffect->setColor( QColor( 100, 100, 100, 100 ) );
setGraphicsEffect( dropShadowEffect );
auto hblayout = new QVBoxLayout( this );
this->setLayout( hblayout );
m_overlayItemLabel = new QLabel( this );
hblayout->addWidget( m_overlayItemLabel );
m_overlayItemLabel->setObjectName( "OverlayFrameLabel" );
m_overlayItemLabel->setGraphicsEffect( nullptr );
m_overlayItemLabel->setAlignment( Qt::AlignTop | Qt::AlignLeft );
dragger->addWidget( m_overlayItemLabel );
this->setContentsMargins( 1, 1, 1, 1 );
m_layout = new QVBoxLayout( this );
m_layout->setContentsMargins( 0, 0, 0, 0 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QLabel* RiuDraggableOverlayFrame::label()
RiuAbstractOverlayContentFrame* RiuDraggableOverlayFrame::contentFrame()
{
return m_overlayItemLabel;
return m_contentFrame;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDraggableOverlayFrame::setContentFrame( RiuAbstractOverlayContentFrame* contentFrame )
{
if ( m_contentFrame )
{
m_layout->removeWidget( m_contentFrame );
m_contentFrame->setParent( nullptr ); // TODO: check if both removeWidget and setParent is necessary
delete m_contentFrame;
m_contentFrame = nullptr;
}
m_contentFrame = contentFrame;
m_layout->addWidget( m_contentFrame );
this->adjustSize();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDraggableOverlayFrame::renderTo( QPainter* painter, const QRect& targetRect )
{
if ( m_contentFrame )
{
painter->save();
painter->fillRect( targetRect, this->palette().color( QWidget::backgroundRole() ) );
QRect contentRect = targetRect;
contentRect.adjust( -1, -1, -1, -1 );
m_contentFrame->renderTo( painter, contentRect );
painter->drawRect( targetRect );
painter->restore();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDraggableOverlayFrame::setAnchorCorner( AnchorCorner corner )
{
m_anchorCorner = corner;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuDraggableOverlayFrame::AnchorCorner RiuDraggableOverlayFrame::anchorCorner() const
{
return m_anchorCorner;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuDraggableOverlayFrame::sizeHint() const
{
QSize contentSize = m_contentFrame->sizeHint();
return QSize( contentSize.width() + 2, contentSize.height() + 2 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiuDraggableOverlayFrame::minimumSizeHint() const
{
QSize contentSize = m_contentFrame->minimumSizeHint();
return QSize( contentSize.width() + 2, contentSize.height() + 2 );
}