Branding

From FreeCAD Documentation
Revision as of 09:55, 15 March 2019 by Gnrc (talk | contribs) (Created page with "{{docnav/fr|Intégration continue|Localisation}}")

Cet article décrit l'image de marque de FreeCAD. Branding, est le moyen de lancer votre propre application, sur les bases de FreeCAD.

Cela ne concerne que votre propre exécutable, ou, votre écran de démarrage (splash screen) ou jusqu'à ce que le programme complet soit retravaillé (refonte totale).

Grâce aux bases très souples de l'architecture de FreeCAD, il est très facile de l'utiliser, comme fondation pour votre programme personnalisé, ou pour une utilisation spécifique.

Generalités

La plupart des marques (branding) se font dans MainCmd.cpp, ou, MainGui.cpp. Ces projets génèrent les fichiers exécutables de FreeCAD.

Pour faire votre propre marque (branding), il suffit de copier Main (les projets principaux) ou MainGui (les projets graphiques GUI), et donner à l'exécutable un nom qui vous est propre, pour notre exemple, FooApp.exe. Les paramètres les plus importants pour un nouveau look, ne peuvent être fait qu'en un seul endroit, dans la fonction main().

Voici la section de code qui contrôle la marque (branding) :

 int main( int argc, char ** argv )
 {
   // 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;
 }

La première entrée, ::Config définit le nom du programme ici, "FooApp.exe". Ce n'est pas le nom de l'exécutable qui peut être modifié en le renommant, ou par les paramètres du compilateur, mais le nom qui est affiché dans la barre des tâches sur les fenêtres, ou dans la liste des programmes sur les systèmes Unix.

Les lignes suivantes définissent les entrées de configuration de votre application "FooApp", une description de la configuration, et de ses entrées, que vous trouverez dans Start up and Configuration.

Images

Image resources are compiled into FreeCAD using Qt's resource system. Therefore you have to write a .qrc file, an XML-based file format that lists image files on the disk but also any other kind of resource files. To load the compiled resources inside the application you have to add a line

Q_INIT_RESOURCE(FooApp);

into the main() function. Alternatively, if you have an image in XPM format you can directly include it into your main.cpp and add the following line to register it:

Gui::BitmapFactory().addXPM("FooAppSplasher", ( const char** ) splash_screen);

Branding XML

In FreeCAD there is also a method supported without writing a customized main() function. For this method you must write a file name called branding.xml and put it into the installation directory of FreeCAD. Here is an example with all supported tags:

 <?xml version="1.0" encoding="utf-8"?>
 <Branding>
 	<Application>FooApp</Application>
 	<WindowTitle>Foo App in title bar</WindowTitle>
 	<BuildVersionMajor>1</BuildVersionMajor>
 	<BuildVersionMinor>0</BuildVersionMinor>
 	<BuildRevision>1234</BuildRevision>
 	<BuildRevisionDate>2014/1/1</BuildRevisionDate>
 	<CopyrightInfo>(c) My copyright</CopyrightInfo>
 	<MaintainerUrl>Foo App URL</MaintainerUrl>
 	<ProgramLogo>Path to logo (appears in bottom right corner)</ProgramLogo>
 	<WindowIcon>Path to icon file</WindowIcon>
 	<ProgramIcons>Path to program icons</ProgramIcons>
 	<SplashScreen>splashscreen.png</SplashScreen>
 	<SplashAlignment>Bottom|Left</SplashAlignment>
 	<SplashTextColor>#ffffff</SplashTextColor>
 	<SplashInfoColor>#c8c8c8</SplashInfoColor>
 	<StartWorkbench>PartDesignWorkbench</StartWorkbench>
 </Branding>

All of the listed tags are optional.