CDPBaseDialog Class

The Dialog widget can be used to prompt the user with dialog windows. More...

Header: #include <CDPBaseDialog>
Inherits: RenderPixWidget, RoutingReplacer,
Inherited By:

CDPBaseKeyPad and CDPBaseNumPad


Public Functions

CDPBaseDialog(QWidget *parent = 0)
virtual ~CDPBaseDialog()
virtual QWidget *containerWidget()
virtual bool moveOnlyByHeader()
virtual void setIQtCDPPointer(IQtCDP *pIQtCDP)
virtual void setMoveOnlyByHeader(bool headMove)
virtual void setSvgFile(const QString &svg)
virtual void setTitle(const QString &text)
void setTranslucentBg(bool translucent)
virtual void setUserEventAction(ExternalUserEventEater::UserEventAction action)
QString svgFile()
QString title()
bool translucentBg()
virtual ExternalUserEventEater::UserEventAction userEventAction()

Public Slots

virtual void hideWidget()
virtual void setContainerWidget(QWidget *widget)
virtual void setInCommand(bool cmd)
virtual void setSmoothPixmap(bool smooth)
virtual void setTimeOffsetSecs(double value)
virtual void setWidgetFont(const QString &font)
virtual void setWidgetStyle(int style)
virtual void setWidgetTheme(const QString &theme)
virtual void showWidget()

Protected Functions

virtual void changeEvent(QEvent *e)
void processSvgFile(QString svg)
virtual void updateShadowMargins()
void updateTitleColor()

Reimplemented Protected Functions

virtual void mouseMoveEvent(QMouseEvent *ev)
virtual void mousePressEvent(QMouseEvent *ev)
virtual void mouseReleaseEvent(QMouseEvent *ev)
virtual void resizeEvent(QResizeEvent *ev)

Additional Inherited Members

Detailed Description

The Dialog widget can be used to prompt the user with dialog windows.

The CDPBaseDialog supports features like animated startup, rendered pixmap to make movement as smooth as possible, themes, and other useful features.

Note: The class is intended for in-window use and will get window borders if configured without a parent (set in the loader object).

How to reuse dialogs to show different remote values

Some applications might require multiple identical dialogs showing values from different remote sources. A good example of such, is pipe diagram applications with pumps and valves. Clicking the various elements usually pops up a dialog showing further status/control details. When the dialogs are identical and more than just a few, it would be much simpler to create one dialog and have it show different sources when clicked, than to create hundreds of dialogs. This is where routing replacement comes in handy.

Routing replacement is done using simple string replacement. The dialog property replaceableRouting, must first be configured with a string that does not occur in any remote objects that are to be routed, for instance REPLACE. This string can now be used as a placeholder in the different cdp routing properties of our dialog items. When the dialog is opened, by for instance a button of type CDPBaseButtonPopDlg, the placeholder string will get replaced by a string configured in the button. In CDPBaseButtonPopDlg, this property is named routingReplacement.

To illustrate the above with a full example, we'll add two labels to a dialog to show state and location of a valve. In the control application, the valve is a component having the two as signals. This would make our dialog.ui look something like the following (when wanting valve component name to be replaceable):


Next, we need to configure the buttons that are to open the dialog. The properties will be identical in each button instance, except for CDPBaseButtonPopDlg::routingReplacement, which represents the valve component name.


Clicking the button will bring up the dialog, replace routings and show the labels with their new routed values. They should now be showing the values of PipeApp.Valve1.state and PipeApp.Valve1.location.

Note: The property named useCache was added to make the dialog global and thus save memory.

Styling by SVG

Use the svgFile property to style the widget using a svg file. Styling by svg enables switching between different themes in runtime (as long as the files are placed at identical locations within theme directories).

Main element structure

In the svg structure for the CDPBaseDialog, all graphics are located in the cdpBackground element. The widget draws the background as a border pixmap based on the border margin rects. Thus, the title and the exit cross gets painted correctly when the widget is scaled. The shadow rects are used to place the content of the dialog correctly when we got shadows and the exit rect for knowing the position of the close box.

└─── Layer1
      ├─── cdpTitleText               (text)
      ├─── cdpShadowTopLeft           (transparent rect/path)
      ├─── cdpShadowBottomRight       (transparent rect/path)
      ├─── cdpBorderMarginBottomRight (transparent rect/path)
      ├─── cdpBorderMarginTopLeft     (transparent rect/path)
      ├─── cdpExitRect                (transparent rect/path)
      └─── cdpBackground              (element group or rect/path)
            ├─── < Path >             (transparent rect/path)
            └─── < Group >            (graphics)

The following tree view shows the svg structure that can be used on the CDPBaseDialog.

cdpTitleTexttextSet font color and size.
cdpShadowTopLeftrectWhen a shadow is added to the edges of the dialog we can use this property to make sure that the contents of the dialog will not be placed on top of shadows. The width of the rect specifies width of the left shadow while the height specifies the top shadow.
cdpShadowBottomRightrectWhen a shadow is added to the edges of the dialog we can use this property to make sure that the contents of the dialog will not be placed on top of shadows. The width of the rect specifies width of the right shadow while the height specifies the bottom shadow.
cdpBorderMarginBottomRightrectAll graphics are placed on the background and rects are used to set the border margins. The right border margin must be wide enough to include the exit rect, else the cross will get stretched when the dialog is extended. Note that the width of the rect specifies the right border margin while its height specifies the bottom margin.
cdpBorderMarginTopLeftrectThe width of the rect specifies the left border margin while the height specifies the top margin.
cdpExitRectrectTransparent rectangle that specifies the location and size of the close box (exit cross).
cdpBackgroundrect or an element group containing a rectThe cdpBackground should contain the actual background graphics including shadows and close cross. To ensure that the svg parser gets the correct background size (and aspect ratio), we have to place a transparent rect along with the graphics within a group element.

Style element structure

The dialog supports the following structure for styles.

├─── Layer1
│     └─── ...                  (see previous section)
└─── Styles
      ├─── cdpTitleTextStyleX   (text)
      └─── cdpBackgroundStyleX  (element group or rect/path)
            ├─── < Path >       (transparent rect/path)
            └─── < Group >      (background graphics)

Note: The X in the above list is just a placeholder for the style number that the element represents.

Property Documentation

moveOnlyByHeader : bool

This property holds whether the widget is only movable by clicking on the header.

Access functions:

virtual bool moveOnlyByHeader()
virtual void setMoveOnlyByHeader(bool headMove)

replaceableRouting : const QString

This property holds a string that can be used and replaced in child object routings.

The string added in this property can be used in routing properties of all child objects. The string that are to replace the replaceableRouting is configured in the button that launches the dialog.

Click here for further details.

svgFile : QString

This property holds the path to the svg file that styles the widget.

The path can be either to a resource or a file on disk.

Note: Resources can be overridden by files on disk with identical names.

Access functions:

QString svgFile()
virtual void setSvgFile(const QString &svg)

title : QString

This property holds the dialog title.

Access functions:

QString title()
virtual void setTitle(const QString &text)

translucentBg : bool

This property holds whether to allow transparency of the widget or not.

Set this property if you are using a theme that has transparent parts.

Note: Transparency increases cpu usage during move as we also have to redraw the widget behind the widget being moved.

Access functions:

bool translucentBg()
void setTranslucentBg(bool translucent)

userEventsExternal : ExternalUserEventEater::UserEventAction

This property holds how to behave when the user attemts to interact with widgets outside the dialog.

Access functions:

virtual ExternalUserEventEater::UserEventAction userEventAction()
virtual void setUserEventAction(ExternalUserEventEater::UserEventAction action)

Member Function Documentation

CDPBaseDialog::CDPBaseDialog(QWidget *parent = 0)

Default constructs an instance of CDPBaseDialog.

[virtual] CDPBaseDialog::~CDPBaseDialog()

Destroys the instance of CDPBaseDialog. The destructor is virtual.

[virtual protected] void CDPBaseDialog::changeEvent(QEvent *e)

[virtual] QWidget *CDPBaseDialog::containerWidget()

See also setContainerWidget().

[virtual slot] void CDPBaseDialog::hideWidget()

[virtual protected] void CDPBaseDialog::mouseMoveEvent(QMouseEvent *ev)

[virtual protected] void CDPBaseDialog::mousePressEvent(QMouseEvent *ev)

[virtual protected] void CDPBaseDialog::mouseReleaseEvent(QMouseEvent *ev)

[protected] void CDPBaseDialog::processSvgFile(QString svg)

[virtual protected] void CDPBaseDialog::resizeEvent(QResizeEvent *ev)

[virtual slot] void CDPBaseDialog::setContainerWidget(QWidget *widget)

See also containerWidget().

[virtual] void CDPBaseDialog::setIQtCDPPointer(IQtCDP *pIQtCDP)

[virtual slot] void CDPBaseDialog::setInCommand(bool cmd)

[virtual slot] void CDPBaseDialog::setSmoothPixmap(bool smooth)

[virtual slot] void CDPBaseDialog::setTimeOffsetSecs(double value)

[virtual slot] void CDPBaseDialog::setWidgetFont(const QString &font)

[virtual slot] void CDPBaseDialog::setWidgetStyle(int style)

[virtual slot] void CDPBaseDialog::setWidgetTheme(const QString &theme)

[virtual slot] void CDPBaseDialog::showWidget()

[virtual protected] void CDPBaseDialog::updateShadowMargins()

[protected] void CDPBaseDialog::updateTitleColor()