From 03f8479d95a30022bda6adac3b0afb110b4dd93a Mon Sep 17 00:00:00 2001 From: chensiming Date: Fri, 29 May 2026 09:03:51 +0800 Subject: [PATCH] =?UTF-8?q?fix/=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=A1=B5=E6=96=87=E6=9C=AC=E9=87=8D=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gui/SplashScreen.cpp | 14 ++++++++++++-- src/Gui/SplashScreen.h | 5 +++++ tests/src/Gui/CMakeLists.txt | 1 + tests/src/Gui/SplashScreen.cpp | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/src/Gui/SplashScreen.cpp diff --git a/src/Gui/SplashScreen.cpp b/src/Gui/SplashScreen.cpp index 7006911..d94ada2 100644 --- a/src/Gui/SplashScreen.cpp +++ b/src/Gui/SplashScreen.cpp @@ -47,6 +47,16 @@ using namespace Gui; namespace Gui { +bool shouldDrawSplashScreenTitle(const QString& title) +{ + QString compactTitle = title; + compactTitle.remove(QRegularExpression(QStringLiteral("\\s"))); + compactTitle = compactTitle.toCaseFolded(); + + return compactTitle != QLatin1String("freecad") + && compactTitle != QLatin1String("lightworks3d"); +} + /** Displays all messages at startup inside the splash screen. * \author Werner Mayer */ @@ -387,8 +397,8 @@ QPixmap SplashScreen::splashImage() if (color.isValid()) { painter.setPen(color); painter.setFont(fontExe); - if (title != QLatin1String("FreeCAD")) { - // FreeCAD's Splashscreen already contains the EXE name, no need to draw it + if (shouldDrawSplashScreenTitle(title)) { + // Some splashscreen graphics already contain the EXE name, no need to draw it. painter.drawText(x, y, title); } painter.setFont(fontVer); diff --git a/src/Gui/SplashScreen.h b/src/Gui/SplashScreen.h index 4310abe..6f6e161 100644 --- a/src/Gui/SplashScreen.h +++ b/src/Gui/SplashScreen.h @@ -23,13 +23,18 @@ #ifndef GUI_SPLASHSCREEN_H #define GUI_SPLASHSCREEN_H +#include "FCGlobal.h" + #include +#include namespace Gui { class SplashObserver; +GuiExport bool shouldDrawSplashScreenTitle(const QString& title); + /** This widget provides a splash screen that can be shown during application startup. * * \author Werner Mayer diff --git a/tests/src/Gui/CMakeLists.txt b/tests/src/Gui/CMakeLists.txt index d0ce6af..d4dd8c2 100644 --- a/tests/src/Gui/CMakeLists.txt +++ b/tests/src/Gui/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(Gui_tests_run StyleParameters/ParserTest.cpp StyleParameters/ParameterManagerTest.cpp InputHintTest.cpp + SplashScreen.cpp ) # Qt tests diff --git a/tests/src/Gui/SplashScreen.cpp b/tests/src/Gui/SplashScreen.cpp new file mode 100644 index 0000000..4ba4176 --- /dev/null +++ b/tests/src/Gui/SplashScreen.cpp @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later + +#include + +#include + +TEST(SplashScreen, doesNotDrawBundledBrandTitles) +{ + EXPECT_FALSE(Gui::shouldDrawSplashScreenTitle(QStringLiteral("FreeCAD"))); + EXPECT_FALSE(Gui::shouldDrawSplashScreenTitle(QStringLiteral("Light works 3D"))); + EXPECT_FALSE(Gui::shouldDrawSplashScreenTitle(QStringLiteral("LightWorks3D"))); + EXPECT_FALSE(Gui::shouldDrawSplashScreenTitle(QStringLiteral("lightworks3D"))); +} + +TEST(SplashScreen, drawsCustomBrandTitles) +{ + EXPECT_TRUE(Gui::shouldDrawSplashScreenTitle(QStringLiteral("CustomCAD"))); +}