Skip to content

Commit

Permalink
When a style manager dialog is opened in read only mode, still allow
Browse files Browse the repository at this point in the history
symbols to be double clicked to view their properties. Just disable
actually saving any edited symbols instead.
  • Loading branch information
nyalldawson committed Jul 18, 2019
1 parent c715bc1 commit a57d04f
Show file tree
Hide file tree
Showing 26 changed files with 236 additions and 55 deletions.
Expand Up @@ -90,6 +90,13 @@ Sets the color ramp to show in the dialog.
:param ramp: color ramp

.. seealso:: :py:func:`ramp`
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

signals:
Expand Down
7 changes: 7 additions & 0 deletions python/gui/auto_generated/qgsgradientcolorrampdialog.sip.in
Expand Up @@ -46,6 +46,13 @@ Sets the color ramp to show in the dialog.
:param ramp: color ramp

.. seealso:: :py:func:`ramp`
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

signals:
Expand Down
Expand Up @@ -8,6 +8,7 @@




class QgsLimitedRandomColorRampWidget : QgsPanelWidget
{
%Docstring
Expand Down Expand Up @@ -121,6 +122,13 @@ Sets the color ramp to show in the dialog.
:param ramp: color ramp

.. seealso:: :py:func:`ramp`
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

signals:
Expand Down
8 changes: 8 additions & 0 deletions python/gui/auto_generated/qgspresetcolorrampdialog.sip.in
Expand Up @@ -8,6 +8,7 @@




class QgsPresetColorRampWidget : QgsPanelWidget
{
%Docstring
Expand Down Expand Up @@ -89,6 +90,13 @@ Sets the color ramp to show in the dialog.
:param ramp: color ramp

.. seealso:: :py:func:`ramp`
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

signals:
Expand Down
7 changes: 7 additions & 0 deletions python/gui/auto_generated/qgstextformatwidget.sip.in
Expand Up @@ -200,6 +200,13 @@ Constructor for QgsTextFormatDialog.
QgsTextFormat format() const;
%Docstring
Returns the current formatting settings defined by the widget.
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

};
Expand Down
Expand Up @@ -57,6 +57,13 @@ Returns the name of the ramp currently selected in the dialog.
bool saveAsGradientRamp() const;
%Docstring
Returns ``True`` if the ramp should be converted to a :py:class:`QgsGradientColorRamp`.
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

virtual bool eventFilter( QObject *obj, QEvent *event );
Expand Down
Expand Up @@ -234,6 +234,13 @@ Returns the context in which the symbol widget is shown, e.g., the associated ma
Returns the symbol that is currently active in the widget. Can be ``None``.

:return: The active symbol.
%End

QDialogButtonBox *buttonBox() const;
%Docstring
Returns a reference to the dialog's button box.

.. versionadded:: 3.10
%End

protected:
Expand Down
15 changes: 10 additions & 5 deletions src/gui/qgscolorbrewercolorrampdialog.cpp
Expand Up @@ -128,16 +128,21 @@ QgsColorBrewerColorRampDialog::QgsColorBrewerColorRampDialog( const QgsColorBrew
QVBoxLayout *vLayout = new QVBoxLayout();
mWidget = new QgsColorBrewerColorRampWidget( ramp );
vLayout->addWidget( mWidget );
QDialogButtonBox *bbox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
connect( bbox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( bbox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( bbox, &QDialogButtonBox::helpRequested, this, &QgsColorBrewerColorRampDialog::showHelp );
vLayout->addWidget( bbox );
mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsColorBrewerColorRampDialog::showHelp );
vLayout->addWidget( mButtonBox );
setLayout( vLayout );
setWindowTitle( tr( "ColorBrewer Ramp" ) );
connect( mWidget, &QgsColorBrewerColorRampWidget::changed, this, &QgsColorBrewerColorRampDialog::changed );
}

QDialogButtonBox *QgsColorBrewerColorRampDialog::buttonBox() const
{
return mButtonBox;
}

void QgsColorBrewerColorRampDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "working_with_vector/style_library.html#color-ramp" ) );
Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgscolorbrewercolorrampdialog.h
Expand Up @@ -24,6 +24,7 @@
#include "qgis_sip.h"

class QgsColorBrewerColorRamp;
class QDialogButtonBox;

/**
* \ingroup gui
Expand Down Expand Up @@ -109,6 +110,12 @@ class GUI_EXPORT QgsColorBrewerColorRampDialog : public QDialog
*/
void setRamp( const QgsColorBrewerColorRamp &ramp ) { mWidget->setRamp( ramp ); }

/**
* Returns a reference to the dialog's button box.
* \since QGIS 3.10
*/
QDialogButtonBox *buttonBox() const;

signals:

//! Emitted when the dialog settings change
Expand All @@ -117,6 +124,7 @@ class GUI_EXPORT QgsColorBrewerColorRampDialog : public QDialog
private:

QgsColorBrewerColorRampWidget *mWidget = nullptr;
QDialogButtonBox *mButtonBox = nullptr;

private slots:

Expand Down
7 changes: 6 additions & 1 deletion src/gui/qgsgradientcolorrampdialog.cpp
Expand Up @@ -155,7 +155,7 @@ QgsGradientColorRampDialog::QgsGradientColorRampDialog( const QgsGradientColorRa
connect( mStopEditor, &QgsGradientStopEditor::selectedStopChanged, this, &QgsGradientColorRampDialog::selectedStopChanged );
mStopEditor->selectStop( 0 );

connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsGradientColorRampDialog::showHelp );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsGradientColorRampDialog::showHelp );
}

QgsGradientColorRampDialog::~QgsGradientColorRampDialog()
Expand All @@ -179,6 +179,11 @@ void QgsGradientColorRampDialog::setRamp( const QgsGradientColorRamp &ramp )
emit changed();
}

QDialogButtonBox *QgsGradientColorRampDialog::buttonBox() const
{
return mButtonBox;
}

void QgsGradientColorRampDialog::cboType_currentIndexChanged( int index )
{
if ( ( index == 0 && mRamp.isDiscrete() ) ||
Expand Down
6 changes: 6 additions & 0 deletions src/gui/qgsgradientcolorrampdialog.h
Expand Up @@ -63,6 +63,12 @@ class GUI_EXPORT QgsGradientColorRampDialog : public QDialog, private Ui::QgsGra
*/
void setRamp( const QgsGradientColorRamp &ramp );

/**
* Returns a reference to the dialog's button box.
* \since QGIS 3.10
*/
QDialogButtonBox *buttonBox() const;

signals:

//! Emitted when the dialog settings change
Expand Down
13 changes: 9 additions & 4 deletions src/gui/qgslabelinggui.cpp
Expand Up @@ -1070,14 +1070,19 @@ QgsLabelSettingsDialog::QgsLabelSettingsDialog( const QgsPalLayerSettings &setti
QVBoxLayout *vLayout = new QVBoxLayout();
mWidget = new QgsLabelingGui( layer, mapCanvas, settings, nullptr, geomType );
vLayout->addWidget( mWidget );
QDialogButtonBox *bbox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal );
connect( bbox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( bbox, &QDialogButtonBox::rejected, this, &QDialog::reject );
vLayout->addWidget( bbox );
mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal );
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
vLayout->addWidget( mButtonBox );
setLayout( vLayout );
setWindowTitle( tr( "Label Settings" ) );
}

QDialogButtonBox *QgsLabelSettingsDialog::buttonBox() const
{
return mButtonBox;
}



///@endcond
8 changes: 8 additions & 0 deletions src/gui/qgslabelinggui.h
Expand Up @@ -23,6 +23,8 @@
#include "qgspropertyoverridebutton.h"
#include "qgis_gui.h"

class QDialogButtonBox;

#define SIP_NO_FILE

///@cond PRIVATE
Expand Down Expand Up @@ -132,9 +134,15 @@ class GUI_EXPORT QgsLabelSettingsDialog : public QDialog

QgsPalLayerSettings settings() const { return mWidget->layerSettings(); }

/**
* Returns a reference to the dialog's button box.
*/
QDialogButtonBox *buttonBox() const;

private:

QgsLabelingGui *mWidget = nullptr;
QDialogButtonBox *mButtonBox = nullptr;

};

Expand Down
15 changes: 10 additions & 5 deletions src/gui/qgslimitedrandomcolorrampdialog.cpp
Expand Up @@ -122,16 +122,21 @@ QgsLimitedRandomColorRampDialog::QgsLimitedRandomColorRampDialog( const QgsLimit
QVBoxLayout *vLayout = new QVBoxLayout();
mWidget = new QgsLimitedRandomColorRampWidget( ramp );
vLayout->addWidget( mWidget );
QDialogButtonBox *bbox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
connect( bbox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( bbox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( bbox, &QDialogButtonBox::helpRequested, this, &QgsLimitedRandomColorRampDialog::showHelp );
vLayout->addWidget( bbox );
mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsLimitedRandomColorRampDialog::showHelp );
vLayout->addWidget( mButtonBox );
setLayout( vLayout );
setWindowTitle( tr( "Random Color Ramp" ) );
connect( mWidget, &QgsLimitedRandomColorRampWidget::changed, this, &QgsLimitedRandomColorRampDialog::changed );
}

QDialogButtonBox *QgsLimitedRandomColorRampDialog::buttonBox() const
{
return mButtonBox;
}

void QgsLimitedRandomColorRampDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "working_with_vector/style_library.html#color-ramp" ) );
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgslimitedrandomcolorrampdialog.h
Expand Up @@ -23,6 +23,8 @@
#include "ui_qgslimitedrandomcolorrampwidgetbase.h"
#include "qgis_gui.h"

class QDialogButtonBox;

/**
* \ingroup gui
* \class QgsLimitedRandomColorRampWidget
Expand Down Expand Up @@ -120,6 +122,12 @@ class GUI_EXPORT QgsLimitedRandomColorRampDialog : public QDialog
*/
void setRamp( const QgsLimitedRandomColorRamp &ramp ) { mWidget->setRamp( ramp ); }

/**
* Returns a reference to the dialog's button box.
* \since QGIS 3.10
*/
QDialogButtonBox *buttonBox() const;

signals:

//! Emitted when the dialog settings change
Expand All @@ -128,6 +136,7 @@ class GUI_EXPORT QgsLimitedRandomColorRampDialog : public QDialog
private:

QgsLimitedRandomColorRampWidget *mWidget = nullptr;
QDialogButtonBox *mButtonBox = nullptr;

private slots:

Expand Down
15 changes: 10 additions & 5 deletions src/gui/qgspresetcolorrampdialog.cpp
Expand Up @@ -112,16 +112,21 @@ QgsPresetColorRampDialog::QgsPresetColorRampDialog( const QgsPresetSchemeColorRa
QVBoxLayout *vLayout = new QVBoxLayout();
mWidget = new QgsPresetColorRampWidget( ramp );
vLayout->addWidget( mWidget );
QDialogButtonBox *bbox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
connect( bbox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( bbox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( bbox, &QDialogButtonBox::helpRequested, this, &QgsPresetColorRampDialog::showHelp );
vLayout->addWidget( bbox );
mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
connect( mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsPresetColorRampDialog::showHelp );
vLayout->addWidget( mButtonBox );
setLayout( vLayout );
setWindowTitle( tr( "Color Presets Ramp" ) );
connect( mWidget, &QgsPresetColorRampWidget::changed, this, &QgsPresetColorRampDialog::changed );
}

QDialogButtonBox *QgsPresetColorRampDialog::buttonBox() const
{
return mButtonBox;
}

void QgsPresetColorRampDialog::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "working_with_vector/style_library.html#color-ramp" ) );
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgspresetcolorrampdialog.h
Expand Up @@ -23,6 +23,8 @@
#include "ui_qgspresetcolorrampwidgetbase.h"
#include "qgis_gui.h"

class QDialogButtonBox;

/**
* \ingroup gui
* \class QgsPresetColorRampWidget
Expand Down Expand Up @@ -108,6 +110,12 @@ class GUI_EXPORT QgsPresetColorRampDialog : public QDialog
*/
void setRamp( const QgsPresetSchemeColorRamp &ramp ) { mWidget->setRamp( ramp ); }

/**
* Returns a reference to the dialog's button box.
* \since QGIS 3.10
*/
QDialogButtonBox *buttonBox() const;

signals:

//! Emitted when the dialog settings change
Expand All @@ -116,6 +124,7 @@ class GUI_EXPORT QgsPresetColorRampDialog : public QDialog
private:

QgsPresetColorRampWidget *mWidget = nullptr;
QDialogButtonBox *mButtonBox = nullptr;

private slots:

Expand Down
13 changes: 9 additions & 4 deletions src/gui/qgstextformatwidget.cpp
Expand Up @@ -1686,21 +1686,26 @@ QgsTextFormatDialog::QgsTextFormatDialog( const QgsTextFormat &format, QgsMapCan
QVBoxLayout *layout = new QVBoxLayout( this );
layout->addWidget( mFormatWidget );

QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
layout->addWidget( buttonBox );
mButtonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
layout->addWidget( mButtonBox );

setLayout( layout );
QgsGui::instance()->enableAutoGeometryRestore( this );

connect( buttonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked, this, &QDialog::accept );
connect( buttonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked, this, &QDialog::reject );
connect( mButtonBox->button( QDialogButtonBox::Ok ), &QAbstractButton::clicked, this, &QDialog::accept );
connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QAbstractButton::clicked, this, &QDialog::reject );
}

QgsTextFormat QgsTextFormatDialog::format() const
{
return mFormatWidget->format();
}

QDialogButtonBox *QgsTextFormatDialog::buttonBox() const
{
return mButtonBox;
}

QgsTextFormatPanelWidget::QgsTextFormatPanelWidget( const QgsTextFormat &format, QgsMapCanvas *mapCanvas, QWidget *parent )
: QgsPanelWidgetWrapper( new QgsTextFormatWidget( format, mapCanvas ), parent )
{
Expand Down

0 comments on commit a57d04f

Please sign in to comment.