40
QString cleanMessage(QString message)
42
QString s = Qt::escape(Konversation::removeIrcMarkup(message));
40
46
void NotificationHandler::message(ChatWindow* chatWin, const QString& fromNick, const QString& message)
42
48
if (!chatWin || !chatWin->notificationsEnabled())
45
51
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
48
bool osd = Preferences::self()->oSDShowChannel() &&
49
(!m_mainWindow->isActiveWindow() || (chatWin != m_mainWindow->getViewContainer()->getFrontView()));
51
if (message.isEmpty())
53
KNotification::event(QString::fromLatin1("message"), QString("<html><%1></html>").arg(fromNick), QPixmap(), m_mainWindow);
57
Application* konvApp = static_cast<Application*>(kapp);
59
konvApp->osd->show('(' + chatWin->getName() + ") <" + fromNick + '>');
64
QString cleanedMessage = removeIrcMarkup(message);
65
QString forKNotify = Qt::escape(cleanedMessage);
67
KNotification::event(QString::fromLatin1("message"), QString("<html><%1> %2</html>").arg(fromNick).arg(forKNotify), QPixmap(), m_mainWindow);
71
Application* konvApp = static_cast<Application*>(kapp);
73
konvApp->osd->show('(' + chatWin->getName() + ") <" + fromNick + "> " + cleanedMessage);
77
if (!Preferences::self()->trayNotifyOnlyOwnNick())
54
QString cleanedMessage = cleanMessage(message);
55
QString cutup = addLineBreaks(cleanedMessage);
57
KNotification::event(QString::fromLatin1("message"), QString("<qt><%1> %2</qt>").arg(fromNick).arg(cutup), QPixmap(), m_mainWindow);
59
if(!Preferences::self()->trayNotifyOnlyOwnNick())
79
61
startTrayNotification(chatWin);
65
if(Preferences::self()->oSDShowChannel() &&
66
(!m_mainWindow->isActiveWindow() || (chatWin != m_mainWindow->getViewContainer()->getFrontView())))
68
Application* konvApp = static_cast<Application*>(kapp);
69
konvApp->osd->show('(' + chatWin->getName() + ") <" + fromNick + "> " + cleanedMessage);
83
74
void NotificationHandler::nick(ChatWindow* chatWin, const QString& fromNick, const QString& message)
88
79
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
91
bool osd = (Preferences::self()->oSDShowChannel() || Preferences::self()->oSDShowOwnNick()) &&
82
QString cleanedMessage = cleanMessage(message);
83
QString cutup = addLineBreaks(cleanedMessage);
85
KNotification::event(QString::fromLatin1("nick"), QString("<qt><%1> %2</qt>").arg(fromNick).arg(cutup), QPixmap(), m_mainWindow);
87
startTrayNotification(chatWin);
89
Application* konvApp = static_cast<Application*>(kapp);
91
if((Preferences::self()->oSDShowChannel() || Preferences::self()->oSDShowOwnNick()) &&
92
92
(!m_mainWindow->isActiveWindow() ||
93
(chatWin != m_mainWindow->getViewContainer()->getFrontView()));
95
if (message.isEmpty())
97
KNotification::event(QString::fromLatin1("nick"), QString("<html><%1></html>").arg(fromNick), QPixmap(), m_mainWindow);
101
Application* konvApp = static_cast<Application*>(kapp);
103
konvApp->osd->show(i18n("[HighLight] (%1) <%2>", chatWin->getName(), fromNick));
108
QString cleanedMessage = removeIrcMarkup(message);
109
QString forKNotify = Qt::escape(cleanedMessage);
111
KNotification::event(QString::fromLatin1("nick"), QString("<html><%1> %2</html>").arg(fromNick).arg(forKNotify), QPixmap(), m_mainWindow);
115
Application* konvApp = static_cast<Application*>(kapp);
117
konvApp->osd->show(i18n("[HighLight] (%1) <%2> %3", chatWin->getName(), fromNick, cleanedMessage));
121
startTrayNotification(chatWin);
93
(chatWin != m_mainWindow->getViewContainer()->getFrontView())))
95
konvApp->osd->show(i18n("[HighLight] (%1) <%2> %3",chatWin->getName(),fromNick,cleanedMessage));
124
99
void NotificationHandler::queryMessage(ChatWindow* chatWin,
130
105
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
133
bool osd = Preferences::self()->oSDShowQuery() && (!m_mainWindow->isActiveWindow() ||
134
(chatWin != m_mainWindow->getViewContainer()->getFrontView()));
136
if (message.isEmpty())
138
KNotification::event(QString::fromLatin1("queryMessage"), QString("<html><%1></html>").arg(fromNick), QPixmap(), m_mainWindow);
142
Application* konvApp = static_cast<Application*>(kapp);
144
konvApp->osd->show(i18n("[Query] <%1>", fromNick));
149
QString cleanedMessage = removeIrcMarkup(message);
150
QString forKNotify = Qt::escape(cleanedMessage);
152
KNotification::event(QString::fromLatin1("queryMessage"), QString("<html><%1> %2</html>").arg(fromNick).arg(forKNotify), QPixmap(), m_mainWindow);
156
Application* konvApp = static_cast<Application*>(kapp);
158
konvApp->osd->show(i18n("[Query] <%1> %2", fromNick, cleanedMessage));
108
QString cleanedMessage = cleanMessage(message);
109
QString cutup = addLineBreaks(cleanedMessage);
111
KNotification::event(QString::fromLatin1("queryMessage"), QString("<qt><%1> %2</qt>").arg(fromNick).arg(cutup), QPixmap(), m_mainWindow);
162
113
startTrayNotification(chatWin);
115
Application* konvApp = static_cast<Application*>(kapp);
117
if(Preferences::self()->oSDShowQuery() && (!m_mainWindow->isActiveWindow() ||
118
(chatWin != m_mainWindow->getViewContainer()->getFrontView())))
120
konvApp->osd->show(i18n("[Query] <%1> %2",fromNick,cleanedMessage));
165
124
void NotificationHandler::startTrayNotification(ChatWindow* chatWin)
254
213
if (Preferences::self()->disableNotifyWhileAway() && chatWin->getServer() && chatWin->getServer()->isAway())
257
KNotification::event(QString::fromLatin1("dcc_error"), i18n("An error has occurred in a DCC transfer: %1",error), QPixmap(), m_mainWindow);
216
KNotification::event(QString::fromLatin1("dcc_error"), i18n("An Error has occurred in a DCC transfer: %1",error), QPixmap(), m_mainWindow);
260
219
void NotificationHandler::dccTransferDone(ChatWindow* chatWin, const QString& file)
348
307
KNotification *ev=new KNotification("dccChat", m_mainWindow);
349
ev->setText(i18n("%1 started a DCC chat with you", nick));
308
ev->setText(i18n("%1 started a dcc chat with you", nick));
362
321
startTrayNotification(chatWin);
364
QString cleanedMessage = removeIrcMarkup(message);
365
QString forKNotify = Qt::escape(cleanedMessage);
323
QString cleanedMessage = cleanMessage(message);
324
QString cutup = addLineBreaks(cleanedMessage);
367
326
if(fromNick.isEmpty())
368
KNotification::event(QString::fromLatin1("highlight"), QString("<html>(%1) *** %2</html>").arg(chatWin->getName()).arg(forKNotify), QPixmap(), m_mainWindow);
327
KNotification::event(QString::fromLatin1("highlight"), QString("<qt>(%1) *** %2</qt>").arg(chatWin->getName()).arg(cutup), QPixmap(), m_mainWindow);
370
KNotification::event(QString::fromLatin1("highlight"), QString("<html>(%1) <%2> %3</html>").arg(chatWin->getName()).arg(fromNick).arg(forKNotify), QPixmap(), m_mainWindow);
329
KNotification::event(QString::fromLatin1("highlight"), QString("<qt>(%1) <%2> %3</qt>").arg(chatWin->getName()).arg(fromNick).arg(cutup), QPixmap(), m_mainWindow);
372
331
if(Preferences::self()->oSDShowOwnNick() &&
373
332
(!m_mainWindow->isActiveWindow() || (chatWin != m_mainWindow->getViewContainer()->getFrontView())))
376
335
// if there was no nick associated, this must be a command message, so don't try displaying
377
336
// an empty nick in <>
378
337
if(fromNick.isEmpty())
379
konvApp->osd->show(i18n("[HighLight] (%1) *** %2",chatWin->getName(),cleanedMessage));
338
konvApp->osd->show(i18n("[HighLight] (%1) *** %2",chatWin->getName(),message));
380
339
// normal highlight message
382
konvApp->osd->show(i18n("[HighLight] (%1) <%2> %3",chatWin->getName(),fromNick,cleanedMessage));
341
konvApp->osd->show(i18n("[HighLight] (%1) <%2> %3",chatWin->getName(),fromNick,message));
405
364
KNotification::event(QString::fromLatin1("channelJoin"), i18n("You have joined %1.",channel), QPixmap(), m_mainWindow);
367
QString NotificationHandler::addLineBreaks(const QString& string)
369
QString cutup = string;
372
for(int i = 0; i < string.length(); i += 50)
374
cutup.insert(i + (offset * 4), "<br>");
410
383
#include "notificationhandler.moc"