Use Application::getExecutableName() instead of Config()["ExeName"]

This commit is contained in:
wmayer
2025-05-10 17:05:11 +02:00
committed by Ladislav Michl
parent 4f116d8de3
commit cda2b8cbdb
8 changed files with 17 additions and 18 deletions

View File

@@ -1320,7 +1320,7 @@ void Application::addImportType(const char* filter, const char* moduleName)
// Due to branding stuff replace "FreeCAD" with the branded application name
if (strncmp(filter, "FreeCAD", 7) == 0) {
std::string AppName = Config()["ExeName"];
std::string AppName = getExecutableName();
AppName += item.filter.substr(7);
item.filter = std::move(AppName);
// put to the front of the array
@@ -1436,7 +1436,7 @@ void Application::addExportType(const char* filter, const char* moduleName)
// Due to branding stuff replace "FreeCAD" with the branded application name
if (strncmp(filter, "FreeCAD", 7) == 0) {
std::string AppName = Config()["ExeName"];
std::string AppName = getExecutableName();
AppName += item.filter.substr(7);
item.filter = std::move(AppName);
// put to the front of the array

View File

@@ -1976,8 +1976,8 @@ void MainWindow::switchToDockedMode()
void MainWindow::loadWindowSettings()
{
QString vendor = QString::fromUtf8(App::Application::Config()["ExeVendor"].c_str());
QString application = QString::fromUtf8(App::Application::Config()["ExeName"].c_str());
QString vendor = QString::fromStdString(App::Application::Config()["ExeVendor"]);
QString application = QString::fromStdString(App::Application::getExecutableName());
int major = (QT_VERSION >> 0x10) & 0xff;
int minor = (QT_VERSION >> 0x08) & 0xff;
QString qtver = QStringLiteral("Qt%1.%2").arg(major).arg(minor);

View File

@@ -104,7 +104,7 @@ int main(int argc, char** argv)
exit(0);
}
catch (const Base::Exception& e) {
std::string appName = App::Application::Config()["ExeName"];
std::string appName = App::Application::getExecutableName();
std::cout << "While initializing " << appName << " the following exception occurred: '"
<< e.what() << "'\n\n";
std::cout << "Python is searching for its runtime files in the following directories:\n"
@@ -123,7 +123,7 @@ int main(int argc, char** argv)
exit(100);
}
catch (...) {
std::string appName = App::Application::Config()["ExeName"];
std::string appName = App::Application::getExecutableName();
std::cout << "Unknown runtime error occurred while initializing " << appName << ".\n\n";
std::cout << "Please contact the application's support team for more information.";
std::cout << std::endl;

View File

@@ -104,7 +104,7 @@ static bool inGuiMode()
static void displayInfo(const QString& msg, bool preformatted = true)
{
if (inGuiMode()) {
QString appName = QString::fromStdString(App::Application::Config()["ExeName"]);
QString appName = QString::fromStdString(App::Application::getExecutableName());
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setWindowTitle(appName);
@@ -120,7 +120,7 @@ static void displayInfo(const QString& msg, bool preformatted = true)
static void displayCritical(const QString& msg, bool preformatted = true)
{
if (inGuiMode()) {
QString appName = QString::fromStdString(App::Application::Config()["ExeName"]);
QString appName = QString::fromStdString(App::Application::getExecutableName());
QString title = QObject::tr("Initialization of %1 failed").arg(appName);
QString text = preformatted ? QStringLiteral("<pre>%1</pre>").arg(msg) : msg;
QMessageBox::critical(nullptr, title, text);
@@ -278,7 +278,7 @@ int main(int argc, char** argv)
catch (const Base::Exception& e) {
// Popup an own dialog box instead of that one of Windows
QApplication app(argc, argv);
QString appName = QString::fromStdString(App::Application::Config()["ExeName"]);
QString appName = QString::fromStdString(App::Application::getExecutableName());
QString msg;
msg = QObject::tr(
"While initializing %1 the following exception occurred: '%2'\n\n"
@@ -312,7 +312,7 @@ int main(int argc, char** argv)
catch (...) {
// Popup an own dialog box instead of that one of Windows
QApplication app(argc, argv);
QString appName = QString::fromStdString(App::Application::Config()["ExeName"]);
QString appName = QString::fromStdString(App::Application::getExecutableName());
QString msg = QObject::tr(
"Unknown runtime error occurred while initializing %1.\n\n"
"Please contact the application's support team for more information.\n\n"
@@ -359,12 +359,12 @@ int main(int argc, char** argv)
std::cerr.rdbuf(oldcerr);
// Destruction phase ===========================================================
Base::Console().log("%s terminating...\n", App::Application::Config()["ExeName"].c_str());
Base::Console().log("%s terminating...\n", App::Application::getExecutableName().c_str());
// cleans up
App::Application::destruct();
Base::Console().log("%s completely terminated\n", App::Application::Config()["ExeName"].c_str());
Base::Console().log("%s completely terminated\n", App::Application::getExecutableName().c_str());
return 0;
}

View File

@@ -167,7 +167,7 @@ PyMOD_INIT_FUNC(FreeCAD)
App::Application::init(argc, argv.data());
}
catch (const Base::Exception& e) {
std::string appName = App::Application::Config()["ExeName"];
std::string appName = App::Application::getExecutableName();
std::cout << "While initializing " << appName << " the following exception occurred: '"
<< e.what() << "'\n\n";
std::cout << "Please contact the application's support team for more information."

View File

@@ -1568,7 +1568,7 @@ void Material::save(QTextStream& stream, bool overwrite, bool saveAsCopy, bool s
}
stream << "---\n";
stream << "# File created by " << QString::fromStdString(App::Application::Config()["ExeName"])
stream << "# File created by " << QString::fromStdString(App::Application::getExecutableName())
<< " " << QString::fromStdString(App::Application::Config()["ExeVersion"])
<< " Revision: " << QString::fromStdString(App::Application::Config()["BuildRevision"])
<< "\n";

View File

@@ -267,9 +267,9 @@ private:
std::unique_ptr<Exporter> exporter;
if (exportFormat == MeshIO::AMF) {
std::map<std::string, std::string> meta;
meta["cad"] = App::Application::Config()["ExeName"] + " "
meta["cad"] = App::Application::getExecutableName() + " "
+ App::Application::Config()["ExeVersion"];
meta[App::Application::Config()["ExeName"] + "-buildRevisionHash"]
meta[App::Application::getExecutableName() + "-buildRevisionHash"]
= App::Application::Config()["BuildRevisionHash"];
exporter = std::make_unique<ExporterAMF>(outputFileName, meta, exportAmfCompressed);

View File

@@ -57,7 +57,6 @@ void FirstStartWidget::setupUi()
{
auto outerLayout = gsl::owner<QVBoxLayout*>(new QVBoxLayout(this));
outerLayout->setAlignment(Qt::AlignCenter);
QString application = QString::fromUtf8(App::Application::Config()["ExeName"].c_str());
_welcomeLabel = gsl::owner<QLabel*>(new QLabel);
outerLayout->addWidget(_welcomeLabel);
_descriptionLabel = gsl::owner<QLabel*>(new QLabel);
@@ -90,7 +89,7 @@ bool FirstStartWidget::eventFilter(QObject* object, QEvent* event)
void FirstStartWidget::retranslateUi()
{
_doneButton->setText(tr("Done"));
QString application = QString::fromUtf8(App::Application::Config()["ExeName"].c_str());
QString application = QString::fromStdString(App::Application::getExecutableName());
_welcomeLabel->setText(
QLatin1String("<h1>") + tr("Welcome to %1").arg(application) + QLatin1String("</h1>")
);