feat(CreateChannelPopup): inherit the channel color from community color

- if there's a valid community info and the color is non-empty, inherit
it when creating a new channel
- also fix the color picker button height
- adjust the SB page with separate "create" and "edit" options

Fixes #14570
This commit is contained in:
Lukáš Tinkl 2024-05-03 17:51:25 +02:00 committed by Lukáš Tinkl
parent 953fff0e68
commit d703d0e87f
4 changed files with 47 additions and 39 deletions

View File

@ -49,18 +49,17 @@ SplitView {
id: dialog
anchors.centerIn: parent
destroyOnClose: true
isEdit: true
isEdit: ctrlIsEdit.checked
isDeleteable: isDeleteableCheckBox.checked
isDiscordImport: isDiscordCheckBox.checked
chatId: "_general"
channelName: "general"
channelDescription: "general discussion"
channelColor: "#4360DF"
chatId: isEdit ? "_general" : ""
channelName: isEdit ? "general" : ""
channelDescription: isEdit ? "general discussion" : ""
activeCommunity: QtObject {
readonly property string id: "0x039c47e9837a1a7dcd00a6516399d0eb521ab0a92d512ca20a44ac6278bfdbb5c5"
readonly property string name: "test-1"
readonly property string image: ModelsData.icons.superRare
readonly property string color: "#4360DF"
readonly property string color: dialog.isEdit ? "#4360DF" : "green"
readonly property int memberRole: 0
}
assetsModel: AssetsModel {}
@ -68,9 +67,13 @@ SplitView {
collectiblesModel: CollectiblesModel {}
permissionsModel: ListModel {
id: permissionsModel
function belongsToChat(permissionId, chatId) {
return chatId === dialog.chatId
}
Component.onCompleted: {
append(PermissionsModel.channelsOnlyPermissionsModelData)
if (dialog.isEdit)
append(PermissionsModel.channelsOnlyPermissionsModelData)
}
}
@ -159,19 +162,19 @@ SplitView {
}
onCreateCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId) {
onCreateCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet) {
logs.logEvent("onCreateCommunityChannel",
["chName", "chDescription", "chEmoji", "chColor", "chCategoryId"], arguments)
["chName", "chDescription", "chEmoji", "chColor", "chCategoryId",
"viewOnlyCanAddReaction", "hideIfPermissionsNotMet"], arguments)
}
onEditCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId) {
onEditCommunityChannel: function(chName, chDescription, chEmoji, chColor, chCategoryId, viewOnlyCanAddReaction, hideIfPermissionsNotMet) {
logs.logEvent("onEditCommunityChannel",
["chName", "chDescription", "chEmoji", "chColor", "chCategoryId"], arguments)
["chName", "chDescription", "chEmoji", "chColor", "chCategoryId",
"viewOnlyCanAddReaction", "hideIfPermissionsNotMet"], arguments)
}
onDeleteCommunityChannel: () => {
logs.logEvent("onDeleteCommunityChannel")
}
onDeleteCommunityChannel: () => { logs.logEvent("onDeleteCommunityChannel") }
}
}
}
@ -182,18 +185,29 @@ SplitView {
logsView.logText: logs.logText
RowLayout {
CheckBox {
ColumnLayout {
RowLayout {
RadioButton {
text: "Create mode"
checked: true
}
RadioButton {
id: ctrlIsEdit
text: "Edit mode"
}
RadioButton {
id: isDiscordCheckBox
text: "isDiscordImport"
onToggled: {
if (!!dialog && dialog.opened)
dialog.close()
}
}
}
Switch {
id: isDeleteableCheckBox
text: "isDeleteable"
}
CheckBox {
id: isDiscordCheckBox
text: "isDiscordImport"
onToggled: {
if (!!dialog && dialog.opened)
dialog.close()
}
enabled: ctrlIsEdit.checked
}
}
}

View File

@ -28,6 +28,7 @@ ColumnLayout {
StatusPickerButton {
Layout.fillWidth: true
Layout.preferredHeight: 44
property string validationError: ""

View File

@ -264,7 +264,7 @@ QtObject {
// Channel permissions model containing the temporarely edited permissions
property WritableProxyModel channelPermissionsModel: WritableProxyModel {
sourceModel: filteredPermissionsModel
sourceModel: d.filteredPermissionsModel
}
// Channels model containing the temporarely edited channel

View File

@ -41,7 +41,7 @@ StatusStackModal {
property string channelName: ""
property string channelDescription: ""
property string channelEmoji: ""
property string channelColor: ""
property string channelColor: d.communityDetails.color !== "" ? d.communityDetails.color : ""
property bool emojiPopupOpened: false
property var emojiPopup: null
readonly property int communityColorValidator: Utils.Validate.NoEmpty
@ -103,7 +103,7 @@ StatusStackModal {
d.hideIfPermissionsNotMet !== root.hideIfPermissionsNotMet ||
nameInput.input.text !== root.channelName ||
descriptionTextArea.text !== root.channelDescription ||
colorPanel.color.toString().toUpperCase() !== root.channelColor ||
!Qt.colorEqual(colorPanel.color, root.channelColor) ||
nameInput.input.asset.emoji !== root.channelEmoji
property int currentPage: CreateChannelPopup.CurrentPage.ChannelDetails
@ -252,8 +252,6 @@ StatusStackModal {
nextButton: StatusButton {
objectName: "createOrEditCommunityChannelBtn"
font.weight: Font.Medium
height: 44
visible: !d.colorPickerOpened
enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
text: !!currentItem.nextButtonText ? currentItem.nextButtonText :
@ -271,8 +269,6 @@ StatusStackModal {
finishButton: StatusButton {
objectName: "createChannelNextBtn"
font.weight: Font.Medium
height: 44
text: (typeof currentItem.nextButtonText !== "undefined") ? currentItem.nextButtonText :
qsTr("Import chat history")
enabled: typeof(currentItem.canGoNext) == "undefined" || currentItem.canGoNext
@ -289,9 +285,7 @@ StatusStackModal {
}
readonly property StatusButton clearFilesButton: StatusButton {
font.weight: Font.Medium
text: qsTr("Clear all")
height: 44
type: StatusBaseButton.Type.Danger
visible: typeof currentItem.isFileListView !== "undefined" && currentItem.isFileListView
enabled: !fileListView.fileListModelEmpty && !root.communitiesStore.discordDataExtractionInProgress
@ -348,7 +342,6 @@ StatusStackModal {
if (root.channelEmoji) {
nameInput.input.asset.emoji = root.channelEmoji
}
colorPanel.color = root.channelColor
} else {
nameInput.input.asset.isLetterIdenticon = true;
}
@ -452,7 +445,6 @@ StatusStackModal {
horizontalAlignment: Qt.AlignHCenter
text: qsTr("Refer to this <a href='https://github.com/Tyrrrz/DiscordChatExporter/blob/master/.docs/Readme.md'>documentation</a> if you have any queries")
onLinkActivated: Global.openLink(link)
onHoveredLinkChanged: print(hoveredLink)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
@ -705,7 +697,7 @@ StatusStackModal {
input.letterIconName = text
}
}
input.asset.color: colorPanel.color.toString()
input.asset.color: colorPanel.color
input.rightComponent: StatusRoundButton {
objectName: "StatusChannelPopup_emojiButton"
implicitWidth: 32
@ -747,6 +739,7 @@ StatusStackModal {
property string validationError: ""
width: parent.width
height: 44
anchors.bottom: parent.bottom
bgColor: colorPanel.colorSelected ? colorPanel.color : Theme.palette.baseColor2
contentColor: colorPanel.colorSelected ? Theme.palette.white : Theme.palette.baseColor1
@ -909,8 +902,8 @@ StatusStackModal {
leftPadding: 16
rightPadding: 16
height: Math.min(parent.height, 624)
property bool colorSelected: root.isEdit && root.channelColor
color: root.isEdit && root.channelColor ? root.channelColor : Theme.palette.primaryColor1
property bool colorSelected: !!root.channelColor && root.channelColor != Theme.palette.primaryColor1
color: root.channelColor || Theme.palette.primaryColor1
onAccepted: {
colorSelected = true; d.colorPickerOpened = false; d.currentPage = CreateChannelPopup.CurrentPage.ChannelDetails;
}