Compare commits

..

No commits in common. "381dcfa102143cc342f671b072267b661a46de83" and "6879a69ca1b6ff436c483922bd383e869e6cee88" have entirely different histories.

View File

@ -30,6 +30,7 @@ namespace autoapp
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui_(new Ui::MainWindow), webSocket(new QWebSocket),
reconnectTimer(new QTimer(this)),
metadataTimer(new QTimer(this)),
shuttingDown(false)
{
ui_->setupUi(this);
@ -38,6 +39,10 @@ namespace autoapp
connect(ui_->pushButtonToggleCursor, &QPushButton::clicked, this, &MainWindow::toggleCursor);
connect(ui_->pushButtonWirelessConnection, &QPushButton::clicked, this, &MainWindow::openConnectDialog);
// BT NOW PLAYING UPDATE
connect(metadataTimer, &QTimer::timeout, this, &MainWindow::updateNowPlaying);
metadataTimer->start(1000); // refresh every 5 seconds
// RADIO WEBSOCKET STUFF
reconnectTimer->setSingleShot(true);
reconnectTimer->setInterval(3000);
@ -89,21 +94,6 @@ void autoapp::ui::MainWindow::connectWebSocket()
void autoapp::ui::MainWindow::handleIncomingMessage(const QString &message)
{
// Your custom message processing logic here
qDebug() << "[Handler] Processing message:" << message;
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8(), &error);
QJsonObject rootObj = doc.object();
if (rootObj.contains("bluetooth")) {
ui_->stackedWidget->setCurrentIndex(0);
QJsonObject btObj = rootObj["bluetooth"].toObject();
ui_->btSongName->setText(btObj["song"].toString());
ui_->btArtistName->setText(btObj["artist"].toString());
ui_->btAlbumName->setText(btObj["album"].toString());
} else if (rootObj.contains("radio")) {
ui_->stackedWidget->setCurrentIndex(1);
QJsonObject radioObj = rootObj["radio"].toObject();
ui_->radioScreen->setText(radioObj["screen"].toString());
ui_->radioPreset->setText(radioObj["preset"].toString());
ui_->radioSecondLine->setText(radioObj["second"].toString());
}
}
}