import QtQuick 2.11 import QtQuick.Controls 2.4 import Qt.labs.platform 1.0 ApplicationWindow { id: appwindow width: 1100 height: 500 minimumHeight: 500 minimumWidth: 1100 visible: true title: qsTr("Benutzerkontensteuerung") property bool canClose: false Component.onCompleted: HP.start(appwindow) onClosing: { if (canClose) { close.accepted = true; } else { HP.save(appwindow) close.accepted = false; } } function pyclose() { canClose = true appwindow.close() } Timer { interval: 100 running: true onTriggered: userchange() } function userchange() { var username = userlistView.model.data( userlistView.model.index(userlistView.currentIndex, 0)) if (username === undefined) { docfilter.enabled = false exportbutton.enabled = false rightpane.enabled = false removeuserbutton.enabled = false } else { removeuserbutton.enabled = true docfilter.enabled = true rightpane.enabled = true exportbutton.enabled = true buttonnamesubmit.visible = false buttonpasssubmit.visible = false nametext.text = username passtext.text = "" HP.requestUserData(appwindow, username) HP.requestAllowedDocs(appwindow, username) } } function setUserData(cockpit, colorlist, money, userconfig, config) { checkBoxCock.checked = cockpit checkBoxColor.checked = colorlist checkBoxMoney.checked = money checkBoxUser.checked = userconfig checkBoxConfig.checked = config } function nametextchange() { if (nametext.text === userlistView.model.data( userlistView.model.index(userlistView.currentIndex, 0))) { buttonnamesubmit.visible = false } else if (nametext.text) { buttonnamesubmit.visible = true } else { buttonnamesubmit.visible = false } } function passtextchange() { buttonpasssubmit.visible = true } function popupmessage(text) { popuphider.start() popuptext.text = text popup.open() } Timer { id: popuphider interval: 3000 onTriggered: popup.close() } Popup { id: popup x: 0 y: 0 width: parent.width height: 65 visible: false modal: true focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside Text { id: popuptext text: qsTr("Falsches Passwort") horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter anchors.fill: parent font.pixelSize: 20 } } Pane { id: panecontainer padding: 0 anchors.right: rightpane.left anchors.bottom: parent.bottom anchors.left: parent.left anchors.top: parent.top anchors.rightMargin: 0 Pane { id: leftpane anchors.right: parent.horizontalCenter anchors.bottom: parent.bottom anchors.left: parent.left anchors.top: parent.top anchors.rightMargin: 0 Component { id: userDelegate MouseArea { Text { text: display font.pixelSize: 12 anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left anchors.leftMargin: 8 } anchors.left: parent.left anchors.right: parent.right height: 26 onClicked: { ListView.view.currentIndex = index userchange() } } } GroupBox { id: groupBox2 anchors.fill: parent title: qsTr("Benutzer") ListView { id: userlistView anchors.bottomMargin: 50 anchors.fill: parent model: Users currentIndex: 0 focus: true highlight: Rectangle { border.color: "#E91E63" border.width: 3 radius: 5 } ScrollBar.vertical: ScrollBar { policy: userlistView.contentHeight > userlistView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff } interactive: userlistView.contentHeight > userlistView.height clip: true delegate: userDelegate } Button { id: adduserbutton text: qsTr("Hinzufügen") anchors.topMargin: 10 anchors.right: parent.horizontalCenter anchors.bottom: parent.bottom anchors.left: parent.left anchors.top: userlistView.bottom anchors.rightMargin: 10 onPressed: { HP.addNew(appwindow) } } DelayButton { id: removeuserbutton text: qsTr("Entfernen") anchors.rightMargin: 0 anchors.topMargin: 10 anchors.left: parent.horizontalCenter anchors.right: parent.right anchors.bottom: parent.bottom anchors.top: userlistView.bottom anchors.leftMargin: 10 ToolTip.visible: hovered ToolTip.text: qsTr("Gedrückt halten zum Entfernen.") delay:1000 onActivated: { HP.removeUser(appwindow, userlistView.currentIndex) progress = 0; } } } } Pane { id: middlepane anchors.left: parent.horizontalCenter anchors.leftMargin: 0 anchors.right: parent.right anchors.rightMargin: 0 anchors.bottom: parent.bottom anchors.bottomMargin: 0 anchors.top: parent.top anchors.topMargin: 0 GroupBox { id: docfilter anchors.bottom: groupBoxConfigPort.top anchors.right: parent.right anchors.left: parent.left anchors.top: parent.top anchors.bottomMargin: 20 title: qsTr("Ärztedaten") ToolTip.visible: hovered ToolTip.text: qsTr("Auswahl der Ärzte deren Daten angezeigt werden.") ToolTip.delay: 1000 ListView { id: doclistView anchors.top: parent.top anchors.bottom: buttonToggleAll.top anchors.left: parent.left anchors.right: parent.right model: Doctors ScrollBar.vertical: ScrollBar { policy: doclistView.contentHeight > doclistView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff } interactive: doclistView.contentHeight > doclistView.height clip: true delegate: CheckDelegate { height: 24 padding: 0 checked: modelstate LayoutMirroring.enabled: true text: modelstring objectName: "CheckDelegate" onCheckStateChanged: HP.toggledocuser( userlistView.currentIndex, index, checked) } } Button { id: buttonToggleAll text: qsTr("Alle") anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right onClicked: { HP.toggle_all_docs(userlistView.currentIndex); } } } GroupBox { id: groupBoxConfigPort height: 80 anchors.right: parent.right anchors.bottom: parent.bottom anchors.left: parent.left title: qsTr("Gesamte Konfiguration ...") Button { id: importbutton text: qsTr("Importieren") anchors.verticalCenter: parent.verticalCenter anchors.topMargin: 10 anchors.right: parent.horizontalCenter anchors.left: parent.left anchors.rightMargin: 10 onPressed: { importdialog.open() } FileDialog { id: importdialog title: "HonorarPlus Benutzerkonfiguration zum Importieren auswählen..." folder: StandardPaths.writableLocation( StandardPaths.DocumentsLocation) defaultSuffix: "hpuserconfig" nameFilters: ["HonorarPlus Benutzerkonfiguration (*.hpuserconfig)"] fileMode: FileDialog.OpenFile onAccepted: { HP.importuserconfig(appwindow, file) } onRejected: { HP.log("Cancelled") } } } Button { id: exportbutton text: qsTr("Exportieren") anchors.verticalCenter: parent.verticalCenter anchors.rightMargin: 0 anchors.topMargin: 10 anchors.left: parent.horizontalCenter anchors.right: parent.right anchors.leftMargin: 10 onPressed: { exportdialog.open() } FileDialog { id: exportdialog title: "HonorarPlus Benutzerkonfiguration speichern..." folder: StandardPaths.writableLocation( StandardPaths.DocumentsLocation) defaultSuffix: "hpuserconfig" nameFilters: ["HonorarPlus Benutzerkonfiguration (*.hpuserconfig)"] fileMode: FileDialog.SaveFile onAccepted: { HP.exportuserconfig(appwindow, file) } onRejected: { HP.log("Cancelled") } } } } } } Pane { id: rightpane width: 400 anchors.right: parent.right anchors.bottom: parent.bottom anchors.top: parent.top GroupBox { id: groupBoxUserSettings anchors.right: parent.right anchors.bottom: parent.bottom anchors.left: parent.left anchors.top: parent.top anchors.rightMargin: 0 title: qsTr("Benutzer Einstellungen:") Column { id: column anchors.right: parent.right anchors.left: parent.left anchors.top: parent.top Text { id: name text: qsTr("Name") anchors.leftMargin: 8 font.pixelSize: 12 anchors.left: parent.left anchors.right: parent.right } TextField { selectByMouse: true id: nametext font.pixelSize: 12 anchors.left: parent.left anchors.leftMargin: 8 anchors.right: parent.right onTextChanged: { nametextchange() } } Text { id: pass text: qsTr("Passwort") font.pixelSize: 12 anchors.left: parent.left anchors.leftMargin: 8 anchors.right: parent.right } TextField { selectByMouse: true id: passtext placeholderText: qsTr("") font.pixelSize: 12 anchors.left: parent.left anchors.leftMargin: 8 anchors.right: parent.right echoMode: TextInput.Password onTextChanged: { passtextchange() } } Text { id: access text: qsTr("Zugriff auf:") font.pixelSize: 12 anchors.leftMargin: 8 anchors.left: parent.left anchors.right: parent.right } CheckBox { id: checkBoxCock text: qsTr("Management-Konsole") anchors.left: parent.left anchors.right: parent.right onClicked: { HP.setBox(userlistView.currentIndex, "cockpit", checked) } } CheckBox { id: checkBoxColor text: qsTr("Bunte Liste") anchors.left: parent.left anchors.right: parent.right onClicked: { HP.setBox(userlistView.currentIndex, "colorlist", checked) } } CheckBox { id: checkBoxMoney text: qsTr("Geldwerte") anchors.left: parent.left anchors.right: parent.right ToolTip.visible: hovered ToolTip.text: qsTr("Gilt nur für Bunte Liste, Werte im Cockpit bleiben.") onClicked: { HP.setBox(userlistView.currentIndex, "money", checked) } } CheckBox { id: checkBoxConfig text: qsTr("Programmeinstellungen") anchors.left: parent.left anchors.right: parent.right onClicked: { HP.setBox(userlistView.currentIndex, "config", checked) } } CheckBox { id: checkBoxUser text: qsTr("Benutzerkontensteuerung") anchors.left: parent.left anchors.right: parent.right onClicked: { HP.setBox(userlistView.currentIndex, "userconfig", checked) } } } Button { id: buttonnamesubmit x: 0 y: 282 text: qsTr("Geänderten Namen übernehmen") anchors.bottom: parent.bottom anchors.bottomMargin: 0 anchors.right: parent.right anchors.rightMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 visible: false onClicked: { HP.setName(appwindow, userlistView.currentIndex, nametext.text) visible = false } } Button { id: buttonpasssubmit x: 0 y: 282 text: qsTr("Geändertes Passwort übernehmen") anchors.bottom: buttonnamesubmit.visible ? buttonnamesubmit.top : parent.bottom anchors.bottomMargin: 0 anchors.right: parent.right anchors.rightMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 visible: false onClicked: { HP.setPass(appwindow, userlistView.currentIndex, passtext.text) passtext.text = qsTr("") visible = false } } } } }