Adds icon to exporter, and test if latex is available

This commit is contained in:
Olivier Keshavjee 2016-04-15 14:04:07 +02:00
parent b7dec65501
commit 0ed3e36952
5 changed files with 13 additions and 2 deletions

View file

@ -17,6 +17,7 @@ class basicExporter:
exportTo = []
cmd = ""
customPath = ""
icon = ""
def __init__(self):
settings = QSettings()

View file

@ -6,6 +6,7 @@ from manuskript.exporter.basic import basicExporter, basicFormat
from manuskript.exporter.manuskript.HTML import HTML
from manuskript.exporter.manuskript.markdown import markdown
from manuskript.exporter.manuskript.plainText import plainText
from manuskript.functions import appPath
class manuskriptExporter(basicExporter):
@ -18,6 +19,7 @@ class manuskriptExporter(basicExporter):
HTML(),
basicFormat("OPML", icon="text-x-opml+xml")
]
icon = appPath("icons/Manuskript/icon-256px.png")
@classmethod
def isValid(cls):

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
# --!-- coding: utf8 --!--
import random
import shutil
from PyQt5.QtCore import QUrl
from PyQt5.QtWebKit import QWebSettings
@ -17,6 +18,8 @@ class PDF(abstractOutput):
name = "PDF"
description = qApp.translate("Export", "Needs latex to be installed.")
InvalidBecause = qApp.translate("Export", """a valid latex installation. See pandoc recommendations on:
<a href="http://pandoc.org/installing.html">http://pandoc.org/installing.html</a>""")
icon = "application-pdf"
exportVarName = "lastPandocPDF"
@ -27,6 +30,10 @@ class PDF(abstractOutput):
"Preview": True,
}
def isValid(self):
path = shutil.which("pdflatex")
return path is not None
def output(self, settingsWidget, outputfile=None):
args = settingsWidget.runnableSettings()
args.remove("--to=pdf")

View file

@ -46,7 +46,7 @@ class exporterDialog(QWidget, Ui_exporter):
if not E.isValid():
continue
self.cmbExporters.addItem(E.name)
self.cmbExporters.addItem(QIcon(E.icon), E.name)
self.cmbExporters.setItemData(self.cmbExporters.count() - 1, QBrush(QColor(Qt.darkBlue)), Qt.ForegroundRole)
self.cmbExporters.setItemData(self.cmbExporters.count() - 1, QBrush(lightBlue()), Qt.BackgroundRole)
item = self.cmbExporters.model().item(self.cmbExporters.count() - 1)

View file

@ -25,7 +25,8 @@ class exportersManager(QWidget, Ui_ExportersManager):
# Populates lite
self.lstExporters.clear()
for E in exporter.exporters:
self.lstExporters.addItem(E.name)
item = QListWidgetItem(QIcon(E.icon), E.name)
self.lstExporters.addItem(item)
# UI
for i in range(self.lstExporters.count()):