mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Multi-window: Fix circle modified from dialog window, fix groupchat leave warnings, flip dialog window title
This commit is contained in:
parent
aa9a10fa8b
commit
4e5c4cb678
|
@ -92,54 +92,57 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
|
|||
|
||||
QAction* selectedItem = menu.exec(mapToGlobal(event->pos()));
|
||||
|
||||
if (selectedItem == renameAction)
|
||||
if (selectedItem)
|
||||
{
|
||||
editName();
|
||||
}
|
||||
else if (selectedItem == removeAction)
|
||||
{
|
||||
FriendListWidget* friendList = static_cast<FriendListWidget*>(parentWidget());
|
||||
moveFriendWidgets(friendList);
|
||||
|
||||
friendList->removeCircleWidget(this);
|
||||
|
||||
int replacedCircle = Settings::getInstance().removeCircle(id);
|
||||
|
||||
auto circleReplace = circleList.find(replacedCircle);
|
||||
if (circleReplace != circleList.end())
|
||||
circleReplace.value()->updateID(id);
|
||||
else
|
||||
assert(true); // This should never happen.
|
||||
|
||||
circleList.remove(replacedCircle);
|
||||
}
|
||||
else if (selectedItem == openAction)
|
||||
{
|
||||
ContentDialog* dialog = Widget::getInstance()->createContentDialog();
|
||||
|
||||
for (int i = 0; i < friendOnlineLayout()->count(); ++i)
|
||||
if (selectedItem == renameAction)
|
||||
{
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(friendOnlineLayout()->itemAt(i)->widget());
|
||||
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
Friend* f = friendWidget->getFriend();
|
||||
dialog->addFriend(friendWidget->friendId, f->getDisplayedName());
|
||||
}
|
||||
editName();
|
||||
}
|
||||
for (int i = 0; i < friendOfflineLayout()->count(); ++i)
|
||||
else if (selectedItem == removeAction)
|
||||
{
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(friendOfflineLayout()->itemAt(i)->widget());
|
||||
FriendListWidget* friendList = static_cast<FriendListWidget*>(parentWidget());
|
||||
moveFriendWidgets(friendList);
|
||||
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
Friend* f = friendWidget->getFriend();
|
||||
dialog->addFriend(friendWidget->friendId, f->getDisplayedName());
|
||||
}
|
||||
friendList->removeCircleWidget(this);
|
||||
|
||||
int replacedCircle = Settings::getInstance().removeCircle(id);
|
||||
|
||||
auto circleReplace = circleList.find(replacedCircle);
|
||||
if (circleReplace != circleList.end())
|
||||
circleReplace.value()->updateID(id);
|
||||
else
|
||||
assert(true); // This should never happen.
|
||||
|
||||
circleList.remove(replacedCircle);
|
||||
}
|
||||
else if (selectedItem == openAction)
|
||||
{
|
||||
ContentDialog* dialog = Widget::getInstance()->createContentDialog();
|
||||
|
||||
dialog->show();
|
||||
dialog->ensureSplitterVisible();
|
||||
for (int i = 0; i < friendOnlineLayout()->count(); ++i)
|
||||
{
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(friendOnlineLayout()->itemAt(i)->widget());
|
||||
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
Friend* f = friendWidget->getFriend();
|
||||
dialog->addFriend(friendWidget->friendId, f->getDisplayedName());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < friendOfflineLayout()->count(); ++i)
|
||||
{
|
||||
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(friendOfflineLayout()->itemAt(i)->widget());
|
||||
|
||||
if (friendWidget != nullptr)
|
||||
{
|
||||
Friend* f = friendWidget->getFriend();
|
||||
dialog->addFriend(friendWidget->friendId, f->getDisplayedName());
|
||||
}
|
||||
}
|
||||
|
||||
dialog->show();
|
||||
dialog->ensureSplitterVisible();
|
||||
}
|
||||
}
|
||||
|
||||
setContainerAttribute(Qt::WA_UnderMouse, false);
|
||||
|
|
|
@ -241,8 +241,12 @@ void ContentDialog::removeFriend(int friendId)
|
|||
void ContentDialog::removeGroup(int groupId)
|
||||
{
|
||||
Group* group = GroupList::findGroup(groupId);
|
||||
disconnect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget);
|
||||
disconnect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget);
|
||||
|
||||
if (group)
|
||||
{
|
||||
disconnect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget);
|
||||
disconnect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget);
|
||||
}
|
||||
|
||||
auto iter = groupList.find(groupId);
|
||||
|
||||
|
@ -424,7 +428,7 @@ ContentDialog* ContentDialog::getGroupDialog(int groupId)
|
|||
void ContentDialog::updateTitleUsername(const QString& username)
|
||||
{
|
||||
if (displayWidget != nullptr)
|
||||
setWindowTitle(username + QStringLiteral(" - ") + displayWidget->getTitle());
|
||||
setWindowTitle(displayWidget->getTitle() + QStringLiteral(" - ") + username);
|
||||
else
|
||||
setWindowTitle(username);
|
||||
}
|
||||
|
|
|
@ -389,8 +389,11 @@ void FriendListWidget::addCircleWidget(FriendWidget* friendWidget)
|
|||
}
|
||||
|
||||
Widget::getInstance()->searchCircle(circleWidget);
|
||||
circleWidget->editName();
|
||||
|
||||
if (window()->isActiveWindow())
|
||||
circleWidget->editName();
|
||||
}
|
||||
reDraw();
|
||||
}
|
||||
|
||||
void FriendListWidget::removeCircleWidget(CircleWidget* widget)
|
||||
|
|
|
@ -105,7 +105,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
FriendListWidget *friendList;
|
||||
|
||||
if (circleWidget == nullptr)
|
||||
friendList = dynamic_cast<FriendListWidget*>(parentWidget());
|
||||
friendList = dynamic_cast<FriendListWidget*>(FriendList::findFriend(friendId)->getFriendWidget()->parentWidget());
|
||||
else
|
||||
friendList = dynamic_cast<FriendListWidget*>(circleWidget->parentWidget());
|
||||
|
||||
|
@ -214,7 +214,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
circleWidget->updateStatus();
|
||||
|
||||
if (friendList != nullptr)
|
||||
friendList->addCircleWidget(this);
|
||||
friendList->addCircleWidget(FriendList::findFriend(friendId)->getFriendWidget());
|
||||
else
|
||||
Settings::getInstance().setFriendCircleID(id, Settings::getInstance().addCircle());
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
else if (removeCircleAction != nullptr && selectedItem == removeCircleAction)
|
||||
{
|
||||
if (friendList != nullptr)
|
||||
friendList->moveWidget(this, FriendList::findFriend(friendId)->getStatus(), true);
|
||||
friendList->moveWidget(FriendList::findFriend(friendId)->getFriendWidget(), FriendList::findFriend(friendId)->getStatus(), true);
|
||||
else
|
||||
Settings::getInstance().setFriendCircleID(id, -1);
|
||||
|
||||
|
@ -242,7 +242,7 @@ void FriendWidget::contextMenuEvent(QContextMenuEvent * event)
|
|||
|
||||
if (circle != nullptr)
|
||||
{
|
||||
circle->addFriendWidget(this, FriendList::findFriend(friendId)->getStatus());
|
||||
circle->addFriendWidget(FriendList::findFriend(friendId)->getFriendWidget(), FriendList::findFriend(friendId)->getStatus());
|
||||
circle->setExpanded(true);
|
||||
Widget::getInstance()->searchCircle(circle);
|
||||
Settings::getInstance().savePersonal();
|
||||
|
|
Loading…
Reference in New Issue
Block a user