/***************************************************************************
- * Copyright (C) 2005-2013 by the Quassel Project *
+ * Copyright (C) 2005-2018 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "chatviewsearchcontroller.h"
#include "chatviewsettings.h"
#include "client.h"
-#include "iconloader.h"
+#include "icon.h"
#include "multilineedit.h"
#include "qtui.h"
#include "settings.h"
BufferWidget::BufferWidget(QWidget *parent)
: AbstractBufferContainer(parent),
_chatViewSearchController(new ChatViewSearchController(this)),
- _autoMarkerLine(true)
+ _autoMarkerLine(true),
+ _autoMarkerLineOnLostFocus(true)
{
ui.setupUi(this);
layout()->setContentsMargins(0, 0, 0, 0);
ActionCollection *coll = QtUi::actionCollection();
- Action *zoomInChatview = coll->add<Action>("ZoomInChatView", this, SLOT(zoomIn()));
+ auto *zoomInChatview = coll->add<Action>("ZoomInChatView", this, SLOT(zoomIn()));
zoomInChatview->setText(tr("Zoom In"));
- zoomInChatview->setIcon(SmallIcon("zoom-in"));
+ zoomInChatview->setIcon(icon::get("zoom-in"));
zoomInChatview->setShortcut(QKeySequence::ZoomIn);
- Action *zoomOutChatview = coll->add<Action>("ZoomOutChatView", this, SLOT(zoomOut()));
- zoomOutChatview->setIcon(SmallIcon("zoom-out"));
+ auto *zoomOutChatview = coll->add<Action>("ZoomOutChatView", this, SLOT(zoomOut()));
+ zoomOutChatview->setIcon(icon::get("zoom-out"));
zoomOutChatview->setText(tr("Zoom Out"));
zoomOutChatview->setShortcut(QKeySequence::ZoomOut);
- Action *zoomOriginalChatview = coll->add<Action>("ZoomOriginalChatView", this, SLOT(zoomOriginal()));
- zoomOriginalChatview->setIcon(SmallIcon("zoom-original"));
+ auto *zoomOriginalChatview = coll->add<Action>("ZoomOriginalChatView", this, SLOT(zoomOriginal()));
+ zoomOriginalChatview->setIcon(icon::get("zoom-original"));
zoomOriginalChatview->setText(tr("Actual Size"));
//zoomOriginalChatview->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0)); // used for RTS switching
- Action *setMarkerLine = coll->add<Action>("SetMarkerLineToBottom", this, SLOT(setMarkerLine()));
+ auto *setMarkerLine = coll->add<Action>("SetMarkerLineToBottom", this, SLOT(setMarkerLine()));
setMarkerLine->setText(tr("Set Marker Line"));
setMarkerLine->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
- Action *jumpToMarkerLine = QtUi::actionCollection("Navigation")->add<Action>("JumpToMarkerLine", this, SLOT(jumpToMarkerLine()));
+ auto *jumpToMarkerLine = QtUi::actionCollection("Navigation")->add<Action>("JumpToMarkerLine", this, SLOT(jumpToMarkerLine()));
jumpToMarkerLine->setText(tr("Go to Marker Line"));
jumpToMarkerLine->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_K));
ChatViewSettings s;
s.initAndNotify("AutoMarkerLine", this, SLOT(setAutoMarkerLine(QVariant)), true);
+ s.initAndNotify("AutoMarkerLineOnLostFocus", this, SLOT(setAutoMarkerLineOnLostFocus(QVariant)), true);
}
BufferWidget::~BufferWidget()
{
delete _chatViewSearchController;
- _chatViewSearchController = 0;
+ _chatViewSearchController = nullptr;
}
_autoMarkerLine = v.toBool();
}
+void BufferWidget::setAutoMarkerLineOnLostFocus(const QVariant &v)
+{
+ _autoMarkerLineOnLostFocus = v.toBool();
+}
+
AbstractChatView *BufferWidget::createChatView(BufferId id)
{
ui.stackedWidget->setCurrentWidget(ui.page);
}
else {
- ChatView *view = qobject_cast<ChatView *>(_chatViews.value(id));
+ auto *view = qobject_cast<ChatView *>(_chatViews.value(id));
Q_ASSERT(view);
ui.stackedWidget->setCurrentWidget(view);
_chatViewSearchController->setScene(view->scene());
void BufferWidget::scrollToHighlight(QGraphicsItem *highlightItem)
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view) {
view->centerOn(highlightItem);
}
void BufferWidget::zoomIn()
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->zoomIn();
}
void BufferWidget::zoomOut()
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->zoomOut();
}
void BufferWidget::zoomOriginal()
{
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->zoomOriginal();
}
if (event->type() != QEvent::KeyPress)
return false;
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ auto *keyEvent = static_cast<QKeyEvent *>(event);
- MultiLineEdit *inputLine = qobject_cast<MultiLineEdit *>(watched);
+ auto *inputLine = qobject_cast<MultiLineEdit *>(watched);
if (!inputLine)
return false;
if (keyEvent == QKeySequence::Copy) {
if (inputLine->hasSelectedText())
return false;
- ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (view)
view->scene()->selectionToClipboard();
return true;
case Qt::Key_Down:
if (!(keyEvent->modifiers() & Qt::ShiftModifier))
return false;
+ // fallthrough
case Qt::Key_PageUp:
case Qt::Key_PageDown:
// static cast to access public qobject::event
void BufferWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
- ChatView *prevView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ auto *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());
+ auto *curView = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
if (curView) {
BufferId curBufferId = current.data(NetworkModel::BufferIdRole).value<BufferId>();
if (curBufferId.isValid()) {
if (lastLine) {
QModelIndex idx = lastLine->index();
MsgId msgId = idx.data(MessageModel::MsgIdRole).value<MsgId>();
+ BufferId bufId = view->scene()->singleBufferId();
if (!allowGoingBack) {
- BufferId bufId = view->scene()->singleBufferId();
MsgId oldMsgId = Client::markerLine(bufId);
if (oldMsgId.isValid() && msgId <= oldMsgId)
return;
}
- view->setMarkerLine(msgId);
+ Client::setMarkerLine(bufId, msgId);
}
}