mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
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:
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user