Browse Source

refactor: Remove using 'Friend::getChatForm'

reviewable/pr4942/r2
Diadlo 8 years ago
parent
commit
254f5cc4b1
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
  1. 16
      src/widget/circlewidget.cpp
  2. 5
      src/widget/genericchatroomwidget.cpp
  3. 1
      src/widget/genericchatroomwidget.h
  4. 1
      src/widget/widget.cpp

16
src/widget/circlewidget.cpp

@ -116,23 +116,19 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event) @@ -116,23 +116,19 @@ void CircleWidget::contextMenuEvent(QContextMenuEvent* event)
ContentDialog* dialog = Widget::getInstance()->createContentDialog();
for (int i = 0; i < friendOnlineLayout()->count(); ++i) {
FriendWidget* friendWidget =
qobject_cast<FriendWidget*>(friendOnlineLayout()->itemAt(i)->widget());
QWidget* const widget = friendOnlineLayout()->itemAt(i)->widget();
FriendWidget* const friendWidget = qobject_cast<FriendWidget*>(widget);
if (friendWidget != nullptr) {
const Friend* const f = friendWidget->getFriend();
ChatForm* const form = f->getChatForm();
dialog->addFriend(f, form);
friendWidget->activate();
}
}
for (int i = 0; i < friendOfflineLayout()->count(); ++i) {
FriendWidget* friendWidget =
qobject_cast<FriendWidget*>(friendOfflineLayout()->itemAt(i)->widget());
QWidget* const widget = friendOfflineLayout()->itemAt(i)->widget();
FriendWidget* const friendWidget = qobject_cast<FriendWidget*>(widget);
if (friendWidget != nullptr) {
const Friend* f = friendWidget->getFriend();
ChatForm* const form = f->getChatForm();
dialog->addFriend(f, form);
friendWidget->activate();
}
}

5
src/widget/genericchatroomwidget.cpp

@ -179,6 +179,11 @@ void GenericChatroomWidget::reloadTheme() @@ -179,6 +179,11 @@ void GenericChatroomWidget::reloadTheme()
setPalette(p);
}
void GenericChatroomWidget::activate()
{
emit chatroomWidgetClicked(this);
}
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent* event)
{
if (event->button() == Qt::LeftButton)

1
src/widget/genericchatroomwidget.h

@ -63,6 +63,7 @@ public: @@ -63,6 +63,7 @@ public:
void reloadTheme();
public slots:
void activate();
void compactChange(bool compact);
signals:

1
src/widget/widget.cpp

@ -977,7 +977,6 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk) @@ -977,7 +977,6 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
FriendWidget* widget = new FriendWidget(newfriend, compact);
History* history = Nexus::getProfile()->getHistory();
ChatForm* friendForm = new ChatForm(newfriend, history);
newfriend->setChatForm(friendForm);
friendWidgets[friendId] = widget;
chatForms[friendId] = friendForm;

Loading…
Cancel
Save