2023-07-06 08:02:41 +00:00
import QtQuick 2.15
import QtQml 2.15
import QtQuick . Controls 2.15
import QtQuick . Layouts 1.15
import StatusQ . Components 0.1
import StatusQ . Controls 0.1
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import utils 1.0
Control {
id: root
2023-09-28 10:09:47 +00:00
2024-05-10 15:57:06 +00:00
property bool isPromoteSelfToControlNodeEnabled: false
2024-04-17 13:25:45 +00:00
property bool isControlNode: true
2023-07-06 08:02:41 +00:00
property string communityName: ""
2023-09-28 10:09:47 +00:00
property string communityColor: ""
// Community transfer ownership related props:
required property bool isPendingOwnershipRequest
2023-07-06 08:02:41 +00:00
2023-07-19 05:58:21 +00:00
signal exportControlNodeClicked
signal importControlNodeClicked
signal learnMoreClicked
2023-09-28 10:09:47 +00:00
signal finaliseOwnershipTransferClicked
2023-07-06 08:02:41 +00:00
QtObject {
id: d
readonly property real verticalBreakPoint: 950
readonly property bool twoRowsLayout: contentItem . width <= verticalBreakPoint
property string paragraphTitle
property string paragraphSubtitle
property string primaryButtonText
property string secondaryButtonText
property string indicatorBgColor
property string indicatorColor
2023-09-28 10:09:47 +00:00
property string indicatorName
2023-07-19 05:58:21 +00:00
property var primaryButtonAction: root . exportControlNodeClicked
2023-07-06 08:02:41 +00:00
}
contentItem: GridLayout {
id: mainGrid
columnSpacing: 16
rowSpacing: 16
2024-05-10 15:57:06 +00:00
visible: root . isPromoteSelfToControlNodeEnabled
2023-07-06 08:02:41 +00:00
StatusRoundIcon {
id: icon
Layout.row: 0
Layout.column: 0
color: d . indicatorBgColor
asset.color: d . indicatorColor
2023-09-28 10:09:47 +00:00
asset.name: d . indicatorName
2023-07-06 08:02:41 +00:00
}
ColumnLayout {
id: paragraph
Layout.row: 0
Layout.column: 1
Layout.columnSpan: d . twoRowsLayout ? 2 : 1
Layout.fillWidth: true
spacing: 4
StatusBaseText {
id: title
Layout.fillWidth: true
text: d . paragraphTitle
font.pixelSize: 15
font.bold: true
color: Theme . palette . directColor1
wrapMode: Text . WordWrap
}
StatusBaseText {
id: subtitle
Layout.fillWidth: true
text: d . paragraphSubtitle
font.pixelSize: 15
color: Theme . palette . baseColor1
wrapMode: Text . WordWrap
}
}
Item {
Layout.fillWidth: true
Layout.row: 0
Layout.column: 3
}
RowLayout {
Layout.row: d . twoRowsLayout ? 1 : 0
Layout.column: d . twoRowsLayout ? 1 : 4
Layout.alignment: Qt . AlignLeft
StatusFlatButton {
size: StatusBaseButton . Size . Small
2023-09-12 09:26:57 +00:00
text: qsTr ( "Learn more" )
icon.name: "external-link"
2023-07-19 05:58:21 +00:00
onClicked: root . learnMoreClicked ( )
2023-07-06 08:02:41 +00:00
}
StatusButton {
size: StatusBaseButton . Size . Small
text: d . primaryButtonText
2023-07-19 05:58:21 +00:00
onClicked: d . primaryButtonAction ( )
2023-07-06 08:02:41 +00:00
}
}
}
// Behavior
states: [
2023-09-28 10:09:47 +00:00
State {
name: "isPendingOwnershipRequest"
when: root . isPendingOwnershipRequest
PropertyChanges { target: d ; indicatorBgColor: Theme . palette . alphaColor ( root . communityColor , 0.1 ) }
PropertyChanges { target: d ; indicatorColor: root . communityColor }
PropertyChanges { target: d ; paragraphTitle: qsTr ( "Finalise your ownership of the %1 Community" ) . arg ( root . communityName ) }
PropertyChanges { target: d ; paragraphSubtitle: qsTr ( "You currently hodl the Owner token for %1. Make your device the control node to finalise ownership." ) . arg ( root . communityName ) }
PropertyChanges { target: d ; primaryButtonText: qsTr ( "Finalise %1 ownership" ) . arg ( root . communityName ) }
PropertyChanges { target: d ; primaryButtonAction: root . finaliseOwnershipTransferClicked }
PropertyChanges { target: d ; indicatorName: "crown" }
} ,
2023-07-06 08:02:41 +00:00
State {
name: "isControlNode"
2023-09-28 10:09:47 +00:00
when: root . isControlNode && ! root . isPendingOwnershipRequest
2023-07-06 08:02:41 +00:00
PropertyChanges { target: d ; indicatorBgColor: Theme . palette . successColor2 }
PropertyChanges { target: d ; indicatorColor: Theme . palette . successColor1 }
PropertyChanges { target: d ; paragraphTitle: qsTr ( "This device is currently the control node for the %1 Community" ) . arg ( root . communityName ) }
PropertyChanges { target: d ; paragraphSubtitle: qsTr ( "For your Community to function correctly keep this device online with Status running as much as possible." ) }
2023-09-12 09:26:57 +00:00
PropertyChanges { target: d ; primaryButtonText: qsTr ( "How to move control node" ) }
2023-07-19 05:58:21 +00:00
PropertyChanges { target: d ; primaryButtonAction: root . exportControlNodeClicked }
2023-09-28 10:09:47 +00:00
PropertyChanges { target: d ; indicatorName: "desktop" }
2023-07-06 08:02:41 +00:00
} ,
State {
name: "isNotControlNode"
2023-09-28 10:09:47 +00:00
when: ! root . isControlNode && ! root . isPendingOwnershipRequest
2023-07-06 08:02:41 +00:00
PropertyChanges { target: d ; indicatorBgColor: Theme . palette . primaryColor3 }
PropertyChanges { target: d ; indicatorColor: Theme . palette . primaryColor1 }
PropertyChanges { target: d ; paragraphTitle: qsTr ( "Make this device the control node for the %1 Community" ) . arg ( root . communityName ) }
2023-09-12 09:26:57 +00:00
PropertyChanges { target: d ; paragraphSubtitle: qsTr ( "Ensure this is a device you can keep online with Status running." ) }
2023-07-06 08:02:41 +00:00
PropertyChanges { target: d ; primaryButtonText: qsTr ( "Make this device the control node" ) }
2023-07-19 05:58:21 +00:00
PropertyChanges { target: d ; primaryButtonAction: root . importControlNodeClicked }
2023-09-28 10:09:47 +00:00
PropertyChanges { target: d ; indicatorName: "desktop" }
2023-07-06 08:02:41 +00:00
}
]
}