Adds a tip if pandoc is not installed. #190

This commit is contained in:
Olivier Keshavjee 2017-11-06 10:05:20 +01:00
parent fc1bd40c21
commit b520b12d7a
5 changed files with 26 additions and 7 deletions

View file

@ -19,6 +19,8 @@ class basicExporter:
cmd = ""
customPath = ""
icon = ""
absentTip = "" # A tip displayed when exporter is absent.
absentURL = "" # URL to open if exporter is absent.
def __init__(self):
settings = QSettings()
@ -129,7 +131,7 @@ class basicFormat:
@classmethod
def isValid(cls):
return True
@classmethod
def projectPath(cls):
return os.path.dirname(os.path.abspath(mainWindow().currentProject))

View file

@ -22,6 +22,8 @@ class pandocExporter(basicExporter):
<p>Website: <a href="http://www.pandoc.org">http://pandoc.org/</a></p>
""")
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):
basicExporter.__init__(self)

View file

@ -6,7 +6,9 @@ import re
from random import *
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 QDesktopServices
from PyQt5.QtWidgets import qApp, QTextEdit
from manuskript.enums import Outline
@ -355,3 +357,7 @@ def customIcons():
]
return sorted(r)
def openURL(url):
QDesktopServices.openUrl(QUrl(url))

View file

@ -1142,8 +1142,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
w.setDict(settings.dict)
def openPyEnchantWebPage(self):
from PyQt5.QtGui import QDesktopServices
QDesktopServices.openUrl(QUrl("http://pythonhosted.org/pyenchant/"))
F.openURL("http://pythonhosted.org/pyenchant/")
def toggleSpellcheck(self, val):
settings.spellcheck = val

View file

@ -5,10 +5,10 @@ import os
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QBrush, QColor, QIcon
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QWidget, QStyle
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.exportersManager import exportersManager
@ -42,7 +42,7 @@ class exporterDialog(QWidget, Ui_exporter):
self.cmbExporters.clear()
for E in exporter.exporters:
if not E.isValid():
if not E.isValid() and not E.absentTip:
continue
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.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:
if not f.isValid():
@ -60,6 +64,12 @@ class exporterDialog(QWidget, Ui_exporter):
self.cmbExporters.addItem(QIcon.fromTheme(f.icon), name, E.name)
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()
if not E or not F or not F.implemented:
@ -142,4 +152,4 @@ class exporterDialog(QWidget, Ui_exporter):
item.widget().deleteLater()
l.addWidget(widget)
widget.setParent(group)
widget.setParent(group)