X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatmonitorview.cpp;h=39439d90fc13121e3051cb6be90e78cec1aa4f54;hp=e004e0cb27082c2ab6052342bd3ac88514570e0f;hb=9442592230dc6c95685bc92f298068cf84eeef6f;hpb=aec3a3ab4432d3898ced99de0a61321a1b300fa1 diff --git a/src/qtui/chatmonitorview.cpp b/src/qtui/chatmonitorview.cpp index e004e0cb..39439d90 100644 --- a/src/qtui/chatmonitorview.cpp +++ b/src/qtui/chatmonitorview.cpp @@ -29,54 +29,64 @@ #include "chatitem.h" #include "chatscene.h" #include "client.h" +#include "iconloader.h" #include "networkmodel.h" #include "buffermodel.h" #include "messagemodel.h" #include "qtuisettings.h" +#include "settingspagedlg.h" +#include "settingspages/chatmonitorsettingspage.h" ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent) : ChatView(filter, parent), _filter(filter) { + scene()->setSenderCutoffMode(ChatScene::CutoffLeft); } -void ChatMonitorView::contextMenuEvent(QContextMenuEvent *event) { - if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn) - return; - - int showFields = _filter->showFields(); - - QMenu contextMenu(this); - QAction *showNetworkAction = contextMenu.addAction(tr("Show network name"), this, SLOT(showFieldsChanged(bool))); - showNetworkAction->setCheckable(true); - showNetworkAction->setChecked(showFields & ChatMonitorFilter::NetworkField); - showNetworkAction->setData(ChatMonitorFilter::NetworkField); - - QAction *showBufferAction = contextMenu.addAction(tr("Show buffer name"), this, SLOT(showFieldsChanged(bool))); - showBufferAction->setCheckable(true); - showBufferAction->setChecked(showFields & ChatMonitorFilter::BufferField); - showBufferAction->setData(ChatMonitorFilter::BufferField); - - contextMenu.exec(QCursor::pos()); +void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos) { + ChatView::addActionsToMenu(menu, pos); + menu->addSeparator(); + QAction *showOwnNicksAction = menu->addAction(tr("Show Own Messages"), _filter, SLOT(setShowOwnMessages(bool))); + showOwnNicksAction->setCheckable(true); + showOwnNicksAction->setChecked(_filter->showOwnMessages()); + + if(scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) { + menu->addSeparator(); + + QAction *showNetworkAction = menu->addAction(tr("Show Network Name"), this, SLOT(showFieldsChanged(bool))); + showNetworkAction->setCheckable(true); + showNetworkAction->setChecked(_filter->showFields() & ChatMonitorFilter::NetworkField); + showNetworkAction->setData(ChatMonitorFilter::NetworkField); + + QAction *showBufferAction = menu->addAction(tr("Show Buffer Name"), this, SLOT(showFieldsChanged(bool))); + showBufferAction->setCheckable(true); + showBufferAction->setChecked(_filter->showFields() & ChatMonitorFilter::BufferField); + showBufferAction->setData(ChatMonitorFilter::BufferField); + } + + menu->addSeparator(); + menu->addAction(SmallIcon("configure"), tr("Configure..."), this, SLOT(showSettingsPage())); } void ChatMonitorView::mouseDoubleClickEvent(QMouseEvent *event) { - if(scene()->sectionByScenePos(event->pos()) != ChatLineModel::SenderColumn) { + if(scene()->columnByScenePos(event->pos()) != ChatLineModel::SenderColumn) { ChatView::mouseDoubleClickEvent(event); return; } - event->accept(); ChatItem *chatItem = dynamic_cast(itemAt(event->pos())); + if(!chatItem) { + event->ignore(); + return; + } + + event->accept(); BufferId bufferId = chatItem->data(MessageModel::BufferIdRole).value(); if(!bufferId.isValid()) return; - - QModelIndex bufferIdx = Client::networkModel()->bufferIndex(bufferId); - if(!bufferIdx.isValid()) - return; - Client::bufferModel()->setCurrentIndex(Client::bufferModel()->mapFromSource(bufferIdx)); + Client::bufferModel()->switchToBuffer(bufferId); } void ChatMonitorView::showFieldsChanged(bool checked) { @@ -87,5 +97,10 @@ void ChatMonitorView::showFieldsChanged(bool checked) { if(checked) _filter->addShowField(showAction->data().toInt()); else - _filter->removeShowField(showAction->data().toInt()); + _filter->removeShowField(showAction->data().toInt()); +} + +void ChatMonitorView::showSettingsPage() { + SettingsPageDlg dlg(new ChatMonitorSettingsPage(), this); + dlg.exec(); }