Files
pyqcrm/Gui/main.qml
Yuri Becker 309f1f58d7 Fix up Menu
2025-03-25 12:28:30 +01:00

152 lines
3.5 KiB
QML

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Dialogs
import QtCore
ApplicationWindow {
id: appWindow
property string confile: ""
property alias settingsFileDialog: settingsFiledialog
function goToLogin() {
appLoader.source = "LoginScreen.qml";
navigation.visible = true;
}
function showWindow(why) {
if (why === 3) {
systray.setVisible(false);
appWindow.show();
}
}
color: Colors.mantle
font: Typography.body
height: Screen.height * .85
palette.text: Colors.foreground
title: "TERO Personal"
visible: true
width: Screen.width * .75
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";
}
}
onClosing: close => {
if (false) {
console.log("Main window closed!! Was soll ich tun? kann ich mich beenden?!");
}
}
onVisibilityChanged: {
if (appWindow.visibility === Window.Minimized && config.systray()) {
systray.setVisible(true);
appWindow.hide();
}
}
onWindowStateChanged: windowState => {
if (windowState !== Qt.WindowMinimized) {
systray.setVisible(false);
appWindow.show();
}
}
Navigation {
id: navigation
visible: bad_config || !db_con ? false : true
}
PrinterDialog {
id: printerDialog
}
ReadMe {
id: readMeWin
}
Item {
id: mainView
}
Rectangle {
id: contentBackground
anchors {
bottom: parent.bottom
left: navigation.right
right: parent.right
top: parent.top
}
color: Colors.background
}
Loader {
id: appLoader
property alias window: appWindow
anchors {
fill: contentBackground
margins: Dimensions.l
}
}
Dialog {
id: importDialog
anchors.centerIn: parent
modal: true
standardButtons: Dialog.Yes | Dialog.No
title: qsTr("Einstellungen importieren")
onAccepted: settingsFiledialog.open()
onRejected: appLoader.source = "Firststart.qml"
}
FileDialog {
id: settingsFiledialog
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
modality: "ApplicationModal"
nameFilters: [qsTr("PYQCRM Einstellungen (*.pyqrec)")]
title: qsTr("PYQCRM Einstellungen")
onAccepted: {
exportFilePassword.open();
confile = selectedFile;
}
}
Dialog {
id: exportFilePassword
anchors.centerIn: parent
modal: true
standardButtons: Dialog.Ok | Dialog.Cancel
title: qsTr("PYQCRM Einstellungen")
onAccepted: config.importConfig(confile, exportPasswordInput.text)
ColumnLayout {
RowLayout {
Label {
text: qsTr("Passwort eingeben:")
}
TextField {
id: exportPasswordInput
echoMode: TextInput.Password
implicitWidth: 300
}
}
}
}
}