From 76971f5238cd7843836142006f497222d1f982aa Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Sun, 31 Aug 2014 18:29:55 +0200 Subject: [PATCH] Make notifications consistent Notify of AV and FT requests if we're selected but not active or minimised, and add sound (consistent with how message notifications work) --- widget/form/chatform.cpp | 11 ++++++----- widget/widget.cpp | 5 +++++ widget/widget.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 5757e7444..1e3b4cd16 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -377,12 +377,13 @@ void ChatForm::onFileRecvRequest(ToxFile file) connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled); connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); - if (!f->widget->isActive()) + Widget* w = Widget::getInstance(); + if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow()) { - f->hasNewEvents = 1; - // FIXME: add sound alert, as for incoming message + w->newMessageAlert(); + f->hasNewEvents=true; + f->widget->updateStatusLight(); } - f->widget->updateStatusLight(); } void ChatForm::onAvInvite(int FriendId, int CallId, bool video) @@ -411,7 +412,7 @@ void ChatForm::onAvInvite(int FriendId, int CallId, bool video) } Widget* w = Widget::getInstance(); - if (!w->isFriendWidgetCurActiveWidget(f)) + if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow()) { w->newMessageAlert(); f->hasNewEvents=true; diff --git a/widget/widget.cpp b/widget/widget.cpp index 211a36bce..4c2f95c99 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -1146,3 +1146,8 @@ bool Widget::eventFilter(QObject *, QEvent *event) } return false; } + +bool Widget::getIsWindowMinimized() +{ + return static_cast(isWindowMinimized); +} diff --git a/widget/widget.h b/widget/widget.h index e8f5599ea..bbf66c512 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -58,6 +58,7 @@ public: void showTestCamview(); void newMessageAlert(); bool isFriendWidgetCurActiveWidget(Friend* f); + bool getIsWindowMinimized(); ~Widget(); virtual void closeEvent(QCloseEvent *event);