X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=14329168e6f0f96f072ee571481c091fe207b508;hp=e7704d833a6ca6ad235e27eee14209bd8de73769;hb=4ae8f86c1ce452582d6fe576956c7c1bc1460adf;hpb=b8f1a5320b3669538bbb943741c2d1045a57e94a diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index e7704d83..14329168 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2010 by the Quassel Project * + * Copyright (C) 2005-2012 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,6 +19,11 @@ ***************************************************************************/ #include "mainwin.h" +#include +#include +#include +#include + #ifdef HAVE_KDE # include # include @@ -304,7 +309,7 @@ void MainWin::updateIcon() { if(Client::isConnected()) icon = DesktopIcon("quassel", size); else - icon = DesktopIcon("quassel_inactive", size); + icon = DesktopIcon("quassel-inactive", size); setWindowIcon(icon); qApp->setWindowIcon(icon); } @@ -363,7 +368,7 @@ void MainWin::setupActions() { configureQuasselAct->setMenuRole(QAction::PreferencesRole); #else QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll, - this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7)) + this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7)); #endif coll->addAction("ConfigureQuassel", configureQuasselAct); @@ -390,6 +395,9 @@ void MainWin::setupActions() { coll->addAction("ReloadStyle", new Action(SmallIcon("view-refresh"), tr("Reload Stylesheet"), coll, QtUi::style(), SLOT(reload()), QKeySequence::Refresh)); + coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll, + this, SLOT(hideCurrentBuffer()), QKeySequence::Close)); + // Navigation coll = QtUi::actionCollection("Navigation", tr("Navigation")); @@ -713,6 +721,12 @@ void MainWin::previousBuffer() { view->previousBuffer(); } +void MainWin::hideCurrentBuffer() { + BufferView *view = activeBufferView(); + if(view) + view->hideCurrentBuffer(); +} + void MainWin::showNotificationsDlg() { SettingsPageDlg dlg(new NotificationsSettingsPage(this), this); dlg.exec(); @@ -1262,29 +1276,39 @@ void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) { BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value(); BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId); + // check if bufferId belongs to the shown chatlists + if(!(Client::bufferViewOverlay()->bufferIds().contains(bufId) || + Client::bufferViewOverlay()->tempRemovedBufferIds().contains(bufId))) + continue; + + // check if it's the buffer currently displayed if(hasFocus && bufId == Client::bufferModel()->currentBuffer()) continue; - if((flags & Message::Highlight || bufType == BufferInfo::QueryBuffer) - && !(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value(), - Client::networkModel()->networkName(bufId)))) - { - QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn); - QString sender = senderIdx.data(ChatLineModel::EditRole).toString(); - QString contents = idx.data(ChatLineModel::DisplayRole).toString(); - 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::instance()->invokeNotification(bufId, type, sender, contents); - } + // only show notifications for higlights or queries + if(bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight)) + continue; + + // and of course: don't notify for ignored messages + if(Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value(), Client::networkModel()->networkName(bufId))) + continue; + + // seems like we have a legit notification candidate! + QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn); + QString sender = senderIdx.data(ChatLineModel::EditRole).toString(); + QString contents = idx.data(ChatLineModel::DisplayRole).toString(); + 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::instance()->invokeNotification(bufId, type, sender, contents); } }