![]() |
VR-Forces 5.0.3 Developer's Guide
|
The widget icon style manager chooses the icons of QWidgets based on whether the VR-Vantage application is using dark mode or light mode. UI Element classes, e.g. dialogs and other widgets, may have their icon managed by this manager by using one of the following class methods: 1) manageWidget(QObject* widgetToManage, const std::string& iconFileNameOrPath) 2) manageWidget(QObject* widgetToManage, const DtQIconConfigurations& iconConfigurations); 3) manageIndexableWidget(QObject* indexedWidgetToManage, int index, const DtQIconConfigurations& iconConfigurations)
Class methods 1 and 2 are used for non-indexable widgets and class method 3 is used for indexable widgets. Indexable widgets are widgets that can support the rendering of an icon at particular indices, e.g. lists/tables/trees.
QObject does not have a setIcon method (nor anything similar) so the manager will dynamic cast to a supporting widget type when it comes time to update the icons.
The supported un-indexable widget types are:
The supported indexable widget types are:
To support more widget types, subclass this manager class and extend updateIcon(...) to support other un-indexable widget types OR updateIndexedIcon(...) to support other indexable widget types.
Users of this class can use unmanageWidget(QObject* widgetToManage) to stop further management of a widget's icon style.
If the manager is managing a widget that has been deleted - it will detect that case and automatically removed the deleted widget from its internal list of widgets to manage.
To manage a widget, one thing the manager needs to be provided is the file name of icon asset OR the file path to that icon asset. The file name or file path is provided:
The manager uses the provided icon file name or file path in the following way:
Public Types | |
| typedef std::vector< std::pair < int, DtQIconConfigurations > > | DtIndexableQIconConfigurations |
Public Member Functions | |
| DtWidgetIconStyleManager ()=delete | |
| DtWidgetIconStyleManager (const DtWidgetIconStyleManager &other)=delete | |
| DtWidgetIconStyleManager & | operator= (const DtWidgetIconStyleManager &other)=delete |
| virtual void | manageWidget (QObject *widgetToManage, const std::string &iconFileNameOrPath) |
| virtual void | manageWidget (QObject *widgetToManage, const DtQIconConfigurations &iconConfigurations) |
| virtual void | manageIndexableWidget (QObject *indexedWidgetToManage, int index, const DtQIconConfigurations &iconConfigurations) |
| virtual void | unmanageWidget (QObject *widgetToManage) |
| virtual void | clearCache (bool refreshIcons=true) |
| virtual QPixmap | generateThemedPixmap (const std::string &iconFileNameOrPath, const QSize &pixmapSize=QSize(16, 16), QIcon::Mode iconModeOfGeneratedPixmap=QIcon::Normal, QIcon::State iconStateOfGeneratedPixmap=QIcon::Off) |
| virtual QIcon | createQIconBasedOnConfigurations (const DtQIconConfigurations &configurations) |
Public Member Functions inherited from makVrv::DtVirtualBaseClass | |
| DtVirtualBaseClass () | |
| virtual | ~DtVirtualBaseClass () |
Static Public Member Functions | |
| static DtWidgetIconStyleManager & | instance (DtDe &de) |
| static void | registerInstance (DtDe &de, DtWidgetIconStyleManager *instance) |
Public Attributes | |
| boost::signalslib::signal< void()> | signal_refreshApplicationIcons |
Protected Member Functions | |
| DtWidgetIconStyleManager (DtDe &de) | |
| virtual | ~DtWidgetIconStyleManager () |
| virtual void | slot_darkModeEnabledChanged (bool enabled) |
| virtual void | slot_lightModeDarkModeIconsEnabledChanged (bool enabled) |
| virtual void | updateAllManagedIcons (bool lightDarkModeIconsEnabled) |
| virtual void | updateIcon (QObject *widget, const DtQIconConfigurations &iconConfigurations, bool lightDarkModeIconsEnabled) |
| virtual void | updateIndexedIcon (QObject *indexedWidget, const DtIndexableQIconConfigurations &iconConfigurations, bool lightDarkModeIconsEnabled) |
| virtual QPixmap | findOrCreatePixmapInCache (const std::string &filePath) |
| virtual QPixmap | findOrCreateThemedPixmapInCache (const std::string &fileNameOrPath) |
| virtual std::string | iconsDirectory (const std::string &iconFileNameOrPath) const |
| virtual bool | iconExistsOnDiskOrInCache (const std::string &iconFilePath) const |
| virtual std::string | iconFilePath (const std::string &iconFileNameOrPath) const |
| virtual void | generateAndAppendAdditionalIconConfigurationsIfNeeded (QIcon &iconToAppendToIfNeeded, const DtQIconConfigurations &iconConfigurations) const |
| virtual QPixmap | generateThemedPixmap (const std::string &iconFileNameOrPath, QIcon::Mode iconModeOfGeneratedPixmap=QIcon::Normal, QIcon::State iconStateOfGeneratedPixmap=QIcon::Off) const |
| virtual bool | getPixmapFromSVGAndColorMappings (const std::string &iconFileNameOrPath, const std::vector< std::pair< QColor, QColor >> colorMappings, QPixmap &resultIcon) const |
Protected Attributes | |
| DtDe & | myDe |
| DtSignalConnectionManager | myConnections |
| std::map< QPointer< QObject > , DtQIconConfigurations > | myWidgetsToManage |
| std::map< QPointer< QObject > , DtIndexableQIconConfigurations > | myIndexedWidgetsToManage |
| std::map< std::string, QPixmap > | myFilepathsToPixmapCache |
| DtWidgetIconStyleManagerEventFilter * | myEventFilter |
Friends | |
| class | DtWidgetIconStyleManagerEventFilter |
| typedef std::vector<std::pair<int, DtQIconConfigurations> > makVrv::DtWidgetIconStyleManager::DtIndexableQIconConfigurations |
Vector of mappings between a DtQIconConfigurations and the index to apply the configuration to.
|
delete |
Default Constructor not implemented.
|
delete |
Copy Constructor not implemented - Copy not allowed.
|
protected |
Protected CTOR - use the static instance function to create.
|
protectedvirtual |
DTOR.
|
static |
Returns a reference to the DtWidgetIconStyleManager instance This function will register the manager with the DtDe if one has not been registered already.
Referenced by makVrf::DtToolButtonWrapperWidget::addActionWithIcon().
|
static |
Register a new widget icon style manager instance and replace the default.
|
delete |
Assignment Operator not implemented - Assignment not allowed.
|
virtual |
Add a new widget to the manager. The manager will now manage the icon style for the widget.
| widgetToManage | The widget to manage the icon for. |
| iconFileNameOrFilePath | The file name of the icon asset OR the file path to the icon asset. |
Referenced by makVrf::DtToolButtonWrapperWidget::addActionWithIcon().
|
virtual |
Add a new widget to the manager. The manager will now manage the icon style for the widget.
| widgetToManage | The widget to manage the icon for. |
| iconConfigurations | The configurations for the widget's icon. |
|
virtual |
Add a new indexable widget to the manager. The manager will now manage the icon style for the widget.
| widgetToManage | The indexable widget to manage the icon for. |
| index | The index of the widget the icon configurations will be applied to. |
| iconConfigurations | The configurations for the widget's icon. |
|
virtual |
Remove a new widget the manager. The manager will not manage the icon style.
| widgetToManage | The (non)indexable widget to no longer manage. |
|
virtual |
Clear the cache of QPixmap objects that are used to set the icons.
| refreshIcons | If true, update all managed widgets after clearing the cache. |
|
virtual |
Generate a pixmap from an SVG and the desired size, mode and state. The generated pixmap is a modified version of the SVG pointed to by the provided icon file name/path with a different set of colors. The colors of the SVG are swapped out with other colors based on mappings maintained by the main window.
|
virtual |
Helper function for creating a QIcon based on a DtQIconConfigurations.
| configurations | The VRV-specific configurations to convert to a QIcon |
|
protectedvirtual |
Invoked when dark mode has been enabled or disabled.
|
protectedvirtual |
Invoked when light/dark mode icons has been enabled or disabled.
|
protectedvirtual |
Update all managed icons based on application settings.
|
protectedvirtual |
Helper function to update a single widget that uses the provided icon file name.
|
protectedvirtual |
Helper function to update a single widget that uses the provided icon file name.
|
protectedvirtual |
Helper function for getting the QPixmap for the associated asset pointed to by the provided filePath from the manager's QPixmap cache. This function will create a QPixmap and cache it if one does not exist in the cache already.
|
protectedvirtual |
Attempt to get the QPixmap for the associated asset pointed to by the provided fileName from the manager's QPixmap cache based on the current theme used by the application. This function will create a QPixmap and cache it if one does not exist in the cache already.
| iconFileNameOrFilePath | The file name of the icon asset OR the file path to the icon asset. |
|
protectedvirtual |
Helper function to get the base icons directory associated with the provided icon file name or path.
|
protectedvirtual |
Helper function that returns whether or not provided iconFilePath exists on disk or is present in the icon cache.
|
protectedvirtual |
Helper function used to get the full icon file path of an icon configuration This function considers the application setting for whether dark mode or light mode is being used and whether dark mode and light mode -specific icons are used.
|
protectedvirtual |
Helper function to generate additional icon configurations, if needed Additional icon configurations need to be generated if the flags maintained by the collection of configurations indicate they should be generated.
The asset used for the generation of an icon for a given mode and state is determined by the following rules:
Generation in this context means we create a modified version of a provided icon configuration. The modified version is the same as the provided icon configuration and only differs in the colors it uses. The colors to use for generated icons come from mappings present in the stylesheet of the application and that are maintained by the main window of the application.
|
protectedvirtual |
Helper function for generating a pixmap from an SVG and the desired mode and state for the pixmap. The generated SVG is a modified version of the SVG pointed to by the provided icon file name/path with a different set of colors. The colors of the SVG are swapped out with other colors based on mappings maintained by the main window.
|
protectedvirtual |
Helper function that creates a modified version of an icon asset. This function assumes the icon asset is an SVG. The modified version of the SVG swaps out colors with other colors defined in the provided color mappings. If the icon asset is not a SVG, then just return a QPixmap with the icon asset loaded.
|
friend |
| boost::signalslib::signal<void()> makVrv::DtWidgetIconStyleManager::signal_refreshApplicationIcons |
Emitted when the manager has updated all of its managed widgets If a widget is managing its own icon (as opposed to this manager managing the icon for the widget), then the widget will likely need to connect to this signal, to be notified when all the other application icons have been refreshed, as the widget will likely need to refresh its own icon also.
|
protected |
|
protected |
|
protected |
Mapping a QObject (UI element with the icon) and its configuration.
|
protected |
Mapping an indexed QObject (UI element with indices where each index can have an icon) and its configuration.
|
protected |
Mapping a filepath to the cached QPixmap for the asset pointed to by the filepath.
|
protected |
Event filter to detect changes to enable state of some widget types.