MT Showcase SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Showcase::Showcase Class Reference

This is a singleton class that manages the Showcase runtime. More...

#include <Showcase.hpp>

Public Member Functions

void tearDown ()
 Clear all UI, content and settings and reset node graph This should only be called once just before shutting down the application.
 
GraphPtr graph ()
 Graph class handles Showcase node graph parsing and queries. More...
 
UserInterfacePtr ui ()
 UserInterface class handles all UI-components in Showcase. More...
 
ServiceProviderPtr services ()
 ServiceProvider class handles all registered services in Showcase. More...
 
RemoteControlPtr remoteControl ()
 RemoteControl class handles communication with the Showcase Editor. More...
 
std::shared_ptr< ScheduleManager > scheduleManager ()
 Schedule manager notifies scheduled events to update their status at requested times. More...
 
void init ()
 Initialize Showcase instance, this will parse and load all packages and prepare Showcase data Called automatically when Showcase instance is created. More...
 
PackagePtr packageOfComponent (const QString &componentName)
 Find a package that includes a component with the given name. More...
 
void addCSSFiles (const std::vector< QString > &filePaths)
 Load given CSS files to the application. More...
 
void addCSSFile (const QString &filePath)
 Load given CSS file to the application. More...
 
void removeCSSFiles (const std::vector< QString > &filePaths)
 Unload given CSS files from the application. More...
 
void removeCSSFile (const QString &filePath)
 Unload given CSS file from the application. More...
 
void run ()
 Start the Showcase application This will load the UI and services for the selected run configuration, or display the welcome screen if no run configuration is selected. More...
 
bool hasRunConfiguration () const
 Run configuration determines Showcase application looks, content and settings. More...
 
RunConfigurationPtr runConfiguration ()
 Run configuration determines Showcase application looks, content and settings. More...
 
void reloadRunConfiguration (bool showLoadingOverlay=false)
 Reset all UI and services and reload the current run configuration. More...
 
void runConfigurationChanged (int id)
 Notifies Showcase that a run configuration has changed. More...
 
void reloadSchedule ()
 Reload the current schedule configuration.
 
void scheduleChanged (int id)
 Notifies Showcase that a schedule has changed. More...
 
void registerWidgetInstance (Valuable::Node::Uuid widgetId, std::weak_ptr< WidgetInstance > instance)
 Register a WidgetInstance for given widgetId. More...
 
void unregisterWidgetInstance (Valuable::Node::Uuid widgetId)
 Unregister a WidgetInstance for given widget id. More...
 
std::shared_ptr< WidgetInstancewidgetInstance (Valuable::Node::Uuid widgetId)
 Get a WidgetInstance for the given widget id. More...
 
void showErrorScreen (const QByteArray &css="", const QString &error="")
 Display an error screen with an optional error text and CSS class. More...
 
void removeErrorScreen ()
 Remove the error screen if it's active.
 
QString editorAddress (bool hideDefaultPort=true) const
 Get the URL address of the connected Showcase Editor. More...
 
void minimize ()
 Minimize Showcase, for example when another application is running in fullscreen.
 
void resume ()
 Resume Showcase.
 
QString remoteControlServer () const
 Get the address of the Showcase Editor's control server. More...
 
std::shared_ptr< folly::Executor > graphExecutor ()
 Showcase uses a single executor for all graph handling. More...
 
std::shared_ptr< folly::Executor > configExecutor ()
 Showcase uses a single executor for handling configuration. More...
 
bool verifyGraphExecutorCallingThread () const
 All graph handling should happen in the graph executor's thread, this will check the current thread. More...
 
void addThemeComponent (const QString &component)
 Some components are 'theme-defaults'. More...
 
const QStringList & themeComponents () const
 Get a list of all registered theme defaults components. More...
 
void setShowExit (bool show)
 If show exit is enabled, Showcase Welcome screen displays a button to exit Showcase. More...
 

Static Public Member Functions

static void setAssetsPath (const QString &path)
 Set the path to main Showcase assets directory This will add the path to search paths as Utils::assetSearchPathName. More...
 
static std::weak_ptr< ShowcaseweakInstance ()
 Access a weak pointer to Showcase instance. More...
 
static const QString & version ()
 Current version of Showcase core. More...
 
static QByteArray showcaseGitHash ()
 Showcase build git hash, or empty string if git hash is not available.
 
static boost::expected
< QString, QString > 
showcaseRoot ()
 Find the Showcase root folder. More...
 
static QString localDataDirectory ()
 Local directory for Showcase data. More...
 
static QString localCacheDirectory ()
 Showcase saves some data in a local cache directory. More...
 
static QString logDirectory ()
 Log directory for Showcase. More...
 
static void errorMessage (const QString &msg)
 Log the given error message. More...
 

Detailed Description

This is a singleton class that manages the Showcase runtime.

You can access other aspects of Showcase like the user interface, configuration or packages through this class.

Member Function Documentation

void Showcase::Showcase::addCSSFile ( const QString &  filePath)

Load given CSS file to the application.

You can load the same file multiple times if it's used by multiple different packages. In that case you need to remove the file multiple times as well.

Parameters
filePathpath to the CSS file
void Showcase::Showcase::addCSSFiles ( const std::vector< QString > &  filePaths)

Load given CSS files to the application.

Parameters
filePathspaths to the CSS files
void Showcase::Showcase::addThemeComponent ( const QString &  component)

Some components are 'theme-defaults'.

They are never used directly, but other components can use their settings if they have matching slots or attributes. For example a component with attribute "rotate-towards-hands" will use that attribute value from theme defaults if it doesn't have it defined itself Register a new component as a theme default

Parameters
componentname of the component
std::shared_ptr<folly::Executor> Showcase::Showcase::configExecutor ( )
inline

Showcase uses a single executor for handling configuration.

Returns
Showacase's config handling executor
QString Showcase::Showcase::editorAddress ( bool  hideDefaultPort = true) const

Get the URL address of the connected Showcase Editor.

Parameters
hideDefaultPortif true, default network port 80 is not included in the address
Returns
URL of Showcase Editor
void Showcase::Showcase::errorMessage ( const QString &  msg)
static

Log the given error message.

Parameters
msgerror message to log
GraphPtr Showcase::Showcase::graph ( )

Graph class handles Showcase node graph parsing and queries.

Returns
instance of the class that handles queries to graphs
std::shared_ptr<folly::Executor> Showcase::Showcase::graphExecutor ( )
inline

Showcase uses a single executor for all graph handling.

Returns
Showcase's graph handling executor
bool Showcase::Showcase::hasRunConfiguration ( ) const

Run configuration determines Showcase application looks, content and settings.

Check if Showcase has a run configration selected

Returns
true if Showcase has a run configration
void Showcase::Showcase::init ( )

Initialize Showcase instance, this will parse and load all packages and prepare Showcase data Called automatically when Showcase instance is created.

Load all libs from default locations and environment Need to load everything here, because we need to call Showcase::instance() during addition of components

Add global CSS file for components that don't come from packages, such as the root component

QString Showcase::Showcase::localCacheDirectory ( )
static

Showcase saves some data in a local cache directory.

For example previous run configuration and generated PDF page images are saved in this location.

Returns
path to cache directory
QString Showcase::Showcase::localDataDirectory ( )
static

Local directory for Showcase data.

Data such as logs and cache should be stored in this directory

Returns
path to Showcase data directory
QString Showcase::Showcase::logDirectory ( )
static

Log directory for Showcase.

Returns
path to Showcase log directory
PackagePtr Showcase::Showcase::packageOfComponent ( const QString &  componentName)

Find a package that includes a component with the given name.

Parameters
componentNameUnique name that identifies the component
Returns
package with the component or nullptr
void Showcase::Showcase::registerWidgetInstance ( Valuable::Node::Uuid  widgetId,
std::weak_ptr< WidgetInstance instance 
)

Register a WidgetInstance for given widgetId.

Parameters
widgetIdid of the widget to register an instance for
instanceto register
void Showcase::Showcase::reloadRunConfiguration ( bool  showLoadingOverlay = false)

Reset all UI and services and reload the current run configuration.

Parameters
showLoadingOverlayif true, show a loading overlay until the new run configuration has finished loading
RemoteControlPtr Showcase::Showcase::remoteControl ( )

RemoteControl class handles communication with the Showcase Editor.

Returns
instance of the class that handles Editor communication
QString Showcase::Showcase::remoteControlServer ( ) const

Get the address of the Showcase Editor's control server.

Note that this address can be different from the Editor address, as the server uses a different port

Returns
address of the server
void Showcase::Showcase::removeCSSFile ( const QString &  filePath)

Unload given CSS file from the application.

Parameters
filePathpath to the CSS file
void Showcase::Showcase::removeCSSFiles ( const std::vector< QString > &  filePaths)

Unload given CSS files from the application.

Parameters
filePathspaths to the CSS files
void Showcase::Showcase::run ( )

Start the Showcase application This will load the UI and services for the selected run configuration, or display the welcome screen if no run configuration is selected.

If control host is not specified read run confs manually

RunConfigurationPtr Showcase::Showcase::runConfiguration ( )

Run configuration determines Showcase application looks, content and settings.

Returns
current run configuration
void Showcase::Showcase::runConfigurationChanged ( int  id)

Notifies Showcase that a run configuration has changed.

If this is the current run configuration, it's reloaded

Parameters
idif of the changed configuration
void Showcase::Showcase::scheduleChanged ( int  id)

Notifies Showcase that a schedule has changed.

Parameters
idif of the changed schedule
ScheduleManagerPtr Showcase::Showcase::scheduleManager ( )

Schedule manager notifies scheduled events to update their status at requested times.

Returns
instance of the schedule manager class
ServiceProviderPtr Showcase::Showcase::services ( )

ServiceProvider class handles all registered services in Showcase.

Returns
instance of the class that handles services
void Showcase::Showcase::setAssetsPath ( const QString &  path)
static

Set the path to main Showcase assets directory This will add the path to search paths as Utils::assetSearchPathName.

Parameters
pathpath to new assets directory
void Showcase::Showcase::setShowExit ( bool  show)

If show exit is enabled, Showcase Welcome screen displays a button to exit Showcase.

Parameters
showif true, exit button is enabled
boost::expected< QString, QString > Showcase::Showcase::showcaseRoot ( )
static

Find the Showcase root folder.

Root folder is assumed to be one directory up from the Showcase library location

Returns
root folder path or an error string if an error occurred
void Showcase::Showcase::showErrorScreen ( const QByteArray &  css = "",
const QString &  error = "" 
)

Display an error screen with an optional error text and CSS class.

Parameters
csscss class to apply to the error screen
errorerror text to show in the error screen
const QStringList & Showcase::Showcase::themeComponents ( ) const

Get a list of all registered theme defaults components.

Returns
list of components that are theme defaults
UserInterfacePtr Showcase::Showcase::ui ( )

UserInterface class handles all UI-components in Showcase.

Returns
instance of the class that handles creation of UI-components
void Showcase::Showcase::unregisterWidgetInstance ( Valuable::Node::Uuid  widgetId)

Unregister a WidgetInstance for given widget id.

Parameters
widgetIdid of the widget to unregister
bool Showcase::Showcase::verifyGraphExecutorCallingThread ( ) const

All graph handling should happen in the graph executor's thread, this will check the current thread.

Used for internal debugging

Returns
true if current thread is the graph executor's thread
const QString & Showcase::Showcase::version ( )
static

Current version of Showcase core.

Returns
version string
std::weak_ptr< Showcase > Showcase::Showcase::weakInstance ( )
static

Access a weak pointer to Showcase instance.

This will not create an instance if one doesn't exist

Returns
weak pointer to Showcase instance
std::shared_ptr< WidgetInstance > Showcase::Showcase::widgetInstance ( Valuable::Node::Uuid  widgetId)

Get a WidgetInstance for the given widget id.

Showcase keeps track of which widget instance matches widget ids.

Parameters
widgetIdid of the widget to query the instance for
Returns
pointer to the widget instance