Generic dialog box class.
#include <QtxDialog.h>
Classes | |
class | Area |
Area containing dialog box buttons. More... | |
class | Border |
Special label used as border widget (separator between main frame and button frame). More... | |
Public Types | |
enum | PlacePolicy { Position, Expand, Uniform } |
Buttons alignment type. More... | |
enum | ButtonArea { TopArea, BottomArea, LeftArea, RightArea } |
Buttons area. More... | |
enum | ButtonPosition { Left, Right, Center, Top = Left, Bottom = Right } |
Button position. More... | |
enum | ButtonFlags { None = 0x00000000, OK = 0x00000001, Apply = 0x00000002, Cancel = 0x00000004, Yes = 0x00000008, No = 0x00000010, Close = 0x00000020, Help = 0x00000040, OKCancel = OK | Cancel, YesNo = Yes | No, Standard = OK | Cancel | Help, All = Standard | YesNo | Apply | Close } |
Button ID flags. More... | |
enum | DialogFlags { Accept = 0x000001, Reject = 0x000002, AlignOnce = 0x000004, SetFocus = 0x000008 } |
Dialog box flags. More... | |
Public Slots | |
void | update () |
Update dialog box. More... | |
virtual void | setVisible (bool) |
Show/hide dialog box, set keyboard focus to the dialog. More... | |
Signals | |
void | dlgButton (int) |
Emitted when the user button is clicked. More... | |
void | dlgParamChanged () |
This signal can be used in successor classes to signalize about some dialog parameter changing. More... | |
void | dlgHelp () |
Emitted when the "Help" button is clicked. More... | |
void | dlgApply () |
Emitted when the "Apply" button is clicked. More... | |
void | dlgOk () |
Emitted when the "OK" button is clicked. More... | |
void | dlgNo () |
Emitted when the "No" button is clicked. More... | |
void | dlgYes () |
Emitted when the "Yes" button is clicked. More... | |
void | dlgClose () |
Emitted when the "Close" button is clicked. More... | |
void | dlgCancel () |
Emitted when the "Cancel" button is clicked. More... | |
Public Member Functions | |
QtxDialog (QWidget *=0, bool=false, bool=false, const int=Standard, Qt::WindowFlags=0) | |
Constructor. More... | |
virtual | ~QtxDialog () |
Destructor. More... | |
void | setDialogFlags (const int) |
Set specified dialog box flags. More... | |
void | clearDialogFlags (const int) |
Clear specified the dialog flags. More... | |
bool | testDialogFlags (const int) const |
Test specified dialog flags. More... | |
void | setButtonFlags (const int) |
Add specified control button(s) to the dialog box. More... | |
void | clearButtonFlags (const int) |
Remove specified control button(s) from the dialog box. More... | |
bool | testButtonFlags (const int) const |
Test specified buttons. More... | |
int | buttonPosition (const int) const |
Get specified control button position. More... | |
void | setButtonPosition (const int, const int=-1) |
Set the specified control button(s) position. More... | |
void | setPlacePosition (const int, const int) |
Set button position for all buttons in specified area. More... | |
int | placePolicy (const int) const |
Get buttons layouting policy for the specified area. More... | |
void | setPlacePolicy (const int, const int) |
set buttons layouting policy for the specified area. More... | |
void | setButtonPlace (const int, const int) |
Move specified button(s) into specified area. More... | |
QString | buttonText (const int) |
Get specified button's text. More... | |
void | setButtonText (const int, const QString &text) |
Set specified button's text. More... | |
void | setButtonFocus (const int) |
Sets the keyboard focus to the specified button. More... | |
bool | hasButtonFocus (const int) const |
Check if specified button has keyboard focus. More... | |
bool | isButtonEnabled (const int) const |
Get "enabled" status of the specified button(s). More... | |
void | setButtonEnabled (const bool, const int) |
Enable/disable specified button(s). More... | |
bool | isBorderEnabled (const int) const |
Check if border is enabled. More... | |
void | setBorderEnabled (const bool, const int) |
Show/hide border for the specified button area. More... | |
void | removeButton (const int) |
Remove user button. More... | |
int | insertButton (const QString &, const int=BottomArea) |
Add user button to the dialog box. More... | |
QIntList | userButtonIds () const |
Get all user button IDs. More... | |
QAbstractButton * | userButton (const int) const |
Get user button by the specified id. More... | |
uint | setAlignment (uint align) |
Sets alignment policy. More... | |
Static Public Member Functions | |
static void | setUnits (QLabel *, const QString &) |
Set measure units to the specified label. More... | |
Protected Types | |
typedef QMap< int, QAbstractButton * > | ButtonMap |
button map More... | |
Protected Slots | |
virtual void | accept () |
Accept the dialog box. More... | |
virtual void | reject () |
Reject the dialog box. More... | |
Protected Member Functions | |
QFrame * | mainFrame () const |
Get dialog box main frame widget. More... | |
virtual bool | acceptData () const |
Check if data entered by the user is valid. More... | |
virtual bool | rejectData () const |
Check if dialog box can be cancelled. More... | |
virtual QAbstractButton * | createButton (QWidget *) |
Create new user button. More... | |
QAbstractButton * | button (const int) const |
Get button by the specified ID. More... | |
ButtonMap | buttons (const int=All) const |
Get buttons by the specified IDs. More... | |
int | buttonId (const QAbstractButton *) const |
Get specified button's identifier. More... | |
int | buttonPosition (QAbstractButton *) const |
Get position of specified button. More... | |
virtual void | showEvent (QShowEvent *) |
Align this dialog according to the parent widget and alignment policy before the dialog box is shown. More... | |
virtual void | hideEvent (QHideEvent *) |
Process all existing events when dialog box is hidden. More... | |
virtual void | closeEvent (QCloseEvent *) |
Called when user closes dialog box. More... | |
virtual void | childEvent (QChildEvent *) |
Update dialog box layout when the size grip is added. More... | |
virtual void | keyPressEvent (QKeyEvent *) |
Process key pressing event. More... | |
Private Types | |
typedef QMap< int, Area * > | AreaMap |
button area map More... | |
typedef QMap< int, int > | PositionMap |
button position map More... | |
Private Slots | |
void | onAccept () |
This slot is called when user presses on of the buttons "OK", "Yes", etc. More... | |
void | onReject () |
This slot is called when user presses on of the buttons "Cancel", "No", "Close". More... | |
void | onButton () |
Process user button click event. More... | |
void | onSizeGripDestroyed () |
Update dialog box layout when the size grip is destroyed. More... | |
void | onDestroyed (QObject *) |
Watch for the user button destroying. More... | |
Private Member Functions | |
void | adjustButtons () |
Adjust buttons (set equal size for all buttons). More... | |
void | emitSignal () |
Emit signal correspondingly to the control button. More... | |
Private Attributes | |
AreaMap | myArea |
buttons areas map More... | |
ButtonMap | myButton |
buttons map More... | |
PositionMap | myPosition |
buttons position map More... | |
bool | myInited |
dialog's "initialized" flag More... | |
const QObject * | mySender |
signal sender More... | |
uint | myAlignment |
dialog box alignment type More... | |
QFrame * | myMainFrame |
main frame More... | |
int | myButtonFlags |
button flags More... | |
int | myDialogFlags |
dialog flags More... | |
Friends | |
class | Area |
|
private |
|
protected |
|
private |
QtxDialog::QtxDialog | ( | QWidget * | parent = 0 , |
bool | modal = false , |
||
bool | allowResize = false , |
||
const int | f = Standard , |
||
Qt::WindowFlags | wf = 0 |
||
) |
Construct a dialog with specified parent and name. By default non-modal, non-resizable with the OK, Cancel and Help buttons dialog box is created.
parent | parent widget |
modal | if true dialog box is modal |
allowResize | if true then dialog can be resized by user |
f | specified control buttons for dialog box (QtxDialog::ButtonFlags) |
wf | dialog box flags (Qt::WindowFlags) |
References All, Apply, Area, BottomArea, Cancel, Center, Close, dlgApply(), dlgHelp(), Help, Horizontal, Left, LeftArea, main(), myArea, myButton, myButtonFlags, myMainFrame, No, OK, onAccept(), onDestroyed(), onReject(), Right, RightArea, QtxDialog::Area::setBorderWidget(), setButtonPlace(), setButtonPosition(), TopArea, update(), Vertical, and Yes.
|
virtual |
|
protectedvirtualslot |
This method is used when any accept button is pressed (usually "OK", "Yes", etc).
If dialog flag QtxDialog::Accept is set, this function invokes acceptData() method, which should in this case return true
to allow further processing.
If acceptData() returns false
, this function just returns.
If acceptData() returns true
, the Accepted result is set and signal according to the pressed control button is emitted. Then the default implementation of accept() method is called (which hides the dialog box and, depending on the dialog box flags, can close and destroy it).
Reimplemented in Style_PrefDlg, and LightApp_PreferencesDlg.
References Accept, acceptData(), button(), Close, emitSignal(), mySender, OK, testButtonFlags(), testDialogFlags(), and Yes.
|
protectedvirtual |
This method can be re-implemented in the successor class if it requires to check user input consistency. Default implementation returns true
.
This method is called if dialog flag QtxDialog::Accept is set. If this method returns true
, then dialog will be accepted and closed.
true
if user input is valid Reimplemented in QtxPathDialog.
|
private |
References myArea.
|
protected |
f | control button ID (QtxDialog::ButtonFlags) |
References myButton.
|
protected |
int QtxDialog::buttonPosition | ( | const int | id | ) | const |
id | control button ID (QtxDialog::ButtonFlags) |
References myPosition.
|
protected |
b | button |
References buttonId(), and buttonPosition().
|
protected |
QString QtxDialog::buttonText | ( | const int | id | ) |
id | control button ID (QtxDialog::ButtonFlags) |
References button().
|
protectedvirtual |
void QtxDialog::clearButtonFlags | ( | const int | f | ) |
f | ORed buttons flags (Qtx::ButtonFlags) |
References myButtonFlags, and update().
void QtxDialog::clearDialogFlags | ( | const int | f | ) |
f | dialog box flags (QtxDialog::DialogFlags) |
References myDialogFlags.
|
protectedvirtual |
|
protectedvirtual |
This method is invoked from method insertButton().
parent | parent widget |
|
signal |
|
signal |
id | user button identificator |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
signal |
|
private |
References buttonId(), Cancel, Close, dlgCancel(), dlgClose(), dlgNo(), dlgOk(), dlgYes(), mySender, No, OK, and Yes.
bool QtxDialog::hasButtonFocus | ( | const int | id | ) | const |
id | control button ID (QtxDialog::ButtonFlags) |
true
if specified button has keyboard focus References button().
|
protectedvirtual |
Re-implemented from Qt.
e | hide event |
int QtxDialog::insertButton | ( | const QString & | text, |
const int | area = BottomArea |
||
) |
The button is inserted to the specified dialog box area. if the button is added successfully, the unique identificator of the added button is returned, otherwise -1 is returned.
text | text of the added button |
area | buttons area (QtxDialog::ButtonArea) |
References createButton(), QtxDialog::Area::insertButton(), Left, myArea, myButton, myPosition, onButton(), onDestroyed(), and update().
bool QtxDialog::isBorderEnabled | ( | const int | area | ) | const |
area | buttons area (QtxDialog::ButtonArea) |
true
if border is enabled for specified button area. References myArea.
bool QtxDialog::isButtonEnabled | ( | const int | id | ) | const |
id | control button(s) ID (QtxDialog::ButtonFlags) |
true
if all specified buttons are enabled. References buttons().
|
protectedvirtual |
Re-implemented from Qt.
Call reject() if "Escape" key is pressed. Call accept() if "Ctrl+Enter" key-sequence is pressed. Process "F1" key and emit signal dlgHelp(). Transfer "Ctrl+(Shift+)Tab" key-sequence press event to the child Tab widget (if there is any).
e | key press event |
Reimplemented in VTKViewer_MarkerDlg.
References accept(), Apply, dlgApply(), dlgHelp(), Help, isButtonEnabled(), OK, reject(), testButtonFlags(), and Yes.
|
protected |
Main frame is an internal widget which should contains all elements of dialog box except control buttons.
References myMainFrame.
|
privateslot |
|
privateslot |
This method is called when user presses one of custom user buttons. Emits signal dlgButton(int) with identificator of the clicked user button passed as parameter.
References buttonId(), and dlgButton().
|
privateslot |
obj | button being destroyed |
References buttonId(), myArea, myButton, and myPosition.
|
privateslot |
|
privateslot |
int QtxDialog::placePolicy | ( | const int | area | ) | const |
|
protectedvirtualslot |
This method is used when any reject button is pressed (usually "Close", "Cancel", "No", etc).
If dialog flag QtxDialog::Reject is set, this function invokes rejectData() method, which should in this case return true
to allow further processing.
If rejectData() returns false
, this function just returns.
If rejectData() returns true
, the Rejected result is set and signal according to the pressed control button is emitted. Then the default implementation of reject() method is called (which hides the dialog box and, depending on the dialog box flags, can close and destroy it).
Reimplemented in LightApp_PreferencesDlg.
References button(), Cancel, Close, emitSignal(), mySender, No, Reject, rejectData(), testButtonFlags(), and testDialogFlags().
|
protectedvirtual |
This method can be re-implemented in the successor class if it requires to check possibility to cancel dialog box safely. Default implementation returns true
.
This method is called if dialog flag QtxDialog::Reject is set. If this method returns true
, then dialog will be rejected and closed.
true
if dialog box can be cancelled void QtxDialog::removeButton | ( | const int | id | ) |
If id
is -1, all user buttons are removed.
id | user button ID |
References myArea, myButton, myPosition, and update().
uint QtxDialog::setAlignment | ( | uint | align | ) |
Use the function before the the dialog is first time shown. If dialog flag AlignOnce is set then alignment is performed only once, otherwise the dialog is aligned each time when it is shown. Dialog box is aligned relatively to its parent. By default, dialog box is aligned to the center of the parent widget (usually desktop or another dialog box).
align | alignment flag(s) (Qtx::AlignmentFlags) |
References myAlignment.
Border is a line which separate main frame and control buttons.
area | buttons area (QtxDialog::ButtonArea) |
on | enable border flag |
References isBorderEnabled(), and myArea.
on | enable button(s) flag |
id | control button(s) ID (QtxDialog::ButtonFlags) |
References buttons().
void QtxDialog::setButtonFlags | ( | const int | f | ) |
f | ORed buttons flags (Qtx::ButtonFlags) |
References myButtonFlags, and update().
void QtxDialog::setButtonFocus | ( | const int | id | ) |
id | control button ID (QtxDialog::ButtonFlags) |
References button().
area | buttons area (QtxDialog::ButtonArea) |
id | control button(s) ID (QtxDialog::ButtonFlags) |
References buttons(), QtxDialog::Area::insertButton(), myArea, and QtxDialog::Area::removeButton().
id | control button(s) ID (QtxDialog::ButtonFlags) |
pos | button(s) position (QtxDialog::ButtonPosition) |
References button(), buttons(), myArea, and myPosition.
id | control button ID (QtxDialog::ButtonFlags) |
text | button's text |
References adjustButtons(), and button().
void QtxDialog::setDialogFlags | ( | const int | f | ) |
f | dialog box flags (QtxDialog::DialogFlags) |
References myDialogFlags.
policy | buttons layouting policy (QtxDialog::PlacePolicy) |
area | buttons area (QtxDialog::ButtonArea) |
References myArea.
pos | button(s) position (QtxDialog::ButtonPosition) |
area | buttons area (QtxDialog::ButtonArea) |
References QtxDialog::Area::contains(), QtxDialog::Area::layoutButtons(), myArea, myButton, and myPosition.
In the dialog box label the measure units are closed in braces. If measure units do not exist they will be added.
For example:
aLabel | label widget |
aUnits | measure units |
|
virtualslot |
Re-implemented from Qt.
on | show/hide flag |
Reimplemented in LightApp_PreferencesDlg.
References myInited, SetFocus, and testDialogFlags().
|
protectedvirtual |
Re-implemented from Qt.
e | show event |
References AlignOnce, Qtx::alignWidget(), myAlignment, myInited, and testDialogFlags().
bool QtxDialog::testButtonFlags | ( | const int | f | ) | const |
true
if specified control buttons are used in the dialog box References myButtonFlags.
bool QtxDialog::testDialogFlags | ( | const int | f | ) | const |
true
if specified dialog box falgs are set References myDialogFlags.
|
slot |
References adjustButtons(), myArea, myButton, and testButtonFlags().
QAbstractButton * QtxDialog::userButton | ( | const int | id | ) | const |
id | user button ID |
References myButton.
QIntList QtxDialog::userButtonIds | ( | ) | const |
References myButton.
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |