mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(groupwidget): Move updatTitle in GroupWidget
Also, remove unused now slot ContentDialog::updateGroupWidget
This commit is contained in:
parent
47cf113868
commit
1e90106a08
|
@ -191,8 +191,6 @@ GroupWidget* ContentDialog::addGroup(int groupId, const QString& name)
|
||||||
groupLayout.addSortedWidget(groupWidget);
|
groupLayout.addSortedWidget(groupWidget);
|
||||||
|
|
||||||
Group* group = groupWidget->getGroup();
|
Group* group = groupWidget->getGroup();
|
||||||
connect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget);
|
|
||||||
connect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget);
|
|
||||||
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
|
connect(groupWidget, &GroupWidget::chatroomWidgetClicked, this, &ContentDialog::activate);
|
||||||
connect(groupWidget, &FriendWidget::newWindowOpened, this, &ContentDialog::openNewDialog);
|
connect(groupWidget, &FriendWidget::newWindowOpened, this, &ContentDialog::openNewDialog);
|
||||||
|
|
||||||
|
@ -244,11 +242,6 @@ void ContentDialog::removeGroup(int groupId)
|
||||||
{
|
{
|
||||||
Group* group = GroupList::findGroup(groupId);
|
Group* group = GroupList::findGroup(groupId);
|
||||||
|
|
||||||
if (group) {
|
|
||||||
disconnect(group, &Group::titleChanged, this, &ContentDialog::updateGroupWidget);
|
|
||||||
disconnect(group, &Group::userListChanged, this, &ContentDialog::updateGroupWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto iter = groupList.find(groupId);
|
auto iter = groupList.find(groupId);
|
||||||
if (iter == groupList.end()) {
|
if (iter == groupList.end()) {
|
||||||
return;
|
return;
|
||||||
|
@ -752,20 +745,6 @@ void ContentDialog::updateFriendWidget(uint32_t friendId, QString alias)
|
||||||
friendLayout->addFriendWidget(friendWidget, status);
|
friendLayout->addFriendWidget(friendWidget, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Update group widget name and 'status'.
|
|
||||||
* @param groupId Id of group to update.
|
|
||||||
*/
|
|
||||||
void ContentDialog::updateGroupWidget(uint32_t groupId)
|
|
||||||
{
|
|
||||||
Group* g = GroupList::findGroup(groupId);
|
|
||||||
QString name = g->getName();
|
|
||||||
|
|
||||||
ContactInfo info = groupList.find(groupId).value();
|
|
||||||
GroupWidget* widget = static_cast<GroupWidget*>(std::get<1>(info));
|
|
||||||
widget->setName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Handler of `groupchatPositionChanged` action.
|
* @brief Handler of `groupchatPositionChanged` action.
|
||||||
* Move group layout on the top or on the buttom.
|
* Move group layout on the top or on the buttom.
|
||||||
|
|
|
@ -103,7 +103,6 @@ private slots:
|
||||||
void activate(GenericChatroomWidget* widget);
|
void activate(GenericChatroomWidget* widget);
|
||||||
void openNewDialog(GenericChatroomWidget* widget);
|
void openNewDialog(GenericChatroomWidget* widget);
|
||||||
void updateFriendWidget(uint32_t friendId, QString alias);
|
void updateFriendWidget(uint32_t friendId, QString alias);
|
||||||
void updateGroupWidget(uint32_t groupId);
|
|
||||||
void onGroupchatPositionChanged(bool top);
|
void onGroupchatPositionChanged(bool top);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -53,6 +53,7 @@ GroupWidget::GroupWidget(int groupId, const QString& name, bool compact)
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
Group* g = GroupList::findGroup(groupId);
|
Group* g = GroupList::findGroup(groupId);
|
||||||
|
connect(g, &Group::titleChanged, this, &GroupWidget::updateTitle);
|
||||||
connect(g, &Group::userListChanged, this, &GroupWidget::updateUserCount);
|
connect(g, &Group::userListChanged, this, &GroupWidget::updateUserCount);
|
||||||
connect(nameLabel, &CroppingLabel::editFinished, this, &GroupWidget::setTitle);
|
connect(nameLabel, &CroppingLabel::editFinished, this, &GroupWidget::setTitle);
|
||||||
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
|
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
|
||||||
|
@ -69,6 +70,12 @@ void GroupWidget::setTitle(const QString& newName)
|
||||||
g->setName(newName);
|
g->setName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GroupWidget::updateTitle(uint32_t groupId, const QString& newName)
|
||||||
|
{
|
||||||
|
Q_UNUSED(groupId);
|
||||||
|
nameLabel->setText(newName);
|
||||||
|
}
|
||||||
|
|
||||||
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||||
{
|
{
|
||||||
if (!active)
|
if (!active)
|
||||||
|
|
|
@ -53,6 +53,7 @@ protected:
|
||||||
private slots:
|
private slots:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
void setTitle(const QString& newName);
|
void setTitle(const QString& newName);
|
||||||
|
void updateTitle(uint32_t groupId, const QString& newName);
|
||||||
void updateUserCount();
|
void updateUserCount();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user