]> Nutra Git (v2) - nutratech/gui.git/commitdiff
wip
authorShane Jaroch <chown_tee@proton.me>
Wed, 21 Jan 2026 10:39:30 +0000 (05:39 -0500)
committerShane Jaroch <chown_tee@proton.me>
Wed, 21 Jan 2026 10:49:47 +0000 (05:49 -0500)
.github/workflows/version-bump.yml [new file with mode: 0644]
CMakeLists.txt
Makefile
include/mainwindow.h
nutra.desktop.in [moved from nutra.desktop with 89% similarity]
src/mainwindow.cpp

diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml
new file mode 100644 (file)
index 0000000..2019c8e
--- /dev/null
@@ -0,0 +1,65 @@
+name: Manual Version Bump
+
+on:
+  workflow_dispatch:
+    inputs:
+      bump_type:
+        description: "Type of bump"
+        required: true
+        default: "patch"
+        type: choice
+        options:
+          - patch
+          - minor
+          - major
+
+jobs:
+  bump:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+          token: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Configure Git
+        run: |
+          git config user.name "github-actions[bot]"
+          git config user.email "github-actions[bot]@users.noreply.github.com"
+
+      - name: Calculate and Push New Tag
+        run: |
+          # Get current tag
+          CURRENT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
+          echo "Current tag: $CURRENT_TAG"
+
+          # Remove 'v' prefix
+          VERSION=${CURRENT_TAG#v}
+
+          # Split version
+          IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
+
+          # Calculate next version
+          case "${{ inputs.bump_type }}" in
+            major)
+              MAJOR=$((MAJOR + 1))
+              MINOR=0
+              PATCH=0
+              ;;
+            minor)
+              MINOR=$((MINOR + 1))
+              PATCH=0
+              ;;
+            patch)
+              PATCH=$((PATCH + 1))
+              ;;
+          esac
+
+          NEW_TAG="v$MAJOR.$MINOR.$PATCH"
+          echo "New tag: $NEW_TAG"
+
+          # Create and push tag
+          git tag "$NEW_TAG"
+          git push origin "$NEW_TAG"
index aaec69dee6124ec66c457f236301e3e5b6dd645a..dc3de9a0a2ec4b7abe84ff2bfeaa40570e9a9d34 100644 (file)
@@ -32,6 +32,23 @@ set(PROJECT_SOURCES
     resources.qrc
 )
 
+# Versioning
+if(NOT NUTRA_VERSION)
+    execute_process(
+        COMMAND git describe --tags --always --dirty
+        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+        OUTPUT_VARIABLE GIT_VERSION
+        ERROR_QUIET
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+    if(GIT_VERSION)
+        set(NUTRA_VERSION "${GIT_VERSION}")
+    else()
+        set(NUTRA_VERSION "v0.0.0-unknown")
+    endif()
+endif()
+add_compile_definitions(NUTRA_VERSION_STRING="${NUTRA_VERSION}")
+
 
 
 
@@ -55,9 +72,13 @@ target_link_libraries(test_nutra PRIVATE Qt${QT_VERSION_MAJOR}::Test Qt${QT_VERS
 add_test(NAME FoodRepoTest COMMAND test_nutra)
 
 
-install(TARGETS nutra DESTINATION bin)
-install(FILES nutra.desktop DESTINATION share/applications)
-install(FILES resources/nutrition_icon-no_bg.png DESTINATION share/icons/hicolor/128x128/apps RENAME nutra.png)
+include(GNUInstallDirs)
+set(NUTRA_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/nutra")
+configure_file(nutra.desktop.in ${CMAKE_BINARY_DIR}/nutra.desktop @ONLY)
+
+install(TARGETS nutra DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(FILES ${CMAKE_BINARY_DIR}/nutra.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
+install(FILES resources/nutrition_icon-no_bg.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps RENAME nutra.png)
 
 if(NUTRA_DB_FILE AND EXISTS "${NUTRA_DB_FILE}")
     install(FILES "${NUTRA_DB_FILE}" DESTINATION share/nutra RENAME usda.sqlite3)
index d10b8fc90469de84a0e64d53c0a67939a799dc4c..3f58b8e95a0a222f0946bff5f0ada933d2902cc0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,9 @@ CMAKE := cmake
 CTEST := ctest
 SRC_DIRS := src
 
+# Get version from git
+VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0")
+
 # Find source files for linting
 LINT_LOCS_CPP ?= $(shell git ls-files '*.cpp')
 LINT_LOCS_H ?= $(shell git ls-files '*.h')
@@ -14,6 +17,7 @@ config:
        $(CMAKE) \
                -DCMAKE_BUILD_TYPE=Debug \
                -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
+               -DNUTRA_VERSION="$(VERSION)" \
                -B $(BUILD_DIR)
 
 .PHONY: debug
@@ -23,7 +27,7 @@ debug: config
 .PHONY: release
 release:
        $(CMAKE) -E make_directory $(BUILD_DIR)
-       $(CMAKE) -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release
+       $(CMAKE) -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=Release -DNUTRA_VERSION="$(VERSION)"
        $(CMAKE) --build $(BUILD_DIR) --config Release
 
 .PHONY: clean
index 7253a88d3e49e18aaf53241d29ab8f7874adfb0a..fce7ce965feb1fc60d4653cc0c073387d8b46899 100644 (file)
@@ -21,6 +21,9 @@ private:
   SearchWidget *searchWidget;
   DetailsWidget *detailsWidget;
   MealWidget *mealWidget;
+
+private slots:
+  void onAbout();
 };
 
 #endif // MAINWINDOW_H
similarity index 89%
rename from nutra.desktop
rename to nutra.desktop.in
index 099e32c42214033f743e5d3ba8761a74aaec86a4..b8dd1fe1e1f5321391afbba81e12e6df550e6f13 100644 (file)
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Name=Nutra
 Comment=Nutrition Tracker and USDA Database
-Exec=nutra
+Exec=@NUTRA_EXECUTABLE@
 Icon=nutra
 Terminal=false
 Type=Application
index 4cf18038e48e79bbb65d01844cf249302cc8d5d4..f56469d0fe6b7c21a5d7361f115c2f10606e0c99 100644 (file)
@@ -1,4 +1,7 @@
 #include "mainwindow.h"
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
 #include <QVBoxLayout>
 
 #include <QDebug>
@@ -14,6 +17,11 @@ void MainWindow::setupUi() {
   setWindowIcon(QIcon(":/resources/nutrition_icon-no_bg.png"));
   resize(1000, 700);
 
+  // Menu Bar
+  auto *helpMenu = menuBar()->addMenu("&Help");
+  auto *aboutAction = helpMenu->addAction("&About");
+  connect(aboutAction, &QAction::triggered, this, &MainWindow::onAbout);
+
   auto *centralWidget = new QWidget(this);
   setCentralWidget(centralWidget);
 
@@ -50,3 +58,14 @@ void MainWindow::setupUi() {
             // tabs->setCurrentWidget(mealWidget);
           });
 }
+
+void MainWindow::onAbout() {
+  QMessageBox::about(
+      this, "About Nutrient Coach",
+      QString("<h3>Nutrient Coach %1</h3>"
+              "<p>A C++/Qt application for tracking nutrition.</p>"
+              "<p>Homepage: <a "
+              "href=\"https://github.com/nutratech/gui\">https://github.com/"
+              "nutratech/gui</a></p>")
+          .arg(NUTRA_VERSION_STRING));
+}