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);
|
nameLabel->setText(name);
|
||||||
|
|
||||||
onUserListChanged();
|
onUserListChanged();
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
connect(nameLabel, &CroppingLabel::editFinished, [=](const QString& newName) {
|
connect(nameLabel, &CroppingLabel::editFinished, this, &GroupWidget::setTitle);
|
||||||
if (!newName.isEmpty()) {
|
|
||||||
Group* g = GroupList::findGroup(groupId);
|
|
||||||
emit renameRequested(this, newName);
|
|
||||||
emit g->getChatForm()->groupTitleChanged(groupId, newName.left(128));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
|
Translator::registerHandler(std::bind(&GroupWidget::retranslateUi, this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +61,16 @@ GroupWidget::~GroupWidget()
|
||||||
Translator::unregister(this);
|
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)
|
void GroupWidget::contextMenuEvent(QContextMenuEvent* event)
|
||||||
{
|
{
|
||||||
if (!active)
|
if (!active)
|
||||||
|
|
|
@ -52,8 +52,9 @@ protected:
|
||||||
void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
void dragLeaveEvent(QDragLeaveEvent* ev) override;
|
||||||
void dropEvent(QDropEvent* ev) override;
|
void dropEvent(QDropEvent* ev) override;
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
void setTitle(const QString& newName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int groupId;
|
int groupId;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user