Commit 00a3225b authored by Edric Milaret's avatar Edric Milaret

im: add notification of incoming message when client is not active

- Also use focusWidget instead of activeWindow for all notifications
because we can have an activeWidget without focus
- Fix missing tr on notification text

Change-Id: I0dd22799e1810530aecc6ed050c2be6ed2551b3e
Tuleap: #242
parent 4be7202c
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "localhistorycollection.h" #include "localhistorycollection.h"
#include "media/text.h" #include "media/text.h"
#include "media/recording.h" #include "media/recording.h"
#include "media/textrecording.h" #include "media/recordingmodel.h"
#include "recentmodel.h" #include "recentmodel.h"
#include "contactmethod.h" #include "contactmethod.h"
#include "globalinstances.h" #include "globalinstances.h"
...@@ -231,6 +231,26 @@ CallWidget::setupOutOfCallIM() ...@@ -231,6 +231,26 @@ CallWidget::setupOutOfCallIM()
}; };
connect(displayAuthor, &QAction::triggered, lamdba); connect(displayAuthor, &QAction::triggered, lamdba);
connect(displayDate, &QAction::triggered, lamdba); connect(displayDate, &QAction::triggered, lamdba);
connect(&::Media::RecordingModel::instance(),
SIGNAL(newTextMessage(::Media::TextRecording*, ContactMethod*)),
this,
SLOT(onIncomingMessage(::Media::TextRecording*, ContactMethod*)));
}
void
CallWidget::onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm) {
Q_UNUSED(cm)
if (!QApplication::focusWidget()) {
auto idx = t->instantTextMessagingModel()->
index(t->instantTextMessagingModel()->rowCount()-1, 0);
GlobalSystemTray::instance()
.showMessage("Ring",
QString(tr("Message incoming from %1")).arg(
idx.data((int)Media::TextRecording::Role::AuthorDisplayname).toString()));
QApplication::alert(this, 5000);
}
} }
void void
...@@ -321,8 +341,10 @@ CallWidget::callIncoming(Call* call) ...@@ -321,8 +341,10 @@ CallWidget::callIncoming(Call* call)
{ {
ui->outboundCall->hide(); ui->outboundCall->hide();
if (!QApplication::activeWindow()) { if (!QApplication::focusWidget()) {
GlobalSystemTray::instance().showMessage("Ring", "Call incoming from " + call->formattedName()); GlobalSystemTray::instance()
.showMessage("Ring",
QString(tr("Call incoming from %1")).arg(call->formattedName()));
QApplication::alert(this, 5000); QApplication::alert(this, 5000);
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "video/previewmanager.h" #include "video/previewmanager.h"
#include "accountmodel.h" #include "accountmodel.h"
#include "categorizedhistorymodel.h" #include "categorizedhistorymodel.h"
#include "media/textrecording.h"
class ContactDelegate; class ContactDelegate;
class HistoryDelegate; class HistoryDelegate;
...@@ -86,6 +87,7 @@ private slots: ...@@ -86,6 +87,7 @@ private slots:
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec); void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel); void smartListSelectionChanged(const QItemSelection& newSel, const QItemSelection& oldSel);
void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir); void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
private: private:
Ui::CallWidget* ui; Ui::CallWidget* ui;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment