Add option for users to change text color and size for the nodes and links.
This commit is contained in:
@@ -28,7 +28,12 @@ class WorkspaceWidget(QtWidgets.QWidget):
|
||||
messageHandler,
|
||||
urlManager,
|
||||
entityDB,
|
||||
resourceHandler):
|
||||
resourceHandler,
|
||||
entityTextFont,
|
||||
entityTextBrush,
|
||||
linkTextFont,
|
||||
linkTextBrush):
|
||||
|
||||
super(WorkspaceWidget, self).__init__(parent=mainWindow)
|
||||
|
||||
self.mainWindow = mainWindow
|
||||
@@ -42,6 +47,10 @@ class WorkspaceWidget(QtWidgets.QWidget):
|
||||
urlManager,
|
||||
entityDB,
|
||||
resourceHandler,
|
||||
entityTextFont,
|
||||
entityTextBrush,
|
||||
linkTextFont,
|
||||
linkTextBrush,
|
||||
mainWindow)
|
||||
|
||||
self.docAndCanvasLayout.addWidget(self.tabbedPane, 0, 1)
|
||||
@@ -154,6 +163,10 @@ class TabbedPane(QtWidgets.QTabWidget):
|
||||
urlManager,
|
||||
entityDB,
|
||||
resourceHandler,
|
||||
entityTextFont,
|
||||
entityTextBrush,
|
||||
linkTextFont,
|
||||
linkTextBrush,
|
||||
mainWindow):
|
||||
|
||||
super(TabbedPane, self).__init__(parent)
|
||||
@@ -161,6 +174,10 @@ class TabbedPane(QtWidgets.QTabWidget):
|
||||
self.urlManager = urlManager
|
||||
self.entityDB = entityDB
|
||||
self.resourceHandler = resourceHandler
|
||||
self.entityTextFont = entityTextFont
|
||||
self.entityTextBrush = entityTextBrush
|
||||
self.linkTextFont = linkTextFont
|
||||
self.linkTextBrush = linkTextBrush
|
||||
self.mainWindow = mainWindow
|
||||
|
||||
self.setAcceptDrops(True)
|
||||
@@ -174,7 +191,8 @@ class TabbedPane(QtWidgets.QTabWidget):
|
||||
def addCanvas(self, canvasName='New Graph', graph=None, positions=None, a=0, b=0, c=0, d=0) -> bool:
|
||||
if not self.isCanvasNameAvailable(canvasName):
|
||||
return False
|
||||
scene = CanvasScene(self, graph, positions, a, b, c, d, canvasName)
|
||||
scene = CanvasScene(self, graph, positions, a, b, c, d, canvasName,
|
||||
self.entityTextFont, self.entityTextBrush, self.linkTextFont, self.linkTextBrush)
|
||||
view = CanvasView(self,
|
||||
scene,
|
||||
canvasName,
|
||||
@@ -459,7 +477,8 @@ class TabbedPane(QtWidgets.QTabWidget):
|
||||
nodePrimaryAttribute = nodeJSON.get(list(nodeJSON)[1])
|
||||
except IndexError:
|
||||
nodePrimaryAttribute = ''
|
||||
newNode = Entity.BaseNode(picture, uid, nodePrimaryAttribute)
|
||||
newNode = Entity.BaseNode(picture, uid, nodePrimaryAttribute, self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
scene.addNodeToScene(newNode)
|
||||
scene.addLinkDragDrop(scene.nodesDict[parentUID], newNode, newLink[2])
|
||||
|
||||
@@ -1038,7 +1057,8 @@ class CanvasView(QtWidgets.QGraphicsView):
|
||||
|
||||
class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
|
||||
def __init__(self, parent, graph=None, positions=None, a=0, b=0, c=0, d=0, canvasName: str = 'New Canvas') -> None:
|
||||
def __init__(self, parent, graph=None, positions=None, a=0, b=0, c=0, d=0, canvasName: str = 'New Canvas',
|
||||
entityTextFont=None, entityTextBrush=None, linkTextFont=None, linkTextBrush=None) -> None:
|
||||
super(CanvasScene, self).__init__(a, b, c, d, parent)
|
||||
self.itemsToLink = []
|
||||
self.linking = False
|
||||
@@ -1046,6 +1066,10 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
self.appendingToGroup = False
|
||||
self.sceneGraph = graph
|
||||
self.scenePos = positions
|
||||
self.entityTextFont = entityTextFont
|
||||
self.entityTextBrush = entityTextBrush
|
||||
self.linkTextFont = linkTextFont
|
||||
self.linkTextBrush = linkTextBrush
|
||||
|
||||
# All the nodes on the canvas. Easier than looping through self.items().
|
||||
self.nodesDict = {}
|
||||
@@ -1063,6 +1087,23 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
self.selectionChanged.connect(self.selectionChangeUpdater)
|
||||
self.resolutionThreadingLock = threading.Lock()
|
||||
|
||||
def updateNodeGraphics(self, entityTextFont, entityTextBrush, linkTextFont, linkTextBrush) -> None:
|
||||
self.entityTextFont = entityTextFont
|
||||
self.entityTextBrush = entityTextBrush
|
||||
self.linkTextFont = linkTextFont
|
||||
self.linkTextBrush = linkTextBrush
|
||||
for item in self.items():
|
||||
if isinstance(item, Entity.BaseNode):
|
||||
item.labelItem.setFont(self.entityTextFont)
|
||||
item.labelItem.setBrush(self.entityTextBrush)
|
||||
# Re-Center the Label
|
||||
item.updateLabel(item.labelItem.text())
|
||||
elif isinstance(item, Entity.BaseConnector):
|
||||
item.labelItem.setFont(self.linkTextFont)
|
||||
item.labelItem.setBrush(self.linkTextBrush)
|
||||
# Re-Center the Label
|
||||
item.updateLabel(item.labelItem.text())
|
||||
|
||||
# Redefined so that the BaseConnector items are not considered.
|
||||
def itemsBoundingRect(self) -> QtCore.QRectF:
|
||||
try:
|
||||
@@ -1073,10 +1114,10 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
itemsX.append(item.pos().x())
|
||||
itemsY.append(item.pos().y())
|
||||
|
||||
minX = min(itemsX) - 210
|
||||
minY = min(itemsY) - 110
|
||||
width = max(itemsX) - minX + 260
|
||||
height = max(itemsY) - minY + 110
|
||||
minX = min(itemsX) - (21 * self.entityTextFont.pointSize())
|
||||
minY = min(itemsY) - 100 - self.entityTextFont.pointSize()
|
||||
width = max(itemsX) - minX + (24 * self.entityTextFont.pointSize())
|
||||
height = max(itemsY) - minY + 100 + self.entityTextFont.pointSize()
|
||||
|
||||
return QtCore.QRectF(minX, minY, width, height)
|
||||
except ValueError:
|
||||
@@ -1224,10 +1265,12 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
nodePrimaryAttribute = ''
|
||||
|
||||
if groupItems is None:
|
||||
newNode = Entity.BaseNode(picture, node, nodePrimaryAttribute)
|
||||
newNode = Entity.BaseNode(picture, node, nodePrimaryAttribute, self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
self.addNodeToScene(newNode)
|
||||
else:
|
||||
newNode = Entity.GroupNode(picture, node, nodePrimaryAttribute)
|
||||
newNode = Entity.GroupNode(picture, node, nodePrimaryAttribute, self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
self.addNodeToScene(newNode)
|
||||
|
||||
newGroupList = newNode.listWidget
|
||||
@@ -1276,7 +1319,8 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
# either a new one being created or an old one that was copied.
|
||||
groupItems = [uid for uid in entity['Child UIDs'] if uid not in self.sceneGraph.nodes]
|
||||
if len(groupItems) > 0:
|
||||
newNode = Entity.GroupNode(picture, uid, entity['Group Name'])
|
||||
newNode = Entity.GroupNode(picture, uid, entity['Group Name'], self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
self.addNodeToScene(newNode, x, y)
|
||||
|
||||
newGroupList = newNode.listWidget
|
||||
@@ -1288,7 +1332,8 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
elif entity.get('Entity Type'):
|
||||
if not fromServer:
|
||||
self.parent().mainWindow.sendLocalCanvasUpdateToServer(self.getSelfName(), uid)
|
||||
newNode = Entity.BaseNode(picture, uid, nodePrimaryAttribute)
|
||||
newNode = Entity.BaseNode(picture, uid, nodePrimaryAttribute, self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
self.addNodeToScene(newNode, x, y)
|
||||
|
||||
if newNode is not None:
|
||||
@@ -1319,12 +1364,14 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
nodePrimaryAttribute = entity.get(list(entity)[1])
|
||||
except IndexError:
|
||||
nodePrimaryAttribute = ''
|
||||
newNode = Entity.BaseNode(picture, uid, nodePrimaryAttribute)
|
||||
newNode = Entity.BaseNode(picture, uid, nodePrimaryAttribute, self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
self.addNodeToScene(newNode)
|
||||
else:
|
||||
groupItems = [uid for uid in groupItems if uid not in self.sceneGraph.nodes]
|
||||
if len(groupItems) > 0:
|
||||
newNode = Entity.GroupNode(picture, uid, entity['Group Name'])
|
||||
newNode = Entity.GroupNode(picture, uid, entity['Group Name'], self.entityTextFont,
|
||||
self.entityTextBrush)
|
||||
self.addNodeToScene(newNode)
|
||||
|
||||
newGroupList = newNode.listWidget
|
||||
@@ -1518,7 +1565,8 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
linkToEdit.uid.add(linkUID)
|
||||
else:
|
||||
self.sceneGraph.add_edge(origin.uid, destination.uid)
|
||||
self.addLinkToScene(Entity.BaseConnector(origin, destination, name))
|
||||
self.addLinkToScene(Entity.BaseConnector(origin, destination, name, font=self.linkTextFont,
|
||||
brush=self.linkTextBrush))
|
||||
|
||||
if not fromServer:
|
||||
self.parent().mainWindow.sendLocalCanvasUpdateToServer(self.getSelfName(), linkUID)
|
||||
@@ -1541,7 +1589,8 @@ class CanvasScene(QtWidgets.QGraphicsScene):
|
||||
linkToEdit.uid.add(uid)
|
||||
else:
|
||||
self.sceneGraph.add_edge(uid[0], uid[1])
|
||||
self.addLinkToScene(Entity.BaseConnector(parentItem, childItem, name, uid))
|
||||
self.addLinkToScene(Entity.BaseConnector(parentItem, childItem, name, uid, font=self.linkTextFont,
|
||||
brush=self.linkTextBrush))
|
||||
|
||||
if not fromServer:
|
||||
self.parent().mainWindow.sendLocalCanvasUpdateToServer(self.getSelfName(), uid)
|
||||
|
||||
@@ -9,12 +9,14 @@ from PySide6.QtWidgets import QGraphicsItem
|
||||
from PySide6.QtWidgets import QGraphicsItemGroup, QGraphicsSimpleTextItem, QGraphicsPixmapItem
|
||||
from PySide6.QtSvgWidgets import QGraphicsSvgItem
|
||||
|
||||
TEXTFONT = QtGui.QFont("Mono", 11, 700)
|
||||
ENTITY_TEXT_FONT = QtGui.QFont("Mono", 11, 700)
|
||||
LINK_TEXT_FONT = QtGui.QFont("Mono", 11, 700)
|
||||
|
||||
|
||||
class BaseNode(QGraphicsItemGroup):
|
||||
|
||||
def __init__(self, pictureByteArray: QtCore.QByteArray, uid, primaryAttribute: str) -> None:
|
||||
def __init__(self, pictureByteArray: QtCore.QByteArray, uid, primaryAttribute: str, font: QtGui.QFont,
|
||||
brush: QtGui.QBrush) -> None:
|
||||
super(BaseNode, self).__init__()
|
||||
|
||||
self.setCacheMode(self.DeviceCoordinateCache)
|
||||
@@ -34,7 +36,12 @@ class BaseNode(QGraphicsItemGroup):
|
||||
self.labelItem = QGraphicsSimpleTextItem('')
|
||||
self.addToGroup(self.iconItem)
|
||||
self.addToGroup(self.labelItem)
|
||||
self.labelItem.setFont(TEXTFONT)
|
||||
if font is not None:
|
||||
self.labelItem.setFont(font)
|
||||
else:
|
||||
self.labelItem.setFont(ENTITY_TEXT_FONT)
|
||||
if brush is not None:
|
||||
self.labelItem.setBrush(brush)
|
||||
|
||||
self.updateLabel(primaryAttribute)
|
||||
|
||||
@@ -115,8 +122,8 @@ class BaseNode(QGraphicsItemGroup):
|
||||
class GroupNode(BaseNode):
|
||||
|
||||
# childNodes is a list of tuples, uid and picture, of all the nodes in the group.
|
||||
def __init__(self, pictureByteArray, uid: str, label: str = 'Entity Group') -> None:
|
||||
super(GroupNode, self).__init__(pictureByteArray, uid, label)
|
||||
def __init__(self, pictureByteArray, uid: str, label: str = 'Entity Group', font=None, brush=None) -> None:
|
||||
super(GroupNode, self).__init__(pictureByteArray, uid, label, font, brush)
|
||||
self.groupedNodesConnectors = []
|
||||
self.itemsThatWereGrouped = []
|
||||
self.groupedNodesUid = set()
|
||||
@@ -190,7 +197,8 @@ class GroupNode(BaseNode):
|
||||
# Ref: https://github.com/PySide/Examples/blob/master/examples/graphicsview/diagramscene/diagramscene.py
|
||||
class BaseConnector(QGraphicsItemGroup):
|
||||
|
||||
def __init__(self, origin, destination, name: str = 'None', uid=None, parent=None) -> None:
|
||||
def __init__(self, origin, destination, name: str = 'None', uid=None, parent=None,
|
||||
font: QtGui.QFont = None, brush: QtGui.QBrush = None) -> None:
|
||||
super(BaseConnector, self).__init__(parent)
|
||||
|
||||
self.myStartItem = origin
|
||||
@@ -198,7 +206,12 @@ class BaseConnector(QGraphicsItemGroup):
|
||||
|
||||
self.labelItem = QGraphicsSimpleTextItem('')
|
||||
self.addToGroup(self.labelItem)
|
||||
self.labelItem.setFont(TEXTFONT)
|
||||
if font is not None:
|
||||
self.labelItem.setFont(font)
|
||||
else:
|
||||
self.labelItem.setFont(LINK_TEXT_FONT)
|
||||
if brush is not None:
|
||||
self.labelItem.setBrush(brush)
|
||||
|
||||
self.updateLabel(name)
|
||||
|
||||
|
||||
@@ -124,10 +124,16 @@ class MenuBar(QtWidgets.QMenuBar):
|
||||
statusTip="Edit Program Settings",
|
||||
triggered=self.editProgramSettings)
|
||||
|
||||
editGraphics = QtGui.QAction('Graphics Settings',
|
||||
self,
|
||||
statusTip="Edit Graphics Settings",
|
||||
triggered=self.editGraphicsSettings)
|
||||
|
||||
editSettingsMenu.addAction(editLog)
|
||||
editSettingsMenu.addAction(editResolution)
|
||||
editSettingsMenu.addAction(editProject)
|
||||
editSettingsMenu.addAction(editProgram)
|
||||
editSettingsMenu.addAction(editGraphics)
|
||||
|
||||
exitAction = QtGui.QAction("Exit",
|
||||
self,
|
||||
@@ -728,6 +734,9 @@ class MenuBar(QtWidgets.QMenuBar):
|
||||
def editProgramSettings(self) -> None:
|
||||
self.parent().editProgramSettings()
|
||||
|
||||
def editGraphicsSettings(self) -> None:
|
||||
self.parent().changeGraphics()
|
||||
|
||||
def editResolutionsSettings(self) -> None:
|
||||
self.parent().editResolutionsSettings()
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ class ResourceHandler:
|
||||
"Resources" / "Icons" / "DrawLink.png"),
|
||||
"rearrange": str(Path(self.mainWindow.SETTINGS.value("Program/BaseDir")) /
|
||||
"Resources" / "Icons" / "RearrangeGraph.png"),
|
||||
"colorPicker": str(Path(self.mainWindow.SETTINGS.value("Program/BaseDir")) /
|
||||
"Resources" / "Icons" / "ColorPicker.png"),
|
||||
}
|
||||
# These are not meant to be strict - just restrictive enough such that users don't put in utter nonsense.
|
||||
# Note that regex isn't always the best way of validating fields, but it should be good enough for our
|
||||
|
||||
@@ -23,6 +23,14 @@ class SettingsObject(dict):
|
||||
super().__init__()
|
||||
self.setValue("Program/BaseDir", "Unset") # dirname(abspath(getsourcefile(lambda:0))) + "/../" )
|
||||
self.setValue("Program/GraphLayout", "dot")
|
||||
self.setValue("Program/EntityTextFontType", "Mono")
|
||||
self.setValue("Program/EntityTextFontSize", "11")
|
||||
self.setValue("Program/EntityTextFontBoldness", "700")
|
||||
self.setValue("Program/LinkTextFontType", "Mono")
|
||||
self.setValue("Program/LinkTextFontSize", "11")
|
||||
self.setValue("Program/LinkTextFontBoldness", "700")
|
||||
self.setValue("Program/EntityTextColor", "#000000") # RGB
|
||||
self.setValue("Program/LinkTextColor", "#000000") # RGB
|
||||
self.setValue("Project/Name", "Untitled")
|
||||
self.setValue("Project/BaseDir", "")
|
||||
self.setValue("Project/FilesDir", "")
|
||||
|
||||
194
LinkScope.py
194
LinkScope.py
@@ -38,7 +38,6 @@ from Core.PathHelper import is_path_exists_or_creatable_portable
|
||||
|
||||
# Main Window of Application
|
||||
class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
facilitateResolutionSignalListener = QtCore.Signal(str, list)
|
||||
|
||||
# Redefining the function to adjust its signature.
|
||||
@@ -818,6 +817,43 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
self.saveProject()
|
||||
|
||||
def changeGraphics(self):
|
||||
settingsDialog = GraphicsEditDialog(self.SETTINGS, self.RESOURCEHANDLER)
|
||||
settingsConfirm = settingsDialog.exec()
|
||||
|
||||
if settingsConfirm:
|
||||
newSettings = settingsDialog.newSettings
|
||||
try:
|
||||
etfVal = int(newSettings["ETF"])
|
||||
self.entityTextFont.setPointSize(etfVal)
|
||||
self.SETTINGS.setValue("Program/EntityTextFontSize", str(newSettings["ETF"]))
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
ltfVal = int(newSettings["LTF"])
|
||||
self.linkTextFont.setPointSize(ltfVal)
|
||||
self.SETTINGS.setValue("Program/LinkTextFontSize", str(newSettings["LTF"]))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
etcVal = newSettings["ETC"]
|
||||
newEtcColor = QtGui.QColor(etcVal)
|
||||
if newEtcColor.isValid():
|
||||
self.entityTextBrush.setColor(newEtcColor)
|
||||
self.SETTINGS.setValue("Program/EntityTextColor", newEtcColor.name())
|
||||
ltcVal = newSettings["LTC"]
|
||||
newLtcColor = QtGui.QColor(ltcVal)
|
||||
if newLtcColor.isValid():
|
||||
self.linkTextBrush.setColor(newLtcColor)
|
||||
self.SETTINGS.setValue("Program/LinkTextColor", newLtcColor.name())
|
||||
|
||||
for viewKey in self.centralWidget().tabbedPane.canvasTabs:
|
||||
scene = self.centralWidget().tabbedPane.canvasTabs[viewKey].scene()
|
||||
scene.updateNodeGraphics(self.entityTextFont, self.entityTextBrush, self.linkTextFont,
|
||||
self.linkTextBrush)
|
||||
|
||||
self.saveProject()
|
||||
|
||||
def loadModules(self) -> None:
|
||||
"""
|
||||
Loads user-defined modules from the Modules folder in the installation directory.
|
||||
@@ -1697,11 +1733,25 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.RESOLUTIONMANAGER.loadResolutionsFromDir(
|
||||
Path(self.SETTINGS.value("Program/BaseDir")) / "Core" / "Resolutions" / "Core")
|
||||
|
||||
self.entityTextFont = QtGui.QFont(self.SETTINGS.value("Program/EntityTextFontType"),
|
||||
int(self.SETTINGS.value("Program/EntityTextFontSize")),
|
||||
int(self.SETTINGS.value("Program/EntityTextFontBoldness")))
|
||||
self.entityTextBrush = QtGui.QBrush(self.SETTINGS.value("Program/EntityTextColor"))
|
||||
self.linkTextFont = QtGui.QFont(self.SETTINGS.value("Program/LinkTextFontType"),
|
||||
int(self.SETTINGS.value("Program/LinkTextFontSize")),
|
||||
int(self.SETTINGS.value("Program/LinkTextFontBoldness")))
|
||||
self.linkTextBrush = QtGui.QBrush(self.SETTINGS.value("Program/LinkTextColor"))
|
||||
|
||||
self.setCentralWidget(CentralPane.WorkspaceWidget(self,
|
||||
self.MESSAGEHANDLER,
|
||||
self.URLMANAGER,
|
||||
self.LENTDB,
|
||||
self.RESOURCEHANDLER))
|
||||
self.RESOURCEHANDLER,
|
||||
self.entityTextFont,
|
||||
self.entityTextBrush,
|
||||
self.linkTextFont,
|
||||
self.linkTextBrush))
|
||||
|
||||
self.facilitateResolutionSignalListener.connect(self.centralWidget().tabbedPane.facilitateResolution)
|
||||
|
||||
self.loadModules()
|
||||
@@ -2575,6 +2625,132 @@ class MultiChoicePropertyInput(QtWidgets.QGroupBox):
|
||||
return valuesSelected
|
||||
|
||||
|
||||
class GraphicsEditDialog(QtWidgets.QDialog):
|
||||
|
||||
def __init__(self, settingsObject, resourceHandler):
|
||||
super(GraphicsEditDialog, self).__init__()
|
||||
|
||||
self.setModal(True)
|
||||
self.setMaximumWidth(850)
|
||||
self.setMinimumWidth(600)
|
||||
self.setMaximumHeight(600)
|
||||
self.setMinimumHeight(400)
|
||||
self.settings = settingsObject
|
||||
self.setStyleSheet(Stylesheets.MAIN_WINDOW_STYLESHEET)
|
||||
|
||||
editDialogLayout = QtWidgets.QGridLayout()
|
||||
self.setLayout(editDialogLayout)
|
||||
scrollArea = QtWidgets.QScrollArea()
|
||||
scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
|
||||
scrollArea.setWidgetResizable(True)
|
||||
scrollContainer = QtWidgets.QWidget()
|
||||
scrollLayout = QtWidgets.QVBoxLayout()
|
||||
scrollContainer.setLayout(scrollLayout)
|
||||
scrollArea.setWidget(scrollContainer)
|
||||
editDialogLayout.addWidget(scrollArea, 0, 0, 2, 2)
|
||||
|
||||
resolutionCategoryWidget = QtWidgets.QWidget()
|
||||
self.resolutionCategoryLayout = SettingsCategoryLayout(supportsDeletion=False)
|
||||
resolutionCategoryWidget.setLayout(self.resolutionCategoryLayout)
|
||||
resolutionCategoryLabel = QtWidgets.QLabel('Graphics Settings')
|
||||
|
||||
resolutionCategoryLabel.setFont(QtGui.QFont("Times", 13, QtGui.QFont.Bold))
|
||||
resolutionCategoryLabel.setFrameStyle(QtWidgets.QFrame.Raised | QtWidgets.QFrame.Panel)
|
||||
|
||||
resolutionCategoryLabel.setAlignment(QtCore.Qt.AlignCenter)
|
||||
scrollLayout.addWidget(resolutionCategoryLabel)
|
||||
scrollLayout.addWidget(resolutionCategoryWidget)
|
||||
|
||||
confirmButton = QtWidgets.QPushButton('Confirm')
|
||||
confirmButton.setStyleSheet(Stylesheets.BUTTON_STYLESHEET_2)
|
||||
confirmButton.clicked.connect(self.accept)
|
||||
editDialogLayout.addWidget(confirmButton, 2, 1, 1, 1)
|
||||
cancelButton = QtWidgets.QPushButton('Cancel')
|
||||
cancelButton.setStyleSheet(Stylesheets.BUTTON_STYLESHEET_2)
|
||||
cancelButton.clicked.connect(self.reject)
|
||||
editDialogLayout.addWidget(cancelButton, 2, 0, 1, 1)
|
||||
|
||||
self.settingsTextboxes = []
|
||||
self.settingsValueTextboxes = []
|
||||
self.newSettings = {}
|
||||
|
||||
etfSettingTextbox = SettingsIntegerEditTextBox(int(self.settings.value("Program/EntityTextFontSize")), "ETF",
|
||||
50, 5)
|
||||
etfSettingTextbox.setStyleSheet(Stylesheets.TEXT_BOX_STYLESHEET)
|
||||
self.settingsValueTextboxes.append(etfSettingTextbox)
|
||||
self.resolutionCategoryLayout.addRow("Entity Text Font Size", etfSettingTextbox)
|
||||
|
||||
ltfSettingTextbox = SettingsIntegerEditTextBox(int(self.settings.value("Program/LinkTextFontSize")), "LTF",
|
||||
50, 5)
|
||||
ltfSettingTextbox.setStyleSheet(Stylesheets.TEXT_BOX_STYLESHEET)
|
||||
self.settingsValueTextboxes.append(ltfSettingTextbox)
|
||||
self.resolutionCategoryLayout.addRow("Link Text Font Size", ltfSettingTextbox)
|
||||
|
||||
self.colorPicker = QtWidgets.QColorDialog()
|
||||
self.colorPicker.setStyleSheet(Stylesheets.MAIN_WINDOW_STYLESHEET)
|
||||
self.colorPicker.setOption(QtWidgets.QColorDialog.DontUseNativeDialog, True)
|
||||
|
||||
etcSettingWidget = QtWidgets.QWidget()
|
||||
etcSettingLayout = QtWidgets.QHBoxLayout()
|
||||
etcSettingWidget.setLayout(etcSettingLayout)
|
||||
|
||||
etcSettingTextbox = SettingsEditTextBox(self.settings.value("Program/EntityTextColor"), "ETC")
|
||||
etcSettingTextbox.setReadOnly(True)
|
||||
etcSettingTextbox.setStyleSheet(Stylesheets.TEXT_BOX_STYLESHEET)
|
||||
etcSettingLayout.addWidget(etcSettingTextbox, 5)
|
||||
|
||||
etcSettingPalettePrompt = QtWidgets.QPushButton(QtGui.QIcon(resourceHandler.getIcon("colorPicker")),
|
||||
"Pick Colour")
|
||||
etcSettingPalettePrompt.clicked.connect(self.runEntityColorPicker)
|
||||
etcSettingLayout.addWidget(etcSettingPalettePrompt)
|
||||
|
||||
self.settingsTextboxes.append(etcSettingTextbox)
|
||||
self.resolutionCategoryLayout.addRow("Entity Text Color", etcSettingWidget)
|
||||
|
||||
ltcSettingWidget = QtWidgets.QWidget()
|
||||
ltcSettingLayout = QtWidgets.QHBoxLayout()
|
||||
ltcSettingWidget.setLayout(ltcSettingLayout)
|
||||
|
||||
ltcSettingTextbox = SettingsEditTextBox(self.settings.value("Program/LinkTextColor"), "LTC")
|
||||
ltcSettingTextbox.setReadOnly(True)
|
||||
ltcSettingTextbox.setStyleSheet(Stylesheets.TEXT_BOX_STYLESHEET)
|
||||
ltcSettingLayout.addWidget(ltcSettingTextbox, 5)
|
||||
|
||||
ltcSettingPalettePrompt = QtWidgets.QPushButton(QtGui.QIcon(resourceHandler.getIcon("colorPicker")),
|
||||
"Pick Colour")
|
||||
ltcSettingPalettePrompt.clicked.connect(self.runLinkColorPicker)
|
||||
ltcSettingLayout.addWidget(ltcSettingPalettePrompt)
|
||||
|
||||
self.settingsTextboxes.append(ltcSettingTextbox)
|
||||
self.resolutionCategoryLayout.addRow("Link Text Color", ltcSettingWidget)
|
||||
|
||||
def runEntityColorPicker(self):
|
||||
color = self.colorPicker.getColor(QtGui.QColor(self.settings.value("Program/EntityTextColor")),
|
||||
title="Select New Entity Text Color")
|
||||
if color.isValid():
|
||||
self.settingsTextboxes[0].setText(color.name())
|
||||
|
||||
def runLinkColorPicker(self):
|
||||
color = self.colorPicker.getColor(QtGui.QColor(self.settings.value("Program/LinkTextColor")),
|
||||
title="Select New Link Text Color")
|
||||
if color.isValid():
|
||||
self.settingsTextboxes[1].setText(color.name())
|
||||
|
||||
def accept(self) -> None:
|
||||
# Cannot delete these values.
|
||||
for settingTextbox in self.settingsTextboxes:
|
||||
key = settingTextbox.settingsKey
|
||||
value = settingTextbox.text()
|
||||
self.newSettings[key] = value
|
||||
for settingsValueTextbox in self.settingsValueTextboxes:
|
||||
key = settingsValueTextbox.settingsKey
|
||||
value = settingsValueTextbox.value()
|
||||
self.newSettings[key] = value
|
||||
|
||||
super(GraphicsEditDialog, self).accept()
|
||||
|
||||
|
||||
class ProgramEditDialog(QtWidgets.QDialog):
|
||||
|
||||
def __init__(self, settingsObject):
|
||||
@@ -2877,13 +3053,25 @@ class ProjectEditDialog(QtWidgets.QDialog):
|
||||
|
||||
class SettingsEditTextBox(QtWidgets.QLineEdit):
|
||||
|
||||
def __init__(self, contents, settingsKey):
|
||||
def __init__(self, contents: str, settingsKey: str):
|
||||
super(SettingsEditTextBox, self).__init__(str(contents))
|
||||
self.settingsKey = settingsKey
|
||||
self.keyDeleted = False
|
||||
self.setToolTip("Edit the contents to change the setting's value.")
|
||||
|
||||
|
||||
class SettingsIntegerEditTextBox(QtWidgets.QSpinBox):
|
||||
|
||||
def __init__(self, contents: int, settingsKey: str, maxVal: int, minVal: int):
|
||||
super(SettingsIntegerEditTextBox, self).__init__()
|
||||
self.setMaximum(maxVal)
|
||||
self.setMinimum(minVal)
|
||||
self.setValue(contents)
|
||||
self.settingsKey = settingsKey
|
||||
self.keyDeleted = False
|
||||
self.setToolTip("Edit the contents to change the setting's value.")
|
||||
|
||||
|
||||
class SettingsEditSingleChoice(QtWidgets.QWidget):
|
||||
|
||||
def __init__(self, contents, currentSettingValue, settingsKey):
|
||||
|
||||
BIN
Resources/Icons/ColorPicker.png
Normal file
BIN
Resources/Icons/ColorPicker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Reference in New Issue
Block a user