Skip to content

Commit

Permalink
refactor: Update UI code to use PlainTextEdit for text editing and fi…
Browse files Browse the repository at this point in the history
…x languages
  • Loading branch information
LyubomirT committed Aug 4, 2024
1 parent e7db649 commit 0684dd3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import os
import sys

class PlainTextEdit(QtWidgets.QTextEdit):
def insertFromMimeData(self, source):
if source.hasText():
self.insertPlainText(source.text())

class Ui_MainWindow(object):
def __init__(self):
if os.path.exists("language.txt"):
Expand Down Expand Up @@ -32,8 +37,9 @@ def setupUi(self, MainWindow):
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")

self.textEdit = QtWidgets.QTextEdit(self.horizontalLayoutWidget)
self.textEdit = PlainTextEdit(self.horizontalLayoutWidget)
self.textEdit.setObjectName("textEdit")
self.textEdit.setAcceptRichText(False)
self.horizontalLayout.addWidget(self.textEdit)

self.settingsLayout = QtWidgets.QVBoxLayout()
Expand Down Expand Up @@ -111,9 +117,6 @@ def setupUi(self, MainWindow):

self.load_theme_based_on_last_choice()

# set the current language of the dropdown to the saved language
self.languageComboBox.setCurrentText(self.current_language)

def load_translations(self):
self.translations = {}
translations_dir = "translations"
Expand All @@ -124,6 +127,9 @@ def load_translations(self):
self.translations[language_code] = json.load(f)
language_original = self.translations[language_code].get("original", "Unknown")
self.languageComboBox.addItem(language_code + " - " + language_original)
if language_code == self.current_language:
self.current_language = language_code
self.languageComboBox.setCurrentText(self.current_language + " - " + language_original)

def load_theme_based_on_last_choice(self):
if not os.path.exists("theme.txt"):
Expand Down

0 comments on commit 0684dd3

Please sign in to comment.