|
@@ -34,6 +34,7 @@ class WebkitView(QWebView):
|
|
|
self.port = core.server.port
|
|
|
self.view = QWebView.__init__(self, parent)
|
|
|
self.setZoomFactor(1)
|
|
|
+ self.loadFinished.connect(self.onLoaded)
|
|
|
self.load(QUrl('http://localhost:'+str(self.port)))
|
|
|
self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
|
|
|
|
|
@@ -42,6 +43,10 @@ class WebkitView(QWebView):
|
|
|
|
|
|
|
|
|
|
|
|
+ def onLoaded(self):
|
|
|
+ print("onLoaded")
|
|
|
+ self.parent.webviewtoolbar.onReload()
|
|
|
+
|
|
|
def initPDF(self):
|
|
|
self.printer = QPrinter(QPrinter.HighResolution)
|
|
|
self.printer.setFullPage(True)
|
|
@@ -59,7 +64,6 @@ class WebkitView(QWebView):
|
|
|
self.printer.setOutputFileName(self.core.projectname+".pdf")
|
|
|
|
|
|
|
|
|
-
|
|
|
def ongenPDF(self):
|
|
|
|
|
|
|
|
@@ -85,7 +89,6 @@ class WebkitView(QWebView):
|
|
|
command = """document.documentElement.classList."""+togg+"""('"""+c+"""')"""
|
|
|
self.evaluateJS(command)
|
|
|
|
|
|
-
|
|
|
def evaluateJS(self, command):
|
|
|
self.page().mainFrame().evaluateJavaScript(command)
|
|
|
|
|
@@ -119,31 +122,25 @@ class WebViewToolBar(QWidget):
|
|
|
font.setPointSize(8)
|
|
|
self.setFont(font)
|
|
|
|
|
|
-
|
|
|
self.hbox = QHBoxLayout()
|
|
|
self.hbox.setContentsMargins(0,0,0,0)
|
|
|
|
|
|
self.preview = QCheckBox('Prev&iew', self)
|
|
|
-
|
|
|
- self.preview.clicked.connect(self.onPreview)
|
|
|
+ self.preview.stateChanged.connect(self.onPreview)
|
|
|
self.hbox.addWidget(self.preview)
|
|
|
|
|
|
self.debug = QCheckBox('Deb&ug', self)
|
|
|
-
|
|
|
- self.debug.clicked.connect(self.onDebug)
|
|
|
+ self.debug.stateChanged.connect(self.onDebug)
|
|
|
self.hbox.addWidget(self.debug)
|
|
|
|
|
|
self.grid = QCheckBox('&Grid', self)
|
|
|
-
|
|
|
- self.grid.clicked.connect(self.onGrid)
|
|
|
+ self.grid.stateChanged.connect(self.onGrid)
|
|
|
self.hbox.addWidget(self.grid)
|
|
|
|
|
|
-
|
|
|
self.spread = QCheckBox('&Spread', self)
|
|
|
-
|
|
|
- self.spread.clicked.connect(self.onSpread)
|
|
|
+ self.spread.stateChanged.connect(self.onSpread)
|
|
|
self.hbox.addWidget(self.spread)
|
|
|
-
|
|
|
+
|
|
|
self.hbox.addStretch()
|
|
|
|
|
|
|
|
@@ -159,10 +156,10 @@ class WebViewToolBar(QWidget):
|
|
|
self.hbox.addWidget(self.page)
|
|
|
|
|
|
self.addpage = QPushButton("&Add Page", self)
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+ self.addpage.clicked.connect(self.onAddPage)
|
|
|
self.hbox.addWidget(self.addpage)
|
|
|
|
|
|
self.hbox.addStretch()
|
|
@@ -183,26 +180,49 @@ class WebViewToolBar(QWidget):
|
|
|
|
|
|
self.setLayout(self.hbox)
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
def onPreview(self):
|
|
|
self.parent.webkitview.toggleDocClass('preview', self.preview.isChecked())
|
|
|
+ self.recordDocSettings('preview', self.preview.isChecked())
|
|
|
|
|
|
def onDebug(self):
|
|
|
self.parent.webkitview.toggleDocClass('debug', self.debug.isChecked())
|
|
|
+ self.recordDocSettings('debug', self.debug.isChecked())
|
|
|
|
|
|
def onGrid(self):
|
|
|
self.parent.webkitview.toggleDocClass('grid', self.grid.isChecked())
|
|
|
+ self.recordDocSettings('grid', self.grid.isChecked())
|
|
|
|
|
|
def onSpread(self):
|
|
|
self.parent.webkitview.toggleDocClass('spread', self.spread.isChecked())
|
|
|
+ self.recordDocSettings('spread', self.spread.isChecked())
|
|
|
+
|
|
|
+ def onAddPage(self):
|
|
|
+ print("onAddPage")
|
|
|
|
|
|
def onReload(self):
|
|
|
print("onReload")
|
|
|
-
|
|
|
|
|
|
def onGenPDF(self):
|
|
|
print("onGenPDF")
|
|
|
self.parent.webkitview.ongenPDF()
|
|
|
|
|
|
+ def recordDocSettings(self, prop, val):
|
|
|
+ print('recordDocSettings : '+prop, val)
|
|
|
+ settings = QSettings('FiguresLibres', 'Cascade')
|
|
|
+ settings.setValue('design/toolbar/'+prop, val)
|
|
|
+
|
|
|
+ def onReload(self):
|
|
|
+
|
|
|
+ settings = QSettings('FiguresLibres', 'Cascade')
|
|
|
+ self.preview.setChecked(settings.value('design/toolbar/preview', "false") == "true")
|
|
|
+ self.debug.setChecked(settings.value('design/toolbar/debug', "false") == "true")
|
|
|
+ self.grid.setChecked(settings.value('design/toolbar/grid', "false") == "true")
|
|
|
+ self.spread.setChecked(settings.value('design/toolbar/spread', "false") == "true")
|
|
|
+
|
|
|
|
|
|
|
|
|
|