mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix right click friend in circle
This commit is contained in:
parent
2c7f3de346
commit
0d4ca979bc
|
@ -1301,6 +1301,15 @@ void Settings::setFriendCircleIndex(const ToxId &id, int index)
|
|||
auto it = friendLst.find(key);
|
||||
if (it != friendLst.end())
|
||||
it->circleIndex = index;
|
||||
else
|
||||
{
|
||||
friendProp fp;
|
||||
fp.addr = key;
|
||||
fp.alias = "";
|
||||
fp.autoAcceptDir = "";
|
||||
fp.circleIndex = index;
|
||||
friendLst[key] = fp;
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::removeFriendSettings(const ToxId &id)
|
||||
|
|
|
@ -119,8 +119,6 @@ CircleWidget::CircleWidget(FriendListWidget *parent, int id_)
|
|||
renameCircle();
|
||||
|
||||
listWidget->setVisible(Settings::getInstance().getCircleExpanded(id));
|
||||
//expand();
|
||||
//Settings::getInstance().setCircleExpanded(id, isExpanded);
|
||||
}
|
||||
|
||||
void CircleWidget::addFriendWidget(FriendWidget *w, Status s)
|
||||
|
@ -128,6 +126,7 @@ void CircleWidget::addFriendWidget(FriendWidget *w, Status s)
|
|||
listLayout->addFriendWidget(w, s);
|
||||
updateStatus();
|
||||
Settings::getInstance().setFriendCircleIndex(FriendList::findFriend(w->friendId)->getToxId(), id);
|
||||
qDebug() << Settings::getInstance().getFriendCircleIndex(FriendList::findFriend(w->friendId)->getToxId()) << " WITH " << id;
|
||||
}
|
||||
|
||||
void CircleWidget::expand()
|
||||
|
@ -401,7 +400,7 @@ void CircleWidget::dropEvent(QDropEvent *event)
|
|||
assert(widget != nullptr);
|
||||
|
||||
// Update old circle after moved.
|
||||
CircleWidget *circleWidget = dynamic_cast<CircleWidget*>(widget->parent());
|
||||
CircleWidget *circleWidget = getFromID(Settings::getInstance().getFriendCircleIndex(f->getToxId()));
|
||||
|
||||
addFriendWidget(widget, f->getStatus());
|
||||
|
||||
|
@ -433,7 +432,6 @@ void CircleWidget::updateID(int index)
|
|||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(listLayout->getLayoutOnline()->itemAt(i));
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
qDebug() << "My yolo slow";
|
||||
Settings::getInstance().setFriendCircleIndex(FriendList::findFriend(friendWidget->friendId)->getToxId(), id);
|
||||
}
|
||||
}
|
||||
|
@ -442,7 +440,6 @@ void CircleWidget::updateID(int index)
|
|||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(listLayout->getLayoutOffline()->itemAt(i));
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
qDebug() << "My yolo slow";
|
||||
Settings::getInstance().setFriendCircleIndex(FriendList::findFriend(friendWidget->friendId)->getToxId(), id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,27 +156,29 @@ void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget
|
|||
if (activeChatroomWidget == nullptr)
|
||||
return;
|
||||
|
||||
CircleWidget* circleWidget = dynamic_cast<CircleWidget*>(activeChatroomWidget->parentWidget());
|
||||
|
||||
int index = -1;
|
||||
QLayout* currentLayout = nullptr;
|
||||
|
||||
CircleWidget* circleWidget = nullptr;
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(activeChatroomWidget);
|
||||
if (circleWidget != nullptr)
|
||||
{
|
||||
if (friendWidget == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (circleWidget->cycleContacts(friendWidget, forward))
|
||||
return;
|
||||
|
||||
index = circleLayout.indexOfSortedWidget(circleWidget);
|
||||
currentLayout = circleLayout.getLayout();
|
||||
}
|
||||
else
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
if (friendWidget != nullptr)
|
||||
circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleIndex(FriendList::findFriend(friendWidget->friendId)->getToxId()));
|
||||
if (circleWidget != nullptr)
|
||||
{
|
||||
if (friendWidget == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (circleWidget->cycleContacts(friendWidget, forward))
|
||||
return;
|
||||
|
||||
index = circleLayout.indexOfSortedWidget(circleWidget);
|
||||
currentLayout = circleLayout.getLayout();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLayout = listLayout->getLayoutOnline();
|
||||
index = listLayout->indexOfFriendWidget(friendWidget, true);
|
||||
|
@ -186,19 +188,19 @@ void FriendListWidget::cycleContacts(GenericChatroomWidget* activeChatroomWidget
|
|||
index = listLayout->indexOfFriendWidget(friendWidget, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupWidget* groupWidget = dynamic_cast<GroupWidget*>(activeChatroomWidget);
|
||||
if (groupWidget != nullptr)
|
||||
{
|
||||
currentLayout = groupLayout.getLayout();
|
||||
index = groupLayout.indexOfSortedWidget(groupWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
GroupWidget* groupWidget = dynamic_cast<GroupWidget*>(activeChatroomWidget);
|
||||
if (groupWidget != nullptr)
|
||||
{
|
||||
currentLayout = groupLayout.getLayout();
|
||||
index = groupLayout.indexOfSortedWidget(groupWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
};
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
index += forward ? 1 : -1;
|
||||
|
@ -277,7 +279,7 @@ void FriendListWidget::dropEvent(QDropEvent *event)
|
|||
assert(widget != nullptr);
|
||||
|
||||
// Update old circle after moved.
|
||||
CircleWidget *circleWidget = dynamic_cast<CircleWidget*>(widget->parent());
|
||||
CircleWidget *circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleIndex(f->getToxId()));
|
||||
|
||||
listLayout->addFriendWidget(widget, f->getStatus());
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ void FriendWidget::updateStatusLight()
|
|||
|
||||
if (f->getEventFlag())
|
||||
{
|
||||
CircleWidget* circleWidget = dynamic_cast<CircleWidget*>(parentWidget());
|
||||
CircleWidget* circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleIndex(FriendList::findFriend(friendId)->getToxId()));
|
||||
if (circleWidget != nullptr)
|
||||
circleWidget->expand();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user