]> Nutra Git (v1) - nutratech/gui.git/commitdiff
lint & ui tweaks/stuff
authorShane Jaroch <chown_tee@proton.me>
Wed, 21 Jan 2026 21:20:40 +0000 (16:20 -0500)
committerShane Jaroch <chown_tee@proton.me>
Wed, 21 Jan 2026 21:20:40 +0000 (16:20 -0500)
include/widgets/preferencesdialog.h
src/mainwindow.cpp
src/widgets/preferencesdialog.cpp

index 47921f0224ba974a4128db5758489ac3755b9d9d..644a54f848e70e7fe847138871b66ac928d89b86 100644 (file)
@@ -15,7 +15,7 @@ public:
 private:
     void setupUi();
     void loadStatistics();
-    QString formatBytes(qint64 bytes) const;
+    [[nodiscard]] QString formatBytes(qint64 bytes) const;
 
     QTabWidget* tabWidget;
 
index 98205bb4d5ad5f9671d2264aa862cd0b9687add3..26e54104865e6b480164624ab9dbdd9c789f6caf 100644 (file)
@@ -60,19 +60,26 @@ void MainWindow::setupUi() {
 
     // Help Menu
     auto* helpMenu = menuBar()->addMenu("&Help");
-    auto* aboutAction = helpMenu->addAction("&About");
-    connect(aboutAction, &QAction::triggered, this, &MainWindow::onAbout);
 
-    auto* infoAction = helpMenu->addAction("&Info");
-    connect(infoAction, &QAction::triggered, this, [this]() {
+    auto* licenseAction = helpMenu->addAction("&License");
+    connect(licenseAction, &QAction::triggered, this, [this]() {
         QMessageBox::information(
-            this, "Philosophy",
-            "It's a free app designed not as a weight-loss app but a true nutrition "
-            "coach, giving insights into what you're getting and what you're lacking, "
-            "empowering you to make more informed and healthy decisions and live more "
-            "of the vibrant life you were put here for.");
+            this, "License",
+            "<h3>GNU General Public License v3.0</h3>"
+            "<p>This program is free software: you can redistribute it and/or modify "
+            "it under the terms of the GNU General Public License as published by "
+            "the Free Software Foundation, either version 3 of the License, or "
+            "(at your option) any later version.</p>"
+            "<p>This program is distributed in the hope that it will be useful, "
+            "but WITHOUT ANY WARRANTY; without even the implied warranty of "
+            "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>"
+            "<p>See <a href=\"https://www.gnu.org/licenses/gpl-3.0.html\">"
+            "https://www.gnu.org/licenses/gpl-3.0.html</a> for details.</p>");
     });
 
+    auto* aboutAction = helpMenu->addAction("&About");
+    connect(aboutAction, &QAction::triggered, this, &MainWindow::onAbout);
+
     auto* centralWidget = new QWidget(this);
     setCentralWidget(centralWidget);
 
@@ -238,7 +245,11 @@ void MainWindow::onSettings() {
 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>This application is a tool designed not as a weight-loss app "
+                               "but as a true <b>nutrition coach</b>, giving insights into what "
+                               "you're getting and what you're lacking, empowering you to make "
+                               "more informed and healthy decisions and live more of the vibrant "
+                               "life you were put here for.</p>"
                                "<p>Homepage: <a "
                                "href=\"https://github.com/nutratech/gui\">https://github.com/"
                                "nutratech/gui</a></p>")
index 10e56db271b40947fe2bb6a010952af695b80dc1..eba3c4af3473fa63eccd478862511ff54ad5887d 100644 (file)
@@ -99,7 +99,7 @@ void PreferencesDialog::loadStatistics() {
     QDir recipeDir(recipePath);
     int recipeCount = 0;
     if (recipeDir.exists()) {
-        recipeCount = recipeDir.entryList(QDir::Files).count();
+        recipeCount = static_cast<int>(recipeDir.entryList(QDir::Files).count());
     }
     lblRecipes->setText(QString::number(recipeCount));
 
@@ -110,7 +110,7 @@ void PreferencesDialog::loadStatistics() {
     qint64 totalBackupSize = 0;
     if (backupDir.exists()) {
         QFileInfoList files = backupDir.entryInfoList({"*.sql.gz"}, QDir::Files);
-        snapshotCount = files.count();
+        snapshotCount = static_cast<int>(files.count());
         for (const auto& fi : files) {
             totalBackupSize += fi.size();
         }
@@ -131,9 +131,11 @@ void PreferencesDialog::loadStatistics() {
 }
 
 QString PreferencesDialog::formatBytes(qint64 bytes) const {
-    if (bytes < 1024) return QString("%1 B").arg(bytes);
-    if (bytes < 1024 * 1024) return QString("%1 KB").arg(bytes / 1024.0, 0, 'f', 1);
-    if (bytes < 1024 * 1024 * 1024)
-        return QString("%1 MB").arg(bytes / (1024.0 * 1024.0), 0, 'f', 2);
-    return QString("%1 GB").arg(bytes / (1024.0 * 1024.0 * 1024.0), 0, 'f', 2);
+    constexpr qint64 KB = 1024LL;
+    constexpr qint64 MB = 1024LL * 1024LL;
+    constexpr qint64 GB = 1024LL * 1024LL * 1024LL;
+    if (bytes < KB) return QString("%1 B").arg(bytes);
+    if (bytes < MB) return QString("%1 KB").arg(static_cast<double>(bytes) / KB, 0, 'f', 1);
+    if (bytes < GB) return QString("%1 MB").arg(static_cast<double>(bytes) / MB, 0, 'f', 2);
+    return QString("%1 GB").arg(static_cast<double>(bytes) / GB, 0, 'f', 2);
 }