Rename python-chordpro to igitar

This commit is contained in:
Raoul Snyman 2022-04-07 21:32:27 -07:00
parent 54e0af1915
commit 0d2010d05f
Signed by: raoul
GPG Key ID: F55BCED79626AE9C
3 changed files with 19 additions and 11 deletions

View File

@ -2,7 +2,7 @@
from functools import partial from functools import partial
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
from chordpro.renderers.html import get_options, get_option_groups from igitar.renderers.html import get_options, get_option_groups
from ukatali.util import coerce_bool, convert_units from ukatali.util import coerce_bool, convert_units

View File

@ -1,7 +1,7 @@
import re import re
from PyQt5 import QtCore, QtGui, QtWidgets, Qsci from PyQt5 import QtCore, QtGui, QtWidgets, Qsci
from chordpro.constants import KNOWN_DIRECTIVES, KNOWN_VERSE_TYPES from igitar.constants import KNOWN_DIRECTIVES, KNOWN_VERSE_TYPES
PALETTE_ROLES = { PALETTE_ROLES = {
'window': QtGui.QPalette.WindowText, 'window': QtGui.QPalette.WindowText,

View File

@ -2,8 +2,8 @@
from pathlib import Path from pathlib import Path
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets, Qsci, QtPrintSupport from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets, Qsci, QtPrintSupport
from chordpro import Song from igitar import Song
from chordpro.renderers.html import render, get_options from igitar.renderers.html import render, get_options
from ukatali.configuredialog import ConfigureDialog from ukatali.configuredialog import ConfigureDialog
from ukatali.lexer import ChordProLexer from ukatali.lexer import ChordProLexer
@ -345,13 +345,16 @@ class MainWindow(QtWidgets.QMainWindow):
options = self._get_render_options(self.is_lyrics_mode) options = self._get_render_options(self.is_lyrics_mode)
text = self.file_editor.text() text = self.file_editor.text()
song = Song() song = Song()
try:
song.parse(text) song.parse(text)
return render(song, options, extra_styles) return render(song, options, extra_styles)
except Exception:
return None
def on_text_changed(self): def on_text_changed(self):
"""Update the preview when the text changes""" """Update the preview when the text changes"""
# self.setWindowModified(True)
html = self._render_song() html = self._render_song()
if html:
self.preview_view.setHtml(html) self.preview_view.setHtml(html)
def on_export_pdf_clicked(self): def on_export_pdf_clicked(self):
@ -404,9 +407,14 @@ class MainWindow(QtWidgets.QMainWindow):
# Export to HTML # Export to HTML
try: try:
with filename.open('w') as html_file: with filename.open('w') as html_file:
html_file.write(self._render_song()) html = self._render_song()
if html:
html_file.write(html)
QtWidgets.QMessageBox.information(self, 'Export to HTML Successful', QtWidgets.QMessageBox.information(self, 'Export to HTML Successful',
'Successfully exported to "{}"'.format(filename.name)) 'Successfully exported to "{}"'.format(filename.name))
else:
QtWidgets.QMessageBox.critical(self, 'Error Exporting to HTML',
'There was an error while exporting to HTML')
except Exception as e: except Exception as e:
QtWidgets.QMessageBox.critical(self, 'Error Exporting to HTML', QtWidgets.QMessageBox.critical(self, 'Error Exporting to HTML',
'There was an error while exporting to HTML:\n{e}'.format(e=e)) 'There was an error while exporting to HTML:\n{e}'.format(e=e))