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