feat(ProfileShowcase): Integrate profile perspective selector

This commit is contained in:
Alex Jbanca 2024-03-25 15:29:31 +02:00 committed by Alex Jbanca
parent 77933cc732
commit 1d45243bc1
5 changed files with 72 additions and 26 deletions

View File

@ -1,10 +1,13 @@
import QtQuick 2.14 import QtQuick 2.15
import QtGraphicalEffects 1.14 import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
import shared.views 1.0 as SharedViews import shared.views 1.0 as SharedViews
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import shared.controls 1.0
Item { Item {
property alias profileStore: profilePreview.profileStore property alias profileStore: profilePreview.profileStore
property alias contactsStore: profilePreview.contactsStore property alias contactsStore: profilePreview.contactsStore
@ -20,27 +23,42 @@ Item {
implicitHeight: profilePreview.implicitHeight implicitHeight: profilePreview.implicitHeight
+ profilePreview.anchors.topMargin + layout.anchors.topMargin
+ profilePreview.anchors.bottomMargin + layout.anchors.bottomMargin
implicitWidth: profilePreview.implicitWidth implicitWidth: profilePreview.implicitWidth
+ profilePreview.anchors.leftMargin + layout.anchors.leftMargin
+ profilePreview.anchors.rightMargin + layout.anchors.rightMargin
function reload() { function reload() {
profilePreview.reload() profilePreview.reload()
} }
SharedViews.ProfileDialogView { ColumnLayout {
id: profilePreview id: layout
anchors.fill: parent anchors.fill: parent
anchors.margins: 64 anchors.margins: 64
spacing: 20
ProfilePerspectiveSelector {
id: selector
showcaseVisibility: profilePreview.showcaseMaxVisibility
onVisibilitySelected: (visibility) => profilePreview.showcaseMaxVisibility = visibility
}
SharedViews.ProfileDialogView {
id: profilePreview
Layout.fillWidth: true
Layout.fillHeight: true
Layout.maximumHeight: implicitHeight
readOnly: true readOnly: true
} }
Item { Layout.fillHeight: true }
}
DropShadow { DropShadow {
id: shadow id: shadow
anchors.fill: profilePreview anchors.fill: layout
anchors.topMargin: profilePreview.y
horizontalOffset: 0 horizontalOffset: 0
verticalOffset: 4 verticalOffset: 4
radius: 16 radius: 16

View File

@ -65,7 +65,7 @@ StatusButton {
id: menuItem id: menuItem
required property int showcaseVisibility required property int showcaseVisibility
readonly property string selectedText: d.buttonTextFormat.arg(text) readonly property string selectedText: qsTr("Preview as %1").arg(text)
readonly property alias selectedTextWidth: textMetricsMaxWidth.width readonly property alias selectedTextWidth: textMetricsMaxWidth.width
ButtonGroup.group: showcaseVisibilityGroup ButtonGroup.group: showcaseVisibilityGroup
@ -82,9 +82,6 @@ StatusButton {
QtObject { QtObject {
id: d id: d
readonly property string buttonTextFormat: "%1%2".arg(qsTr("Preview as "))
property real maxTextWidth: { property real maxTextWidth: {
let max = 0 let max = 0
for (var i = 0; i < showcaseVisibilityGroup.buttons.length; i++) { for (var i = 0; i < showcaseVisibilityGroup.buttons.length; i++) {

View File

@ -1,8 +1,10 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.15
import StatusQ.Popups.Dialog 0.1 import StatusQ.Popups.Dialog 0.1
import shared.views 1.0 import shared.views 1.0
import shared.controls 1.0
StatusDialog { StatusDialog {
id: root id: root
@ -24,11 +26,29 @@ StatusDialog {
property alias dirtyValues: profileView.dirtyValues property alias dirtyValues: profileView.dirtyValues
property alias dirty: profileView.dirty property alias dirty: profileView.dirty
implicitHeight: implicitContentHeight + (header.visible ? header.height : 0)
width: 640 width: 640
padding: 0 padding: 0
header: null
footer: null footer: null
background: null
header: Item {
id: headerItem
height: selector.height + 20
visible: profileView.isCurrentUser
TapHandler {
enabled: root.closePolicy != Popup.NoAutoClose
onTapped: {
root.close()
}
}
ProfilePerspectiveSelector {
id: selector
showcaseVisibility: profileView.showcaseMaxVisibility
onVisibilitySelected: (visibility) => profileView.showcaseMaxVisibility = visibility
}
}
contentItem: ProfileDialogView { contentItem: ProfileDialogView {
id: profileView id: profileView

View File

@ -29,6 +29,7 @@ Pane {
property bool readOnly // inside settings/profile/preview property bool readOnly // inside settings/profile/preview
property string publicKey: contactsStore.myPublicKey property string publicKey: contactsStore.myPublicKey
readonly property alias isCurrentUser: d.isCurrentUser
property var profileStore property var profileStore
property var contactsStore property var contactsStore
@ -44,6 +45,8 @@ Pane {
property var showcaseSocialLinksModel property var showcaseSocialLinksModel
property var showcaseAssetsModel property var showcaseAssetsModel
property alias showcaseMaxVisibility: showcaseView.maxVisibility
signal closeRequested() signal closeRequested()
padding: 0 padding: 0

View File

@ -20,6 +20,8 @@ Control {
property alias currentTabIndex: stackLayout.currentIndex property alias currentTabIndex: stackLayout.currentIndex
property int maxVisibility: Constants.ShowcaseVisibility.Everyone
property alias communitiesModel: communitiesProxyModel.sourceModel property alias communitiesModel: communitiesProxyModel.sourceModel
property alias accountsModel: accountsProxyModel.sourceModel property alias accountsModel: accountsProxyModel.sourceModel
property alias collectiblesModel: collectiblesProxyModel.sourceModel property alias collectiblesModel: collectiblesProxyModel.sourceModel
@ -48,7 +50,8 @@ Control {
roleName: "showcasePosition" roleName: "showcasePosition"
} }
] ]
filters: AnyOf { filters: [
AnyOf {
inverted: true inverted: true
UndefinedFilter { UndefinedFilter {
roleName: "showcaseVisibility" roleName: "showcaseVisibility"
@ -58,7 +61,12 @@ Control {
roleName: "showcaseVisibility" roleName: "showcaseVisibility"
value: Constants.ShowcaseVisibility.NoOne value: Constants.ShowcaseVisibility.NoOne
} }
},
FastExpressionFilter {
expression: model.showcaseVisibility >= root.maxVisibility
expectedRoles: ["showcaseVisibility"]
} }
]
} }
PositionSFPM { PositionSFPM {