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:
@@ -24,12 +24,9 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuWidgetDragger::RiuWidgetDragger( QWidget* widgetToMove,
|
||||
QWidget* widgetToSnapTo /*= nullptr*/,
|
||||
int snapMargins /*= 5*/ )
|
||||
RiuWidgetDragger::RiuWidgetDragger( QWidget* widgetToMove, int snapMargins /*= 5*/ )
|
||||
: QObject( widgetToMove )
|
||||
, m_widgetToMove( widgetToMove )
|
||||
, m_widgetToSnapTo( widgetToSnapTo )
|
||||
, m_snapMargins( snapMargins )
|
||||
, m_startPos( 0, 0 )
|
||||
{
|
||||
@@ -56,61 +53,58 @@ bool RiuWidgetDragger::eventFilter( QObject* watched, QEvent* event )
|
||||
{
|
||||
QPoint relativeMove = mMoveEv->pos() - m_startPos;
|
||||
QRect newFrameRect = m_widgetToMove->frameGeometry().translated( relativeMove );
|
||||
QRect snapToRect = m_widgetToMove->parentWidget()->rect();
|
||||
|
||||
if ( m_widgetToSnapTo )
|
||||
{
|
||||
QRect snapToRect = m_widgetToSnapTo->frameGeometry();
|
||||
QPoint snapToTopLeft = snapToRect.topLeft();
|
||||
QPoint widgetTopLeft = newFrameRect.topLeft();
|
||||
QPoint diff = snapToTopLeft - widgetTopLeft;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
QPoint snapToTopLeft = snapToRect.topLeft();
|
||||
QPoint widgetTopLeft = newFrameRect.topLeft();
|
||||
QPoint diff = snapToTopLeft - widgetTopLeft;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveLeft( snapToTopLeft.x() + m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveTop( snapToTopLeft.y() + m_snapMargins );
|
||||
}
|
||||
newFrameRect.moveLeft( snapToTopLeft.x() + m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
QPoint snapToBottomLeft = snapToRect.bottomLeft();
|
||||
QPoint widgetBottomLeft = newFrameRect.bottomLeft();
|
||||
QPoint diff = snapToBottomLeft - widgetBottomLeft;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveLeft( snapToBottomLeft.x() + m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveBottom( snapToBottomLeft.y() - m_snapMargins );
|
||||
}
|
||||
newFrameRect.moveTop( snapToTopLeft.y() + m_snapMargins );
|
||||
}
|
||||
}
|
||||
{
|
||||
QPoint snapToBottomLeft = snapToRect.bottomLeft();
|
||||
QPoint widgetBottomLeft = newFrameRect.bottomLeft();
|
||||
QPoint diff = snapToBottomLeft - widgetBottomLeft;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
QPoint snapToTopRight = snapToRect.topRight();
|
||||
QPoint widgetTopRight = newFrameRect.topRight();
|
||||
QPoint diff = snapToTopRight - widgetTopRight;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveRight( snapToTopRight.x() - m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveTop( snapToTopRight.y() + m_snapMargins );
|
||||
}
|
||||
newFrameRect.moveLeft( snapToBottomLeft.x() + m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
QPoint snapToBottomRight = snapToRect.bottomRight();
|
||||
QPoint widgetBottomRight = newFrameRect.bottomRight();
|
||||
QPoint diff = snapToBottomRight - widgetBottomRight;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveRight( snapToBottomRight.x() - m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveBottom( snapToBottomRight.y() - m_snapMargins );
|
||||
}
|
||||
newFrameRect.moveBottom( snapToBottomLeft.y() - m_snapMargins );
|
||||
}
|
||||
}
|
||||
{
|
||||
QPoint snapToTopRight = snapToRect.topRight();
|
||||
QPoint widgetTopRight = newFrameRect.topRight();
|
||||
QPoint diff = snapToTopRight - widgetTopRight;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveRight( snapToTopRight.x() - m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveTop( snapToTopRight.y() + m_snapMargins );
|
||||
}
|
||||
}
|
||||
{
|
||||
QPoint snapToBottomRight = snapToRect.bottomRight();
|
||||
QPoint widgetBottomRight = newFrameRect.bottomRight();
|
||||
QPoint diff = snapToBottomRight - widgetBottomRight;
|
||||
if ( std::abs( diff.x() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveRight( snapToBottomRight.x() - m_snapMargins );
|
||||
}
|
||||
if ( std::abs( diff.y() ) < 4 * m_snapMargins )
|
||||
{
|
||||
newFrameRect.moveBottom( snapToBottomRight.y() - m_snapMargins );
|
||||
}
|
||||
}
|
||||
m_widgetToMove->move( newFrameRect.topLeft() );
|
||||
|
||||
Reference in New Issue
Block a user