Skip to content
Browse files
[needs-docs] Show actual linked color in color buttons when color
has been linked to a project color

Instead of only showing linked color status in the accompanying
data defined button, we now also show it inside the color button
itself. So now the button color is a live reflection of the
project color it is linked to.

Additionally, when the color is linked, the button only allows
users the choice of "unlinking" the color from the linked
project color. The usual color button options allowing users
to directly change the color are not present. (As linked
colors must be edited in the project colors section from
the project properties dialog)
  • Loading branch information
nyalldawson committed Jan 17, 2019
1 parent 4ae3bcd commit 3d283c1b05c998f1e00297f533d4455489f4b380
@@ -303,6 +303,32 @@ that are shown in the button's drop-down menu.
swatch grids are hidden from the button's drop-down menu.

.. seealso:: :py:func:`setColorSchemeRegistry`

void linkToProjectColor( const QString &name );
Sets the button to link to an existing project color, by color ``name``.

This changes the behavior of the button to a "linked" mode. Specifically,
the button will show the linked color and respond to changes in the project
color scheme by refreshing the displayed color automatically. Additionally,
the button's menu will show items specific to linked color mode, including
an option to "unlink" from the project color.

.. seealso:: :py:func:`linkedProjectColorName`

.. seealso:: :py:func:`unlink`

.. versionadded:: 3.6

QString linkedProjectColorName() const;
Returns the linked project color name, if set.

.. seealso:: :py:func:`linkToProjectColor`

.. versionadded:: 3.6

static QPixmap createMenuIcon( const QColor &color, bool showChecks = true );
@@ -390,6 +416,17 @@ Sets color to null.
.. seealso:: :py:func:`setToNoColor`

.. versionadded:: 2.16

void unlink();
Unlinks the button from a project color.

.. seealso:: :py:func:`unlinked`

.. seealso:: :py:func:`linkToProjectColor`

.. versionadded:: 3.6

@@ -411,6 +448,18 @@ Emitted when the button is clicked, if the button's behavior is set to SignalOnl
.. seealso:: :py:func:`setBehavior`

.. seealso:: :py:func:`behavior`

void unlinked();
Emitted when the color is unlinked, e.g. when it was previously set to link
to a project color and is now no longer linked.

.. seealso:: :py:func:`unlink`

.. seealso:: :py:func:`linkToProjectColor`

.. versionadded:: 3.6

@@ -31,38 +31,13 @@ and layouts.

enum Flag
typedef QFlags<QgsPropertyOverrideButton::Flag> Flags;

QgsPropertyOverrideButton( QWidget *parent /TransferThis/ = 0,
const QgsVectorLayer *layer = 0 );
Constructor for QgsPropertyOverrideButton.

:param parent: parent widget
:param layer: associated vector layer

Flags flags() const;
Returns the button's flags, which control the button behavior.

.. seealso:: :py:func:`setFlags`

.. versionadded:: 3.6

void setFlags( QgsPropertyOverrideButton::Flags flags );
Sets the button's ``flags``, which control the button behavior.

.. seealso:: :py:func:`flags`

.. versionadded:: 3.6

void init( int propertyKey,
@@ -219,6 +194,17 @@ Register a sibling ``widget`` (line edit, text edit) that will receive the prope
Register an expression context generator class that will be used to retrieve
an expression context for the button when required.

void registerLinkedWidget( QWidget *widget );
Registers a ``widget`` which is linked to this button. The meaning of linked widgets
depends on the property type, and the type of linked widget.

For color properties, linking a QgsColorButton allows the color button to correctly
reflect the status of the property when it's set to follow a project color.

.. versionadded:: 3.6

void updateFieldLists();
@@ -265,9 +251,6 @@ Emitted when creating a new auxiliary field


QFlags<QgsPropertyOverrideButton::Flag> operator|(QgsPropertyOverrideButton::Flag f1, QFlags<QgsPropertyOverrideButton::Flag> f2);

* This file has been generated automatically from *
* *
@@ -61,10 +61,8 @@ QgsLayoutPictureWidget::QgsLayoutPictureWidget( QgsLayoutItemPicture *picture )
mStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
mStrokeColorButton->setContext( QStringLiteral( "composer" ) );

mFillColorDDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mFillColorDDBtn->registerEnabledWidget( mFillColorButton, false );
mStrokeColorDDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mStrokeColorDDBtn->registerEnabledWidget( mStrokeColorButton, false );
mFillColorDDBtn->registerLinkedWidget( mFillColorButton );
mStrokeColorDDBtn->registerLinkedWidget( mStrokeColorButton );

mNorthTypeComboBox->blockSignals( true );
mNorthTypeComboBox->addItem( tr( "Grid north" ), QgsLayoutItemPicture::GridNorth );
@@ -109,12 +109,9 @@ QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget( QgsLayoutItemScaleBar *scaleBa
mStrokeColorButton->setNoColorString( tr( "Transparent Line" ) );
mStrokeColorButton->setShowNoColor( true );

mFillColorDDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mFillColorDDBtn->registerEnabledWidget( mFillColorButton, false );
mFillColor2DDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mFillColor2DDBtn->registerEnabledWidget( mFillColor2Button, false );
mLineColorDDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mLineColorDDBtn->registerEnabledWidget( mStrokeColorButton, false );
mFillColorDDBtn->registerLinkedWidget( mFillColorButton );
mFillColor2DDBtn->registerLinkedWidget( mFillColor2Button );
mLineColorDDBtn->registerLinkedWidget( mStrokeColorButton );

if ( mScalebar )
@@ -252,10 +252,8 @@ QgsLayoutItemPropertiesWidget::QgsLayoutItemPropertiesWidget( QWidget *parent, Q
mSizeLockAspectRatio->setWidthSpinBox( mWidthSpin );
mSizeLockAspectRatio->setHeightSpinBox( mHeightSpin );

mItemFrameColorDDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mItemFrameColorDDBtn->registerEnabledWidget( mFrameColorButton, false );
mItemBackgroundColorDDBtn->setFlags( QgsPropertyOverrideButton::FlagDisableCheckedWidgetOnlyWhenProjectColorSet );
mItemBackgroundColorDDBtn->registerEnabledWidget( mBackgroundColorButton, false );
mItemFrameColorDDBtn->registerLinkedWidget( mFrameColorButton );
mItemBackgroundColorDDBtn->registerLinkedWidget( mBackgroundColorButton );

connect( mFrameColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutItemPropertiesWidget::mFrameColorButton_colorChanged );
connect( mBackgroundColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutItemPropertiesWidget::mBackgroundColorButton_colorChanged );

0 comments on commit 3d283c1

Please sign in to comment.