Skip to content
Permalink
Browse files

Add layout view to layout designer

  • Loading branch information
nyalldawson committed Jul 11, 2017
1 parent 4c2447f commit b2a01d84a30f5e1104ecf3b0f5119a9e6b9b4acd
@@ -20,6 +20,7 @@
#include "qgssettings.h"
#include "qgisapp.h"
#include "qgslogger.h"
#include "qgslayoutview.h"

QgsAppLayoutDesignerInterface::QgsAppLayoutDesignerInterface( QgsLayoutDesignerDialog *dialog )
: QgsLayoutDesignerInterface( dialog )
@@ -55,6 +56,26 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
setDockOptions( dockOptions() | QMainWindow::GroupedDragging ) ;
#endif

//create layout view
QGridLayout *viewLayout = new QGridLayout();
viewLayout->setSpacing( 0 );
viewLayout->setMargin( 0 );
viewLayout->setContentsMargins( 0, 0, 0, 0 );
centralWidget()->layout()->setSpacing( 0 );
centralWidget()->layout()->setMargin( 0 );
centralWidget()->layout()->setContentsMargins( 0, 0, 0, 0 );
mView = new QgsLayoutView();
//mView->setMapCanvas( mQgis->mapCanvas() );
mView->setContentsMargins( 0, 0, 0, 0 );
//mView->setHorizontalRuler( mHorizontalRuler );
//mView->setVerticalRuler( mVerticalRuler );
viewLayout->addWidget( mView, 1, 1 );
//view does not accept focus via tab
mView->setFocusPolicy( Qt::ClickFocus );
mViewFrame->setLayout( viewLayout );
mViewFrame->setContentsMargins( 0, 0, 0, 1 ); // 1 is deliberate!
mView->setFrameShape( QFrame::NoFrame );

connect( mActionClose, &QAction::triggered, this, &QWidget::close );

// populate with initial items...
@@ -21,6 +21,8 @@
#include "qgslayoutdesignerinterface.h"

class QgsLayoutDesignerDialog;
class QgsLayoutView;


class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
{
@@ -108,6 +110,8 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner

QActionGroup *mToolsActionGroup = nullptr;

QgsLayoutView *mView = nullptr;


//! Save window state
void saveWindowState();
@@ -21,7 +21,9 @@
QgsLayoutView::QgsLayoutView( QWidget *parent )
: QGraphicsView( parent )
{

setResizeAnchor( QGraphicsView::AnchorViewCenter );
setMouseTracking( true );
viewport()->setMouseTracking( true );
}

QgsLayout *QgsLayoutView::currentLayout()
@@ -33,6 +33,9 @@
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="mViewFrame">
<property name="mouseTracking">
@@ -42,7 +45,7 @@
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>

0 comments on commit b2a01d8

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