From: Shane Jaroch Date: Wed, 21 Jan 2026 19:07:48 +0000 (-0500) Subject: add status bar X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=ff7fc26db22e451137309c74789852b020ae199b;p=nutratech%2Fgui.git add status bar --- diff --git a/include/mainwindow.h b/include/mainwindow.h index 32c2ff0..6668513 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -1,6 +1,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include #include #include #include @@ -36,6 +37,10 @@ private: QMenu* recentFilesMenu; static constexpr int MaxRecentFiles = 5; std::array recentFileActions; + + // Status Bar + QLabel* dbStatusLabel; + void updateStatusBar(); }; #endif // MAINWINDOW_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9b8bdee..0dfdf31 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -99,6 +100,35 @@ void MainWindow::setupUi() { // Optional: switch tab? // tabs->setCurrentWidget(mealWidget); }); + + // Status Bar + dbStatusLabel = new QLabel(this); + dbStatusLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + statusBar()->addPermanentWidget(dbStatusLabel); + updateStatusBar(); +} + +void MainWindow::updateStatusBar() { + auto& dbMgr = DatabaseManager::instance(); + QStringList parts; + QString tooltip = "Active Databases:\n"; + + if (dbMgr.isOpen()) { + parts << "USDA [Connected]"; + tooltip += QString("- USDA: %1\n").arg(dbMgr.database().databaseName()); + } else { + parts << "USDA [Disconnected]"; + } + + if (dbMgr.userDatabase().isOpen()) { + parts << "User [Connected]"; + tooltip += QString("- User: %1\n").arg(dbMgr.userDatabase().databaseName()); + } else { + parts << "User [Disconnected]"; + } + + dbStatusLabel->setText("DB Status: " + parts.join(" | ")); + dbStatusLabel->setToolTip(tooltip.trimmed()); } void MainWindow::onOpenDatabase() { @@ -116,6 +146,7 @@ void MainWindow::onOpenDatabase() { if (DatabaseManager::instance().connect(fileName)) { qDebug() << "Switched to database:" << fileName; addToRecentFiles(fileName); + updateStatusBar(); // In a real app, we'd emit a signal or refresh all widgets // For now, let's just log and show success QMessageBox::information(this, "Database Opened", @@ -140,6 +171,7 @@ void MainWindow::onRecentFileClick() { if (DatabaseManager::instance().connect(fileName)) { qDebug() << "Switched to database (recent):" << fileName; addToRecentFiles(fileName); + updateStatusBar(); QMessageBox::information(this, "Database Opened", "Successfully connected to: " + fileName); } else {