From: Shane Jaroch Date: Wed, 21 Jan 2026 10:39:30 +0000 (-0500) Subject: wip X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=ad2de45e597fd17e0e9073d7cacaedb1e66110d0;p=nutratech%2Fgui.git wip --- diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 0000000..2019c8e --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -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" diff --git a/CMakeLists.txt b/CMakeLists.txt index aaec69d..dc3de9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile b/Makefile index d10b8fc..3f58b8e 100644 --- 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 diff --git a/include/mainwindow.h b/include/mainwindow.h index 7253a88..fce7ce9 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -21,6 +21,9 @@ private: SearchWidget *searchWidget; DetailsWidget *detailsWidget; MealWidget *mealWidget; + +private slots: + void onAbout(); }; #endif // MAINWINDOW_H diff --git a/nutra.desktop b/nutra.desktop.in similarity index 89% rename from nutra.desktop rename to nutra.desktop.in index 099e32c..b8dd1fe 100644 --- a/nutra.desktop +++ b/nutra.desktop.in @@ -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 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4cf1803..f56469d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,4 +1,7 @@ #include "mainwindow.h" +#include +#include +#include #include #include @@ -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("

Nutrient Coach %1

" + "

A C++/Qt application for tracking nutrition.

" + "

Homepage: https://github.com/" + "nutratech/gui

") + .arg(NUTRA_VERSION_STRING)); +}