From f1123a6fd5763e7a3aecf1aa9a72cc1db915e613 Mon Sep 17 00:00:00 2001
From: Paul S
Date: Fri, 2 Jul 2021 17:16:03 +0200
Subject: [PATCH] Verbesserungen in Sprachdatei "hu_HU.ts" + Laden von Zahlen
aus der .CSV-Datei als Zahlenwerte, nicht Text
---
changelog.md | 8 ++++++
i18n/hu_HU.qm | Bin 4676 -> 4676 bytes
i18n/hu_HU.ts | 8 +++---
src/main.py | 72 +++++++++++++++++++++++++++++++-------------------
4 files changed, 57 insertions(+), 31 deletions(-)
diff --git a/changelog.md b/changelog.md
index 61f827e..580e931 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,13 @@
# Changelog GarageCalc1
+## [0.5.2] - 2021-07-02
+## Changed
+- Verbesserungen in Sprachdatei "hu_HU.ts"
+
+## [0.5.1] - 2021-07-02
+## Fixed
+- Laden von Zahlen aus der .CSV-Datei als Zahlenwerte, nicht Text
+
## [0.5] - 2021-07-02
## Added
- Tabelle "Gegenstände": Zeilen sind sortierbar (-> Klick auf Spaltenköpfe)
diff --git a/i18n/hu_HU.qm b/i18n/hu_HU.qm
index 04280b2d6eee10da01257efaccbebdb569ab5ea0..40edbedd382be8a74b53d18927471bae9de39915 100644
GIT binary patch
delta 83
zcmX@2aztf<8e`2w_4$l%CLZ@^G@2~V7|ytMaz0}tKOaLb!$XE*hJ1z`5Iy-XV?K8_
jLncERkeAMoH@TcCnU{wlgy9=Q5m3cThT_dHnWFgtg*6(2
delta 83
zcmX@2aztf<8e`Q&_4$miCLZ@^G?*;T7|ytQaz0}tFAqZ)Ln=cF5T-KZPX5oB&mG3_
lkRhERg+YNKdvYaHGCv
+
@@ -6,12 +6,12 @@
- Vágd ki
+ kivágni
- Vettem
+ másolás
@@ -21,7 +21,7 @@
- Törölje
+ Törlés
diff --git a/src/main.py b/src/main.py
index 2d86660..9d196d6 100644
--- a/src/main.py
+++ b/src/main.py
@@ -28,7 +28,7 @@ from utils import show_about, resource_path
from clsTableWidget import TableWidget
# Local globals
-APP_VERSION = "v0.5"
+APP_VERSION = "v0.5.2"
DIR_APPDATA = os.getenv('LOCALAPPDATA')
@@ -70,11 +70,15 @@ WIN_HEIGHT = 640
TXT_UNSAVED_CHANGES = QCoreApplication.translate("main", "There are unsaved entries. Without saving, all changes are lost. Continue anyway?")
+CONFIG = configparser.ConfigParser()
+TRANSLATOR = QTranslator()
+
####################################################################
def main():
qApp = QApplication(sys.argv)
- global APP_NAME
+ global APP_NAME, CONFIG, TRANSLATOR
+
qApp.setApplicationName(APP_NAME)
qApp.setApplicationDisplayName(APP_DISPNAME)
qApp.setApplicationVersion(APP_VERSION)
@@ -84,34 +88,30 @@ def main():
qApp.setWindowIcon(QIcon(APP_ICON))
qApp.setDesktopFileName(APP_DESKTOPFILENAME)
- config = configparser.ConfigParser()
-
language = "Deutsch"
if os.path.exists(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini')):
- config.read(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'))
- language = config['DEFAULT']['language']
+ CONFIG.read(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'))
+ language = CONFIG['DEFAULT']['language']
else:
- config['DEFAULT']['language'] = language
+ CONFIG['DEFAULT']['language'] = language
if not os.path.exists(os.path.join(DIR_APPDATA, APP_DISPNAME)):
os.makedirs(os.path.join(DIR_APPDATA, APP_DISPNAME))
with open(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'), 'w') as configfile: # save
- config.write(configfile)
-
- translator = QTranslator()
+ CONFIG.write(configfile)
print("Current dir:", os.getcwd())
if language == "Deutsch":
print("Loading german language file.")
- translator.load(resource_path('./i18n/de_DE'))
+ TRANSLATOR.load(resource_path('./i18n/de_DE'))
elif language == "Magyar":
print("Loading hungarian langauge file.")
- translator.load(resource_path('./i18n/hu_HU'))
+ TRANSLATOR.load(resource_path('./i18n/hu_HU'))
else:
print(f"Unknown language setting '{language}' -> defaulting to english language.")
- qApp.installTranslator(translator)
+ qApp.installTranslator(TRANSLATOR)
app_name = qApp.translate("main", APP_NAME)
qApp.setApplicationName(app_name)
@@ -258,7 +258,6 @@ class MainWindow(QMainWindow):
layoutGb.addWidget(self.ui.tableStuff)
-
def create_actions(self):
self.actionNew = QAction()
self.actionNew.setIcon(QIcon(resource_path(ICON_NEW)))
@@ -369,6 +368,7 @@ class MainWindow(QMainWindow):
if reply == QMessageBox.No:
return False
self.init_ui()
+ self.ui.tableStuff.sortByColumn(-1) # reset sorting
def file_save(self):
tblGarage = self.ui.tableGarage
@@ -515,6 +515,7 @@ class MainWindow(QMainWindow):
options=options)
if fileName:
self.init_ui()
+ self.ui.tableStuff.sortByColumn(-1) # reset sorting
file = open(fileName, "r", newline='')
reader = csv.reader(file, delimiter=';')
@@ -528,9 +529,9 @@ class MainWindow(QMainWindow):
garage_height = row[3]
garage_comment = row[4]
- tblGarage.setItem(0, COL_LENGTH-1, QTableWidgetItem(str(garage_length)))
- tblGarage.setItem(0, COL_WIDTH-1, QTableWidgetItem(str(garage_width)))
- tblGarage.setItem(0, COL_HEIGHT-1, QTableWidgetItem(str(garage_height)))
+ tblGarage.setItem(0, COL_LENGTH-1, QTableWidgetItem(garage_length))
+ tblGarage.setItem(0, COL_WIDTH-1, QTableWidgetItem(garage_width))
+ tblGarage.setItem(0, COL_HEIGHT-1, QTableWidgetItem(garage_height))
tblGarage.setItem(0, COL_COMMENT-1, QTableWidgetItem(garage_comment))
except IndexError as ex:
@@ -546,10 +547,26 @@ class MainWindow(QMainWindow):
stuff_comment = row[5]
tblStuff.setItem(row_idx - 1, COL_STUFF, QTableWidgetItem(stuff))
- tblStuff.setItem(row_idx - 1, COL_LENGTH, QTableWidgetItem(str(stuff_length)))
- tblStuff.setItem(row_idx - 1, COL_WIDTH, QTableWidgetItem(str(stuff_width)))
- tblStuff.setItem(row_idx - 1, COL_HEIGHT, QTableWidgetItem(str(stuff_height)))
- tblStuff.setItem(row_idx - 1, COL_WEIGHT, QTableWidgetItem(str(stuff_weight)))
+
+ item = QTableWidgetItem()
+ item.setData(Qt.DisplayRole, float(stuff_length))
+ tblStuff.setItem(row_idx - 1, COL_LENGTH, item)
+
+ # tblStuff.setItem(row_idx - 1, COL_WIDTH, QTableWidgetItem(float(stuff_width)))
+ item = QTableWidgetItem()
+ item.setData(Qt.DisplayRole, float(stuff_width))
+ tblStuff.setItem(row_idx - 1, COL_WIDTH, item)
+
+ #tblStuff.setItem(row_idx - 1, COL_HEIGHT, QTableWidgetItem(float(stuff_height)))
+ item = QTableWidgetItem(stuff_height)
+ item.setData(Qt.DisplayRole, float(stuff_height))
+ tblStuff.setItem(row_idx - 1, COL_HEIGHT, item)
+
+ # tblStuff.setItem(row_idx - 1, COL_WEIGHT, QTableWidgetItem(float(stuff_weight)))
+ item = QTableWidgetItem(stuff_weight)
+ item.setData(Qt.DisplayRole, float(stuff_weight))
+ tblStuff.setItem(row_idx - 1, COL_WEIGHT, item)
+
tblStuff.setItem(row_idx - 1, COL_COMMENT, QTableWidgetItem(stuff_comment))
except IndexError as ex:
@@ -871,6 +888,7 @@ class MainWindow(QMainWindow):
def store_selected_language(self, menu):
""" Stores selected menu labels to ini-file. """
# [print(action.text()) for action in menu.actions() if action.isChecked()]
+ global CONFIG
print("Current dir:", os.getcwd())
language = "English"
@@ -878,23 +896,23 @@ class MainWindow(QMainWindow):
if action.isChecked():
language = action.text()
- config['DEFAULT']['language'] = language
+ CONFIG['DEFAULT']['language'] = language
if not os.path.exists(os.path.join(DIR_APPDATA, APP_DISPNAME)):
os.makedirs(os.path.join(DIR_APPDATA, APP_DISPNAME))
with open(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'), 'w') as configfile: # save
- config.write(configfile)
+ CONFIG.write(configfile)
if language == "Deutsch":
print("Loading german language file.")
- translator.load(resource_path('./i18n/de_DE'))
+ TRANSLATOR.load(resource_path('./i18n/de_DE'))
elif language == "Magyar":
print("Loading hungarian langauge file.")
- translator.load(resource_path('./i18n/hu_HU'))
+ TRANSLATOR.load(resource_path('./i18n/hu_HU'))
+
else:
- #qApp.removeTranslator(translator)
- translator.load("dummy")
print(f"Unknown language setting '{language}' -> defaulting to english language.")
+ TRANSLATOR.load("dummy")
self.retranslateUi()