fix(StatusQ): Dynamic width calculation for StatusMenu
This commit is contained in:
parent
2ba9680316
commit
ef837a9c9c
|
@ -1,4 +1,5 @@
|
|||
import QtQuick 2.15
|
||||
import QtQml 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtGraphicalEffects 1.15
|
||||
|
||||
|
@ -32,6 +33,7 @@ import StatusQ.Popups 0.1
|
|||
Menu {
|
||||
id: root
|
||||
|
||||
property real maxImplicitWidth: 640
|
||||
readonly property color defaultIconColor: Theme.palette.primaryColor1
|
||||
|
||||
property StatusAssetSettings assetSettings: StatusAssetSettings {
|
||||
|
@ -72,6 +74,7 @@ Menu {
|
|||
topPadding: 8
|
||||
bottomPadding: 8
|
||||
margins: 16
|
||||
width: Math.min(implicitWidth, root.maxImplicitWidth)
|
||||
|
||||
onOpened: {
|
||||
if (typeof openHandler === "function") {
|
||||
|
@ -85,15 +88,24 @@ Menu {
|
|||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
//helper property to get the max implicit width of the delegate
|
||||
property real maxDelegateImplWidth: 0
|
||||
}
|
||||
|
||||
delegate: StatusMenuItem {
|
||||
visible: root.hideDisabledItems ? enabled : true
|
||||
height: visible ? implicitHeight : 0
|
||||
onImplicitWidthChanged: {
|
||||
d.maxDelegateImplWidth = Math.max(d.maxDelegateImplWidth, implicitWidth)
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: StatusListView {
|
||||
currentIndex: root.currentIndex
|
||||
implicitHeight: contentHeight
|
||||
implicitWidth: contentWidth
|
||||
implicitWidth: d.maxDelegateImplWidth
|
||||
interactive: contentHeight > availableHeight
|
||||
model: root.contentModel
|
||||
}
|
||||
|
|
|
@ -9,9 +9,7 @@ import StatusQ.Popups 0.1
|
|||
|
||||
MenuItem {
|
||||
id: root
|
||||
|
||||
implicitWidth: parent ? parent.width : 0
|
||||
implicitHeight: 38
|
||||
|
||||
objectName: action ? action.objectName : "StatusMenuItemDelegate"
|
||||
|
||||
spacing: 4
|
||||
|
|
|
@ -275,7 +275,6 @@ Item {
|
|||
id: editImageMenuComponent
|
||||
|
||||
StatusMenu {
|
||||
width: 200
|
||||
|
||||
StatusAction {
|
||||
text: qsTr("Select different image")
|
||||
|
|
|
@ -207,7 +207,6 @@ Item {
|
|||
|
||||
StatusMenu {
|
||||
id: imageEditMenu
|
||||
width: 200
|
||||
|
||||
StatusAction {
|
||||
text: qsTr("Select different image")
|
||||
|
|
|
@ -15,8 +15,6 @@ StatusMenu {
|
|||
|
||||
property var store
|
||||
|
||||
width: 210
|
||||
|
||||
ProfileHeader {
|
||||
width: parent.width
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ Pane {
|
|||
|
||||
StatusMenu {
|
||||
id: moreMenu
|
||||
width: 230
|
||||
|
||||
SendContactRequestMenuItem {
|
||||
enabled: !d.isContact && !d.isBlocked && d.contactRequestState !== Constants.ContactRequestState.Sent &&
|
||||
d.contactDetails.trustStatus === Constants.trustStatus.untrustworthy // we have an action button otherwise
|
||||
|
|
|
@ -89,8 +89,6 @@ StatusMenu {
|
|||
selectedUserPublicKey = ""
|
||||
}
|
||||
|
||||
width: 230
|
||||
|
||||
ProfileHeader {
|
||||
width: parent.width
|
||||
height: visible ? implicitHeight : 0
|
||||
|
|
Loading…
Reference in New Issue