mirror of
https://github.com/savoirfairelinux/jami-client-qt.git
synced 2026-01-05 12:21:37 +08:00
notifications: implement incoming message notifications
- Note: adds forcing the main window to the top to overcome a Qt/QML bug which prevents this from working when activating from a notification window source. Change-Id: Ib5a93d3937fe5a4de0229f7aeae8469d1ffdfba3
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
/*!
|
||||
* Copyright (C) 2015-2020 by Savoir-faire Linux
|
||||
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>
|
||||
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
|
||||
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com
|
||||
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||
* Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -281,34 +281,38 @@ Utils::getCirclePhoto(const QImage original, int sizePhoto)
|
||||
}
|
||||
|
||||
void
|
||||
Utils::showSystemNotification(QWidget* widget,
|
||||
const QString& message,
|
||||
long delay,
|
||||
const QString& triggeredAccountId)
|
||||
Utils::showNotification(const QString& message,
|
||||
const QString& from,
|
||||
const QString& accountId,
|
||||
const QString& convUid,
|
||||
std::function<void()> const& onClicked)
|
||||
{
|
||||
if (!AppSettingsManager::getValue(Settings::Key::EnableNotifications).toBool()) {
|
||||
qWarning() << "Notifications are disabled";
|
||||
return;
|
||||
if (accountId.isEmpty() || convUid.isEmpty()) {
|
||||
// This should never happen.
|
||||
qFatal("Invalid account or conversation.");
|
||||
}
|
||||
GlobalSystemTray::instance().setTriggeredAccountId(triggeredAccountId);
|
||||
GlobalSystemTray::instance().showMessage(message, "", QIcon(":images/jami.png"));
|
||||
QApplication::alert(widget, delay);
|
||||
}
|
||||
|
||||
void
|
||||
Utils::showSystemNotification(QWidget* widget,
|
||||
const QString& sender,
|
||||
const QString& message,
|
||||
long delay,
|
||||
const QString& triggeredAccountId)
|
||||
{
|
||||
if (!AppSettingsManager::getValue(Settings::Key::EnableNotifications).toBool()) {
|
||||
qWarning() << "Notifications are disabled";
|
||||
return;
|
||||
}
|
||||
GlobalSystemTray::instance().setTriggeredAccountId(triggeredAccountId);
|
||||
GlobalSystemTray::instance().showMessage(sender, message, QIcon(":images/jami.png"));
|
||||
QApplication::alert(widget, delay);
|
||||
|
||||
if (accountId == GlobalSystemTray::notificationAccountId
|
||||
&& convUid == GlobalSystemTray::notificationConvUid) {
|
||||
GlobalSystemTray::notificationAccountId.clear();
|
||||
GlobalSystemTray::notificationConvUid.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalSystemTray::connectClicked(std::move(onClicked));
|
||||
|
||||
GlobalSystemTray::notificationAccountId = accountId;
|
||||
GlobalSystemTray::notificationConvUid = convUid;
|
||||
|
||||
if (from.isEmpty())
|
||||
GlobalSystemTray::instance().showMessage(message, "", QIcon(":images/jami.png"));
|
||||
else
|
||||
GlobalSystemTray::instance().showMessage(from, message, QIcon(":images/jami.png"));
|
||||
}
|
||||
|
||||
QSize
|
||||
|
||||
Reference in New Issue
Block a user