Extend application branding
This commit is contained in:
parent
68c9d5e0fb
commit
d6511969cd
|
@ -1095,7 +1095,7 @@ void Application::initConfig(int argc, char ** argv)
|
|||
mConfig["BuildVersionMajor"].c_str(),
|
||||
mConfig["BuildVersionMinor"].c_str(),
|
||||
mConfig["BuildRevision"].c_str(),
|
||||
mConfig["ConsoleBanner"].c_str());
|
||||
mConfig["CopyrightInfo"].c_str());
|
||||
else
|
||||
Console().Message("%s %s, Libs: %s.%sB%s\n",mConfig["ExeName"].c_str(),
|
||||
mConfig["ExeVersion"].c_str(),
|
||||
|
|
|
@ -77,6 +77,10 @@ BitmapFactoryInst& BitmapFactoryInst::instance(void)
|
|||
if (_pcSingleton == NULL)
|
||||
{
|
||||
_pcSingleton = new BitmapFactoryInst;
|
||||
std::map<std::string,std::string>::const_iterator it;
|
||||
it = App::GetApplication().Config().find("ProgramIcons");
|
||||
if (it != App::GetApplication().Config().end())
|
||||
_pcSingleton->addPath(QString::fromUtf8(it->second.c_str()));
|
||||
_pcSingleton->addPath(QLatin1String(":/icons/"));
|
||||
_pcSingleton->addPath(QLatin1String(":/Icons/"));
|
||||
_pcSingleton->addPath(QString::fromUtf8(App::GetApplication().GetHomePath()));
|
||||
|
|
|
@ -193,7 +193,7 @@ Action * StdCmdAbout::createAction(void)
|
|||
|
||||
QString exe;
|
||||
std::map<std::string,std::string>& cfg = App::Application::Config();
|
||||
std::map<std::string,std::string>::iterator it = cfg.find("WindowTitle");
|
||||
std::map<std::string,std::string>::iterator it = cfg.find("Application");
|
||||
if (it != cfg.end())
|
||||
exe = QString::fromUtf8(it->second.c_str());
|
||||
else
|
||||
|
@ -235,7 +235,7 @@ void StdCmdAbout::languageChange()
|
|||
if (_pcAction) {
|
||||
QString exe;
|
||||
std::map<std::string,std::string>& cfg = App::Application::Config();
|
||||
std::map<std::string,std::string>::iterator it = cfg.find("WindowTitle");
|
||||
std::map<std::string,std::string>::iterator it = cfg.find("Application");
|
||||
if (it != cfg.end())
|
||||
exe = QString::fromUtf8(it->second.c_str());
|
||||
else
|
||||
|
|
|
@ -1303,12 +1303,15 @@ QPixmap MainWindow::splashImage() const
|
|||
if (fi.isFile() && fi.exists())
|
||||
splash_image.load(fi.filePath(), "PNG");
|
||||
if (splash_image.isNull())
|
||||
splash_image = Gui::BitmapFactory().pixmap(App::Application::Config()["SplashPicture"].c_str());
|
||||
splash_image = Gui::BitmapFactory().pixmap(App::Application::Config()["SplashScreen"].c_str());
|
||||
|
||||
// include application name and version number
|
||||
std::map<std::string,std::string>::const_iterator tc = App::Application::Config().find("SplashExeColor");
|
||||
std::map<std::string,std::string>::const_iterator tc = App::Application::Config().find("SplashInfoColor");
|
||||
if (tc != App::Application::Config().end()) {
|
||||
QString exeName = QString::fromAscii(App::Application::Config()["ExeName"].c_str());
|
||||
QString title = QString::fromAscii(App::Application::Config()["ExeName"].c_str());
|
||||
std::map<std::string,std::string>::iterator it = App::Application::Config().find("Application");
|
||||
if (it != App::Application::Config().end())
|
||||
title = QString::fromUtf8(it->second.c_str());
|
||||
QString major = QString::fromAscii(App::Application::Config()["BuildVersionMajor"].c_str());
|
||||
QString minor = QString::fromAscii(App::Application::Config()["BuildVersionMinor"].c_str());
|
||||
QString version = QString::fromAscii("%1.%2").arg(major).arg(minor);
|
||||
|
@ -1318,7 +1321,7 @@ QPixmap MainWindow::splashImage() const
|
|||
QFont fontExe = painter.font();
|
||||
fontExe.setPointSize(20);
|
||||
QFontMetrics metricExe(fontExe);
|
||||
int l = metricExe.width(exeName);
|
||||
int l = metricExe.width(title);
|
||||
int w = splash_image.width();
|
||||
int h = splash_image.height();
|
||||
|
||||
|
@ -1329,17 +1332,14 @@ QPixmap MainWindow::splashImage() const
|
|||
|
||||
QColor color;
|
||||
color.setNamedColor(QString::fromAscii(tc->second.c_str()));
|
||||
if (!color.isValid()) {
|
||||
color.setRed(200);
|
||||
color.setGreen(200);
|
||||
color.setBlue(200);
|
||||
if (color.isValid()) {
|
||||
painter.setPen(color);
|
||||
painter.setFont(fontExe);
|
||||
painter.drawText(w-(l+v+10),h-20, title);
|
||||
painter.setFont(fontVer);
|
||||
painter.drawText(w-(v+5),h-20, version);
|
||||
painter.end();
|
||||
}
|
||||
painter.setPen(color);
|
||||
painter.setFont(fontExe);
|
||||
painter.drawText(w-(l+v+10),h-20, exeName);
|
||||
painter.setFont(fontVer);
|
||||
painter.drawText(w-(v+5),h-20, version);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
return splash_image;
|
||||
|
|
|
@ -715,6 +715,8 @@ void NavigationStyle::zoomByCursor(const SbVec2f & thispos, const SbVec2f & prev
|
|||
|
||||
void NavigationStyle::doZoom(SoCamera* camera, SbBool forward, const SbVec2f& pos)
|
||||
{
|
||||
if (this->button3down)
|
||||
return;
|
||||
SbBool zoomAtCur = this->zoomAtCursor;
|
||||
if (zoomAtCur) {
|
||||
const SbViewportRegion & vp = viewer->getViewportRegion();
|
||||
|
|
|
@ -256,7 +256,7 @@ void AboutDialog::setupLabels()
|
|||
std::map<std::string,std::string>::iterator it = config.find("WindowTitle");
|
||||
if (it != config.end())
|
||||
exeName = QString::fromUtf8(it->second.c_str());
|
||||
QString banner = QString::fromUtf8(config["ConsoleBanner"].c_str());
|
||||
QString banner = QString::fromUtf8(config["CopyrightInfo"].c_str());
|
||||
banner = banner.left( banner.indexOf(QLatin1Char('\n')) );
|
||||
QString major = QString::fromAscii(config["BuildVersionMajor"].c_str());
|
||||
QString minor = QString::fromAscii(config["BuildVersionMinor"].c_str());
|
||||
|
@ -266,7 +266,7 @@ void AboutDialog::setupLabels()
|
|||
|
||||
QString author = ui->labelAuthor->text();
|
||||
author.replace(QString::fromAscii("Unknown Application"), exeName);
|
||||
author.replace(QString::fromAscii("Unknown Author"), banner);
|
||||
author.replace(QString::fromAscii("(c) Unknown Author"), banner);
|
||||
ui->labelAuthor->setText(author);
|
||||
ui->labelAuthor->setUrl(mturl);
|
||||
|
||||
|
|
|
@ -303,8 +303,8 @@ PyMODINIT_FUNC initFreeCADGui()
|
|||
try {
|
||||
Base::Interpreter().loadModule("FreeCAD");
|
||||
App::Application::Config()["AppIcon"] = "freecad";
|
||||
App::Application::Config()["SplashPicture"] = "freecadsplash";
|
||||
App::Application::Config()["ConsoleBanner"] = "\xc2\xa9 Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2011\n";
|
||||
App::Application::Config()["SplashScreen"] = "freecadsplash";
|
||||
App::Application::Config()["CopyrightInfo"] = "\xc2\xa9 Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2011\n";
|
||||
Gui::Application::initApplication();
|
||||
Py_InitModule("FreeCADGui", FreeCADGui_methods);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ int main( int argc, char ** argv )
|
|||
App::Application::Config()["AppDataSkipVendor"] = "true";
|
||||
|
||||
// set the banner (for logging and console)
|
||||
App::Application::Config()["ConsoleBanner"] = sBanner;
|
||||
App::Application::Config()["CopyrightInfo"] = sBanner;
|
||||
|
||||
try {
|
||||
// Init phase ===========================================================
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
# include <config.h>
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <cstdio>
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
|
@ -74,16 +78,31 @@ const char sBanner[] = "\xc2\xa9 Juergen Riegel, Werner Mayer, Yorik van Havre 2
|
|||
class Branding
|
||||
{
|
||||
public:
|
||||
struct UserDefines
|
||||
{
|
||||
std::string windowTitle;
|
||||
std::string windowIcon;
|
||||
std::string programLogo;
|
||||
std::string splashScreen;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::string> XmlConfig;
|
||||
Branding()
|
||||
{
|
||||
filter.push_back("Application");
|
||||
filter.push_back("WindowTitle");
|
||||
filter.push_back("CopyrightInfo");
|
||||
filter.push_back("MaintainerUrl");
|
||||
filter.push_back("WindowIcon");
|
||||
filter.push_back("ProgramLogo");
|
||||
filter.push_back("ProgramIcons");
|
||||
|
||||
filter.push_back("BuildVersionMajor");
|
||||
filter.push_back("BuildVersionMinor");
|
||||
filter.push_back("BuildRevision");
|
||||
filter.push_back("BuildRevisionDate");
|
||||
|
||||
filter.push_back("SplashScreen");
|
||||
filter.push_back("SplashAlignment");
|
||||
filter.push_back("SplashTextColor");
|
||||
filter.push_back("SplashInfoColor");
|
||||
|
||||
filter.push_back("StartWorkbench");
|
||||
|
||||
filter.push_back("ExeName");
|
||||
filter.push_back("ExeVendor");
|
||||
}
|
||||
|
||||
bool readFile(const QString& fn)
|
||||
|
@ -96,29 +115,26 @@ public:
|
|||
file.close();
|
||||
return true;
|
||||
}
|
||||
UserDefines getUserDefines() const
|
||||
XmlConfig getUserDefines() const
|
||||
{
|
||||
UserDefines ud;
|
||||
XmlConfig cfg;
|
||||
QDomElement root = domDocument.documentElement();
|
||||
QDomElement child;
|
||||
if (!root.isNull()) {
|
||||
child = root.firstChildElement(QLatin1String("WindowTitle"));
|
||||
if (!child.isNull())
|
||||
ud.windowTitle = (const char*)child.text().toUtf8();
|
||||
child = root.firstChildElement(QLatin1String("WindowIcon"));
|
||||
if (!child.isNull())
|
||||
ud.windowIcon = (const char*)child.text().toUtf8();
|
||||
child = root.firstChildElement(QLatin1String("ProgramLogo"));
|
||||
if (!child.isNull())
|
||||
ud.programLogo = (const char*)child.text().toUtf8();
|
||||
child = root.firstChildElement(QLatin1String("SplashScreen"));
|
||||
if (!child.isNull())
|
||||
ud.splashScreen = (const char*)child.text().toUtf8();
|
||||
child = root.firstChildElement();
|
||||
while (!child.isNull()) {
|
||||
std::string name = (const char*)child.localName().toAscii();
|
||||
std::string value = (const char*)child.text().toUtf8();
|
||||
if (std::find(filter.begin(), filter.end(), name) != filter.end())
|
||||
cfg[name] = value;
|
||||
child = child.nextSiblingElement();
|
||||
}
|
||||
}
|
||||
return ud;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::string> filter;
|
||||
bool evaluateXML(QIODevice *device, QDomDocument& xmlDocument)
|
||||
{
|
||||
QString errorStr;
|
||||
|
@ -269,14 +285,14 @@ int main( int argc, char ** argv )
|
|||
App::Application::Config()["MaintainerUrl"] = "http://apps.sourceforge.net/mediawiki/free-cad/index.php?title=Main_Page";
|
||||
|
||||
// set the banner (for logging and console)
|
||||
App::Application::Config()["ConsoleBanner"] = sBanner;
|
||||
App::Application::Config()["CopyrightInfo"] = sBanner;
|
||||
App::Application::Config()["AppIcon"] = "freecad";
|
||||
App::Application::Config()["SplashPicture"] = "freecadsplash";
|
||||
App::Application::Config()["SplashScreen"] = "freecadsplash";
|
||||
App::Application::Config()["StartWorkbench"] = "StartWorkbench";
|
||||
//App::Application::Config()["HiddenDockWindow"] = "Property editor";
|
||||
App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
|
||||
App::Application::Config()["SplashTextColor" ] = "#ffffff"; // white
|
||||
App::Application::Config()["SplashExeColor" ] = "#c8c8c8"; // light grey
|
||||
App::Application::Config()["SplashInfoColor" ] = "#c8c8c8"; // light grey
|
||||
|
||||
try {
|
||||
// Init phase ===========================================================
|
||||
|
@ -326,15 +342,10 @@ int main( int argc, char ** argv )
|
|||
QString path = QString::fromUtf8(App::GetApplication().GetHomePath());
|
||||
QFileInfo fi(path, QString::fromAscii("branding.xml"));
|
||||
if (brand.readFile(fi.absoluteFilePath())) {
|
||||
Branding::UserDefines ud = brand.getUserDefines();
|
||||
if (!ud.windowTitle.empty())
|
||||
App::Application::Config()["WindowTitle"] = ud.windowTitle;
|
||||
if (!ud.windowIcon.empty())
|
||||
App::Application::Config()["WindowIcon"] = ud.windowIcon;
|
||||
if (!ud.programLogo.empty())
|
||||
App::Application::Config()["ProgramLogo"] = ud.programLogo;
|
||||
if (!ud.splashScreen.empty())
|
||||
App::Application::Config()["SplashPicture"] = ud.splashScreen;
|
||||
Branding::XmlConfig cfg = brand.getUserDefines();
|
||||
for (Branding::XmlConfig::iterator it = cfg.begin(); it != cfg.end(); ++it) {
|
||||
App::Application::Config()[it->first] = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
// Run phase ===========================================================
|
||||
|
|
23
src/Main/res/branding.xml
Normal file
23
src/Main/res/branding.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Branding>
|
||||
<!-- This is a full list of all elements for the branding. They are all optional.-->
|
||||
<!-- This file must be put into the directory where the application is installed -->
|
||||
<Application>Application</Application>
|
||||
<BuildVersionMajor>1</BuildVersionMajor>
|
||||
<BuildVersionMinor>0</BuildVersionMinor>
|
||||
<BuildRevision>2000</BuildRevision>
|
||||
<WindowTitle>My Application with some text</WindowTitle>
|
||||
<CopyrightInfo>My copyright notice</CopyrightInfo>
|
||||
<MaintainerUrl>http://www.something.com</MaintainerUrl>
|
||||
<StartWorkbench>PartWorkbench</StartWorkbench>
|
||||
<!--
|
||||
<WindowIcon>Path to icon file</WindowIcon>
|
||||
<ProgramLogo>Path to logo (appears in bottom right corner)</ProgramLogo>
|
||||
<SplashScreen>Path to splash screen</SplashScreen>
|
||||
<SplashAlignment>Bottom|Left</SplashAlignment>
|
||||
<SplashTextColor>#ffffff</SplashTextColor>
|
||||
<SplashInfoColor>#c8c8c8</SplashInfoColor>
|
||||
<BuildRevisionDate>01/01/2012</BuildRevisionDate>
|
||||
<ProgramIcons>Path to program icons</ProgramIcons>
|
||||
-->
|
||||
</Branding>
|
|
@ -28,15 +28,21 @@
|
|||
|
||||
// Importing of App classes
|
||||
#ifdef FC_OS_WIN32
|
||||
# define PartExport __declspec(dllimport)
|
||||
# define MeshExport __declspec(dllimport)
|
||||
# define PartExport __declspec(dllimport)
|
||||
# define MeshPartAppExport __declspec(dllimport)
|
||||
# define MeshPartGuiExport __declspec(dllexport)
|
||||
#else // for Linux
|
||||
# define MeshExport
|
||||
# define PartExport
|
||||
# define MeshPartAppExport
|
||||
# define MeshPartGuiExport
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4290)
|
||||
# pragma warning(disable : 4275)
|
||||
#endif
|
||||
|
||||
#ifdef _PreComp_
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user