fix/修复启动页文本重叠

dev
jiangyini 4 weeks ago
parent 7be09df318
commit 03f8479d95

@ -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);

@ -23,13 +23,18 @@
#ifndef GUI_SPLASHSCREEN_H
#define GUI_SPLASHSCREEN_H
#include "FCGlobal.h"
#include <QSplashScreen>
#include <QString>
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

@ -10,6 +10,7 @@ add_executable(Gui_tests_run
StyleParameters/ParserTest.cpp
StyleParameters/ParameterManagerTest.cpp
InputHintTest.cpp
SplashScreen.cpp
)
# Qt tests

@ -0,0 +1,18 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <gtest/gtest.h>
#include <Gui/SplashScreen.h>
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")));
}
Loading…
Cancel
Save