Browse Source

refactor(widget): remove Widget singleton in ContentDialog

reviewable/pr5733/r2
jenli669 6 years ago
parent
commit
6d0ae67c9d
No known key found for this signature in database
GPG Key ID: 8267F9F7C2BF7E5E
  1. 10
      src/widget/contentdialog.cpp
  2. 9
      src/widget/contentdialog.h
  3. 2
      src/widget/widget.cpp

10
src/widget/contentdialog.cpp

@ -37,10 +37,10 @@ @@ -37,10 +37,10 @@
#include "src/model/status.h"
#include "src/persistence/settings.h"
#include "src/widget/contentlayout.h"
#include "src/widget/friendwidget.h"
#include "src/widget/groupwidget.h"
#include "src/widget/form/chatform.h"
#include "src/widget/friendlistlayout.h"
#include "src/widget/friendwidget.h"
#include "src/widget/groupwidget.h"
#include "src/widget/style.h"
#include "src/widget/tool/adjustingscrollarea.h"
#include "src/widget/translator.h"
@ -141,7 +141,7 @@ ContentDialog::~ContentDialog() @@ -141,7 +141,7 @@ ContentDialog::~ContentDialog()
Translator::unregister(this);
}
void ContentDialog::closeEvent(QCloseEvent *event)
void ContentDialog::closeEvent(QCloseEvent* event)
{
emit willClose();
event->accept();
@ -499,7 +499,7 @@ void ContentDialog::dropEvent(QDropEvent* event) @@ -499,7 +499,7 @@ void ContentDialog::dropEvent(QDropEvent* event)
return;
}
Widget::getInstance()->addFriendDialog(contact, this);
emit addFriendDialog(contact, this);
ensureSplitterVisible();
} else if (group) {
assert(event->mimeData()->hasFormat("groupId"));
@ -509,7 +509,7 @@ void ContentDialog::dropEvent(QDropEvent* event) @@ -509,7 +509,7 @@ void ContentDialog::dropEvent(QDropEvent* event)
return;
}
Widget::getInstance()->addGroupDialog(contact, this);
emit addGroupDialog(contact, this);
ensureSplitterVisible();
}
}

9
src/widget/contentdialog.h

@ -20,12 +20,12 @@ @@ -20,12 +20,12 @@
#ifndef CONTENTDIALOG_H
#define CONTENTDIALOG_H
#include "src/core/groupid.h"
#include "src/core/toxpk.h"
#include "src/model/dialogs/idialogs.h"
#include "src/model/status.h"
#include "src/widget/genericchatitemlayout.h"
#include "src/widget/tool/activatedialog.h"
#include "src/model/status.h"
#include "src/core/groupid.h"
#include "src/core/toxpk.h"
#include <memory>
@ -79,6 +79,8 @@ public: @@ -79,6 +79,8 @@ public:
signals:
void friendDialogShown(const Friend* f);
void groupDialogShown(Group* g);
void addFriendDialog(Friend* frnd, ContentDialog* contentDialog);
void addGroupDialog(Group* group, ContentDialog* contentDialog);
void activated();
void willClose();
@ -116,7 +118,6 @@ private: @@ -116,7 +118,6 @@ private:
void focusCommon(const ContactId& id, QHash<const ContactId&, GenericChatroomWidget*> list);
private:
QList<QLayout*> layouts;
QSplitter* splitter;
FriendListLayout* friendLayout;

2
src/widget/widget.cpp

@ -1820,6 +1820,8 @@ ContentDialog* Widget::createContentDialog() const @@ -1820,6 +1820,8 @@ ContentDialog* Widget::createContentDialog() const
connect(core, &Core::usernameSet, contentDialog, &ContentDialog::setUsername);
connect(&settings, &Settings::groupchatPositionChanged, contentDialog,
&ContentDialog::reorderLayouts);
connect(contentDialog, &ContentDialog::addFriendDialog, this, &Widget::addFriendDialog);
connect(contentDialog, &ContentDialog::addGroupDialog, this, &Widget::addGroupDialog);
#ifdef Q_OS_MAC
Nexus& n = Nexus::getInstance();

Loading…
Cancel
Save