Solves issue #1219 on bugs.quassel-irc.org.
We now listen for QEvent::WindowDeactivate in the main window. This
should pickup on window closing/minimizing/losing focus. We also change
view->setMarkerLine() to Client::setMarkerLine which will send an event
to the syncher, and eventually arrives at ChatView::markerLineSet, which
moves the marker line for us.
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);
ChatViewSettings s;
s.initAndNotify("AutoMarkerLine", this, SLOT(setAutoMarkerLine(QVariant)), true);
+ s.initAndNotify("AutoMarkerLineOnLostFocus", this, SLOT(setAutoMarkerLineOnLostFocus(QVariant)), true);
}
_autoMarkerLine = v.toBool();
}
+void BufferWidget::setAutoMarkerLineOnLostFocus(const QVariant &v)
+{
+ _autoMarkerLineOnLostFocus = v.toBool();
+}
+
AbstractChatView *BufferWidget::createChatView(BufferId id)
{
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);
}
}
inline ChatViewSearchBar *searchBar() const { return ui.searchBar; }
void addActionsToMenu(QMenu *, const QPointF &pos);
+ virtual inline bool autoMarkerLineOnLostFocus() const { return _autoMarkerLineOnLostFocus; }
public slots:
virtual void setMarkerLine(ChatView *view = 0, bool allowGoingBack = true);
void zoomOriginal();
void setAutoMarkerLine(const QVariant &);
+ void setAutoMarkerLineOnLostFocus(const QVariant &);
private:
Ui::BufferWidget ui;
ChatViewSearchController *_chatViewSearchController;
bool _autoMarkerLine;
+ bool _autoMarkerLineOnLostFocus;
};
bool MainWin::event(QEvent *event)
{
- if (event->type() == QEvent::WindowActivate) {
- BufferId buffer = Client::bufferModel()->currentBuffer();
- if (buffer.isValid())
- Client::instance()->markBufferAsRead(buffer);
+ switch(event->type()) {
+ case QEvent::WindowActivate: {
+ BufferId bufferId = Client::bufferModel()->currentBuffer();
+ if (bufferId.isValid())
+ Client::instance()->markBufferAsRead(bufferId);
+ break;
+ }
+ case QEvent::WindowDeactivate:
+ if (bufferWidget()->autoMarkerLineOnLostFocus())
+ bufferWidget()->setMarkerLine();
+ break;
+ default:
+ break;
}
return QMainWindow::event(event);
}
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="autoMarkerLineOnLostFocus">
+ <property name="toolTip">
+ <string>Set the marker line to the bottom of the current chat window when Quassel loses focus.</string>
+ </property>
+ <property name="text">
+ <string>Set marker line automatically when Quassel loses focus</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>AutoMarkerLineOnLostFocus</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>