diff --git a/Gui/BackupSettings.qml b/Gui/BackupSettings.qml index 31a6076..d602c3d 100644 --- a/Gui/BackupSettings.qml +++ b/Gui/BackupSettings.qml @@ -30,7 +30,7 @@ GridLayout { id: saveConfig text: qsTr("Jetzt sichern!") - onClicked: dialog.open() + onClicked: utilityDialogs.item.backup_config.open() } Label { @@ -41,75 +41,17 @@ GridLayout { id: saveEncryption text: qsTr("Jetzt sichern!") - onClicked: apploader.item.recoverEnc.open() + onClicked: utilityDialogs.item.backup_encrypt_pw.open() } Item { id: spacer Layout.fillHeight: true } - Dialog + + Loader { - anchors.centerIn: parent - id: dialog - title: "Title" - standardButtons: Dialog.Apply | Dialog.Cancel - - onApplied: - { - - if (configPwd.text === repeatConfigPwd.text) - { - - saveConfigFile.open() - } - else - { - configPwd.text = "" - configPwd.placeholderText = qsTr("Passwort stimmt nicht überein") - configPwd.placeholderTextColor = "red" - repeatConfigPwd.placeholderText = qsTr("") - repeatConfigPwd.text = "" - } - } - onRejected: console.log("Cancel clicked") - GridLayout - { - id: gridPw - columns: 2 - Label - { - text: qsTr("Passwort eingeben") - } - TextField - { - - id: configPwd - placeholderText: qsTr("Sicherungspasswort festlegen") - } - Label - { - text: qsTr("Passwort wiederholen") - } - TextField - { - property string name: "password" - id: repeatConfigPwd - placeholderText: qsTr("Sicherungspasswort wiederholen") - } - - } - } - FileDialog - { - id: saveConfigFile - fileMode: FileDialog.SaveFile - nameFilters: ["PYQCRM Recovery files (*.pyqrec)"] - currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0] - onAccepted: - { - var pw = JsLib.parseForm(gridPw) - config.backupConfig(saveConfigFile.currentFile, pw["password"]) - } + id: utilityDialogs + source: "UtilityDialogs.qml" } } diff --git a/Gui/Firststart.qml b/Gui/Firststart.qml index 031d688..1f87c58 100644 --- a/Gui/Firststart.qml +++ b/Gui/Firststart.qml @@ -7,11 +7,12 @@ import QtCore import "../js/qmldict.js" as Qmldict + Item { property string recpass: "" property bool adminAvailable: true - property alias recoverEnc: recoveryPaswordDialog + id: firstStartItem anchors.fill: parent @@ -72,7 +73,6 @@ Item MessageDialog { id: recoveryDialog - text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?") title: qsTr("Wiederherstellen") buttons: MessageDialog.Yes | MessageDialog.No @@ -156,6 +156,12 @@ Item } } + Loader + { + id: utilityDialogs + source: "UtilityDialogs.qml" + } + Component.onCompleted: { config.dbConnectionError.connect(onDbConnectionError) @@ -163,15 +169,10 @@ Item config.backupEncryptionKey.connect(onBackupEncryptionKey) } - function gotoLogin() - { - appLoader.source= "LoginScreen.qml" - topBar.visible = true - } - function onBackupEncryptionKey() { - recoveryDialog.open() + + utilityDialogs.item.recoveryDialog.open() } function onDbConnectionError(msg, success) @@ -192,5 +193,4 @@ Item firstStart.push("AdminUserConfig.qml") } } - } diff --git a/Gui/ObjectTable.qml b/Gui/ObjectTable.qml index 5ee6ed7..aee6002 100644 --- a/Gui/ObjectTable.qml +++ b/Gui/ObjectTable.qml @@ -12,6 +12,7 @@ Item { id: objectsStack anchors.fill: parent initialItem: "ObjectsTable.qml" + anchors.margins: 9 } } diff --git a/Gui/OfferTable.qml b/Gui/OfferTable.qml new file mode 100644 index 0000000..7f16a20 --- /dev/null +++ b/Gui/OfferTable.qml @@ -0,0 +1,17 @@ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import Qt.labs.qmlmodels + + +Item +{ + StackView + { + id: employeesStack + anchors.fill: parent + initialItem: "OffersTable.qml" + anchors.margins: 9 + } +} + diff --git a/Gui/OffersTable.qml b/Gui/OffersTable.qml new file mode 100644 index 0000000..8c64582 --- /dev/null +++ b/Gui/OffersTable.qml @@ -0,0 +1,15 @@ +import QtQuick +import QtQuick.Layouts +import QtQuick.Controls +import Qt.labs.qmlmodels + +Item +{ + property var availableFilters: [] + + SearchBar + { + id:searchBar + anchors.margins: 9 + } +} diff --git a/Gui/TopBar.qml b/Gui/TopBar.qml index 16bf968..3af0fae 100644 --- a/Gui/TopBar.qml +++ b/Gui/TopBar.qml @@ -138,6 +138,37 @@ RowLayout } } + Button + { + id: offers + flat: true + text: qsTr("Angebote") + implicitWidth: abrechnung.implicitContentWidth + 10 + Layout.margins: 3 + background: Rectangle + { + id: offersBackie + border.width: offers.activeFocus ? 2 : 1 + border.color: "#888" + radius: 4 + gradient: Gradient + { + GradientStop { position: 0 ; color: offers.pressed ? "#000" : "#001" } + GradientStop { position: 1 ; color: offers.pressed ? "#100" : "#000" } + } + } + onClicked: + { + appLoader.source = "OfferTable.qml" + mitoBackie.border.width = 2 + dashiBackie.border.width = 1 + kundiBackie.border.width = 1 + invoBackie.border.width = 1 + objBackie.border.width = 1 + offersBackie.border.width = 1 + } + } + Button { id: abrechnung diff --git a/Gui/UtilityDialogs.qml b/Gui/UtilityDialogs.qml new file mode 100644 index 0000000..2a19905 --- /dev/null +++ b/Gui/UtilityDialogs.qml @@ -0,0 +1,208 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Dialogs +import QtCore +import "../js/qmldict.js" as JsLib + +Item +{ + id: utilityDialogs + property alias backup_config: backupConfig + property alias backup_encrypt_pw: recoveryPasswordDialog + + property var recpass + property var configpass + Dialog + { + + anchors.centerIn: parent + id: backupConfig + title: "Backup Config" + standardButtons: Dialog.Apply | Dialog.Cancel + + onApplied: + { + + if (configPwd.text === repeatConfigPwd.text) + { + configpass = repeatConfigPwd.text + saveConfigFile.open() + } + else + { + configPwd.text = "" + configPwd.placeholderText = qsTr("Passwort stimmt nicht überein") + configPwd.placeholderTextColor = "red" + repeatConfigPwd.placeholderText = qsTr("") + repeatConfigPwd.text = "" + } + } + onRejected: resetRecoveryConfigDialog() + GridLayout + { + id: gridPw + columns: 2 + Label + { + text: qsTr("Passwort eingeben") + } + TextField + { + + id: configPwd + placeholderText: qsTr("Sicherungspasswort festlegen") + echoMode: TextInput.Password + implicitWidth: 300 + } + Label + { + text: qsTr("Passwort wiederholen") + } + TextField + { + property string name: "password" + id: repeatConfigPwd + placeholderText: qsTr("Sicherungspasswort wiederholen") + echoMode: TextInput.Password + implicitWidth: 300 + } + + } + + } + + FileDialog + { + id: saveConfigFile + fileMode: FileDialog.SaveFile + nameFilters: ["PYQCRM Recovery files (*.pyqrec)"] + currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0] + onAccepted: + { + config.backupConfig(saveConfigFile.currentFile, configpass) + } + onRejected: + { + backupConfig.close() + resetRecoveryConfigDialog() + } + } + + MessageDialog + { + id: recoveryDialog + + text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?") + title: qsTr("Wiederherstellen") + buttons: MessageDialog.Yes | MessageDialog.No + onAccepted: recoveryPasswordDialog.open() + onRejected: gotoLogin() + } + + MessageDialog + { + id: conErrDialog + text: qsTr("Datenbankverbindung fehlgeschlagen") + title: qsTr("Datenbank Verbindung") + } + + Dialog + { + + id: recoveryPasswordDialog + modal: true + title: qsTr("Wiederherstellung") + anchors.centerIn: parent + standardButtons: Dialog.Apply | Dialog.Cancel + onApplied: + { + if (recoveryPasswordInput.text === repeatRecoveryPasswordInput.text) + { + recpass = recoveryPasswordInput.text + saveRecoveryDialog.open() + } + else + { + recoveryPasswordInput.text = "" + recoveryPasswordInput.placeholderText = qsTr("Passwort stimmt nicht überein") + recoveryPasswordInput.placeholderTextColor = "red" + repeatRecoveryPasswordInput.placeholderText = qsTr("") + repeatRecoveryPasswordInput.text = "" + } + } + + onClosed: resetRecoveryPwDialog() + + ColumnLayout + { + GridLayout + { + columns: 2 + Label + { + text: qsTr("Wiederherstellungspasswort festlegen: ") + } + + TextField + { + id: recoveryPasswordInput + text: "" + echoMode: TextInput.Password + implicitWidth: 300 + placeholderText: qsTr("Hier Wiederherstellungspasswort eingeben") + } + Label + { + text: qsTr("Wiederherstellungspasswort wiederholen: ") + } + + TextField + { + id: repeatRecoveryPasswordInput + text: "" + echoMode: TextInput.Password + implicitWidth: 300 + placeholderText: qsTr("Hier Wiederherstellungspasswort wiederholen") + } + } + } + } + + FileDialog + { + id: saveRecoveryDialog + title: qsTr("Wiederherstellungsdatei") + fileMode: FileDialog.SaveFile + nameFilters: ["PYQCRM Recovery files (*.pyqrec)"] + currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0] + onAccepted: + { + config.backupEncryptkey(saveRecoveryDialog.currentFile, recpass) + } + + onRejected: + { + recoveryPasswordDialog.close() + resetRecoveryPwDialog() + } + } + + function resetRecoveryPwDialog() + { + recoveryPasswordInput.text = "" + recoveryPasswordInput.placeholderText = qsTr("Hier Wiederherstellungspasswort eingeben") + recoveryPasswordInput.placeholderTextColor = repeatRecoveryPasswordInput.placeholderTextColor + repeatRecoveryPasswordInput.text = "" + repeatRecoveryPasswordInput.placeholderText = qsTr("Hier Wiederherstellungspasswort wiederholen") + } + + function resetRecoveryConfigDialog() + { + configPwd.text = "" + configPwd.placeholderText = qsTr("Hier Wiederherstellungspasswort eingeben") + configPwd.placeholderTextColor = repeatConfigPwd.placeholderTextColor + repeatConfigPwd.text = "" + repeatConfigPwd.placeholderText = qsTr("Hier Wiederherstellungspasswort wiederholen") + } +} diff --git a/Gui/main.qml b/Gui/main.qml index f3c1c06..b68e806 100644 --- a/Gui/main.qml +++ b/Gui/main.qml @@ -62,6 +62,7 @@ ApplicationWindow property alias window: appWindow } + Dialog { id: importDialog @@ -117,7 +118,9 @@ ApplicationWindow Component.onCompleted: { + config.configurationReady.connect(goToLogin) systray.activated.connect(showWindow) + if(bad_config) { importDialog.open() @@ -129,6 +132,7 @@ ApplicationWindow } } + function showWindow(why) { if (why === 3) @@ -153,4 +157,10 @@ ApplicationWindow console.log("Main window closed!! Was soll ich tun? kann ich mich beenden?!") } } + + function goToLogin() + { + appLoader.source= "LoginScreen.qml" + topBar.visible = true + } } diff --git a/images/addoffer.svg b/images/addoffer.svg new file mode 100644 index 0000000..056d0e7 --- /dev/null +++ b/images/addoffer.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/lib/ConfigLoader.py b/lib/ConfigLoader.py index b2d58cc..7e70cd9 100644 --- a/lib/ConfigLoader.py +++ b/lib/ConfigLoader.py @@ -41,6 +41,7 @@ class ConfigLoader(QObject): else: config_dir.mkdir(0o750, True, True) + @Slot(dict, result = bool) def setConfig(self, app_config): # print(f"In {__file__} file, setConfig()") @@ -110,18 +111,13 @@ class ConfigLoader(QObject): self.backupEncryptionKey.emit() return admin - """###################################################""" - """ """ - """ TODO: Rename method and rename self.__encrypt_key """ - """ """ - """###################################################""" @Slot(str, str) - def saveRecoveryKey(self, recovery_file, recovery_password): - # print(f"In {__file__} file, saveRecoveryKey()") + def __saveData(self, recovery_file, recovery_password, data): + # print(f"In {__file__} file, __saveData()") local = False rp = self.__setRecoveryPassword(recovery_password) - rf = rp[1] + self.__encrypt_key + rp[0] + rf = rp[1] + data + rp[0] rf = Vermasseln().oscarVermasseln(rf, local) rec_file = urlparse(recovery_file) if os.name == "nt": @@ -197,7 +193,8 @@ class ConfigLoader(QObject): if ek: self.__config = toml.loads(ek) self.__saveConfig() - self.configurationReady.emit() + self.__configLoad() + else: self.invalidEncryptionKey.emit() except Exception as e: @@ -242,8 +239,9 @@ class ConfigLoader(QObject): @Slot(str, str) def backupConfig(self, filename, password): - self.__encrypt_key = toml.dumps(self.getConfig()) - self.saveRecoveryKey(filename, password) + conf_file = toml.dumps(self.getConfig()) + self.__saveData(filename, password, conf_file) + @Slot(dict) def saveCompanyInfo(self, company = None): @@ -263,3 +261,9 @@ class ConfigLoader(QObject): def systray(self): return self.__config['misc']['SYSTRAY'] + + @Slot(str, str) + def backupEncryptkey(self, filename, password): + encrypt_key = self.__config['pyqcrm']['ENCRYPTION_KEY'] + self.__saveData(filename, password, encrypt_key) + diff --git a/lib/DB/EmployeeModel.py b/lib/DB/EmployeeModel.py index d1c3862..64fb884 100644 --- a/lib/DB/EmployeeModel.py +++ b/lib/DB/EmployeeModel.py @@ -22,7 +22,6 @@ class EmployeeModel(QAbstractTableModel): self.__employee_dao.newEmployeeAdded.connect(self.__refreshView) self.__conf = ConfigLoader().getConfig() self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY'] - print(self.__key) self.__getData() @Slot(dict, bool) diff --git a/main.py b/main.py index 2bec9ea..8e54ad7 100644 --- a/main.py +++ b/main.py @@ -46,7 +46,7 @@ printers = None user = None def initializeProgram(): - #print(f"In {__file__} file, initializeProgram()") + print(f"In {__file__} file, initializeProgram()") global address_model, bad_config, business_model, user, business_type, contact_model, employee_model, object_model, db_con, printers if not bad_config: dbconf = config.getConfig()['database'] @@ -63,7 +63,11 @@ def initializeProgram(): object_model = ObjectModel() publishContext() +def configReady(): + global bad_config bad_config = False + initializeProgram() + def publishContext(): # print(f"In {__file__} file, publishContext()") @@ -98,7 +102,7 @@ if __name__ == "__main__": if not config.getConfig(): bad_config = True - config.configurationReady.connect(initializeProgram) + config.configurationReady.connect(configReady) else: initializeProgram() diff --git a/qml.qrc b/qml.qrc index d1ad983..83f2403 100644 --- a/qml.qrc +++ b/qml.qrc @@ -46,5 +46,8 @@ Gui/Firststart.qml Gui/BackupSettings.qml Gui/MiscConf.qml + Gui/UtilityDialogs.qml + Gui/OffersTable.qml + Gui/OfferTable.qml