Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/PYMD/_pymd.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from ._converter import Converter
from ._files_manager import FileManager
from .db_manager import db_manage
from chromologger import Logger as Log
from .interface import run
import sys


log:Log = Log('./logs/log_pymd')

Expand All @@ -13,4 +9,6 @@
class Pymd:
@staticmethod
def run_app():
db_manage.database_config()
from .interface import run
run()
14 changes: 0 additions & 14 deletions src/PYMD/database/_db.py

This file was deleted.

File renamed without changes.
15 changes: 15 additions & 0 deletions src/PYMD/db_manager/db_manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from sqlazo import Database
from chromologger import Logger as Log

log = Log('./log.log')

def database_config():
db = Database('./db_manager/config.db', False)
# Query to validate that the table exists
validate_query = db.get_data_where('config_ui', 'id == 1')
if validate_query is None:
cols_config: list[str] = ['id INTEGER PRIMARY KEY', 'name TEXT NOT NULL', 'value TEXT NOT NULL']
db.create_table('config_ui', cols_config)
db.insert_data(['current_lang_code', 'es_CO'], ['name', 'value'], 'config_ui')
db.insert_data(['last_directory_open', 'C:/'], ['name', 'value'], 'config_ui')
db.insert_data(['last_directory_output', 'C:/'], ['name', 'value'], 'config_ui')
16 changes: 12 additions & 4 deletions src/PYMD/interface/_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Feature: Change focus order (the exit dialog focus is "ok", should be "cancel")

db = Database('./database/config.db', False)
db = Database('./db_manager/config.db', False)
log:Log = Log('./logs/log_interface')

app = QApplication(sys.argv)
Expand All @@ -29,8 +29,8 @@ def __init__(self, parent=None):
super().__init__(parent)
self.__closed_ui:bool = False
self.current_lang = lang_manager.lang_code
lang_manager.set_super_parent(self)
self.ui: Ui_MainWindow = Ui_MainWindow()
lang_manager.set_super_parent(self)
self.ui.setupUi(self)
self.__listeners()
# Hide views temporally (to Show initial help)
Expand Down Expand Up @@ -71,10 +71,12 @@ def __open_file(self):
# Save last directory
print(self.__filename.absolute().parent.__str__())
db.insert_data(['last_directory_open', self.__filename.absolute().parent.__str__()], ['name', 'value'], 'config_ui')

# Feature: Show progress bar
# => Can be a Label image (hide initialHelp if all ok, continue else show initialHelp again)
__converter:Converter = Converter(self.__filename.absolute().__str__())
__content:str | None = __converter.convert_file().data_str

if __content is not None:
self.__init_help.hide()
self.ui.frame_views.show()
Expand Down Expand Up @@ -113,7 +115,7 @@ def __extensions(self) -> str:

def __exit(self, event_target: QCloseEvent | None = None):
__result:int = self.__box_dialog(self.tr('Close Program'),self.tr('Do you want to close this program?'),{'ok': self.tr('Accept')}).exec()
print(__result)

if __result == 1024:
self.__closed_ui = True
self.close()
Expand All @@ -129,11 +131,15 @@ def __language(self):
if self.ui.text_preview_mode.isVisible():
# Show a warning dialog before change language
__result = self.__box_dialog(self.tr('Warning'), self.tr('Extracted content will be deleted once you change the language (unless you have already saved it)'),{'ok': self.tr('Accept')}).exec()

if not self.ui.text_preview_mode.isVisible() or __result == 1024:
#Feature: Save content in a temporal file (The content is removed when language change)
lang_manager.show_dialog()
#Update UI language

#Update UI language (MainWindow > childs and Language Dialog)
self.ui.retranslateUi(self)
lang_manager.lang_dialog.retranslateUi(lang_manager)

self.current_lang = lang_manager.lang_code
# When initial info screen is visible
if self.__init_help.info.isVisible(): self.__init_help.load_info(self.current_lang)
Expand All @@ -149,10 +155,12 @@ def __box_dialog(self, title:str = '', text:str = '', buttons_cancel_ok:dict | N
__dialog.setWindowIcon(__icon)
__dialog.setWindowTitle(title)
__dialog.setText(text)

# Has been received a dict with buttons
if buttons_cancel_ok is not None and type(buttons_cancel_ok) is dict:
if 'ok' in buttons_cancel_ok: __buttons_txt[0] = buttons_cancel_ok['ok']
if 'cancel' in buttons_cancel_ok: __buttons_txt[1] = buttons_cancel_ok['cancel']

# Set visible text for each button
__dialog.button(__dialog.StandardButton.Ok).setText(__buttons_txt[0])
__dialog.button(__dialog.StandardButton.Cancel).setText(__buttons_txt[1])
Expand Down
20 changes: 12 additions & 8 deletions src/PYMD/interface/_lang.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from PySide6.QtCore import Qt, QTranslator, QLocale
from PySide6.QtWidgets import QApplication
from PySide6.QtWidgets import QApplication, QMainWindow
from .ui_dialog_language import Ui_Lang_Dialog
from PySide6.QtWidgets import QDialog
from sqlazo import Database

db = Database('./database/config.db', False)
db = Database('./db_manager/config.db', False)

class LanguageManager(QDialog):
def __init__(self, app:QApplication=None):
Expand All @@ -14,19 +14,23 @@ def __init__(self, app:QApplication=None):
self.lang_file:str = ''
self.__translator:QTranslator = QTranslator(app)
self.__app:QApplication = app
self.parent = None
self.__lang_dialog = None
self.parent:QMainWindow | None = None
self.lang_dialog:Ui_Lang_Dialog | None = None

def set_super_parent(self, parent):
self.parent = parent
super().__init__(self.parent)
self.__lang_dialog = Ui_Lang_Dialog()
self.__lang_dialog.setupUi(self)
self.lang_dialog = Ui_Lang_Dialog()
self.lang_dialog.setupUi(self)

def show_dialog(self):
__buttons_dialog = self.lang_dialog.dialog_btn
__buttons_dialog.setStandardButtons(__buttons_dialog.StandardButton.Ok | __buttons_dialog.StandardButton.Cancel)
__buttons_dialog.button(__buttons_dialog.StandardButton.Ok).setText(self.tr('Save'))
__buttons_dialog.button(__buttons_dialog.StandardButton.Cancel).setText(self.tr('Cancel'))
self.exec()
if self.result() == 1 and self.__lang_dialog.languages.currentItem() is not None:
self.lang_code:str = self.__lang_dialog.languages.currentItem().toolTip()
if self.result() == 1 and self.lang_dialog.languages.currentItem() is not None:
self.lang_code:str = self.lang_dialog.languages.currentItem().toolTip()
# Pending improvement (when 'update_data' is added to 'sqlazo')
db.delete_data('config_ui', 'name == "current_lang_code"')
db.insert_data(['current_lang_code', self.lang_code], ['name', 'value'], 'config_ui')
Expand Down
Binary file modified src/PYMD/interface/translations/locale/pymd_en_GB.qm
Binary file not shown.
133 changes: 108 additions & 25 deletions src/PYMD/interface/translations/locale/pymd_en_GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,91 @@
<translation>Spanish - CO</translation>
</message>
</context>
<context>
<name>LanguageManager</name>
<message>
<location filename="../../_lang.py" line="29"/>
<source>Save</source>
<translation>Save</translation>
</message>
<message>
<location filename="../../_lang.py" line="30"/>
<source>Cancel</source>
<translation>Cancel</translation>
</message>
</context>
<context>
<name>MainWindow</name>
<message>
<location filename="../../_interface.py" line="59"/>
<location filename="../../_interface.py" line="67"/>
<location filename="../../main_window.ui" line="366"/>
<location filename="../../main_window.ui" line="1473"/>
<source>Open File</source>
<translation>Open File</translation>
</message>
<message>
<location filename="../../_interface.py" line="59"/>
<source>Select a file (*pdf *html *docx)</source>
<translation>Select a file (*pdf *html *docx)</translation>
<translation type="vanished">Select a file (*pdf *html *docx)</translation>
</message>
<message>
<location filename="../../_interface.py" line="66"/>
<source>Select a file</source>
<translation>Select a file</translation>
</message>
<message>
<location filename="../../_interface.py" line="78"/>
<location filename="../../_interface.py" line="85"/>
<location filename="../../_interface.py" line="102"/>
<location filename="../../_interface.py" line="131"/>
<source>Warning</source>
<translation>Warning</translation>
</message>
<message>
<location filename="../../_interface.py" line="85"/>
<source>The file does not contain plain text (make sure the file content is not just images)</source>
<translation>The file does not contain plain text (make sure the file content is not just images)</translation>
</message>
<message>
<location filename="../../_interface.py" line="94"/>
<source>Select a directory</source>
<translation>Select a directory</translation>
</message>
<message>
<location filename="../../_interface.py" line="102"/>
<source>The file is empty</source>
<translation>The file is empty</translation>
</message>
<message>
<location filename="../../_interface.py" line="102"/>
<location filename="../../_interface.py" line="115"/>
<location filename="../../_interface.py" line="131"/>
<source>Accept</source>
<translation>Accept</translation>
</message>
<message>
<location filename="../../_interface.py" line="115"/>
<source>Close Program</source>
<translation>Close Program</translation>
</message>
<message>
<location filename="../../_interface.py" line="79"/>
<location filename="../../_interface.py" line="115"/>
<source>Do you want to close this program?</source>
<translation>Do you want to close this program?</translation>
</message>
<message>
<location filename="../../_interface.py" line="131"/>
<source>Extracted content will be deleted once you change the language (unless you have already saved it)</source>
<translation>Extracted content will be deleted once you change the language (unless you have already saved it)</translation>
</message>
<message>
<location filename="../../_interface.py" line="148"/>
<source>Ok</source>
<translation>Ok</translation>
</message>
<message>
<location filename="../../_interface.py" line="149"/>
<source>Cancel</source>
<translation>Cancel</translation>
</message>
<message>
<location filename="../../main_window.ui" line="246"/>
<source>PYMD - SRM &amp; TRG</source>
Expand All @@ -63,18 +124,6 @@
<source>Markdown</source>
<translation>Markdown</translation>
</message>
<message>
<location filename="../../main_window.ui" line="518"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Gabriola&apos;; font-size:12pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation></translation>
</message>
<message>
<location filename="../../main_window.ui" line="541"/>
<source>Preview</source>
Expand Down Expand Up @@ -110,9 +159,32 @@ li.checked::marker { content: &quot;\2612&quot;; }
<translation>Menu</translation>
</message>
<message>
<location filename="../../main_window.ui" line="1434"/>
<source>Settings</source>
<translation>Settings</translation>
<translation type="vanished">Settings</translation>
</message>
<message>
<location filename="../../main_window.ui" line="518"/>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Times New Roman&apos;; font-size:12pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:&apos;Gabriola&apos;;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Times New Roman&apos;; font-size:12pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:&apos;Gabriola&apos;;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
</message>
<message>
<location filename="../../main_window.ui" line="1434"/>
<source>Preferences</source>
<translation>Preferences</translation>
</message>
<message>
<location filename="../../main_window.ui" line="1453"/>
Expand Down Expand Up @@ -170,17 +242,29 @@ li.checked::marker { content: &quot;\2612&quot;; }
<translation>Open Source Licences</translation>
</message>
</context>
<context>
<name>OSL</name>
<message>
<location filename="../../_osl.py" line="25"/>
<source>{__name_library.capitalize()} - original: {__links[__name_library.lower()]}</source>
<translation>{__name_library.capitalize()} - original: {__links[__name_library.lower()]}</translation>
</message>
</context>
<context>
<name>about_dialog</name>
<message>
<location filename="../../dialog_about.ui" line="20"/>
<location filename="../../dialog_about.ui" line="21"/>
<source>About</source>
<translation>About</translation>
</message>
<message>
<location filename="../../dialog_about.ui" line="63"/>
<location filename="../../dialog_about.ui" line="88"/>
<source>&lt;code&gt;pip install pymd&lt;/code&gt;</source>
<translation>&lt;code&gt;pip install pymd&lt;/code&gt;</translation>
</message>
<message>
<source>PYMD</source>
<translation>PYMD</translation>
<translation type="vanished">PYMD</translation>
</message>
</context>
<context>
Expand All @@ -207,12 +291,11 @@ li.checked::marker { content: &quot;\2612&quot;; }
<translation>PySide6</translation>
</message>
<message>
<location filename="../../osl.ui" line="85"/>
<source>Markdown</source>
<translation>Markdown</translation>
<translation type="vanished">Markdown</translation>
</message>
<message>
<location filename="../../osl.ui" line="195"/>
<location filename="../../osl.ui" line="190"/>
<source>CREDITS</source>
<translation>CREDITS</translation>
</message>
Expand Down
Binary file modified src/PYMD/interface/translations/locale/pymd_es_CO.qm
Binary file not shown.
Loading