src/hbplugins/devicedialogs/devicemessageboxplugin/hbdevicemessageboxwidget.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    36 HbDeviceMessageBoxWidget::HbDeviceMessageBoxWidget(
    36 HbDeviceMessageBoxWidget::HbDeviceMessageBoxWidget(
    37     HbMessageBox::MessageBoxType type, const QVariantMap &parameters) : HbMessageBox(type)
    37     HbMessageBox::MessageBoxType type, const QVariantMap &parameters) : HbMessageBox(type)
    38 {
    38 {
    39     TRACE_ENTRY
    39     TRACE_ENTRY
    40     mLastError = NoError;
    40     mLastError = NoError;
    41     mShowEventReceived = false;
    41     mCloseEventReceived = false;
    42     initActions();
    42     initActions();
    43     connectToActions();
    43     connectToActions();
    44     resetProperties();
    44     resetProperties();
    45     constructDialog(parameters);
    45     constructDialog(parameters);
       
    46     setDismissOnAction(false);
    46     TRACE_EXIT
    47     TRACE_EXIT
    47 }
    48 }
    48 
    49 
    49 // Destructor
    50 // Destructor
    50 HbDeviceMessageBoxWidget::~HbDeviceMessageBoxWidget()
    51 HbDeviceMessageBoxWidget::~HbDeviceMessageBoxWidget()
    65     }
    66     }
    66     else {
    67     else {
    67         mLastError = ParameterError;
    68         mLastError = ParameterError;
    68         ret = false;
    69         ret = false;
    69     }
    70     }
       
    71 
    70     TRACE_EXIT
    72     TRACE_EXIT
    71     return ret;
    73     return ret;
    72 }
    74 }
    73 
    75 
    74 // Get error
    76 // Get error
    85     TRACE_ENTRY
    87     TRACE_ENTRY
    86     Q_UNUSED(byClient);
    88     Q_UNUSED(byClient);
    87     // Closed by client or internally by server -> no action to be transmitted.
    89     // Closed by client or internally by server -> no action to be transmitted.
    88     mSendAction = false;
    90     mSendAction = false;
    89     close();
    91     close();
    90     // If show event has been received, close is signalled from hide event. If not,
       
    91     // hide event does not come and close is signalled from here.
       
    92     if (!mShowEventReceived) {
       
    93         emit deviceDialogClosed();
       
    94     }
       
    95     TRACE_EXIT
    92     TRACE_EXIT
    96 }
    93 }
    97 
    94 
    98 // Return display widget
    95 // Return display widget
    99 HbDialog *HbDeviceMessageBoxWidget::deviceDialogWidget() const
    96 HbDialog *HbDeviceMessageBoxWidget::deviceDialogWidget() const
   266 
   263 
   267 // Widget is about to hide. Closing effect has ended.
   264 // Widget is about to hide. Closing effect has ended.
   268 void HbDeviceMessageBoxWidget::hideEvent(QHideEvent *event)
   265 void HbDeviceMessageBoxWidget::hideEvent(QHideEvent *event)
   269 {
   266 {
   270     HbMessageBox::hideEvent(event);
   267     HbMessageBox::hideEvent(event);
   271     emit deviceDialogClosed();
   268     if (mCloseEventReceived) {
   272 }
   269         emit deviceDialogClosed();
   273 
   270     }
   274 // Widget is about to show
   271 }
   275 void HbDeviceMessageBoxWidget::showEvent(QShowEvent *event)
   272 
   276 {
   273 // Widget is about to close, close() has been called
   277     HbMessageBox::showEvent(event);
   274 void HbDeviceMessageBoxWidget::closeEvent(QCloseEvent *event)
   278     mShowEventReceived = true;
   275 {
       
   276     HbMessageBox::closeEvent(event);
       
   277     mCloseEventReceived = true;
       
   278     // If widget is visible, close is signalled from hide event. If not,
       
   279     // hide event does not come and close is signalled from here.
       
   280     if (!isVisible()) {
       
   281         emit deviceDialogClosed();
       
   282     }
   279 }
   283 }
   280 
   284 
   281 void HbDeviceMessageBoxWidget::setAnimationDefinition(QString &animationDefinition)
   285 void HbDeviceMessageBoxWidget::setAnimationDefinition(QString &animationDefinition)
   282 {
   286 {
   283     // Load animation definition
   287     // Load animation definition
   304 HbMessageBox::StandardButtons HbDeviceMessageBoxWidget::standardButtons() const
   308 HbMessageBox::StandardButtons HbDeviceMessageBoxWidget::standardButtons() const
   305 {
   309 {
   306     return HbMessageBox::standardButtons();
   310     return HbMessageBox::standardButtons();
   307 }
   311 }
   308 
   312 
       
   313 
       
   314 void HbDeviceMessageBoxWidget::setShowLevel(int level)
       
   315 {
       
   316     // Show level can only be set on construction
       
   317     Q_UNUSED(level)
       
   318 }
       
   319 
       
   320 int HbDeviceMessageBoxWidget::showLevel() const
       
   321 {
       
   322     return 0;
       
   323 }
       
   324 
   309 // Action (accept or reject) was triggered
   325 // Action (accept or reject) was triggered
   310 void HbDeviceMessageBoxWidget::actionTriggered()
   326 void HbDeviceMessageBoxWidget::actionTriggered()
   311 {
   327 {
   312     TRACE_ENTRY
   328     TRACE_ENTRY
   313     bool accepted = (sender() == mActions[Accept].mAction);
   329     bool accepted = (sender() == mActions[Accept].mAction);
   314     QVariantMap data;
   330     QVariantMap data;
   315     data.insert("act", accepted ? "p" : "s");
   331     data.insert("act", accepted ? "p" : "s");
   316     emit deviceDialogData(data);
   332     emit deviceDialogData(data);
   317     mSendAction = false;
   333     mSendAction = false;
       
   334     close();
   318     TRACE_EXIT
   335     TRACE_EXIT
   319 }
   336 }
   320 
   337 
   321 // Parse action data and return button text
   338 // Parse action data and return button text
   322 void HbDeviceMessageBoxWidget::parseActionData(QString &data)
   339 void HbDeviceMessageBoxWidget::parseActionData(QString &data)
   352             act->setText(actionData);
   369             act->setText(actionData);
   353         } else {
   370         } else {
   354             // Create action
   371             // Create action
   355             mActions[index].mAction = new HbAction(actionData, 0);
   372             mActions[index].mAction = new HbAction(actionData, 0);
   356             mActions[index].mOwned = true;
   373             mActions[index].mOwned = true;
   357             //connect(mActions[index].mAction, SIGNAL(triggered()), this, SLOT(actionTriggered()));
       
   358         }
   374         }
   359         // Add action to dialog if it's not there
   375         // Add action to dialog if it's not there
   360         if (!mActions[index].mInDialog) {
   376         if (!mActions[index].mInDialog) {
   361             mActions[index].mInDialog = true;
   377             mActions[index].mInDialog = true;
   362             QAction *before = 0;
   378             QAction *before = 0;