Workspace 6.21.5
Public Slots | Public Member Functions | Protected Member Functions | List of all members
BrandingWidget Class Reference

Software branding widget for use with SplashScreen and AboutDialog in stand alone applications. More...

#include <Workspace/Widgets/brandingwidgets.h>

Inherits QWidget.

Public Slots

void logText (const QString &msg)
 

Public Member Functions

 BrandingWidget (QWidget *parent=nullptr)
 
 ~BrandingWidget () override
 
void addImage (const QString &filename, const QPoint &pos, float scale=1.0f)
 
void addText (const QFont &font, const QPoint &position, const QString &text, const QColor &color)
 
const QString & getBackgroundFilename () const
 
QPixmap getBackgroundPixmap () const
 
void setBackgroundFilename (const QString &backgroundFilename) const
 
void setHeadingColor (const QColor &color)
 
void setHeadingFont (const QFont &font)
 
void setHeadingPos (const QPoint &pos)
 
void setHeadingShadow (int offset=3, int alpha=150)
 
void setHeadingText (const QString &text)
 
void setLogBorder (bool enabled, const QColor &color=Qt::black)
 
void setLogColor (const QColor &color)
 
void setLogFont (const QFont &font)
 
void setLogRegion (const QRect &rect)
 
void setLogSingleLine (bool singleLine)
 
void setSubHeadingColor (const QColor &color)
 
void setSubHeadingFont (const QFont &font)
 
void setSubHeadingPos (const QPoint &pos)
 
void setSubHeadingShadow (int offset=3, int alpha=150)
 
void setSubHeadingText (const QString &text)
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 

Detailed Description

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(); } };

Constructor & Destructor Documentation

◆ BrandingWidget()

BrandingWidget ( QWidget *  parent = nullptr)

◆ ~BrandingWidget()

~BrandingWidget ( )
override

Member Function Documentation

◆ addImage()

void addImage ( const QString &  filename,
const QPoint &  pos,
float  scale = 1.0f 
)

◆ addText()

void addText ( const QFont &  font,
const QPoint &  position,
const QString &  text,
const QColor &  color 
)

◆ getBackgroundFilename()

const QString & getBackgroundFilename ( ) const

◆ getBackgroundPixmap()

QPixmap getBackgroundPixmap ( ) const

◆ logText

void logText ( const QString &  msg)
slot

◆ paintEvent()

void paintEvent ( QPaintEvent *  event)
overrideprotected

◆ setBackgroundFilename()

void setBackgroundFilename ( const QString &  backgroundFilename) const

◆ setHeadingColor()

void setHeadingColor ( const QColor &  color)

◆ setHeadingFont()

void setHeadingFont ( const QFont &  font)

◆ setHeadingPos()

void setHeadingPos ( const QPoint &  pos)

◆ setHeadingShadow()

void setHeadingShadow ( int  offset = 3,
int  alpha = 150 
)

◆ setHeadingText()

void setHeadingText ( const QString &  text)

◆ setLogBorder()

void setLogBorder ( bool  enabled,
const QColor &  color = Qt::black 
)

◆ setLogColor()

void setLogColor ( const QColor &  color)

◆ setLogFont()

void setLogFont ( const QFont &  font)

◆ setLogRegion()

void setLogRegion ( const QRect &  rect)

◆ setLogSingleLine()

void setLogSingleLine ( bool  singleLine)

◆ setSubHeadingColor()

void setSubHeadingColor ( const QColor &  color)

◆ setSubHeadingFont()

void setSubHeadingFont ( const QFont &  font)

◆ setSubHeadingPos()

void setSubHeadingPos ( const QPoint &  pos)

◆ setSubHeadingShadow()

void setSubHeadingShadow ( int  offset = 3,
int  alpha = 150 
)

◆ setSubHeadingText()

void setSubHeadingText ( const QString &  text)