Skip to content

Commit

Permalink
Merge pull request #3579 from nyalldawson/composer_dock
Browse files Browse the repository at this point in the history
Port composer item configuration widgets to inline dock
  • Loading branch information
nyalldawson committed Oct 6, 2016
2 parents e5f7cdc + 521cc3b commit a9e9a6e
Show file tree
Hide file tree
Showing 20 changed files with 239 additions and 94 deletions.
17 changes: 17 additions & 0 deletions python/core/composer/qgscomposeritemcommand.sip
Expand Up @@ -49,9 +49,14 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
//composer label
ComposerLabelSetText,
ComposerLabelSetId,
ComposerLabelFontColor,
//composer map
ComposerMapRotation,
ComposerMapAnnotationDistance,
ComposerMapGridFramePenColor,
ComposerMapGridFrameFill1Color,
ComposerMapGridFrameFill2Color,
ComposerMapGridAnnotationFontColor,
//composer legend
ComposerLegendText,
LegendColumnCount,
Expand All @@ -69,8 +74,12 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
LegendBoxSpace,
LegendColumnSpace,
LegendRasterBorderWidth,
LegendFontColor,
LegendRasterBorderColor,
//composer picture
ComposerPictureRotation,
ComposerPictureFillColor,
ComposerPictureOutlineColor,
// composer scalebar
ScaleBarLineWidth,
ScaleBarHeight,
Expand All @@ -81,6 +90,10 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
ScaleBarMapUnitsSegment,
ScaleBarLabelBarSize,
ScaleBarBoxContentSpace,
ScaleBarFontColor,
ScaleBarFillColor,
ScaleBarFill2Color,
ScaleBarStrokeColor,
// composer table
TableMaximumFeatures,
TableMargin,
Expand All @@ -90,9 +103,13 @@ class QgsComposerMergeCommand : QgsComposerItemCommand
ShapeOutlineWidth,
//composer arrow
ArrowOutlineWidth,
ArrowHeadFillColor,
ArrowHeadOutlineColor,
ArrowHeadWidth,
//item
ItemOutlineWidth,
ItemOutlineColor,
ItemBackgroundColor,
ItemMove,
ItemRotation,
ItemTransparency,
Expand Down
6 changes: 5 additions & 1 deletion python/core/composer/qgscomposermultiframecommand.sip
Expand Up @@ -49,7 +49,11 @@ class QgsComposerMultiFrameMergeCommand: QgsComposerMultiFrameCommand
TableMaximumFeatures,
TableMargin,
TableGridStrokeWidth,
TableCellStyle
TableCellStyle,
TableHeaderFontColor,
TableContentFontColor,
TableGridColor,
TableBackgroundColor,
};

QgsComposerMultiFrameMergeCommand( Context c, QgsComposerMultiFrame* multiFrame, const QString& text );
Expand Down
26 changes: 14 additions & 12 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -67,6 +67,7 @@
#include "qgsvectorlayer.h"
#include "qgscomposerimageexportoptionsdialog.h"
#include "ui_qgssvgexportoptions.h"
#include "qgspanelwidgetstack.h"

#include <QCloseEvent>
#include <QCheckBox>
Expand Down Expand Up @@ -578,6 +579,8 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
mItemDock = new QgsDockWidget( tr( "Item properties" ), this );
mItemDock->setObjectName( "ItemDock" );
mItemDock->setMinimumWidth( minDockWidth );
mItemPropertiesStack = new QgsPanelWidgetStack();
mItemDock->setWidget( mItemPropertiesStack );
mPanelMenu->addAction( mItemDock->toggleViewAction() );
mUndoDock = new QgsDockWidget( tr( "Command history" ), this );
mUndoDock->setObjectName( "CommandDock" );
Expand Down Expand Up @@ -996,28 +999,27 @@ void QgsComposer::updateStatusAtlasMsg( const QString& message )

void QgsComposer::showItemOptions( QgsComposerItem* item )
{
QWidget* currentWidget = mItemDock->widget();

if ( !item )
{
mItemDock->setWidget( nullptr );
mItemPropertiesStack->takeMainPanel();
return;
}

QMap<QgsComposerItem*, QWidget*>::const_iterator it = mItemWidgetMap.constFind( item );
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator it = mItemWidgetMap.constFind( item );
if ( it == mItemWidgetMap.constEnd() )
{
return;
}

QWidget* newWidget = it.value();

if ( !newWidget || newWidget == currentWidget ) //bail out if new widget does not exist or is already there
QgsPanelWidget* newWidget = it.value();
if ( !newWidget || newWidget == mItemPropertiesStack->mainPanel() ) //bail out if new widget does not exist or is already there
{
return;
}

mItemDock->setWidget( newWidget );
( void ) mItemPropertiesStack->takeMainPanel();
newWidget->setDockMode( true );
mItemPropertiesStack->setMainPanel( newWidget );
}

void QgsComposer::on_mActionOptions_triggered()
Expand Down Expand Up @@ -3774,7 +3776,7 @@ void QgsComposer::addComposerHtmlFrame( QgsComposerHtml* html, QgsComposerFrame*

void QgsComposer::deleteItem( QgsComposerItem* item )
{
QMap<QgsComposerItem*, QWidget*>::const_iterator it = mItemWidgetMap.constFind( item );
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator it = mItemWidgetMap.constFind( item );

if ( it == mItemWidgetMap.constEnd() )
{
Expand All @@ -3800,7 +3802,7 @@ void QgsComposer::setSelectionTool()

bool QgsComposer::containsWmsLayer() const
{
QMap<QgsComposerItem*, QWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QgsComposerItem* currentItem = nullptr;
QgsComposerMap* currentMap = nullptr;

Expand All @@ -3822,7 +3824,7 @@ bool QgsComposer::containsWmsLayer() const
bool QgsComposer::containsAdvancedEffects() const
{
// Check if composer contains any blend modes or flattened layers for transparency
QMap<QgsComposerItem*, QWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QgsComposerItem* currentItem = nullptr;
QgsComposerMap* currentMap = nullptr;

Expand Down Expand Up @@ -3893,7 +3895,7 @@ void QgsComposer::showAdvancedEffectsWarning()

void QgsComposer::cleanupAfterTemplateRead()
{
QMap<QgsComposerItem*, QWidget*>::const_iterator itemIt = mItemWidgetMap.constBegin();
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator itemIt = mItemWidgetMap.constBegin();
for ( ; itemIt != mItemWidgetMap.constEnd(); ++itemIt )
{
//update all legends completely
Expand Down
5 changes: 4 additions & 1 deletion src/app/composer/qgscomposer.h
Expand Up @@ -18,6 +18,7 @@
#define QGSCOMPOSER_H
#include "ui_qgscomposerbase.h"

#include "qgspanelwidget.h"
class QgisApp;
class QgsComposerArrow;
class QgsComposerPolygon;
Expand All @@ -44,6 +45,7 @@ class QgsDockWidget;
class QgsMapLayer;
class QgsFeature;
class QgsVectorLayer;
class QgsPanelWidgetStack;

class QGridLayout;
class QDomNode;
Expand Down Expand Up @@ -568,7 +570,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
QSizeGrip *mSizeGrip;

//! To know which item to show if selection changes
QMap<QgsComposerItem*, QWidget*> mItemWidgetMap;
QMap<QgsComposerItem*, QgsPanelWidget*> mItemWidgetMap;

//! Window menu action to select this window
QAction *mWindowAction;
Expand Down Expand Up @@ -597,6 +599,7 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
QMap< QgsComposerMap*, int > mMapsToRestore;

QgsDockWidget* mItemDock;
QgsPanelWidgetStack* mItemPropertiesStack;
QgsDockWidget* mUndoDock;
QgsDockWidget* mGeneralDock;
QgsDockWidget* mAtlasDock;
Expand Down
5 changes: 3 additions & 2 deletions src/app/composer/qgscomposerarrowwidget.cpp
Expand Up @@ -28,6 +28,7 @@
QgsComposerArrowWidget::QgsComposerArrowWidget( QgsComposerArrow* arrow ): QgsComposerItemBaseWidget( nullptr, arrow ), mArrow( arrow )
{
setupUi( this );
setPanelTitle( tr( "Arrow properties" ) );
mRadioButtonGroup = new QButtonGroup( this );
mRadioButtonGroup->addButton( mDefaultMarkerRadioButton );
mRadioButtonGroup->addButton( mNoMarkerRadioButton );
Expand Down Expand Up @@ -98,7 +99,7 @@ void QgsComposerArrowWidget::on_mArrowHeadFillColorButton_colorChanged( const QC
return;
}

mArrow->beginCommand( tr( "Arrow head fill color" ) );
mArrow->beginCommand( tr( "Arrow head fill color" ), QgsComposerMergeCommand::ArrowHeadFillColor );
mArrow->setArrowHeadFillColor( newColor );
mArrow->update();
mArrow->endCommand();
Expand All @@ -111,7 +112,7 @@ void QgsComposerArrowWidget::on_mArrowHeadOutlineColorButton_colorChanged( const
return;
}

mArrow->beginCommand( tr( "Arrow head outline color" ) );
mArrow->beginCommand( tr( "Arrow head outline color" ), QgsComposerMergeCommand::ArrowHeadOutlineColor );
mArrow->setArrowHeadOutlineColor( newColor );
mArrow->update();
mArrow->endCommand();
Expand Down
9 changes: 5 additions & 4 deletions src/app/composer/qgscomposerattributetablewidget.cpp
Expand Up @@ -39,6 +39,7 @@ QgsComposerAttributeTableWidget::QgsComposerAttributeTableWidget( QgsComposerAtt
, mFrame( frame )
{
setupUi( this );
setPanelTitle( tr( "Table properties" ) );

blockAllSignals( true );

Expand Down Expand Up @@ -268,7 +269,7 @@ void QgsComposerAttributeTableWidget::on_mHeaderFontColorButton_colorChanged( co
QgsComposition* composition = mComposerTable->composition();
if ( composition )
{
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font color" ) );
composition->beginMultiFrameCommand( mComposerTable, tr( "Table header font color" ), QgsComposerMultiFrameMergeCommand::TableHeaderFontColor );
}
mComposerTable->setHeaderFontColor( newColor );
if ( composition )
Expand Down Expand Up @@ -309,7 +310,7 @@ void QgsComposerAttributeTableWidget::on_mContentFontColorButton_colorChanged( c
QgsComposition* composition = mComposerTable->composition();
if ( composition )
{
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font color" ) );
composition->beginMultiFrameCommand( mComposerTable, tr( "Table content font color" ), QgsComposerMultiFrameMergeCommand::TableContentFontColor );
}
mComposerTable->setContentFontColor( newColor );
if ( composition )
Expand Down Expand Up @@ -347,7 +348,7 @@ void QgsComposerAttributeTableWidget::on_mGridColorButton_colorChanged( const QC
QgsComposition* composition = mComposerTable->composition();
if ( composition )
{
composition->beginMultiFrameCommand( mComposerTable, tr( "Table grid color" ) );
composition->beginMultiFrameCommand( mComposerTable, tr( "Table grid color" ), QgsComposerMultiFrameMergeCommand::TableGridColor );
}
mComposerTable->setGridColor( newColor );
if ( composition )
Expand Down Expand Up @@ -385,7 +386,7 @@ void QgsComposerAttributeTableWidget::on_mBackgroundColorButton_colorChanged( co
QgsComposition* composition = mComposerTable->composition();
if ( composition )
{
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background color" ) );
composition->beginMultiFrameCommand( mComposerTable, tr( "Table background color" ), QgsComposerMultiFrameMergeCommand::TableBackgroundColor );
}
mComposerTable->setBackgroundColor( newColor );
if ( composition )
Expand Down
1 change: 1 addition & 0 deletions src/app/composer/qgscomposerhtmlwidget.cpp
Expand Up @@ -31,6 +31,7 @@ QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposer
, mFrame( frame )
{
setupUi( this );
setPanelTitle( tr( "HTML properties" ) );

//setup html editor
mHtmlEditor = new QgsCodeEditorHTML( this );
Expand Down

0 comments on commit a9e9a6e

Please sign in to comment.