Browse Source

chatgui: save scroll/read position on app quit via aboutToQuit

Make saveChannelState() public, connect to QApplication::aboutToQuit so
state is persisted on SIGINT, tray quit, or any other shutdown.
topo_upd
Evgeny 2 months ago
parent
commit
393b7d36c8
  1. 2
      tools/chatgui/src/mainwindow.cpp
  2. 2
      tools/chatgui/src/messagelist.h

2
tools/chatgui/src/mainwindow.cpp

@ -229,6 +229,8 @@ void MainWindow::setupConnects() {
m_channelList->setChannelUnreadCount(channelId, m_channelList->setChannelUnreadCount(channelId,
m_db->getUnreadCount(channelId, lastReadMsgId)); m_db->getUnreadCount(channelId, lastReadMsgId));
}); });
connect(qApp, &QApplication::aboutToQuit, m_messageList, &MessageList::saveChannelState);
} }
void MainWindow::setupTray() { void MainWindow::setupTray() {

2
tools/chatgui/src/messagelist.h

@ -18,6 +18,7 @@ public:
void loadChannel(const QString& channelId); void loadChannel(const QString& channelId);
void refresh(); void refresh();
void saveChannelState();
void addMessage(const QString& channelId, quint64 authorNodeId, void addMessage(const QString& channelId, quint64 authorNodeId,
const QByteArray& content, qint64 timestamp); const QByteArray& content, qint64 timestamp);
@ -38,7 +39,6 @@ private:
qint64 m_savedTopMsgId = 0; qint64 m_savedTopMsgId = 0;
bool m_wasAtBottom = false; bool m_wasAtBottom = false;
void saveChannelState();
void restoreScrollPosition(const QString& channelId); void restoreScrollPosition(const QString& channelId);
void updateReadPosition(); void updateReadPosition();
}; };

Loading…
Cancel
Save