From: Chris H (Shade / Zren) Date: Thu, 22 Aug 2013 22:25:51 +0000 (-0400) Subject: Implement issue #1219: Update the marker line when quassel loses focus X-Git-Tag: 0.10-beta1~50 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ab9609663dd8ca549cf52a83f54a54bf3634fbc6;ds=sidebyside Implement issue #1219: Update the marker line when quassel loses focus 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. --- diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index c5fbff23..3f6ba6d2 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -40,7 +40,8 @@ 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); @@ -99,6 +100,7 @@ BufferWidget::BufferWidget(QWidget *parent) ChatViewSettings s; s.initAndNotify("AutoMarkerLine", this, SLOT(setAutoMarkerLine(QVariant)), true); + s.initAndNotify("AutoMarkerLineOnLostFocus", this, SLOT(setAutoMarkerLineOnLostFocus(QVariant)), true); } @@ -114,6 +116,11 @@ void BufferWidget::setAutoMarkerLine(const QVariant &v) _autoMarkerLine = v.toBool(); } +void BufferWidget::setAutoMarkerLineOnLostFocus(const QVariant &v) +{ + _autoMarkerLineOnLostFocus = v.toBool(); +} + AbstractChatView *BufferWidget::createChatView(BufferId id) { @@ -270,14 +277,14 @@ void BufferWidget::setMarkerLine(ChatView *view, bool allowGoingBack) if (lastLine) { QModelIndex idx = lastLine->index(); MsgId msgId = idx.data(MessageModel::MsgIdRole).value(); + 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); } } diff --git a/src/qtui/bufferwidget.h b/src/qtui/bufferwidget.h index 8a93a387..88d5a4e5 100644 --- a/src/qtui/bufferwidget.h +++ b/src/qtui/bufferwidget.h @@ -42,6 +42,7 @@ public: 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); @@ -63,6 +64,7 @@ private slots: void zoomOriginal(); void setAutoMarkerLine(const QVariant &); + void setAutoMarkerLineOnLostFocus(const QVariant &); private: Ui::BufferWidget ui; @@ -71,6 +73,7 @@ private: ChatViewSearchController *_chatViewSearchController; bool _autoMarkerLine; + bool _autoMarkerLineOnLostFocus; }; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 1798256a..b984e563 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1395,10 +1395,19 @@ void MainWin::onFullScreenToggled() 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); } diff --git a/src/qtui/settingspages/chatviewsettingspage.ui b/src/qtui/settingspages/chatviewsettingspage.ui index 073ae2df..31cf9eb2 100644 --- a/src/qtui/settingspages/chatviewsettingspage.ui +++ b/src/qtui/settingspages/chatviewsettingspage.ui @@ -153,6 +153,25 @@ + + + + Set the marker line to the bottom of the current chat window when Quassel loses focus. + + + Set marker line automatically when Quassel loses focus + + + true + + + AutoMarkerLineOnLostFocus + + + true + + +