@@ -74,6 +74,10 @@ class GraphicsView(QtWidgets.QGraphicsView):
7474 :param parent: parent widget
7575 """
7676
77+ # Class-level constants for default colors
78+ DEFAULT_DRAWING_GRID_COLOR = QtGui .QColor (208 , 208 , 208 ) # #D0D0D0
79+ DEFAULT_NODE_GRID_COLOR = QtGui .QColor (190 , 190 , 190 ) # #BEBEBE
80+
7781 def __init__ (self , parent ):
7882
7983 # Our parent is the central widget which parent is the main window.
@@ -92,6 +96,8 @@ def __init__(self, parent):
9296 self ._dragging = False
9397 self ._grid_size = 75
9498 self ._drawing_grid_size = 25
99+ self ._drawing_grid_color = self .DEFAULT_DRAWING_GRID_COLOR
100+ self ._node_grid_color = self .DEFAULT_NODE_GRID_COLOR
95101 self ._last_mouse_position = None
96102 self ._topology = Topology .instance ()
97103 self ._background_warning_msgbox = QtWidgets .QErrorMessage (self )
@@ -1659,11 +1665,39 @@ def createDrawingItem(self, type, x, y, z, locked=False, rotation=0, svg=None, d
16591665 self ._topology .addDrawing (item )
16601666 return item
16611667
1668+ @QtCore .Property (QtGui .QColor )
1669+ def drawingGridColor (self ):
1670+ """Returns the drawing grid color"""
1671+ return self ._drawing_grid_color
1672+
1673+ @drawingGridColor .setter
1674+ def drawingGridColor (self , color ):
1675+ """Sets the drawing grid color"""
1676+ self ._drawing_grid_color = color
1677+ self .viewport ().update ()
1678+
1679+ @QtCore .Property (QtGui .QColor )
1680+ def nodeGridColor (self ):
1681+ """Returns the node grid color"""
1682+ return self ._node_grid_color
1683+
1684+ @nodeGridColor .setter
1685+ def nodeGridColor (self , color ):
1686+ """Sets the node grid color"""
1687+ self ._node_grid_color = color
1688+ self .viewport ().update ()
1689+
1690+ def resetGridColors (self ):
1691+ """Reset grid colors to defaults"""
1692+ self ._drawing_grid_color = self .DEFAULT_DRAWING_GRID_COLOR
1693+ self ._node_grid_color = self .DEFAULT_NODE_GRID_COLOR
1694+ self .viewport ().update ()
1695+
16621696 def drawBackground (self , painter , rect ):
16631697 super ().drawBackground (painter , rect )
16641698 if self ._main_window .uiShowGridAction .isChecked ():
1665- grids = [(self .drawingGridSize (), QtGui . QColor ( 208 , 208 , 208 ) ),
1666- (self .nodeGridSize (), QtGui . QColor ( 190 , 190 , 190 ) )]
1699+ grids = [(self .drawingGridSize (), self . _drawing_grid_color ),
1700+ (self .nodeGridSize (), self . _node_grid_color )]
16671701 painter .save ()
16681702 for (grid , colour ) in grids :
16691703 if not grid :
0 commit comments