mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(groupwidget): Extract setTitle in method
This commit is contained in:
parent
99ebb73562
commit
14c2a30f4c
|
@ -50,16 +50,9 @@ GroupWidget::GroupWidget(int groupId, const QString& name, bool compact)
|
|||
nameLabel->setText(name);
|
||||
|
||||
onUserListChanged();
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(nameLabel, &CroppingLabel::editFinished, [=](const QString& newName) {
|
||||
if (!newName.isEmpty()) {
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
emit renameRequested(this, newName);
|
||||
emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128));
|
||||
}
|
||||
});
|
||||
connect(nameLabel, &CroppingLabel::editFinished, this, &GroupWidget::setTitle);
|
||||
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
|
||||
}
|
||||
|
||||
|
@ -68,6 +61,16 @@ GroupWidget::~GroupWidget()
|
|||
Translator::unregister(this);
|
||||
}
|
||||
|
||||
void GroupWidget::setTitle(const QString& newName)
|
||||
{
|
||||
if (!newName.isEmpty()) {
|
||||
Group* g = GroupList::findGroup(groupId);
|
||||
g->setName(newName);
|
||||
emit renameRequested(this, newName);
|
||||
emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128));
|
||||
}
|
||||
}
|
||||
|
||||
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
if (!active)
|
||||
|
|
|
@ -52,8 +52,9 @@ protected:
|
|||
void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
||||
void dropEvent(QDropEvent* ev) override;
|
||||
|
||||
private:
|
||||
private slots:
|
||||
void retranslateUi();
|
||||
void setTitle(const QString& newName);
|
||||
|
||||
public:
|
||||
int groupId;
|
||||
|
|
Loading…
Reference in New Issue
Block a user