|
@@ -155,7 +155,6 @@ class WebViewToolBar(QWidget):
|
|
|
|
|
|
|
|
|
self.gotopage = QLabel("Go to Page: /"+self.parent.core.docsettings['np'])
|
|
|
-
|
|
|
self.hbox.addWidget(self.gotopage)
|
|
|
self.page = QSpinBox(self)
|
|
|
|
|
@@ -213,19 +212,19 @@ class WebViewToolBar(QWidget):
|
|
|
self.recToolbarState('facing', self.facing.isChecked())
|
|
|
|
|
|
def onAddPage(self):
|
|
|
- print("onAddPage")
|
|
|
+
|
|
|
self.parent.core.addPage()
|
|
|
|
|
|
|
|
|
def onRmPage(self):
|
|
|
- print("onAddPage")
|
|
|
+
|
|
|
self.parent.core.rmPage()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def onReload(self):
|
|
|
- print("onReload")
|
|
|
+
|
|
|
self.parent.webkitview.reload()
|
|
|
|
|
|
def onGenPDF(self):
|
|
@@ -233,10 +232,10 @@ class WebViewToolBar(QWidget):
|
|
|
self.parent.webkitview.ongenPDF()
|
|
|
|
|
|
def recToolbarState(self, prop, val):
|
|
|
- print('recToolbarState : '+prop, val)
|
|
|
+
|
|
|
settings = QSettings('FiguresLibres', 'Cascade')
|
|
|
settings.setValue('design/toolbar/'+prop, val)
|
|
|
- print('recToolbarState after : '+prop, settings.value('design/toolbar/'+prop))
|
|
|
+
|
|
|
|
|
|
def onRefresh(self):
|
|
|
|
|
@@ -260,48 +259,47 @@ class WebViewToolBar(QWidget):
|
|
|
|
|
|
|
|
|
class CodeEditor(QPlainTextEdit):
|
|
|
- def __init__(self, core, tabs, file, mode):
|
|
|
+ def __init__(self, parent, core, tabs, file, mode):
|
|
|
super(CodeEditor, self).__init__()
|
|
|
+ self.parent = parent
|
|
|
self.core = core
|
|
|
self.tabs = tabs
|
|
|
self.file = file
|
|
|
+ self.hl= highlighter.Highlighter(self.document(),mode)
|
|
|
self.setText()
|
|
|
self.setTabStopWidth(15)
|
|
|
- self.hl= highlighter.Highlighter(self.document(),mode)
|
|
|
+
|
|
|
+ self.textChanged.connect(self.onTextChanged)
|
|
|
|
|
|
self.shortcut = QShortcut(QKeySequence("Ctrl+s"), self)
|
|
|
self.shortcut.activated.connect(self.save)
|
|
|
|
|
|
def setText(self):
|
|
|
- try:
|
|
|
- self.textChanged.disconnect(self.onTextChanged)
|
|
|
- except Exception as e:
|
|
|
- print(e)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
self.filepath = os.path.join(self.core.cwd,self.file)
|
|
|
self.clear()
|
|
|
self.insertPlainText(open(self.filepath, 'r').read())
|
|
|
self.changed = False
|
|
|
- self.textChanged.connect(self.onTextChanged)
|
|
|
-
|
|
|
|
|
|
font = QFont()
|
|
|
font.setFamily("Droid Sans Mono")
|
|
|
font.setFixedPitch(True)
|
|
|
font.setPointSize(12)
|
|
|
self.setFont(font)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
def onTextChanged(self):
|
|
|
-
|
|
|
+ print('textChanged')
|
|
|
|
|
|
|
|
|
if not self.changed:
|
|
|
self.changed = True
|
|
|
i = self.tabs.currentIndex()
|
|
|
+
|
|
|
self.tabs.setTabText(i, "* "+self.tabs.tabText(i))
|
|
|
|
|
|
|
|
@@ -309,14 +307,15 @@ class CodeEditor(QPlainTextEdit):
|
|
|
if self.changed:
|
|
|
open(self.filepath, 'w').write(self.toPlainText())
|
|
|
i = self.tabs.currentIndex()
|
|
|
- self.tabs.setTabText(i, re.sub(r'^\*\s', '', self.tabs.tabText(i)))
|
|
|
+ self.tabs.setTabText(i, re.sub(r'^\**\s', '', self.tabs.tabText(i)))
|
|
|
+ self.parent.reloadView()
|
|
|
self.changed = False
|
|
|
|
|
|
|
|
|
class Editor(QWidget):
|
|
|
- def __init__(self, parent, core):
|
|
|
+ def __init__(self, parent):
|
|
|
super(Editor, self).__init__()
|
|
|
- self.core = core
|
|
|
+ self.parent = parent
|
|
|
|
|
|
self.layout = QVBoxLayout(self)
|
|
|
self.layout.setContentsMargins(0,0,0,0)
|
|
@@ -324,8 +323,8 @@ class Editor(QWidget):
|
|
|
|
|
|
self.tabs = QTabWidget()
|
|
|
|
|
|
- self.scsstab = CodeEditor(core, self.tabs, 'assets/css/styles.scss', "scss")
|
|
|
- self.jstab = CodeEditor(core, self.tabs, 'assets/js/script.js', 'js')
|
|
|
+ self.scsstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/css/styles.scss', "scss")
|
|
|
+ self.jstab = CodeEditor(self, self.parent.core, self.tabs, 'assets/js/script.js', 'js')
|
|
|
|
|
|
|
|
|
self.tabs.addTab(self.scsstab,"scss")
|
|
@@ -339,6 +338,9 @@ class Editor(QWidget):
|
|
|
self.scsstab.setText()
|
|
|
self.jstab.setText()
|
|
|
|
|
|
+ def reloadView(self):
|
|
|
+ self.parent.webkitview.reload()
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -387,7 +389,7 @@ class DesignStack(QWidget):
|
|
|
self.hsplitter.addWidget(self.webview)
|
|
|
|
|
|
|
|
|
- self.editor = Editor(self, core)
|
|
|
+ self.editor = Editor(self)
|
|
|
self.hsplitter.addWidget(self.editor)
|
|
|
|
|
|
self.hsplitter.splitterMoved.connect(self.movedSplitter)
|