feat(StatusSearchPopupMenuItem): New APIs resetSearchSelection and setSearchSelection
New methods added `resetSearchSelection` and `setSearchSelection` for resetting and setting selected location.
This commit is contained in:
parent
e10c8f5d16
commit
9396bd208c
|
@ -567,8 +567,9 @@ Rectangle {
|
||||||
chatInfoButton.type: StatusChatInfoButton.Type.CommunityChat
|
chatInfoButton.type: StatusChatInfoButton.Type.CommunityChat
|
||||||
onSearchButtonClicked: {
|
onSearchButtonClicked: {
|
||||||
searchButton.highlighted = !searchButton.highlighted;
|
searchButton.highlighted = !searchButton.highlighted;
|
||||||
searchPopup.searchSelectionButton.primaryText = demoCommunityDetailModal.header.title;
|
searchPopup.setSearchSelection(demoCommunityDetailModal.header.title,
|
||||||
searchPopup.searchSelectionButton.image.source = demoCommunityDetailModal.header.image.source;
|
"",
|
||||||
|
demoCommunityDetailModal.header.image.source);
|
||||||
searchPopup.open();
|
searchPopup.open();
|
||||||
}
|
}
|
||||||
membersButton.onClicked: membersButton.highlighted = !membersButton.highlighted
|
membersButton.onClicked: membersButton.highlighted = !membersButton.highlighted
|
||||||
|
|
|
@ -16,8 +16,7 @@ StatusPopupMenu {
|
||||||
StatusMenuItem {
|
StatusMenuItem {
|
||||||
text: "Anywhere"
|
text: "Anywhere"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
searchPopup.resetSelectionBadge();
|
searchPopup.resetSearchSelection();
|
||||||
searchPopup.searchSelectionButton.primaryText = text;
|
|
||||||
root.itemClicked("", "");
|
root.itemClicked("", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,13 +63,13 @@ StatusPopupMenu {
|
||||||
id: subMenuItemComponent
|
id: subMenuItemComponent
|
||||||
StatusSearchPopupMenuItem {
|
StatusSearchPopupMenuItem {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
searchPopup.resetSelectionBadge()
|
searchPopup.resetSearchSelection()
|
||||||
searchPopup.searchSelectionButton.primaryText = text;
|
searchPopup.setSearchSelection(text,
|
||||||
searchPopup.searchSelectionButton.image.source = image.source;
|
"",
|
||||||
searchPopup.searchSelectionButton.image.isIdenticon = image.isIdenticon;
|
image.source,
|
||||||
searchPopup.searchSelectionButton.iconSettings.name = iconSettings.name;
|
image.isIdenticon,
|
||||||
searchPopup.searchSelectionButton.iconSettings.color = !!iconSettings.color ? iconSettings.color : Theme.palette.primaryColor1
|
iconSettings.name,
|
||||||
searchPopup.searchSelectionButton.iconSettings.isLetterIdenticon = !iconSettings.name && !image.source
|
iconSettings.color)
|
||||||
root.itemClicked(value, "")
|
root.itemClicked(value, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,22 +104,21 @@ StatusPopupMenu {
|
||||||
iconSettings.color: model.iconColor
|
iconSettings.color: model.iconColor
|
||||||
image.isIdenticon: model.isIdenticon
|
image.isIdenticon: model.isIdenticon
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
searchPopup.resetSelectionBadge();
|
searchPopup.resetSearchSelection()
|
||||||
if (menuLoader.parentTitleText === "Chat") {
|
if (menuLoader.parentTitleText === "Chat") {
|
||||||
searchPopup.searchSelectionButton.primaryText = model.text;
|
searchPopup.setSearchSelection(model.text,
|
||||||
searchPopup.searchSelectionButton.image.source = model.imageSource;
|
"",
|
||||||
searchPopup.searchSelectionButton.image.isIdenticon = model.isIdenticon;
|
model.imageSource,
|
||||||
searchPopup.searchSelectionButton.iconSettings.name = model.iconName;
|
model.isIdenticon,
|
||||||
searchPopup.searchSelectionButton.iconSettings.color = !!model.iconColor ? model.iconColor : Theme.palette.primaryColor1;
|
model.iconName,
|
||||||
searchPopup.searchSelectionButton.iconSettings.isLetterIdenticon = !model.iconName && !model.imageSource
|
model.iconColor)
|
||||||
} else {
|
} else {
|
||||||
searchPopup.searchSelectionButton.primaryText = menuLoader.parentTitleText;
|
searchPopup.setSearchSelection(menuLoader.parentTitleText,
|
||||||
searchPopup.searchSelectionButton.secondaryText = model.text;
|
model.text,
|
||||||
searchPopup.searchSelectionButton.image.source = menuLoader.parentImageSource;
|
menuLoader.parentImageSource,
|
||||||
searchPopup.searchSelectionButton.image.isIdenticon = menuLoader.parentIsIdenticon;
|
menuLoader.parentIsIdenticon,
|
||||||
searchPopup.searchSelectionButton.iconSettings.name = menuLoader.parentIconName;
|
menuLoader.parentIconName,
|
||||||
searchPopup.searchSelectionButton.iconSettings.color = !!menuLoader.parentIdenticonColor ? menuLoader.parentIdenticonColor : Theme.palette.primaryColor1;
|
menuLoader.parentIdenticonColor)
|
||||||
searchPopup.searchSelectionButton.iconSettings.isLetterIdenticon = !menuLoader.parentIconName && !menuLoader.parentImageSource
|
|
||||||
}
|
}
|
||||||
root.itemClicked(menuLoader.parentValue, value)
|
root.itemClicked(menuLoader.parentValue, value)
|
||||||
root.dismiss()
|
root.dismiss()
|
||||||
|
@ -131,14 +129,14 @@ StatusPopupMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMenuItemClicked: {
|
onMenuItemClicked: {
|
||||||
searchPopup.resetSelectionBadge();
|
searchPopup.resetSearchSelection()
|
||||||
let menuItem = root.menuAt(root.currentIndex)
|
let menuItem = root.menuAt(root.currentIndex)
|
||||||
searchPopup.searchSelectionButton.primaryText = menuItem.title;
|
searchPopup.setSearchSelection(menuItem.title,
|
||||||
searchPopup.searchSelectionButton.image.source = menuItem.parentImageSource;
|
"",
|
||||||
searchPopup.searchSelectionButton.image.isIdenticon = menuItem.parentIsIdenticon;
|
menuItem.parentImageSource,
|
||||||
searchPopup.searchSelectionButton.iconSettings.name = menuItem.parentIconName;
|
menuItem.parentIsIdenticon,
|
||||||
searchPopup.searchSelectionButton.iconSettings.color = menuItem.parentIdenticonColor;
|
menuItem.parentIconName,
|
||||||
searchPopup.searchSelectionButton.iconSettings.isLetterIdenticon = !menuItem.parentIconName && !menuItem.parentImageSource
|
menuItem.parentIdenticonColor)
|
||||||
root.itemClicked(menuItem.parentValue, "")
|
root.itemClicked(menuItem.parentValue, "")
|
||||||
//TODO fix error "QML StatusPopupMenu: cannot find any window to open popup in."
|
//TODO fix error "QML StatusPopupMenu: cannot find any window to open popup in."
|
||||||
root.dismiss()
|
root.dismiss()
|
||||||
|
|
|
@ -19,21 +19,32 @@ StatusModal {
|
||||||
|
|
||||||
property string searchText: contentComponent.searchText
|
property string searchText: contentComponent.searchText
|
||||||
property string noResultsLabel: "No results"
|
property string noResultsLabel: "No results"
|
||||||
|
property string defaultSearchLocationText: "Anywhere"
|
||||||
property bool loading
|
property bool loading
|
||||||
property Menu searchOptionsPopupMenu: Menu { }
|
property Menu searchOptionsPopupMenu: Menu { }
|
||||||
property var searchResults: [ ]
|
property var searchResults: [ ]
|
||||||
property var searchSelectionButton
|
property var searchSelectionButton
|
||||||
function resetSelectionBadge() {
|
|
||||||
searchSelectionButton.iconSettings.name = ""
|
|
||||||
searchSelectionButton.iconSettings.isLetterIdenticon = false
|
|
||||||
searchSelectionButton.iconSettings.color = "transparent"
|
|
||||||
searchSelectionButton.image.source = ""
|
|
||||||
searchSelectionButton.image.isIdenticon = false
|
|
||||||
searchSelectionButton.primaryText = qsTr("Anywhere");
|
|
||||||
searchSelectionButton.secondaryText = "";
|
|
||||||
|
|
||||||
signal resultItemClicked(string itemId)
|
signal resultItemClicked(string itemId)
|
||||||
signal resultItemTitleClicked(string titleId)
|
signal resultItemTitleClicked(string titleId)
|
||||||
|
|
||||||
|
function setSearchSelection(text = "",
|
||||||
|
secondaryText = "",
|
||||||
|
imageSource = "",
|
||||||
|
isIdenticon = "",
|
||||||
|
iconName = "",
|
||||||
|
iconColor = "") {
|
||||||
|
searchSelectionButton.primaryText = text
|
||||||
|
searchSelectionButton.secondaryText = secondaryText
|
||||||
|
searchSelectionButton.image.source = imageSource
|
||||||
|
searchSelectionButton.image.isIdenticon = isIdenticon
|
||||||
|
searchSelectionButton.iconSettings.name = iconName
|
||||||
|
searchSelectionButton.iconSettings.color = iconColor !== ""? iconColor : Theme.palette.primaryColor1
|
||||||
|
searchSelectionButton.iconSettings.isLetterIdenticon = !iconName && !imageSource
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetSearchSelection() {
|
||||||
|
setSearchSelection(defaultSearchLocationText, "", "", false, "", "transparent")
|
||||||
}
|
}
|
||||||
|
|
||||||
content: Item {
|
content: Item {
|
||||||
|
@ -134,9 +145,10 @@ StatusModal {
|
||||||
Loader {
|
Loader {
|
||||||
Layout.preferredWidth: active ? 16 : 0
|
Layout.preferredWidth: active ? 16 : 0
|
||||||
Layout.preferredHeight: 16
|
Layout.preferredHeight: 16
|
||||||
active: searchOptionsMenuButton.iconSettings.name ||
|
active: searchOptionsMenuButton.primaryText !== defaultSearchLocationText &&
|
||||||
|
(searchOptionsMenuButton.iconSettings.name ||
|
||||||
searchOptionsMenuButton.iconSettings.isLetterIdenticon ||
|
searchOptionsMenuButton.iconSettings.isLetterIdenticon ||
|
||||||
!!searchOptionsMenuButton.image.source.toString()
|
!!searchOptionsMenuButton.image.source.toString())
|
||||||
|
|
||||||
sourceComponent: {
|
sourceComponent: {
|
||||||
if (!!searchOptionsMenuButton.image.source.toString()) {
|
if (!!searchOptionsMenuButton.image.source.toString()) {
|
||||||
|
@ -231,14 +243,14 @@ StatusModal {
|
||||||
anchors.left: searchOptionsMenuButton.right
|
anchors.left: searchOptionsMenuButton.right
|
||||||
anchors.leftMargin: 4
|
anchors.leftMargin: 4
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
opacity: (searchOptionsMenuButton.primaryText === qsTr("Anywhere")) ? 0.0 : 1.0
|
opacity: (searchOptionsMenuButton.primaryText === defaultSearchLocationText) ? 0.0 : 1.0
|
||||||
visible: (opacity > 0.1)
|
visible: (opacity > 0.1)
|
||||||
type: StatusFlatRoundButton.Type.Secondary
|
type: StatusFlatRoundButton.Type.Secondary
|
||||||
icon.name: "close"
|
icon.name: "close"
|
||||||
icon.color: Theme.palette.directColor1
|
icon.color: Theme.palette.directColor1
|
||||||
icon.width: 20
|
icon.width: 20
|
||||||
icon.height: 20
|
icon.height: 20
|
||||||
onClicked: { root.resetSelectionBadge(); }
|
onClicked: { root.resetSearchSelection(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +333,7 @@ StatusModal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClosed: {
|
onClosed: {
|
||||||
root.resetSelectionBadge();
|
root.resetSearchSelection();
|
||||||
root.loading = false;
|
root.loading = false;
|
||||||
contentComponent.searchText = "";
|
contentComponent.searchText = "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue