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

@ -505,37 +505,33 @@ bool ContentDialog::event(QEvent* event)
{ {
switch (event->type()) switch (event->type())
{ {
case QEvent::WindowActivate: case QEvent::WindowActivate:
if (activeChatroomWidget != nullptr) if (activeChatroomWidget != nullptr)
{
activeChatroomWidget->resetEventFlags();
activeChatroomWidget->updateStatusLight();
updateTitle(activeChatroomWidget);
Friend* frnd = activeChatroomWidget->getFriend();
Group* group = activeChatroomWidget->getGroup();
if (frnd)
{ {
activeChatroomWidget->resetEventFlags(); emit friendDialogShown(frnd);
activeChatroomWidget->updateStatusLight();
updateTitle(activeChatroomWidget);
Friend* frnd = activeChatroomWidget->getFriend();
Group* group = activeChatroomWidget->getGroup();
GenericChatroomWidget *widget = nullptr;
if (frnd)
widget = frnd->getFriendWidget();
else
widget = group->getGroupWidget();
widget->resetEventFlags();
widget->updateStatusLight();
Widget::getInstance()->updateScroll(widget);
Widget::getInstance()->resetIcon();
} }
else if (group)
{
emit groupDialogShown(group);
}
}
currentDialog = this; currentDialog = this;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
emit activated(); emit activated();
#endif #endif
default: default:
break; break;
} }
return ActivateDialog::event(event); return ActivateDialog::event(event);

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);
@ -174,7 +175,7 @@ private slots:
void onGroupClicked(); void onGroupClicked();
void onTransferClicked(); void onTransferClicked();
void showProfile(); void showProfile();
void onChatroomWidgetClicked(GenericChatroomWidget *, bool group); void onChatroomWidgetClicked(GenericChatroomWidget*, bool group);
void onStatusMessageChanged(const QString& newStatusMessage); void onStatusMessageChanged(const QString& newStatusMessage);
void removeFriend(int friendId); void removeFriend(int friendId);
void copyFriendIdToClipboard(int friendId); void copyFriendIdToClipboard(int friendId);
@ -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;