]> Nutra Git (v2) - nutratech/gui.git/commitdiff
add status bar
authorShane Jaroch <chown_tee@proton.me>
Wed, 21 Jan 2026 19:07:48 +0000 (14:07 -0500)
committerShane Jaroch <chown_tee@proton.me>
Wed, 21 Jan 2026 19:07:48 +0000 (14:07 -0500)
include/mainwindow.h
src/mainwindow.cpp

index 32c2ff0e28f7883bb2436bc87f2840804722f9ac..666851365001104e64557ce644ea802a117b2924 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef MAINWINDOW_H
 #define MAINWINDOW_H
 
+#include <QLabel>
 #include <QMainWindow>
 #include <QTabWidget>
 #include <array>
@@ -36,6 +37,10 @@ private:
     QMenu* recentFilesMenu;
     static constexpr int MaxRecentFiles = 5;
     std::array<QAction*, MaxRecentFiles> recentFileActions;
+
+    // Status Bar
+    QLabel* dbStatusLabel;
+    void updateStatusBar();
 };
 
 #endif  // MAINWINDOW_H
index 9b8bdeef5569eebe2dfcfea82755f79889c9f9f1..0dfdf31d0d21bcea74cc89271f1f30770dbacc6b 100644 (file)
@@ -7,6 +7,7 @@
 #include <QMenuBar>
 #include <QMessageBox>
 #include <QSettings>
+#include <QStatusBar>
 #include <QStringList>
 #include <QVBoxLayout>
 #include <QWidget>
@@ -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 {