mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-14 08:54:34 +12:00
Adds a tip if pandoc is not installed. #190
This commit is contained in:
parent
fc1bd40c21
commit
b520b12d7a
|
@ -19,6 +19,8 @@ class basicExporter:
|
||||||
cmd = ""
|
cmd = ""
|
||||||
customPath = ""
|
customPath = ""
|
||||||
icon = ""
|
icon = ""
|
||||||
|
absentTip = "" # A tip displayed when exporter is absent.
|
||||||
|
absentURL = "" # URL to open if exporter is absent.
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
|
@ -129,7 +131,7 @@ class basicFormat:
|
||||||
@classmethod
|
@classmethod
|
||||||
def isValid(cls):
|
def isValid(cls):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def projectPath(cls):
|
def projectPath(cls):
|
||||||
return os.path.dirname(os.path.abspath(mainWindow().currentProject))
|
return os.path.dirname(os.path.abspath(mainWindow().currentProject))
|
||||||
|
|
|
@ -22,6 +22,8 @@ class pandocExporter(basicExporter):
|
||||||
<p>Website: <a href="http://www.pandoc.org">http://pandoc.org/</a></p>
|
<p>Website: <a href="http://www.pandoc.org">http://pandoc.org/</a></p>
|
||||||
""")
|
""")
|
||||||
cmd = "pandoc"
|
cmd = "pandoc"
|
||||||
|
absentTip = "Install pandoc to benefit from a wide range of export formats (DocX, ePub, PDF, etc.)"
|
||||||
|
absentURL = "http://pandoc.org/installing.html"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
basicExporter.__init__(self)
|
basicExporter.__init__(self)
|
||||||
|
|
|
@ -6,7 +6,9 @@ import re
|
||||||
from random import *
|
from random import *
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QRect, QStandardPaths, QObject, QRegExp, QDir
|
from PyQt5.QtCore import Qt, QRect, QStandardPaths, QObject, QRegExp, QDir
|
||||||
|
from PyQt5.QtCore import QUrl
|
||||||
from PyQt5.QtGui import QBrush, QIcon, QPainter, QColor, QImage, QPixmap
|
from PyQt5.QtGui import QBrush, QIcon, QPainter, QColor, QImage, QPixmap
|
||||||
|
from PyQt5.QtGui import QDesktopServices
|
||||||
from PyQt5.QtWidgets import qApp, QTextEdit
|
from PyQt5.QtWidgets import qApp, QTextEdit
|
||||||
|
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
|
@ -355,3 +357,7 @@ def customIcons():
|
||||||
]
|
]
|
||||||
|
|
||||||
return sorted(r)
|
return sorted(r)
|
||||||
|
|
||||||
|
def openURL(url):
|
||||||
|
QDesktopServices.openUrl(QUrl(url))
|
||||||
|
|
||||||
|
|
|
@ -1142,8 +1142,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
w.setDict(settings.dict)
|
w.setDict(settings.dict)
|
||||||
|
|
||||||
def openPyEnchantWebPage(self):
|
def openPyEnchantWebPage(self):
|
||||||
from PyQt5.QtGui import QDesktopServices
|
F.openURL("http://pythonhosted.org/pyenchant/")
|
||||||
QDesktopServices.openUrl(QUrl("http://pythonhosted.org/pyenchant/"))
|
|
||||||
|
|
||||||
def toggleSpellcheck(self, val):
|
def toggleSpellcheck(self, val):
|
||||||
settings.spellcheck = val
|
settings.spellcheck = val
|
||||||
|
|
|
@ -5,10 +5,10 @@ import os
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QBrush, QColor, QIcon
|
from PyQt5.QtGui import QBrush, QColor, QIcon
|
||||||
from PyQt5.QtWidgets import QWidget
|
from PyQt5.QtWidgets import QWidget, QStyle
|
||||||
|
|
||||||
from manuskript import exporter
|
from manuskript import exporter
|
||||||
from manuskript.functions import lightBlue, writablePath
|
from manuskript.functions import lightBlue, writablePath, openURL
|
||||||
from manuskript.ui.exporters.exporter_ui import Ui_exporter
|
from manuskript.ui.exporters.exporter_ui import Ui_exporter
|
||||||
from manuskript.ui.exporters.exportersManager import exportersManager
|
from manuskript.ui.exporters.exportersManager import exportersManager
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class exporterDialog(QWidget, Ui_exporter):
|
||||||
self.cmbExporters.clear()
|
self.cmbExporters.clear()
|
||||||
for E in exporter.exporters:
|
for E in exporter.exporters:
|
||||||
|
|
||||||
if not E.isValid():
|
if not E.isValid() and not E.absentTip:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.cmbExporters.addItem(QIcon(E.icon), E.name)
|
self.cmbExporters.addItem(QIcon(E.icon), E.name)
|
||||||
|
@ -51,6 +51,10 @@ class exporterDialog(QWidget, Ui_exporter):
|
||||||
item = self.cmbExporters.model().item(self.cmbExporters.count() - 1)
|
item = self.cmbExporters.model().item(self.cmbExporters.count() - 1)
|
||||||
item.setFlags(Qt.ItemIsEnabled)
|
item.setFlags(Qt.ItemIsEnabled)
|
||||||
|
|
||||||
|
if not E.isValid() and E.absentTip:
|
||||||
|
self.cmbExporters.addItem(self.style().standardIcon(QStyle.SP_MessageBoxWarning), E.absentTip, "::URL::" + E.absentURL)
|
||||||
|
continue
|
||||||
|
|
||||||
for f in E.exportTo:
|
for f in E.exportTo:
|
||||||
|
|
||||||
if not f.isValid():
|
if not f.isValid():
|
||||||
|
@ -60,6 +64,12 @@ class exporterDialog(QWidget, Ui_exporter):
|
||||||
self.cmbExporters.addItem(QIcon.fromTheme(f.icon), name, E.name)
|
self.cmbExporters.addItem(QIcon.fromTheme(f.icon), name, E.name)
|
||||||
|
|
||||||
def updateUi(self, index):
|
def updateUi(self, index):
|
||||||
|
|
||||||
|
# We check if we have an URL to open
|
||||||
|
data = self.cmbExporters.currentData()
|
||||||
|
if data and data[:7] == "::URL::" and data[7:]:
|
||||||
|
openURL(data[7:])
|
||||||
|
|
||||||
E, F = self.getSelectedExporter()
|
E, F = self.getSelectedExporter()
|
||||||
|
|
||||||
if not E or not F or not F.implemented:
|
if not E or not F or not F.implemented:
|
||||||
|
@ -142,4 +152,4 @@ class exporterDialog(QWidget, Ui_exporter):
|
||||||
item.widget().deleteLater()
|
item.widget().deleteLater()
|
||||||
|
|
||||||
l.addWidget(widget)
|
l.addWidget(widget)
|
||||||
widget.setParent(group)
|
widget.setParent(group)
|
||||||
|
|
Loading…
Reference in a new issue