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
|
2023-03-21 05:10:06 +00:00
|
|
|
readonly property int contentHeight: root.height - titleRow.height - Style.current.padding
|
2022-05-07 11:45:15 +00:00
|
|
|
|
2023-07-11 15:10:26 +00:00
|
|
|
property alias titleRowLeftComponentLoader: leftLoader
|
2022-05-07 11:45:15 +00:00
|
|
|
property alias titleRowComponentLoader: loader
|
|
|
|
property list<Item> headerComponents
|
2022-10-20 13:41:18 +00:00
|
|
|
property alias bottomHeaderComponents: secondHeaderRow.contentItem
|
2022-05-07 11:45:15 +00:00
|
|
|
default property Item content
|
2023-07-11 15:10:26 +00:00
|
|
|
property alias titleLayout: titleLayout
|
2022-05-07 11:45:15 +00:00
|
|
|
|
2022-06-22 12:16:21 +00:00
|
|
|
property bool dirty: false
|
|
|
|
property bool saveChangesButtonEnabled: false
|
|
|
|
|
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 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
ColumnLayout {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: titleRow
|
2022-10-20 13:41:18 +00:00
|
|
|
width: root.contentWidth
|
|
|
|
spacing: 0
|
2023-03-21 05:10:06 +00:00
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
RowLayout {
|
2023-07-11 15:10:26 +00:00
|
|
|
id: titleLayout
|
2023-09-22 09:58:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-10-20 13:41:18 +00:00
|
|
|
Layout.preferredHeight: visible ? d.titleRowHeight : 0
|
|
|
|
visible: (root.sectionTitle !== "")
|
|
|
|
|
2023-07-11 15:10:26 +00:00
|
|
|
Loader {
|
|
|
|
id: leftLoader
|
|
|
|
}
|
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: root.sectionTitle
|
|
|
|
font.weight: Font.Bold
|
|
|
|
font.pixelSize: Constants.settingsSection.mainHeaderFontSize
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
|
2022-10-20 13:41:18 +00:00
|
|
|
Loader {
|
|
|
|
id: loader
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-10-20 13:41:18 +00:00
|
|
|
Control {
|
|
|
|
id: secondHeaderRow
|
|
|
|
Layout.fillWidth: true
|
|
|
|
visible: !!contentItem
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-06-22 12:16:21 +00:00
|
|
|
id: scrollView
|
2022-08-12 12:11:57 +00:00
|
|
|
objectName: "settingsContentBaseScrollView"
|
2022-10-20 13:41:18 +00:00
|
|
|
anchors.top: titleRow.bottom
|
2022-05-07 11:45:15 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2023-07-18 09:10:48 +00:00
|
|
|
anchors.topMargin: titleLayout.visible ? Style.current.padding: 0
|
2022-07-14 11:03:36 +00:00
|
|
|
padding: 0
|
2023-03-20 12:29:05 +00:00
|
|
|
width: root.width
|
|
|
|
contentWidth: root.contentWidth
|
|
|
|
contentHeight: contentLayout.implicitHeight + Style.current.bigPadding
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
Column {
|
|
|
|
id: contentLayout
|
|
|
|
width: scrollView.availableWidth
|
2022-04-01 10:30:55 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
MouseArea {
|
|
|
|
onClicked: root.baseAreaClicked()
|
|
|
|
width: contentWrapper.implicitWidth
|
|
|
|
height: contentWrapper.implicitHeight
|
2022-12-07 15:29:37 +00:00
|
|
|
hoverEnabled: true
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
Column {
|
|
|
|
id: contentWrapper
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
2022-07-14 11:03:36 +00:00
|
|
|
}
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
Item {
|
|
|
|
// This is a settingsDirtyToastMessage placeholder
|
|
|
|
width: settingsDirtyToastMessage.implicitWidth
|
|
|
|
height: settingsDirtyToastMessage.active ? settingsDirtyToastMessage.implicitHeight : 0
|
2022-06-22 12:16:21 +00:00
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
Behavior on implicitHeight {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 150
|
|
|
|
easing.type: Easing.InOutQuad
|
2022-06-22 12:16:21 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
2023-05-31 20:58:23 +00:00
|
|
|
flickable: scrollView.flickable
|
2022-06-22 12:16:21 +00:00
|
|
|
saveChangesButtonEnabled: root.saveChangesButtonEnabled
|
|
|
|
onResetChangesClicked: root.resetChangesClicked()
|
|
|
|
onSaveChangesClicked: root.saveChangesClicked()
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|