Inherits QWidget.
Clients can use this class along with SplashScreen and AboutDialogs to easily implement software branding in their applications. These classes can be used in one of two ways.
Usage 1: For direct creation
void main() { QApplication myApp;
// Set properties on a new BrandingWidget BrandingWidget* branding = new BrandingWidget(); branding->setBackgroundFilename("splashbackground.png"); branding->setHeadingText(QApplication::tr("Workspace App")); branding->setHeadingColor(Qt::white); branding->setHeadingShadow(); branding->setSubHeadingText(QApplication::tr(" v1.0")); branding->setSubHeadingColor(Qt::white); branding->setSubHeadingShadow(); branding->setLogColor(Qt::white); branding->setLogBorder(true, QColor(126, 192, 238, 150)); branding->setHeadingShadow();
// Create a splash screen using the BrandingWidget SplashScreen* splash = new SplashScreen(*branding);
// Optionally capture log messages during startup LogToGui mainLog(*splash); LogManager::getInstance().addStream(mainLog);
// Show the splash screen splash->show(); app.processEvents();
... do startup tasks ...
splash->finish(&mainWindow); return app.exec(); }
Usage 2: Subclass BrandingWidget for use throughout your application
class MyBrandingWidget : public Widgets::BrandingWidget { public: MyBrandingWidget(QWidget* parent = 0) : BrandingWidget(parent) { setBackgroundFilename("splashbackground.png"); setWindowIcon(QIcon("logo.png"));
// Heading QFont font("Gill Sans"); font.setPixelSize(40); font.setBold(true); setHeadingText("MyApp"); setWindowTitle("MyApp"); setHeadingFont(font); setHeadingPos(QPoint(170,30));
// Version number font.setPixelSize(20); setSubHeadingText(tr("v1.0")); setSubHeadingFont(font); setSubHeadingPos(QPoint(170, 75));
// Copyright notice font.setPixelSize(10); addText(font, QPoint(170, 105), tr("Copyright 2003-2012:\n" "Commonwealth Scientific and Industrial Research Organisation (CSIRO)\n" "All rights reserved."), Qt::black);
// Startup log font.setBold(false); font.setPixelSize(15); setLogFont(font); setLogBorder(false); setLogColor(QColor(114,114,144)); setLogRegion(QRect(20, 200, 400, 150));
// Logos addImage("csiro_logo.png", QPoint(465,190)); addImage("client-logo.png", QPoint(445,270)); } };
class MySplashScreen : public Widgets::SplashScreen { public: SplashScreen() : Widgets::SplashScreen(*(new MyBrandingWidget())) { } };
class MyAboutBox : public Widgets::AboutDialog { AboutBox(QWidget* parent=0) : Widgets::AboutDialog(*(new MyBrandingWidget()), parent) { Widgets::BrandingWidget* branding = findChild<Widgets::BrandingWidget*>(); CSIRO_ASSERT(branding);
// Add any extra items needed in this dialog QFont font("Gill Sans"); font.setPixelSize(13); branding->addText("Some extra text needed in the about box");
... add any other child widgets required to the BrandingWidget ...
show(); } };