Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions
QtPromptService Class Reference

#include <QtPromptService.h>

Inheritance diagram for QtPromptService:
Inheritance graph
[legend]
Collaboration diagram for QtPromptService:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QtPromptService ()
virtual ~QtPromptService ()
void alert (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText)
 Puts up an alert dialog with an OK button.
void alertCheck (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, in wstring aCheckMsg, inout boolean aCheckState)
 Puts up an alert dialog with an OK button and a labeled checkbox.
boolean confirm (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText)
 Puts up a dialog with OK and Cancel buttons.
boolean confirmCheck (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, in wstring aCheckMsg, inout boolean aCheckState)
 Puts up a dialog with OK and Cancel buttons and a labeled checkbox.
PRInt32 confirmEx (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, in unsigned long aButtonFlags, in wstring aButton0Title, in wstring aButton1Title, in wstring aButton2Title, in wstring aCheckMsg, inout boolean aCheckState)
 Puts up a dialog with up to 3 buttons and an optional, labeled checkbox.
boolean prompt (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, inout wstring aValue, in wstring aCheckMsg, inout boolean aCheckState)
 Puts up a dialog with an edit field and an optional, labeled checkbox.
boolean promptUsernameAndPassword (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, inout wstring aUsername, inout wstring aPassword, in wstring aCheckMsg, inout boolean aCheckState)
 Puts up a dialog with an edit field, a password field, and an optional, labeled checkbox.
boolean promptPassword (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, inout wstring aPassword, in wstring aCheckMsg, inout boolean aCheckState)
 Puts up a dialog with a password field and an optional, labeled checkbox.
boolean select (in nsIDOMWindow aParent, in wstring aDialogTitle, in wstring aText, in PRUint32 aCount,[array, size_is(aCount)] in wstring aSelectList, out long aOutSelection)
 Puts up a dialog box which has a list box of strings from which the user may make a single selection.

Public Attributes

const unsigned long BUTTON_POS_0 = 1
 Button Flags.
const unsigned long BUTTON_POS_1 = 1 << 8
const unsigned long BUTTON_POS_2 = 1 << 16
const unsigned long BUTTON_TITLE_OK = 1
 Button Title Flags (used to set the labels of buttons in the prompt)
const unsigned long BUTTON_TITLE_CANCEL = 2
const unsigned long BUTTON_TITLE_YES = 3
const unsigned long BUTTON_TITLE_NO = 4
const unsigned long BUTTON_TITLE_SAVE = 5
const unsigned long BUTTON_TITLE_DONT_SAVE = 6
const unsigned long BUTTON_TITLE_REVERT = 7
const unsigned long BUTTON_TITLE_IS_STRING = 127
const unsigned long BUTTON_POS_0_DEFAULT = 0
 Button Default Flags (used to select which button is the default one)
const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24
const unsigned long BUTTON_POS_2_DEFAULT = 1 << 25
const unsigned long BUTTON_DELAY_ENABLE = 1 << 26
 Causes the buttons to be initially disabled.
const unsigned long STD_OK_CANCEL_BUTTONS
 Selects the standard set of OK/Cancel buttons.
const unsigned long STD_YES_NO_BUTTONS
 Selects the standard set of Yes/No buttons.

Private Member Functions

QWidget * GetQWidgetForDOMWindow (nsIDOMWindow *aDOMWindow)
QString GetButtonLabel (PRUint32 aFlags, PRUint32 aPos, const PRUnichar *aStringValue)

Detailed Description

Definition at line 47 of file QtPromptService.h.


Constructor & Destructor Documentation

Definition at line 68 of file QtPromptService.cpp.

{
}

Definition at line 72 of file QtPromptService.cpp.

{
}

Member Function Documentation

void nsIPromptService::alert ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText 
) [inherited]

Puts up an alert dialog with an OK button.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
void nsIPromptService::alertCheck ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
in wstring  aCheckMsg,
inout boolean  aCheckState 
) [inherited]

Puts up an alert dialog with an OK button and a labeled checkbox.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aCheckMsgText to appear with the checkbox.
aCheckStateContains the initial checked state of the checkbox when this method is called and the final checked state after this method returns.
boolean nsIPromptService::confirm ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText 
) [inherited]

Puts up a dialog with OK and Cancel buttons.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
Returns:
true for OK, false for Cancel
boolean nsIPromptService::confirmCheck ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
in wstring  aCheckMsg,
inout boolean  aCheckState 
) [inherited]

Puts up a dialog with OK and Cancel buttons and a labeled checkbox.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aCheckMsgText to appear with the checkbox.
aCheckStateContains the initial checked state of the checkbox when this method is called and the final checked state after this method returns.
Returns:
true for OK, false for Cancel
PRInt32 nsIPromptService::confirmEx ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
in unsigned long  aButtonFlags,
in wstring  aButton0Title,
in wstring  aButton1Title,
in wstring  aButton2Title,
in wstring  aCheckMsg,
inout boolean  aCheckState 
) [inherited]

Puts up a dialog with up to 3 buttons and an optional, labeled checkbox.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aButtonFlagsA combination of Button Flags.
aButton0TitleUsed when button 0 uses TITLE_IS_STRING
aButton1TitleUsed when button 1 uses TITLE_IS_STRING
aButton2TitleUsed when button 2 uses TITLE_IS_STRING
aCheckMsgText to appear with the checkbox. Null if no checkbox.
aCheckStateContains the initial checked state of the checkbox when this method is called and the final checked state after this method returns.
Returns:
index of the button pressed.

Buttons are numbered 0 - 2. The implementation can decide whether the sequence goes from right to left or left to right. Button 0 is the default button unless one of the Button Default Flags is specified.

A button may use a predefined title, specified by one of the Button Title Flags values. Each title value can be multiplied by a position value to assign the title to a particular button. If BUTTON_TITLE_IS_STRING is used for a button, the string parameter for that button will be used. If the value for a button position is zero, the button will not be shown.

In general, aButtonFlags is constructed per the following example:

aButtonFlags = (BUTTON_POS_0) * (BUTTON_TITLE_AAA) + (BUTTON_POS_1) * (BUTTON_TITLE_BBB) + BUTTON_POS_1_DEFAULT;

where "AAA" and "BBB" correspond to one of the button titles.

QString QtPromptService::GetButtonLabel ( PRUint32  aFlags,
PRUint32  aPos,
const PRUnichar aStringValue 
) [private]

Definition at line 468 of file QtPromptService.cpp.

{
    PRUint32 posFlag = (aFlags & (255 * aPos)) / aPos;
    switch (posFlag) {
    case BUTTON_TITLE_OK:
        return qApp->translate("QtPromptService", "&OK");
    case BUTTON_TITLE_CANCEL:
        return qApp->translate("QtPromptService", "&Cancel");
    case BUTTON_TITLE_YES:
        return qApp->translate("QtPromptService", "&Yes");
    case BUTTON_TITLE_NO:
        return qApp->translate("QtPromptService", "&No");
    case BUTTON_TITLE_SAVE:
        return qApp->translate("QtPromptService", "&Save");
    case BUTTON_TITLE_DONT_SAVE:
        return qApp->translate("QtPromptService", "&Don't Save");
    case BUTTON_TITLE_REVERT:
        return qApp->translate("QtPromptService", "&Revert");
    case BUTTON_TITLE_IS_STRING:
        return qApp->translate("QtPromptService",
                               QString::fromUcs2(aStringValue));
    case 0:
        return QString::null;
    default:
        NS_WARNING("Unexpected button flags");
        return QString::null;
    }
}
QWidget * QtPromptService::GetQWidgetForDOMWindow ( nsIDOMWindow aDOMWindow) [private]

Definition at line 454 of file QtPromptService.cpp.

{
    nsCOMPtr<nsIWindowWatcher> wwatch = do_GetService("@mozilla.org/embedcomp/window-watcher;1");

    nsCOMPtr<nsIWebBrowserChrome> chrome;
    wwatch->GetChromeForWindow(aDOMWindow, getter_AddRefs(chrome));
    nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow = do_QueryInterface(chrome);
    QWidget* parentWidget;
    siteWindow->GetSiteWindow((void**)&parentWidget);

    return parentWidget;
}

Here is the call graph for this function:

boolean nsIPromptService::prompt ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
inout wstring  aValue,
in wstring  aCheckMsg,
inout boolean  aCheckState 
) [inherited]

Puts up a dialog with an edit field and an optional, labeled checkbox.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aValueContains the default value for the dialog field when this method is called (null value is ok). Upon return, if the user pressed OK, then this parameter contains a newly allocated string value. Otherwise, the parameter's value is unmodified.
aCheckMsgText to appear with the checkbox. If null, check box will not be shown.
aCheckStateContains the initial checked state of the checkbox when this method is called and the final checked state after this method returns.
Returns:
true for OK, false for Cancel.
boolean nsIPromptService::promptPassword ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
inout wstring  aPassword,
in wstring  aCheckMsg,
inout boolean  aCheckState 
) [inherited]

Puts up a dialog with a password field and an optional, labeled checkbox.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aPasswordContains the default value for the password field when this method is called (null value is ok). Upon return, if the user pressed OK, then this parameter contains a newly allocated string value. Otherwise, the parameter's value is unmodified.
aCheckMsgText to appear with the checkbox. If null, check box will not be shown.
aCheckStateContains the initial checked state of the checkbox when this method is called and the final checked state after this method returns.
Returns:
true for OK, false for Cancel.
boolean nsIPromptService::promptUsernameAndPassword ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
inout wstring  aUsername,
inout wstring  aPassword,
in wstring  aCheckMsg,
inout boolean  aCheckState 
) [inherited]

Puts up a dialog with an edit field, a password field, and an optional, labeled checkbox.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aUsernameContains the default value for the username field when this method is called (null value is ok). Upon return, if the user pressed OK, then this parameter contains a newly allocated string value. Otherwise, the parameter's value is unmodified.
aPasswordContains the default value for the password field when this method is called (null value is ok). Upon return, if the user pressed OK, then this parameter contains a newly allocated string value. Otherwise, the parameter's value is unmodified.
aCheckMsgText to appear with the checkbox. If null, check box will not be shown.
aCheckStateContains the initial checked state of the checkbox when this method is called and the final checked state after this method returns.
Returns:
true for OK, false for Cancel.
boolean nsIPromptService::select ( in nsIDOMWindow  aParent,
in wstring  aDialogTitle,
in wstring  aText,
in PRUint32  aCount,
[array, size_is(aCount)] in wstring  aSelectList,
out long  aOutSelection 
) [inherited]

Puts up a dialog box which has a list box of strings from which the user may make a single selection.

Parameters:
aParentThe parent window or null.
aDialogTitleText to appear in the title of the dialog.
aTextText to appear in the body of the dialog.
aCountThe length of the aSelectList array parameter.
aSelectListThe list of strings to display.
aOutSelectionContains the index of the selected item in the list when this method returns true.
Returns:
true for OK, false for Cancel.

Member Data Documentation

const unsigned long nsIPromptService::BUTTON_DELAY_ENABLE = 1 << 26 [inherited]

Causes the buttons to be initially disabled.

They are enabled after a timeout expires. The implementation may interpret this loosely as the intent is to ensure that the user does not click through a security dialog too quickly. Strictly speaking, the implementation could choose to ignore this flag.

Definition at line 192 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_POS_0 = 1 [inherited]

Button Flags.

The following flags are combined to form the aButtonFlags parameter passed to confirmEx. See confirmEx for more information on how the flags may be combined. Button Position Flags

Definition at line 162 of file nsIPromptService.idl.

Button Default Flags (used to select which button is the default one)

Definition at line 181 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_POS_1 = 1 << 8 [inherited]

Definition at line 163 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_POS_1_DEFAULT = 1 << 24 [inherited]

Definition at line 182 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_POS_2 = 1 << 16 [inherited]

Definition at line 164 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_POS_2_DEFAULT = 1 << 25 [inherited]

Definition at line 183 of file nsIPromptService.idl.

Definition at line 170 of file nsIPromptService.idl.

Definition at line 174 of file nsIPromptService.idl.

Definition at line 176 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_TITLE_NO = 4 [inherited]

Definition at line 172 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_TITLE_OK = 1 [inherited]

Button Title Flags (used to set the labels of buttons in the prompt)

Definition at line 169 of file nsIPromptService.idl.

Definition at line 175 of file nsIPromptService.idl.

Definition at line 173 of file nsIPromptService.idl.

const unsigned long nsIPromptService::BUTTON_TITLE_YES = 3 [inherited]

Definition at line 171 of file nsIPromptService.idl.

Initial value:

Selects the standard set of OK/Cancel buttons.

Definition at line 197 of file nsIPromptService.idl.

Initial value:

Selects the standard set of Yes/No buttons.

Definition at line 203 of file nsIPromptService.idl.


The documentation for this class was generated from the following files: