diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/python/main.py | 5 | ||||
-rw-r--r-- | src/main/python/utils/data.py | 317 | ||||
-rw-r--r-- | src/main/python/utils/funcs.py | 9 | ||||
-rw-r--r-- | src/main/python/utils/toolbar.py | 6 | ||||
-rw-r--r-- | src/main/resources/base/config/items.json | 1 | ||||
-rw-r--r-- | src/main/resources/base/config/paperSizes.json | 1 |
6 files changed, 22 insertions, 317 deletions
diff --git a/src/main/python/main.py b/src/main/python/main.py index 335e449..4bb5abd 100644 --- a/src/main/python/main.py +++ b/src/main/python/main.py @@ -62,9 +62,8 @@ class appWindow(QMainWindow): def updateMenuBar(self): # self.undo.setAction(self.activeScene.painter.undoAction) - self.undo.triggered(self.activeScene.painter.undoAction.trigger) - self.redo.triggered(self.activeScene.painter.redoAction.trigger) - # self.redo.setAction(self.activeScene.painter.redoAction) + self.undo.triggered.connect(self.activeScene.painter.undoAction.trigger()) + self.redo.triggered.connect(self.activeScene.painter.redoAction.trigger()) def createToolbar(self): #place holder for toolbar with fixed width, layout may change diff --git a/src/main/python/utils/data.py b/src/main/python/utils/data.py index 593cb1b..863e4c6 100644 --- a/src/main/python/utils/data.py +++ b/src/main/python/utils/data.py @@ -1,311 +1,14 @@ -paperSizes = { - "A0": { - "72": [2384, 3370], - "96": [3179, 4494], - "150": [4967, 7022], - "300": [9933, 14043] - }, - "A1": { - "72": [1684, 2384], - "96": [2245, 3179], - "150": [3508, 4967], - "300": [7016, 9933] - }, - "A2": { - "72": [1191, 1684], - "96": [1587, 2245], - "150": [2480, 3508], - "300": [4960, 7016] - }, - "A3": { - "72": [842, 1191], - "96": [1123, 1587], - "150": [1754, 2480], - "300": [3508, 4960] - }, - "A4": { - "72": [595, 842], - "96": [794, 1123], - "150": [1240, 1754], - "300": [2480, 3508] - } -} +import json +from .funcs import fileImporter -sheetDimensionList = [f'A{i}' for i in range(5)] +paperSizes = json.load(open(fileImporter("config/paperSizes.json"))) -ppiList = ["72", "96", "150", "300"] +sheetDimensionList = list(paperSizes.keys()) + +ppiList = paperSizes[sheetDimensionList[0]].keys() + +toolbarItems = json.load(open(fileImporter("config/items.json"))) + +defaultToolbarItems = toolbarItems.keys() -toolbarItems = { - 'Ellipse': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse2': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse3': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse4': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse5': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse6': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse7': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse8': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse9': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse11': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse12': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse13': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse14': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse15': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse16': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse17': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse18': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse19': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse20': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse21': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse22': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse23': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse24': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse25': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse26': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse27': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse28': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse29': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse30': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse31': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse32': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse33': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse34': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse35': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse36': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse37': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse38': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse39': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse40': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse41': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse42': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse43': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse44': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse45': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, - 'Ellipse46': { - 'name': 'Ellipse', - 'icon': 'ellipse.png', - 'object': 'QGraphicsEllipseItem', - 'args': [20, 20, 300, 300] - }, -} -defaultToolbarItems = toolbarItems.keys()
\ No newline at end of file diff --git a/src/main/python/utils/funcs.py b/src/main/python/utils/funcs.py index 7796ece..9f38554 100644 --- a/src/main/python/utils/funcs.py +++ b/src/main/python/utils/funcs.py @@ -1,5 +1,6 @@ -from itertools import zip_longest +from fbs_runtime.application_context.PyQt5 import ApplicationContext -def grouper(n, iterable, fillvalue=None): - args = [iter(iterable)] * n - return zip_longest(fillvalue=fillvalue, *args)
\ No newline at end of file +importTool = ApplicationContext() + +def fileImporter(file): + return importTool.get_resource(file)
\ No newline at end of file diff --git a/src/main/python/utils/toolbar.py b/src/main/python/utils/toolbar.py index ec3b6a8..8e1f8d2 100644 --- a/src/main/python/utils/toolbar.py +++ b/src/main/python/utils/toolbar.py @@ -6,10 +6,10 @@ from PyQt5.QtWidgets import (QBoxLayout, QDockWidget, QGridLayout, QLineEdit, from re import search, IGNORECASE from .data import toolbarItems -from .funcs import grouper +from .funcs import fileImporter from .layout import flowLayout -resourceManager = ApplicationContext() #Used to load images, mainly toolbar icons +# resourceManager = ApplicationContext() #Used to load images, mainly toolbar icons class toolbar(QDockWidget): """ @@ -103,7 +103,7 @@ class toolbarButton(QToolButton): def __init__(self, parent = None, item = None): super(toolbarButton, self).__init__(parent) #uses fbs resource manager to get icons - self.setIcon(QIcon(resourceManager.get_resource(f'toolbar/{item["icon"]}'))) + self.setIcon(QIcon(fileImporter(f'toolbar/{item["icon"]}'))) self.setIconSize(QSize(40, 40)) #unecessary but left for future references self.dragStartPosition = None #intialize value for drag event self.itemObject = item['object'] #refer current item object, to handle drag mime diff --git a/src/main/resources/base/config/items.json b/src/main/resources/base/config/items.json new file mode 100644 index 0000000..b286abd --- /dev/null +++ b/src/main/resources/base/config/items.json @@ -0,0 +1 @@ +{"Ellipse": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse2": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse3": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse4": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse5": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse6": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse7": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse8": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse9": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse11": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse12": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse13": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse14": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse15": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse16": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse17": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse18": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse19": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse20": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse21": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse22": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse23": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse24": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse25": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse26": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse27": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse28": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse29": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse30": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse31": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse32": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse33": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse34": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse35": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse36": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse37": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse38": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse39": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse40": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse41": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse42": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse43": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse44": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse45": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}, "Ellipse46": {"name": "Ellipse", "icon": "ellipse.png", "object": "QGraphicsEllipseItem", "args": [20, 20, 300, 300]}}
\ No newline at end of file diff --git a/src/main/resources/base/config/paperSizes.json b/src/main/resources/base/config/paperSizes.json new file mode 100644 index 0000000..670b657 --- /dev/null +++ b/src/main/resources/base/config/paperSizes.json @@ -0,0 +1 @@ +{"A0": {"72": [2384, 3370], "96": [3179, 4494], "150": [4967, 7022], "300": [9933, 14043]}, "A1": {"72": [1684, 2384], "96": [2245, 3179], "150": [3508, 4967], "300": [7016, 9933]}, "A2": {"72": [1191, 1684], "96": [1587, 2245], "150": [2480, 3508], "300": [4960, 7016]}, "A3": {"72": [842, 1191], "96": [1123, 1587], "150": [1754, 2480], "300": [3508, 4960]}, "A4": {"72": [595, 842], "96": [794, 1123], "150": [1240, 1754], "300": [2480, 3508]}}
\ No newline at end of file |