Skip to content
Permalink
Browse files

[needs-docs][layouts] Move pushbutton actions for map items up to

a toolbar in the map item properties panel

This moves the
- refresh preview
- set to map canvas extent
- view extent in map canvas

buttons from being oversized push buttons within the item properties
panel up to a new toolbar at the top of this panel. Apart from looking
better, it means these important actions are always visible regardless
of the scroll position of the item properties panel itself.
Additionally, it makes it possible to add MORE actions here without
overloading the UI (e.g. "set canvas extent to item extent")

TODO: better icons
  • Loading branch information
nyalldawson committed Dec 10, 2018
1 parent 5acd7ff commit cdd23e663e4572b59ee201395486dfd44a4ed4f0
@@ -44,6 +44,12 @@ open layout designer dialogs.
%End
public:

enum StandardTool
{
ToolMoveItemContent,
ToolMoveItemNodes,
};

QgsLayoutDesignerInterface( QObject *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsLayoutDesignerInterface.
@@ -389,6 +395,13 @@ Removes the specified ``dock`` widget from layout designer (without deleting it)


.. versionadded:: 3.4
%End

virtual void activateTool( StandardTool tool ) = 0;
%Docstring
Activates a standard layout designer ``tool``.

.. versionadded:: 3.6
%End

public slots:
@@ -10,7 +10,6 @@




class QgsLayoutConfigObject: QObject
{
%Docstring
@@ -99,6 +98,14 @@ Sets the ``string`` to use to describe the current report type (e.g.
"atlas" or "report").
Subclasses which display this text to users should override this
and update their widget labels accordingly.
%End

virtual void setDesignerInterface( QgsLayoutDesignerInterface *iface );
%Docstring
Sets the the layout designer interface in which the widget is
being shown.

.. versionadded:: 3.6
%End

protected:
@@ -214,6 +214,23 @@ void QgsAppLayoutDesignerInterface::removeDockWidget( QDockWidget *dock )
mDesigner->removeDockWidget( dock );
}

void QgsAppLayoutDesignerInterface::activateTool( QgsLayoutDesignerInterface::StandardTool tool )
{
switch ( tool )
{
case QgsLayoutDesignerInterface::ToolMoveItemContent:
if ( !mDesigner->mActionMoveItemContent->isChecked() )
mDesigner->mActionMoveItemContent->trigger();
break;

case QgsLayoutDesignerInterface::ToolMoveItemNodes:
if ( !mDesigner->mActionEditNodesItem->isChecked() )
mDesigner->mActionEditNodesItem->trigger();
break;

}
}

void QgsAppLayoutDesignerInterface::close()
{
mDesigner->close();
@@ -1096,6 +1113,7 @@ void QgsLayoutDesignerDialog::showItemOptions( QgsLayoutItem *item, bool bringPa
if ( ! widget )
return;

widget->setDesignerInterface( iface() );
widget->setReportTypeString( reportTypeString() );

if ( QgsLayoutPagePropertiesWidget *ppWidget = qobject_cast< QgsLayoutPagePropertiesWidget * >( widget.get() ) )
@@ -77,6 +77,7 @@ class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
QToolBar *atlasToolbar() override;
void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dock ) override;
void removeDockWidget( QDockWidget *dock ) override;
void activateTool( StandardTool tool ) override;

public slots:

@@ -30,6 +30,7 @@
#include "qgsstyle.h"
#include "qgslayoutundostack.h"
#include "qgslayoutatlas.h"
#include "qgslayoutdesignerinterface.h"
#include <QMenu>
#include <QMessageBox>

@@ -41,9 +42,9 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )

setupUi( this );
connect( mScaleLineEdit, &QLineEdit::editingFinished, this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
connect( mSetToMapCanvasExtentButton, &QPushButton::clicked, this, &QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked );
connect( mViewExtentInCanvasButton, &QPushButton::clicked, this, &QgsLayoutMapWidget::mViewExtentInCanvasButton_clicked );
connect( mUpdatePreviewButton, &QPushButton::clicked, this, &QgsLayoutMapWidget::mUpdatePreviewButton_clicked );
connect( mActionSetToCanvasExtent, &QAction::triggered, this, &QgsLayoutMapWidget::setToMapCanvasExtent );
connect( mActionViewExtentInCanvas, &QAction::triggered, this, &QgsLayoutMapWidget::viewExtentInCanvas );
connect( mActionUpdatePreview, &QAction::triggered, this, &QgsLayoutMapWidget::updatePreview );
connect( mFollowVisibilityPresetCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
@@ -77,9 +78,12 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
connect( mOverviewListWidget, &QListWidget::itemChanged, this, &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
connect( mLabelSettingsButton, &QPushButton::clicked, this, &QgsLayoutMapWidget::showLabelSettings );

connect( mActionMoveContent, &QAction::triggered, this, &QgsLayoutMapWidget::switchToMoveContentTool );
setPanelTitle( tr( "Map Properties" ) );
mMapRotationSpinBox->setClearValue( 0 );

mDockToolbar->setIconSize( QgisApp::instance()->iconSize( true ) );

//add widget for general composer item properties
mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, item );
mainLayout->addWidget( mItemPropertiesWidget );
@@ -163,6 +167,11 @@ void QgsLayoutMapWidget::setReportTypeString( const QString &string )
mAtlasPredefinedScaleRadio->setToolTip( tr( "Use one of the predefined scales of the project where the %1 feature best fits." ).arg( string ) );
}

void QgsLayoutMapWidget::setDesignerInterface( QgsLayoutDesignerInterface *iface )
{
mInterface = iface;
}

bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
{
if ( item->type() != QgsLayoutItemRegistry::LayoutMap )
@@ -352,6 +361,12 @@ void QgsLayoutMapWidget::showLabelSettings()
openPanel( w );
}

void QgsLayoutMapWidget::switchToMoveContentTool()
{
if ( mInterface )
mInterface->activateTool( QgsLayoutDesignerInterface::ToolMoveItemContent );
}

void QgsLayoutMapWidget::mAtlasCheckBox_toggled( bool checked )
{
if ( !mMapItem )
@@ -512,7 +527,7 @@ void QgsLayoutMapWidget::rotationChanged( double value )
mMapItem->invalidateCache();
}

void QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked()
void QgsLayoutMapWidget::setToMapCanvasExtent()
{
if ( !mMapItem )
{
@@ -543,7 +558,7 @@ void QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked()
mMapItem->layout()->undoStack()->endCommand();
}

void QgsLayoutMapWidget::mViewExtentInCanvasButton_clicked()
void QgsLayoutMapWidget::viewExtentInCanvas()
{
if ( !mMapItem )
{
@@ -779,8 +794,8 @@ void QgsLayoutMapWidget::blockAllSignals( bool b )
mFollowVisibilityPresetCombo->blockSignals( b );
mKeepLayerListCheckBox->blockSignals( b );
mKeepLayerStylesCheckBox->blockSignals( b );
mSetToMapCanvasExtentButton->blockSignals( b );
mUpdatePreviewButton->blockSignals( b );
mActionSetToCanvasExtent->blockSignals( b );
mActionUpdatePreview->blockSignals( b );

blockOverviewItemsSignals( b );
}
@@ -830,7 +845,7 @@ void QgsLayoutMapWidget::handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::B
mMapItem->layout()->undoStack()->endCommand();
}

void QgsLayoutMapWidget::mUpdatePreviewButton_clicked()
void QgsLayoutMapWidget::updatePreview()
{
if ( !mMapItem )
{
@@ -39,12 +39,13 @@ class QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutM
explicit QgsLayoutMapWidget( QgsLayoutItemMap *item );

void setReportTypeString( const QString &string ) override;
void setDesignerInterface( QgsLayoutDesignerInterface *iface ) override;

public slots:
void mScaleLineEdit_editingFinished();
void mSetToMapCanvasExtentButton_clicked();
void mViewExtentInCanvasButton_clicked();
void mUpdatePreviewButton_clicked();
void setToMapCanvasExtent();
void viewExtentInCanvas();
void updatePreview();
void mFollowVisibilityPresetCheckBox_stateChanged( int state );
void mKeepLayerListCheckBox_stateChanged( int state );
void mKeepLayerStylesCheckBox_stateChanged( int state );
@@ -118,9 +119,12 @@ class QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutM
void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
void overviewSymbolChanged();
void showLabelSettings();
void switchToMoveContentTool();

private:
QPointer< QgsLayoutItemMap > mMapItem;
QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
QgsLayoutDesignerInterface *mInterface = nullptr;

//! Sets extent of composer map from line edits
void updateComposerExtentFromGui();
@@ -66,6 +66,13 @@ class GUI_EXPORT QgsLayoutDesignerInterface: public QObject

public:

//! Standard designer tools which are always available for use
enum StandardTool
{
ToolMoveItemContent, //!< Move item content tool
ToolMoveItemNodes, //!< Move item nodes tool
};

/**
* Constructor for QgsLayoutDesignerInterface.
*/
@@ -329,6 +336,13 @@ class GUI_EXPORT QgsLayoutDesignerInterface: public QObject
*/
virtual void removeDockWidget( QDockWidget *dock ) = 0;

/**
* Activates a standard layout designer \a tool.
*
* \since QGIS 3.6
*/
virtual void activateTool( StandardTool tool ) = 0;

public slots:

/**
@@ -180,6 +180,11 @@ void QgsLayoutItemBaseWidget::setReportTypeString( const QString & )
{
}

void QgsLayoutItemBaseWidget::setDesignerInterface( QgsLayoutDesignerInterface * )
{

}

void QgsLayoutItemBaseWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsLayoutObject::DataDefinedProperty property )
{
mConfigObject->initializeDataDefinedButton( button, property );
@@ -23,7 +23,7 @@
#include <QObject>
#include <QPointer>


class QgsLayoutDesignerInterface;
class QgsPropertyOverrideButton;

// NOTE - the inheritance here is tricky, as we need to avoid the multiple inheritance
@@ -151,6 +151,14 @@ class GUI_EXPORT QgsLayoutItemBaseWidget: public QgsPanelWidget
*/
virtual void setReportTypeString( const QString &string );

/**
* Sets the the layout designer interface in which the widget is
* being shown.
*
* \since QGIS 3.6
*/
virtual void setDesignerInterface( QgsLayoutDesignerInterface *iface );

protected:

/**

0 comments on commit cdd23e6

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