mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[projects] Add signals for background color and selection color change
This commit is contained in:
parent
6b1e31170e
commit
23cc659a05
@ -1412,6 +1412,24 @@ Emitted whenever the project's color scheme has been changed.
|
||||
.. versionadded:: 3.6
|
||||
%End
|
||||
|
||||
void backgroundColorChanged();
|
||||
%Docstring
|
||||
Emitted whenever the project's canvas background color has been changed.
|
||||
|
||||
.. seealso:: :py:func:`setBackgroundColor`
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
void selectionColorChanged();
|
||||
%Docstring
|
||||
Emitted whenever the project's selection color has been changed.
|
||||
|
||||
.. seealso:: :py:func:`setSelectionColor`
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
|
||||
void layersWillBeRemoved( const QStringList &layerIds );
|
||||
%Docstring
|
||||
|
@ -3206,6 +3206,8 @@ void QgsProject::setBackgroundColor( const QColor &color )
|
||||
writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorRedPart" ), color.red() );
|
||||
writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorGreenPart" ), color.green() );
|
||||
writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/CanvasColorBluePart" ), color.blue() );
|
||||
|
||||
emit backgroundColorChanged();
|
||||
}
|
||||
|
||||
QColor QgsProject::backgroundColor() const
|
||||
@ -3221,6 +3223,8 @@ void QgsProject::setSelectionColor( const QColor &color )
|
||||
writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorGreenPart" ), color.green() );
|
||||
writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorBluePart" ), color.blue() );
|
||||
writeEntry( QStringLiteral( "Gui" ), QStringLiteral( "/SelectionColorAlphaPart" ), color.alpha() );
|
||||
|
||||
emit selectionColorChanged();
|
||||
}
|
||||
|
||||
QColor QgsProject::selectionColor() const
|
||||
|
@ -1421,6 +1421,22 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
|
||||
*/
|
||||
void projectColorsChanged();
|
||||
|
||||
/**
|
||||
* Emitted whenever the project's canvas background color has been changed.
|
||||
|
||||
* \see setBackgroundColor()
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void backgroundColorChanged();
|
||||
|
||||
/**
|
||||
* Emitted whenever the project's selection color has been changed.
|
||||
|
||||
* \see setSelectionColor()
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void selectionColorChanged();
|
||||
|
||||
//
|
||||
// signals from QgsMapLayerRegistry
|
||||
//
|
||||
|
@ -1242,7 +1242,9 @@ class TestQgsProject(unittest.TestCase):
|
||||
blue = int(s.value("qgis/default_canvas_color_blue", 255))
|
||||
# test default canvas backgroud color
|
||||
self.assertEqual(p.backgroundColor(), QColor(red, green, blue))
|
||||
spy = QSignalSpy(p.backgroundColorChanged)
|
||||
p.setBackgroundColor(QColor(0, 0, 0))
|
||||
self.assertEqual(len(spy), 1)
|
||||
# test customized canvas background color
|
||||
self.assertEqual(p.backgroundColor(), QColor(0, 0, 0))
|
||||
|
||||
@ -1256,7 +1258,9 @@ class TestQgsProject(unittest.TestCase):
|
||||
alpha = int(s.value("qgis/default_selection_color_alpha", 255))
|
||||
# test default feature selection color
|
||||
self.assertEqual(p.selectionColor(), QColor(red, green, blue, alpha))
|
||||
spy = QSignalSpy(p.selectionColorChanged)
|
||||
p.setSelectionColor(QColor(0, 0, 0, 50))
|
||||
self.assertEqual(len(spy), 1)
|
||||
# test customized feature selection color
|
||||
self.assertEqual(p.selectionColor(), QColor(0, 0, 0, 50))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user