1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-07-14 04:25:22 +02:00

contextmenu: various fixes + simplify

Change-Id: Ibf10c91d4f875e9e346003c6fe9797325cf23c4f
This commit is contained in:
Andreas Traczyk 2023-11-27 08:09:14 -05:00
parent bb8f4cc3a7
commit d5bacf6b9f
3 changed files with 39 additions and 43 deletions

View file

@ -58,34 +58,28 @@ Menu {
menuItems[i].itemRealWidth = menuPreferredWidth;
if (menuItemsPreferredHeight)
menuItems[i].itemPreferredHeight = menuItemsPreferredHeight;
var menuSeparatorComponent, menuSeparatorComponentObj;
if (i !== menuItems.length - 1) {
var menuSeparatorComponent = Qt.createComponent("GeneralMenuSeparator.qml", Component.PreferSynchronous, root);
var menuSeparatorComponentObj = menuSeparatorComponent.createObject();
menuSeparatorComponent = Qt.createComponent("GeneralMenuSeparator.qml", Component.PreferSynchronous, root);
menuSeparatorComponentObj = menuSeparatorComponent.createObject();
generalMenuSeparatorList.push(menuSeparatorComponentObj);
root.addItem(menuSeparatorComponentObj);
}
if (menuItems[i].addMenuSeparatorAfter) {
var menuSeparatorComponent = Qt.createComponent("GeneralMenuSeparator.qml", Component.PreferSynchronous, root);
var menuSeparatorComponentObj = menuSeparatorComponent.createObject(root, {
menuSeparatorComponent = Qt.createComponent("GeneralMenuSeparator.qml", Component.PreferSynchronous, root);
menuSeparatorComponentObj = menuSeparatorComponent.createObject(root, {
"separatorColor": "#DEDEDE",
"separatorPreferredHeight": 0
});
generalMenuSeparatorList.push(menuSeparatorComponentObj);
root.addItem(menuSeparatorComponentObj);
var menuSeparatorComponent = Qt.createComponent("GeneralMenuSeparator.qml", Component.PreferSynchronous, root);
var menuSeparatorComponentObj = menuSeparatorComponent.createObject();
menuSeparatorComponentObj = menuSeparatorComponent.createObject();
generalMenuSeparatorList.push(menuSeparatorComponentObj);
root.addItem(menuSeparatorComponentObj);
}
}
}
root.addItem(menuBottomBorder);
root.open();
}
onVisibleChanged: {
if (!visible)
root.close();
}
font.pointSize: JamiTheme.menuFontSize

View file

@ -56,6 +56,7 @@ Loader {
contextMenu.menuItemsPreferredHeight = contextMenuItemPreferredHeight;
contextMenu.menuSeparatorPreferredHeight = contextMenuSeparatorPreferredHeight;
contextMenu.loadMenuItems(menuItemsToLoad);
contextMenu.open();
}
}
}

View file

@ -51,7 +51,12 @@ RowLayout {
signal showMapClicked
signal emojiButtonClicked
height: showTypo || multiLine ? messageBarTextArea.height + 25 + 3 * marginSize + 1 : textAreaObj.height + marginSize + 1
height: {
if (showTypo || multiLine)
return messageBarTextArea.height + 25 + 3 * marginSize + 1
else
return textAreaObj.height + marginSize + 1
}
Rectangle {
@ -67,11 +72,16 @@ RowLayout {
anchors.bottom: parent.bottom
anchors.bottomMargin: marginSize / 2
// Used to choose the correct color for the button.
readonly property bool highlight: down || hovered
background: Rectangle {
implicitWidth: showMoreButton.width
implicitHeight: showMoreButton.height
radius: 5
color: JamiTheme.transparentColor
color: showMoreButton.highlight ?
JamiTheme.hoveredButtonColor :
JamiTheme.transparentColor
}
MaterialToolTip {
@ -80,7 +90,7 @@ RowLayout {
parent: showMoreButton
visible: showMoreButton.hovered && (text.length > 0)
delay: Qt.styleHints.mousePressAndHoldInterval
text: JamiStrings.showMore
text: showMoreButton.down ? JamiStrings.showLess : JamiStrings.showMore
}
indicator: ResponsiveImage {
@ -93,28 +103,29 @@ RowLayout {
source: JamiResources.more_menu_black_24dp_svg
color: JamiTheme.chatViewFooterImgColor
color: showMoreButton.highlight ?
JamiTheme.chatViewFooterImgHoverColor :
JamiTheme.chatViewFooterImgColor;
}
onHoveredChanged: {
if (!sharePopup.opened) {
showMoreButton.indicator.color = hovered ? JamiTheme.chatViewFooterImgHoverColor : JamiTheme.chatViewFooterImgColor;
showMoreButton.background.color = hovered ? JamiTheme.hoveredButtonColor : JamiTheme.transparentColor;
Component {
id: sharePopupComp
ShareMenu {
id: sharePopup
onAudioRecordMessageButtonClicked: root.audioRecordMessageButtonClicked()
onVideoRecordMessageButtonClicked: root.videoRecordMessageButtonClicked()
onShowMapClicked: root.showMapClicked()
modelList: listViewMoreButton.menuMoreButton
y: showMoreButton.y + 31
x: showMoreButton.x - 3
}
toolTipMoreButton.text = sharePopup.opened ? JamiStrings.showLess : JamiStrings.showMore;
}
popup: ShareMenu {
id: sharePopup
onAudioRecordMessageButtonClicked: {
root.audioRecordMessageButtonClicked();
}
onVideoRecordMessageButtonClicked: {
root.videoRecordMessageButtonClicked();
}
onShowMapClicked: {
root.showMapClicked();
}
onAudioRecordMessageButtonClicked: root.audioRecordMessageButtonClicked()
onVideoRecordMessageButtonClicked: root.videoRecordMessageButtonClicked()
onShowMapClicked: root.showMapClicked()
modelList: listViewMoreButton.menuMoreButton
y: showMoreButton.y + 31
x: showMoreButton.x - 3
@ -122,14 +133,6 @@ RowLayout {
}
}
Connections {
target: sharePopup
function onOpenedChanged() {
showMoreButton.indicator.color = (showMoreButton.parent && showMoreButton.parent.hovered) || (sharePopup != null && sharePopup.opened) ? JamiTheme.chatViewFooterImgHoverColor : JamiTheme.chatViewFooterImgColor;
showMoreButton.background.color = (showMoreButton.parent && showMoreButton.parent.hovered) || sharePopup.opened ? JamiTheme.hoveredButtonColor : JamiTheme.transparentColor;
}
}
Rectangle {
id: rectangle
@ -349,8 +352,6 @@ RowLayout {
}
var selectedText = text.substring(start - char1.length, end + char2.length);
return (selectedText.startsWith(char1) && selectedText.endsWith(char2));
var res = regex.test(text.substring(start - char1.length, end + char2.length));
return res && start - char1.length >= 0 && end + char2.length <= text.length;
}
function isStarStyle(text, selectionStart, selectionEnd, type) {
@ -836,14 +837,14 @@ RowLayout {
toolTipText: modelData.shortcutText
shortcutKey: modelData.shortcutKey
hasShortcut: modelData.hasShortcut != null ? modelData.hasShortcut : true
hasShortcut: modelData.hasShortcut ? true : false
source: modelData.iconSrc
focusPolicy: Qt.TabFocus
normalColor: {
if (showPreview) {
return JamiTheme.primaryBackgroundColor;
} else if (modelData.normalColor != null) {
} else if (modelData.normalColor) {
return modelData.normalColor;
} else if (modelData.isStyle) {
return JamiTheme.hoveredButtonColor;
@ -856,7 +857,7 @@ RowLayout {
return JamiTheme.chatViewFooterImgDisableColor;
} else if (hovered) {
return JamiTheme.chatViewFooterImgHoverColor;
} else if (modelData.imageColor != null) {
} else if (modelData.imageColor !== null) {
return modelData.imageColor;
} else if (modelData.isStyle) {
return JamiTheme.chatViewFooterImgHoverColor;