Skip to content
Permalink
Browse files

Call saveSettings from QgsCompoundColorWidget::hideEvent

We currently call saveSettings from the QgsCompoundColorWidget destructor.
Since we restore the custom colors when the constructor runs, any changes made
will be lost if a second QgsCompoundColorWidget is created before the first is
destroyed. This adds a hideEvent handler, and saves the settings from there.

Fixes #37749.
  • Loading branch information
dminor committed Jul 20, 2020
1 parent 9d41db1 commit bfc0925bbfcae6994e33c753ee23d981c9e17bbe
@@ -133,6 +133,9 @@ Sets the color to show in an optional "previous color" section

protected:

virtual void hideEvent( QHideEvent *e );


virtual void mousePressEvent( QMouseEvent *e );


@@ -292,7 +292,6 @@ QgsCompoundColorWidget::QgsCompoundColorWidget( QWidget *parent, const QColor &c

QgsCompoundColorWidget::~QgsCompoundColorWidget()
{
saveSettings();
if ( !mDiscarded )
{
QgsRecentColorScheme::addRecentColor( color() );
@@ -741,6 +740,12 @@ void QgsCompoundColorWidget::setPreviousColor( const QColor &color )
mColorPreview->setColor2( color );
}

void QgsCompoundColorWidget::hideEvent( QHideEvent *e )
{
saveSettings();
QWidget::hideEvent( e );
}

void QgsCompoundColorWidget::mousePressEvent( QMouseEvent *e )
{
if ( mPickingColor )
@@ -136,6 +136,8 @@ class GUI_EXPORT QgsCompoundColorWidget : public QgsPanelWidget, private Ui::Qgs

protected:

void hideEvent( QHideEvent *e ) override;

void mousePressEvent( QMouseEvent *e ) override;

void mouseMoveEvent( QMouseEvent *e ) override;

0 comments on commit bfc0925

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