Doc settings recordeed as json, need now to be applied to scss
This commit is contained in:
+16
-3
@@ -12,7 +12,7 @@
|
||||
import os, shutil, tempfile
|
||||
# sys,
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtCore import QSettings
|
||||
from PyQt5.QtCore import QSettings, QCoreApplication
|
||||
|
||||
import json
|
||||
import git
|
||||
@@ -44,6 +44,7 @@ class Core():
|
||||
print('tail', tail)
|
||||
self.projectname = tail
|
||||
|
||||
self.loadDocSettings()
|
||||
|
||||
|
||||
def initDeamons(self):
|
||||
@@ -76,6 +77,17 @@ class Core():
|
||||
self.mw_pos = settings.value('mainwindow/pos', QtCore.QPoint(0, 0))
|
||||
self.mw_curstack = int(settings.value('mainwindow/curstack', 0))
|
||||
|
||||
def loadDocSettings(self):
|
||||
self.docsettings = json.loads(open(os.path.join(self.cwd,'.config/prefs.json')).read())
|
||||
|
||||
def recordDocSettings(self,docsettings):
|
||||
# print("doc settings",docsettings)
|
||||
for key in docsettings:
|
||||
self.docsettings[key] = docsettings[key]
|
||||
jsonfilepath = os.path.join(self.cwd,'.config/prefs.json')
|
||||
with open(jsonfilepath, "w") as fp:
|
||||
json.dump(self.docsettings, fp, ensure_ascii=False, indent="\t")
|
||||
|
||||
|
||||
def savePreferences(self):
|
||||
# print("savePreferences")
|
||||
@@ -97,13 +109,14 @@ class Core():
|
||||
cwd = self.cwd
|
||||
|
||||
shutil.copytree(os.path.join(self.appcwd,'templates/newproject'), cwd)
|
||||
self.prefs = json.loads(open(os.path.join(cwd,'.config/prefs.json')).read())
|
||||
self.changeCWD(cwd)
|
||||
self.loadDocSettings()
|
||||
# self.docsettings = json.loads(open(os.path.join(cwd,'.config/prefs.json')).read())
|
||||
self.summary = json.loads(open(os.path.join(cwd,'.config/summary.json')).read())
|
||||
self.repository = git.Repo.init(cwd)
|
||||
self.repository.index.add(['assets','contents','.config'])
|
||||
self.repository.index.commit("initial commit")
|
||||
|
||||
self.changeCWD(cwd)
|
||||
|
||||
def saveproject(self, cwd = None):
|
||||
if not cwd == None:
|
||||
|
||||
+56
-36
@@ -10,14 +10,14 @@
|
||||
# @License: GPL-V3
|
||||
|
||||
import os
|
||||
# from PyQt5.QtCore import
|
||||
# from PyQt5.QtCore import QLine
|
||||
from PyQt5.QtGui import QIcon, QIntValidator
|
||||
from PyQt5.QtWidgets import QWidget, QLabel, QDialog, QGroupBox, QDialogButtonBox, QVBoxLayout, QFormLayout, QLineEdit, QComboBox, QSpinBox
|
||||
from PyQt5.QtWidgets import QWidget, QLabel, QDialog, QGroupBox, QDialogButtonBox, QVBoxLayout, QFormLayout, QLineEdit, QComboBox, QSpinBox, QFrame
|
||||
|
||||
class DocsetDialog(QDialog):
|
||||
def __init__(self, parent):
|
||||
super(DocsetDialog, self).__init__(parent)
|
||||
|
||||
self.parent = parent
|
||||
self.createFormGroupBox()
|
||||
|
||||
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||
@@ -32,44 +32,64 @@ class DocsetDialog(QDialog):
|
||||
self.setWindowTitle("Doc settings")
|
||||
|
||||
def createFormGroupBox(self):
|
||||
ds = self.parent.core.docsettings
|
||||
|
||||
self.formGroupBox = QGroupBox("Form layout")
|
||||
layout = QFormLayout()
|
||||
|
||||
pw = QLineEdit(str(210))
|
||||
pw.setValidator(QIntValidator())
|
||||
pw.setMaxLength(5)
|
||||
layout.addRow(QLabel("Page Width (mm):"), pw)
|
||||
|
||||
ph = QLineEdit(str(297))
|
||||
ph.setValidator(QIntValidator())
|
||||
ph.setMaxLength(5)
|
||||
layout.addRow(QLabel("Page Height (mm):"), ph)
|
||||
layout.addRow(QLabel("Page"))
|
||||
self.pw = QLineEdit(str(ds['pw']))
|
||||
self.pw.setFixedWidth(60)
|
||||
self.pw.setValidator(QIntValidator())
|
||||
self.pw.setMaxLength(5)
|
||||
layout.addRow(QLabel("Page Width (mm):"), self.pw)
|
||||
self.ph = QLineEdit(str(ds['ph']))
|
||||
self.ph.setFixedWidth(60)
|
||||
self.ph.setValidator(QIntValidator())
|
||||
self.ph.setMaxLength(5)
|
||||
layout.addRow(QLabel("Page Height (mm):"), self.ph)
|
||||
#
|
||||
mt = QLineEdit(str(15))
|
||||
mt.setValidator(QIntValidator())
|
||||
mt.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin Top (mm):"), mt)
|
||||
mb = QLineEdit(str(15))
|
||||
mb.setValidator(QIntValidator())
|
||||
mb.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin Bottom (mm):"), mb)
|
||||
mi = QLineEdit(str(15))
|
||||
mi.setValidator(QIntValidator())
|
||||
mi.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin inner (mm):"), mi)
|
||||
me = QLineEdit(str(10))
|
||||
me.setValidator(QIntValidator())
|
||||
me.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin external (mm):"), me)
|
||||
line1 = QFrame()
|
||||
line1.setFrameShape(QFrame.HLine)
|
||||
line1.setFrameShadow(QFrame.Sunken)
|
||||
layout.addRow(line1)
|
||||
#
|
||||
cs = QLineEdit(str(5))
|
||||
cs.setValidator(QIntValidator())
|
||||
cs.setMaxLength(3)
|
||||
layout.addRow(QLabel("Crop size (mm):"), cs)
|
||||
bs = QLineEdit(str(5))
|
||||
bs.setValidator(QIntValidator())
|
||||
bs.setMaxLength(3)
|
||||
layout.addRow(QLabel("Bleed size (mm):"), bs)
|
||||
self.mt = QLineEdit(str(ds['mt']))
|
||||
self.mt.setFixedWidth(60)
|
||||
self.mt.setValidator(QIntValidator())
|
||||
self.mt.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin Top (mm):"), self.mt)
|
||||
self.mb = QLineEdit(str(ds['mb']))
|
||||
self.mb.setFixedWidth(60)
|
||||
self.mb.setValidator(QIntValidator())
|
||||
self.mb.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin Bottom (mm):"), self.mb)
|
||||
self.mi = QLineEdit(str(ds['mi']))
|
||||
self.mi.setFixedWidth(60)
|
||||
self.mi.setValidator(QIntValidator())
|
||||
self.mi.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin inner (mm):"), self.mi)
|
||||
self.me = QLineEdit(str(ds['me']))
|
||||
self.me.setFixedWidth(60)
|
||||
self.me.setValidator(QIntValidator())
|
||||
self.me.setMaxLength(3)
|
||||
layout.addRow(QLabel("Margin external (mm):"), self.me)
|
||||
#
|
||||
line2 = QFrame()
|
||||
line2.setFrameShape(QFrame.HLine)
|
||||
line2.setFrameShadow(QFrame.Sunken)
|
||||
layout.addRow(line2)
|
||||
#
|
||||
self.cs = QLineEdit(str(ds['cs']))
|
||||
self.cs.setFixedWidth(60)
|
||||
self.cs.setValidator(QIntValidator())
|
||||
self.cs.setMaxLength(3)
|
||||
layout.addRow(QLabel("Crop size (mm):"), self.cs)
|
||||
self.bs = QLineEdit(str(ds['bs']))
|
||||
self.bs.setFixedWidth(60)
|
||||
self.bs.setValidator(QIntValidator())
|
||||
self.bs.setMaxLength(3)
|
||||
layout.addRow(QLabel("Bleed size (mm):"), self.bs)
|
||||
# # layout.addRow(QLabel("Country:"), QComboBox())
|
||||
# layout.addRow(QLabel("Age:"), QSpinBox())
|
||||
|
||||
|
||||
+12
-5
@@ -108,7 +108,6 @@ class MainWindow(QMainWindow):
|
||||
about = bar.addMenu("About")
|
||||
about.addAction("&Website")
|
||||
|
||||
|
||||
def onfilemenutrigger(self, q):
|
||||
print(q.text()+" is triggered")
|
||||
if q.text() == "&New Project":
|
||||
@@ -196,10 +195,18 @@ class MainWindow(QMainWindow):
|
||||
pass
|
||||
|
||||
def onDocSettings(self):
|
||||
dialog = docsetdialog.DocsetDialog(self)
|
||||
value = dialog.exec_()
|
||||
if value:
|
||||
print(value)
|
||||
d = docsetdialog.DocsetDialog(self)
|
||||
d.exec_()
|
||||
self.core.recordDocSettings({
|
||||
"pw":d.pw.text(),
|
||||
"ph":d.ph.text(),
|
||||
"mt":d.mt.text(),
|
||||
"mb":d.mb.text(),
|
||||
"me":d.me.text(),
|
||||
"mi":d.mi.text(),
|
||||
"cs":d.cs.text(),
|
||||
"bs":d.bs.text()
|
||||
})
|
||||
|
||||
def genPDF(self):
|
||||
print('PDF')
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
{
|
||||
"git.user.name":"Cascade",
|
||||
"git.user.email":"cascade@figureslibres.io"
|
||||
"git.user.email":"cascade@figureslibres.io",
|
||||
"docsettings":{
|
||||
"pw":210,
|
||||
"ph":297,
|
||||
"mt":15,
|
||||
"mb":15,
|
||||
"me":10,
|
||||
"mi":15,
|
||||
"cs":5,
|
||||
"bs":5
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user