2022-03-23 15:38:23 +00:00
import QtQuick 2.14
import QtQuick . Layouts 1.14
import QtQuick . Controls 2.14
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import StatusQ . Controls 0.1
import StatusQ . Components 0.1
import "../../layouts"
2022-04-13 20:54:17 +00:00
/ * ! T O D O : v e r y c o n f u s i n g t o b e r e f a c t o r e d
2022-05-23 18:53:51 +00:00
The "API" properties are just for input purposes and to track the initial state
used in evaluating the dirty flag . They should not be updated based
on user input . The final relevant values are accessed through the \ c item member of \ c edit property
2022-04-13 20:54:17 +00:00
* /
2022-03-23 15:38:23 +00:00
StackLayout {
id: root
property string name
property string description
2022-05-23 18:53:51 +00:00
property string logoImageData
property string bannerImageData
property rect bannerCropRect
2022-03-23 15:38:23 +00:00
property color color
property bool editable: false
property bool owned: false
2022-04-13 20:54:17 +00:00
property bool isCommunityHistoryArchiveSupportEnabled: false
property bool historyArchiveSupportToggle: false
2022-03-23 15:38:23 +00:00
2022-05-23 18:53:51 +00:00
signal edited ( Item item ) // item containing edited fields (name, description, logoImagePath, bannerPath, bannerCropRect, color)
2022-03-23 15:38:23 +00:00
clip: true
SettingsPageLayout {
title: qsTr ( "Overview" )
content: ColumnLayout {
spacing: 16
RowLayout {
Layout.fillWidth: true
spacing: 16
StatusSmartIdenticon {
name: root . name
icon {
width: 80
height: 80
2022-05-23 18:53:51 +00:00
isLetterIdenticon: ! root . logoImageData
2022-03-23 15:38:23 +00:00
color: root . color
letterSize: width / 2.4
}
image {
width: 80
height: 80
2022-05-23 18:53:51 +00:00
source: root . logoImageData
2022-03-23 15:38:23 +00:00
}
}
ColumnLayout {
Layout.fillWidth: true
StatusBaseText {
id: nameText
Layout.fillWidth: true
font.pixelSize: 24
color: Theme . palette . directColor1
wrapMode: Text . WordWrap
text: root . name
}
StatusBaseText {
id: descriptionText
Layout.fillWidth: true
font.pixelSize: 15
color: Theme . palette . directColor1
wrapMode: Text . WordWrap
text: root . description
}
}
StatusButton {
visible: root . editable
text: qsTr ( "Edit Community" )
onClicked: root . currentIndex = 1
}
}
Rectangle {
Layout.fillWidth: true
implicitHeight: 1
visible: root . editable
color: Theme . palette . statusPopupMenu . separatorColor
}
RowLayout {
Layout.fillWidth: true
visible: root . owned
StatusIcon {
icon: "info"
}
StatusBaseText {
Layout.fillWidth: true
text: qsTr ( "This node is the Community Owner Node. For your Community to function correctly try to keep this computer with Status running and onlinie as much as possible." )
font.pixelSize: 15
color: Theme . palette . directColor1
wrapMode: Text . WordWrap
}
}
Item {
Layout.fillHeight: true
}
}
}
SettingsPageLayout {
id: editCommunityPage
previousPage: qsTr ( "Overview" )
title: qsTr ( "Edit Community" )
content: CommunityEditSettingsPanel {
2022-04-13 20:54:17 +00:00
id: communityEditSettingsPanel
2022-03-23 15:38:23 +00:00
name: root . name
description: root . description
color: root . color
2022-05-23 18:53:51 +00:00
logoImageData: root . logoImageData
bannerImageData: root . bannerImageData
2022-04-13 20:54:17 +00:00
isCommunityHistoryArchiveSupportEnabled: root . isCommunityHistoryArchiveSupportEnabled
historyArchiveSupportToggle: root . historyArchiveSupportToggle
2022-03-23 15:38:23 +00:00
Component.onCompleted: {
editCommunityPage . dirty =
Qt . binding ( ( ) = > {
2022-05-23 18:53:51 +00:00
return root . name !== name ||
root . description !== description ||
logoImagePath . length > 0 ||
2022-05-23 17:36:48 +00:00
isValidRect ( logoCropRect ) ||
2022-05-23 18:53:51 +00:00
root . color !== color ||
bannerPath . length > 0 ||
isValidRect ( bannerCropRect ) ||
2022-04-13 20:54:17 +00:00
root . historyArchiveSupportToggle !== historyArchiveSupportToggle
2022-03-23 15:38:23 +00:00
} )
2022-05-23 18:53:51 +00:00
function isValidRect ( r /*rect*/ ) { return r . width !== 0 && r . height !== 0 }
2022-03-23 15:38:23 +00:00
}
}
onPreviousPageClicked: {
if ( dirty ) {
notifyDirty ( )
} else {
root . currentIndex = 0
}
}
onSaveChangesClicked: {
root . currentIndex = 0
root . edited ( contentItem )
reloadContent ( )
}
onResetChangesClicked: reloadContent ( )
}
}