Compare commits

...

1 Commits

Author SHA1 Message Date
Tobias Fella
b3736882f1 Port General RoomSettings to FormCard 2023-09-01 14:55:18 +02:00

View File

@@ -8,32 +8,24 @@ import QtQuick.Layouts 1.15
import QtQuick.Window 2.15 import QtQuick.Window 2.15
import org.kde.kirigami 2.15 as Kirigami import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm import org.kde.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
import org.kde.neochat 1.0 import org.kde.neochat 1.0
Kirigami.ScrollablePage { FormCard.FormCardPage {
id: root id: root
property NeoChatRoom room property NeoChatRoom room
title: i18n("General") title: i18n("General")
topPadding: 0
leftPadding: 0 FormCard.FormHeader {
rightPadding: 0
ColumnLayout {
spacing: 0
MobileForm.FormHeader {
Layout.fillWidth: true
title: i18n("Room Information") title: i18n("Room Information")
} }
MobileForm.FormCard {
Layout.fillWidth: true FormCard.FormCard {
contentItem: ColumnLayout { FormCard.AbstractFormDelegate {
spacing: 0
MobileForm.AbstractFormDelegate {
Layout.fillWidth: true
background: Item {} background: Item {}
contentItem: RowLayout { contentItem: RowLayout {
Item { Item {
@@ -69,21 +61,29 @@ Kirigami.ScrollablePage {
QQC2.ToolTip.text: text QQC2.ToolTip.text: text
QQC2.ToolTip.visible: hovered QQC2.ToolTip.visible: hovered
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
Component {
id: openFileDialog
OpenFileDialog {
parentWindow: root.Window.window
}
}
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
} }
} }
} }
MobileForm.FormTextFieldDelegate { FormCard.FormTextFieldDelegate {
id: roomNameField id: roomNameField
label: i18n("Room name:") label: i18n("Room name:")
text: room.name text: room.name
enabled: room.canSendState("m.room.name") enabled: room.canSendState("m.room.name")
} }
MobileForm.AbstractFormDelegate { FormCard.AbstractFormDelegate {
id: roomTopicField id: roomTopicField
Layout.fillWidth: true
enabled: room.canSendState("m.room.topic") enabled: room.canSendState("m.room.topic")
background: Item {} background: Item {}
contentItem: ColumnLayout { contentItem: ColumnLayout {
@@ -100,8 +100,7 @@ Kirigami.ScrollablePage {
} }
} }
} }
MobileForm.AbstractFormDelegate { FormCard.AbstractFormDelegate {
Layout.fillWidth: true
background: Item {} background: Item {}
contentItem: RowLayout { contentItem: RowLayout {
Item { Item {
@@ -124,7 +123,7 @@ Kirigami.ScrollablePage {
} }
} }
} }
MobileForm.FormTextDelegate { FormCard.FormTextDelegate {
id: roomIdDelegate id: roomIdDelegate
text: i18n("Room ID") text: i18n("Room ID")
description: room.id description: room.id
@@ -144,7 +143,7 @@ Kirigami.ScrollablePage {
QQC2.ToolTip.visible: hovered QQC2.ToolTip.visible: hovered
} }
} }
MobileForm.FormTextDelegate { FormCard.FormTextDelegate {
text: i18n("Room version") text: i18n("Room version")
description: room.version description: room.version
@@ -165,20 +164,39 @@ Kirigami.ScrollablePage {
text: text text: text
delay: Kirigami.Units.toolTipDelay delay: Kirigami.Units.toolTipDelay
} }
Kirigami.OverlaySheet {
id: roomUpgradeSheet
property var currentRoomVersion
title: i18n("Upgrade the Room")
Kirigami.FormLayout {
QQC2.SpinBox {
id: spinBox
Kirigami.FormData.label: i18n("Select new version")
from: room.version
to: room.maxRoomVersion
value: room.version
}
QQC2.Button {
text: i18n("Confirm")
onClicked: {
room.switchVersion(spinBox.value)
roomUpgradeSheet.close()
}
}
}
} }
} }
} }
} }
MobileForm.FormHeader { FormCard.FormHeader {
Layout.fillWidth: true
title: i18n("Aliases") title: i18n("Aliases")
} }
MobileForm.FormCard { FormCard.FormCard {
Layout.fillWidth: true FormCard.FormTextDelegate {
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormTextDelegate {
visible: room.aliases.length <= 0 visible: room.aliases.length <= 0
text: i18n("No canonical alias set") text: i18n("No canonical alias set")
} }
@@ -186,7 +204,7 @@ Kirigami.ScrollablePage {
id: altAliasRepeater id: altAliasRepeater
model: room.aliases.slice().reverse() model: room.aliases.slice().reverse()
delegate: MobileForm.FormTextDelegate { delegate: FormCard.FormTextDelegate {
text: modelData text: modelData
description: room.canonicalAlias.length > 0 && modelData === room.canonicalAlias ? "Canonical alias" : "" description: room.canonicalAlias.length > 0 && modelData === room.canonicalAlias ? "Canonical alias" : ""
contentItem.children: [ contentItem.children: [
@@ -224,8 +242,7 @@ Kirigami.ScrollablePage {
} }
} }
MobileForm.AbstractFormDelegate { FormCard.AbstractFormDelegate {
Layout.fillWidth: true
visible: room.canSendState("m.room.canonical_alias") visible: room.canSendState("m.room.canonical_alias")
contentItem : RowLayout { contentItem : RowLayout {
@@ -268,17 +285,12 @@ Kirigami.ScrollablePage {
} }
} }
} }
}
MobileForm.FormHeader { FormCard.FormHeader {
Layout.fillWidth: true
title: i18n("URL Previews") title: i18n("URL Previews")
} }
MobileForm.FormCard { FormCard.FormCard {
Layout.fillWidth: true FormCard.FormCheckDelegate {
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCheckDelegate {
text: i18n("Enable URL previews by default for room members") text: i18n("Enable URL previews by default for room members")
checked: room.defaultUrlPreviewState checked: room.defaultUrlPreviewState
visible: room.canSendState("org.matrix.room.preview_urls") visible: room.canSendState("org.matrix.room.preview_urls")
@@ -286,7 +298,7 @@ Kirigami.ScrollablePage {
room.defaultUrlPreviewState = checked room.defaultUrlPreviewState = checked
} }
} }
MobileForm.FormCheckDelegate { FormCard.FormCheckDelegate {
text: i18n("Enable URL previews") text: i18n("Enable URL previews")
// Most users won't see the above setting so tell them the default. // Most users won't see the above setting so tell them the default.
description: room.defaultUrlPreviewState ? i18n("URL previews are enabled by default in this room") : i18n("URL previews are disabled by default in this room") description: room.defaultUrlPreviewState ? i18n("URL previews are enabled by default in this room") : i18n("URL previews are disabled by default in this room")
@@ -296,7 +308,6 @@ Kirigami.ScrollablePage {
} }
} }
} }
}
Kirigami.InlineMessage { Kirigami.InlineMessage {
Layout.fillWidth: true Layout.fillWidth: true
@@ -328,38 +339,5 @@ Kirigami.ScrollablePage {
} }
} }
} }
Component {
id: openFileDialog
OpenFileDialog {
parentWindow: root.Window.window
}
}
Kirigami.OverlaySheet {
id: roomUpgradeSheet
property var currentRoomVersion
title: i18n("Upgrade the Room")
Kirigami.FormLayout {
QQC2.SpinBox {
id: spinBox
Kirigami.FormData.label: i18n("Select new version")
from: room.version
to: room.maxRoomVersion
value: room.version
}
QQC2.Button {
text: i18n("Confirm")
onClicked: {
room.switchVersion(spinBox.value)
roomUpgradeSheet.close()
}
}
}
}
}
} }