src/hbwidgets/popups/hbmessagebox.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 7 923ff622b8b9
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include "hbmessagebox_p.h"
    26 #include "hbnamespace_p.h"
    27 #include "hbnamespace_p.h"
    27 #include <hbmessagebox.h>
    28 #include <hbmessagebox.h>
    28 #include "hbmessagebox_p.h"
       
    29 #include <hbstyleoptionmessagebox_p.h>
    29 #include <hbstyleoptionmessagebox_p.h>
    30 #include <hbmainwindow.h>
    30 #include <hbmainwindow.h>
    31 #include <hbaction.h>
    31 #include <hbaction.h>
    32 #include <hblineedit.h>
    32 #include <hblineedit.h>
    33 #include <hbscrollbar.h>
    33 #include <hbscrollbar.h>
    35 #include "hbglobal_p.h"
    35 #include "hbglobal_p.h"
    36 #include <QGraphicsItem>
    36 #include <QGraphicsItem>
    37 #include <QGraphicsSceneMouseEvent>
    37 #include <QGraphicsSceneMouseEvent>
    38 #include <QTimer>
    38 #include <QTimer>
    39 #include <QTextOption>
    39 #include <QTextOption>
       
    40 #ifdef Q_OS_SYMBIAN
       
    41 #include <systemtoneservice.h>
       
    42 #endif
    40 
    43 
    41 class HbStyle;
    44 class HbStyle;
    42 
    45 
    43 class HbMessageBoxEditor : public HbLineEdit
    46 class HbMessageBoxEditor : public HbLineEdit
    44 {
    47 {
       
    48 	Q_OBJECT
    45 public:
    49 public:
    46     HbMessageBoxEditor(QGraphicsItem* parent =0) : HbLineEdit(parent),mText()
    50     HbMessageBoxEditor(QGraphicsItem* parent =0) : HbLineEdit(parent),mText()
    47     {
    51     {
    48         setReadOnly(true);
    52         setReadOnly(true);
    49         setCursorVisibility(Hb::TextCursorHidden);
    53         setCursorVisibility(Hb::TextCursorHidden);
    50         HbScrollArea *scroll = scrollArea();
    54         HbScrollArea *scroll = scrollArea();
    51         scroll->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
    55         scroll->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded);
    52         clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
    56         clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
    53         clearContextMenuFlag(Hb::ShowTextContextMenuOnSelectionClicked);
    57         clearContextMenuFlag(Hb::ShowTextContextMenuOnSelectionClicked);
    54         primitive(HbStyle::P_LineEdit_frame_normal)->setVisible(false);        
    58         setBackgroundItem(0,0);     
    55         primitive(HbStyle::P_LineEdit_frame_highlight)->setVisible(false);        
       
    56     }
       
    57 
       
    58     HbScrollBar * getScrollBar() const
       
    59     {
       
    60         HbScrollArea *scroll = scrollArea();
       
    61         return scroll->verticalScrollBar();
       
    62     }
    59     }
    63 
    60 
    64     void focusInEvent(QFocusEvent * event)
    61     void focusInEvent(QFocusEvent * event)
    65     {
    62     {
    66         Q_UNUSED(event);         
    63         Q_UNUSED(event);         
    71     }
    68     }
    72 
    69 
    73     void setHtmlText(const QString &text)
    70     void setHtmlText(const QString &text)
    74     {
    71     {
    75         mText = text;
    72         mText = text;
    76         setHtml(text);
    73         if(Qt::mightBeRichText(mText)){
    77     }
    74             setHtml(text);
       
    75         }
       
    76         else {
       
    77              QString htmlString = Qt::convertFromPlainText(mText);
       
    78              setHtml(htmlString);
       
    79         }
       
    80      }
    78 
    81 
    79     QString htmlText() const
    82     QString htmlText() const
    80     {
    83     {
    81         return mText;
    84         return mText;
    82     }
    85     }
   114 
   117 
   115 HbMessageBoxPrivate::HbMessageBoxPrivate() :
   118 HbMessageBoxPrivate::HbMessageBoxPrivate() :
   116     HbDialogPrivate(),
   119     HbDialogPrivate(),
   117     mIcon(),
   120     mIcon(),
   118     mMessageBoxContentWidget(0),
   121     mMessageBoxContentWidget(0),
   119     mMessageBoxType(HbMessageBox::MessageTypeInformation),
   122     mMessageBoxType(HbMessageBox::MessageTypeNone),
   120     mIconVisible(true)
   123     mIconVisible(true)
   121 {
   124 {
   122 }
   125 }
   123 
   126 
   124 void HbMessageBoxPrivate::_q_closeOnGesture()
   127 void HbMessageBoxPrivate::_q_buttonClicked()
   125 {
   128 {
   126 }
   129     Q_Q(HbMessageBox);    
   127 
   130     HbAction *action = static_cast<HbAction*>(q->sender());
       
   131     q->done(mActionList.value(action));
       
   132 }
   128 /*
   133 /*
   129     destructor
   134     destructor
   130 */
   135 */
   131 HbMessageBoxPrivate::~HbMessageBoxPrivate()
   136 HbMessageBoxPrivate::~HbMessageBoxPrivate()
   132 {
   137 {
   136     init()
   141     init()
   137 */
   142 */
   138 void HbMessageBoxPrivate::init()
   143 void HbMessageBoxPrivate::init()
   139 {
   144 {
   140     Q_Q(HbMessageBox);
   145     Q_Q(HbMessageBox);
   141 
   146        
       
   147     mMessageBoxContentWidget = new HbMessageBoxContentWidget( this );
       
   148     q->setContentWidget( mMessageBoxContentWidget );
       
   149     q->setDismissPolicy(HbPopup::NoDismiss);
       
   150     q->setTimeout(HbPopup::NoTimeout);      
       
   151     q->setStandardButtons(HbMessageBox::Ok);
       
   152     
   142     switch(mMessageBoxType) {
   153     switch(mMessageBoxType) {
       
   154     case HbMessageBox::MessageTypeNone:
       
   155         mMessageBoxContentWidget->mIconItem->hide();
       
   156         mMessageBoxContentWidget->setProperty("hasIcon",false);
       
   157         break;
   143     case HbMessageBox::MessageTypeInformation:
   158     case HbMessageBox::MessageTypeInformation:
   144     case HbMessageBox::MessageTypeWarning:
   159     case HbMessageBox::MessageTypeWarning:
   145         mMessageBoxContentWidget = new HbMessageBoxContentWidget( this );
   160     case HbMessageBox::MessageTypeQuestion:
   146         q->setContentWidget( mMessageBoxContentWidget );
       
   147         q->setDismissPolicy(HbPopup::NoDismiss);
       
   148         q->setTimeout(HbPopup::NoTimeout);      
       
   149         q->addAction(new HbAction(q->tr("OK"),q));
       
   150         break;
   161         break;
   151 
   162         
   152     case HbMessageBox::MessageTypeQuestion:
   163     }
   153         mMessageBoxContentWidget = new HbMessageBoxContentWidget( this );
   164 
   154         q->setContentWidget( mMessageBoxContentWidget );
   165 }
   155         q->setDismissPolicy(HbPopup::NoDismiss);
   166 void HbMessageBoxPrivate::_q_appearEffectEnded(HbEffect::EffectStatus status)
   156         q->setTimeout(HbPopup::NoTimeout);       
   167 {
   157         q->addAction(new HbAction(q->tr("Yes"),q));
   168 #ifdef Q_OS_SYMBIAN 
   158         q->addAction(new HbAction(q->tr("No"),q));
   169 	
   159         break;
   170     	if ( (status.reason == Hb::EffectFinished) ||  ( (status.reason == Hb::EffectCancelled) && (!mStartEffect) ))  {
   160     }
   171 	        CSystemToneService *pSystemTone = systemToneService();
   161 
   172 			if(!pSystemTone) {
       
   173 				return ;
       
   174 			}
       
   175 			switch(mMessageBoxType) {
       
   176     		case HbMessageBox::MessageTypeInformation:
       
   177     			pSystemTone->PlayTone(CSystemToneService::EInformationBeep); 
       
   178     			break;
       
   179     		case HbMessageBox::MessageTypeWarning:
       
   180     			pSystemTone->PlayTone(CSystemToneService::EWarningBeep); 
       
   181     			break;
       
   182     		case HbMessageBox::MessageTypeQuestion:
       
   183     			pSystemTone->PlayTone(CSystemToneService::EConfirmationBeep); 
       
   184         	break;
       
   185       	default:
       
   186       		break;        
       
   187     	}
       
   188 
       
   189 		}
       
   190 #else
       
   191 	Q_UNUSED(status);
       
   192 #endif // Q_OS_SYMBIAN
   162 }
   193 }
   163 
   194 
   164 /*!
   195 /*!
   165     @beta
   196     @beta
   166     
   197     
   167     \class HbMessageBox
   198     \class HbMessageBox
   168     \brief HbMessageBox is a convenience modal dialog class, using which a simple information, a question, or a simple warning can be shown to the user.
   199     \brief HbMessageBox is a convenience modal dialog class. HbMessageBox can be used to launch a information,question,warning or any other 
       
   200     general messages.
       
   201 
       
   202 	\image html information.PNG  "An information MessageBox"
       
   203 	\image html question.PNG  "A question MessageBox"
       
   204 	\image html warning.PNG  "A warning MessageBox"
   169 
   205 
   170     Using HbMessageBox, the following dialogs can be created:
   206     Using HbMessageBox, the following dialogs can be created:
   171 
   207 
   172     <b>Information:</b> a statement to the user to which they may respond by acknowledging the information ('OK').<br>
   208     <b>Information:</b> a statement to the user to which they may respond by acknowledging the information ('Ok').<br>
   173     <b>Question:</b> a query to the user requiring a response. User needs to select between two alternatives, the positive or negative (For example: 'Delete Mailbox?' 'Yes'/'No').<br>
   209     <b>Question:</b> a query to the user requiring a response. User needs to select between two alternatives, the positive or negative (For example: 'Delete Mailbox?' 'Yes'/'No').<br>
   174     <b>Warning:</b> a statement to the user to which they may respond by acknowledging the warning ('OK').<br>
   210     <b>Warning:</b> a statement to the user to which they may respond by acknowledging the warning ('OK').<br>
   175     
   211     <b>None:</b> Any general messages to which user responds. 
   176     By default, Message box launches an information dialog which contains a description text and user actions visualized as command buttons.
   212     
       
   213     By default, Message box launches a None dialog which can contain a text, an icon and action buttons
   177 
   214 
   178     Default properties for the MessageBox (warning, information and question dialogs) are:
   215     Default properties for the MessageBox (warning, information and question dialogs) are:
   179 
   216 
   180     Description text: Text shown to the user as information. The amount of text rows is not limited, but after five rows the text starts scrolling.
   217     Description text: Text shown to the user as information. The amount of text rows is not limited, but after five rows the text starts scrolling.
   181     Icon: Default icons are available for each dialog type using the MessageBox template. Changing the default icons is not recommended.
   218     Icon: Default icons are available for each dialog type using the MessageBox template. Changing the default icons is not recommended.
   182     Action buttons (one or two): one button for information and warning MessageBox, two buttons for question MessageBox.
   219     Action button : One action button ("Ok") for all the types.
   183     
   220     
   184     All the three dialogs(information, warning, question) supported by MessageBox are by default modal in nature, with
   221     All the four dialogs(information, warning, question and none) supported by MessageBox are by default modal in nature, with
   185     a dismiss policy of NoDismiss, timeout policy of NoTimeout, and with a BackgroundFade property on.
   222     a dismiss policy of NoDismiss, timeout policy of NoTimeout, and with a BackgroundFade property on.
   186 
   223 
   187     Example code for launching MessageBox using static convenience functions:
   224     Example code for launching MessageBox using static convenience functions:
   188 
   225 
   189     \code
   226     \code
   190     //Information MessageBox
   227     //Information MessageBox
   191     HbMessageBox::information(informationText, this, SLOT(onDialogClose(HbAction*)), headWidget, scene, parent);
   228     HbMessageBox::information("The file is deleted",0,0,HbMessageBox::Ok);
   192 
   229 
   193     //Warning MessageBox
   230     //Warning MessageBox
   194     HbMessageBox::warning(warningText, this, SLOT(onDialogClose(HbAction*)), headWidget, scene, parent);
   231     HbMessageBox::warning("This will change the name",0,0,HbMessageBox::Ok);
   195 
   232 
   196     //Question MessageBox
   233     //Question MessageBox
   197     HbMessageBox::question(questionText, this, SLOT(onDialogClose(HbAction*)), primaryButtonText, secondaryButtonText, headWidget, scene, parent);
   234      HbMessageBox::question("Do you want to delete the file ?", this, SLOT(onDialogClose(int)),HbMessageBox::Yes |HbMessageBox::No );
   198     \endcode
   235     \endcode
   199 
   236 
   200     Example code to show an information messagebox:
   237     Example code to show an information messagebox:
   201 
       
   202     \code
   238     \code
   203     HbMessageBox *box = new HbMessageBox("This is an information dialog.");
   239     HbMessageBox *box = new HbMessageBox("This is a general note.");
   204     box->setAttribute(Qt::WA_DeleteOnClose);
   240     box->setAttribute(Qt::WA_DeleteOnClose);
   205     box->open();
   241     box->open();
   206     \endcode
   242     \endcode
   207 
   243 
   208     Example code to show an information messagebox with two action buttons:
       
   209     \code
       
   210     HbMessageBox *box = new HbMessageBox("XX will be deleted. Do you want to Continue ? ");
       
   211 
       
   212     //Add new action.
       
   213     box->addAction(new HbAction(HbWidget::tr("Cancel"), q));
       
   214 
       
   215     box->setAttribute(Qt::WA_DeleteOnClose);
       
   216 
       
   217     box->open();
       
   218     \endcode
       
   219 
       
   220     Example code to show a question messagebox with a return value based action
   244     Example code to show a question messagebox with a return value based action
   221     \code
   245     \code
   222     HbMessageBox *box = new HbMessageBox(" Delete file IC0002 ? ",HbMessageBox::MessageTypeQuestion);
   246     HbMessageBox *box = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
       
   247     box->setText("Delete file IC0002 ? ");
   223     box->setAttribute(Qt::WA_DeleteOnClose);
   248     box->setAttribute(Qt::WA_DeleteOnClose);
   224     box->open(this,SLOT(dialogClosed(HbAction*)));
   249     box->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
   225 
   250     box->open(this,SLOT(onDialogClosed(int)));
       
   251     
   226     //Slot implementation
   252     //Slot implementation
   227     void dialogClosed(HbAction *action)
   253     void MessageBoxView::onDialogClosed(int action)
   228     {
   254     {
   229         HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
   255          if (action == HbMessageBox::Yes) {
   230         if(action == dlg->actions().at(0)) 
   256           //User Clicked Yes//
   231         {
   257           //Delete the file//
   232             // Delete file 
   258          }
   233         }
   259          else if (action == HbMessageBox::No) {
   234         else
   260           //User Clicked No//
   235         {
   261           //do not delete the file//
   236            // Cancellation is done.Dont delete the file
   262          }
   237         }
   263         
   238      }
   264     }
       
   265     \endcode     
       
   266 
       
   267     Example code to show a question messagebox using static API
       
   268      \code
       
   269      HbMessageBox::question("Delete file IC0002 ? ",this,SLOT(onDialogClosed(int)),HbMessageBox::Yes | HbMessageBox::No);  
       
   270      // Here the SLOT implementation is same as above
   239      \endcode     
   271      \endcode     
   240 
   272 
       
   273 
   241     \enum HbMessageBox::MessageBoxType
   274     \enum HbMessageBox::MessageBoxType
   242 
   275 
   243     \value \b MessageTypeInformation creates a modal information dialog, which by default will have one OK button 
   276     \value \b MessageTypeNone creates a modal dialog, which by default will have one OK button 
   244         for the user to dismiss the dialog.
   277         for the user to dismiss the dialog.
   245 
   278 
   246     \value \b MessageTypeWarning creates a simple modal dialog with a warning icon and a description text. 
   279     \value \b MessageTypeWarning creates a simple modal dialog with a warning icon and a description text. 
   247         Dialog by default will have one OK button, for the user to dismiss the dialog. 
   280         This Dialog by default will have one Ok button, for the user to dismiss the dialog. 
   248 
   281 
   249     \value \b MessageTypeQuestion Shows a modal dialog with question icon and a description text. The user can either confirm or
   282     \value \b MessageTypeWarning creates a simple modal dialog with a information icon and a description text. 
   250         reject the dialog. By default dialog supports two buttons, using which user can dismiss the dialog. 
   283         This Dialog by default will have one Ok button, for the user to dismiss the dialog. 
   251 
   284 
       
   285      \value \b MessageTypeQuestion creates a simple modal dialog with a question icon and a description text. 
       
   286         This Dialog by default will have one Ok button, for the user to dismiss the dialog.  
   252 */
   287 */
   253 
   288 
   254 /*!
   289 /*!
   255     Constructs a MessageBox with \a type and a \a parent.
   290     Constructs a MessageBox with \a type and a \a parent.
   256     \param type User can create information/warning/question dialogs by passing appropriate MessageBoxType.
   291     \param type User can create information/warning/question dialogs by passing appropriate MessageBoxType.
   346     }
   381     }
   347    
   382    
   348 }
   383 }
   349 
   384 
   350 /*!
   385 /*!
   351     Sets the descriptive text for the messagebox.
   386     Sets the descriptive text for the messagebox. It can be in plain text format or html format.
   352     \param text Descriptive text for the MessageBox
   387     \param text Descriptive text for the MessageBox
   353     \sa text()
   388     \sa text()
   354 */
   389 */
   355 void HbMessageBox::setText(const QString &text)
   390 void HbMessageBox::setText(const QString &text)
   356 {
   391 {
   382         d->mIcon = icon;
   417         d->mIcon = icon;
   383         if (d->mMessageBoxContentWidget->mIconItem) {
   418         if (d->mMessageBoxContentWidget->mIconItem) {
   384             HbStyleOptionMessageBox option;
   419             HbStyleOptionMessageBox option;
   385             initStyleOption(&option);
   420             initStyleOption(&option);
   386             style()->updatePrimitive(d->mMessageBoxContentWidget->mIconItem, HbStyle::P_MessageBox_icon, &option);
   421             style()->updatePrimitive(d->mMessageBoxContentWidget->mIconItem, HbStyle::P_MessageBox_icon, &option);
       
   422         }
       
   423         if(iconVisible() ) {
       
   424             d->mMessageBoxContentWidget->mIconItem->show();
       
   425             d->mMessageBoxContentWidget->setProperty("hasIcon",true);
   387         }
   426         }
   388     }
   427     }
   389 }
   428 }
   390 
   429 
   391 /*!
   430 /*!
   433 {
   472 {
   434     Q_D(const HbMessageBox);
   473     Q_D(const HbMessageBox);
   435     return d->mIconVisible;
   474     return d->mIconVisible;
   436 
   475 
   437 }
   476 }
   438 
   477 /*!
   439 
   478     sets the buttons for the dialog. If the Application wants "Yes" and "No" buttons 
   440 /*!
   479     can set it like setStandardButtons(HbMessageBox::Yes | HbMessageBox::No).
   441     This is a convenience function for showing a question dialog with \a questionText and buttons with specified \a primaryButtonText and
   480     If only yes Button then setStandardButtons(HbMessageBox::Yes).
   442     \a secondaryButtonText. 
   481    
       
   482    \param buttons the button set
       
   483     \sa standardButtons()
       
   484 
       
   485 */
       
   486 void HbMessageBox::setStandardButtons(HbMessageBox::StandardButtons buttons)
       
   487 {
       
   488     Q_D(HbMessageBox); 
       
   489     if(d->mStandardButtons == buttons ) {
       
   490         return;
       
   491     }
       
   492     clearActions();
       
   493     d->mStandardButtons = buttons;
       
   494     uint i = HbMessageBox::Ok;        
       
   495     int count =0;
       
   496     while (i <= HbMessageBox::Reset) {
       
   497          HbAction *action=0;
       
   498          if (i & buttons) {
       
   499              StandardButton button = HbMessageBox::StandardButton(i);
       
   500              switch(button){
       
   501                     case Ok:
       
   502                           action = new HbAction(hbTrId("txt_common_button_ok"),this); 
       
   503                           d->mActionList.insert(action,Ok);
       
   504                           break;
       
   505                     case Save:
       
   506                           action = new HbAction(hbTrId("txt_common_button_save"),this); 
       
   507                           d->mActionList.insert(action,Save);
       
   508                           break;
       
   509                     case Open:
       
   510                           action = new HbAction(hbTrId("txt_common_button_open"),this); 
       
   511                           d->mActionList.insert(action,Open);
       
   512                           break;
       
   513                      case Yes:
       
   514                           action = new HbAction(hbTrId("txt_common_button_yes"),this); 
       
   515                           d->mActionList.insert(action,Yes);
       
   516                           break;
       
   517                       case No:
       
   518                           action = new HbAction(hbTrId("txt_common_button_no"),this);                         
       
   519                           d->mActionList.insert(action,No);
       
   520                           break;
       
   521                       case Retry:
       
   522                           action = new HbAction(hbTrId("txt_common_button_retry"),this);  
       
   523                           d->mActionList.insert(action,Retry);
       
   524                           break;                      
       
   525                       case Continue:
       
   526                           action = new HbAction(hbTrId("txt_common_button_continue"),this);  
       
   527                           d->mActionList.insert(action,Continue);
       
   528                           break;
       
   529                       case Close:
       
   530                           action = new HbAction(hbTrId("txt_common_button_close"),this);
       
   531                           d->mActionList.insert(action,Close);
       
   532                           break;
       
   533                        case Cancel:
       
   534                           action = new HbAction(hbTrId("txt_common_button_cancel"),this); 
       
   535                           d->mActionList.insert(action,Cancel);
       
   536                           break;
       
   537                        case Help:
       
   538                           action = new HbAction(hbTrId("txt_common_button_help"),this); 
       
   539                           d->mActionList.insert(action,Help);
       
   540                           break;
       
   541                        case Reset:
       
   542                           action = new HbAction(hbTrId("txt_common_button_reset"),this);    
       
   543                           d->mActionList.insert(action,Reset);
       
   544                           break;
       
   545                        case Delete:
       
   546                           action = new HbAction(hbTrId("txt_common_button_delete"),this);
       
   547                           d->mActionList.insert(action,Delete);
       
   548                           break;
       
   549                        default :
       
   550                            break;
       
   551 
       
   552                 };
       
   553             
       
   554             }
       
   555             i = i << 1;
       
   556 
       
   557             if(action) {
       
   558                 connect(action,SIGNAL(triggered()),this,SLOT(_q_buttonClicked()));
       
   559                 addAction(action);                
       
   560                 count++;
       
   561             }
       
   562             
       
   563         }
       
   564 }
       
   565 /*!
       
   566    Returns the standared button list
       
   567    
       
   568    \sa setStandardButtons()
       
   569 
       
   570 */
       
   571 HbMessageBox::StandardButtons HbMessageBox::standardButtons() const
       
   572 {
       
   573     Q_D(const HbMessageBox);
       
   574     return d->mStandardButtons;
       
   575 
       
   576 }
       
   577 
       
   578 /*!
       
   579 
       
   580     \deprecated HbMessageBox::question(const QString&,QObject*,const char*,const QString&,const QString&,QGraphicsWidget*,QGraphicsScene*,QGraphicsItem*)
       
   581         is deprecated.
       
   582 
       
   583     Please use 
       
   584     
       
   585     question(const QString &questionText,
       
   586                                             QObject *receiver,
       
   587                                             const char *member,
       
   588                                             HbMessageBox::StandardButtons buttons,
       
   589                                             QGraphicsWidget *headWidget,
       
   590                                             QGraphicsScene *scene,
       
   591                                             QGraphicsItem *parent)
       
   592 
       
   593     This is a convenience function for showing a question dialog with \a questionText with provided buttons.
   443     \param questionText descriptive text for the messagebox
   594     \param questionText descriptive text for the messagebox
   444     \param receiver Object which has the slot, which acts as a handler once the dialog closes.
   595     \param receiver Object which has the slot, which acts as a handler once the dialog closes.
   445     \param member the slot, where the control will come, once the dialog is closed.
   596     \param member the slot, where the control will come, once the dialog is closed.
   446     \param primaryButtonText text for the primary button.
   597     \param primaryButtonText text for the primary button.
   447     \param secondaryButtonText text for the secondary button.
   598     \param secondaryButtonText text for the secondary button.
   478     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   629     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   479     messageBox->open(receiver,member);
   630     messageBox->open(receiver,member);
   480 }
   631 }
   481      
   632      
   482 /*!
   633 /*!
       
   634     \deprecated HbMessageBox::information(const QString&,QObject*,const char*,QGraphicsWidget*,QGraphicsScene*,QGraphicsItem*)
       
   635         is deprecated.
       
   636 
       
   637     Please use 
       
   638     
       
   639     information(const QString &questionText,
       
   640                                             QObject *receiver,
       
   641                                             const char *member,
       
   642                                             HbMessageBox::StandardButtons buttons,
       
   643                                             QGraphicsWidget *headWidget,
       
   644                                             QGraphicsScene *scene,
       
   645                                             QGraphicsItem *parent)
   483     This is a convenience function for showing an information dialog with a descriptive text and a default OK button.
   646     This is a convenience function for showing an information dialog with a descriptive text and a default OK button.
   484     \param informationText Descriptive text for the information dialog.
   647     \param informationText Descriptive text for the information dialog.
   485     \param receiver Which has the slot, which acts as a handler once the dialog closes.
   648     \param receiver Which has the slot, which acts as a handler once the dialog closes.
   486     \param member the slot, where the control will come, once the dialog is closed.
   649     \param member the slot, where the control will come, once the dialog is closed.
   487     \param headWidget This can used by the user to set a title widget. Null by default.
   650     \param headWidget This can used by the user to set a title widget. Null by default.
   506     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   669     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   507     messageBox->open(receiver,member);
   670     messageBox->open(receiver,member);
   508 }
   671 }
   509                                                                                               
   672                                                                                               
   510 /*!
   673 /*!
       
   674     \deprecated HbMessageBox::warning(const QString&,QObject*,const char*,QGraphicsWidget*,QGraphicsScene*,QGraphicsItem*)
       
   675         is deprecated.
       
   676 
       
   677     Please use 
       
   678     
       
   679     warning(const QString &questionText,
       
   680                                             QObject *receiver,
       
   681                                             const char *member,
       
   682                                             HbMessageBox::StandardButtons buttons,
       
   683                                             QGraphicsWidget *headWidget,
       
   684                                             QGraphicsScene *scene,
       
   685                                             QGraphicsItem *parent)
       
   686 
   511     This is a convenience function for showing a warning dialog with a descriptive text and an OK button.
   687     This is a convenience function for showing a warning dialog with a descriptive text and an OK button.
   512     \param warningText Descriptive text for the warning dialog.
   688     \param warningText Descriptive text for the warning dialog.
   513     \param receiver Which has the slot, which acts as a handler once the dialog closes.
   689     \param receiver Which has the slot, which acts as a handler once the dialog closes.
   514     \param member the slot, where the control will come, once the dialog is closed.
   690     \param member the slot, where the control will come, once the dialog is closed.
   515     \param headWidget This can used by the user to set a title widget, Null by default.
   691     \param headWidget This can used by the user to set a title widget, Null by default.
   532         messageBox->setHeadingWidget(headWidget);
   708         messageBox->setHeadingWidget(headWidget);
   533     }
   709     }
   534     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   710     messageBox->setAttribute(Qt::WA_DeleteOnClose);
   535     messageBox->open(receiver,member);
   711     messageBox->open(receiver,member);
   536 }
   712 }
       
   713 
       
   714 /*!
       
   715     This is a convenience function for showing a question dialog with \a questionText and a default OK button.
       
   716     \param questionText descriptive text for the messagebox
       
   717     \param receiver Object which has the slot, which acts as a handler once the dialog closes.
       
   718     \param member the slot, where the control will come, once the dialog is closed.The signature of member is void dialogClosed(int val);
       
   719     \param buttons The action buttons of the dialog.
       
   720     \param headWidget the heading widget, where the user can set a title, Null by default.
       
   721     \param scene the scene for the MessageBox. Null by default.
       
   722     \param parent the parent widget. Null by default.
       
   723 */
       
   724 void HbMessageBox::question(const QString &questionText,
       
   725                                             QObject *receiver,
       
   726                                             const char *member,
       
   727                                             HbMessageBox::StandardButtons buttons,
       
   728                                             QGraphicsWidget *headingWidget,
       
   729                                             QGraphicsScene *scene,
       
   730                                             QGraphicsItem *parent)
       
   731 {    
       
   732     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion, parent);
       
   733     if (scene && !parent) {
       
   734         scene->addItem(messageBox);
       
   735     }
       
   736     messageBox->setText(questionText);
       
   737 
       
   738     messageBox->setStandardButtons(buttons);   
       
   739     
       
   740     if(headingWidget) {
       
   741         messageBox->setHeadingWidget(headingWidget);
       
   742     }
       
   743     messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
   744     messageBox->open(receiver,member);
       
   745 }
       
   746      
       
   747 /*!
       
   748     This is a convenience function for showing an information dialog with a descriptive text and a default OK button.
       
   749     \param informationText Descriptive text for the information dialog.
       
   750     \param receiver Which has the slot, which acts as a handler once the dialog closes.
       
   751     \param member the slot, where the control will come, once the dialog is closed.The signature of member is void dialogClosed(int val);
       
   752     \param buttons The action buttons of the dialog.
       
   753     \param headWidget This can used by the user to set a title widget. Null by default.
       
   754     \param scene the scene for the MessageBox, Null by default.
       
   755     \param parent the parent widget. Null by default
       
   756 */
       
   757 void HbMessageBox::information(const QString &informationText,
       
   758                                                QObject *receiver,
       
   759                                                const char *member,
       
   760                                                HbMessageBox::StandardButtons buttons,
       
   761                                                QGraphicsWidget *headingWidget,
       
   762                                                QGraphicsScene *scene,
       
   763                                                QGraphicsItem *parent)
       
   764 {
       
   765     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation, parent);
       
   766     if (scene && !parent) {
       
   767         scene->addItem(messageBox);
       
   768     }
       
   769     messageBox->setText(informationText);
       
   770 
       
   771     messageBox->setStandardButtons(buttons);   
       
   772 
       
   773     if(headingWidget) {
       
   774         messageBox->setHeadingWidget(headingWidget);
       
   775     }
       
   776     messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
   777     messageBox->open(receiver,member);
       
   778 }
       
   779                                                                                               
       
   780 /*!
       
   781     This is a convenience function for showing a warning dialog with a descriptive text and an OK button.
       
   782     \param warningText Descriptive text for the warning dialog.
       
   783     \param receiver Which has the slot, which acts as a handler once the dialog closes.
       
   784     \param member the slot, where the control will come, once the dialog is closed.The signature of member is void dialogClosed(int val);
       
   785     \param buttons The action buttons of the dialog.
       
   786     \param headWidget This can used by the user to set a title widget, Null by default.
       
   787     \param scene the scene for the messagebox, Null by default.
       
   788     \param parent the parent widget, Null by default.
       
   789 */
       
   790 void HbMessageBox::warning(const QString &warningText,
       
   791                                            QObject *receiver,
       
   792                                            const char *member,
       
   793                                            HbMessageBox::StandardButtons buttons,
       
   794                                            QGraphicsWidget *headingWidget,
       
   795                                            QGraphicsScene *scene,
       
   796                                            QGraphicsItem *parent)
       
   797 {
       
   798     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning, parent);
       
   799     if (scene && !parent) {
       
   800         scene->addItem(messageBox);
       
   801     }
       
   802     messageBox->setText(warningText);
       
   803 
       
   804     messageBox->setStandardButtons(buttons);   
       
   805 
       
   806     if(headingWidget) {
       
   807         messageBox->setHeadingWidget(headingWidget);
       
   808     }
       
   809     messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
   810     messageBox->open(receiver,member);
       
   811 }
   537 #include "moc_hbmessagebox.cpp"
   812 #include "moc_hbmessagebox.cpp"
   538 #include "hbmessagebox.moc"
   813 #include "hbmessagebox.moc"
   539 
   814