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())
{
case QEvent::WindowActivate:
if (activeChatroomWidget != nullptr)
case QEvent::WindowActivate:
if (activeChatroomWidget != nullptr)
{
activeChatroomWidget->resetEventFlags();
activeChatroomWidget->updateStatusLight();
updateTitle(activeChatroomWidget);
Friend* frnd = activeChatroomWidget->getFriend();
Group* group = activeChatroomWidget->getGroup();
if (frnd)
{
activeChatroomWidget->resetEventFlags();
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();
emit friendDialogShown(frnd);
}
else if (group)
{
emit groupDialogShown(group);
}
}
currentDialog = this;
currentDialog = this;
#ifdef Q_OS_MAC
emit activated();
emit activated();
#endif
default:
break;
default:
break;
}
return ActivateDialog::event(event);

View File

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

View File

@ -1450,13 +1450,32 @@ void Widget::clearContactsList()
removeGroup(g, true);
}
void Widget::updateScroll(GenericChatroomWidget *widget) {
void Widget::onDialogShown(GenericChatroomWidget* widget)
{
widget->resetEventFlags();
widget->updateStatusLight();
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* contentDialog = new ContentDialog(settingsWidget);
connect(contentDialog, &ContentDialog::friendDialogShown, this, &Widget::onFriendDialogShown);
connect(contentDialog, &ContentDialog::groupDialogShown, this, &Widget::onGroupDialogShown);
#ifdef Q_OS_MAC
connect(contentDialog, &ContentDialog::destroyed, &Nexus::getInstance(), &Nexus::updateWindowsClosed);
connect(contentDialog, &ContentDialog::windowStateChanged, &Nexus::getInstance(), &Nexus::onWindowStateChanged);
@ -1466,7 +1485,7 @@ ContentDialog* Widget::createContentDialog() const
return contentDialog;
}
ContentLayout* Widget::createContentDialog(DialogType type)
ContentLayout* Widget::createContentDialog(DialogType type) const
{
class Dialog : public ActivateDialog
{

View File

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