Skip to content

Commit

Permalink
GUI: Add prominent dev build indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
chennes committed Aug 5, 2023
1 parent 16e083c commit ea49b3f
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions src/Build/Version.h.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/Gui/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
32 changes: 31 additions & 1 deletion src/Gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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
Expand Down Expand Up @@ -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<std::string,std::string>::const_iterator te = App::Application::Config().find("SplashInfoExeName");
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/Gui/Splashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
Expand Down Expand Up @@ -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());
Expand All @@ -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";
Expand Down

0 comments on commit ea49b3f

Please sign in to comment.