2022-05-07 11:45:15 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
|
|
|
|
import utils 1.0
|
2022-06-22 12:16:21 +00:00
|
|
|
import shared.popups 1.0
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
Item {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property string sectionTitle
|
|
|
|
property int contentWidth
|
|
|
|
|
|
|
|
property string backButtonName: ""
|
|
|
|
|
|
|
|
property alias titleRowComponentLoader: loader
|
|
|
|
property list<Item> headerComponents
|
|
|
|
default property Item content
|
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
property bool dirty: false
|
|
|
|
property bool saveChangesButtonEnabled: false
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
signal backButtonClicked()
|
2022-04-01 10:30:55 +00:00
|
|
|
signal baseAreaClicked()
|
2022-06-22 12:16:21 +00:00
|
|
|
signal saveChangesClicked()
|
|
|
|
signal resetChangesClicked()
|
|
|
|
|
|
|
|
function notifyDirty() {
|
|
|
|
settingsDirtyToastMessage.notifyDirty();
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
readonly property int topHeaderHeight: 56
|
|
|
|
readonly property int titleRowHeight: 56
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: { root.baseAreaClicked() }
|
|
|
|
}
|
2022-04-01 10:30:55 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
content.parent = contentWrapper
|
|
|
|
|
|
|
|
if (headerComponents.length) {
|
|
|
|
for (let i in headerComponents) {
|
|
|
|
headerComponents[i].parent = titleRow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: topHeader
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
width: root.contentWidth + Style.current.padding
|
|
|
|
height: d.topHeaderHeight
|
|
|
|
|
|
|
|
StatusFlatButton {
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
visible: root.backButtonName != ""
|
|
|
|
icon.name: "arrow-left"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 20
|
|
|
|
text: root.backButtonName
|
|
|
|
size: StatusBaseButton.Size.Large
|
|
|
|
onClicked: root.backButtonClicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: titleRow
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: topHeader.bottom
|
|
|
|
anchors.leftMargin: Style.current.padding
|
|
|
|
width: root.contentWidth - 2 * Style.current.padding
|
|
|
|
height: d.titleRowHeight
|
|
|
|
visible: root.sectionTitle !== ""
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: root.sectionTitle
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: Constants.settingsSection.mainHeaderFontSize
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
2022-06-22 12:16:21 +00:00
|
|
|
id: scrollView
|
|
|
|
anchors.top: titleRow.visible ? titleRow.bottom : topHeader.bottom
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.topMargin: Style.current.bigPadding
|
2022-06-22 12:16:21 +00:00
|
|
|
width: root.contentWidth
|
2022-05-07 11:45:15 +00:00
|
|
|
clip: true
|
2022-06-22 12:16:21 +00:00
|
|
|
|
|
|
|
Flickable {
|
|
|
|
id: contentFliackable
|
|
|
|
contentWidth: Math.max(contentLayout.implicitWidth, scrollView.width)
|
|
|
|
contentHeight: Math.max(contentLayout.implicitHeight, scrollView.height) + scrollView.anchors.topMargin
|
2022-04-01 10:30:55 +00:00
|
|
|
|
|
|
|
Column {
|
2022-06-22 12:16:21 +00:00
|
|
|
id: contentLayout
|
|
|
|
anchors.fill: parent.contentItem
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
onClicked: root.baseAreaClicked()
|
|
|
|
width: contentWrapper.implicitWidth
|
|
|
|
height: contentWrapper.implicitHeight
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: contentWrapper
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
// This is a settingsDirtyToastMessage placeholder
|
|
|
|
width: settingsDirtyToastMessage.implicitWidth
|
|
|
|
height: settingsDirtyToastMessage.active ? settingsDirtyToastMessage.implicitHeight : 0
|
|
|
|
|
|
|
|
Behavior on implicitHeight {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 150
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-01 10:30:55 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
|
|
|
|
SettingsDirtyToastMessage {
|
|
|
|
id: settingsDirtyToastMessage
|
|
|
|
anchors.bottom: scrollView.bottom
|
|
|
|
anchors.horizontalCenter: scrollView.horizontalCenter
|
|
|
|
active: root.dirty
|
|
|
|
flickable: contentFliackable
|
|
|
|
saveChangesButtonEnabled: root.saveChangesButtonEnabled
|
|
|
|
onResetChangesClicked: root.resetChangesClicked()
|
|
|
|
onSaveChangesClicked: root.saveChangesClicked()
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|