Continue working on macros.

This commit is contained in:
AccentuSoft
2022-07-31 23:54:14 +03:00
parent 312c6a87c6
commit 58fa19fdfd
2 changed files with 67 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import importlib
import sys import sys
from os import listdir from os import listdir
from pathlib import Path from pathlib import Path
from uuid import uuid4
from typing import Union from typing import Union
@@ -14,6 +15,8 @@ class ResolutionManager:
self.messageHandler = messageHandler self.messageHandler = messageHandler
self.mainWindow = mainWindow self.mainWindow = mainWindow
self.resolutions = {} self.resolutions = {}
# Macro dict item contents: tuple of (category, resolution name)
self.macros = {}
def loadResolutionsFromDir(self, directory: Path) -> None: def loadResolutionsFromDir(self, directory: Path) -> None:
exceptionsCount = 0 exceptionsCount = 0
@@ -145,3 +148,9 @@ class ResolutionManager:
resolutionClass = self.resolutions[category][resolution]['resolution']() resolutionClass = self.resolutions[category][resolution]['resolution']()
result = resolutionClass.resolution(resolutionEntitiesInput, parameters) result = resolutionClass.resolution(resolutionEntitiesInput, parameters)
return result return result
def createMacro(self, resolutionList: list) -> str:
macroUID = str(uuid4())
self.macros[macroUID] = resolutionList
return macroUID

View File

@@ -1227,6 +1227,11 @@ class MainWindow(QtWidgets.QMainWindow):
resolutionThread[0].deleteLater() resolutionThread[0].deleteLater()
self.resolutions.remove(resolutionThread) self.resolutions.remove(resolutionThread)
def showMacrosDialog(self) -> None:
macrosDialog = MacroDialog(self)
if macrosDialog.exec():
pass
def getClientCollectors(self) -> dict: def getClientCollectors(self) -> dict:
with self.serverCollectorsLock: with self.serverCollectorsLock:
try: try:
@@ -4510,9 +4515,61 @@ class MacroDialog(QtWidgets.QDialog):
def __init__(self, mainWindowObject: MainWindow): def __init__(self, mainWindowObject: MainWindow):
super(MacroDialog, self).__init__() super(MacroDialog, self).__init__()
self.setModal(True) self.setModal(True)
self.setStyleSheet(Stylesheets.MAIN_WINDOW_STYLESHEET)
currentScene = mainWindowObject.centralWidget().tabbedPane.getCurrentScene()
canvasName = currentScene.getSelfName()
endPoints = [item.uid for item in currentScene.selectedItems()
if isinstance(item, BaseNode)]
currentCanvasGraph = currentScene.sceneGraph
# allResolutions = mainWindowObject.RESOLUTIONMANAGER.getAllResolutions() - need categories too.
allMacros = mainWindowObject.RESOLUTIONMANAGER.macros
layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
macroLabel = QtWidgets.QLabel("This is a list of all currently configured Macros. Click on a Macro to view the " macroLabel = QtWidgets.QLabel("This is a list of all currently configured Macros. Click on a Macro to view the "
"resolutions included in it.") "Resolutions included in it.")
macroLabel.setWordWrap(True)
macroTree = QtWidgets.QTreeWidget(self) macroTree = QtWidgets.QTreeWidget(self)
macroTree.setSelectionMode(macroTree.SingleSelection)
macroTree.setSelectionBehavior(macroTree.SelectRows)
macroTree.setHeaderLabels(['Macro UID', 'Delete'])
for macro in allMacros:
newMacro = QtWidgets.QTreeWidgetItem()
macroTree.addTopLevelItem(newMacro)
newMacro.setText(0, macro)
newMacro.setText(1, 'DELETE BUTTON TODO')
for resolution in allMacros[macro]:
resolutionItem = QtWidgets.QTreeWidgetItem(newMacro)
resolutionItem.setText(0, resolution)
buttonsWidget = QtWidgets.QWidget()
buttonsWidgetLayout = QtWidgets.QHBoxLayout()
buttonsWidget.setLayout(buttonsWidgetLayout)
closeButton = QtWidgets.QPushButton('Close')
closeButton.clicked.connect(self.reject)
runSelectedButton = QtWidgets.QPushButton('Run Selected Macros')
runSelectedButton.clicked.connect(self.accept)
buttonsWidgetLayout.addWidget(closeButton)
buttonsWidgetLayout.addWidget(runSelectedButton)
layout.addWidget(macroLabel)
layout.addWidget(macroTree)
layout.addWidget(buttonsWidget)
def createMacro(self) -> None:
pass
def deleteMacro(self) -> None:
pass
def accept(self) -> None:
pass # TODO - run resolutions - function in main / thread?
super(MacroDialog, self).accept()
class ExtractCyclesThread(QtCore.QThread): class ExtractCyclesThread(QtCore.QThread):