Skip to content

Instantly share code, notes, and snippets.

@Zren
Last active December 21, 2015 13:29
Show Gist options
  • Select an option

  • Save Zren/6313393 to your computer and use it in GitHub Desktop.

Select an option

Save Zren/6313393 to your computer and use it in GitHub Desktop.
diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp
index d632420..124a1d8 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<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);
}
}
diff --git a/src/qtui/bufferwidget.h b/src/qtui/bufferwidget.h
index 0ad7faf..0267556 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 a4be9fd..6ddcb79 100644
--- a/src/qtui/mainwin.cpp
+++ b/src/qtui/mainwin.cpp
@@ -1365,11 +1365,17 @@ void MainWin::toggleFullscreen()
/********************************************************************************************************/
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;
}
return QMainWindow::event(event);
}
diff --git a/src/qtui/settingspages/chatviewsettingspage.ui b/src/qtui/settingspages/chatviewsettingspage.ui
index d1d47be..dac2c07 100644
--- a/src/qtui/settingspages/chatviewsettingspage.ui
+++ b/src/qtui/settingspages/chatviewsettingspage.ui
@@ -154,6 +154,25 @@
</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>
<widget class="QGroupBox" name="useCustomColors">
<property name="title">
<string>Custom Colors</string>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment