UML Diagrams: added support for dark color scheme.

Sun, 12 Apr 2020 18:40:37 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 12 Apr 2020 18:40:37 +0200
changeset 7529
2b8a0d8ba12a
parent 7528
0345f54d3959
child 7530
9f4fac61e7c7

UML Diagrams: added support for dark color scheme.

eric6/E5Graphics/E5ArrowItem.py file | annotate | diff | comparison | revisions
eric6/E5Graphics/E5GraphicsView.py file | annotate | diff | comparison | revisions
eric6/Graphics/ApplicationDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Graphics/AssociationItem.py file | annotate | diff | comparison | revisions
eric6/Graphics/ClassItem.py file | annotate | diff | comparison | revisions
eric6/Graphics/ImportsDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Graphics/ModuleItem.py file | annotate | diff | comparison | revisions
eric6/Graphics/PackageDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Graphics/PackageItem.py file | annotate | diff | comparison | revisions
eric6/Graphics/UMLClassDiagramBuilder.py file | annotate | diff | comparison | revisions
eric6/Graphics/UMLGraphicsView.py file | annotate | diff | comparison | revisions
eric6/Graphics/UMLItem.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/GraphicsPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/GraphicsPage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
--- a/eric6/E5Graphics/E5ArrowItem.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/E5Graphics/E5ArrowItem.py	Sun Apr 12 18:40:37 2020 +0200
@@ -11,7 +11,7 @@
 import math
 
 from PyQt5.QtCore import QPointF, QRectF, QSizeF, QLineF, Qt
-from PyQt5.QtGui import QPen, QPolygonF
+from PyQt5.QtGui import QPen, QPolygonF, QColor
 from PyQt5.QtWidgets import QAbstractGraphicsShapeItem, QGraphicsItem, QStyle
 
 NormalArrow = 1
@@ -26,15 +26,23 @@
     Class implementing an arrow graphics item subclass.
     """
     def __init__(self, origin=None, end=None,
-                 filled=False, arrowType=NormalArrow, parent=None):
+                 filled=False, arrowType=NormalArrow, colors=None,
+                 parent=None):
         """
         Constructor
         
-        @param origin origin of the arrow (QPointF)
-        @param end end point of the arrow (QPointF)
-        @param filled flag indicating a filled arrow head (boolean)
-        @param arrowType arrow type (NormalArrow, WideArrow)
-        @keyparam parent reference to the parent object (QGraphicsItem)
+        @param origin origin of the arrow
+        @type QPointF
+        @param end end point of the arrow
+        @type QPointF
+        @param filled flag indicating a filled arrow head
+        @type bool
+        @param arrowType arrow type
+        @type int, one of NormalArrow, WideArrow
+        @param colors tuple containing the foreground and background colors
+        @type tuple of (QColor, QColor)
+        @param parent reference to the parent object
+        @type QGraphicsItem
         """
         super(E5ArrowItem, self).__init__(parent)
         
@@ -43,6 +51,11 @@
         self._filled = filled
         self._type = arrowType
         
+        if colors is None:
+            self._colors = (QColor(Qt.black), QColor(Qt.white))
+        else:
+            self._colors = colors
+        
         self._halfLength = 13.0
         
         self.setFlag(QGraphicsItem.ItemIsMovable, True)
@@ -114,7 +127,8 @@
         # draw the line first
         line = QLineF(self._origin, self._end)
         painter.setPen(
-            QPen(Qt.black, width, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin))
+            QPen(self._colors[0], width, Qt.SolidLine, Qt.FlatCap,
+                 Qt.MiterJoin))
         painter.drawLine(line)
         
         # draw the arrow head
@@ -132,9 +146,9 @@
                      self._end.y() - self._halfLength * math.sin(arrowSlope))
         
         if self._filled:
-            painter.setBrush(Qt.black)
+            painter.setBrush(self._colors[0])
         else:
-            painter.setBrush(Qt.white)
+            painter.setBrush(self._colors[1])
         polygon = QPolygonF()
         polygon.append(line.p2())
         polygon.append(a1)
--- a/eric6/E5Graphics/E5GraphicsView.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/E5Graphics/E5GraphicsView.py	Sun Apr 12 18:40:37 2020 +0200
@@ -14,6 +14,8 @@
 from PyQt5.QtGui import QBrush, QPainter, QPixmap, QFont, QColor
 from PyQt5.QtWidgets import QGraphicsView
 
+from E5Gui.E5Application import e5App
+
 import Preferences
 
 
@@ -45,8 +47,7 @@
         self.setObjectName("E5GraphicsView")
         
         self.__initialSceneSize = self.scene().sceneRect().size()
-        # TODO: set background according to user selected color
-        self.setBackgroundBrush(QBrush(Qt.white))
+        self.setBackgroundBrush(QBrush(self.getBackgroundColor()))
         self.setRenderHint(QPainter.Antialiasing, True)
         self.setDragMode(QGraphicsView.RubberBandDrag)
         self.setAlignment(Qt.Alignment(Qt.AlignLeft | Qt.AlignTop))
@@ -71,7 +72,44 @@
             "whole selection.</li>\n"
             "</ul>\n"
         ))
+    
+    def getDrawingColors(self):
+        """
+        Public method to get the configured drawing colors.
         
+        @return tuple containing the foreground and background colors
+        @rtype tuple of (QColor, QColor)
+        """
+        drawingMode = Preferences.getGraphics("DrawingMode")
+        if drawingMode == "automatic":
+            if e5App().usesDarkPalette():
+                drawingMode = "white_black"
+            else:
+                drawingMode = "black_white"
+        
+        if drawingMode == "white_black":
+            return (QColor("#ffffff"), QColor("#262626"))
+        else:
+            return (QColor("#000000"), QColor("#ffffff"))
+    
+    def getForegroundColor(self):
+        """
+        Public method to get the configured foreground color.
+        
+        @return foreground color
+        @rtype QColor
+        """
+        return self.getDrawingColors()[0]
+    
+    def getBackgroundColor(self):
+        """
+        Public method to get the configured background color.
+        
+        @return background color
+        @rtype QColor
+        """
+        return self.getDrawingColors()[1]
+    
     def __levelForZoom(self, zoom):
         """
         Private method determining the zoom level index given a zoom factor.
--- a/eric6/Graphics/ApplicationDiagramBuilder.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/ApplicationDiagramBuilder.py	Sun Apr 12 18:40:37 2020 +0200
@@ -244,7 +244,8 @@
         from .PackageItem import PackageItem, PackageModel
         modules.sort()
         pm = PackageModel(name, modules)
-        pw = PackageItem(pm, x, y, noModules=self.noModules, scene=self.scene)
+        pw = PackageItem(pm, x, y, noModules=self.noModules, scene=self.scene,
+                         colors=self.umlView.getDrawingColors())
         pw.setId(self.umlView.getItemId())
         return pw
         
@@ -259,7 +260,8 @@
             for rel in shapes[package][1]:
                 assoc = AssociationItem(
                     shapes[package][0], shapes[rel][0],
-                    Imports)
+                    Imports,
+                    colors=self.umlView.getDrawingColors())
                 self.scene.addItem(assoc)
     
     def getPersistenceData(self):
--- a/eric6/Graphics/AssociationItem.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/AssociationItem.py	Sun Apr 12 18:40:37 2020 +0200
@@ -41,7 +41,7 @@
     ending at the second.
     """
     def __init__(self, itemA, itemB, assocType=Normal, topToBottom=False,
-                 parent=None):
+                 colors=None, parent=None):
         """
         Constructor
         
@@ -53,9 +53,13 @@
             <li>Generalisation</li>
             <li>Imports</li>
             </ul>
-        @keyparam topToBottom flag indicating to draw the association
-            from item A top to item B bottom (boolean)
-        @keyparam parent reference to the parent object (QGraphicsItem)
+        @param topToBottom flag indicating to draw the association
+            from item A top to item B bottom
+        @type bool
+        @param colors tuple containing the foreground and background colors
+        @type tuple of (QColor, QColor)
+        @param parent reference to the parent object
+        @type QGraphicsItem
         """
         if assocType == Normal:
             arrowType = NormalArrow
@@ -68,7 +72,7 @@
             arrowFilled = False
         
         E5ArrowItem.__init__(self, QPointF(0, 0), QPointF(100, 100),
-                             arrowFilled, arrowType, parent)
+                             arrowFilled, arrowType, colors, parent)
         
         self.setFlag(QGraphicsItem.ItemIsMovable, False)
         self.setFlag(QGraphicsItem.ItemIsSelectable, False)
--- a/eric6/Graphics/ClassItem.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/ClassItem.py	Sun Apr 12 18:40:37 2020 +0200
@@ -75,22 +75,31 @@
     ItemType = "class"
     
     def __init__(self, model=None, external=False, x=0, y=0,
-                 rounded=False, noAttrs=False, parent=None, scene=None):
+                 rounded=False, noAttrs=False, colors=None, parent=None,
+                 scene=None):
         """
         Constructor
         
-        @param model class model containing the class data (ClassModel)
+        @param model class model containing the class data
+        @type ClassModel
         @param external flag indicating a class defined outside our scope
-            (boolean)
-        @param x x-coordinate (integer)
-        @param y y-coordinate (integer)
-        @keyparam rounded flag indicating a rounded corner (boolean)
-        @keyparam noAttrs flag indicating, that no attributes should be shown
-            (boolean)
-        @keyparam parent reference to the parent object (QGraphicsItem)
-        @keyparam scene reference to the scene object (QGraphicsScene)
+        @type boolean
+        @param x x-coordinate
+        @type int
+        @param y y-coordinate
+        @type int
+        @param rounded flag indicating a rounded corner
+        @type bool
+        @param noAttrs flag indicating, that no attributes should be shown
+        @type bool
+        @param colors tuple containing the foreground and background colors
+        @type tuple of (QColor, QColor)
+        @param parent reference to the parent object
+        @type QGraphicsItem
+        @param scene reference to the scene object
+        @type QGraphicsScene
         """
-        UMLItem.__init__(self, model, x, y, rounded, parent)
+        UMLItem.__init__(self, model, x, y, rounded, colors, parent)
         
         self.external = external
         self.noAttrs = noAttrs
@@ -117,6 +126,7 @@
         x = self.margin + self.rect().x()
         y = self.margin + self.rect().y()
         self.header = QGraphicsSimpleTextItem(self)
+        self.header.setBrush(self._colors[0])
         self.header.setFont(boldFont)
         self.header.setText(self.model.getName())
         self.header.setPos(x, y)
@@ -127,6 +137,7 @@
             else:
                 txt = " "
             self.attrs = QGraphicsSimpleTextItem(self)
+            self.attrs.setBrush(self._colors[0])
             self.attrs.setFont(self.font)
             self.attrs.setText(txt)
             self.attrs.setPos(x, y)
@@ -138,6 +149,7 @@
         else:
             txt = " "
         self.meths = QGraphicsSimpleTextItem(self)
+        self.meths.setBrush(self._colors[0])
         self.meths.setFont(self.font)
         self.meths.setText(txt)
         self.meths.setPos(x, y)
--- a/eric6/Graphics/ImportsDiagramBuilder.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/ImportsDiagramBuilder.py	Sun Apr 12 18:40:37 2020 +0200
@@ -241,7 +241,8 @@
         from .ModuleItem import ModuleItem, ModuleModel
         classes.sort()
         impM = ModuleModel(name, classes)
-        impW = ModuleItem(impM, x, y, scene=self.scene)
+        impW = ModuleItem(impM, x, y, scene=self.scene,
+                          colors=self.umlView.getDrawingColors())
         impW.setId(self.umlView.getItemId())
         return impW
     
@@ -256,7 +257,8 @@
             for rel in shapes[module][1]:
                 assoc = AssociationItem(
                     shapes[module][0], shapes[rel][0],
-                    Imports)
+                    Imports,
+                    colors=self.umlView.getDrawingColors())
                 self.scene.addItem(assoc)
     
     def getPersistenceData(self):
--- a/eric6/Graphics/ModuleItem.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/ModuleItem.py	Sun Apr 12 18:40:37 2020 +0200
@@ -52,19 +52,27 @@
     """
     ItemType = "module"
     
-    def __init__(self, model=None, x=0, y=0, rounded=False,
+    def __init__(self, model=None, x=0, y=0, rounded=False, colors=None,
                  parent=None, scene=None):
         """
         Constructor
         
-        @param model module model containing the module data (ModuleModel)
-        @param x x-coordinate (integer)
-        @param y y-coordinate (integer)
-        @keyparam rounded flag indicating a rounded corner (boolean)
-        @keyparam parent reference to the parent object (QGraphicsItem)
-        @keyparam scene reference to the scene object (QGraphicsScene)
+        @param model module model containing the module data
+        @type ModuleModel
+        @param x x-coordinate
+        @type int
+        @param y y-coordinate
+        @type int
+        @param rounded flag indicating a rounded corner
+        @type bool
+        @param colors tuple containing the foreground and background colors
+        @type tuple of (QColor, QColor)
+        @param parent reference to the parent object
+        @type QGraphicsItem
+        @param scene reference to the scene object
+        @type QGraphicsScene
         """
-        UMLItem.__init__(self, model, x, y, rounded, parent)
+        UMLItem.__init__(self, model, x, y, rounded, colors, parent)
         
         scene.addItem(self)
         
@@ -87,6 +95,7 @@
         x = self.margin + self.rect().x()
         y = self.margin + self.rect().y()
         self.header = QGraphicsSimpleTextItem(self)
+        self.header.setBrush(self._colors[0])
         self.header.setFont(boldFont)
         self.header.setText(self.model.getName())
         self.header.setPos(x, y)
@@ -96,6 +105,7 @@
         else:
             txt = " "
         self.classes = QGraphicsSimpleTextItem(self)
+        self.classes.setBrush(self._colors[0])
         self.classes.setFont(self.font)
         self.classes.setText(txt)
         self.classes.setPos(x, y)
--- a/eric6/Graphics/PackageDiagramBuilder.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/PackageDiagramBuilder.py	Sun Apr 12 18:40:37 2020 +0200
@@ -394,7 +394,8 @@
         if isRbModule:
             name = "{0} (Module)".format(name)
         cl = ClassModel(name, meths[:], attrs[:])
-        cw = ClassItem(cl, False, x, y, noAttrs=self.noAttrs, scene=self.scene)
+        cw = ClassItem(cl, False, x, y, noAttrs=self.noAttrs, scene=self.scene,
+                       colors=self.umlView.getDrawingColors())
         cw.setId(self.umlView.getItemId())
         self.allClasses[className] = cw
     
@@ -411,7 +412,8 @@
         """
         from .ClassItem import ClassItem, ClassModel
         cl = ClassModel(_class)
-        cw = ClassItem(cl, True, x, y, noAttrs=self.noAttrs, scene=self.scene)
+        cw = ClassItem(cl, True, x, y, noAttrs=self.noAttrs, scene=self.scene,
+                       colors=self.umlView.getDrawingColors())
         cw.setId(self.umlView.getItemId())
         self.allClasses[_class] = cw
     
@@ -427,7 +429,8 @@
         """
         from .PackageItem import PackageItem, PackageModel
         pm = PackageModel(name, modules)
-        pw = PackageItem(pm, x, y, scene=self.scene)
+        pw = PackageItem(pm, x, y, scene=self.scene,
+                         colors=self.umlView.getDrawingColors())
         pw.setId(self.umlView.getItemId())
         self.allClasses[name] = pw
     
@@ -444,7 +447,8 @@
                     self.__getCurrentShape(route[1]),
                     self.__getCurrentShape(route[0]),
                     Generalisation,
-                    topToBottom=True)
+                    topToBottom=True,
+                    colors=self.umlView.getDrawingColors())
                 self.scene.addItem(assoc)
     
     def getPersistenceData(self):
--- a/eric6/Graphics/PackageItem.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/PackageItem.py	Sun Apr 12 18:40:37 2020 +0200
@@ -55,20 +55,29 @@
     ItemType = "package"
     
     def __init__(self, model=None, x=0, y=0, rounded=False,
-                 noModules=False, parent=None, scene=None):
+                 noModules=False, colors=None, parent=None, scene=None):
         """
         Constructor
         
-        @param model package model containing the package data (PackageModel)
-        @param x x-coordinate (integer)
-        @param y y-coordinate (integer)
-        @param rounded flag indicating a rounded corner (boolean)
-        @keyparam noModules flag indicating, that no module names should be
-            shown (boolean)
-        @keyparam parent reference to the parent object (QGraphicsItem)
-        @keyparam scene reference to the scene object (QGraphicsScene)
+        @param model package model containing the package data
+        @type PackageModel
+        @param x x-coordinate
+        @type int
+        @param y y-coordinate
+        @type int
+        @param rounded flag indicating a rounded corner
+        @type bool
+        @param noModules flag indicating, that no module names should be
+            shown
+        @type bool
+        @param colors tuple containing the foreground and background colors
+        @type tuple of (QColor, QColor)
+        @param parent reference to the parent object
+        @type QGraphicsItem
+        @param scene reference to the scene object
+        @type QGraphicsScene
         """
-        UMLItem.__init__(self, model, x, y, rounded, parent)
+        UMLItem.__init__(self, model, x, y, rounded, colors, parent)
         self.noModules = noModules
         
         scene.addItem(self)
@@ -92,6 +101,7 @@
         x = self.margin + self.rect().x()
         y = self.margin + self.rect().y()
         self.header = QGraphicsSimpleTextItem(self)
+        self.header.setBrush(self._colors[0])
         self.header.setFont(boldFont)
         self.header.setText(self.model.getName())
         self.header.setPos(x, y)
@@ -103,6 +113,7 @@
             else:
                 txt = " "
             self.modules = QGraphicsSimpleTextItem(self)
+            self.modules.setBrush(self._colors[0])
             self.modules.setFont(self.font)
             self.modules.setText(txt)
             self.modules.setPos(x, y)
--- a/eric6/Graphics/UMLClassDiagramBuilder.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/UMLClassDiagramBuilder.py	Sun Apr 12 18:40:37 2020 +0200
@@ -241,7 +241,8 @@
         if isRbModule:
             name = "{0} (Module)".format(name)
         cl = ClassModel(name, meths[:], attrs[:])
-        cw = ClassItem(cl, False, x, y, noAttrs=self.noAttrs, scene=self.scene)
+        cw = ClassItem(cl, False, x, y, noAttrs=self.noAttrs, scene=self.scene,
+                       colors=self.umlView.getDrawingColors())
         cw.setId(self.umlView.getItemId())
         self.allClasses[className] = cw
         if _class.name not in self.allModules[self.file]:
@@ -260,7 +261,8 @@
         """
         from .ClassItem import ClassItem, ClassModel
         cl = ClassModel(_class)
-        cw = ClassItem(cl, True, x, y, noAttrs=self.noAttrs, scene=self.scene)
+        cw = ClassItem(cl, True, x, y, noAttrs=self.noAttrs, scene=self.scene,
+                       colors=self.umlView.getDrawingColors())
         cw.setId(self.umlView.getItemId())
         self.allClasses[_class] = cw
         if _class not in self.allModules[self.file]:
@@ -279,7 +281,8 @@
                     self.__getCurrentShape(route[1]),
                     self.__getCurrentShape(route[0]),
                     Generalisation,
-                    topToBottom=True)
+                    topToBottom=True,
+                    colors=self.umlView.getDrawingColors())
                 self.scene.addItem(assoc)
     
     def getPersistenceData(self):
--- a/eric6/Graphics/UMLGraphicsView.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/UMLGraphicsView.py	Sun Apr 12 18:40:37 2020 +0200
@@ -744,11 +744,14 @@
                     y = float(y.split("=", 1)[1].strip())
                     itemType = itemType.split("=", 1)[1].strip()
                     if itemType == ClassItem.ItemType:
-                        itm = ClassItem(x=x, y=y, scene=self.scene())
+                        itm = ClassItem(x=x, y=y, scene=self.scene(),
+                                        colors=self.getDrawingColors())
                     elif itemType == ModuleItem.ItemType:
-                        itm = ModuleItem(x=x, y=y, scene=self.scene())
+                        itm = ModuleItem(x=x, y=y, scene=self.scene(),
+                                         colors=self.getDrawingColors())
                     elif itemType == PackageItem.ItemType:
-                        itm = PackageItem(x=x, y=y, scene=self.scene())
+                        itm = PackageItem(x=x, y=y, scene=self.scene(),
+                                          colors=self.getDrawingColors())
                     itm.setId(itemId)
                     umlItems[itemId] = itm
                     if not itm.parseItemDataString(version, itemData):
--- a/eric6/Graphics/UMLItem.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Graphics/UMLItem.py	Sun Apr 12 18:40:37 2020 +0200
@@ -9,6 +9,7 @@
 
 
 from PyQt5.QtCore import Qt, QSizeF
+from PyQt5.QtGui import QColor, QPen
 from PyQt5.QtWidgets import QGraphicsItem, QGraphicsRectItem, QStyle
 
 import Preferences
@@ -41,19 +42,33 @@
     """
     ItemType = "UMLItem"
     
-    def __init__(self, model=None, x=0, y=0, rounded=False, parent=None):
+    def __init__(self, model=None, x=0, y=0, rounded=False, colors=None,
+                 parent=None):
         """
         Constructor
         
-        @param model UML model containing the item data (UMLModel)
-        @param x x-coordinate (integer)
-        @param y y-coordinate (integer)
-        @param rounded flag indicating a rounded corner (boolean)
-        @keyparam parent reference to the parent object (QGraphicsItem)
+        @param model UML model containing the item data
+        @type UMLModel
+        @param x x-coordinate
+        @type int
+        @param y y-coordinate
+        @type int
+        @param rounded flag indicating a rounded corner
+        @type bool
+        @param colors tuple containing the foreground and background colors
+        @type tuple of (QColor, QColor)
+        @param parent reference to the parent object
+        @type QGraphicsItem
         """
         super(UMLItem, self).__init__(parent)
         self.model = model
         
+        if colors is None:
+            self._colors = (QColor(Qt.black), QColor(Qt.white))
+        else:
+            self._colors = colors
+        self.setPen(QPen(self._colors[0]))
+        
         # TODO: set pen according to user selected color
         self.font = Preferences.getGraphics("Font")
         self.margin = 5
--- a/eric6/Preferences/ConfigurationPages/GraphicsPage.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/GraphicsPage.py	Sun Apr 12 18:40:37 2020 +0200
@@ -32,12 +32,29 @@
         self.graphicsFont = Preferences.getGraphics("Font")
         self.graphicsFontSample.setFont(self.graphicsFont)
         
+        drawingMode = Preferences.getGraphics("DrawingMode")
+        if drawingMode == "black_white":
+            self.blackWhiteButton.setChecked(True)
+        elif drawingMode == "white_black":
+            self.whiteBlackButton.setChecked(True)
+        else:
+            self.automaticButton.setChecked(True)
+    
     def save(self):
         """
         Public slot to save the Printer configuration.
         """
         Preferences.setGraphics("Font", self.graphicsFont)
         
+        if self.blackWhiteButton.isChecked():
+            drawingMode = "black_white"
+        elif self.whiteBlackButton.isChecked():
+            drawingMode = "white_black"
+        else:
+            # default is automatic
+            drawingMode = "automatic"
+        Preferences.setGraphics("DrawingMode", drawingMode)
+    
     @pyqtSlot()
     def on_graphicsFontButton_clicked(self):
         """
--- a/eric6/Preferences/ConfigurationPages/GraphicsPage.ui	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Preferences/ConfigurationPages/GraphicsPage.ui	Sun Apr 12 18:40:37 2020 +0200
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>GraphicsPage</class>
- <widget class="QWidget" name="GraphicsPage" >
-  <property name="geometry" >
+ <widget class="QWidget" name="GraphicsPage">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,63 +10,123 @@
     <height>334</height>
    </rect>
   </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <widget class="QLabel" name="headerLabel" >
-     <property name="text" >
-      <string>&lt;b>Configure graphics settings&lt;/b></string>
+    <widget class="QLabel" name="headerLabel">
+     <property name="text">
+      <string>&lt;b&gt;Configure graphics settings&lt;/b&gt;</string>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="Line" name="line7" >
-     <property name="frameShape" >
+    <widget class="Line" name="line7">
+     <property name="frameShape">
       <enum>QFrame::HLine</enum>
      </property>
-     <property name="frameShadow" >
+     <property name="frameShadow">
       <enum>QFrame::Sunken</enum>
      </property>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" >
-     <item>
-      <widget class="QPushButton" name="graphicsFontButton" >
-       <property name="toolTip" >
-        <string>Press to select the font for the graphic items</string>
-       </property>
-       <property name="text" >
-        <string>Graphics Font</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QLineEdit" name="graphicsFontSample" >
-       <property name="focusPolicy" >
-        <enum>Qt::NoFocus</enum>
-       </property>
-       <property name="text" >
-        <string>Graphics Font</string>
-       </property>
-       <property name="alignment" >
-        <set>Qt::AlignHCenter</set>
-       </property>
-       <property name="readOnly" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Font</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <widget class="QPushButton" name="graphicsFontButton">
+        <property name="toolTip">
+         <string>Press to select the font for the graphic items</string>
+        </property>
+        <property name="text">
+         <string>Graphics Font</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLineEdit" name="graphicsFontSample">
+        <property name="focusPolicy">
+         <enum>Qt::NoFocus</enum>
+        </property>
+        <property name="text">
+         <string>Graphics Font</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignHCenter</set>
+        </property>
+        <property name="readOnly">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Drawing Mode</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <item>
+       <widget class="QRadioButton" name="automaticButton">
+        <property name="toolTip">
+         <string>Select to determine the drawing mode automatically</string>
+        </property>
+        <property name="text">
+         <string>Automatic</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="blackWhiteButton">
+        <property name="toolTip">
+         <string>Select to draw black shapes on a white background</string>
+        </property>
+        <property name="text">
+         <string>Black On White</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="whiteBlackButton">
+        <property name="toolTip">
+         <string>Select to draw white shapes on a black background</string>
+        </property>
+        <property name="text">
+         <string>White On Black</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <spacer name="horizontalSpacer">
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>53</width>
+          <height>20</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
+     </layout>
+    </widget>
    </item>
    <item>
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
@@ -77,6 +138,8 @@
  </widget>
  <tabstops>
   <tabstop>graphicsFontButton</tabstop>
+  <tabstop>blackWhiteButton</tabstop>
+  <tabstop>whiteBlackButton</tabstop>
  </tabstops>
  <resources/>
  <connections/>
--- a/eric6/Preferences/__init__.py	Sun Apr 12 15:03:27 2020 +0200
+++ b/eric6/Preferences/__init__.py	Sun Apr 12 18:40:37 2020 +0200
@@ -1318,7 +1318,11 @@
     
     # defaults for the printer settings
     graphicsDefaults = {
-        "Font": "SansSerif,10,-1,5,50,0,0,0,0,0"
+        "Font": "SansSerif,10,-1,5,50,0,0,0,0,0",
+        "DrawingMode": "automatic",
+        # automatic - determine mode depending upon desktop scheme
+        # black_white - black items on white background
+        # white_black - white items on black background
     }
     
     # defaults for the icon editor

eric ide

mercurial