Skip to content

Instantly share code, notes, and snippets.

@Zren
Created August 21, 2013 19:57
Show Gist options
  • Select an option

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

Select an option

Save Zren/6299385 to your computer and use it in GitHub Desktop.
diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp
index d632420..b6400f0 100644
--- a/src/qtui/bufferwidget.cpp
+++ b/src/qtui/bufferwidget.cpp
@@ -243,22 +243,32 @@ void BufferWidget::currentChanged(const QModelIndex &current, const QModelIndex
// 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 (curView)
+ updateMarkerLine(curView);
if (prevView && autoMarkerLine())
setMarkerLine(prevView, false);
}
+void BufferWidget::updateMarkerLine(ChatView *view)
+{
+ if (!view)
+ view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
+ if (!view)
+ return;
+
+ BufferId bufId = view->scene()->singleBufferId();
+ if (bufId.isValid()) {
+ MsgId markerMsgId = Client::networkModel()->markerLineMsgId(bufId);
+ if (markerMsgId == view->lastMsgId() && markerMsgId == view->lastVisibleMsgId())
+ view->setMarkerLineVisible(false);
+ else
+ view->setMarkerLineVisible(true);
+ }
+}
+
+
void BufferWidget::setMarkerLine(ChatView *view, bool allowGoingBack)
{
if (!view)
diff --git a/src/qtui/bufferwidget.h b/src/qtui/bufferwidget.h
index 0ad7faf..4b5e0e1 100644
--- a/src/qtui/bufferwidget.h
+++ b/src/qtui/bufferwidget.h
@@ -44,6 +44,7 @@ public:
void addActionsToMenu(QMenu *, const QPointF &pos);
public slots:
+ virtual void updateMarkerLine(ChatView *view = 0);
virtual void setMarkerLine(ChatView *view = 0, bool allowGoingBack = true);
virtual void jumpToMarkerLine(ChatView *view = 0, bool requestBacklog = true);
diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp
index a4be9fd..4b0d5d8 100644
--- a/src/qtui/mainwin.cpp
+++ b/src/qtui/mainwin.cpp
@@ -162,6 +162,8 @@ MainWin::MainWin(QWidget *parent)
QApplication::setQuitOnLastWindowClosed(false);
+ setFocusPolicy(Qt::StrongFocus);
+
setWindowTitle("Quassel IRC");
setWindowIconText("Quassel IRC");
updateIcon();
@@ -1366,11 +1368,38 @@ 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();
+ MainWin::showStatusBarMessage((QString("onWindowActivate(buffer = %1)").arg(bufferId.toInt())));
+ break;
+
+ case QEvent::WindowDeactivate:
+ BufferId bufferId = Client::bufferModel()->currentBuffer();
+ MainWin::showStatusBarMessage((QString("onWindowDeactivate(buffer = %1)").arg(bufferId.toInt())));
+ break;
+ }
+ */
+
+ switch(event->type()) {
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ BufferId bufferId = Client::bufferModel()->currentBuffer();
+ if (bufferId.isValid()) {
+ Client::instance()->markBufferAsRead(bufferId);
+ }
+ break;
}
+
+ switch(event->type()) {
+ case QEvent::WindowDeactivate:
+ bufferWidget()->setMarkerLine();
+ break;
+ }
+
return QMainWindow::event(event);
}
@@ -1409,6 +1438,16 @@ void MainWin::closeEvent(QCloseEvent *event)
}
+void MainWin::focusOutEvent(QFocusEvent *event) {
+ BufferId bufferId = Client::bufferModel()->currentBuffer();
+ MainWin::showStatusBarMessage((QString("onFocusOutEvent(buffer = %1)").arg(bufferId.toInt())));
+
+ //bufferWidget()->setMarkerLine();
+
+ QMainWindow::focusOutEvent(event);
+}
+
+
void MainWin::messagesInserted(const QModelIndex &parent, int start, int end)
{
Q_UNUSED(parent);
diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h
index 9104654..153543f 100644
--- a/src/qtui/mainwin.h
+++ b/src/qtui/mainwin.h
@@ -99,6 +99,7 @@ protected:
void closeEvent(QCloseEvent *event);
void moveEvent(QMoveEvent *event);
void resizeEvent(QResizeEvent *event);
+ virtual void focusOutEvent(QFocusEvent *event);
protected slots:
void connectedToCore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment