From ea49b3fe788769c46410859529a804c99869bb16 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Thu, 3 Aug 2023 22:59:34 -0600 Subject: [PATCH] GUI: Add prominent dev build indicators --- CMakeLists.txt | 2 +- src/App/Application.cpp | 7 +++++-- src/Build/Version.h.cmake | 9 +++++---- src/Gui/Application.cpp | 3 ++- src/Gui/MainWindow.cpp | 32 +++++++++++++++++++++++++++++++- src/Gui/MainWindow.h | 2 ++ src/Gui/Splashscreen.cpp | 6 ++++-- 7 files changed, 50 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d06bf39c038..d1536fbc7297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ project(FreeCAD) set(PACKAGE_VERSION_NAME "Vulcan") set(PACKAGE_VERSION_MAJOR "0") -set(PACKAGE_VERSION_MINOR "21") +set(PACKAGE_VERSION_MINOR "22") set(PACKAGE_VERSION_PATCH "0") # number of patch release (e.g. "4" for the 0.18.4 release) set(PACKAGE_VERSION_SUFFIX "dev") # either "dev" for development snapshot or "" (empty string) set(PACKAGE_BUILD_VERSION "0") # used when the same FreeCAD version will be re-released (for example using an updated LibPack) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 151a379ae034..058385e64f6d 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -2478,6 +2478,7 @@ void Application::initConfig(int argc, char ** argv) App::Application::Config()["BuildVersionMajor" ] = FCVersionMajor; App::Application::Config()["BuildVersionMinor" ] = FCVersionMinor; App::Application::Config()["BuildVersionPoint" ] = FCVersionPoint; + App::Application::Config()["BuildVersionSuffix" ] = FCVersionSuffix; App::Application::Config()["BuildRevision" ] = FCRevision; App::Application::Config()["BuildRepositoryURL" ] = FCRepositoryURL; App::Application::Config()["BuildRevisionDate" ] = FCRevisionDate; @@ -2557,21 +2558,23 @@ void Application::initConfig(int argc, char ** argv) // Remove banner if FreeCAD is invoked via the -c command as regular // Python interpreter if (!(mConfig["Verbose"] == "Strict")) - Base::Console().Message("%s %s, Libs: %s.%s.%sR%s\n%s", + Base::Console().Message("%s %s, Libs: %s.%s.%s%sR%s\n%s", mConfig["ExeName"].c_str(), mConfig["ExeVersion"].c_str(), mConfig["BuildVersionMajor"].c_str(), mConfig["BuildVersionMinor"].c_str(), mConfig["BuildVersionPoint"].c_str(), + mConfig["BuildVersionSuffix"].c_str(), mConfig["BuildRevision"].c_str(), mConfig["CopyrightInfo"].c_str()); else - Base::Console().Message("%s %s, Libs: %s.%s.%sR%s\n", + Base::Console().Message("%s %s, Libs: %s.%s.%s%sR%s\n", mConfig["ExeName"].c_str(), mConfig["ExeVersion"].c_str(), mConfig["BuildVersionMajor"].c_str(), mConfig["BuildVersionMinor"].c_str(), mConfig["BuildVersionPoint"].c_str(), + mConfig["BuildVersionSuffix"].c_str(), mConfig["BuildRevision"].c_str()); } LoadParameters(); diff --git a/src/Build/Version.h.cmake b/src/Build/Version.h.cmake index 71abdd481389..eda5cec5ef55 100644 --- a/src/Build/Version.h.cmake +++ b/src/Build/Version.h.cmake @@ -1,9 +1,10 @@ // Version Number -#define FCVersionMajor "${PACKAGE_VERSION_MAJOR}" -#define FCVersionMinor "${PACKAGE_VERSION_MINOR}" -#define FCVersionName "${PACKAGE_VERSION_NAME}" -#define FCVersionPoint "${PACKAGE_VERSION_PATCH}" +#define FCVersionMajor "${PACKAGE_VERSION_MAJOR}" +#define FCVersionMinor "${PACKAGE_VERSION_MINOR}" +#define FCVersionName "${PACKAGE_VERSION_NAME}" +#define FCVersionPoint "${PACKAGE_VERSION_PATCH}" +#define FCVersionSuffix "${PACKAGE_VERSION_SUFFIX}" // test: $Format:Hash (%H), Date: %ci$ #define FCRevision "${PACKAGE_WCREF}" //Highest committed revision number #define FCRevisionDate "${PACKAGE_WCDATE}" //Date of highest committed revision diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index d2a7e94e3dd8..a39c4ddef557 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -2129,8 +2129,9 @@ void Application::runApplication() QString major = QString::fromLatin1(config["BuildVersionMajor"].c_str()); QString minor = QString::fromLatin1(config["BuildVersionMinor"].c_str()); QString point = QString::fromLatin1(config["BuildVersionPoint"].c_str()); + QString suffix = QString::fromLatin1(config["BuildVersionSuffix"].c_str()); QString title = - QString::fromLatin1("%1 %2.%3.%4").arg(mainApp.applicationName(), major, minor, point); + QString::fromLatin1("%1 %2.%3.%4%5").arg(mainApp.applicationName(), major, minor, point, suffix); mw.setWindowTitle(title); } else { diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index ae05af157fc3..61196609f83f 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1691,6 +1691,32 @@ QPixmap MainWindow::aboutImage() const return about_image; } +void MainWindow::RenderDevBuildWarning(QPainter &painter, int x, int y) const +{ + // Create a background box that fades out the artwork for better legibility + QColor fader (Qt::black); + const float halfDensity (0.5); + fader.setAlphaF(halfDensity); + QBrush fillBrush(fader, Qt::BrushStyle::SolidPattern); + painter.setBrush(fillBrush); + + // Construct the lines of text and figure out how much space they need + auto devWarningLine1 = tr("WARNING: This is a development version."); + auto devWarningLine2 = tr("Please do not use in a production environment."); + QFontMetrics fontMetrics(painter.font()); + int padding = QtTools::horizontalAdvance(fontMetrics, QLatin1String("M")); // Arbitrary + int line1Width = QtTools::horizontalAdvance(fontMetrics, devWarningLine1); + int line2Width = QtTools::horizontalAdvance(fontMetrics, devWarningLine2); + int boxWidth = std::max(line1Width,line2Width) + 2 * padding; + int lineHeight = fontMetrics.lineSpacing(); + int boxHeight = static_cast(lineHeight*2.3); + + // Draw the background rectangle and the text + painter.drawRect(x, y, boxWidth, boxHeight); + painter.drawText(x+padding, y+lineHeight, devWarningLine1); + painter.drawText(x+padding, y+2*lineHeight, devWarningLine2); +} + QPixmap MainWindow::splashImage() const { // search in the UserAppData dir as very first @@ -1731,7 +1757,8 @@ QPixmap MainWindow::splashImage() const QString major = QString::fromLatin1(App::Application::Config()["BuildVersionMajor"].c_str()); QString minor = QString::fromLatin1(App::Application::Config()["BuildVersionMinor"].c_str()); QString point = QString::fromLatin1(App::Application::Config()["BuildVersionPoint"].c_str()); - QString version = QString::fromLatin1("%1.%2.%3").arg(major, minor, point); + QString suffix = QString::fromLatin1(App::Application::Config()["BuildVersionSuffix"].c_str()); + QString version = QString::fromLatin1("%1.%2.%3%4").arg(major, minor, point, suffix); QString position, fontFamily; std::map::const_iterator te = App::Application::Config().find("SplashInfoExeName"); @@ -1793,6 +1820,9 @@ QPixmap MainWindow::splashImage() const } painter.setFont(fontVer); painter.drawText(x + (l + 5), y, version); + if (suffix == QLatin1String("dev")) { + RenderDevBuildWarning(painter, x + l + 5, y + 10); + } painter.end(); } } diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index ca40c48b9fac..ab9fb8752885 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -292,6 +292,8 @@ public Q_SLOTS: bool setupReportView(const std::string&); bool setupPythonConsole(const std::string&); + void RenderDevBuildWarning(QPainter &painter, int x, int y) const; + private Q_SLOTS: /** * \internal diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 9bd14e1fc675..1f2a6e355a02 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -375,6 +375,7 @@ void AboutDialog::setupLabels() QString major = QString::fromLatin1(config["BuildVersionMajor"].c_str()); QString minor = QString::fromLatin1(config["BuildVersionMinor"].c_str()); QString point = QString::fromLatin1(config["BuildVersionPoint"].c_str()); + QString suffix = QString::fromLatin1(config["BuildVersionSuffix"].c_str()); QString build = QString::fromLatin1(config["BuildRevision"].c_str()); QString disda = QString::fromLatin1(config["BuildRevisionDate"].c_str()); QString mturl = QString::fromLatin1(config["MaintainerUrl"].c_str()); @@ -393,7 +394,7 @@ void AboutDialog::setupLabels() } QString version = ui->labelBuildVersion->text(); - version.replace(QString::fromLatin1("Unknown"), QString::fromLatin1("%1.%2.%3").arg(major, minor, point)); + version.replace(QString::fromLatin1("Unknown"), QString::fromLatin1("%1.%2.%3%4").arg(major, minor, point, suffix)); ui->labelBuildVersion->setText(version); QString revision = ui->labelBuildRevision->text(); @@ -787,6 +788,7 @@ void AboutDialog::copyToClipboard() QString major = QString::fromLatin1(config["BuildVersionMajor"].c_str()); QString minor = QString::fromLatin1(config["BuildVersionMinor"].c_str()); QString point = QString::fromLatin1(config["BuildVersionPoint"].c_str()); + QString suffix = QString::fromLatin1(config["BuildVersionSuffix"].c_str()); QString build = QString::fromLatin1(config["BuildRevision"].c_str()); QString deskEnv = QProcessEnvironment::systemEnvironment().value(QStringLiteral("XDG_CURRENT_DESKTOP"), QString()); @@ -803,7 +805,7 @@ void AboutDialog::copyToClipboard() str << "[code]\n"; str << "OS: " << prettyProductInfoWrapper() << deskInfo << '\n'; str << "Word size of " << exe << ": " << QSysInfo::WordSize << "-bit\n"; - str << "Version: " << major << "." << minor << "." << point << "." << build; + str << "Version: " << major << "." << minor << "." << point << suffix << "." << build; char *appimage = getenv("APPIMAGE"); if (appimage) str << " AppImage";