Modify Branding of FreeCAD
This article describes the Branding of FreeCAD. Branding means to start your own application based on FreeCAD. That can be only your own executable or splash screen till a complete reworked program. Based on the flexible architecture of FreeCAD it’s easy to use it as base for your own special purpose program.
本文主要描述如何修改FreeCAD的Branding,從而使自己能基于FreeCAD靈活的架構(gòu)快速開發(fā)出自己的應(yīng)用程序。通過修改FreeCAD的Branding甚至啟動(dòng)畫面,從而使程序看上去更像是自己開發(fā)的。
Branding信息主要在文件MainCmd.cpp和MainGrui.cpp中,這兩個(gè)工程生成了FreeCAD可執(zhí)行文件。
可以通過修改相關(guān)字符串,可以給可執(zhí)行程序一個(gè)自己的名字,或者版本信息等的自定義,還有啟動(dòng)畫面的自定義。
{
// Name and Version of the Application
App::Application::Config()["ExeName"] = "FooApp";
App::Application::Config()["ExeVersion"] = "0.7";
// set the banner (for loging and console)
App::Application::Config()["CopyrightInfo"] = sBanner;
App::Application::Config()["AppIcon"] = "FooAppIcon";
App::Application::Config()["SplashScreen"] = "FooAppSplasher";
App::Application::Config()["StartWorkbench"] = "Part design";
App::Application::Config()["HiddenDockWindow"] = "Property editor";
App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
App::Application::Config()["SplashTextColor" ] = "#000000"; // black
// Inits the Application
App::Application::Config()["RunMode"] = "Gui";
App::Application::init(argc,argv);
Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);
Gui::Application::initApplication();
Gui::Application::runApplication();
App::Application::destruct();
return 0;
}
圖片數(shù)據(jù)通過使用Qt的資源系統(tǒng)來編譯到FreeCAD中去的。所以你需要寫一個(gè).qrc文件,將資源加到這個(gè)類似XML的qrc文件中。在程序中使用資源,需要在main()中添加下面一行:
如果你有XPM格式的圖片,則可以直接使用:
改后效果如下圖所示: