From fb88dac713f21737ba13cdba9db0d99ea402aac0 Mon Sep 17 00:00:00 2001 From: Paul S Date: Fri, 2 Jul 2021 15:45:59 +0200 Subject: [PATCH] splitter-control + optimize row height --- changelog.md | 4 +- i18n/de_DE.qm | Bin 4690 -> 4748 bytes i18n/de_DE.ts | 109 +++++++++++---------- i18n/hu_HU.qm | Bin 4616 -> 4676 bytes i18n/hu_HU.ts | 109 +++++++++++---------- scripts/pyinstaller.cmd | 38 ++++---- scripts/pyinstaller_v2.cmd | 97 ------------------- src/clsTableWidget.py | 16 ++-- src/main.py | 105 +++++++++++++++++---- ui/main.ui | 189 +++++++++++++++++++++---------------- 10 files changed, 341 insertions(+), 326 deletions(-) delete mode 100644 scripts/pyinstaller_v2.cmd diff --git a/changelog.md b/changelog.md index 7a4d7e0..61f827e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,10 +1,12 @@ # Changelog GarageCalc1 -## [0.4.2] - 2021-07-01 +## [0.5] - 2021-07-02 ## Added - Tabelle "Gegenstände": Zeilen sind sortierbar (-> Klick auf Spaltenköpfe) - Tabelle "Gegenstände": Spalten sind anordenbar - Beide Tabellen: Rechte Spalte wächst dynamisch ans Ende +- Beide Tabellen: Zusätzliche Spalte "Kommentar" am Ende der Tabelle +- Horizontales Splitter-Control zwischen Tabelle "Garage" und "Gegenstände" ## [0.4.1] - 2021-07-01 ## Added diff --git a/i18n/de_DE.qm b/i18n/de_DE.qm index d8fb6a91c30c1f44c07b6a60445c8d3f77676bc9..a3d31e65a3fb827057ca459910889efcc491d17c 100644 GIT binary patch delta 519 zcmWkqO-NKx7(Fv{@0<7To8A*sA_LnfE)*nr1wlzzxG>O!Mo18fW(w08qf8pa-oiyS zyhSiV1!W=q2}4k0n`UYejb;TSf?&^n zuJ-`00w)&$q+2MAf1)rp1q6#?_4*3?IkEn?3>b%HOE-;_DbMa9-?|{Z&O8vKi2aZsvzCEE}qE93zPFL=nd*&ft>H*`VGT7=1hY`;9v@>#XRCn4lNMiy$s*WQQe8ggj`0>p>8dG*PpQpe|8!@L&#e z2sElg7Sg|!CCJr_+lq*5D#3~*sYw?P9n8G!681-Yoj$(reeXTqb1JsWAC_9nK+`IK zQK0oBpeqosBisS;`#s=$1bJ(T_by0BaDIV&k^+pUP`4_GUxvEZ0pwjpoBawP@fpxd_yoaty_rZfhJ~*ON zTL3(jB34CVoQd@C6p#}YyW=~&+v4b72G9&y)l4I8Pu?sc-@GK9#uVT#l1?m0-G2G? z|DSm%GcN TableWidget - + Cut Ausschneiden - + Copy Kopieren - + Paste Einfügen - + Delete Löschen - + Cut row Zeile ausschneiden - + Copy row Zeile kopieren - + Paste row Zeile einfügen - + Insert row before Zeile oberhalb einfügen - + Insert row after Zeile unterhalb einfügen - + Remove row Zeile entfernen - + Delete items Zellinhalte löschen - + Row Nr. Zeile Nr. - + to be removed? entfernen? - + Remove Entfernen - + Delete cell content? Zellinhalt löschen? @@ -87,122 +87,122 @@ Hallo Welt - + &Settings &Einstellungen - + Language Sprache - + Stuff Gegenstand - + Length Länge - + Width Breite - + Height Höhe - + Weight Gewicht - + Dimension of the garage Dimension der Garage - + Dimensions of the objects to be stored Dimensionen der zu verstauenden Gegenstände - + Result Ergebnis - + Volume of the garage Volumen der Garage - + Volume of the items Volumen der Gegenstände - + Free space in the garage Freier Raum in der Garage - + Total weight Gesamtgewicht - + New (Ctrl+N) Neu (Strg+N) - + Open... (Ctrl+O) Öffnen... (Strg+O) - + Save (Ctrl+S) Speichern (Strg+S) - + Export to EXCEL... Export nach EXCEL... - + Information about the application Informationen über das Programm - + Quit the application (Strg+Q) Programm beenden (Strg+Q) - + Garage Garage - + Quit Beenden - + New Neu - + Save Speichern @@ -212,27 +212,27 @@ CSV-Datei - + All files Alle Dateien - + file Datei - + saved gespeichert - + Open Öffnen - + Export Export @@ -242,45 +242,50 @@ EXCEL-Datei - + Error in the garage dimension Fehler in der Garagen-Dimension - + Error in the dimensions of the objects to be stored Fehler in den Dimensionen der zu verstauenden Gegenstände - + Successfully exported to EXCEL Erfolgreich nach EXCEL exportiert - + CSV-file CSV-Datei - + EXCEL-file EXCEL-Datei - + There are unsaved entries. Without saving, all changes are lost. Continue anyway? Es gibt ungespeicherte Einträge. Ohne zu speichern, gehen alle Änderungen verloren. Trotzdem fortfahren? - + Garage Space Calculator Garagenraum-Rechner - + Calculates available garage space Berechnet zur Verfügung stehenden Garagenraum + + + Comment + Kommentar + utils diff --git a/i18n/hu_HU.qm b/i18n/hu_HU.qm index 5bbd152236a4d45e06e113b81f4f24b1232c4e46..04280b2d6eee10da01257efaccbebdb569ab5ea0 100644 GIT binary patch delta 521 zcmW+zO-NKx7(Fv{@0<7TjPC_b3lk=Y=?|pRObS9OqlJ(mWD7wOnn`pVT}%j5|Jcn8FvH-Oa*dG#aTZAeG(+=9HH1$>{Oec4Mq2<=-7u%ir@`X2-C zyJ*f#0RH1>`TGno*N||=SXYPdtGC&Az*WRG9kH9`SxNN;#sB;lk!FhgN6 zYP2^6iN7*_hnt9pRrq88kZtPe;YB*0QO~n^I?k(!1bOg6%?)njOKP*`7@gnqMN9iQ zK-|}rxj>#}-%F>ANxt^KUynCZpvs?#&Xb_kKlR9D!%B&rTH^q<=BcrVbbQq8oMs}T z)65Ul^8VE_E6*^2wDsWxlW-rh3cXBFoo(koG^T&LqHa@5HzrhdJx3GN@eOL5N7Fn=#U@p zLD@h-FcJHrQPdRFMM*egBFu}R=`A8yejPT1KB&jjj~~w$&$C%PRy^gmHh|_$0K-7* z7eGIUcpl;ph+ppjvj+11M?l?zv;}Vxay9{YW}xj}2aGhdgHH0kqkZBT;G9NBd<*aj zbpC!xd>tWsnYf9sC*#y-99a|r4!?7tBM-2AF;~T6l7<^D>*+nF?zxV}zL790?&vE( zPF6$%G)7vah9dlfV*kk=;BFN^|7Lg(WuS#Y`X||4NWJe=+KmaoRVeLf1$}$v;U&)q z%gj{Y28$)Vugy>Vt$uO0 zjd+=QQTl^TchsvyicRO#R)~7MR{N1WK(44iRh4Yq?Fn9a%-}lDVEi`qY0n$GfD1hG zuAe=iZ@D)fJZhprz?)n!C|LDb(NhL1qkegwLH~^YZ7w1Dja0an&F4+yW&;~r=7(x7 Z;4CpSqg+nq_5r!qV#ki4j7{dOssA5yf*1e* diff --git a/i18n/hu_HU.ts b/i18n/hu_HU.ts index 70dd26d..d29237c 100644 --- a/i18n/hu_HU.ts +++ b/i18n/hu_HU.ts @@ -4,77 +4,77 @@ TableWidget - + Cut Vágd ki - + Copy Vettem - + Paste Beillesztés - + Delete Törölje - + Cut row Vágott vonal - + Copy row Vettem a szöveget - + Paste row Beilleszteni a sort - + Insert row before A fenti sort beilleszteni - + Insert row after Az alábbi sor beillesztése - + Remove row Távolítsa el a sort - + Delete items Tartalom törlése - + Row Nr. Vonalszám. - + to be removed? eltávolítani? - + Remove A eltávolítása - + Delete cell content? Cellatartalom törlése? @@ -87,122 +87,122 @@ Hallo Welt - + &Settings &Beállítások - + Language Nyelv - + Stuff Tárgy - + Length Hosszúság - + Width Szélesség - + Height Magasság - + Weight Súly - + Dimension of the garage A garázs mérete - + Dimensions of the objects to be stored A tárolandó objektumok méretei - + Result Eredmény - + Volume of the garage A garázs térfogata - + Volume of the items A tételek mennyisége - + Free space in the garage Szabad hely a garázsban - + Total weight Teljes súly - + New (Ctrl+N) Új (Ctrl+N) - + Open... (Ctrl+O) Nyissa ki (Ctrl+O) - + Save (Ctrl+S) Mentés (Ctrl+S) - + Export to EXCEL... Exportálás EXCEL-be... - + Information about the application Az alkalmazással kapcsolatos információk - + Quit the application (Strg+Q) Az alkalmazás kilépése (Ctrl+Q) - + Garage Garázs - + Quit Kilépés - + New Új - + Save Mentés @@ -212,27 +212,27 @@ CSV-fájl - + All files Minden fájl - + file fájl - + saved mentett - + Open Megnyitott - + Export Exportálás @@ -242,45 +242,50 @@ EXCEL-fájl - + Error in the garage dimension Hiba a garázs dimenziójában - + Error in the dimensions of the objects to be stored Hiba a tárolandó objektumok méreteiben - + Successfully exported to EXCEL Sikeresen exportált EXCEL-be - + CSV-file CSV-fájl - + EXCEL-file EXCEL-fájl - + There are unsaved entries. Without saving, all changes are lost. Continue anyway? Vannak mentetlen bejegyzések. Mentés nélkül minden módosítás elveszik. Folytassa mégis? - + Garage Space Calculator Garázs hely kalkulátor - + Calculates available garage space Kiszámítja a rendelkezésre álló garázshelyet + + + Comment + Megjegyzés + utils diff --git a/scripts/pyinstaller.cmd b/scripts/pyinstaller.cmd index 58f1c86..5892f60 100644 --- a/scripts/pyinstaller.cmd +++ b/scripts/pyinstaller.cmd @@ -1,36 +1,36 @@ @ECHO OFF :: -------------------------------------------------------------------------------------------------------------------------------------- -:: project: GarageCalc1 Window-Exe Generator -:: summary: create a GarageCalc1-executable for Windows (version with no-console-windows as well as version with console windows for traces) +:: project: GarageCalc Window-Exe Generator +:: summary: create a GarageCalc-executable for Windows (version with no-console-windows as well as version with console windows for traces) :: file: pyinstaller.cmd :: date: version author :: 2021-06-27 1 paul salajean :: -------------------------------------------------------------------------------------------------------------------------------------- -SET version="v0.1" +SET version="v0.4" SET release_dir="D:\Temp\Prog\ownCloud\profp@uberspace\transfer" SET prev_dir=%cd% -SET reinstall_venv="true" +SET reinstall_venv="false" SET do_zip="false" CD .. -ECHO Creating GarageCalc1 Windows.exe-version in folder %cd%\dist +ECHO Creating GarageCalc Windows.exe-version in folder %cd%\dist PAUSE REM pyinstaller --noconfirm --log-level=ERROR ^ REM --onedir --nowindow ^ REM --add-data="README;." ^ REM --add-data="image1.png;img" ^ REM --add-data="img;doc;ui" ^ -REM --add-data="LICENSE.txt;changelog.md;GarageCalc1.bat" ^ +REM --add-data="LICENSE.txt;changelog.md;GarageCalc.bat" ^ REM --add-binary="libfoo.so;lib" ^ REM --hidden-import=secret1 ^ REM --hidden-import=secret2 ^ -REM --icon=.\img\GarageCalc1.ico ^ +REM --icon=.\img\GarageCalc.ico ^ REM --debug=imports ^ REM --key=N0T1me40pp0ssum5 REM --paths=.\src ^ -REM GarageCalc1.spec +REM GarageCalc.spec REM The key-string is a string of 16 characters which is used to encrypt each file of Python byte-code before it is stored in the archive inside the executable file. REM This feature uses the "tinyaes" module internally for the encryption. REM @@ -55,21 +55,21 @@ python -m pip install -r requirements.txt :PYINSTALL IF %reinstall_venv%=="false" CALL .\env2\Scripts\activate.bat ECHO Running "pyinstaller"... -REM pyinstaller .\main.py --name=GarageCalc1 --noconfirm --console --clean --onedir --log-level=ERROR --hidden-import=PySide2.QtXml --icon=.\img\GarageCalc1.ico --add-data="LICENSE;." --add-data="README.md;." --add-data="changelog.md;." --add-data="*.ui;." --add-data="img;.\img" -pyinstaller .\src\main.py --name=GarageCalc1 --noconfirm --windowed --clean --onefile --log-level=ERROR --hidden-import=PySide2.QtXml ^ +REM pyinstaller .\main.py --name=GarageCalc --noconfirm --console --clean --onedir --log-level=ERROR --hidden-import=PySide2.QtXml --icon=.\img\GarageCalc.ico --add-data="LICENSE;." --add-data="README.md;." --add-data="changelog.md;." --add-data="*.ui;." --add-data="img;.\img" +REM --windowed +pyinstaller .\src\main.py --name=GarageCalc --noconfirm --windowed --clean --onefile --log-level=ERROR --hidden-import=PySide2.QtXml ^ --icon=.\img\icons8-garage-32.ico ^ - --add-data="LICENSE.txt;." ^ - --add-data="README.md;." ^ - --add-data="changelog.md;." ^ - --add-data="requirements.txt;." ^ - --add-data=".\src\*.ui;." ^ + --add-data="*.txt;." ^ + --add-data="*.md;." ^ + --add-data="ui;.\ui" ^ + --add-data="i18n;.\i18n" ^ --add-data="img;.\img" -::MOVE .\dist\GarageCalc1\*.md .\dist\ -::MOVE .\dist\GarageCalc1\LICENSE .\dist\ +::MOVE .\dist\GarageCalc\*.md .\dist\ +::MOVE .\dist\GarageCalc\LICENSE .\dist\ ::clean-up img-folder -::MOVE .\dist\GarageCalc1\img .\dist\img>NUL +::MOVE .\dist\GarageCalc\img .\dist\img>NUL ::Remove temp dir and files DEL /Q *.spec>NUL @@ -83,7 +83,7 @@ IF %do_zip%=="false" GOTO END ::-mx5 = This is default (compression is normal). ::-mx7 = Maximum compression. ::-mx9 = Ultra compression. -"C:\Program Files\7-zip\7z.exe" a %release_dir%\GarageCalc1_%version%_portable.exe -mx9 -sfx7z.sfx .\dist\* +"C:\Program Files\7-zip\7z.exe" a %release_dir%\GarageCalc_%version%_portable.exe -mx9 -sfx7z.sfx .\dist\* ::Disable Virtual env CALL .\env2\Scripts\deactivate.bat diff --git a/scripts/pyinstaller_v2.cmd b/scripts/pyinstaller_v2.cmd deleted file mode 100644 index 5892f60..0000000 --- a/scripts/pyinstaller_v2.cmd +++ /dev/null @@ -1,97 +0,0 @@ -@ECHO OFF -:: -------------------------------------------------------------------------------------------------------------------------------------- -:: project: GarageCalc Window-Exe Generator -:: summary: create a GarageCalc-executable for Windows (version with no-console-windows as well as version with console windows for traces) -:: file: pyinstaller.cmd -:: date: version author -:: 2021-06-27 1 paul salajean -:: -------------------------------------------------------------------------------------------------------------------------------------- -SET version="v0.4" -SET release_dir="D:\Temp\Prog\ownCloud\profp@uberspace\transfer" - -SET prev_dir=%cd% -SET reinstall_venv="false" -SET do_zip="false" - -CD .. - -ECHO Creating GarageCalc Windows.exe-version in folder %cd%\dist -PAUSE -REM pyinstaller --noconfirm --log-level=ERROR ^ -REM --onedir --nowindow ^ -REM --add-data="README;." ^ -REM --add-data="image1.png;img" ^ -REM --add-data="img;doc;ui" ^ -REM --add-data="LICENSE.txt;changelog.md;GarageCalc.bat" ^ -REM --add-binary="libfoo.so;lib" ^ -REM --hidden-import=secret1 ^ -REM --hidden-import=secret2 ^ -REM --icon=.\img\GarageCalc.ico ^ -REM --debug=imports ^ -REM --key=N0T1me40pp0ssum5 -REM --paths=.\src ^ -REM GarageCalc.spec -REM The key-string is a string of 16 characters which is used to encrypt each file of Python byte-code before it is stored in the archive inside the executable file. -REM This feature uses the "tinyaes" module internally for the encryption. -REM - -::one dir: -ECHO ...Running... - -RMDIR /S /Q .\dist>nul -RMDIR /S /Q .\build>nul - -::Use Virtual env -IF %reinstall_venv%=="false" GOTO PYINSTALL -ECHO Installing virtual env as ".\env2"... -RMDIR /S /Q .\env2>NUL -python -m venv env2 -CALL .\env2\Scripts\activate.bat - -ECHO Installing necessary python packages... -python -m pip install --upgrade pip -python -m pip install -r requirements.txt - -:PYINSTALL -IF %reinstall_venv%=="false" CALL .\env2\Scripts\activate.bat -ECHO Running "pyinstaller"... -REM pyinstaller .\main.py --name=GarageCalc --noconfirm --console --clean --onedir --log-level=ERROR --hidden-import=PySide2.QtXml --icon=.\img\GarageCalc.ico --add-data="LICENSE;." --add-data="README.md;." --add-data="changelog.md;." --add-data="*.ui;." --add-data="img;.\img" -REM --windowed -pyinstaller .\src\main.py --name=GarageCalc --noconfirm --windowed --clean --onefile --log-level=ERROR --hidden-import=PySide2.QtXml ^ - --icon=.\img\icons8-garage-32.ico ^ - --add-data="*.txt;." ^ - --add-data="*.md;." ^ - --add-data="ui;.\ui" ^ - --add-data="i18n;.\i18n" ^ - --add-data="img;.\img" - -::MOVE .\dist\GarageCalc\*.md .\dist\ -::MOVE .\dist\GarageCalc\LICENSE .\dist\ - -::clean-up img-folder -::MOVE .\dist\GarageCalc\img .\dist\img>NUL - -::Remove temp dir and files -DEL /Q *.spec>NUL -RMDIR /S /Q .\build - -::Create self extracting archive -IF %do_zip%=="false" GOTO END -::-mx0 = Don't compress at all - just copy the contents to archive. -::-mx1 = Consumes least time, but compression is low. -::-mx3 = Better than -mx1. -::-mx5 = This is default (compression is normal). -::-mx7 = Maximum compression. -::-mx9 = Ultra compression. -"C:\Program Files\7-zip\7z.exe" a %release_dir%\GarageCalc_%version%_portable.exe -mx9 -sfx7z.sfx .\dist\* - -::Disable Virtual env -CALL .\env2\Scripts\deactivate.bat - -:END -CD %prev_dir% - -ECHO Done. Check %prev_dir%\..\dist -IF %do_zip%=="true" ECHO Done. Check %release_dir% - -PAUSE diff --git a/src/clsTableWidget.py b/src/clsTableWidget.py index 9d9b686..15f362f 100644 --- a/src/clsTableWidget.py +++ b/src/clsTableWidget.py @@ -65,12 +65,14 @@ class TableWidget(QTableWidget): # self.setEditTriggers(QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed | QAbstractItemView.AnyKeyPressed) - self.headers = self.verticalHeader() - self.headers.setContextMenuPolicy(Qt.CustomContextMenu) - self.headers.customContextMenuRequested.connect(self.on_rowheadercontext_menu) - self.headers.setSelectionMode(QAbstractItemView.SingleSelection) - self.headers.sectionClicked.connect(self.select_row) - self.headers.setSectionsMovable(True) + self.vertHeader = self.verticalHeader() + self.vertHeader.setContextMenuPolicy(Qt.CustomContextMenu) + self.vertHeader.customContextMenuRequested.connect(self.on_rowheadercontext_menu) + self.vertHeader.setSelectionMode(QAbstractItemView.SingleSelection) + self.vertHeader.sectionClicked.connect(self.select_row) + self.vertHeader.setSectionsMovable(True) + # optimize row height + self.resizeRowsToContents() self.row_selected = False @@ -114,7 +116,7 @@ class TableWidget(QTableWidget): row_delete_items = menu.addAction(QIcon(ICON_ERASER), QCoreApplication.translate("TableWidget", "Delete items")) ac = menu.exec_(self.mapToGlobal(position)) - row = self.headers.logicalIndexAt(position) + row = self.vertHeader.logicalIndexAt(position) if ac == row_cut: self.item_cut() diff --git a/src/main.py b/src/main.py index 0f22d8f..2d86660 100644 --- a/src/main.py +++ b/src/main.py @@ -15,7 +15,7 @@ import configparser # Third party imports from PySide2.QtWidgets import QApplication, QMainWindow, QTableWidgetItem, QStatusBar, QFileDialog, \ - QAbstractItemView, QMenu, QMessageBox, QHBoxLayout, QVBoxLayout, QAction, QActionGroup + QAbstractItemView, QMenu, QMessageBox, QHBoxLayout, QVBoxLayout, QAction, QActionGroup, QSizePolicy from PySide2.QtGui import QIcon from PySide2.QtCore import QFile, QSize, Qt, QCoreApplication, QTranslator from PySide2.QtUiTools import QUiLoader @@ -28,7 +28,7 @@ from utils import show_about, resource_path from clsTableWidget import TableWidget # Local globals -APP_VERSION = "v0.4.2" +APP_VERSION = "v0.5" DIR_APPDATA = os.getenv('LOCALAPPDATA') @@ -56,20 +56,25 @@ COL_LENGTH = 1 COL_WIDTH = 2 COL_HEIGHT = 3 COL_WEIGHT = 4 +COL_COMMENT = 5 DEFAULT_GARAGE_LENGTH = "6" DEFAULT_GARAGE_WIDTH = "2.5" DEFAULT_GARAGE_HEIGHT = "2.5" -TBL_STUFF_COL_COUNT = 5 +TBL_STUFF_COL_COUNT = 6 TBL_STUFF_ROW_COUNT = 50 +WIN_WIDTH = 700 +WIN_HEIGHT = 640 + TXT_UNSAVED_CHANGES = QCoreApplication.translate("main", "There are unsaved entries. Without saving, all changes are lost. Continue anyway?") #################################################################### def main(): qApp = QApplication(sys.argv) + global APP_NAME qApp.setApplicationName(APP_NAME) qApp.setApplicationDisplayName(APP_DISPNAME) qApp.setApplicationVersion(APP_VERSION) @@ -108,19 +113,39 @@ def main(): qApp.installTranslator(translator) + app_name = qApp.translate("main", APP_NAME) + qApp.setApplicationName(app_name) + winMain = MainWindow(language) - if qApp.primaryScreen().size().width() <= 700: + if qApp.primaryScreen().size().width() <= 800: winMain.showMaximized() else: - winMain.resize(610, 640) - - winMain.show() + winMain.resize(WIN_WIDTH, WIN_HEIGHT) + winMain.show() sys.exit(qApp.exec_()) #################################################################### +def create_examples(table): + from random import randint, choice + from string import ascii_letters, punctuation, digits + min = 12 + max = 15 + string_format = ascii_letters + + for row in range(table.rowCount()): + generated_string1 = "".join(choice(string_format) for x in range(randint(min, max))) + generated_string2 = "".join(choice(string_format) for x in range(randint(min, max))) + + table.setItem(row, 0, QTableWidgetItem(generated_string1)) + table.setItem(row, 1, QTableWidgetItem(str(randint(1, 10)))) + table.setItem(row, 2, QTableWidgetItem(str(randint(1, 10)))) + table.setItem(row, 3, QTableWidgetItem(str(randint(1, 10)))) + table.setItem(row, 4, QTableWidgetItem(str(randint(20, 100)))) + table.setItem(row, 5, QTableWidgetItem(generated_string2)) + #################################################################### class MainWindow(QMainWindow): def __init__(self, language): @@ -140,15 +165,16 @@ class MainWindow(QMainWindow): self.create_toolbar() self.create_statusbar() - global APP_NAME - APP_NAME = qApp.setApplicationName(qApp.translate("main", "Garage Space Calculator")) - - self.statusBar.showMessage(f"{APP_NAME} {APP_VERSION} - {APP_AUTHOR}", 5000) + self.statusBar.showMessage(f"{APP_DISPNAME} {APP_VERSION} - {APP_AUTHOR}", 5000) self.calc_voluminae() self.ui.efWeight.setText(str("0")) self.retranslateUi() self.ui.tableStuff.setFocus() + # TODO: disable for PROD! + create_examples(self.ui.tableStuff) + self.ui.tableGarage.setItem(0, 3, QTableWidgetItem("Garázs az udvaron")) + def create_menu(self, language=None): menuMain = self.menuBar() self.menuSettings = menuMain.addMenu(QCoreApplication.translate("main", "&Settings")) @@ -176,18 +202,24 @@ class MainWindow(QMainWindow): self.menuLanguage.setTitle(QCoreApplication.translate("main", "Language")) # tables - self.ui.tableGarage.setVerticalHeaderLabels([QCoreApplication.translate("main","Garage")]) + self.ui.tableGarage.setVerticalHeaderLabels([ + QCoreApplication.translate("main","Garage")]) + self.ui.tableGarage.setHorizontalHeaderLabels([ QCoreApplication.translate("main","Length") + " [m]", QCoreApplication.translate("main","Width") + " [m]", - QCoreApplication.translate("main","Height") + " [m]" + QCoreApplication.translate("main","Height") + " [m]", + QCoreApplication.translate("main","Comment") ]) - self.ui.tableStuff.setHorizontalHeaderLabels([QCoreApplication.translate("main","Stuff"), + self.ui.tableStuff.setHorizontalHeaderLabels([ + QCoreApplication.translate("main","Stuff"), QCoreApplication.translate("main","Length") + " [m]", QCoreApplication.translate("main","Width") + " [m]", QCoreApplication.translate("main","Height") + " [m]", - QCoreApplication.translate("main","Weight") + " [m]"]) + QCoreApplication.translate("main","Weight") + " [m]", + QCoreApplication.translate("main","Comment") + ]) # labels self.ui.gbGarage.setTitle(QCoreApplication.translate("main","Dimension of the garage")) @@ -220,8 +252,13 @@ class MainWindow(QMainWindow): self.ui.tableStuff = TableWidget() self.ui.tableStuff.setColumnCount(TBL_STUFF_COL_COUNT) self.ui.tableStuff.setRowCount(TBL_STUFF_ROW_COUNT) + self.ui.tableStuff.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + + self.ui.splitter.setStretchFactor(1, 10) + layoutGb.addWidget(self.ui.tableStuff) + def create_actions(self): self.actionNew = QAction() self.actionNew.setIcon(QIcon(resource_path(ICON_NEW))) @@ -310,7 +347,7 @@ class MainWindow(QMainWindow): if self.opened_file: self.setWindowTitle(self.opened_file) else: - self.setWindowTitle(f"{APP_NAME} {APP_VERSION} by {APP_AUTHOR}") + self.setWindowTitle(f"{qApp.applicationName()} {APP_VERSION} - {APP_AUTHOR}") self.ui.efVol_Free.setStyleSheet("") self.is_modified = False @@ -358,10 +395,12 @@ class MainWindow(QMainWindow): garage_length = 0 garage_width = 0 garage_height = 0 + garage_comment = "" item_length = tblGarage.item(0, 0) item_width = tblGarage.item(0, 1) item_height = tblGarage.item(0, 2) + item_comment = tblGarage.item(0, 3) # loop over table Garage for row in range(tblGarage.rowCount()): @@ -389,8 +428,12 @@ class MainWindow(QMainWindow): except ValueError: garage_height = 0.0 + # get garage comment + if item_comment: + garage_comment = item_comment.text() + if garage_length or garage_width or garage_height: - writer.writerow([QCoreApplication.translate("main","Garage"), garage_length, garage_width, garage_height]) + writer.writerow([QCoreApplication.translate("main","Garage"), garage_length, garage_width, garage_height, garage_comment]) # loop over table Stuff for row in range(tblStuff.rowCount()): @@ -399,12 +442,14 @@ class MainWindow(QMainWindow): width = None height = None weight = None + comment = None item_stuff = tblStuff.item(row, COL_STUFF) item_length = tblStuff.item(row, COL_LENGTH) item_width = tblStuff.item(row, COL_WIDTH) item_height = tblStuff.item(row, COL_HEIGHT) item_weight = tblStuff.item(row, COL_WEIGHT) + item_comment = tblStuff.item(row, COL_COMMENT) if item_stuff: stuff_text = item_stuff.text() @@ -433,8 +478,11 @@ class MainWindow(QMainWindow): except ValueError: weight = None + if item_comment: + comment = item_comment.text() + if item_stuff or item_length or item_width or item_height or item_weight: - writer.writerow([stuff_text, length, width, height, weight]) + writer.writerow([stuff_text, length, width, height, weight, comment]) is_file_saved = True self.opened_file = os.path.basename(fileName) @@ -478,10 +526,12 @@ class MainWindow(QMainWindow): garage_length = row[1] garage_width = row[2] 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_COMMENT-1, QTableWidgetItem(garage_comment)) except IndexError as ex: pass @@ -493,12 +543,14 @@ class MainWindow(QMainWindow): stuff_width = row[2] stuff_height = row[3] stuff_weight = row[4] + 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))) + tblStuff.setItem(row_idx - 1, COL_COMMENT, QTableWidgetItem(stuff_comment)) except IndexError as ex: pass @@ -506,6 +558,8 @@ class MainWindow(QMainWindow): row_idx += 1 tblStuff.setRowCount(TBL_STUFF_ROW_COUNT) + # optimize row height + tblStuff.resizeRowsToContents() self.is_modified = False self.opened_file = os.path.basename(fileName) @@ -513,7 +567,7 @@ class MainWindow(QMainWindow): if fileName: self.setWindowTitle(self.opened_file) else: - self.setWindowTitle(f"{APP_NAME} {APP_VERSION} by {APP_AUTHOR}") + self.setWindowTitle(f"{qApp.applicationName()} {APP_VERSION} - {APP_AUTHOR}") def file_export(self): tblGarage = self.ui.tableGarage @@ -540,8 +594,10 @@ class MainWindow(QMainWindow): worksheet.write(start_row, COL_LENGTH, QCoreApplication.translate("main","Length") + " [m]") worksheet.write(start_row, COL_WIDTH, QCoreApplication.translate("main","Width") + " [m]") worksheet.write(start_row, COL_HEIGHT, QCoreApplication.translate("main","Height") + " [m]") + worksheet.write(start_row, COL_COMMENT, QCoreApplication.translate("main","Comment")) worksheet.set_column(0, 0, 25) worksheet.set_column(1, 3, 10) + worksheet.set_column(4, 5, 20) start_row = 2 # loop over table Garage @@ -567,9 +623,13 @@ class MainWindow(QMainWindow): except ValueError: garage_height = 0.0 + # get garage comment + garage_comment = tblGarage.item(0, 3).text() + worksheet.write(start_row + row, COL_LENGTH, garage_length) worksheet.write(start_row + row, COL_WIDTH, garage_width) worksheet.write(start_row + row, COL_HEIGHT, garage_height) + worksheet.write(start_row + row, COL_COMMENT, garage_comment) start_row = 4 worksheet.write(start_row, 0, QCoreApplication.translate("main", "Dimensions of the objects to be stored")) @@ -579,6 +639,7 @@ class MainWindow(QMainWindow): worksheet.write(start_row, COL_WIDTH, QCoreApplication.translate("main","Width") + " [m]") worksheet.write(start_row, COL_HEIGHT, QCoreApplication.translate("main","Height") + " [m]") worksheet.write(start_row, COL_WEIGHT, QCoreApplication.translate("main","Weight") + " [kg]") + worksheet.write(start_row, COL_COMMENT, QCoreApplication.translate("main","Comment") ) start_row = 6 # loop over table Stuff @@ -589,6 +650,7 @@ class MainWindow(QMainWindow): item_width = tblStuff.item(row, COL_WIDTH) item_height = tblStuff.item(row, COL_HEIGHT) item_weight = tblStuff.item(row, COL_WEIGHT) + item_comment = tblStuff.item(row, COL_COMMENT) if item_stuff: stuff_text = item_stuff.text() @@ -627,6 +689,11 @@ class MainWindow(QMainWindow): except ValueError: pass + if item_comment: + comment = item_comment.text() + if len(comment)>0: + worksheet.write(start_row + row, COL_COMMENT, comment) + if item_stuff or item_length or item_width or item_height or item_weight: row_idx += 1 diff --git a/ui/main.ui b/ui/main.ui index 60cf484..c4c02e8 100644 --- a/ui/main.ui +++ b/ui/main.ui @@ -6,96 +6,134 @@ 0 0 - 604 - 596 + 605 + 595 Form - + - - - - 0 - 91 - + + + QFrame::NoFrame - - - 16777215 - 91 - + + QFrame::Plain - - Dimension der Garage + + 1 - + + 0 + + + Qt::Vertical + + true - - - - - - 0 - 0 - - - - - 0 - 58 - - - - - 16777215 - 58 - - - - true - - - - Garage - - - - - Länge [m] - - - - - Breite [m] - - - - - Höhe [m] - - - - - - - - - - - Dimensionen der zu verstauenden Gegenstände + + 5 - + true - + + + + 0 + 100 + + + + Dimension der Garage + + + true + + + + + + 1 + + + 4 + + + true + + + true + + + + Garage + + + + + Länge [m] + + + + + Breite [m] + + + + + Höhe [m] + + + + + Kommentar + + + + + + + + + + 0 + 0 + + + + + 0 + 350 + + + + Dimensionen der zu verstauenden Gegenstände + + + true + + + + + + 0 + 0 + + + + + 0 + 0 + + Ergebnis @@ -230,13 +268,6 @@ - - tableGarage - efVol_Garage - efVol_Stuff - efVol_Free - efWeight -