1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: Added emiting signal on window activation in ContentDialog

This commit is contained in:
Diadlo 2016-08-19 15:44:30 +03:00
parent ed11a17dce
commit 74eb06b2aa
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 52 additions and 31 deletions

View File

@ -515,18 +515,14 @@ bool ContentDialog::event(QEvent* event)
Friend* frnd = activeChatroomWidget->getFriend(); Friend* frnd = activeChatroomWidget->getFriend();
Group* group = activeChatroomWidget->getGroup(); Group* group = activeChatroomWidget->getGroup();
GenericChatroomWidget *widget = nullptr;
if (frnd) if (frnd)
widget = frnd->getFriendWidget(); {
else emit friendDialogShown(frnd);
widget = group->getGroupWidget(); }
else if (group)
widget->resetEventFlags(); {
widget->updateStatusLight(); emit groupDialogShown(group);
}
Widget::getInstance()->updateScroll(widget);
Widget::getInstance()->resetIcon();
} }
currentDialog = this; currentDialog = this;

View File

@ -37,6 +37,8 @@ class FriendWidget;
class GroupWidget; class GroupWidget;
class FriendListLayout; class FriendListLayout;
class SettingsWidget; class SettingsWidget;
class Friend;
class Group;
class ContentDialog : public ActivateDialog class ContentDialog : public ActivateDialog
{ {
@ -69,8 +71,10 @@ public:
static ContentDialog* getFriendDialog(int friendId); static ContentDialog* getFriendDialog(int friendId);
static ContentDialog* getGroupDialog(int groupId); static ContentDialog* getGroupDialog(int groupId);
#ifdef Q_OS_MAC
signals: signals:
void friendDialogShown(Friend* f);
void groupDialogShown(Group* g);
#ifdef Q_OS_MAC
void activated(); void activated();
#endif #endif

View File

@ -1450,13 +1450,32 @@ void Widget::clearContactsList()
removeGroup(g, true); removeGroup(g, true);
} }
void Widget::updateScroll(GenericChatroomWidget *widget) { void Widget::onDialogShown(GenericChatroomWidget* widget)
{
widget->resetEventFlags();
widget->updateStatusLight();
ui->friendList->updateTracking(widget); ui->friendList->updateTracking(widget);
resetIcon();
}
void Widget::onFriendDialogShown(Friend* f)
{
int friendId = f->getFriendID();
onDialogShown(friendWidgets[friendId]);
}
void Widget::onGroupDialogShown(Group* g)
{
onDialogShown(g->getGroupWidget());
} }
ContentDialog* Widget::createContentDialog() const ContentDialog* Widget::createContentDialog() const
{ {
ContentDialog* contentDialog = new ContentDialog(settingsWidget); ContentDialog* contentDialog = new ContentDialog(settingsWidget);
connect(contentDialog, &ContentDialog::friendDialogShown, this, &Widget::onFriendDialogShown);
connect(contentDialog, &ContentDialog::groupDialogShown, this, &Widget::onGroupDialogShown);
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
connect(contentDialog, &ContentDialog::destroyed, &Nexus::getInstance(), &Nexus::updateWindowsClosed); connect(contentDialog, &ContentDialog::destroyed, &Nexus::getInstance(), &Nexus::updateWindowsClosed);
connect(contentDialog, &ContentDialog::windowStateChanged, &Nexus::getInstance(), &Nexus::onWindowStateChanged); connect(contentDialog, &ContentDialog::windowStateChanged, &Nexus::getInstance(), &Nexus::onWindowStateChanged);
@ -1466,7 +1485,7 @@ ContentDialog* Widget::createContentDialog() const
return contentDialog; return contentDialog;
} }
ContentLayout* Widget::createContentDialog(DialogType type) ContentLayout* Widget::createContentDialog(DialogType type) const
{ {
class Dialog : public ActivateDialog class Dialog : public ActivateDialog
{ {

View File

@ -78,7 +78,6 @@ public:
bool getIsWindowMinimized(); bool getIsWindowMinimized();
void updateIcons(); void updateIcons();
void clearContactsList(); void clearContactsList();
void updateScroll(GenericChatroomWidget *widget);
enum DialogType enum DialogType
{ {
@ -91,7 +90,7 @@ public:
static QString fromDialogType(DialogType type); static QString fromDialogType(DialogType type);
ContentDialog* createContentDialog() const; ContentDialog* createContentDialog() const;
ContentLayout* createContentDialog(DialogType type); ContentLayout* createContentDialog(DialogType type) const;
static void confirmExecutableOpen(const QFileInfo &file); static void confirmExecutableOpen(const QFileInfo &file);
@ -148,6 +147,8 @@ public slots:
void onFriendTypingChanged(int friendId, bool isTyping); void onFriendTypingChanged(int friendId, bool isTyping);
void nextContact(); void nextContact();
void previousContact(); void previousContact();
void onFriendDialogShown(Friend* f);
void onGroupDialogShown(Group* g);
signals: signals:
void friendRequestAccepted(const QString& userId); void friendRequestAccepted(const QString& userId);
@ -193,6 +194,7 @@ private slots:
void friendRequestsUpdate(); void friendRequestsUpdate();
void groupInvitesUpdate(); void groupInvitesUpdate();
void groupInvitesClear(); void groupInvitesClear();
void onDialogShown(GenericChatroomWidget* widget);
private: private:
int icon_size; int icon_size;