+ if (view)
+ view->zoomOriginal();
+}
+
+
+void BufferWidget::addActionsToMenu(QMenu *menu, const QPointF &pos)
+{
+ Q_UNUSED(pos);
+ ActionCollection *coll = QtUi::actionCollection();
+ menu->addSeparator();
+ menu->addAction(coll->action("ZoomInChatView"));
+ menu->addAction(coll->action("ZoomOutChatView"));
+ menu->addAction(coll->action("ZoomOriginalChatView"));
+}
+
+
+bool BufferWidget::eventFilter(QObject *watched, QEvent *event)
+{
+ if (event->type() != QEvent::KeyPress)
+ return false;
+
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+
+ MultiLineEdit *inputLine = qobject_cast<MultiLineEdit *>(watched);
+ if (!inputLine)
+ return false;
+
+ // Intercept copy key presses
+ if (keyEvent == QKeySequence::Copy) {
+ if (inputLine->hasSelectedText())
+ return false;
+ ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if (view)
+ view->scene()->selectionToClipboard();
+ return true;
+ }
+
+ // We don't want to steal cursor movement keys if the input line is in multiline mode
+ if (!inputLine->isSingleLine())
+ return false;
+
+ switch (keyEvent->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ if (!(keyEvent->modifiers() & Qt::ShiftModifier))
+ return false;
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ // static cast to access public qobject::event
+ return static_cast<QObject *>(ui.stackedWidget->currentWidget())->event(event);
+ default:
+ return false;
+ }
+}
+
+
+void BufferWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
+{
+ ChatView *prevView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+
+ AbstractBufferContainer::currentChanged(current, previous); // switch first to avoid a redraw
+
+ // we need to hide the marker line if it's already/still at the bottom of the view (and not scrolled up)
+ ChatView *curView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if (curView) {
+ BufferId curBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
+ if (curBufferId.isValid()) {
+ MsgId markerMsgId = Client::networkModel()->markerLineMsgId(curBufferId);
+ if (markerMsgId == curView->lastMsgId() && markerMsgId == curView->lastVisibleMsgId())
+ curView->setMarkerLineVisible(false);
+ else
+ curView->setMarkerLineVisible(true);
+ }
+ }
+
+ if (prevView && autoMarkerLine())
+ setMarkerLine(prevView, false);
+}
+
+
+void BufferWidget::setMarkerLine(ChatView *view, bool allowGoingBack)
+{
+ if (!view)
+ view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if (!view)
+ return;
+
+ ChatLine *lastLine = view->lastVisibleChatLine();
+ if (lastLine) {
+ QModelIndex idx = lastLine->index();
+ MsgId msgId = idx.data(MessageModel::MsgIdRole).value<MsgId>();
+ BufferId bufId = view->scene()->singleBufferId();
+
+ if (!allowGoingBack) {
+ MsgId oldMsgId = Client::markerLine(bufId);
+ if (oldMsgId.isValid() && msgId <= oldMsgId)
+ return;
+ }
+ Client::setMarkerLine(bufId, msgId);
+ }
+}
+
+
+void BufferWidget::jumpToMarkerLine(ChatView *view, bool requestBacklog)
+{
+ if (!view)
+ view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if (!view)
+ return;
+
+ view->jumpToMarkerLine(requestBacklog);