mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Fix menu popup that can be outside window.
Fix focus position on contact lists.
This commit is contained in:
parent
ad4e675f66
commit
56dc3db046
6 changed files with 21 additions and 14 deletions
|
|
@ -133,6 +133,11 @@ void MagicSearchList::setSelf(QSharedPointer<MagicSearchList> me) {
|
|||
});
|
||||
}
|
||||
|
||||
void MagicSearchList::connectContact(FriendCore *data) {
|
||||
connect(data, &FriendCore::removed, this, qOverload<QObject *>(&MagicSearchList::remove));
|
||||
connect(data, &FriendCore::starredChanged, this, &MagicSearchList::friendStarredChanged);
|
||||
}
|
||||
|
||||
void MagicSearchList::setResults(const QList<QSharedPointer<FriendCore>> &contacts) {
|
||||
for (auto item : mList) {
|
||||
auto isFriendCore = item.objectCast<FriendCore>();
|
||||
|
|
@ -142,12 +147,13 @@ void MagicSearchList::setResults(const QList<QSharedPointer<FriendCore>> &contac
|
|||
qDebug() << log().arg("SetResults: %1").arg(contacts.size());
|
||||
resetData<FriendCore>(contacts);
|
||||
for (auto it : contacts) {
|
||||
connect(it.get(), &FriendCore::removed, this, qOverload<QObject *>(&MagicSearchList::remove));
|
||||
connect(it.get(), &FriendCore::starredChanged, this, &MagicSearchList::friendStarredChanged);
|
||||
connectContact(it.get());
|
||||
}
|
||||
}
|
||||
|
||||
void MagicSearchList::addResult(const QSharedPointer<FriendCore> &contact) {
|
||||
void MagicSearchList::add(QSharedPointer<FriendCore> contact) {
|
||||
connectContact(contact.get());
|
||||
ListProxy::add(contact);
|
||||
}
|
||||
|
||||
void MagicSearchList::setSearch(const QString &search) {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ public:
|
|||
~MagicSearchList();
|
||||
|
||||
void setSelf(QSharedPointer<MagicSearchList> me);
|
||||
void connectContact(FriendCore* data);
|
||||
void setSearch(const QString &search);
|
||||
void setResults(const QList<QSharedPointer<FriendCore>> &contacts);
|
||||
void addResult(const QSharedPointer<FriendCore> &contact);
|
||||
void add(QSharedPointer<FriendCore> contact);
|
||||
|
||||
int getSourceFlags() const;
|
||||
void setSourceFlags(int flags);
|
||||
|
|
|
|||
|
|
@ -76,9 +76,10 @@ Button {
|
|||
onVisibleChanged: {
|
||||
if (!visible) return
|
||||
// Do not use popup.height as it is not consistent.
|
||||
var position = mainItem.mapToItem(mainItem.Window.contentItem, mainItem.x + popup.implicitContentWidth + popup.padding, mainItem.y + mainItem.height + popup.implicitContentHeight + popup.padding)
|
||||
if (position.y >= mainItem.Window.height) {
|
||||
y = -mainItem.height - popup.implicitContentHeight - popup.padding
|
||||
var popupHeight = mainItem.height + popup.implicitContentHeight + popup.padding
|
||||
var position = mainItem.mapToItem(mainItem.Window.contentItem, mainItem.x + popup.implicitContentWidth + popup.padding, mainItem.y + popupHeight)
|
||||
if (position.y + popupHeight >= mainItem.Window.height) {
|
||||
y = -popupHeight
|
||||
}else {
|
||||
y = mainItem.height + popup.padding
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ Flickable{
|
|||
}
|
||||
function updatePosition(list){
|
||||
var item = list.itemAtIndex(list.currentIndex)
|
||||
var centerPos = list.y - height/2
|
||||
var centerItemPos = 0
|
||||
if( item && list.expanded){
|
||||
// For debugging just in case
|
||||
//var listPosition = item.mapToItem(favoriteList, item.x, item.y)
|
||||
|
|
@ -154,9 +154,10 @@ Flickable{
|
|||
//console.log("new pos: " +newPosition.x + " / " +newPosition.y)
|
||||
//console.log("header pos: " +headerItem.x + " / " +headerItem.y)
|
||||
//console.log("Moving to " + (headerItem.y+item.y))
|
||||
centerPos += item.y
|
||||
centerItemPos = item.y + list.y + list.headerHeight +item.height/2
|
||||
}
|
||||
mainItem.contentY = Math.min(Math.max(0, centerPos), mainItem.contentHeight - mainItem.height)
|
||||
var centerPos = centerItemPos - height/2
|
||||
mainItem.contentY = Math.max(0, Math.min(centerPos, height, contentHeight-height))
|
||||
}
|
||||
Behavior on contentY{
|
||||
NumberAnimation {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ ListView {
|
|||
|
||||
property int itemsRightMargin: 39 * DefaultStyle.dp
|
||||
property bool expanded: true
|
||||
property int headerHeight: headerItem?.height
|
||||
|
||||
signal resultsReceived()
|
||||
signal contactDeletionRequested(FriendGui contact)
|
||||
|
|
@ -119,9 +120,6 @@ ListView {
|
|||
id: headerItem
|
||||
width: mainItem.width
|
||||
height: headerContents.implicitHeight
|
||||
onActiveFocusChanged: {
|
||||
if(activeFocus) mainItem.updatePosition()
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: headerContents
|
||||
|
|
|
|||
|
|
@ -769,7 +769,7 @@ AbstractMainPage {
|
|||
text: qsTr("Supprimer ce contact")
|
||||
visible: !mainItem.selectedContact?.core.readOnly
|
||||
onClicked: {
|
||||
mainItem.deleteContact(contact)
|
||||
mainItem.deleteContact(mainItem.selectedContact)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue