2022-03-23 15:38:23 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2022-06-09 15:27:14 +00:00
|
|
|
import utils 1.0
|
|
|
|
import shared.panels 1.0
|
2022-06-22 12:16:21 +00:00
|
|
|
import shared.popups 1.0
|
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
// required
|
2023-05-15 12:49:26 +00:00
|
|
|
property alias title: itemHeader.text
|
2022-03-23 15:38:23 +00:00
|
|
|
property Component content
|
|
|
|
|
|
|
|
// optional
|
2023-03-07 11:32:45 +00:00
|
|
|
property Component footer
|
2022-03-23 15:38:23 +00:00
|
|
|
property bool dirty: false
|
2022-05-26 15:46:02 +00:00
|
|
|
property bool editable: false
|
2023-05-30 15:18:45 +00:00
|
|
|
property int headerWidth: d.defaultContentWidth
|
2022-12-07 16:14:36 +00:00
|
|
|
property string previousPageName: ""
|
2022-11-24 16:23:54 +00:00
|
|
|
property bool saveChangesButtonEnabled: !!root.contentItem && !!root.contentItem.saveChangesButtonEnabled
|
2023-05-30 15:18:45 +00:00
|
|
|
property alias primaryHeaderButton: primaryHeaderBtn
|
|
|
|
property alias secondaryHeaderButton: secondaryHeaderBtn
|
2023-01-11 13:57:50 +00:00
|
|
|
property alias saveChangesText: settingsDirtyToastMessage.saveChangesText
|
|
|
|
property alias cancelChangesText: settingsDirtyToastMessage.cancelChangesText
|
|
|
|
property alias changesDetectedText: settingsDirtyToastMessage.changesDetectedText
|
2023-05-15 12:49:26 +00:00
|
|
|
property alias subTitle: sideTextHeader.text
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
readonly property Item contentItem: contentLoader.item
|
2022-06-22 12:16:21 +00:00
|
|
|
readonly property size settingsDirtyToastMessageImplicitSize:
|
|
|
|
Qt.size(settingsDirtyToastMessage.implicitWidth,
|
|
|
|
settingsDirtyToastMessage.implicitHeight + settingsDirtyToastMessage.anchors.bottomMargin)
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
signal saveChangesClicked
|
|
|
|
signal resetChangesClicked
|
2023-05-30 15:18:45 +00:00
|
|
|
signal primaryHeaderButtonClicked
|
|
|
|
signal secondaryHeaderButtonClicked
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int leftMargin: 64
|
|
|
|
readonly property int defaultContentWidth: 560
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
function reloadContent() {
|
|
|
|
contentLoader.active = false
|
|
|
|
contentLoader.active = true
|
|
|
|
}
|
|
|
|
|
|
|
|
function notifyDirty() {
|
2022-06-22 12:16:21 +00:00
|
|
|
settingsDirtyToastMessage.notifyDirty()
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
implicitHeight: layout.implicitHeight
|
2023-05-30 15:18:45 +00:00
|
|
|
implicitWidth: layout.implicitWidth
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2023-05-30 15:18:45 +00:00
|
|
|
anchors.bottomMargin: 24
|
2022-03-23 15:38:23 +00:00
|
|
|
spacing: 16
|
|
|
|
|
2022-11-25 17:35:30 +00:00
|
|
|
RowLayout {
|
2023-05-30 15:18:45 +00:00
|
|
|
Layout.leftMargin: d.leftMargin
|
|
|
|
Layout.maximumWidth: root.headerWidth
|
|
|
|
Layout.maximumHeight: 44
|
|
|
|
|
|
|
|
spacing: 9
|
2022-11-25 17:35:30 +00:00
|
|
|
|
2023-05-15 12:49:26 +00:00
|
|
|
RowLayout {
|
2022-11-25 17:35:30 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-05-15 12:49:26 +00:00
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: itemHeader
|
|
|
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
font.pixelSize: 26
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: sideTextHeader
|
|
|
|
|
|
|
|
Layout.leftMargin: 6
|
|
|
|
Layout.topMargin: 6
|
|
|
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
2022-09-13 16:17:54 +00:00
|
|
|
}
|
2022-11-25 17:35:30 +00:00
|
|
|
|
2023-05-30 15:18:45 +00:00
|
|
|
// Filler
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2022-11-25 17:35:30 +00:00
|
|
|
StatusButton {
|
2023-05-30 15:18:45 +00:00
|
|
|
id: secondaryHeaderBtn
|
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
objectName: "secondaryHeaderButton"
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
onClicked: root.secondaryHeaderButtonClicked()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: primaryHeaderBtn
|
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
objectName: "primaryHeaderButton"
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
onClicked: root.primaryHeaderButtonClicked()
|
2022-11-25 17:35:30 +00:00
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: contentLoader
|
2023-05-30 15:18:45 +00:00
|
|
|
|
2022-03-23 15:38:23 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-05-30 15:18:45 +00:00
|
|
|
Layout.leftMargin: d.leftMargin
|
2022-05-26 15:46:02 +00:00
|
|
|
Layout.rightMargin: 24
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
sourceComponent: root.content
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
visible: !!root.footer
|
|
|
|
Layout.fillWidth: true
|
|
|
|
sourceComponent: root.footer
|
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
SettingsDirtyToastMessage {
|
|
|
|
id: settingsDirtyToastMessage
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
bottomMargin: 16
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
active: root.dirty
|
2022-12-09 11:17:34 +00:00
|
|
|
flickable: root.dirty ? root.contentItem : null
|
2022-11-24 16:23:54 +00:00
|
|
|
saveChangesButtonEnabled: root.saveChangesButtonEnabled
|
2022-06-22 12:16:21 +00:00
|
|
|
onResetChangesClicked: root.resetChangesClicked()
|
|
|
|
onSaveChangesClicked: root.saveChangesClicked()
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
}
|