-void CoreInfoDlg::coreInfoAvailable() {
- ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
- ui.labelCoreBuildDate->setText(_coreInfo["quasselBuildDate"].toString());
- ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
- updateUptime();
- startTimer(1000);
+
+void CoreInfoDlg::coreInfoChanged(const QVariantMap &coreInfo) {
+ ui.labelCoreVersion->setText(coreInfo["quasselVersion"].toString());
+ ui.labelCoreVersionDate->setText(coreInfo["quasselBuildDate"].toString()); // "BuildDate" for compatibility
+ ui.labelClientCount->setNum(coreInfo["sessionConnectedClients"].toInt());
+
+ auto coreSessionSupported = false;
+ auto ids = _widgets.keys();
+ for (const auto &peerData : coreInfo["sessionConnectedClientData"].toList()) {
+ coreSessionSupported = true;
+
+ auto peerMap = peerData.toMap();
+ int peerId = peerMap["id"].toInt();
+
+ ids.removeAll(peerId);
+
+ bool isNew = false;
+ CoreSessionWidget *coreSessionWidget = _widgets[peerId];
+ if (coreSessionWidget == nullptr) {
+ coreSessionWidget = new CoreSessionWidget(ui.coreSessionScrollContainer);
+ isNew = true;
+ }
+ coreSessionWidget->setData(peerMap);
+ if (isNew) {
+ _widgets[peerId] = coreSessionWidget;
+ // Add this to the end of the session list, but before the default layout stretch item.
+ // The layout stretch item should never be removed, so count should always be >= 1.
+ ui.coreSessionContainer->insertWidget(ui.coreSessionContainer->count() - 1,
+ coreSessionWidget, 0, Qt::AlignTop);
+ connect(coreSessionWidget, SIGNAL(disconnectClicked(int)), this, SLOT(disconnectClicked(int)));
+ }
+ }
+
+ for (const auto &key : ids) {
+ delete _widgets[key];
+ _widgets.remove(key);
+ }
+
+ ui.coreSessionScrollArea->setVisible(coreSessionSupported);
+
+ // Hide the information bar when core sessions are supported
+ ui.coreUnsupportedWidget->setVisible(!coreSessionSupported);