mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: cleanup Widget
This commit is contained in:
parent
5fdadadfb5
commit
3612e94f5f
@ -290,19 +290,18 @@ void Widget::init()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CoreFile* coreFile = core->getCoreFile();
|
CoreFile* coreFile = core->getCoreFile();
|
||||||
Profile* profile = Nexus::getProfile();
|
profileInfo = new ProfileInfo(core, &profile);
|
||||||
profileInfo = new ProfileInfo(core, profile);
|
|
||||||
profileForm = new ProfileForm(profileInfo);
|
profileForm = new ProfileForm(profileInfo);
|
||||||
|
|
||||||
#if DESKTOP_NOTIFICATIONS
|
#if DESKTOP_NOTIFICATIONS
|
||||||
notificationGenerator.reset(new NotificationGenerator(settings, profile));
|
notificationGenerator.reset(new NotificationGenerator(settings, &profile));
|
||||||
connect(¬ifier, &DesktopNotify::notificationClosed, notificationGenerator.get(), &NotificationGenerator::onNotificationActivated);
|
connect(¬ifier, &DesktopNotify::notificationClosed, notificationGenerator.get(), &NotificationGenerator::onNotificationActivated);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// connect logout tray menu action
|
// connect logout tray menu action
|
||||||
connect(actionLogout, &QAction::triggered, profileForm, &ProfileForm::onLogoutClicked);
|
connect(actionLogout, &QAction::triggered, profileForm, &ProfileForm::onLogoutClicked);
|
||||||
|
|
||||||
connect(profile, &Profile::selfAvatarChanged, profileForm, &ProfileForm::onSelfAvatarLoaded);
|
connect(&profile, &Profile::selfAvatarChanged, profileForm, &ProfileForm::onSelfAvatarLoaded);
|
||||||
|
|
||||||
connect(coreFile, &CoreFile::fileReceiveRequested, this, &Widget::onFileReceiveRequested);
|
connect(coreFile, &CoreFile::fileReceiveRequested, this, &Widget::onFileReceiveRequested);
|
||||||
connect(coreFile, &CoreFile::fileDownloadFinished, filesForm, &FilesForm::onFileDownloadComplete);
|
connect(coreFile, &CoreFile::fileDownloadFinished, filesForm, &FilesForm::onFileDownloadComplete);
|
||||||
@ -1087,7 +1086,6 @@ void Widget::dispatchFile(ToxFile file)
|
|||||||
auto sender =
|
auto sender =
|
||||||
(file.direction == ToxFile::SENDING) ? core->getSelfPublicKey() : pk;
|
(file.direction == ToxFile::SENDING) ? core->getSelfPublicKey() : pk;
|
||||||
|
|
||||||
const Settings& settings = Settings::getInstance();
|
|
||||||
QString autoAcceptDir = settings.getAutoAcceptDir(f->getPublicKey());
|
QString autoAcceptDir = settings.getAutoAcceptDir(f->getPublicKey());
|
||||||
|
|
||||||
if (autoAcceptDir.isEmpty() && settings.getAutoSaveEnabled()) {
|
if (autoAcceptDir.isEmpty() && settings.getAutoSaveEnabled()) {
|
||||||
@ -1142,7 +1140,7 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
|
|||||||
const auto compact = settings.getCompactLayout();
|
const auto compact = settings.getCompactLayout();
|
||||||
auto widget = new FriendWidget(chatroom, compact);
|
auto widget = new FriendWidget(chatroom, compact);
|
||||||
connectFriendWidget(*widget);
|
connectFriendWidget(*widget);
|
||||||
auto history = Nexus::getProfile()->getHistory();
|
auto history = profile.getHistory();
|
||||||
|
|
||||||
auto messageProcessor = MessageProcessor(sharedMessageProcessorParams);
|
auto messageProcessor = MessageProcessor(sharedMessageProcessorParams);
|
||||||
auto friendMessageDispatcher =
|
auto friendMessageDispatcher =
|
||||||
@ -1151,7 +1149,7 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
|
|||||||
// Note: We do not have to connect the message dispatcher signals since
|
// Note: We do not have to connect the message dispatcher signals since
|
||||||
// ChatHistory hooks them up in a very specific order
|
// ChatHistory hooks them up in a very specific order
|
||||||
auto chatHistory =
|
auto chatHistory =
|
||||||
std::make_shared<ChatHistory>(*newfriend, history, *core, Settings::getInstance(),
|
std::make_shared<ChatHistory>(*newfriend, history, *core, settings,
|
||||||
*friendMessageDispatcher);
|
*friendMessageDispatcher);
|
||||||
auto friendForm = new ChatForm(profile, newfriend, *chatHistory, *friendMessageDispatcher);
|
auto friendForm = new ChatForm(profile, newfriend, *chatHistory, *friendMessageDispatcher);
|
||||||
connect(friendForm, &ChatForm::updateFriendActivity, this, &Widget::updateFriendActivity);
|
connect(friendForm, &ChatForm::updateFriendActivity, this, &Widget::updateFriendActivity);
|
||||||
@ -1198,12 +1196,11 @@ void Widget::addFriend(uint32_t friendId, const ToxPk& friendPk)
|
|||||||
connect(widget, &FriendWidget::contextMenuCalled, widget, &FriendWidget::onContextMenuCalled);
|
connect(widget, &FriendWidget::contextMenuCalled, widget, &FriendWidget::onContextMenuCalled);
|
||||||
connect(widget, SIGNAL(removeFriend(const ToxPk&)), this, SLOT(removeFriend(const ToxPk&)));
|
connect(widget, SIGNAL(removeFriend(const ToxPk&)), this, SLOT(removeFriend(const ToxPk&)));
|
||||||
|
|
||||||
Profile* profile = Nexus::getProfile();
|
connect(&profile, &Profile::friendAvatarSet, widget, &FriendWidget::onAvatarSet);
|
||||||
connect(profile, &Profile::friendAvatarSet, widget, &FriendWidget::onAvatarSet);
|
connect(&profile, &Profile::friendAvatarRemoved, widget, &FriendWidget::onAvatarRemoved);
|
||||||
connect(profile, &Profile::friendAvatarRemoved, widget, &FriendWidget::onAvatarRemoved);
|
|
||||||
|
|
||||||
// Try to get the avatar from the cache
|
// Try to get the avatar from the cache
|
||||||
QPixmap avatar = Nexus::getProfile()->loadAvatar(friendPk);
|
QPixmap avatar = profile.loadAvatar(friendPk);
|
||||||
if (!avatar.isNull()) {
|
if (!avatar.isNull()) {
|
||||||
friendForm->onAvatarChanged(friendPk, avatar);
|
friendForm->onAvatarChanged(friendPk, avatar);
|
||||||
widget->onAvatarSet(friendPk, avatar);
|
widget->onAvatarSet(friendPk, avatar);
|
||||||
@ -1449,11 +1446,10 @@ void Widget::addFriendDialog(const Friend* frnd, ContentDialog* dialog)
|
|||||||
// FIXME: emit should be removed
|
// FIXME: emit should be removed
|
||||||
emit widget->chatroomWidgetClicked(widget);
|
emit widget->chatroomWidgetClicked(widget);
|
||||||
|
|
||||||
Profile* profile = Nexus::getProfile();
|
connect(&profile, &Profile::friendAvatarSet, friendWidget, &FriendWidget::onAvatarSet);
|
||||||
connect(profile, &Profile::friendAvatarSet, friendWidget, &FriendWidget::onAvatarSet);
|
connect(&profile, &Profile::friendAvatarRemoved, friendWidget, &FriendWidget::onAvatarRemoved);
|
||||||
connect(profile, &Profile::friendAvatarRemoved, friendWidget, &FriendWidget::onAvatarRemoved);
|
|
||||||
|
|
||||||
QPixmap avatar = Nexus::getProfile()->loadAvatar(frnd->getPublicKey());
|
QPixmap avatar = profile.loadAvatar(frnd->getPublicKey());
|
||||||
if (!avatar.isNull()) {
|
if (!avatar.isNull()) {
|
||||||
friendWidget->onAvatarSet(frnd->getPublicKey(), avatar);
|
friendWidget->onAvatarSet(frnd->getPublicKey(), avatar);
|
||||||
}
|
}
|
||||||
@ -1697,7 +1693,7 @@ void Widget::removeFriend(Friend* f, bool fake)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ask.removeHistory()) {
|
if (ask.removeHistory()) {
|
||||||
Nexus::getProfile()->getHistory()->removeFriendHistory(f->getPublicKey());
|
profile.getHistory()->removeFriendHistory(f->getPublicKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2079,7 +2075,7 @@ Group* Widget::createGroup(uint32_t groupnumber, const GroupId& groupId)
|
|||||||
auto messageProcessor = MessageProcessor(sharedMessageProcessorParams);
|
auto messageProcessor = MessageProcessor(sharedMessageProcessorParams);
|
||||||
auto messageDispatcher =
|
auto messageDispatcher =
|
||||||
std::make_shared<GroupMessageDispatcher>(*newgroup, std::move(messageProcessor), *core,
|
std::make_shared<GroupMessageDispatcher>(*newgroup, std::move(messageProcessor), *core,
|
||||||
*core, Settings::getInstance());
|
*core, settings);
|
||||||
auto groupChatLog = std::make_shared<SessionChatLog>(*core);
|
auto groupChatLog = std::make_shared<SessionChatLog>(*core);
|
||||||
|
|
||||||
connect(messageDispatcher.get(), &IMessageDispatcher::messageReceived, groupChatLog.get(),
|
connect(messageDispatcher.get(), &IMessageDispatcher::messageReceived, groupChatLog.get(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user