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
|
|
|
|
property string title
|
|
|
|
property Component content
|
|
|
|
|
|
|
|
// optional
|
|
|
|
property bool dirty: false
|
2022-05-26 15:46:02 +00:00
|
|
|
property bool editable: false
|
2022-11-25 17:35:30 +00:00
|
|
|
property bool headerButtonVisible: false
|
|
|
|
property string headerButtonText: ""
|
|
|
|
property int headerWidth: 0
|
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
|
2022-11-25 17:35:30 +00:00
|
|
|
signal headerButtonClicked
|
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
|
|
|
}
|
|
|
|
|
|
|
|
implicitWidth: layout.implicitWidth
|
|
|
|
implicitHeight: layout.implicitHeight
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: layout
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 16
|
|
|
|
|
2022-11-25 17:35:30 +00:00
|
|
|
RowLayout {
|
|
|
|
Layout.maximumWidth: root.headerWidth === 0 ? parent.width : (root.headerWidth + itemHeader.Layout.leftMargin)
|
2022-09-13 16:17:54 +00:00
|
|
|
Layout.preferredHeight: 56
|
2022-11-25 17:35:30 +00:00
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
StatusBaseText {
|
2022-11-25 17:35:30 +00:00
|
|
|
id: itemHeader
|
|
|
|
Layout.leftMargin: 64
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-09-13 16:17:54 +00:00
|
|
|
text: root.title
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
font.pixelSize: 26
|
|
|
|
font.bold: true
|
|
|
|
}
|
2022-11-25 17:35:30 +00:00
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
visible: root.headerButtonVisible
|
|
|
|
text: root.headerButtonText
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
onClicked: root.headerButtonClicked()
|
|
|
|
}
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: contentLoader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-06-09 15:27:14 +00:00
|
|
|
Layout.topMargin: 16
|
2022-11-25 17:35:30 +00:00
|
|
|
Layout.leftMargin: 64
|
2022-05-26 15:46:02 +00:00
|
|
|
Layout.rightMargin: 24
|
2022-03-23 15:38:23 +00:00
|
|
|
|
|
|
|
sourceComponent: root.content
|
|
|
|
}
|
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
|
|
|
|
flickable: root.contentItem
|
2022-08-30 16:27:00 +00:00
|
|
|
saveChangesButtonEnabled: !!root.contentItem && !!root.contentItem.saveChangesButtonEnabled
|
2022-06-22 12:16:21 +00:00
|
|
|
onResetChangesClicked: root.resetChangesClicked()
|
|
|
|
onSaveChangesClicked: root.saveChangesClicked()
|
2022-03-23 15:38:23 +00:00
|
|
|
}
|
|
|
|
}
|