bridgex 0.0.1.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bridgex/NOTICE +28 -0
- bridgex/OSL/LICENSE_MARKITDOWN +21 -0
- bridgex/OSL/LICENSE_PYSIDE6 +165 -0
- bridgex/OSL/url_licenses.srm +4 -0
- bridgex/__init__.py +9 -0
- bridgex/__main__.py +7 -0
- bridgex/_bridgex.py +16 -0
- bridgex/database/Manager.py +22 -0
- bridgex/database/__init__.py +0 -0
- bridgex/interface/__init__.py +6 -0
- bridgex/interface/_about.py +20 -0
- bridgex/interface/_initialHelp.py +31 -0
- bridgex/interface/_interface.py +232 -0
- bridgex/interface/_lang.py +46 -0
- bridgex/interface/_osl.py +30 -0
- bridgex/interface/assets/img/gh-logo.png +0 -0
- bridgex/interface/assets/img/language/en_GB.svg +7 -0
- bridgex/interface/assets/img/language/es_CO.svg +11 -0
- bridgex/interface/assets/img/logo-bridgex/logo-bridgex-2.1.png +0 -0
- bridgex/interface/assets/img/logo-bridgex/logo-bridgex-2.2.png +0 -0
- bridgex/interface/assets/img/logo-bridgex/logo-bridgex-2.png +0 -0
- bridgex/interface/assets/img/osl_icon.webp +0 -0
- bridgex/interface/resources_rc.py +34626 -0
- bridgex/interface/translations/locale/bridge_es_CO.qm +0 -0
- bridgex/interface/translations/locale/bridge_es_GB.qm +0 -0
- bridgex/interface/translations/others/ABOUT_en_GB.trg +77 -0
- bridgex/interface/translations/others/ABOUT_es_CO.trg +77 -0
- bridgex/interface/translations/others/IH_en_GB.srm +19 -0
- bridgex/interface/translations/others/IH_es_CO.srm +19 -0
- bridgex/interface/translations/others/NOTICE_en_GB.srm +29 -0
- bridgex/interface/translations/others/NOTICE_es_CO.srm +29 -0
- bridgex/interface/ui_dialog_about.py +107 -0
- bridgex/interface/ui_dialog_language.py +120 -0
- bridgex/interface/ui_main_window.py +532 -0
- bridgex/interface/ui_osl.py +133 -0
- bridgex/logic/Converter.py +33 -0
- bridgex/logic/__init__.py +0 -0
- bridgex/logs/__init__.py +0 -0
- bridgex/models/Returning.py +14 -0
- bridgex/models/__init__.py +0 -0
- bridgex/utils/FilesManager.py +65 -0
- bridgex/utils/__init__.py +0 -0
- bridgex-0.0.1.dev0.dist-info/METADATA +193 -0
- bridgex-0.0.1.dev0.dist-info/RECORD +48 -0
- bridgex-0.0.1.dev0.dist-info/WHEEL +5 -0
- bridgex-0.0.1.dev0.dist-info/entry_points.txt +2 -0
- bridgex-0.0.1.dev0.dist-info/licenses/LICENSE +21 -0
- bridgex-0.0.1.dev0.dist-info/top_level.txt +1 -0
bridgex/NOTICE
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Use of External Libraries
|
2
|
+
|
3
|
+
> **Note:** You can select all the original licences of each library used from the top right-hand corner.
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
This project uses third-party libraries to provide additional functionality. Below is a description of these libraries along with their respective licences:
|
8
|
+
|
9
|
+
## 1. Markitdown
|
10
|
+
- **Author:** Microsoft Corporation
|
11
|
+
- **Repository:** [https://github.com/microsoft/markitdown](https://github.com/microsoft/markitdown)
|
12
|
+
- **Licence:** MIT Licence
|
13
|
+
- **Description:**
|
14
|
+
Markitdown is a tool for analysing and transforming Markdown files, developed by Microsoft. Under the MIT Licence, it allows free use, modification, and distribution, including for commercial projects, provided that the copyright notice is preserved.
|
15
|
+
|
16
|
+
## 2. PySide6 (Qt for Python)
|
17
|
+
- **Author:** The Qt Company Ltd. and contributors
|
18
|
+
- **Website:** [https://doc.qt.io/qtforpython/](https://doc.qt.io/qtforpython/)
|
19
|
+
- **Licence:** GNU Lesser General Public Licence v3.0 (LGPLv3)
|
20
|
+
- **Description:** PySide6 provides the official Python bindings for the Qt graphical user interface library. Under the LGPLv3, it allows use in open source and commercial projects, under the condition that the library can be replaced and that a copy of the licence and a notice of licence usage are provided.
|
21
|
+
|
22
|
+
---
|
23
|
+
|
24
|
+
# General Conditions
|
25
|
+
|
26
|
+
- All third-party libraries used in this project retain their respective licences.
|
27
|
+
- This project respects the usage conditions of those licences.
|
28
|
+
- If you wish to use, redistribute, or modify this project, you must comply not only with this project's primary licence but also with the specific conditions of the libraries mentioned above.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) Microsoft Corporation.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE
|
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
bridgex/__init__.py
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
from .utils.FilesManager import FileManager
|
2
|
+
from .logic.Converter import Converter
|
3
|
+
from ._bridgex import Bridgex
|
4
|
+
|
5
|
+
__author__:str = "Tutos Rive"
|
6
|
+
__version__:str = "0.0.1-dev"
|
7
|
+
__license__:str = "MIT"
|
8
|
+
__description__:str = "Bridgex is a PySide6 application for file management and conversion, featuring a lite markdown editor and viewer."
|
9
|
+
__all__:list[str] = ['FileManager', 'Converter', 'Bridgex', '__author__', '__version__', '__license__', '__description__']
|
bridgex/__main__.py
ADDED
bridgex/_bridgex.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from .database import Manager
|
3
|
+
from chromologger import Logger as Log
|
4
|
+
|
5
|
+
# Initial paths to files
|
6
|
+
log:Log = Log(f'{Path(__file__).parent}/logs/log_bridgex.log')
|
7
|
+
|
8
|
+
class Bridgex:
|
9
|
+
@staticmethod
|
10
|
+
def run_app():
|
11
|
+
try:
|
12
|
+
Manager.database_config()
|
13
|
+
from .interface import run
|
14
|
+
run()
|
15
|
+
except Exception as e:
|
16
|
+
log.log_e(e)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from sqlite3 import Cursor
|
3
|
+
from typing import Optional
|
4
|
+
from sqlazo import Database
|
5
|
+
from chromologger import Logger as Log
|
6
|
+
|
7
|
+
log: Log = Log(f'{Path(__file__).parent.parent}/log.log')
|
8
|
+
|
9
|
+
def database_config():
|
10
|
+
db: Database = Database(f'{Path(__file__).parent.parent}/database/config.db', False)
|
11
|
+
# Query to validate that the table exists
|
12
|
+
validate_query: Optional[Cursor] = db.get_data_where('config_ui', 'id == 1')
|
13
|
+
|
14
|
+
# Means that database don't have configs
|
15
|
+
# Create initial configs
|
16
|
+
if validate_query is None:
|
17
|
+
cols_config: list[str] = ['id INTEGER PRIMARY KEY', 'name TEXT NOT NULL', 'value TEXT NOT NULL']
|
18
|
+
db.create_table('config_ui', cols_config)
|
19
|
+
db.insert_data(['current_lang_code', 'es_CO'], ['name', 'value'], 'config_ui')
|
20
|
+
db.insert_data(['last_directory_open', 'C:/'], ['name', 'value'], 'config_ui')
|
21
|
+
db.insert_data(['last_directory_output', 'C:/'], ['name', 'value'], 'config_ui')
|
22
|
+
db.insert_data(['max_file_size', 10*1024*1024], ['name', 'value'], 'config_ui')
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This Python file uses the following encoding: utf-8
|
2
|
+
from pathlib import Path
|
3
|
+
from PySide6.QtCore import Qt
|
4
|
+
from PySide6.QtWidgets import QDialog
|
5
|
+
from .ui_dialog_about import Ui_about_dialog
|
6
|
+
|
7
|
+
class About(QDialog):
|
8
|
+
def __init__(self, parent=None, lang=None):
|
9
|
+
super().__init__(parent)
|
10
|
+
self.__lang:str = lang
|
11
|
+
self.__dialog = Ui_about_dialog()
|
12
|
+
self.__dialog.setupUi(self)
|
13
|
+
self.load_content()
|
14
|
+
self.show()
|
15
|
+
|
16
|
+
def load_content(self):
|
17
|
+
# Load information
|
18
|
+
with open(f'{Path(__file__).parent.parent}/interface/translations/others/ABOUT_{self.__lang}.trg', 'r', encoding='utf-8') as __about:
|
19
|
+
self.__dialog.text_about.setTextFormat(Qt.TextFormat.RichText)
|
20
|
+
self.__dialog.text_about.setText(__about.read())
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from PySide6.QtCore import Qt
|
3
|
+
from PySide6.QtWidgets import QLabel
|
4
|
+
from ._lang import LanguageManager
|
5
|
+
|
6
|
+
class InitialHelp:
|
7
|
+
def __init__(self, window, app):
|
8
|
+
self._w = window
|
9
|
+
self.__lang: LanguageManager = LanguageManager(app)
|
10
|
+
self.__logo = QLabel()
|
11
|
+
self.__logo.setMinimumSize(500, 500)
|
12
|
+
self.__logo.setTextFormat(Qt.TextFormat.RichText)
|
13
|
+
self.__logo.setText('<style>img{max-width: 100%;max-height: 100%;}</style>'+
|
14
|
+
f'<img src="{Path(__file__).parent.parent}/interface/assets/img/logo-bridgex/logo-bridgex-2.1.png"/>')
|
15
|
+
self.info: QLabel= QLabel()
|
16
|
+
self._w.ui.container_body.addWidget(self.__logo, 0, 0, 1, 1, alignment=Qt.AlignAbsolute)
|
17
|
+
self._w.ui.container_body.addWidget(self.info, 0, 0, 1, 1, alignment=Qt.AlignHCenter)
|
18
|
+
self.load_info()
|
19
|
+
|
20
|
+
def load_info(self, lang_code: str=None):
|
21
|
+
__lang = self.__lang.lang_code if lang_code is None else lang_code
|
22
|
+
__info_md: str = ""
|
23
|
+
# This is not a translator, just a file
|
24
|
+
with open(f"{Path(__file__).parent.parent}/interface/translations/others/IH_{__lang}.srm", "r", encoding="utf-8") as lang:
|
25
|
+
__info_md = lang.read()
|
26
|
+
self.info.setTextFormat(Qt.TextFormat.RichText)
|
27
|
+
self.info.setText(__info_md)
|
28
|
+
|
29
|
+
def hide(self):
|
30
|
+
self.info.hide()
|
31
|
+
self.__logo.hide()
|
@@ -0,0 +1,232 @@
|
|
1
|
+
import sys
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
from PySide6.QtWidgets import QApplication, QMainWindow, QFileDialog, QMessageBox
|
5
|
+
from PySide6.QtGui import QIcon, QCloseEvent
|
6
|
+
from PySide6.QtCore import QSize
|
7
|
+
from ._lang import LanguageManager
|
8
|
+
from ._initialHelp import InitialHelp
|
9
|
+
from ._osl import OSL
|
10
|
+
from ._about import About
|
11
|
+
from .. import FileManager, Converter
|
12
|
+
from .ui_main_window import Ui_MainWindow
|
13
|
+
from chromologger import Logger as Log
|
14
|
+
from sqlazo import Database
|
15
|
+
from pathlib import Path
|
16
|
+
from . import resources_rc
|
17
|
+
|
18
|
+
# Feature: Change focus order (the exit dialog focus is "ok", should be "cancel")
|
19
|
+
|
20
|
+
db = Database(f'{Path(__file__).parent.parent}/database/config.db', False)
|
21
|
+
log:Log = Log(f'{Path(__file__).parent.parent}/logs/log_interface.log')
|
22
|
+
|
23
|
+
app = QApplication(sys.argv)
|
24
|
+
lang_manager:LanguageManager = LanguageManager(app)
|
25
|
+
lang_manager.load_lang()
|
26
|
+
# Feature: Allow change style
|
27
|
+
app.setStyle("windows11")
|
28
|
+
|
29
|
+
class MainWindow(QMainWindow):
|
30
|
+
def __init__(self, parent=None):
|
31
|
+
super().__init__(parent)
|
32
|
+
self.__closed_ui:bool = False
|
33
|
+
self.current_lang = lang_manager.lang_code
|
34
|
+
self.ui: Ui_MainWindow = Ui_MainWindow()
|
35
|
+
lang_manager.set_super_parent(self)
|
36
|
+
self.ui.setupUi(self)
|
37
|
+
self.__listeners()
|
38
|
+
# Hide views temporally (to Show initial help)
|
39
|
+
self.ui.frame_views.hide()
|
40
|
+
self.__init_help: InitialHelp = InitialHelp(self, app)
|
41
|
+
self.__icon_window = QIcon()
|
42
|
+
self.__icon_window.addFile(u":/img/logo-bridgex-2", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
43
|
+
self.__file_dialog:QFileDialog = QFileDialog()
|
44
|
+
self.__filename:Path = Path('')
|
45
|
+
self.__dir_output:str = ''
|
46
|
+
|
47
|
+
@property
|
48
|
+
def get_app(self) -> QApplication: return app
|
49
|
+
|
50
|
+
def __listeners(self):
|
51
|
+
"""Catch events and set an action"""
|
52
|
+
self.ui.explorer_btn.clicked.connect(self.__open_file)
|
53
|
+
self.ui.language_btn.clicked.connect(self.__language)
|
54
|
+
self.ui.action_open_file.triggered.connect(self.__open_file)
|
55
|
+
self.ui.action_exit.triggered.connect(self.__exit)
|
56
|
+
self.ui.action_about.triggered.connect(self.__about)
|
57
|
+
|
58
|
+
self.ui.action_language.triggered.connect(self.__language)
|
59
|
+
self.ui.action_theme.triggered.connect(self.__theme)
|
60
|
+
self.ui.action_OSL.triggered.connect(self.__osl)
|
61
|
+
self.ui.convert_btn.clicked.connect(self.__convert)
|
62
|
+
self.ui.text_file_selected.textChanged.connect(self.__update)
|
63
|
+
|
64
|
+
def __open_file(self) -> None:
|
65
|
+
__msg:str = self.tr('Select a file')
|
66
|
+
__last_dir:str = db.get_data_where('config_ui', 'name == "last_directory_open"').fetchone()[2]
|
67
|
+
__file: tuple[str, str] = self.__file_dialog.getOpenFileName(self, self.tr("Open File"), __last_dir, f"{__msg} ({self.__extensions})")
|
68
|
+
if __file[0].strip() != '':
|
69
|
+
self.__filename = Path(__file[0])
|
70
|
+
db.delete_data('config_ui', 'name == "last_directory_open"')
|
71
|
+
# Save last directory
|
72
|
+
db.insert_data(['last_directory_open', self.__filename.absolute().parent.__str__()], ['name', 'value'], 'config_ui')
|
73
|
+
|
74
|
+
# Feature: Show progress bar
|
75
|
+
# => Can be a Label image (hide initialHelp if all ok, continue else show initialHelp again)
|
76
|
+
__converter:Converter = Converter(self.__filename.absolute().__str__())
|
77
|
+
__content: Optional[str] = __converter.convert_file().data_str
|
78
|
+
|
79
|
+
# File is NOT empty
|
80
|
+
if __content is not None:
|
81
|
+
# Hide initial "screen" and show file content
|
82
|
+
self.__init_help.hide()
|
83
|
+
self.ui.frame_views.show()
|
84
|
+
self.ui.text_file_selected.setPlainText(__content)
|
85
|
+
else:
|
86
|
+
# Missing: Feature: Close progress bar
|
87
|
+
#self.__progress_bar().close()
|
88
|
+
self.__box_dialog(self.tr("Warning"), self.tr('The file does not contain plain text (make sure the file content is not just images)')).exec()
|
89
|
+
|
90
|
+
def __update(self) -> None:
|
91
|
+
"""Update real-time MarkDown preview"""
|
92
|
+
self.ui.text_preview_mode.setMarkdown(self.ui.text_file_selected.toPlainText())
|
93
|
+
|
94
|
+
def __convert(self) -> None:
|
95
|
+
"""Manage file converter, call methods to convert, open files..."""
|
96
|
+
# Feature: New dialog to rename the file (file to save as .md)
|
97
|
+
|
98
|
+
# Before save, validate not empty content
|
99
|
+
if self.ui.text_file_selected.toPlainText().strip() == '':
|
100
|
+
self.__box_dialog(self.tr('Warning'), self.tr('The file is empty'), {'ok': self.tr('Accept')}).exec()
|
101
|
+
return
|
102
|
+
|
103
|
+
# Get the last output directory
|
104
|
+
__last_dir:str = db.get_data_where('config_ui', 'name == "last_directory_output"').fetchone()[2]
|
105
|
+
|
106
|
+
# Ask the user for output directory (Remember the previous directory)
|
107
|
+
self.__dir_output:str = self.__file_dialog.getExistingDirectory(self, self.tr("Select a directory"), __last_dir)
|
108
|
+
|
109
|
+
try:
|
110
|
+
# Output directory was selected
|
111
|
+
if self.__dir_output.strip() != '':
|
112
|
+
# Update output directory in DB
|
113
|
+
db.delete_data('config_ui', 'name == "last_directory_output"')
|
114
|
+
db.insert_data(['last_directory_output', self.__dir_output], ['name', 'value'], 'config_ui')
|
115
|
+
|
116
|
+
# Use the same filename input for the output file (Just change the directory)
|
117
|
+
__file_manager:FileManager = FileManager(self.__filename.absolute().__str__(), self.__dir_output)
|
118
|
+
|
119
|
+
# Save converted file
|
120
|
+
__file_manager.save_md(self.ui.text_file_selected.toPlainText())
|
121
|
+
except Exception as e:
|
122
|
+
log.log_e(e)
|
123
|
+
|
124
|
+
@property
|
125
|
+
def __extensions(self) -> str:
|
126
|
+
__allow_extensions:str = ''
|
127
|
+
for ex in FileManager.extensions(): __allow_extensions += f'*{ex} '
|
128
|
+
return __allow_extensions.strip()
|
129
|
+
|
130
|
+
def __exit(self, event_target: Optional[QCloseEvent] = None) -> None:
|
131
|
+
"""When event "close" is caught or user press `CTRL + W` shortcut
|
132
|
+
|
133
|
+
Args:
|
134
|
+
event_target (Optional[QCloseEvent]): When this method is called from "Title bar" Event (Press title "X")
|
135
|
+
"""
|
136
|
+
__result:int = self.__box_dialog(self.tr('Close Program'),self.tr('Do you want to close this program?'),{'ok': self.tr('Accept')}).exec()
|
137
|
+
|
138
|
+
if __result == 1024:
|
139
|
+
# Close via "Dialog" (CTRL + W)
|
140
|
+
self.__closed_ui = True
|
141
|
+
self.close()
|
142
|
+
else:
|
143
|
+
# When close via "Window" (Title bar "X")
|
144
|
+
if type(event_target) is QCloseEvent: event_target.ignore()
|
145
|
+
|
146
|
+
def closeEvent(self, event: QCloseEvent) -> None:
|
147
|
+
"""Catch Close Event (Title bar "X")
|
148
|
+
|
149
|
+
Args:
|
150
|
+
event (QCloseEvent): Close Event from title bar "X"
|
151
|
+
"""
|
152
|
+
if not self.__closed_ui: self.__exit(event)
|
153
|
+
|
154
|
+
def __about(self):
|
155
|
+
"""Show about dialog"""
|
156
|
+
About(self, self.current_lang)
|
157
|
+
|
158
|
+
def __language(self):
|
159
|
+
"""Change UI language"""
|
160
|
+
__result: int = 0
|
161
|
+
if self.ui.text_preview_mode.isVisible():
|
162
|
+
# Show a warning dialog before change language
|
163
|
+
__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()
|
164
|
+
|
165
|
+
if not self.ui.text_preview_mode.isVisible() or __result == 1024:
|
166
|
+
#Feature: Save content in a temporal file (The content is removed when language change)
|
167
|
+
lang_manager.show_dialog()
|
168
|
+
|
169
|
+
#Update UI language (MainWindow > childs and Language Dialog)
|
170
|
+
self.ui.retranslateUi(self)
|
171
|
+
lang_manager.lang_dialog.retranslateUi(lang_manager)
|
172
|
+
|
173
|
+
# Update lang UI var
|
174
|
+
self.current_lang = lang_manager.lang_code
|
175
|
+
|
176
|
+
# When initial info screen is visible
|
177
|
+
if self.__init_help.info.isVisible(): self.__init_help.load_info(self.current_lang)
|
178
|
+
|
179
|
+
def __box_dialog(self, title:str = '', text:str = '', buttons_cancel_ok: Optional[dict] = None, icon: Optional[QIcon] = None) -> QMessageBox:
|
180
|
+
"""Create a Box Dialog (To show warnings, confirms, e.t.c.)
|
181
|
+
|
182
|
+
Args:
|
183
|
+
title (str): Dialog title (Example: Warning file size)
|
184
|
+
text (str): Dialog message, text
|
185
|
+
buttons_cancel_ok (Optional[dict]): Custom text to standard buttons (Cancel | Ok)
|
186
|
+
icon (Optional[QIcon]): To set window icon
|
187
|
+
|
188
|
+
Returns:
|
189
|
+
QMessageBox: A dialog object ready to use
|
190
|
+
|
191
|
+
Note:
|
192
|
+
`show()` method should be executed to use this, not show by default...
|
193
|
+
|
194
|
+
"""
|
195
|
+
__icon: QIcon = icon if icon is not None else self.__icon_window
|
196
|
+
__dialog: QMessageBox = QMessageBox()
|
197
|
+
|
198
|
+
# Standard dialog buttons
|
199
|
+
__dialog.setStandardButtons(__dialog.StandardButton.Ok | __dialog.StandardButton.Cancel)
|
200
|
+
|
201
|
+
# If not give buttons labels
|
202
|
+
__buttons_txt:list[str] = [self.tr('Ok'), self.tr('Cancel')]
|
203
|
+
|
204
|
+
# Show and set window configs
|
205
|
+
__dialog.setWindowIcon(__icon)
|
206
|
+
__dialog.setWindowTitle(title)
|
207
|
+
__dialog.setText(text)
|
208
|
+
|
209
|
+
# Has been received a dict with buttons
|
210
|
+
if buttons_cancel_ok is not None and type(buttons_cancel_ok) is dict:
|
211
|
+
if 'ok' in buttons_cancel_ok: __buttons_txt[0] = buttons_cancel_ok['ok']
|
212
|
+
if 'cancel' in buttons_cancel_ok: __buttons_txt[1] = buttons_cancel_ok['cancel']
|
213
|
+
|
214
|
+
# Set visible text for each button
|
215
|
+
__dialog.button(__dialog.StandardButton.Ok).setText(__buttons_txt[0])
|
216
|
+
__dialog.button(__dialog.StandardButton.Cancel).setText(__buttons_txt[1])
|
217
|
+
return __dialog
|
218
|
+
|
219
|
+
|
220
|
+
def __theme(self):
|
221
|
+
# Coming Soon
|
222
|
+
# Feature: Change theme
|
223
|
+
pass
|
224
|
+
|
225
|
+
def __osl(self):
|
226
|
+
"""Load Open Source Licenses (Information - OSL)"""
|
227
|
+
OSL(self, lang_manager)
|
228
|
+
|
229
|
+
def run():
|
230
|
+
widget = MainWindow()
|
231
|
+
widget.show()
|
232
|
+
sys.exit(app.exec())
|
@@ -0,0 +1,46 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
from pathlib import Path
|
3
|
+
|
4
|
+
from PySide6.QtCore import Qt, QTranslator
|
5
|
+
from PySide6.QtWidgets import QApplication, QMainWindow
|
6
|
+
from .ui_dialog_language import Ui_Lang_Dialog
|
7
|
+
from PySide6.QtWidgets import QDialog
|
8
|
+
from sqlazo import Database
|
9
|
+
|
10
|
+
db = Database(f'{Path(__file__).parent.parent}/database/config.db', False)
|
11
|
+
|
12
|
+
class LanguageManager(QDialog):
|
13
|
+
def __init__(self, app:QApplication=None):
|
14
|
+
# es_CO is default
|
15
|
+
self.lang_code: str = db.get_data_where('config_ui', 'name == "current_lang_code"').fetchone()[2]
|
16
|
+
self.__dir:str = f'{Path(__file__).parent.parent}/interface/translations/locale'
|
17
|
+
self.lang_file:str = ''
|
18
|
+
self.__translator:QTranslator = QTranslator(app)
|
19
|
+
self.__app:QApplication = app
|
20
|
+
self.parent: Optional[QMainWindow] = None
|
21
|
+
self.lang_dialog: Optional[Ui_Lang_Dialog] = None
|
22
|
+
|
23
|
+
def set_super_parent(self, parent):
|
24
|
+
self.parent = parent
|
25
|
+
super().__init__(self.parent)
|
26
|
+
self.lang_dialog = Ui_Lang_Dialog()
|
27
|
+
self.lang_dialog.setupUi(self)
|
28
|
+
|
29
|
+
def show_dialog(self):
|
30
|
+
__buttons_dialog = self.lang_dialog.dialog_btn
|
31
|
+
__buttons_dialog.setStandardButtons(__buttons_dialog.StandardButton.Ok | __buttons_dialog.StandardButton.Cancel)
|
32
|
+
__buttons_dialog.button(__buttons_dialog.StandardButton.Ok).setText(self.tr('Save'))
|
33
|
+
__buttons_dialog.button(__buttons_dialog.StandardButton.Cancel).setText(self.tr('Cancel'))
|
34
|
+
self.exec()
|
35
|
+
if self.result() == 1 and self.lang_dialog.languages.currentItem() is not None:
|
36
|
+
self.lang_code:str = self.lang_dialog.languages.currentItem().toolTip()
|
37
|
+
# Pending improvement (when 'update_data' is added to 'sqlazo')
|
38
|
+
db.delete_data('config_ui', 'name == "current_lang_code"')
|
39
|
+
db.insert_data(['current_lang_code', self.lang_code], ['name', 'value'], 'config_ui')
|
40
|
+
self.load_lang()
|
41
|
+
|
42
|
+
def load_lang(self, lang_code:str=None):
|
43
|
+
__code = lang_code if lang_code is not None else self.lang_code
|
44
|
+
self.lang_file = f'bridge_{__code}.qm'
|
45
|
+
if self.__translator.load(self.lang_file, self.__dir):
|
46
|
+
self.__app.installTranslator(self.__translator)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
from pathlib import Path
|
2
|
+
from PySide6.QtWidgets import QDialog
|
3
|
+
from .ui_osl import Ui_dialog_osl
|
4
|
+
from .. import FileManager
|
5
|
+
import json
|
6
|
+
|
7
|
+
class OSL(QDialog):
|
8
|
+
def __init__(self, parent=None, lang_manager=None):
|
9
|
+
super().__init__(parent)
|
10
|
+
self.__lang = lang_manager
|
11
|
+
self.__osl: Ui_dialog_osl = Ui_dialog_osl()
|
12
|
+
self.__osl.setupUi(self)
|
13
|
+
self.__load_initial_content()
|
14
|
+
self.show()
|
15
|
+
self.__osl.select_library.currentTextChanged.connect(self.__load_library_osl)
|
16
|
+
|
17
|
+
def __load_initial_content(self):
|
18
|
+
__notice:str = FileManager.read_file(f'{Path(__file__).parent.parent}/interface/translations/others/NOTICE_{self.__lang.lang_code}.srm')
|
19
|
+
self.__osl.text_container_license.setText(__notice)
|
20
|
+
|
21
|
+
def __load_library_osl(self):
|
22
|
+
if self.__osl.select_library.currentIndex() > 0:
|
23
|
+
__name_library:str = self.__osl.select_library.currentText()
|
24
|
+
__license_file:str = f'{Path(__file__).parent.parent}/OSL/LICENSE_{__name_library.upper()}'
|
25
|
+
__links:dict = json.loads(FileManager.read_file(f'{Path(__file__).parent.parent}/OSL/url_licenses.srm'))
|
26
|
+
self.__osl.url_osl.setText(self.tr(f'{__name_library.capitalize()} - original: {__links[__name_library.lower()]}'))
|
27
|
+
self.__osl.text_container_license.setText(FileManager.read_file(__license_file))
|
28
|
+
else:
|
29
|
+
self.__load_initial_content()
|
30
|
+
self.__osl.url_osl.clear()
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
2
|
+
|
3
|
+
<svg height="64px" width="64px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512" xml:space="preserve" fill="#000000">
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|