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
|
import os, shutil, tempfile
|
||||||
# sys,
|
# sys,
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import QSettings
|
from PyQt5.QtCore import QSettings, QCoreApplication
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import git
|
import git
|
||||||
@@ -44,6 +44,7 @@ class Core():
|
|||||||
print('tail', tail)
|
print('tail', tail)
|
||||||
self.projectname = tail
|
self.projectname = tail
|
||||||
|
|
||||||
|
self.loadDocSettings()
|
||||||
|
|
||||||
|
|
||||||
def initDeamons(self):
|
def initDeamons(self):
|
||||||
@@ -76,6 +77,17 @@ class Core():
|
|||||||
self.mw_pos = settings.value('mainwindow/pos', QtCore.QPoint(0, 0))
|
self.mw_pos = settings.value('mainwindow/pos', QtCore.QPoint(0, 0))
|
||||||
self.mw_curstack = int(settings.value('mainwindow/curstack', 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):
|
def savePreferences(self):
|
||||||
# print("savePreferences")
|
# print("savePreferences")
|
||||||
@@ -97,13 +109,14 @@ class Core():
|
|||||||
cwd = self.cwd
|
cwd = self.cwd
|
||||||
|
|
||||||
shutil.copytree(os.path.join(self.appcwd,'templates/newproject'), 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.summary = json.loads(open(os.path.join(cwd,'.config/summary.json')).read())
|
||||||
self.repository = git.Repo.init(cwd)
|
self.repository = git.Repo.init(cwd)
|
||||||
self.repository.index.add(['assets','contents','.config'])
|
self.repository.index.add(['assets','contents','.config'])
|
||||||
self.repository.index.commit("initial commit")
|
self.repository.index.commit("initial commit")
|
||||||
|
|
||||||
self.changeCWD(cwd)
|
|
||||||
|
|
||||||
def saveproject(self, cwd = None):
|
def saveproject(self, cwd = None):
|
||||||
if not cwd == None:
|
if not cwd == None:
|
||||||
|
|||||||
+56
-36
@@ -10,14 +10,14 @@
|
|||||||
# @License: GPL-V3
|
# @License: GPL-V3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
# from PyQt5.QtCore import
|
# from PyQt5.QtCore import QLine
|
||||||
from PyQt5.QtGui import QIcon, QIntValidator
|
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):
|
class DocsetDialog(QDialog):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(DocsetDialog, self).__init__(parent)
|
super(DocsetDialog, self).__init__(parent)
|
||||||
|
self.parent = parent
|
||||||
self.createFormGroupBox()
|
self.createFormGroupBox()
|
||||||
|
|
||||||
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
@@ -32,44 +32,64 @@ class DocsetDialog(QDialog):
|
|||||||
self.setWindowTitle("Doc settings")
|
self.setWindowTitle("Doc settings")
|
||||||
|
|
||||||
def createFormGroupBox(self):
|
def createFormGroupBox(self):
|
||||||
|
ds = self.parent.core.docsettings
|
||||||
|
|
||||||
self.formGroupBox = QGroupBox("Form layout")
|
self.formGroupBox = QGroupBox("Form layout")
|
||||||
layout = QFormLayout()
|
layout = QFormLayout()
|
||||||
|
|
||||||
pw = QLineEdit(str(210))
|
layout.addRow(QLabel("Page"))
|
||||||
pw.setValidator(QIntValidator())
|
self.pw = QLineEdit(str(ds['pw']))
|
||||||
pw.setMaxLength(5)
|
self.pw.setFixedWidth(60)
|
||||||
layout.addRow(QLabel("Page Width (mm):"), pw)
|
self.pw.setValidator(QIntValidator())
|
||||||
|
self.pw.setMaxLength(5)
|
||||||
ph = QLineEdit(str(297))
|
layout.addRow(QLabel("Page Width (mm):"), self.pw)
|
||||||
ph.setValidator(QIntValidator())
|
self.ph = QLineEdit(str(ds['ph']))
|
||||||
ph.setMaxLength(5)
|
self.ph.setFixedWidth(60)
|
||||||
layout.addRow(QLabel("Page Height (mm):"), ph)
|
self.ph.setValidator(QIntValidator())
|
||||||
|
self.ph.setMaxLength(5)
|
||||||
|
layout.addRow(QLabel("Page Height (mm):"), self.ph)
|
||||||
#
|
#
|
||||||
mt = QLineEdit(str(15))
|
line1 = QFrame()
|
||||||
mt.setValidator(QIntValidator())
|
line1.setFrameShape(QFrame.HLine)
|
||||||
mt.setMaxLength(3)
|
line1.setFrameShadow(QFrame.Sunken)
|
||||||
layout.addRow(QLabel("Margin Top (mm):"), mt)
|
layout.addRow(line1)
|
||||||
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)
|
|
||||||
#
|
#
|
||||||
cs = QLineEdit(str(5))
|
self.mt = QLineEdit(str(ds['mt']))
|
||||||
cs.setValidator(QIntValidator())
|
self.mt.setFixedWidth(60)
|
||||||
cs.setMaxLength(3)
|
self.mt.setValidator(QIntValidator())
|
||||||
layout.addRow(QLabel("Crop size (mm):"), cs)
|
self.mt.setMaxLength(3)
|
||||||
bs = QLineEdit(str(5))
|
layout.addRow(QLabel("Margin Top (mm):"), self.mt)
|
||||||
bs.setValidator(QIntValidator())
|
self.mb = QLineEdit(str(ds['mb']))
|
||||||
bs.setMaxLength(3)
|
self.mb.setFixedWidth(60)
|
||||||
layout.addRow(QLabel("Bleed size (mm):"), bs)
|
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("Country:"), QComboBox())
|
||||||
# layout.addRow(QLabel("Age:"), QSpinBox())
|
# layout.addRow(QLabel("Age:"), QSpinBox())
|
||||||
|
|
||||||
|
|||||||
+12
-5
@@ -108,7 +108,6 @@ class MainWindow(QMainWindow):
|
|||||||
about = bar.addMenu("About")
|
about = bar.addMenu("About")
|
||||||
about.addAction("&Website")
|
about.addAction("&Website")
|
||||||
|
|
||||||
|
|
||||||
def onfilemenutrigger(self, q):
|
def onfilemenutrigger(self, q):
|
||||||
print(q.text()+" is triggered")
|
print(q.text()+" is triggered")
|
||||||
if q.text() == "&New Project":
|
if q.text() == "&New Project":
|
||||||
@@ -196,10 +195,18 @@ class MainWindow(QMainWindow):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def onDocSettings(self):
|
def onDocSettings(self):
|
||||||
dialog = docsetdialog.DocsetDialog(self)
|
d = docsetdialog.DocsetDialog(self)
|
||||||
value = dialog.exec_()
|
d.exec_()
|
||||||
if value:
|
self.core.recordDocSettings({
|
||||||
print(value)
|
"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):
|
def genPDF(self):
|
||||||
print('PDF')
|
print('PDF')
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
{
|
{
|
||||||
"git.user.name":"Cascade",
|
"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