fix(Communities): fixed channel color picker dialog

Closes #9696
This commit is contained in:
Lukáš Tinkl 2023-09-14 15:34:36 +02:00 committed by Lukáš Tinkl
parent 1d644d0b9c
commit a75890d7be
4 changed files with 27 additions and 49 deletions

View File

@ -142,7 +142,7 @@ StatusDialog {
*/ */
property alias rightButtons: footerImpl.rightButtons property alias rightButtons: footerImpl.rightButtons
/*! /*!
\qmlproperty rightButtons \qmlproperty leftButtons
This property helps user assign the left buttons on the footer. This property helps user assign the left buttons on the footer.
This doesn't not apply to the advanced footer! This doesn't not apply to the advanced footer!
*/ */

View File

@ -13,15 +13,17 @@ ColumnLayout {
id: root id: root
property color color: Theme.palette.primaryColor1 property color color: Theme.palette.primaryColor1
property string title: qsTr("Community colour")
signal pick() signal pick()
spacing: 8 spacing: 8
implicitHeight: childrenRect.height implicitHeight: childrenRect.height
StatusBaseText { StatusBaseText {
text: qsTr("Community colour") Layout.fillWidth: true
font.pixelSize: 15 text: root.title
} }
StatusPickerButton { StatusPickerButton {

View File

@ -13,10 +13,11 @@ StatusScrollView {
id: root id: root
property string title: qsTr("Community Colour") property string title: qsTr("Community Colour")
property string buttonText: qsTr("Select Community Colour")
property var rightButtons: StatusButton { property var rightButtons: StatusButton {
objectName: "communityColorPanelSelectColorButton" objectName: "communityColorPanelSelectColorButton"
text: qsTr("Select Community Colour") text: root.buttonText
onClicked: root.accepted() onClicked: root.accepted()
enabled: hexInput.valid enabled: hexInput.valid
} }

View File

@ -16,6 +16,7 @@ import StatusQ.Components 0.1
import StatusQ.Popups 0.1 import StatusQ.Popups 0.1
import AppLayouts.Communities.controls 1.0 import AppLayouts.Communities.controls 1.0
import AppLayouts.Communities.panels 1.0
StatusStackModal { StatusStackModal {
id: root id: root
@ -150,7 +151,7 @@ StatusStackModal {
readonly property StatusButton deleteChannelButton: StatusButton { readonly property StatusButton deleteChannelButton: StatusButton {
objectName: "deleteCommunityChannelBtn" objectName: "deleteCommunityChannelBtn"
visible: isEdit && isDeleteable && !isDiscordImport visible: isEdit && isDeleteable && !isDiscordImport && typeof(replaceItem) === "undefined"
text: qsTr("Delete channel") text: qsTr("Delete channel")
type: StatusBaseButton.Type.Danger type: StatusBaseButton.Type.Danger
onClicked: root.deleteCommunityChannel() onClicked: root.deleteCommunityChannel()
@ -555,56 +556,30 @@ StatusStackModal {
Layout.fillWidth: true Layout.fillWidth: true
} }
StatusBaseText { ColorPicker {
Layout.fillWidth: true
text: qsTr("Channel colour")
}
Item {
Layout.preferredHeight: 8
Layout.fillWidth: true
}
Item {
height: colorSelectorButton.height + 16
Layout.fillWidth: true
StatusPickerButton {
id: colorSelectorButton
property string validationError: ""
width: parent.width
bgColor: colorDialog.colorSelected ? colorDialog.color : Theme.palette.baseColor2
contentColor: colorDialog.colorSelected ? Theme.palette.white : Theme.palette.baseColor1
text: colorDialog.colorSelected ? colorDialog.color.toString().toUpperCase() : qsTr("Pick a colour")
onClicked: colorDialog.open()
onTextChanged: {
if (colorDialog.colorSelected) {
validationError = Utils.validateAndReturnError(text, communityColorValidator)
}
}
}
StatusColorDialog {
id: colorDialog id: colorDialog
anchors.centerIn: parent Layout.fillWidth: true
property bool colorSelected: root.isEdit && root.channelColor title: qsTr("Channel colour")
headerSettings.title: qsTr("Channel Colour")
standardColors: Theme.palette.communityColorsArray
color: root.isEdit && root.channelColor ? root.channelColor : Theme.palette.primaryColor1 color: root.isEdit && root.channelColor ? root.channelColor : Theme.palette.primaryColor1
onAccepted: colorSelected = true onPick: root.replace(colorPanel)
Component {
id: colorPanel
ColorPanel {
title: qsTr("Channel colour")
buttonText: qsTr("Select Colour")
Component.onCompleted: color = colorDialog.color
onAccepted: {
colorDialog.color = color
root.replaceItem = undefined
}
}
}
} }
StatusBaseText { Item {
text: colorSelectorButton.validationError Layout.preferredHeight: 16
visible: !!text Layout.fillWidth: true
color: Theme.palette.dangerColor1
anchors.top: colorSelectorButton.bottom
anchors.topMargin: 4
anchors.right: colorSelectorButton.right
}
} }
StatusInput { StatusInput {