From: Shane Jaroch Date: Wed, 21 Jan 2026 21:20:40 +0000 (-0500) Subject: lint & ui tweaks/stuff X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=9c7d0efbbaf680cd38f46b863a4e7686899f46e0;p=nutratech%2Fgui.git lint & ui tweaks/stuff --- diff --git a/include/widgets/preferencesdialog.h b/include/widgets/preferencesdialog.h index 47921f0..644a54f 100644 --- a/include/widgets/preferencesdialog.h +++ b/include/widgets/preferencesdialog.h @@ -15,7 +15,7 @@ public: private: void setupUi(); void loadStatistics(); - QString formatBytes(qint64 bytes) const; + [[nodiscard]] QString formatBytes(qint64 bytes) const; QTabWidget* tabWidget; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 98205bb..26e5410 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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", + "

GNU General Public License v3.0

" + "

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.

" + "

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.

" + "

See " + "https://www.gnu.org/licenses/gpl-3.0.html for details.

"); }); + 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("

Nutrient Coach %1

" - "

A C++/Qt application for tracking nutrition.

" + "

This application is a tool designed not as a weight-loss app " + "but as 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.

" "

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

") diff --git a/src/widgets/preferencesdialog.cpp b/src/widgets/preferencesdialog.cpp index 10e56db..eba3c4a 100644 --- a/src/widgets/preferencesdialog.cpp +++ b/src/widgets/preferencesdialog.cpp @@ -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(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(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(bytes) / KB, 0, 'f', 1); + if (bytes < GB) return QString("%1 MB").arg(static_cast(bytes) / MB, 0, 'f', 2); + return QString("%1 GB").arg(static_cast(bytes) / GB, 0, 'f', 2); }