added more tools t design toolbar, added doc settings menu and form
This commit is contained in:
+43
-17
@@ -6,7 +6,7 @@ import os, re
|
|||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import QUrl, QSettings, QSizeF
|
from PyQt5.QtCore import QUrl, QSettings, QSizeF
|
||||||
from PyQt5.QtGui import QKeySequence, QFont
|
from PyQt5.QtGui import QKeySequence, QFont
|
||||||
from PyQt5.QtWidgets import QWidget, QTabWidget, QVBoxLayout, QHBoxLayout, QSplitter, QPlainTextEdit, QShortcut, QPushButton, QCheckBox
|
from PyQt5.QtWidgets import QWidget, QTabWidget, QVBoxLayout, QHBoxLayout, QSplitter, QPlainTextEdit, QShortcut, QPushButton, QCheckBox, QSpinBox, QLabel
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
from PyQt5.QtWebKitWidgets import QWebView, QWebInspector
|
from PyQt5.QtWebKitWidgets import QWebView, QWebInspector
|
||||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
||||||
@@ -74,6 +74,14 @@ class WebViewToolBar(QWidget):
|
|||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super(WebViewToolBar, self).__init__(parent)
|
super(WebViewToolBar, self).__init__(parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
|
font = QFont()
|
||||||
|
# font.setFamily("Droid Sans Mono")
|
||||||
|
# font.setFixedPitch(True)
|
||||||
|
font.setPointSize(8)
|
||||||
|
self.setFont(font)
|
||||||
|
|
||||||
|
|
||||||
self.hbox = QHBoxLayout()
|
self.hbox = QHBoxLayout()
|
||||||
self.hbox.setContentsMargins(0,0,0,0)
|
self.hbox.setContentsMargins(0,0,0,0)
|
||||||
|
|
||||||
@@ -101,7 +109,23 @@ class WebViewToolBar(QWidget):
|
|||||||
self.hbox.addStretch()
|
self.hbox.addStretch()
|
||||||
|
|
||||||
# zoom
|
# zoom
|
||||||
|
self.hbox.addWidget(QLabel("Zoom:"))
|
||||||
|
self.zoom = QSpinBox(self)
|
||||||
|
# TODO: action
|
||||||
|
self.hbox.addWidget(self.zoom)
|
||||||
|
|
||||||
# page
|
# page
|
||||||
|
self.hbox.addWidget(QLabel("Page:"))
|
||||||
|
self.page = QSpinBox(self)
|
||||||
|
# TODO: action
|
||||||
|
self.hbox.addWidget(self.page)
|
||||||
|
|
||||||
|
self.addpage = QPushButton("&Add Page", self)
|
||||||
|
# self.addpage.setShortcut('Ctrl+Shift+r')
|
||||||
|
# TODO: how to define same shortcut in different places
|
||||||
|
# self.addpage.setIcon(Icon(ico)))
|
||||||
|
# self.addpage.clicked.connect(self.onAddPage)
|
||||||
|
self.hbox.addWidget(self.addpage)
|
||||||
|
|
||||||
self.hbox.addStretch()
|
self.hbox.addStretch()
|
||||||
|
|
||||||
@@ -114,12 +138,12 @@ class WebViewToolBar(QWidget):
|
|||||||
self.reload.clicked.connect(self.onReload)
|
self.reload.clicked.connect(self.onReload)
|
||||||
self.hbox.addWidget(self.reload)
|
self.hbox.addWidget(self.reload)
|
||||||
|
|
||||||
self.imprim = QPushButton("&Print", self)
|
self.genpdf = QPushButton("&PDF", self)
|
||||||
# self.imprim.setShortcut('Ctrl+Shift+r')
|
# self.genpdf.setShortcut('Ctrl+Shift+r')
|
||||||
# TODO: how to define same shortcut in different places
|
# TODO: how to define same shortcut in different places
|
||||||
# self.imprim.setIcon(Icon(ico)))
|
# self.genpdf.setIcon(Icon(ico)))
|
||||||
self.imprim.clicked.connect(self.onPrint)
|
self.genpdf.clicked.connect(self.onGenPDF)
|
||||||
self.hbox.addWidget(self.imprim)
|
self.hbox.addWidget(self.genpdf)
|
||||||
|
|
||||||
self.setLayout(self.hbox)
|
self.setLayout(self.hbox)
|
||||||
|
|
||||||
@@ -140,9 +164,9 @@ class WebViewToolBar(QWidget):
|
|||||||
print("onReload")
|
print("onReload")
|
||||||
# self.parent.webkitview.
|
# self.parent.webkitview.
|
||||||
|
|
||||||
def onPrint(self):
|
def onGenPDF(self):
|
||||||
print("onReload")
|
print("onGenPDF")
|
||||||
self.parent.webkitview.onPrint()
|
self.parent.webkitview.ongenPDF()
|
||||||
|
|
||||||
|
|
||||||
class CodeEditor(QPlainTextEdit):
|
class CodeEditor(QPlainTextEdit):
|
||||||
@@ -169,6 +193,16 @@ class CodeEditor(QPlainTextEdit):
|
|||||||
self.textChanged.connect(self.onTextChanged)
|
self.textChanged.connect(self.onTextChanged)
|
||||||
|
|
||||||
|
|
||||||
|
font = QFont()
|
||||||
|
font.setFamily("Droid Sans Mono")
|
||||||
|
font.setFixedPitch(True)
|
||||||
|
font.setPointSize(12)
|
||||||
|
self.setFont(font)
|
||||||
|
# self.highlighter = Highlighter(self.document())
|
||||||
|
# https://pypi.python.org/pypi/QScintilla/2.9.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def onTextChanged(self):
|
def onTextChanged(self):
|
||||||
# print('textChanged')
|
# print('textChanged')
|
||||||
# print(self.toPlainText())
|
# print(self.toPlainText())
|
||||||
@@ -210,14 +244,6 @@ class Editor(QWidget):
|
|||||||
self.layout.addWidget(self.tabs)
|
self.layout.addWidget(self.tabs)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
# font = QFont()
|
|
||||||
# font.setFamily('Courier')
|
|
||||||
# font.setFixedPitch(True)
|
|
||||||
# font.setPointSize(10)
|
|
||||||
# self.setFont(font)
|
|
||||||
# self.highlighter = Highlighter(self.document())
|
|
||||||
# https://pypi.python.org/pypi/QScintilla/2.9.2
|
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
self.scsstab.setText()
|
self.scsstab.setText()
|
||||||
self.jstab.setText()
|
self.jstab.setText()
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
# @Author: Bachir Soussi Chiadmi <bach>
|
||||||
|
# @Date: 23-05-2017
|
||||||
|
# @Email: bachir@figureslibres.io
|
||||||
|
# @Last modified by: bach
|
||||||
|
# @Last modified time: 21-04-2017
|
||||||
|
# @License: GPL-V3
|
||||||
|
|
||||||
|
import os
|
||||||
|
# from PyQt5.QtCore import
|
||||||
|
from PyQt5.QtGui import QIcon, QIntValidator
|
||||||
|
from PyQt5.QtWidgets import QWidget, QLabel, QDialog, QGroupBox, QDialogButtonBox, QVBoxLayout, QFormLayout, QLineEdit, QComboBox, QSpinBox
|
||||||
|
|
||||||
|
class DocsetDialog(QDialog):
|
||||||
|
def __init__(self, parent):
|
||||||
|
super(DocsetDialog, self).__init__(parent)
|
||||||
|
|
||||||
|
self.createFormGroupBox()
|
||||||
|
|
||||||
|
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
|
buttonBox.accepted.connect(self.accept)
|
||||||
|
buttonBox.rejected.connect(self.reject)
|
||||||
|
|
||||||
|
mainLayout = QVBoxLayout()
|
||||||
|
mainLayout.addWidget(self.formGroupBox)
|
||||||
|
mainLayout.addWidget(buttonBox)
|
||||||
|
self.setLayout(mainLayout)
|
||||||
|
|
||||||
|
self.setWindowTitle("Doc settings")
|
||||||
|
|
||||||
|
def createFormGroupBox(self):
|
||||||
|
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)
|
||||||
|
#
|
||||||
|
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)
|
||||||
|
#
|
||||||
|
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)
|
||||||
|
# # layout.addRow(QLabel("Country:"), QComboBox())
|
||||||
|
# layout.addRow(QLabel("Age:"), QSpinBox())
|
||||||
|
|
||||||
|
self.formGroupBox.setLayout(layout)
|
||||||
+23
-7
@@ -14,7 +14,7 @@ import os
|
|||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtWidgets import QMainWindow, QAction, QWidget, QLabel, QStackedWidget, QFileDialog, QMessageBox
|
from PyQt5.QtWidgets import QMainWindow, QAction, QWidget, QLabel, QStackedWidget, QFileDialog, QMessageBox
|
||||||
|
|
||||||
from classes import design, content
|
from classes import design, content, docsetdialog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -54,13 +54,21 @@ class MainWindow(QMainWindow):
|
|||||||
self.save_action.setShortcut("Ctrl+Shift+s")
|
self.save_action.setShortcut("Ctrl+Shift+s")
|
||||||
file.addAction(self.save_action)
|
file.addAction(self.save_action)
|
||||||
|
|
||||||
prnt = QAction("&PDF",self)
|
self.save_action = QAction("&Save Project as",self)
|
||||||
prnt.setShortcut("Ctrl+p")
|
self.save_action.setShortcut("Ctrl+Shift+s")
|
||||||
file.addAction(prnt)
|
file.addAction(self.save_action)
|
||||||
|
|
||||||
quit = QAction("&Quit",self)
|
self.docset_action = QAction("&Document Settings",self)
|
||||||
quit.setShortcut("Ctrl+q")
|
self.docset_action.setShortcut("Ctrl+d")
|
||||||
file.addAction(quit)
|
file.addAction(self.docset_action)
|
||||||
|
|
||||||
|
self.pdf_action = QAction("&PDF",self)
|
||||||
|
self.pdf_action.setShortcut("Ctrl+p")
|
||||||
|
file.addAction(self.pdf_action)
|
||||||
|
|
||||||
|
self.quit_action = QAction("&Quit",self)
|
||||||
|
self.quit_action.setShortcut("Ctrl+q")
|
||||||
|
file.addAction(self.quit_action)
|
||||||
|
|
||||||
file.triggered[QAction].connect(self.onfilemenutrigger)
|
file.triggered[QAction].connect(self.onfilemenutrigger)
|
||||||
|
|
||||||
@@ -109,6 +117,8 @@ class MainWindow(QMainWindow):
|
|||||||
self.openprojectdialogue()
|
self.openprojectdialogue()
|
||||||
elif q.text() == "&Save Project as":
|
elif q.text() == "&Save Project as":
|
||||||
self.saveprojectdialogue()
|
self.saveprojectdialogue()
|
||||||
|
elif q.text() == "&Document Settings":
|
||||||
|
self.onDocSettings()
|
||||||
elif q.text() == "&PDF":
|
elif q.text() == "&PDF":
|
||||||
self.genPDF()
|
self.genPDF()
|
||||||
elif q.text() == "&Quit":
|
elif q.text() == "&Quit":
|
||||||
@@ -185,6 +195,12 @@ class MainWindow(QMainWindow):
|
|||||||
print('Exception', e)
|
print('Exception', e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def onDocSettings(self):
|
||||||
|
dialog = docsetdialog.DocsetDialog(self)
|
||||||
|
value = dialog.exec_()
|
||||||
|
if value:
|
||||||
|
print(value)
|
||||||
|
|
||||||
def genPDF(self):
|
def genPDF(self):
|
||||||
print('PDF')
|
print('PDF')
|
||||||
self.designstack.webkitview.ongenPDF()
|
self.designstack.webkitview.ongenPDF()
|
||||||
|
|||||||
Reference in New Issue
Block a user