forked from blue/squawk
first ideas for notifications
This commit is contained in:
parent
4c20a314f0
commit
18859cb960
6 changed files with 55 additions and 38 deletions
|
@ -28,10 +28,9 @@ Squawk::Squawk(QWidget *parent) :
|
|||
preferences(nullptr),
|
||||
about(nullptr),
|
||||
dialogueQueue(this),
|
||||
rosterModel(),
|
||||
rosterModel(*(Shared::Global::getInstance()->rosterModel)),
|
||||
conversations(),
|
||||
contextMenu(new QMenu()),
|
||||
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()),
|
||||
vCards(),
|
||||
currentConversation(nullptr),
|
||||
restoreSelection(),
|
||||
|
@ -441,33 +440,7 @@ void Squawk::changeMessage(const QString& account, const QString& jid, const QSt
|
|||
|
||||
void Squawk::notify(const QString& account, const Shared::Message& msg)
|
||||
{
|
||||
QString name = QString(rosterModel.getContactName(account, msg.getPenPalJid()));
|
||||
QString path = QString(rosterModel.getContactIconPath(account, msg.getPenPalJid(), msg.getPenPalResource()));
|
||||
QVariantList args;
|
||||
args << QString(QCoreApplication::applicationName());
|
||||
args << QVariant(QVariant::UInt); //TODO some normal id
|
||||
if (path.size() > 0) {
|
||||
args << path;
|
||||
} else {
|
||||
args << QString("mail-message"); //TODO should here better be unknown user icon?
|
||||
}
|
||||
if (msg.getType() == Shared::Message::groupChat) {
|
||||
args << msg.getFromResource() + " from " + name;
|
||||
} else {
|
||||
args << name;
|
||||
}
|
||||
|
||||
QString body(msg.getBody());
|
||||
QString oob(msg.getOutOfBandUrl());
|
||||
if (body == oob) {
|
||||
body = tr("Attached file");
|
||||
}
|
||||
|
||||
args << body;
|
||||
args << QStringList();
|
||||
args << QVariantMap();
|
||||
args << 3000;
|
||||
dbus.callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
||||
Shared::Global::notify(account, msg);
|
||||
}
|
||||
|
||||
void Squawk::onConversationMessage(const Shared::Message& msg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue