mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-03 04:22:31 +12:00
Added guard to catch errors with translation
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
parent
fa44b505de
commit
a33249fc9d
|
@ -9,7 +9,7 @@ from PyQt5.QtWidgets import qApp, QMessageBox
|
||||||
from PyQt5.QtGui import QCursor
|
from PyQt5.QtGui import QCursor
|
||||||
|
|
||||||
from manuskript.converters import abstractConverter
|
from manuskript.converters import abstractConverter
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow, safeTranslate
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -74,7 +74,7 @@ class pandocConverter(abstractConverter):
|
||||||
err = stderr.decode("utf-8")
|
err = stderr.decode("utf-8")
|
||||||
LOGGER.error(err)
|
LOGGER.error(err)
|
||||||
QMessageBox.critical(mainWindow().dialog,
|
QMessageBox.critical(mainWindow().dialog,
|
||||||
qApp.translate("Export", "Error"), err)
|
safeTranslate(qApp, "Export", "Error"), err)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return stdout.decode("utf-8")
|
return stdout.decode("utf-8")
|
||||||
|
|
|
@ -6,6 +6,8 @@ from PyQt5.QtWidgets import QPlainTextEdit, qApp, QTabWidget, QFrame, QTextEdit
|
||||||
from manuskript.exporter.manuskript.markdown import markdown, markdownSettings
|
from manuskript.exporter.manuskript.markdown import markdown, markdownSettings
|
||||||
from manuskript.ui.views.webView import webView
|
from manuskript.ui.views.webView import webView
|
||||||
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -15,8 +17,8 @@ except ImportError:
|
||||||
|
|
||||||
class HTML(markdown):
|
class HTML(markdown):
|
||||||
name = "HTML"
|
name = "HTML"
|
||||||
description = qApp.translate("Export", "Basic HTML output using the Python module 'markdown'.")
|
description = safeTranslate(qApp, "Export", "Basic HTML output using the Python module 'markdown'.")
|
||||||
InvalidBecause = qApp.translate("Export", "Python module 'markdown'.")
|
InvalidBecause = safeTranslate(qApp, "Export", "Python module 'markdown'.")
|
||||||
icon = "text-html"
|
icon = "text-html"
|
||||||
|
|
||||||
exportVarName = "lastManuskriptHTML"
|
exportVarName = "lastManuskriptHTML"
|
||||||
|
@ -51,12 +53,12 @@ class HTML(markdown):
|
||||||
w1 = QPlainTextEdit()
|
w1 = QPlainTextEdit()
|
||||||
w1.setFrameShape(QFrame.NoFrame)
|
w1.setFrameShape(QFrame.NoFrame)
|
||||||
w1.setReadOnly(True)
|
w1.setReadOnly(True)
|
||||||
t.addTab(w0, qApp.translate("Export", "Markdown source"))
|
t.addTab(w0, safeTranslate(qApp, "Export", "Markdown source"))
|
||||||
t.addTab(w1, qApp.translate("Export", "HTML Source"))
|
t.addTab(w1, safeTranslate(qApp, "Export", "HTML Source"))
|
||||||
|
|
||||||
if webView:
|
if webView:
|
||||||
w2 = webView()
|
w2 = webView()
|
||||||
t.addTab(w2, qApp.translate("Export", "HTML Output"))
|
t.addTab(w2, safeTranslate(qApp, "Export", "HTML Output"))
|
||||||
|
|
||||||
t.setCurrentIndex(2)
|
t.setCurrentIndex(2)
|
||||||
return t
|
return t
|
||||||
|
|
|
@ -6,13 +6,13 @@ from manuskript.exporter.basic import basicExporter, basicFormat
|
||||||
from manuskript.exporter.manuskript.HTML import HTML
|
from manuskript.exporter.manuskript.HTML import HTML
|
||||||
from manuskript.exporter.manuskript.markdown import markdown
|
from manuskript.exporter.manuskript.markdown import markdown
|
||||||
from manuskript.exporter.manuskript.plainText import plainText
|
from manuskript.exporter.manuskript.plainText import plainText
|
||||||
from manuskript.functions import appPath
|
from manuskript.functions import appPath, safeTranslate
|
||||||
|
|
||||||
|
|
||||||
class manuskriptExporter(basicExporter):
|
class manuskriptExporter(basicExporter):
|
||||||
|
|
||||||
name = "Manuskript"
|
name = "Manuskript"
|
||||||
description = qApp.translate("Export", "Default exporter, provides basic formats used by other exporters.")
|
description = safeTranslate(qApp, "Export", "Default exporter, provides basic formats used by other exporters.")
|
||||||
exportTo = [
|
exportTo = [
|
||||||
plainText(),
|
plainText(),
|
||||||
markdown(),
|
markdown(),
|
||||||
|
|
|
@ -4,14 +4,14 @@ from PyQt5.QtGui import QTextCharFormat, QFont
|
||||||
from PyQt5.QtWidgets import QPlainTextEdit, QGroupBox, qApp, QVBoxLayout, QCheckBox
|
from PyQt5.QtWidgets import QPlainTextEdit, QGroupBox, qApp, QVBoxLayout, QCheckBox
|
||||||
|
|
||||||
from manuskript.exporter.manuskript.plainText import plainText
|
from manuskript.exporter.manuskript.plainText import plainText
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow, safeTranslate
|
||||||
from manuskript.ui.highlighters import MMDHighlighter
|
from manuskript.ui.highlighters import MMDHighlighter
|
||||||
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
||||||
|
|
||||||
|
|
||||||
class markdown(plainText):
|
class markdown(plainText):
|
||||||
name = "Markdown"
|
name = "Markdown"
|
||||||
description = qApp.translate("Export", """Just like plain text, excepts adds markdown titles.
|
description = safeTranslate(qApp, "Export", """Just like plain text, excepts adds markdown titles.
|
||||||
Presupposes that texts are formatted in markdown.""")
|
Presupposes that texts are formatted in markdown.""")
|
||||||
|
|
||||||
exportVarName = "lastManuskriptMarkdown"
|
exportVarName = "lastManuskriptMarkdown"
|
||||||
|
@ -57,7 +57,7 @@ class markdownSettings(exporterSettings):
|
||||||
w = self.toolBox.widget(self.toolBox.count() - 1)
|
w = self.toolBox.widget(self.toolBox.count() - 1)
|
||||||
self.grpMarkdown = QGroupBox(self.tr("Markdown"))
|
self.grpMarkdown = QGroupBox(self.tr("Markdown"))
|
||||||
self.grpMarkdown.setLayout(QVBoxLayout())
|
self.grpMarkdown.setLayout(QVBoxLayout())
|
||||||
self.chkMarkdownHighlighter = QCheckBox(qApp.translate("Export", "Preview with highlighter."))
|
self.chkMarkdownHighlighter = QCheckBox(safeTranslate(qApp, "Export", "Preview with highlighter."))
|
||||||
self.grpMarkdown.layout().addWidget(self.chkMarkdownHighlighter)
|
self.grpMarkdown.layout().addWidget(self.chkMarkdownHighlighter)
|
||||||
|
|
||||||
w.layout().insertWidget(w.layout().count() - 1, self.grpMarkdown)
|
w.layout().insertWidget(w.layout().count() - 1, self.grpMarkdown)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from PyQt5.QtGui import QFont, QTextCharFormat
|
||||||
from PyQt5.QtWidgets import QPlainTextEdit, qApp, QFrame, QFileDialog, QMessageBox
|
from PyQt5.QtWidgets import QPlainTextEdit, qApp, QFrame, QFileDialog, QMessageBox
|
||||||
|
|
||||||
from manuskript.exporter.basic import basicFormat
|
from manuskript.exporter.basic import basicFormat
|
||||||
from manuskript.functions import mainWindow, getSaveFileNameWithSuffix
|
from manuskript.functions import mainWindow, getSaveFileNameWithSuffix, safeTranslate
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
from manuskript.ui.exporters.manuskript.plainTextSettings import exporterSettings
|
||||||
import codecs
|
import codecs
|
||||||
|
@ -14,8 +14,8 @@ import logging
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
class plainText(basicFormat):
|
class plainText(basicFormat):
|
||||||
name = qApp.translate("Export", "Plain text")
|
name = safeTranslate(qApp, "Export", "Plain text")
|
||||||
description = qApp.translate("Export", """Simplest export to plain text. Allows you to use your own markup not understood
|
description = safeTranslate(qApp, "Export", """Simplest export to plain text. Allows you to use your own markup not understood
|
||||||
by Manuskript, for example <a href='www.fountain.io'>Fountain</a>.""")
|
by Manuskript, for example <a href='www.fountain.io'>Fountain</a>.""")
|
||||||
implemented = True
|
implemented = True
|
||||||
requires = {
|
requires = {
|
||||||
|
@ -48,8 +48,8 @@ class plainText(basicFormat):
|
||||||
try:
|
try:
|
||||||
return self.concatenate(mainWindow().mdlOutline.rootItem, settings)
|
return self.concatenate(mainWindow().mdlOutline.rootItem, settings)
|
||||||
except re.error as e:
|
except re.error as e:
|
||||||
QMessageBox.warning(mainWindow().dialog, qApp.translate("Export", "Error"),
|
QMessageBox.warning(mainWindow().dialog, safeTranslate(qApp, "Export", "Error"),
|
||||||
qApp.translate("Export", "Could not process regular expression: \n{}").format(str(e)))
|
safeTranslate(qApp, "Export", "Could not process regular expression: \n{}").format(str(e)))
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def getExportFilename(self, settingsWidget, varName=None, filter=None):
|
def getExportFilename(self, settingsWidget, varName=None, filter=None):
|
||||||
|
@ -69,7 +69,7 @@ class plainText(basicFormat):
|
||||||
filename = ""
|
filename = ""
|
||||||
|
|
||||||
filename, filter = getSaveFileNameWithSuffix(settingsWidget.parent(),
|
filename, filter = getSaveFileNameWithSuffix(settingsWidget.parent(),
|
||||||
caption=qApp.translate("Export", "Choose output file…"),
|
caption=safeTranslate(qApp, "Export", "Choose output file…"),
|
||||||
filter=filter,
|
filter=filter,
|
||||||
directory=filename,
|
directory=filename,
|
||||||
defaultSuffix=self.exportDefaultSuffix)
|
defaultSuffix=self.exportDefaultSuffix)
|
||||||
|
|
|
@ -5,12 +5,14 @@ from PyQt5.QtCore import QUrl
|
||||||
|
|
||||||
from manuskript.exporter.manuskript import HTML as MskHTML
|
from manuskript.exporter.manuskript import HTML as MskHTML
|
||||||
from manuskript.exporter.pandoc.abstractPlainText import abstractPlainText
|
from manuskript.exporter.pandoc.abstractPlainText import abstractPlainText
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
class HTML(abstractPlainText):
|
class HTML(abstractPlainText):
|
||||||
name = "HTML"
|
name = "HTML"
|
||||||
description = qApp.translate("Export", """A little known format modestly used. You know, web sites for example.""")
|
description = safeTranslate(qApp, "Export", """A little known format modestly used. You know, web sites for example.""")
|
||||||
icon = "text-html"
|
icon = "text-html"
|
||||||
|
|
||||||
exportVarName = "lastPandocHTML"
|
exportVarName = "lastPandocHTML"
|
||||||
|
|
|
@ -7,7 +7,7 @@ from PyQt5.QtCore import QUrl
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
from manuskript.exporter.pandoc.abstractOutput import abstractOutput
|
from manuskript.exporter.pandoc.abstractOutput import abstractOutput
|
||||||
from manuskript.functions import tempFile
|
from manuskript.functions import tempFile, safeTranslate
|
||||||
from manuskript.ui.views.PDFViewer import PDFViewer
|
from manuskript.ui.views.PDFViewer import PDFViewer
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ class PDF(abstractOutput):
|
||||||
"""PDF Viewer using PDF.js. Cf. https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website"""
|
"""PDF Viewer using PDF.js. Cf. https://github.com/mozilla/pdf.js/wiki/Setup-PDF.js-in-a-website"""
|
||||||
|
|
||||||
name = "PDF"
|
name = "PDF"
|
||||||
description = qApp.translate("Export", "Needs LaTeX to be installed.")
|
description = safeTranslate(qApp, "Export", "Needs LaTeX to be installed.")
|
||||||
InvalidBecause = qApp.translate("Export", """a valid LaTeX installation. Pandoc recommendations can be found on:
|
InvalidBecause = safeTranslate(qApp, "Export", """a valid LaTeX installation. Pandoc recommendations can be found on:
|
||||||
<a href="https://pandoc.org/installing.html">pandoc.org/installing.html</a>. If you want Unicode support, you need XeLaTeX.""")
|
<a href="https://pandoc.org/installing.html">pandoc.org/installing.html</a>. If you want Unicode support, you need XeLaTeX.""")
|
||||||
icon = "application-pdf"
|
icon = "application-pdf"
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ from manuskript.exporter.pandoc.HTML import HTML
|
||||||
from manuskript.exporter.pandoc.PDF import PDF
|
from manuskript.exporter.pandoc.PDF import PDF
|
||||||
from manuskript.exporter.pandoc.outputFormats import ePub, OpenDocument, DocX
|
from manuskript.exporter.pandoc.outputFormats import ePub, OpenDocument, DocX
|
||||||
from manuskript.exporter.pandoc.plainText import reST, markdown, latex, OPML
|
from manuskript.exporter.pandoc.plainText import reST, markdown, latex, OPML
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow, safeTranslate
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -19,7 +19,7 @@ LOGGER = logging.getLogger(__name__)
|
||||||
class pandocExporter(basicExporter):
|
class pandocExporter(basicExporter):
|
||||||
|
|
||||||
name = "Pandoc"
|
name = "Pandoc"
|
||||||
description = qApp.translate("Export", """<p>A universal document converter. Can be used to convert Markdown to a wide range of other
|
description = safeTranslate(qApp, "Export", """<p>A universal document converter. Can be used to convert Markdown to a wide range of other
|
||||||
formats.</p>
|
formats.</p>
|
||||||
<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>
|
||||||
""")
|
""")
|
||||||
|
@ -106,7 +106,7 @@ class pandocExporter(basicExporter):
|
||||||
+ "Stderr content:\n" + stderr.decode("utf-8")
|
+ "Stderr content:\n" + stderr.decode("utf-8")
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
LOGGER.error(err)
|
LOGGER.error(err)
|
||||||
QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err)
|
QMessageBox.critical(mainWindow().dialog, safeTranslate(qApp, "Export", "Error"), err)
|
||||||
else:
|
else:
|
||||||
LOGGER.warning(err)
|
LOGGER.warning(err)
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -7,6 +7,7 @@ from PyQt5.QtWidgets import qApp, QVBoxLayout, QCheckBox, QWidget, QHBoxLayout,
|
||||||
|
|
||||||
from manuskript.exporter.manuskript.markdown import markdown, markdownSettings
|
from manuskript.exporter.manuskript.markdown import markdown, markdownSettings
|
||||||
from manuskript.ui.collapsibleGroupBox2 import collapsibleGroupBox2
|
from manuskript.ui.collapsibleGroupBox2 import collapsibleGroupBox2
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -150,80 +151,80 @@ class pandocSettings(markdownSettings):
|
||||||
settingsList = {
|
settingsList = {
|
||||||
# General
|
# General
|
||||||
"standalone": pandocSetting("--standalone", "checkbox", "",
|
"standalone": pandocSetting("--standalone", "checkbox", "",
|
||||||
qApp.translate("Export", "Standalone document (not just a fragment)"),
|
safeTranslate(qApp, "Export", "Standalone document (not just a fragment)"),
|
||||||
default=True),
|
default=True),
|
||||||
"TOC": pandocSetting("--toc", "checkbox", "",
|
"TOC": pandocSetting("--toc", "checkbox", "",
|
||||||
qApp.translate("Export", "Include a table of contents."), toc=True),
|
safeTranslate(qApp, "Export", "Include a table of contents."), toc=True),
|
||||||
|
|
||||||
"TOC-depth": pandocSetting("--toc-depth=", "number", "",
|
"TOC-depth": pandocSetting("--toc-depth=", "number", "",
|
||||||
qApp.translate("Export", "Number of sections level to include in TOC: "),
|
safeTranslate(qApp, "Export", "Number of sections level to include in TOC: "),
|
||||||
default=3, min=1, max=6, toc=True, minVersion="1.10"),
|
default=3, min=1, max=6, toc=True, minVersion="1.10"),
|
||||||
# pandoc v1 only
|
# pandoc v1 only
|
||||||
"smart": pandocSetting("--smart", "checkbox", "",
|
"smart": pandocSetting("--smart", "checkbox", "",
|
||||||
qApp.translate("Export", "Typographically correct output"),
|
safeTranslate(qApp, "Export", "Typographically correct output"),
|
||||||
maxVersion="1.19.2.4"),
|
maxVersion="1.19.2.4"),
|
||||||
# pandoc v1 only
|
# pandoc v1 only
|
||||||
"normalize": pandocSetting("--normalize", "checkbox", "",
|
"normalize": pandocSetting("--normalize", "checkbox", "",
|
||||||
qApp.translate("Export", "Normalize the document (cleaner)"),
|
safeTranslate(qApp, "Export", "Normalize the document (cleaner)"),
|
||||||
minVersion="1.8", maxVersion="1.19.2.4"),
|
minVersion="1.8", maxVersion="1.19.2.4"),
|
||||||
# pandoc v1.5 to 2.7.3
|
# pandoc v1.5 to 2.7.3
|
||||||
"base-header": pandocSetting("--base-header-level=", "number", "",
|
"base-header": pandocSetting("--base-header-level=", "number", "",
|
||||||
qApp.translate("Export", "Specify the base level for headers: "),
|
safeTranslate(qApp, "Export", "Specify the base level for headers: "),
|
||||||
default=1, min=1, minVersion="1.5", maxVersion="2.7.3"),
|
default=1, min=1, minVersion="1.5", maxVersion="2.7.3"),
|
||||||
# pandoc v2.8+
|
# pandoc v2.8+
|
||||||
"shift-heading": pandocSetting("--shift-heading-level-by=", "number", "",
|
"shift-heading": pandocSetting("--shift-heading-level-by=", "number", "",
|
||||||
qApp.translate("Export", "Specify the base level for headers: "),
|
safeTranslate(qApp, "Export", "Specify the base level for headers: "),
|
||||||
default=0, min=0, minVersion="2.8"),
|
default=0, min=0, minVersion="2.8"),
|
||||||
"disable-YAML": pandocSetting("EXT-yaml_metadata_block", "checkbox", "",
|
"disable-YAML": pandocSetting("EXT-yaml_metadata_block", "checkbox", "",
|
||||||
qApp.translate("Export", "Disable YAML metadata block.\nUse that if you get YAML related error."),
|
safeTranslate(qApp, "Export", "Disable YAML metadata block.\nUse that if you get YAML related error."),
|
||||||
minVersion="1.12"),
|
minVersion="1.12"),
|
||||||
"hard-line-breaks": pandocSetting("EXT-hard_line_block", "checkbox", "",
|
"hard-line-breaks": pandocSetting("EXT-hard_line_block", "checkbox", "",
|
||||||
qApp.translate("Export", "Enable the support on markdown for line break on new line."),
|
safeTranslate(qApp, "Export", "Enable the support on markdown for line break on new line."),
|
||||||
minVersion="1.16"),
|
minVersion="1.16"),
|
||||||
|
|
||||||
# Specific
|
# Specific
|
||||||
"ref-link": pandocSetting("--reference-links", "checkbox", "markdown rst",
|
"ref-link": pandocSetting("--reference-links", "checkbox", "markdown rst",
|
||||||
qApp.translate("Export", "Use reference-style links instead of inline links"),
|
safeTranslate(qApp, "Export", "Use reference-style links instead of inline links"),
|
||||||
specific=True),
|
specific=True),
|
||||||
# pandoc v1.9 to v2.11.1
|
# pandoc v1.9 to v2.11.1
|
||||||
"atx": pandocSetting("--atx-headers", "checkbox", "markdown asciidoc",
|
"atx": pandocSetting("--atx-headers", "checkbox", "markdown asciidoc",
|
||||||
qApp.translate("Export", "Use ATX-style headers"), specific=True,
|
safeTranslate(qApp, "Export", "Use ATX-style headers"), specific=True,
|
||||||
minVersion="1.9", maxVersion="2.11.1"),
|
minVersion="1.9", maxVersion="2.11.1"),
|
||||||
# pandoc v2.11.2+
|
# pandoc v2.11.2+
|
||||||
"atx-heading": pandocSetting("--markdown-headings=atx|setext", "checkbox", "markdown asciidoc",
|
"atx-heading": pandocSetting("--markdown-headings=atx|setext", "checkbox", "markdown asciidoc",
|
||||||
qApp.translate("Export", "Use ATX-style headers"), specific=True,
|
safeTranslate(qApp, "Export", "Use ATX-style headers"), specific=True,
|
||||||
minVersion="2.11.2"),
|
minVersion="2.11.2"),
|
||||||
"self-contained": pandocSetting("--self-contained", "checkbox", "html",
|
"self-contained": pandocSetting("--self-contained", "checkbox", "html",
|
||||||
qApp.translate("Export", "Self-contained HTML files, with no dependencies"),
|
safeTranslate(qApp, "Export", "Self-contained HTML files, with no dependencies"),
|
||||||
specific=True, minVersion="1.9"),
|
specific=True, minVersion="1.9"),
|
||||||
"q-tags": pandocSetting("--html-q-tags", "checkbox", "html",
|
"q-tags": pandocSetting("--html-q-tags", "checkbox", "html",
|
||||||
qApp.translate("Export", "Use <q> tags for quotes in HTML"), specific=True,
|
safeTranslate(qApp, "Export", "Use <q> tags for quotes in HTML"), specific=True,
|
||||||
minVersion="1.10"),
|
minVersion="1.10"),
|
||||||
# pandoc v1 only
|
# pandoc v1 only
|
||||||
"latex-engine": pandocSetting("--latex-engine=", "combo", "pdf",
|
"latex-engine": pandocSetting("--latex-engine=", "combo", "pdf",
|
||||||
qApp.translate("Export", "LaTeX engine used to produce the PDF."),
|
safeTranslate(qApp, "Export", "LaTeX engine used to produce the PDF."),
|
||||||
vals="pdflatex|lualatex|xelatex", specific=True,
|
vals="pdflatex|lualatex|xelatex", specific=True,
|
||||||
minVersion="1.9", maxVersion="1.19.2.4"),
|
minVersion="1.9", maxVersion="1.19.2.4"),
|
||||||
# pandoc v2
|
# pandoc v2
|
||||||
"pdf-engine": pandocSetting("--pdf-engine=", "combo", "pdf",
|
"pdf-engine": pandocSetting("--pdf-engine=", "combo", "pdf",
|
||||||
qApp.translate("Export", "LaTeX engine used to produce the PDF."),
|
safeTranslate(qApp, "Export", "LaTeX engine used to produce the PDF."),
|
||||||
vals="pdflatex|lualatex|xelatex", minVersion="2.0", specific=True),
|
vals="pdflatex|lualatex|xelatex", minVersion="2.0", specific=True),
|
||||||
"epub3": pandocSetting("EXTepub3", "checkbox", "epub",
|
"epub3": pandocSetting("EXTepub3", "checkbox", "epub",
|
||||||
qApp.translate("Export", "Convert to ePUB3"), specific=True,
|
safeTranslate(qApp, "Export", "Convert to ePUB3"), specific=True,
|
||||||
minVersion="1.10"),
|
minVersion="1.10"),
|
||||||
|
|
||||||
# PDF
|
# PDF
|
||||||
"latex-ps": pandocSetting("--variable=papersize:", "combo", "pdf latex", # FIXME: does not work with default template
|
"latex-ps": pandocSetting("--variable=papersize:", "combo", "pdf latex", # FIXME: does not work with default template
|
||||||
qApp.translate("Export", "Paper size:"),
|
safeTranslate(qApp, "Export", "Paper size:"),
|
||||||
vals="letter|A4|A5", specific=True, minVersion="1.4"),
|
vals="letter|A4|A5", specific=True, minVersion="1.4"),
|
||||||
"latex-fs": pandocSetting("--variable=fontsize:", "number", "pdf latex", # FIXME: does not work with default template
|
"latex-fs": pandocSetting("--variable=fontsize:", "number", "pdf latex", # FIXME: does not work with default template
|
||||||
qApp.translate("Export", "Font size:"),
|
safeTranslate(qApp, "Export", "Font size:"),
|
||||||
min=8, max=88, default=12, suffix="pt", specific=True, minVersion="1.4"),
|
min=8, max=88, default=12, suffix="pt", specific=True, minVersion="1.4"),
|
||||||
"latex-class": pandocSetting("--variable=documentclass:", "combo", "pdf latex",
|
"latex-class": pandocSetting("--variable=documentclass:", "combo", "pdf latex",
|
||||||
qApp.translate("Export", "Class:"),
|
safeTranslate(qApp, "Export", "Class:"),
|
||||||
vals="article|report|book|memoir", specific=True, minVersion="1.4"),
|
vals="article|report|book|memoir", specific=True, minVersion="1.4"),
|
||||||
"latex-ls": pandocSetting("--variable=linestretch:", "combo", "pdf latex",
|
"latex-ls": pandocSetting("--variable=linestretch:", "combo", "pdf latex",
|
||||||
qApp.translate("Export", "Line spacing:"),
|
safeTranslate(qApp, "Export", "Line spacing:"),
|
||||||
vals="1|1.25|1.5|2", specific=True, minVersion="1.4"),
|
vals="1|1.25|1.5|2", specific=True, minVersion="1.4"),
|
||||||
|
|
||||||
# FIXME: complete with http://pandoc.org/README.html#variables-for-latex
|
# FIXME: complete with http://pandoc.org/README.html#variables-for-latex
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
from manuskript.exporter.pandoc.abstractOutput import abstractOutput
|
from manuskript.exporter.pandoc.abstractOutput import abstractOutput
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
|
|
||||||
class ePub(abstractOutput):
|
class ePub(abstractOutput):
|
||||||
name = "ePub"
|
name = "ePub"
|
||||||
description = qApp.translate("Export", """Books that don't kill trees.""")
|
description = safeTranslate(qApp, "Export", """Books that don't kill trees.""")
|
||||||
icon = "application-epub+zip"
|
icon = "application-epub+zip"
|
||||||
|
|
||||||
exportVarName = "lastPandocePub"
|
exportVarName = "lastPandocePub"
|
||||||
|
@ -18,7 +19,7 @@ class ePub(abstractOutput):
|
||||||
|
|
||||||
class OpenDocument(abstractOutput):
|
class OpenDocument(abstractOutput):
|
||||||
name = "OpenDocument"
|
name = "OpenDocument"
|
||||||
description = qApp.translate("Export", "OpenDocument format. Used by LibreOffice for example.")
|
description = safeTranslate(qApp, "Export", "OpenDocument format. Used by LibreOffice for example.")
|
||||||
|
|
||||||
exportVarName = "lastPandocODT"
|
exportVarName = "lastPandocODT"
|
||||||
toFormat = "odt"
|
toFormat = "odt"
|
||||||
|
@ -29,7 +30,7 @@ class OpenDocument(abstractOutput):
|
||||||
|
|
||||||
class DocX(abstractOutput):
|
class DocX(abstractOutput):
|
||||||
name = "DocX"
|
name = "DocX"
|
||||||
description = qApp.translate("Export", "Microsoft Office (.docx) document.")
|
description = safeTranslate(qApp, "Export", "Microsoft Office (.docx) document.")
|
||||||
|
|
||||||
exportVarName = "lastPandocDocX"
|
exportVarName = "lastPandocDocX"
|
||||||
toFormat = "docx"
|
toFormat = "docx"
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
from manuskript.exporter.pandoc.abstractPlainText import abstractPlainText
|
from manuskript.exporter.pandoc.abstractPlainText import abstractPlainText
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
|
|
||||||
class markdown(abstractPlainText):
|
class markdown(abstractPlainText):
|
||||||
name = "Markdown"
|
name = "Markdown"
|
||||||
description = qApp.translate("Export", """Export to markdown, using pandoc. Allows more formatting options
|
description = safeTranslate(qApp, "Export", """Export to markdown, using pandoc. Allows more formatting options
|
||||||
than the basic manuskript exporter.""")
|
than the basic manuskript exporter.""")
|
||||||
icon = "text-x-markdown"
|
icon = "text-x-markdown"
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ class markdown(abstractPlainText):
|
||||||
|
|
||||||
class reST(abstractPlainText):
|
class reST(abstractPlainText):
|
||||||
name = "reST"
|
name = "reST"
|
||||||
description = qApp.translate("Export", """reStructuredText is a lightweight markup language.""")
|
description = safeTranslate(qApp, "Export", """reStructuredText is a lightweight markup language.""")
|
||||||
|
|
||||||
exportVarName = "lastPandocreST"
|
exportVarName = "lastPandocreST"
|
||||||
toFormat = "rst"
|
toFormat = "rst"
|
||||||
|
@ -30,7 +31,7 @@ class reST(abstractPlainText):
|
||||||
|
|
||||||
class latex(abstractPlainText):
|
class latex(abstractPlainText):
|
||||||
name = "LaTeX"
|
name = "LaTeX"
|
||||||
description = qApp.translate("Export", """LaTeX is a word processor and document markup language used to create
|
description = safeTranslate(qApp, "Export", """LaTeX is a word processor and document markup language used to create
|
||||||
beautiful documents.""")
|
beautiful documents.""")
|
||||||
|
|
||||||
exportVarName = "lastPandocLatex"
|
exportVarName = "lastPandocLatex"
|
||||||
|
@ -42,7 +43,7 @@ class latex(abstractPlainText):
|
||||||
|
|
||||||
class OPML(abstractPlainText):
|
class OPML(abstractPlainText):
|
||||||
name = "OPML"
|
name = "OPML"
|
||||||
description = qApp.translate("Export", """The purpose of this format is to provide a way to exchange information
|
description = safeTranslate(qApp, "Export", """The purpose of this format is to provide a way to exchange information
|
||||||
between outliners and Internet services that can be browsed or controlled
|
between outliners and Internet services that can be browsed or controlled
|
||||||
through an outliner.""")
|
through an outliner.""")
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@ AUC = Qt.AutoConnection | Qt.UniqueConnection
|
||||||
MW = None
|
MW = None
|
||||||
|
|
||||||
|
|
||||||
|
def safeTranslate(qApp, group, text):
|
||||||
|
try:
|
||||||
|
return qApp.translate(group, text)
|
||||||
|
except:
|
||||||
|
return text
|
||||||
|
|
||||||
def wordCount(text):
|
def wordCount(text):
|
||||||
return len(re.findall(r"\S+", text))
|
return len(re.findall(r"\S+", text))
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import os
|
||||||
from manuskript.importer.abstractImporter import abstractImporter
|
from manuskript.importer.abstractImporter import abstractImporter
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,27 +96,27 @@ class folderImporter(abstractImporter):
|
||||||
|
|
||||||
# Add group
|
# Add group
|
||||||
group = self.addGroup(widget.toolBox.widget(0),
|
group = self.addGroup(widget.toolBox.widget(0),
|
||||||
qApp.translate("Import", "Folder import"))
|
safeTranslate(qApp, "Import", "Folder import"))
|
||||||
#group = cls.addPage(widget, "Folder import")
|
#group = cls.addPage(widget, "Folder import")
|
||||||
|
|
||||||
self.addSetting("info", "label",
|
self.addSetting("info", "label",
|
||||||
qApp.translate("Import", """<p><b>Info:</b> Imports a whole
|
safeTranslate(qApp, "Import", """<p><b>Info:</b> Imports a whole
|
||||||
directory structure. Folders are added as folders, and
|
directory structure. Folders are added as folders, and
|
||||||
plaintext documents within (you chose which ones by extension)
|
plaintext documents within (you chose which ones by extension)
|
||||||
are added as scene.</p>
|
are added as scene.</p>
|
||||||
<p>Only text files are supported (not images, binary or others).</p>"""))
|
<p>Only text files are supported (not images, binary or others).</p>"""))
|
||||||
|
|
||||||
self.addSetting("ext", "text",
|
self.addSetting("ext", "text",
|
||||||
qApp.translate("Import", "Include only those extensions:"),
|
safeTranslate(qApp, "Import", "Include only those extensions:"),
|
||||||
default="*.txt, *.md",
|
default="*.txt, *.md",
|
||||||
tooltip=qApp.translate("Import", "Comma separated values")),
|
tooltip=safeTranslate(qApp, "Import", "Comma separated values")),
|
||||||
|
|
||||||
self.addSetting("sortItems", "checkbox",
|
self.addSetting("sortItems", "checkbox",
|
||||||
qApp.translate("Import", "Sort items by name"),
|
safeTranslate(qApp, "Import", "Sort items by name"),
|
||||||
default=True),
|
default=True),
|
||||||
|
|
||||||
self.addSetting("separateFolderFiles", "checkbox",
|
self.addSetting("separateFolderFiles", "checkbox",
|
||||||
qApp.translate("Import", "Import folder then files"),
|
safeTranslate(qApp, "Import", "Import folder then files"),
|
||||||
default=True),
|
default=True),
|
||||||
|
|
||||||
self.addSettingsTo(group)
|
self.addSettingsTo(group)
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
from manuskript.importer.abstractImporter import abstractImporter
|
from manuskript.importer.abstractImporter import abstractImporter
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
import re, os
|
import re, os
|
||||||
|
|
||||||
|
@ -173,11 +175,11 @@ class markdownImporter(abstractImporter):
|
||||||
|
|
||||||
# Add group
|
# Add group
|
||||||
group = self.addGroup(widget.toolBox.widget(0),
|
group = self.addGroup(widget.toolBox.widget(0),
|
||||||
qApp.translate("Import", "Markdown import"))
|
safeTranslate(qApp, "Import", "Markdown import"))
|
||||||
#group = cls.addPage(widget, "Folder import")
|
#group = cls.addPage(widget, "Folder import")
|
||||||
|
|
||||||
self.addSetting("info", "label",
|
self.addSetting("info", "label",
|
||||||
qApp.translate("Import", """<b>Info:</b> A very simple
|
safeTranslate(qApp, "Import", """<b>Info:</b> A very simple
|
||||||
parser that will go through a markdown document and
|
parser that will go through a markdown document and
|
||||||
create items for each titles.<br/> """))
|
create items for each titles.<br/> """))
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,11 @@ from PyQt5.QtWidgets import qApp, QMessageBox
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow, safeTranslate
|
||||||
from manuskript.importer.abstractImporter import abstractImporter
|
from manuskript.importer.abstractImporter import abstractImporter
|
||||||
from manuskript.converters import HTML2MD, HTML2PlainText
|
from manuskript.converters import HTML2MD, HTML2PlainText
|
||||||
|
|
||||||
|
|
||||||
class mindMapImporter(abstractImporter):
|
class mindMapImporter(abstractImporter):
|
||||||
|
|
||||||
name = "Mind Map"
|
name = "Mind Map"
|
||||||
|
@ -54,8 +55,8 @@ class mindMapImporter(abstractImporter):
|
||||||
if not ret:
|
if not ret:
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
settingsWidget,
|
settingsWidget,
|
||||||
qApp.translate("Import", "Mind Map Import"),
|
safeTranslate(qApp, "Import", "Mind Map Import"),
|
||||||
qApp.translate("Import", "This does not appear to be a valid Mind Map file."))
|
safeTranslate(qApp, "Import", "This does not appear to be a valid Mind Map file."))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -68,10 +69,10 @@ class mindMapImporter(abstractImporter):
|
||||||
|
|
||||||
# Add group
|
# Add group
|
||||||
group = self.addGroup(widget.toolBox.widget(0),
|
group = self.addGroup(widget.toolBox.widget(0),
|
||||||
qApp.translate("Import", "Mind Map import"))
|
safeTranslate(qApp, "Import", "Mind Map import"))
|
||||||
|
|
||||||
self.addSetting("importTipAs", "combo",
|
self.addSetting("importTipAs", "combo",
|
||||||
qApp.translate("Import", "Import tip as:"),
|
safeTranslate(qApp, "Import", "Import tip as:"),
|
||||||
vals="Text|Folder",
|
vals="Text|Folder",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ class mindMapImporter(abstractImporter):
|
||||||
# Title
|
# Title
|
||||||
title = underElement.get('TEXT', "").replace("\n", " ")
|
title = underElement.get('TEXT', "").replace("\n", " ")
|
||||||
if not title:
|
if not title:
|
||||||
title = qApp.translate("Import", "Untitled")
|
title = safeTranslate(qApp, "Import", "Untitled")
|
||||||
|
|
||||||
item = outlineItem(parent=parentItem, title=title)
|
item = outlineItem(parent=parentItem, title=title)
|
||||||
items.append(item)
|
items.append(item)
|
||||||
|
|
|
@ -5,9 +5,10 @@ from PyQt5.QtWidgets import qApp, QMessageBox
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
from lxml import etree as ET
|
from lxml import etree as ET
|
||||||
from manuskript.functions import mainWindow
|
from manuskript.functions import mainWindow, safeTranslate
|
||||||
from manuskript.importer.abstractImporter import abstractImporter
|
from manuskript.importer.abstractImporter import abstractImporter
|
||||||
|
|
||||||
|
|
||||||
class opmlImporter(abstractImporter):
|
class opmlImporter(abstractImporter):
|
||||||
|
|
||||||
name = "OPML"
|
name = "OPML"
|
||||||
|
@ -34,8 +35,8 @@ class opmlImporter(abstractImporter):
|
||||||
opmlContent = opmlFile.read()
|
opmlContent = opmlFile.read()
|
||||||
except:
|
except:
|
||||||
QMessageBox.critical(settingsWidget,
|
QMessageBox.critical(settingsWidget,
|
||||||
qApp.translate("Import", "OPML Import"),
|
safeTranslate(qApp, "Import", "OPML Import"),
|
||||||
qApp.translate("Import", "File open failed."))
|
safeTranslate(qApp, "Import", "File open failed."))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
elif fromString == "":
|
elif fromString == "":
|
||||||
|
@ -63,8 +64,8 @@ class opmlImporter(abstractImporter):
|
||||||
if not ret:
|
if not ret:
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
settingsWidget,
|
settingsWidget,
|
||||||
qApp.translate("Import", "OPML Import"),
|
safeTranslate(qApp, "Import", "OPML Import"),
|
||||||
qApp.translate("Import", "This does not appear to be a valid OPML file."))
|
safeTranslate(qApp, "Import", "This does not appear to be a valid OPML file."))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ from manuskript.importer.abstractImporter import abstractImporter
|
||||||
from manuskript.exporter.pandoc import pandocExporter
|
from manuskript.exporter.pandoc import pandocExporter
|
||||||
from manuskript.importer.opmlImporter import opmlImporter
|
from manuskript.importer.opmlImporter import opmlImporter
|
||||||
from manuskript.importer.markdownImporter import markdownImporter
|
from manuskript.importer.markdownImporter import markdownImporter
|
||||||
|
from manuskript.functions import safeTranslate
|
||||||
|
|
||||||
from PyQt5.QtWidgets import qApp
|
from PyQt5.QtWidgets import qApp
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,10 +57,10 @@ class pandocImporter(abstractImporter):
|
||||||
|
|
||||||
# Add group
|
# Add group
|
||||||
group = self.addGroup(widget.toolBox.widget(0),
|
group = self.addGroup(widget.toolBox.widget(0),
|
||||||
qApp.translate("Import", "Pandoc import"))
|
safeTranslate(qApp, "Import", "Pandoc import"))
|
||||||
|
|
||||||
self.addSetting("info", "label",
|
self.addSetting("info", "label",
|
||||||
qApp.translate("Import", """<b>Info:</b> Manuskript can
|
safeTranslate(qApp, "Import", """<b>Info:</b> Manuskript can
|
||||||
import from <b>markdown</b> or <b>OPML</b>. Pandoc will
|
import from <b>markdown</b> or <b>OPML</b>. Pandoc will
|
||||||
convert your document to either (see option below), and
|
convert your document to either (see option below), and
|
||||||
then it will be imported in manuskript. One or the other
|
then it will be imported in manuskript. One or the other
|
||||||
|
@ -66,14 +68,14 @@ class pandocImporter(abstractImporter):
|
||||||
<br/> """))
|
<br/> """))
|
||||||
|
|
||||||
self.addSetting("formatTo", "combo",
|
self.addSetting("formatTo", "combo",
|
||||||
qApp.translate("Import", "Import using:"),
|
safeTranslate(qApp, "Import", "Import using:"),
|
||||||
vals="markdown|OPML")
|
vals="markdown|OPML")
|
||||||
|
|
||||||
self.addSetting("wrap", "combo",
|
self.addSetting("wrap", "combo",
|
||||||
qApp.translate("Import", "Wrap lines:"),
|
safeTranslate(qApp, "Import", "Wrap lines:"),
|
||||||
vals="auto|none|preserve",
|
vals="auto|none|preserve",
|
||||||
default="none",
|
default="none",
|
||||||
tooltip=qApp.translate("Import", """<p>Should pandoc create
|
tooltip=safeTranslate(qApp, "Import", """<p>Should pandoc create
|
||||||
cosmetic / non-semantic line-breaks?</p><p>
|
cosmetic / non-semantic line-breaks?</p><p>
|
||||||
<b>auto</b>: wraps at 72 characters.<br>
|
<b>auto</b>: wraps at 72 characters.<br>
|
||||||
<b>none</b>: no line wrap.<br>
|
<b>none</b>: no line wrap.<br>
|
||||||
|
|
|
@ -256,12 +256,12 @@ class outlineItem(abstractItem, searchableItem):
|
||||||
if not wc:
|
if not wc:
|
||||||
wc = 0
|
wc = 0
|
||||||
if goal:
|
if goal:
|
||||||
return qApp.translate("outlineItem", "{} words / {} ({})").format(
|
return F.safeTranslate(qApp, "outlineItem", "{} words / {} ({})").format(
|
||||||
locale.format_string("%d", wc, grouping=True),
|
locale.format_string("%d", wc, grouping=True),
|
||||||
locale.format_string("%d", goal, grouping=True),
|
locale.format_string("%d", goal, grouping=True),
|
||||||
"{}%".format(str(int(progress * 100))))
|
"{}%".format(str(int(progress * 100))))
|
||||||
else:
|
else:
|
||||||
return qApp.translate("outlineItem", "{} words").format(
|
return F.safeTranslate(qApp, "outlineItem", "{} words").format(
|
||||||
locale.format_string("%d", wc, grouping=True))
|
locale.format_string("%d", wc, grouping=True))
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
|
@ -19,7 +19,7 @@ from manuskript.enums import Outline
|
||||||
from manuskript.enums import Character
|
from manuskript.enums import Character
|
||||||
from manuskript.enums import Plot
|
from manuskript.enums import Plot
|
||||||
from manuskript.enums import PlotStep
|
from manuskript.enums import PlotStep
|
||||||
from manuskript.functions import mainWindow, mixColors
|
from manuskript.functions import mainWindow, mixColors, safeTranslate
|
||||||
from manuskript.ui import style as S
|
from manuskript.ui import style as S
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ def infos(ref):
|
||||||
"""
|
"""
|
||||||
match = re.fullmatch(RegEx, ref)
|
match = re.fullmatch(RegEx, ref)
|
||||||
if not match:
|
if not match:
|
||||||
return qApp.translate("references", "Not a reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Not a reference: {}.").format(ref)
|
||||||
|
|
||||||
_type = match.group(1)
|
_type = match.group(1)
|
||||||
_ref = match.group(2)
|
_ref = match.group(2)
|
||||||
|
@ -98,19 +98,19 @@ def infos(ref):
|
||||||
idx = m.getIndexByID(_ref)
|
idx = m.getIndexByID(_ref)
|
||||||
|
|
||||||
if not idx.isValid():
|
if not idx.isValid():
|
||||||
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Unknown reference: {}.").format(ref)
|
||||||
|
|
||||||
item = idx.internalPointer()
|
item = idx.internalPointer()
|
||||||
|
|
||||||
# Titles
|
# Titles
|
||||||
pathTitle = qApp.translate("references", "Path:")
|
pathTitle = safeTranslate(qApp, "references", "Path:")
|
||||||
statsTitle = qApp.translate("references", "Stats:")
|
statsTitle = safeTranslate(qApp, "references", "Stats:")
|
||||||
POVTitle = qApp.translate("references", "POV:")
|
POVTitle = safeTranslate(qApp, "references", "POV:")
|
||||||
statusTitle = qApp.translate("references", "Status:")
|
statusTitle = safeTranslate(qApp, "references", "Status:")
|
||||||
labelTitle = qApp.translate("references", "Label:")
|
labelTitle = safeTranslate(qApp, "references", "Label:")
|
||||||
ssTitle = qApp.translate("references", "Short summary:")
|
ssTitle = safeTranslate(qApp, "references", "Short summary:")
|
||||||
lsTitle = qApp.translate("references", "Long summary:")
|
lsTitle = safeTranslate(qApp, "references", "Long summary:")
|
||||||
notesTitle = qApp.translate("references", "Notes:")
|
notesTitle = safeTranslate(qApp, "references", "Notes:")
|
||||||
|
|
||||||
# The POV of the scene
|
# The POV of the scene
|
||||||
POV = ""
|
POV = ""
|
||||||
|
@ -191,30 +191,30 @@ def infos(ref):
|
||||||
m = mainWindow().mdlCharacter
|
m = mainWindow().mdlCharacter
|
||||||
c = m.getCharacterByID(int(_ref))
|
c = m.getCharacterByID(int(_ref))
|
||||||
if c == None:
|
if c == None:
|
||||||
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Unknown reference: {}.").format(ref)
|
||||||
|
|
||||||
index = c.index()
|
index = c.index()
|
||||||
|
|
||||||
name = c.name()
|
name = c.name()
|
||||||
|
|
||||||
# Titles
|
# Titles
|
||||||
basicTitle = qApp.translate("references", "Basic info")
|
basicTitle = safeTranslate(qApp, "references", "Basic info")
|
||||||
detailedTitle = qApp.translate("references", "Detailed info")
|
detailedTitle = safeTranslate(qApp, "references", "Detailed info")
|
||||||
POVof = qApp.translate("references", "POV of:")
|
POVof = safeTranslate(qApp, "references", "POV of:")
|
||||||
|
|
||||||
# Goto (link)
|
# Goto (link)
|
||||||
goto = qApp.translate("references", "Go to {}.")
|
goto = safeTranslate(qApp, "references", "Go to {}.")
|
||||||
goto = goto.format(refToLink(ref))
|
goto = goto.format(refToLink(ref))
|
||||||
|
|
||||||
# basic infos
|
# basic infos
|
||||||
basic = []
|
basic = []
|
||||||
for i in [
|
for i in [
|
||||||
(Character.motivation, qApp.translate("references", "Motivation"), False),
|
(Character.motivation, safeTranslate(qApp, "references", "Motivation"), False),
|
||||||
(Character.goal, qApp.translate("references", "Goal"), False),
|
(Character.goal, safeTranslate(qApp, "references", "Goal"), False),
|
||||||
(Character.conflict, qApp.translate("references", "Conflict"), False),
|
(Character.conflict, safeTranslate(qApp, "references", "Conflict"), False),
|
||||||
(Character.epiphany, qApp.translate("references", "Epiphany"), False),
|
(Character.epiphany, safeTranslate(qApp, "references", "Epiphany"), False),
|
||||||
(Character.summarySentence, qApp.translate("references", "Short summary"), True),
|
(Character.summarySentence, safeTranslate(qApp, "references", "Short summary"), True),
|
||||||
(Character.summaryPara, qApp.translate("references", "Longer summary"), True),
|
(Character.summaryPara, safeTranslate(qApp, "references", "Longer summary"), True),
|
||||||
]:
|
]:
|
||||||
|
|
||||||
val = m.data(index.sibling(index.row(), i[0].value))
|
val = m.data(index.sibling(index.row(), i[0].value))
|
||||||
|
@ -274,16 +274,16 @@ def infos(ref):
|
||||||
name = m.getPlotNameByID(_ref)
|
name = m.getPlotNameByID(_ref)
|
||||||
|
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Unknown reference: {}.").format(ref)
|
||||||
|
|
||||||
# Titles
|
# Titles
|
||||||
descriptionTitle = qApp.translate("references", "Description")
|
descriptionTitle = safeTranslate(qApp, "references", "Description")
|
||||||
resultTitle = qApp.translate("references", "Result")
|
resultTitle = safeTranslate(qApp, "references", "Result")
|
||||||
charactersTitle = qApp.translate("references", "Characters")
|
charactersTitle = safeTranslate(qApp, "references", "Characters")
|
||||||
stepsTitle = qApp.translate("references", "Resolution steps")
|
stepsTitle = safeTranslate(qApp, "references", "Resolution steps")
|
||||||
|
|
||||||
# Goto (link)
|
# Goto (link)
|
||||||
goto = qApp.translate("references", "Go to {}.")
|
goto = safeTranslate(qApp, "references", "Go to {}.")
|
||||||
goto = goto.format(refToLink(ref))
|
goto = goto.format(refToLink(ref))
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
@ -353,15 +353,15 @@ def infos(ref):
|
||||||
name = m.name(index)
|
name = m.name(index)
|
||||||
|
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Unknown reference: {}.").format(ref)
|
||||||
|
|
||||||
# Titles
|
# Titles
|
||||||
descriptionTitle = qApp.translate("references", "Description")
|
descriptionTitle = safeTranslate(qApp, "references", "Description")
|
||||||
passionTitle = qApp.translate("references", "Passion")
|
passionTitle = safeTranslate(qApp, "references", "Passion")
|
||||||
conflictTitle = qApp.translate("references", "Conflict")
|
conflictTitle = safeTranslate(qApp, "references", "Conflict")
|
||||||
|
|
||||||
# Goto (link)
|
# Goto (link)
|
||||||
goto = qApp.translate("references", "Go to {}.")
|
goto = safeTranslate(qApp, "references", "Go to {}.")
|
||||||
goto = goto.format(refToLink(ref))
|
goto = goto.format(refToLink(ref))
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
|
@ -396,7 +396,7 @@ def infos(ref):
|
||||||
return text
|
return text
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return qApp.translate("references", "Unknown reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Unknown reference: {}.").format(ref)
|
||||||
|
|
||||||
|
|
||||||
def shortInfos(ref):
|
def shortInfos(ref):
|
||||||
|
@ -495,28 +495,28 @@ def tooltip(ref):
|
||||||
infos = shortInfos(ref)
|
infos = shortInfos(ref)
|
||||||
|
|
||||||
if not infos:
|
if not infos:
|
||||||
return qApp.translate("references", "<b>Unknown reference:</b> {}.").format(ref)
|
return safeTranslate(qApp, "references", "<b>Unknown reference:</b> {}.").format(ref)
|
||||||
|
|
||||||
if infos == -1:
|
if infos == -1:
|
||||||
return qApp.translate("references", "Not a reference: {}.").format(ref)
|
return safeTranslate(qApp, "references", "Not a reference: {}.").format(ref)
|
||||||
|
|
||||||
|
|
||||||
if infos["type"] == TextLetter:
|
if infos["type"] == TextLetter:
|
||||||
if infos["text_type"] == "folder":
|
if infos["text_type"] == "folder":
|
||||||
tt = qApp.translate("references", "Folder: <b>{}</b>").format(infos["title"])
|
tt = safeTranslate(qApp, "references", "Folder: <b>{}</b>").format(infos["title"])
|
||||||
else:
|
else:
|
||||||
tt = qApp.translate("references", "Text: <b>{}</b>").format(infos["title"])
|
tt = safeTranslate(qApp, "references", "Text: <b>{}</b>").format(infos["title"])
|
||||||
tt += "<br><i>{}</i>".format(infos["path"])
|
tt += "<br><i>{}</i>".format(infos["path"])
|
||||||
return tt
|
return tt
|
||||||
|
|
||||||
elif infos["type"] == CharacterLetter:
|
elif infos["type"] == CharacterLetter:
|
||||||
return qApp.translate("references", "Character: <b>{}</b>").format(infos["title"])
|
return safeTranslate(qApp, "references", "Character: <b>{}</b>").format(infos["title"])
|
||||||
|
|
||||||
elif infos["type"] == PlotLetter:
|
elif infos["type"] == PlotLetter:
|
||||||
return qApp.translate("references", "Plot: <b>{}</b>").format(infos["title"])
|
return safeTranslate(qApp, "references", "Plot: <b>{}</b>").format(infos["title"])
|
||||||
|
|
||||||
elif infos["type"] == WorldLetter:
|
elif infos["type"] == WorldLetter:
|
||||||
return qApp.translate("references", "World: <b>{name}</b>{path}").format(
|
return safeTranslate(qApp, "references", "World: <b>{name}</b>{path}").format(
|
||||||
name=infos["title"],
|
name=infos["title"],
|
||||||
path=" <span style='color:gray;'>({})</span>".format(infos["path"]) if infos["path"] else "")
|
path=" <span style='color:gray;'>({})</span>".format(infos["path"]) if infos["path"] else "")
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ def findReferencesTo(ref, parent=None, recursive=True):
|
||||||
|
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
def listReferences(ref, title=qApp.translate("references", "Referenced in:")):
|
def listReferences(ref, title=safeTranslate(qApp, "references", "Referenced in:")):
|
||||||
oM = mainWindow().mdlOutline
|
oM = mainWindow().mdlOutline
|
||||||
listRefs = ""
|
listRefs = ""
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ from PyQt5.QtWidgets import QFrame, QWidget, QPushButton, qApp, QStyle, QComboBo
|
||||||
from manuskript import settings
|
from manuskript import settings
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.functions import allPaths, drawProgress
|
from manuskript.functions import allPaths, drawProgress, safeTranslate
|
||||||
from manuskript.ui.editors.locker import locker
|
from manuskript.ui.editors.locker import locker
|
||||||
from manuskript.ui.editors.themes import findThemePath, generateTheme, setThemeEditorDatas
|
from manuskript.ui.editors.themes import findThemePath, generateTheme, setThemeEditorDatas
|
||||||
from manuskript.ui.editors.themes import loadThemeDatas
|
from manuskript.ui.editors.themes import loadThemeDatas
|
||||||
|
@ -414,7 +414,7 @@ class fullScreenEditor(QWidget):
|
||||||
|
|
||||||
def createNewText(self):
|
def createNewText(self):
|
||||||
item = self._index.internalPointer()
|
item = self._index.internalPointer()
|
||||||
newItem = outlineItem(title=qApp.translate("outlineBasics", "New"), _type=settings.defaultTextType)
|
newItem = outlineItem(title=safeTranslate(qApp, "outlineBasics", "New"), _type=settings.defaultTextType)
|
||||||
self._index.model().insertItem(newItem, item.row() + 1, item.parent().index())
|
self._index.model().insertItem(newItem, item.row() + 1, item.parent().index())
|
||||||
self.setCurrentModelIndex(newItem.index())
|
self.setCurrentModelIndex(newItem.index())
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from PyQt5.QtWidgets import QAbstractItemView, qApp, QMenu, QAction, \
|
||||||
from manuskript import settings
|
from manuskript import settings
|
||||||
from manuskript.enums import Outline
|
from manuskript.enums import Outline
|
||||||
from manuskript.functions import mainWindow, statusMessage
|
from manuskript.functions import mainWindow, statusMessage
|
||||||
from manuskript.functions import toInt, customIcons
|
from manuskript.functions import toInt, customIcons, safeTranslate
|
||||||
from manuskript.models import outlineItem
|
from manuskript.models import outlineItem
|
||||||
from manuskript.ui.tools.splitDialog import splitDialog
|
from manuskript.ui.tools.splitDialog import splitDialog
|
||||||
|
|
||||||
|
@ -58,24 +58,24 @@ class outlineBasics(QAbstractItemView):
|
||||||
title = mouseIndex.internalPointer().title()
|
title = mouseIndex.internalPointer().title()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
title = qApp.translate("outlineBasics", "Root")
|
title = safeTranslate(qApp, "outlineBasics", "Root")
|
||||||
|
|
||||||
if len(title) > 25:
|
if len(title) > 25:
|
||||||
title = title[:25] + "…"
|
title = title[:25] + "…"
|
||||||
|
|
||||||
# Open Item action
|
# Open Item action
|
||||||
self.actOpen = QAction(QIcon.fromTheme("go-right"),
|
self.actOpen = QAction(QIcon.fromTheme("go-right"),
|
||||||
qApp.translate("outlineBasics", "Open {}".format(title)),
|
safeTranslate(qApp, "outlineBasics", "Open {}".format(title)),
|
||||||
menu)
|
menu)
|
||||||
self.actOpen.triggered.connect(self.openItem)
|
self.actOpen.triggered.connect(self.openItem)
|
||||||
menu.addAction(self.actOpen)
|
menu.addAction(self.actOpen)
|
||||||
|
|
||||||
# Open item(s) in new tab
|
# Open item(s) in new tab
|
||||||
if mouseIndex in sel and len(sel) > 1:
|
if mouseIndex in sel and len(sel) > 1:
|
||||||
actionTitle = qApp.translate("outlineBasics", "Open {} items in new tabs").format(len(sel))
|
actionTitle = safeTranslate(qApp, "outlineBasics", "Open {} items in new tabs").format(len(sel))
|
||||||
self._indexesToOpen = sel
|
self._indexesToOpen = sel
|
||||||
else:
|
else:
|
||||||
actionTitle = qApp.translate("outlineBasics", "Open {} in a new tab").format(title)
|
actionTitle = safeTranslate(qApp, "outlineBasics", "Open {} in a new tab").format(title)
|
||||||
self._indexesToOpen = [mouseIndex]
|
self._indexesToOpen = [mouseIndex]
|
||||||
|
|
||||||
self.actNewTab = QAction(QIcon.fromTheme("go-right"), actionTitle, menu)
|
self.actNewTab = QAction(QIcon.fromTheme("go-right"), actionTitle, menu)
|
||||||
|
@ -86,13 +86,13 @@ class outlineBasics(QAbstractItemView):
|
||||||
|
|
||||||
# Add text / folder
|
# Add text / folder
|
||||||
self.actAddFolder = QAction(QIcon.fromTheme("folder-new"),
|
self.actAddFolder = QAction(QIcon.fromTheme("folder-new"),
|
||||||
qApp.translate("outlineBasics", "New &Folder"),
|
safeTranslate(qApp, "outlineBasics", "New &Folder"),
|
||||||
menu)
|
menu)
|
||||||
self.actAddFolder.triggered.connect(self.addFolder)
|
self.actAddFolder.triggered.connect(self.addFolder)
|
||||||
menu.addAction(self.actAddFolder)
|
menu.addAction(self.actAddFolder)
|
||||||
|
|
||||||
self.actAddText = QAction(QIcon.fromTheme("document-new"),
|
self.actAddText = QAction(QIcon.fromTheme("document-new"),
|
||||||
qApp.translate("outlineBasics", "New &Text"),
|
safeTranslate(qApp, "outlineBasics", "New &Text"),
|
||||||
menu)
|
menu)
|
||||||
self.actAddText.triggered.connect(self.addText)
|
self.actAddText.triggered.connect(self.addText)
|
||||||
menu.addAction(self.actAddText)
|
menu.addAction(self.actAddText)
|
||||||
|
@ -101,29 +101,29 @@ class outlineBasics(QAbstractItemView):
|
||||||
|
|
||||||
# Copy, cut, paste, duplicate
|
# Copy, cut, paste, duplicate
|
||||||
self.actCut = QAction(QIcon.fromTheme("edit-cut"),
|
self.actCut = QAction(QIcon.fromTheme("edit-cut"),
|
||||||
qApp.translate("outlineBasics", "C&ut"), menu)
|
safeTranslate(qApp, "outlineBasics", "C&ut"), menu)
|
||||||
self.actCut.triggered.connect(self.cut)
|
self.actCut.triggered.connect(self.cut)
|
||||||
menu.addAction(self.actCut)
|
menu.addAction(self.actCut)
|
||||||
|
|
||||||
self.actCopy = QAction(QIcon.fromTheme("edit-copy"),
|
self.actCopy = QAction(QIcon.fromTheme("edit-copy"),
|
||||||
qApp.translate("outlineBasics", "&Copy"), menu)
|
safeTranslate(qApp, "outlineBasics", "&Copy"), menu)
|
||||||
self.actCopy.triggered.connect(self.copy)
|
self.actCopy.triggered.connect(self.copy)
|
||||||
menu.addAction(self.actCopy)
|
menu.addAction(self.actCopy)
|
||||||
|
|
||||||
self.actPaste = QAction(QIcon.fromTheme("edit-paste"),
|
self.actPaste = QAction(QIcon.fromTheme("edit-paste"),
|
||||||
qApp.translate("outlineBasics", "&Paste"), menu)
|
safeTranslate(qApp, "outlineBasics", "&Paste"), menu)
|
||||||
self.actPaste.triggered.connect(self.paste)
|
self.actPaste.triggered.connect(self.paste)
|
||||||
menu.addAction(self.actPaste)
|
menu.addAction(self.actPaste)
|
||||||
|
|
||||||
# Rename / duplicate / remove items
|
# Rename / duplicate / remove items
|
||||||
self.actDelete = QAction(QIcon.fromTheme("edit-delete"),
|
self.actDelete = QAction(QIcon.fromTheme("edit-delete"),
|
||||||
qApp.translate("outlineBasics", "&Delete"),
|
safeTranslate(qApp, "outlineBasics", "&Delete"),
|
||||||
menu)
|
menu)
|
||||||
self.actDelete.triggered.connect(self.delete)
|
self.actDelete.triggered.connect(self.delete)
|
||||||
menu.addAction(self.actDelete)
|
menu.addAction(self.actDelete)
|
||||||
|
|
||||||
self.actRename = QAction(QIcon.fromTheme("edit-rename"),
|
self.actRename = QAction(QIcon.fromTheme("edit-rename"),
|
||||||
qApp.translate("outlineBasics", "&Rename"),
|
safeTranslate(qApp, "outlineBasics", "&Rename"),
|
||||||
menu)
|
menu)
|
||||||
self.actRename.triggered.connect(self.rename)
|
self.actRename.triggered.connect(self.rename)
|
||||||
menu.addAction(self.actRename)
|
menu.addAction(self.actRename)
|
||||||
|
@ -131,17 +131,17 @@ class outlineBasics(QAbstractItemView):
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
|
|
||||||
# POV
|
# POV
|
||||||
self.menuPOV = QMenu(qApp.translate("outlineBasics", "Set POV"), menu)
|
self.menuPOV = QMenu(safeTranslate(qApp, "outlineBasics", "Set POV"), menu)
|
||||||
mw = mainWindow()
|
mw = mainWindow()
|
||||||
a = QAction(QIcon.fromTheme("dialog-no"), qApp.translate("outlineBasics", "None"), self.menuPOV)
|
a = QAction(QIcon.fromTheme("dialog-no"), safeTranslate(qApp, "outlineBasics", "None"), self.menuPOV)
|
||||||
a.triggered.connect(lambda: self.setPOV(""))
|
a.triggered.connect(lambda: self.setPOV(""))
|
||||||
self.menuPOV.addAction(a)
|
self.menuPOV.addAction(a)
|
||||||
self.menuPOV.addSeparator()
|
self.menuPOV.addSeparator()
|
||||||
|
|
||||||
menus = []
|
menus = []
|
||||||
for i in [qApp.translate("outlineBasics", "Main"),
|
for i in [safeTranslate(qApp, "outlineBasics", "Main"),
|
||||||
qApp.translate("outlineBasics", "Secondary"),
|
safeTranslate(qApp, "outlineBasics", "Secondary"),
|
||||||
qApp.translate("outlineBasics", "Minor")]:
|
safeTranslate(qApp, "outlineBasics", "Minor")]:
|
||||||
m = QMenu(i, self.menuPOV)
|
m = QMenu(i, self.menuPOV)
|
||||||
menus.append(m)
|
menus.append(m)
|
||||||
self.menuPOV.addMenu(m)
|
self.menuPOV.addMenu(m)
|
||||||
|
@ -160,8 +160,8 @@ class outlineBasics(QAbstractItemView):
|
||||||
menu.addMenu(self.menuPOV)
|
menu.addMenu(self.menuPOV)
|
||||||
|
|
||||||
# Status
|
# Status
|
||||||
self.menuStatus = QMenu(qApp.translate("outlineBasics", "Set Status"), menu)
|
self.menuStatus = QMenu(safeTranslate(qApp, "outlineBasics", "Set Status"), menu)
|
||||||
# a = QAction(QIcon.fromTheme("dialog-no"), qApp.translate("outlineBasics", "None"), self.menuStatus)
|
# a = QAction(QIcon.fromTheme("dialog-no"), safeTranslate(qApp, "outlineBasics", "None"), self.menuStatus)
|
||||||
# a.triggered.connect(lambda: self.setStatus(""))
|
# a.triggered.connect(lambda: self.setStatus(""))
|
||||||
# self.menuStatus.addAction(a)
|
# self.menuStatus.addAction(a)
|
||||||
# self.menuStatus.addSeparator()
|
# self.menuStatus.addSeparator()
|
||||||
|
@ -176,7 +176,7 @@ class outlineBasics(QAbstractItemView):
|
||||||
menu.addMenu(self.menuStatus)
|
menu.addMenu(self.menuStatus)
|
||||||
|
|
||||||
# Labels
|
# Labels
|
||||||
self.menuLabel = QMenu(qApp.translate("outlineBasics", "Set Label"), menu)
|
self.menuLabel = QMenu(safeTranslate(qApp, "outlineBasics", "Set Label"), menu)
|
||||||
mpr = QSignalMapper(self.menuLabel)
|
mpr = QSignalMapper(self.menuLabel)
|
||||||
for i in range(mw.mdlLabels.rowCount()):
|
for i in range(mw.mdlLabels.rowCount()):
|
||||||
a = QAction(mw.mdlLabels.item(i, 0).icon(),
|
a = QAction(mw.mdlLabels.item(i, 0).icon(),
|
||||||
|
@ -194,8 +194,8 @@ class outlineBasics(QAbstractItemView):
|
||||||
if self.menuCustomIcons:
|
if self.menuCustomIcons:
|
||||||
menu.addMenu(self.menuCustomIcons)
|
menu.addMenu(self.menuCustomIcons)
|
||||||
else:
|
else:
|
||||||
self.menuCustomIcons = QMenu(qApp.translate("outlineBasics", "Set Custom Icon"), menu)
|
self.menuCustomIcons = QMenu(safeTranslate(qApp, "outlineBasics", "Set Custom Icon"), menu)
|
||||||
a = QAction(qApp.translate("outlineBasics", "Restore to default"), self.menuCustomIcons)
|
a = QAction(safeTranslate(qApp, "outlineBasics", "Restore to default"), self.menuCustomIcons)
|
||||||
a.triggered.connect(lambda: self.setCustomIcon(""))
|
a.triggered.connect(lambda: self.setCustomIcon(""))
|
||||||
self.menuCustomIcons.addAction(a)
|
self.menuCustomIcons.addAction(a)
|
||||||
self.menuCustomIcons.addSeparator()
|
self.menuCustomIcons.addSeparator()
|
||||||
|
@ -280,7 +280,7 @@ class outlineBasics(QAbstractItemView):
|
||||||
if _type == "text":
|
if _type == "text":
|
||||||
_type = settings.defaultTextType
|
_type = settings.defaultTextType
|
||||||
|
|
||||||
item = outlineItem(title=qApp.translate("outlineBasics", "New"), _type=_type)
|
item = outlineItem(title=safeTranslate(qApp, "outlineBasics", "New"), _type=_type)
|
||||||
self.model().appendItem(item, parent)
|
self.model().appendItem(item, parent)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
|
@ -312,7 +312,7 @@ class outlineBasics(QAbstractItemView):
|
||||||
if not settings.dontShowDeleteWarning:
|
if not settings.dontShowDeleteWarning:
|
||||||
msgInfo = list()
|
msgInfo = list()
|
||||||
msgInfo.append("<p><b>")
|
msgInfo.append("<p><b>")
|
||||||
msgInfo.append(qApp.translate("outlineBasics", "You're about to delete {} item(s).").format(
|
msgInfo.append(safeTranslate(qApp, "outlineBasics", "You're about to delete {} item(s).").format(
|
||||||
len(self.getSelection())
|
len(self.getSelection())
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -322,11 +322,11 @@ class outlineBasics(QAbstractItemView):
|
||||||
msgInfo.append("<li>{}</li>".format(str(title)))
|
msgInfo.append("<li>{}</li>".format(str(title)))
|
||||||
|
|
||||||
msgInfo.append("</ul><p>")
|
msgInfo.append("</ul><p>")
|
||||||
msgInfo.append(qApp.translate("outlineBasics", "Are you sure?"))
|
msgInfo.append(safeTranslate(qApp, "outlineBasics", "Are you sure?"))
|
||||||
msgInfo.append("</p>")
|
msgInfo.append("</p>")
|
||||||
|
|
||||||
msg = QMessageBox(QMessageBox.Warning,
|
msg = QMessageBox(QMessageBox.Warning,
|
||||||
qApp.translate("outlineBasics", "About to remove"),
|
safeTranslate(qApp, "outlineBasics", "About to remove"),
|
||||||
"".join(msgInfo),
|
"".join(msgInfo),
|
||||||
QMessageBox.Yes | QMessageBox.Cancel)
|
QMessageBox.Yes | QMessageBox.Cancel)
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ class outlineBasics(QAbstractItemView):
|
||||||
|
|
||||||
# Check that we have at least 2 items
|
# Check that we have at least 2 items
|
||||||
if len(items) < 2:
|
if len(items) < 2:
|
||||||
statusMessage(qApp.translate("outlineBasics",
|
statusMessage(safeTranslate(qApp, "outlineBasics",
|
||||||
"Select at least two items. Folders are ignored."),
|
"Select at least two items. Folders are ignored."),
|
||||||
importance=2)
|
importance=2)
|
||||||
return
|
return
|
||||||
|
@ -440,7 +440,7 @@ class outlineBasics(QAbstractItemView):
|
||||||
p = items[0].parent()
|
p = items[0].parent()
|
||||||
for i in items:
|
for i in items:
|
||||||
if i.parent() != p:
|
if i.parent() != p:
|
||||||
statusMessage(qApp.translate("outlineBasics",
|
statusMessage(safeTranslate(qApp, "outlineBasics",
|
||||||
"All items must be on the same level (share the same parent)."),
|
"All items must be on the same level (share the same parent)."),
|
||||||
importance=2)
|
importance=2)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue