chatgui: preserve active channel selection on reload, members sync, profile settings, member list model
This commit is contained in:
1 parent
c3f946fb63
commit
d70cdbb040
28 files changed
+1895
-91
No files matched your search
@@ -40,6 +40,12 @@ static void onChannelUpdatedCallback(const char* ch_id, int ch_id_len) {
|
||||
s_mainWindow->reloadChannels();
|
||||
}
|
||||
|
||||
static void onMembersChangedCallback(const char* ch_id, int ch_id_len) {
|
||||
Q_UNUSED(ch_id_len);
|
||||
if (s_mainWindow)
|
||||
s_mainWindow->onMembersChanged(ch_id);
|
||||
}
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
|
||||
const QString& dbPath, const QString& debugFile,
|
||||
const QString& debugLevel, const QString& debugCategories)
|
||||
@@ -65,6 +71,11 @@ MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
|
||||
s_mainWindow = this;
|
||||
gui_bridge_set_msg_received_cb(onMsgReceivedCallback);
|
||||
gui_bridge_set_channel_updated_cb(onChannelUpdatedCallback);
|
||||
gui_bridge_set_members_changed_cb(onMembersChangedCallback);
|
||||
gui_bridge_set_my_node_id_cb([](uint64_t nid) {
|
||||
qDebug("MainWindow: MY_NODE_ID setMyNodeId(%016llx)", (unsigned long long)nid);
|
||||
if (s_mainWindow && s_mainWindow->m_db) s_mainWindow->m_db->setMyNodeId((quint64)nid);
|
||||
});
|
||||
|
||||
setupNode();
|
||||
setupMessaging();
|
||||
@@ -73,6 +84,7 @@ MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
|
||||
this, [this](const QString& channelId) {
|
||||
m_db->setUiState("last_channel_id", channelId);
|
||||
m_messageList->loadChannel(channelId);
|
||||
m_accountList->setChannel(channelId);
|
||||
});
|
||||
|
||||
connect(m_channelList, &ChannelList::inviteRequested,
|
||||
@@ -85,11 +97,12 @@ MainWindow::MainWindow(QWidget *parent, DbManager* db, const QString& cfgPath,
|
||||
this, &MainWindow::showSettings);
|
||||
|
||||
m_channelList->loadChannels();
|
||||
m_accountList->loadAccounts();
|
||||
|
||||
QString lastCid = m_db->getUiState("last_channel_id");
|
||||
if (!lastCid.isEmpty())
|
||||
if (!lastCid.isEmpty()) {
|
||||
m_channelList->selectChannel(lastCid);
|
||||
m_accountList->setChannel(lastCid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,9 +252,23 @@ void MainWindow::onMessageReceived(const char* ch_id) {
|
||||
m_messageList->refresh();
|
||||
}
|
||||
|
||||
void MainWindow::onMembersChanged(const char* ch_id) {
|
||||
QString cur = m_db->getUiState("last_channel_id");
|
||||
if (cur == QString::fromUtf8(ch_id))
|
||||
m_accountList->refresh();
|
||||
}
|
||||
|
||||
void MainWindow::reloadChannels() {
|
||||
if (m_channelList)
|
||||
if (m_channelList) {
|
||||
m_channelList->loadChannels();
|
||||
if (!m_pendingChannelSelect.isEmpty()) {
|
||||
m_channelList->selectChannel(m_pendingChannelSelect);
|
||||
m_accountList->setChannel(m_pendingChannelSelect);
|
||||
m_messageList->loadChannel(m_pendingChannelSelect);
|
||||
m_db->setUiState("last_channel_id", m_pendingChannelSelect);
|
||||
m_pendingChannelSelect.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onCreateGroupRequested() {
|
||||
@@ -344,6 +371,7 @@ void MainWindow::onCreateGroupRequested() {
|
||||
memcpy(req->signature, sig, 64);
|
||||
|
||||
gui_bridge_post_uasync_fn(chat_core_create_channel_trampoline, req);
|
||||
m_pendingChannelSelect = channelId;
|
||||
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "MainWindow: create group request posted ch=%s name=%s",
|
||||
qPrintable(channelId), qPrintable(name));
|
||||
|
||||
Reference in new issue
Block a user