Compare commits

..

5 Commits

21 changed files with 696 additions and 212 deletions

View File

@@ -30,7 +30,7 @@ GridLayout
{ {
id: saveConfig id: saveConfig
text: qsTr("Jetzt sichern!") text: qsTr("Jetzt sichern!")
onClicked: dialog.open() onClicked: utilityDialogs.item.backup_config.open()
} }
Label Label
{ {
@@ -41,75 +41,17 @@ GridLayout
{ {
id: saveEncryption id: saveEncryption
text: qsTr("Jetzt sichern!") text: qsTr("Jetzt sichern!")
onClicked: apploader.item.recoverEnc.open() onClicked: utilityDialogs.item.backup_encrypt_pw.open()
} }
Item Item
{ {
id: spacer id: spacer
Layout.fillHeight: true Layout.fillHeight: true
} }
Dialog
{
anchors.centerIn: parent
id: dialog
title: "Title"
standardButtons: Dialog.Apply | Dialog.Cancel
onApplied: Loader
{ {
id: utilityDialogs
if (configPwd.text === repeatConfigPwd.text) source: "UtilityDialogs.qml"
{
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"])
}
} }
} }

View File

@@ -2,16 +2,113 @@ import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
Item ColumnLayout
{ {
property string name: "company" property alias name: companyName
property alias street: street
property alias house: houseno
property alias zipcode: zipcode
property alias city: city
anchors.fill: parent anchors.fill: parent
anchors.topMargin: 50
RowLayout
{
Layout.fillWidth: true
Label
{
text: qsTr("Namen")
// font.pixelSize: 57
// font.bold: true
}
TextField
{
id: companyName
Layout.fillWidth: true
}
}
RowLayout
{
Layout.fillWidth: true
Label
{
text: qsTr("Straße")
// font.pixelSize: 57
// font.bold: true
}
TextField
{
id: street
Layout.fillWidth: true
}
Label Label
{ {
text: qsTr("Das Unternehmen") text: qsTr("Haus-Nr.")
anchors.centerIn: parent // font.pixelSize: 57
font.pixelSize: 57 // font.bold: true
font.bold: true }
TextField
{
id: houseno
Layout.fillWidth: true
}
}
RowLayout
{
Layout.fillWidth: true
Label
{
text: qsTr("PLZ")
// font.pixelSize: 57
// font.bold: true
}
ComboBox
{
id: zipcode
Layout.fillWidth: true
editable: true
model: address_model
textRole: "display"
popup.height: 300
popup.y: zipcode.y + 5 - (zipcode.height * 2)
//currentIndex: -1
onCurrentIndexChanged: city.currentIndex = zipcode.currentIndex
validator: RegularExpressionValidator
{
regularExpression: /([0-9]{1,5})/
}
}
Label
{
text: qsTr("Stadt")
// font.pixelSize: 57
// font.bold: true
}
ComboBox
{
id: city
Layout.fillWidth: true
editable: true
model: address_model
textRole: "city"
popup.height: 300
popup.y: zipcode.y + 5 - (zipcode.height * 2)
currentIndex: -1
}
}
Item
{
Layout.fillHeight: true
} }
} }

View File

@@ -7,11 +7,12 @@ import QtCore
import "../js/qmldict.js" as Qmldict import "../js/qmldict.js" as Qmldict
Item Item
{ {
property string recpass: "" property string recpass: ""
property bool adminAvailable: true property bool adminAvailable: true
property alias recoverEnc: recoveryPaswordDialog
id: firstStartItem id: firstStartItem
anchors.fill: parent anchors.fill: parent
@@ -72,7 +73,6 @@ Item
MessageDialog MessageDialog
{ {
id: recoveryDialog id: recoveryDialog
text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?") text: qsTr("Diesen Wiederherstellungscode musst du sicher aufbewahren!\nMöchtest du das jetzt machen?")
title: qsTr("Wiederherstellen") title: qsTr("Wiederherstellen")
buttons: MessageDialog.Yes | MessageDialog.No buttons: MessageDialog.Yes | MessageDialog.No
@@ -156,6 +156,12 @@ Item
} }
} }
Loader
{
id: utilityDialogs
source: "UtilityDialogs.qml"
}
Component.onCompleted: Component.onCompleted:
{ {
config.dbConnectionError.connect(onDbConnectionError) config.dbConnectionError.connect(onDbConnectionError)
@@ -163,15 +169,10 @@ Item
config.backupEncryptionKey.connect(onBackupEncryptionKey) config.backupEncryptionKey.connect(onBackupEncryptionKey)
} }
function gotoLogin()
{
appLoader.source= "LoginScreen.qml"
topBar.visible = true
}
function onBackupEncryptionKey() function onBackupEncryptionKey()
{ {
recoveryDialog.open()
utilityDialogs.item.recoveryDialog.open()
} }
function onDbConnectionError(msg, success) function onDbConnectionError(msg, success)
@@ -192,5 +193,4 @@ Item
firstStart.push("AdminUserConfig.qml") firstStart.push("AdminUserConfig.qml")
} }
} }
} }

22
Gui/MiscConf.qml Executable file
View File

@@ -0,0 +1,22 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
ColumnLayout
{
property alias sysTray: sysTray
anchors.fill: parent
anchors.topMargin: 35
Switch
{
id: sysTray
text: qsTr("Beim minimieren, in der Taskleiste anzeigen")
checked: config.systray()
}
Item
{
Layout.fillHeight: true
}
}

View File

@@ -6,7 +6,7 @@ GridLayout
{ {
property var contacts: null property var contacts: null
columns: 2 columns: 2
Layout.fillWidth: true
Label Label
{ {
text: qsTr("Kontaktdaten") text: qsTr("Kontaktdaten")
@@ -15,7 +15,7 @@ GridLayout
ComboBox ComboBox
{ {
property string name: "contacttype" //property string name: "contacttype"
id: contacttype id: contacttype
Layout.fillWidth: true Layout.fillWidth: true
editable: false editable: false
@@ -150,12 +150,13 @@ GridLayout
{ {
contacts[num_contacts] = {} contacts[num_contacts] = {}
contacts[num_contacts]["title"] = title.currentText contacts[num_contacts]["title"] = title.currentText
contacts[num_contacts]["ctype"] = contacttype.currentText
contacts[num_contacts]["fname"] = firstname.text.trim() contacts[num_contacts]["fname"] = firstname.text.trim()
contacts[num_contacts]["lname"] = lastname.text.trim() contacts[num_contacts]["lname"] = lastname.text.trim()
contacts[num_contacts]["phone"] = phonenumber.text.trim() contacts[num_contacts]["phone"] = phonenumber.text.trim()
contacts[num_contacts]["mobile"] = mobile.text.trim() contacts[num_contacts]["mobile"] = mobile.text.trim()
contacts[num_contacts]["position"] = posizion.text.trim() contacts[num_contacts]["position"] = posizion.text.trim()
contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), mobile: mobile.text.trim(), posizion: posizion.text.trim()}) contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), mobile: mobile.text.trim(), posizion: posizion.text.trim(), cdata: contacttype.currentText})
if (checkFields()) if (checkFields())
{ {
saveBtn.enabled = true saveBtn.enabled = true
@@ -184,59 +185,65 @@ GridLayout
id: contactModel id: contactModel
} }
Component // Component
{ // {
id: headline // id: headline
Row // Row
{ // {
Text // spacing: 9
{ // Text
id: cpname // {
text: qsTr("Name") // id: cpname
width: 175 // text: qsTr("Name")
font.bold: true // font.bold: true
horizontalAlignment: Text.AlignLeft // horizontalAlignment: Text.AlignLeft
color: "white" // color: "white"
} // }
Text // Text
{ // {
id: cpphone // id: cpphone
text: qsTr("Telefon") // text: qsTr("Telefon")
width: 100 // font.bold: true
font.bold: true // horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignLeft // color: "white"
color: "white" // }
}
Text // Text
{ // {
id: cpmobile // id: cpmobile
text: qsTr("Mobil") // text: qsTr("Mobil")
width: 100 // font.bold: true
font.bold: true // horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignLeft // color: "white"
color: "white" // }
}
Text // Text
{ // {
id: cppos // id: cppos
text: qsTr("Position") // text: qsTr("Position")
width: 150 // font.bold: true
font.bold: true // horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignLeft // color: "white"
color: "white" // }
}
} // Text
} // {
// id: cttype
// text: qsTr("Typ")
// font.bold: true
// horizontalAlignment: Text.AlignLeft
// color: "white"
// }
// }
// }
Component Component
{ {
id: highlight id: highlight
Rectangle Rectangle
{ {
width: 230; height: 15 width: parent.width
color: "lightsteelblue"; radius: 5 color: "lightsteelblue"; radius: 5
y: contactView.currentItem.y y: contactView.currentItem.y
Behavior on y Behavior on y
@@ -257,23 +264,35 @@ GridLayout
implicitHeight: 100 implicitHeight: 100
color: firstname.palette.base color: firstname.palette.base
border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base
clip: true
ScrollView
{
id: objContactView
// Layout.fillWidth: true
// Layout.preferredHeight: 100
//Layout.columnSpan: 3
anchors.fill: mainRect
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ListView ListView
{ {
id: contactView id: contactView
implicitHeight: parent.height anchors.fill: objContactView
implicitWidth: parent.width // implicitHeight: objContactView.height
// implicitWidth: objContactView.width
model: contactModel model: contactModel
header: headline // header: headline
highlight: Rectangle { color: "grey"} highlight: Rectangle { color: "slategray"; radius: 3}
highlightFollowsCurrentItem: false highlightFollowsCurrentItem: false
//focus: true
onActiveFocusChanged: if(!focus) currentIndex = -1 onActiveFocusChanged: if(!focus) currentIndex = -1
delegate: Item delegate: Item
{ {
width: contactView.width width: contactView.width
height: 77
height: 15
MouseArea MouseArea
{ {
anchors.fill: parent anchors.fill: parent
@@ -285,42 +304,47 @@ GridLayout
} }
Row Column
{ {
//spacing: 9 anchors.margins: 5
//spacing: 3
Text Text
{ {
text: model.name text: '<b>' + qsTr('Name: ') + '</b>' + model.name
width: 175
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
Text Text
{ {
text: model.phone text: '<b>' + qsTr('Telefon: ') + '</b>' + model.phone
width: 100
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
Text Text
{ {
text: model.mobile text: '<b>' + qsTr('Handy: ') + '</b>' + model.mobile
width: 100
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
Text Text
{ {
text: model.posizion text: '<b>' + qsTr('Position: ') + '</b>' + model.posizion
width: 150
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: "white" color: "white"
} }
}
}
Text
{
text: '<b>' + qsTr('Typ: ') + '</b>' + model.cdata
horizontalAlignment: Text.AlignLeft
color: "white"
} }
} // Column
} // delegate
} // Listview
} // Scrollview
} }
} }

View File

@@ -12,6 +12,7 @@ Item {
id: objectsStack id: objectsStack
anchors.fill: parent anchors.fill: parent
initialItem: "ObjectsTable.qml" initialItem: "ObjectsTable.qml"
anchors.margins: 9
} }
} }

17
Gui/OfferTable.qml Normal file
View File

@@ -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
}
}

15
Gui/OffersTable.qml Normal file
View File

@@ -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
}
}

View File

@@ -123,12 +123,21 @@ Window
{ {
copiesSpinBox.value = 1 copiesSpinBox.value = 1
colorPrint.checked = true colorPrint.checked = true
} if (!sys_printers)
Component.onCompleted:
{ {
printers = sys_printers.getPrinters() printers = sys_printers.getPrinters()
if (sys_printers.getDefaultPrinter()) if (sys_printers.getDefaultPrinter())
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter()) allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter())
} }
}
Component.onCompleted:
{
if (sys_printers)
{
printers = sys_printers.getPrinters()
if (sys_printers.getDefaultPrinter())
allPrinters.currentIndex = allPrinters.indexOfValue(sys_printers.getDefaultPrinter())
}
}
} }

View File

@@ -4,6 +4,8 @@ import QtQuick.Layouts
Item Item
{ {
property alias companyConf: companyConf
property alias miscConf: miscConf
anchors.fill: parent anchors.fill: parent
TabBar TabBar
{ {
@@ -27,6 +29,10 @@ Item
text: qsTr("Sicherung") text: qsTr("Sicherung")
} }
TabButton
{
text: qsTr("Sonstiges")
}
} }
StackLayout StackLayout
@@ -72,6 +78,15 @@ Item
} }
} }
Item
{
id: miscelanea
MiscConf
{
id: miscConf
anchors.fill: parent
}
}
} }
RowLayout RowLayout
@@ -101,7 +116,10 @@ Item
break break
case 2: case 2:
console.log("Need to update company's info.") updateCompanyInfo()
break
case 4:
updateMiscConf()
break break
default: default:
console.log("Need to handle users") console.log("Need to handle users")
@@ -109,4 +127,28 @@ Item
} }
} }
} }
function updateCompanyInfo()
{
var company = {}
company['company'] = {}
company['company']['NAME'] = companyConf.name.text.trim()
company['company']['STREET'] = companyConf.street.text.trim()
company['company']['HOUSE'] = companyConf.house.text.trim()
company['company']['ZIPCODE'] = companyConf.zipcode.editText? companyConf.zipcode.editText.trim(): companyConf.zipcode.currentText
company['company']['CITY'] = companyConf.city.editText? companyConf.city.editText.trim(): companyConf.city.currentText
if (company['company']['NAME'] === '' || company['company']['STREET'] === '' ||
company['company']['HOUSE'] === '' || company['company']['ZIPCODE'] === '' ||
company['company']['CITY'] === '');
else config.saveCompanyInfo(company)
}
function updateMiscConf()
{
var misc = {}
misc['misc'] = {}
misc['misc']['SYSTRAY'] = miscConf.sysTray.checked
config.saveMiscConf(misc)
}
} }

View File

@@ -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 Button
{ {
id: abrechnung id: abrechnung

208
Gui/UtilityDialogs.qml Normal file
View File

@@ -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")
}
}

View File

@@ -62,18 +62,6 @@ ApplicationWindow
property alias window: appWindow property alias window: appWindow
} }
Component.onCompleted:
{
if(bad_config)
{
importDialog.open()
}
else
{
if (db_con) appLoader.source= "LoginScreen.qml"
else appLoader.source= "NoDbConnection.qml"
}
}
Dialog Dialog
{ {
@@ -127,4 +115,52 @@ ApplicationWindow
} }
} }
} }
Component.onCompleted:
{
config.configurationReady.connect(goToLogin)
systray.activated.connect(showWindow)
if(bad_config)
{
importDialog.open()
}
else
{
if (db_con) appLoader.source= "LoginScreen.qml"
else appLoader.source= "NoDbConnection.qml"
}
}
function showWindow(why)
{
if (why === 3)
{
systray.setVisible(false)
appWindow.show()
}
}
onVisibilityChanged:
{
if (appWindow.visibility === Window.Minimized && config.systray())
{
systray.setVisible(true)
appWindow.hide()
}
}
onClosing: (close) =>
{
if (false)
{
console.log("Main window closed!! Was soll ich tun? kann ich mich beenden?!")
}
}
function goToLogin()
{
appLoader.source= "LoginScreen.qml"
topBar.visible = true
}
} }

1
images/addoffer.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#5F6368"><path d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h360v80H200v560h560v-360h80v360q0 33-23.5 56.5T760-120H200Zm120-160v-80h320v80H320Zm0-120v-80h320v80H320Zm0-120v-80h320v80H320Zm360-80v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>

After

Width:  |  Height:  |  Size: 362 B

BIN
images/tero.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -41,6 +41,7 @@ class ConfigLoader(QObject):
else: else:
config_dir.mkdir(0o750, True, True) config_dir.mkdir(0o750, True, True)
@Slot(dict, result = bool) @Slot(dict, result = bool)
def setConfig(self, app_config): def setConfig(self, app_config):
# print(f"In {__file__} file, setConfig()") # print(f"In {__file__} file, setConfig()")
@@ -110,18 +111,13 @@ class ConfigLoader(QObject):
self.backupEncryptionKey.emit() self.backupEncryptionKey.emit()
return admin return admin
"""###################################################"""
""" """
""" TODO: Rename method and rename self.__encrypt_key """
""" """
"""###################################################"""
@Slot(str, str) @Slot(str, str)
def saveRecoveryKey(self, recovery_file, recovery_password): def __saveData(self, recovery_file, recovery_password, data):
# print(f"In {__file__} file, saveRecoveryKey()") # print(f"In {__file__} file, __saveData()")
local = False local = False
rp = self.__setRecoveryPassword(recovery_password) rp = self.__setRecoveryPassword(recovery_password)
rf = rp[1] + self.__encrypt_key + rp[0] rf = rp[1] + data + rp[0]
rf = Vermasseln().oscarVermasseln(rf, local) rf = Vermasseln().oscarVermasseln(rf, local)
rec_file = urlparse(recovery_file) rec_file = urlparse(recovery_file)
if os.name == "nt": if os.name == "nt":
@@ -197,7 +193,8 @@ class ConfigLoader(QObject):
if ek: if ek:
self.__config = toml.loads(ek) self.__config = toml.loads(ek)
self.__saveConfig() self.__saveConfig()
self.configurationReady.emit() self.__configLoad()
else: else:
self.invalidEncryptionKey.emit() self.invalidEncryptionKey.emit()
except Exception as e: except Exception as e:
@@ -242,6 +239,31 @@ class ConfigLoader(QObject):
@Slot(str, str) @Slot(str, str)
def backupConfig(self, filename, password): def backupConfig(self, filename, password):
self.__encrypt_key = toml.dumps(self.getConfig()) conf_file = toml.dumps(self.getConfig())
self.saveRecoveryKey(filename, password) self.__saveData(filename, password, conf_file)
@Slot(dict)
def saveCompanyInfo(self, company = None):
self.__config.update(company)
self.__saveConfig()
@Slot(result = dict)
def getCompanyInfo():
return self.__config['company']
@Slot(dict)
def saveMiscConf(self, misc_conf = None):
self.__config.update(misc_conf)
self.__saveConfig()
@Slot(result = bool)
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)

View File

@@ -22,7 +22,6 @@ class EmployeeModel(QAbstractTableModel):
self.__employee_dao.newEmployeeAdded.connect(self.__refreshView) self.__employee_dao.newEmployeeAdded.connect(self.__refreshView)
self.__conf = ConfigLoader().getConfig() self.__conf = ConfigLoader().getConfig()
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY'] self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
print(self.__key)
self.__getData() self.__getData()
@Slot(dict, bool) @Slot(dict, bool)

View File

@@ -33,7 +33,7 @@ class ObjectModel(QAbstractTableModel):
print(new_objcontact) print(new_objcontact)
self.__object_dao.addObject(new_object, new_objcontact, self.__key) #self.__object_dao.addObject(new_object, new_objcontact, self.__key)
# @Slot(str) # @Slot(str)
# def viewCriterion(self, criterion, processed = False, fired = False): # def viewCriterion(self, criterion, processed = False, fired = False):

19
main.py
View File

@@ -2,7 +2,8 @@
import os import os
import sys import sys
import logging import logging
from PySide6.QtGui import QGuiApplication from PySide6.QtWidgets import QSystemTrayIcon
from PySide6.QtGui import QGuiApplication, QIcon
from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtQml import QQmlApplicationEngine
#from PySide6.QtCore import QResource #from PySide6.QtCore import QResource
from lib.ConfigLoader import ConfigLoader from lib.ConfigLoader import ConfigLoader
@@ -45,7 +46,7 @@ printers = None
user = None user = None
def initializeProgram(): 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 global address_model, bad_config, business_model, user, business_type, contact_model, employee_model, object_model, db_con, printers
if not bad_config: if not bad_config:
dbconf = config.getConfig()['database'] dbconf = config.getConfig()['database']
@@ -62,7 +63,11 @@ def initializeProgram():
object_model = ObjectModel() object_model = ObjectModel()
publishContext() publishContext()
def configReady():
global bad_config
bad_config = False bad_config = False
initializeProgram()
def publishContext(): def publishContext():
# print(f"In {__file__} file, publishContext()") # print(f"In {__file__} file, publishContext()")
@@ -86,11 +91,18 @@ if __name__ == "__main__":
qml_file = "qrc:/Gui/main.qml" qml_file = "qrc:/Gui/main.qml"
icon = QIcon(":/images/tero.jpg")
app.setWindowIcon(QIcon(icon))
tray = QSystemTrayIcon()
tray.setIcon(icon)
tray.setToolTip("PYQCRM")
config = ConfigLoader() config = ConfigLoader()
if not config.getConfig(): if not config.getConfig():
bad_config = True bad_config = True
config.configurationReady.connect(initializeProgram) config.configurationReady.connect(configReady)
else: else:
initializeProgram() initializeProgram()
@@ -98,6 +110,7 @@ if __name__ == "__main__":
engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}") engine.rootContext().setContextProperty("bad_config", bad_config) # print(f"Fehler: {i}")
engine.rootContext().setContextProperty("db_con", db_con) engine.rootContext().setContextProperty("db_con", db_con)
engine.rootContext().setContextProperty("config", config) engine.rootContext().setContextProperty("config", config)
engine.rootContext().setContextProperty("systray", tray)
engine.load(qml_file) engine.load(qml_file)

View File

@@ -20,5 +20,6 @@
<file>images/account.svg</file> <file>images/account.svg</file>
<file>README</file> <file>README</file>
<file>LICENSE</file> <file>LICENSE</file>
<file>images/tero.jpg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -45,5 +45,9 @@
<file>Gui/CompanyConf.qml</file> <file>Gui/CompanyConf.qml</file>
<file>Gui/Firststart.qml</file> <file>Gui/Firststart.qml</file>
<file>Gui/BackupSettings.qml</file> <file>Gui/BackupSettings.qml</file>
<file>Gui/MiscConf.qml</file>
<file>Gui/UtilityDialogs.qml</file>
<file>Gui/OffersTable.qml</file>
<file>Gui/OfferTable.qml</file>
</qresource> </qresource>
</RCC> </RCC>