aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/original.py3
-rw-r--r--components/text.py3
-rw-r--r--main.py18
3 files changed, 20 insertions, 4 deletions
diff --git a/components/original.py b/components/original.py
index 5655867..e543dac 100644
--- a/components/original.py
+++ b/components/original.py
@@ -34,6 +34,9 @@ class Component:
self.visColor = RGBFromString(self.page.lineEdit_visColor.text())
self.parent.drawPreview()
+ def version(self):
+ return 1
+
def savePreset(self):
return {}
diff --git a/components/text.py b/components/text.py
index e900994..334fc80 100644
--- a/components/text.py
+++ b/components/text.py
@@ -55,6 +55,9 @@ class Component:
self.page = page
return page
+ def version(self):
+ return 1
+
def update(self):
self.title = self.page.lineEdit_title.text()
self.alignment = self.page.comboBox_textAlign.currentIndex()
diff --git a/main.py b/main.py
index fe76e2c..5bb10f5 100644
--- a/main.py
+++ b/main.py
@@ -304,6 +304,7 @@ class Main(QtCore.QObject):
self.window.stackedWidget.addWidget(self.pages[-1])
self.window.stackedWidget.setCurrentIndex(index)
self.selectedComponents[-1].update()
+ self.updateOpenPresetComboBox(self.selectedComponents[-1])
def removeComponent(self):
for selected in self.window.listWidget_componentList.selectedItems():
@@ -318,6 +319,7 @@ class Main(QtCore.QObject):
selected = self.window.listWidget_componentList.selectedItems()
index = self.window.listWidget_componentList.row(selected[0])
self.window.stackedWidget.setCurrentIndex(index)
+ self.updateOpenPresetComboBox(self.selectedComponents[index])
def moveComponentUp(self):
row = self.window.listWidget_componentList.currentRow()
@@ -351,6 +353,16 @@ class Main(QtCore.QObject):
self.window.listWidget_componentList.setCurrentRow(row + 1)
self.window.stackedWidget.setCurrentIndex(row + 1)
+ def updateOpenPresetComboBox(self, component):
+ self.window.comboBox_openPreset.clear()
+ self.window.comboBox_openPreset.addItem("Open Preset")
+ destination = os.path.join(self.dataDir, 'presets',
+ str(component).strip(), str(component.version()))
+ if not os.path.exists(destination):
+ os.makedirs(destination)
+ for f in os.listdir(destination):
+ self.window.comboBox_openPreset.addItem(f)
+
def openSavePresetDialog(self):
if self.window.listWidget_componentList.currentRow() == -1:
return
@@ -360,10 +372,7 @@ class Main(QtCore.QObject):
if index != -1:
saveValueStore = self.selectedComponents[index].savePreset()
componentName = str(self.selectedComponents[index]).strip()
- if hasattr(self.selectedComponents[index], 'version'):
- vers = self.selectedComponents[index].version()
- else:
- vers = 1
+ vers = self.selectedComponents[index].version()
self.createPresetFile(componentName, vers, saveValueStore, newName)
def createPresetFile(self, componentName, version, saveValueStore, filename):
@@ -373,6 +382,7 @@ class Main(QtCore.QObject):
with open(os.path.join(dirname, filename), 'w') as f:
for itemset in saveValueStore.items():
f.write('%s=%s' % itemset)
+ self.window.comboBox_openPreset.addItem(filename)
def openPreset(self, comboBoxIndex):
pass