Sound=KDE-Im-Highlight-Msg.ogg
Action=Sound|Popup|Taskbar
+[Event/HighlightFocused]
+Name=Highlight when focused
+Comment=A highlighted message has arrived while Quassel is focused
+Sound=KDE-Im-Highlight-Msg.ogg
+Action=Taskbar
+
+[Event/PrivMsg]
+Name=Private Message
+Comment=A private message (query) has arrived
+Sound=KDE-Im-Message-In.ogg
+Action=Sound|Popup|Taskbar
+
+[Event/PrivMsgFocused]
+Name=Private message when focused
+Comment=A private message (query) has arrived while Quassel is focused
+Sound=KDE-Im-Message-In.ogg
+Action=Taskbar
}
void DesktopNotificationBackend::notify(const Notification &n) {
- if(_enabled) {
+ if(_enabled && (n.type == Highlight || n.type == PrivMsg)) {
QStringList actions;
QMap<QString, QVariant> hints;
}
void KNotificationBackend::notify(const Notification &n) {
- //QString title = Client::networkModel()->networkName(n.bufferId) + " - " + Client::networkModel()->bufferName(n.bufferId);
+ QString type;
+ switch(n.type) {
+ case Highlight:
+ type = "Highlight"; break;
+ case HighlightFocused:
+ type = "HighlightFocused"; break;
+ case PrivMsg:
+ type = "PrivMsg"; break;
+ case PrivMsgFocused:
+ type = "PrivMsgFocused"; break;
+ }
+
QString message = QString("<b><%1></b> %2").arg(n.sender, n.message);
- KNotification *notification = KNotification::event("Highlight", message, DesktopIcon("dialog-information"), QtUi::mainWindow(),
+ KNotification *notification = KNotification::event(type, message, DesktopIcon("dialog-information"), QtUi::mainWindow(),
KNotification::Persistent|KNotification::RaiseWidgetOnActivation|KNotification::CloseWhenWidgetActivated);
connect(notification, SIGNAL(activated(uint)), SLOT(notificationActivated()));
connect(notification, SIGNAL(closed()), SLOT(notificationClosed()));
void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
Q_UNUSED(parent);
- if(QApplication::activeWindow() != 0)
- return;
+ bool hasFocus = QApplication::activeWindow() != 0;
for(int i = start; i <= end; i++) {
QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn);
continue;
}
Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt();
- if(flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self)) continue;
+ if(flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self))
+ continue;
flags |= Message::Backlog; // we only want to trigger a highlight once!
Client::messageModel()->setData(idx, (int)flags, ChatLineModel::FlagsRole);
BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>();
BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId);
+ if(hasFocus && bufId == _bufferWidget->currentBuffer())
+ continue;
+
if(flags & Message::Highlight || bufType == BufferInfo::QueryBuffer) {
QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn);
QString sender = senderIdx.data(ChatLineModel::EditRole).toString();
QString contents = idx.data(ChatLineModel::DisplayRole).toString();
- QtUi::invokeNotification(bufId, sender, contents);
+ AbstractNotificationBackend::NotificationType type;
+
+ if(bufType == BufferInfo::QueryBuffer && !hasFocus)
+ type = AbstractNotificationBackend::PrivMsg;
+ else if(bufType == BufferInfo::QueryBuffer && hasFocus)
+ type = AbstractNotificationBackend::PrivMsgFocused;
+ else if(flags & Message::Highlight && !hasFocus)
+ type = AbstractNotificationBackend::Highlight;
+ else
+ type = AbstractNotificationBackend::HighlightFocused;
+
+ QtUi::invokeNotification(bufId, type, sender, contents);
}
}
}
}
void PhononNotificationBackend::notify(const Notification ¬ification) {
- Q_UNUSED(notification)
- if(_enabled && _media) {
+ if(_enabled && _media && (notification.type == Highlight || notification.type == PrivMsg)) {
_media->play();
}
}
return _notificationBackends;
}
-uint QtUi::invokeNotification(BufferId bufId, const QString &sender, const QString &text) {
+uint QtUi::invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text) {
static int notificationId = 0;
//notificationId++;
- AbstractNotificationBackend::Notification notification(++notificationId, bufId, sender, text);
+ AbstractNotificationBackend::Notification notification(++notificationId, bufId, type, sender, text);
_notifications.append(notification);
foreach(AbstractNotificationBackend *backend, _notificationBackends)
backend->notify(notification);
inline static QtUiStyle *style();
inline static MainWin *mainWindow();
-
/* Notifications */
static void registerNotificationBackend(AbstractNotificationBackend *);
static void unregisterNotificationBackend(AbstractNotificationBackend *);
static void unregisterAllNotificationBackends();
static const QList<AbstractNotificationBackend *> ¬ificationBackends();
- static uint invokeNotification(BufferId bufId, const QString &sender, const QString &text);
+ static uint invokeNotification(BufferId bufId, AbstractNotificationBackend::NotificationType type, const QString &sender, const QString &text);
static void closeNotification(uint notificationId);
static void closeNotifications(BufferId bufferId = BufferId());
static const QList<AbstractNotificationBackend::Notification> &activeNotifications();
}
void SystrayNotificationBackend::notify(const Notification ¬ification) {
+ if(notification.type != Highlight && notification.type != PrivMsg)
+ return;
+
/* fancy stuff to be implemented later: show notifications in order
_notifications.append(notification);
if(_showBubble && _notifications.count() == 1) {
}
void TaskbarNotificationBackend::notify(const Notification ¬ification) {
- Q_UNUSED(notification)
- if(_enabled) {
+ if(_enabled && (notification.type == Highlight || notification.type == PrivMsg)) {
QApplication::alert(QtUi::mainWindow(), _timeout);
}
}
Q_OBJECT
public:
+ enum NotificationType {
+ Highlight = 0x01,
+ PrivMsg = 0x02,
+ HighlightFocused = 0x11,
+ PrivMsgFocused = 0x12
+ };
+
struct Notification {
uint notificationId;
BufferId bufferId;
+ NotificationType type;
QString sender;
QString message;
- Notification(uint id_, BufferId buf_, const QString &sender_, const QString &msg_)
- : notificationId(id_), bufferId(buf_), sender(sender_), message(msg_) {};
+ Notification(uint id_, BufferId buf_, NotificationType type_, const QString &sender_, const QString &msg_)
+ : notificationId(id_), bufferId(buf_), type(type_), sender(sender_), message(msg_) {};
};
inline AbstractNotificationBackend(QObject *parent) : QObject(parent) {};