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) {
|
void MagicSearchList::setResults(const QList<QSharedPointer<FriendCore>> &contacts) {
|
||||||
for (auto item : mList) {
|
for (auto item : mList) {
|
||||||
auto isFriendCore = item.objectCast<FriendCore>();
|
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());
|
qDebug() << log().arg("SetResults: %1").arg(contacts.size());
|
||||||
resetData<FriendCore>(contacts);
|
resetData<FriendCore>(contacts);
|
||||||
for (auto it : contacts) {
|
for (auto it : contacts) {
|
||||||
connect(it.get(), &FriendCore::removed, this, qOverload<QObject *>(&MagicSearchList::remove));
|
connectContact(it.get());
|
||||||
connect(it.get(), &FriendCore::starredChanged, this, &MagicSearchList::friendStarredChanged);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
void MagicSearchList::setSearch(const QString &search) {
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@ public:
|
||||||
~MagicSearchList();
|
~MagicSearchList();
|
||||||
|
|
||||||
void setSelf(QSharedPointer<MagicSearchList> me);
|
void setSelf(QSharedPointer<MagicSearchList> me);
|
||||||
|
void connectContact(FriendCore* data);
|
||||||
void setSearch(const QString &search);
|
void setSearch(const QString &search);
|
||||||
void setResults(const QList<QSharedPointer<FriendCore>> &contacts);
|
void setResults(const QList<QSharedPointer<FriendCore>> &contacts);
|
||||||
void addResult(const QSharedPointer<FriendCore> &contact);
|
void add(QSharedPointer<FriendCore> contact);
|
||||||
|
|
||||||
int getSourceFlags() const;
|
int getSourceFlags() const;
|
||||||
void setSourceFlags(int flags);
|
void setSourceFlags(int flags);
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,10 @@ Button {
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (!visible) return
|
if (!visible) return
|
||||||
// Do not use popup.height as it is not consistent.
|
// 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)
|
var popupHeight = mainItem.height + popup.implicitContentHeight + popup.padding
|
||||||
if (position.y >= mainItem.Window.height) {
|
var position = mainItem.mapToItem(mainItem.Window.contentItem, mainItem.x + popup.implicitContentWidth + popup.padding, mainItem.y + popupHeight)
|
||||||
y = -mainItem.height - popup.implicitContentHeight - popup.padding
|
if (position.y + popupHeight >= mainItem.Window.height) {
|
||||||
|
y = -popupHeight
|
||||||
}else {
|
}else {
|
||||||
y = mainItem.height + popup.padding
|
y = mainItem.height + popup.padding
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ Flickable{
|
||||||
}
|
}
|
||||||
function updatePosition(list){
|
function updatePosition(list){
|
||||||
var item = list.itemAtIndex(list.currentIndex)
|
var item = list.itemAtIndex(list.currentIndex)
|
||||||
var centerPos = list.y - height/2
|
var centerItemPos = 0
|
||||||
if( item && list.expanded){
|
if( item && list.expanded){
|
||||||
// For debugging just in case
|
// For debugging just in case
|
||||||
//var listPosition = item.mapToItem(favoriteList, item.x, item.y)
|
//var listPosition = item.mapToItem(favoriteList, item.x, item.y)
|
||||||
|
|
@ -154,9 +154,10 @@ Flickable{
|
||||||
//console.log("new pos: " +newPosition.x + " / " +newPosition.y)
|
//console.log("new pos: " +newPosition.x + " / " +newPosition.y)
|
||||||
//console.log("header pos: " +headerItem.x + " / " +headerItem.y)
|
//console.log("header pos: " +headerItem.x + " / " +headerItem.y)
|
||||||
//console.log("Moving to " + (headerItem.y+item.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{
|
Behavior on contentY{
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ ListView {
|
||||||
|
|
||||||
property int itemsRightMargin: 39 * DefaultStyle.dp
|
property int itemsRightMargin: 39 * DefaultStyle.dp
|
||||||
property bool expanded: true
|
property bool expanded: true
|
||||||
|
property int headerHeight: headerItem?.height
|
||||||
|
|
||||||
signal resultsReceived()
|
signal resultsReceived()
|
||||||
signal contactDeletionRequested(FriendGui contact)
|
signal contactDeletionRequested(FriendGui contact)
|
||||||
|
|
@ -119,9 +120,6 @@ ListView {
|
||||||
id: headerItem
|
id: headerItem
|
||||||
width: mainItem.width
|
width: mainItem.width
|
||||||
height: headerContents.implicitHeight
|
height: headerContents.implicitHeight
|
||||||
onActiveFocusChanged: {
|
|
||||||
if(activeFocus) mainItem.updatePosition()
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: headerContents
|
id: headerContents
|
||||||
|
|
|
||||||
|
|
@ -769,7 +769,7 @@ AbstractMainPage {
|
||||||
text: qsTr("Supprimer ce contact")
|
text: qsTr("Supprimer ce contact")
|
||||||
visible: !mainItem.selectedContact?.core.readOnly
|
visible: !mainItem.selectedContact?.core.readOnly
|
||||||
onClicked: {
|
onClicked: {
|
||||||
mainItem.deleteContact(contact)
|
mainItem.deleteContact(mainItem.selectedContact)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue