2022-08-10 08:29:26 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
import "../controls"
|
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
StatusDialog {
|
|
|
|
id: root
|
2022-08-12 15:51:33 +00:00
|
|
|
objectName: "socialLinksModal"
|
2022-08-10 08:29:26 +00:00
|
|
|
|
|
|
|
property ProfileStore profileStore
|
|
|
|
|
|
|
|
width: 640
|
|
|
|
topPadding: 24
|
|
|
|
bottomPadding: 24
|
|
|
|
leftPadding: 34
|
|
|
|
rightPadding: 34
|
|
|
|
|
|
|
|
title: qsTr("Social Links")
|
|
|
|
footer: null
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
staticLinksRepeater.model = staticSocialLinks
|
|
|
|
customLinksRepeater.model = customSocialLinks
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
// ensure text input values are reevaluated
|
|
|
|
staticLinksRepeater.model = null
|
|
|
|
customLinksRepeater.model = null
|
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: staticSocialLinks
|
|
|
|
|
|
|
|
sourceModel: root.profileStore.temporarySocialLinksModel
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "linkType"
|
|
|
|
value: Constants.socialLinkType.custom
|
|
|
|
inverted: true
|
|
|
|
}
|
|
|
|
sorters: RoleSorter {
|
|
|
|
roleName: "linkType"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SortFilterProxyModel {
|
|
|
|
id: customSocialLinks
|
|
|
|
|
|
|
|
sourceModel: root.profileStore.temporarySocialLinksModel
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "linkType"
|
|
|
|
value: Constants.socialLinkType.custom
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
id: scrollView
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
padding: 0
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
width: scrollView.availableWidth
|
|
|
|
|
|
|
|
spacing: 24 // by design
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: staticLinksRepeater
|
|
|
|
delegate: StaticSocialLinkInput {
|
2022-08-12 15:51:33 +00:00
|
|
|
objectName: model.text + "-socialLinkInput"
|
|
|
|
|
2022-08-10 08:29:26 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
linkType: model.linkType
|
|
|
|
text: model.url
|
|
|
|
|
2022-08-16 17:22:19 +00:00
|
|
|
input.tabNavItem: {
|
|
|
|
if (index < staticLinksRepeater.count - 1) {
|
|
|
|
return staticLinksRepeater.itemAt(index + 1).input.edit
|
|
|
|
}
|
|
|
|
return customLinksRepeater.count ? customLinksRepeater.itemAt(0).focusItem : null
|
|
|
|
}
|
|
|
|
|
2022-08-10 08:29:26 +00:00
|
|
|
onTextChanged: root.profileStore.updateLink(model.uuid, model.text, text)
|
2022-08-16 17:22:19 +00:00
|
|
|
|
|
|
|
Component.onCompleted: if (index === 0) {
|
|
|
|
input.edit.forceActiveFocus()
|
|
|
|
}
|
2022-08-10 08:29:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Custom links")
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
font.pixelSize: 15
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: customLinksLayout
|
|
|
|
|
|
|
|
spacing: 40
|
|
|
|
|
|
|
|
Layout.topMargin: -4 // by design
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: customLinksRepeater
|
|
|
|
delegate: CustomSocialLinkInput {
|
2022-08-12 15:51:33 +00:00
|
|
|
objectName: "customSocialLinkInput"
|
|
|
|
|
2022-08-10 08:29:26 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
hyperlink: model.text
|
|
|
|
url: model.url
|
|
|
|
|
|
|
|
removeButton.visible: index > 0
|
|
|
|
removeButton.onClicked: root.profileStore.removeCustomLink(model.uuid)
|
|
|
|
|
2022-08-16 17:22:19 +00:00
|
|
|
nextFocusItem: {
|
|
|
|
if (index < customLinksRepeater.count - 1) {
|
|
|
|
return customLinksRepeater.itemAt(index + 1).focusItem
|
|
|
|
}
|
|
|
|
return addAnotherCustomLinkButton
|
|
|
|
}
|
|
|
|
|
2022-08-10 08:29:26 +00:00
|
|
|
onHyperlinkChanged: root.profileStore.updateLink(model.uuid, hyperlink, url)
|
|
|
|
onUrlChanged: root.profileStore.updateLink(model.uuid, hyperlink, url)
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
y: -customLinksLayout.spacing / 2
|
|
|
|
width: parent.width
|
|
|
|
height: 1
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
visible: index > 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIconTextButton {
|
2022-08-16 17:22:19 +00:00
|
|
|
id: addAnotherCustomLinkButton
|
2022-08-10 08:29:26 +00:00
|
|
|
text: qsTr("Add another custom link")
|
|
|
|
onClicked: {
|
|
|
|
root.profileStore.createCustomLink("", "")
|
|
|
|
scrollView.contentY = scrollView.contentHeight - scrollView.availableHeight
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|