diff --git a/changelog.md b/changelog.md index 73058ff..c9b13fc 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,15 @@ # Changelog GarageCalc1 +## [0.4.1] - 2021-07-01 +## Added +- Dynamisches Layout +- Programm startet maximiert wenn Breite der Auflösung <= 700 pixel, ansonsten 610 * 640 + +## [0.4] - 2021-06-30 +## Added +- Einzelne Zellen lassen sich nun selektieren/kopieren/verschieben/löschen (zusätzlich zu Reihen) +- Kontextmenü für Zellen + ## [0.3] - 2021-06-29 ### Added - Warnt beim Beenden falls ungespeicherte Einträge vorhanden sind diff --git a/src/main.py b/src/main.py index de26027..a5ff8db 100644 --- a/src/main.py +++ b/src/main.py @@ -28,14 +28,14 @@ from utils import show_about, resource_path from clsTableWidget import TableWidget # Local globals -APP_VERSION = "v0.4" +APP_VERSION = "v0.4.1" DIR_APPDATA = os.getenv('LOCALAPPDATA') -APP_NAME = QCoreApplication.translate("main", "Garage Space Calculator") +APP_NAME = "Garage Space Calculator" APP_DISPNAME = "GarageCalc" APP_AUTHOR = "Paul Salajean" -APP_DESCR = QCoreApplication.translate("main", "Calculates available garage space") +APP_DESCR = "Calculates available garage space" APP_COPYRIGHT = "(c) Paul Salajean 2021" APP_WEBSITE = "https://gitlab.com/ProfP303" APP_DESKTOPFILENAME = APP_DISPNAME @@ -66,7 +66,63 @@ TBL_STUFF_ROW_COUNT = 50 TXT_UNSAVED_CHANGES = QCoreApplication.translate("main", "There are unsaved entries. Without saving, all changes are lost. Continue anyway?") -class MyMainWindow(QMainWindow): +#################################################################### +def main(): + qApp = QApplication(sys.argv) + + qApp.setApplicationName(APP_NAME) + qApp.setApplicationDisplayName(APP_DISPNAME) + qApp.setApplicationVersion(APP_VERSION) + qApp.description = APP_DESCR + qApp.copyright = APP_COPYRIGHT + qApp.website = APP_WEBSITE + 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'] + else: + 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() + + print("Current dir:", os.getcwd()) + if language == "Deutsch": + print("Loading german language file.") + translator.load(resource_path('./i18n/de_DE')) + elif language == "Magyar": + print("Loading hungarian langauge file.") + translator.load(resource_path('./i18n/hu_HU')) + else: + print(f"Unknown language setting '{language}' -> defaulting to english language.") + + qApp.installTranslator(translator) + + winMain = MainWindow(language) + + if qApp.primaryScreen().size().width() <= 700: + winMain.showMaximized() + else: + winMain.resize(610, 640) + + winMain.show() + + sys.exit(qApp.exec_()) + +#################################################################### + +#################################################################### +class MainWindow(QMainWindow): def __init__(self, language): super().__init__() @@ -83,8 +139,10 @@ class MyMainWindow(QMainWindow): self.create_actions() self.create_toolbar() self.create_statusbar() + global APP_NAME - APP_NAME = qApp.translate("main", "Garage Space Calculator") + APP_NAME = qApp.setApplicationName(qApp.translate("main", "Garage Space Calculator")) + self.statusBar.showMessage(f"{APP_NAME} {APP_VERSION} - {APP_AUTHOR}", 5000) self.calc_voluminae() self.ui.efWeight.setText(str("0")) @@ -157,20 +215,12 @@ class MyMainWindow(QMainWindow): self.ui = loader.load(ui_file, self) ui_file.close() - #self.ui.tableStuff = TableWidget(self.ui.gbStuff) + # implement custom class 'TableWidget' + layoutGb = self.ui.gbStuff.layout() self.ui.tableStuff = TableWidget() self.ui.tableStuff.setColumnCount(TBL_STUFF_COL_COUNT) self.ui.tableStuff.setRowCount(TBL_STUFF_ROW_COUNT) - self.ui.tableStuff.move(10, 23) - self.ui.tableStuff.resize(541,268) - - # create layout - #hBox = QHBoxLayout() - #hBox.addWidget(self.ui.tableStuff) - #self.ui.tableStuff.move(10, 23) - self.ui.tableStuff.setParent(self.ui.gbStuff) - #self.ui.gbStuff.setLayout(hBox) - + layoutGb.addWidget(self.ui.tableStuff) def create_actions(self): self.actionNew = QAction() @@ -782,50 +832,7 @@ class MyMainWindow(QMainWindow): self.retranslateUi() +#################################################################### + if __name__ == "__main__": - qApp = QApplication([]) - - qApp.setApplicationName(APP_NAME) - qApp.setApplicationDisplayName(APP_DISPNAME) - qApp.setApplicationVersion(APP_VERSION) - qApp.description = APP_DESCR - qApp.copyright = APP_COPYRIGHT - qApp.website = APP_WEBSITE - 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'] - else: - 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() - - print("Current dir:", os.getcwd()) - if language == "Deutsch": - print("Loading german language file.") - translator.load(resource_path('./i18n/de_DE')) - elif language == "Magyar": - print("Loading hungarian langauge file.") - translator.load(resource_path('./i18n/hu_HU')) - else: - print(f"Unknown language setting '{language}' -> defaulting to english language.") - - qApp.installTranslator(translator) - - winMain = MyMainWindow(language) - # winMain.setWidth(600) - # winMain.setHeight(625) - winMain.resize(610, 640) - winMain.show() - sys.exit(qApp.exec_()) + main() diff --git a/src/utils.py b/src/utils.py index 9d008bb..a6d03e5 100644 --- a/src/utils.py +++ b/src/utils.py @@ -34,13 +34,10 @@ def show_about(): msg = QMessageBox() msg.setIconPixmap(QPixmap(resource_path(APP_ICON))) - APP_NAME = qApp.translate("main", "Garage Space Calculator") - APP_DESCR = qApp.translate("main", "Calculates available garage space") - text = "