Commit 9963fb6f authored by armin's avatar armin

auto resize menu

parent 314ac191
Pipeline #773 passed with stage
in 3 minutes and 33 seconds
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.0
import "qrc:/qml/style"
StyledMenu{
......@@ -7,42 +7,54 @@ StyledMenu{
signal replyTo(string messageId)
signal blockUser()
signal reportContent()
implicitWidth: 110
implicitWidth: 50
//implicitWidth: 110
StyledMenuItem{
id: copyItem
text: qsTr("copy")
onPressed: {
Action {
text: qsTr("copy");
checkable: false;
onTriggered: {
rocketChatController.copyToClipboard(messageText.text)
}
}
StyledMenuItem{
id: reply
text: qsTr("reply")
onPressed: {
Action {
text: qsTr("reply");
checkable: false
onTriggered: {
replyTo(model.id);
}
background: Item{}
}
StyledMenuItem{
id: deleteMessage
text: qsTr("delete")
onPressed: {
Action {
text: qsTr("delete");
checkable: false
onTriggered: {
rocketChatController.deleteMessage(channelView.currentChannel,model.id)
}
}
StyledMenuItem{
id: blockUserItem
text: qsTr("blockUser")
onPressed: {
Action {
text: qsTr("blockUser");
checkable: false
onTriggered: {
textBackground.blockUser();
}
}
StyledMenuItem{
id: reportContent
text: qsTr("report abuse")
onPressed: {
Action {
text: qsTr("report abuse");
checkable: false
onTriggered: {
textBackground.reportContent();
}
}
delegate: StyledMenuItem{
Component.onCompleted: {
console.log("menu item delegate: "+width)
}
}
Component.onCompleted: {
console.log("width menu: "+width)
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.0
import "qrc:/qml/style/"
Menu {
width: {
var result = 0;
var padding = 0;
for (var i = 0; i < count; ++i) {
var item = itemAt(i);
result = Math.max(item.contentItem.implicitWidth, result);
padding = Math.max(item.padding, padding);
}
return result + padding * 2;
}
background: Item{
/*Rectangle{
z:-1
......
......@@ -4,22 +4,34 @@ import QtQuick.Controls 2.2
import "qrc:/qml/style"
MenuItem {
id:menuItem
contentItem: StyledText{
text: parent.text
leftPadding: 5
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
// elide: Text.ElideRight
Component.onCompleted: {
console.log("text width: "+width)
console.log("menu item width: "+menuItem.width)
}
}
background: Rectangle{
anchors.fill: parent
anchors.topMargin: 3
// implicitWidth: 200
implicitHeight: 1
// anchors.fill: parent
/* anchors.topMargin: 3
anchors.leftMargin: 3
anchors.rightMargin: 3
*/
Rectangle{
anchors.bottom: parent.bottom
width: parent.width
/* anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.right: parent.right*/
height: 1
color: Colors.grey
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment