17 |
17 |
18 #include <HbMessageBox> |
18 #include <HbMessageBox> |
19 #include "hsuinstallfailedstate.h" |
19 #include "hsuinstallfailedstate.h" |
20 #include "hsmenuevent.h" |
20 #include "hsmenuevent.h" |
21 #include "hsapp_defs.h" |
21 #include "hsapp_defs.h" |
|
22 #include "hsdialogcontroller.h" |
22 |
23 |
23 const int installerBusyError = 4; |
24 const int installerBusyError = 4; |
24 |
25 |
25 /*! |
26 /*! |
26 Constructor. |
27 Constructor. |
27 /param parent Parent state. |
28 /param parent Parent state. |
28 */ |
29 */ |
29 HsUninstallFailedState::HsUninstallFailedState(QState *parent) : |
30 HsUninstallFailedState::HsUninstallFailedState(QState *parent) : |
30 QState(parent), mBox(0) |
31 QState(parent) |
31 { |
32 { |
32 construct(); |
33 construct(); |
33 } |
34 } |
34 |
35 |
35 /*! |
36 /*! |
36 Destructor |
37 Destructor |
37 */ |
38 */ |
38 HsUninstallFailedState::~HsUninstallFailedState() |
39 HsUninstallFailedState::~HsUninstallFailedState() |
39 { |
40 { |
40 cleanUp(); // in case of throw |
41 QT_TRY { |
|
42 emit exit(); |
|
43 } QT_CATCH (...) { |
|
44 } |
41 } |
45 } |
42 |
46 |
43 /*! |
47 /*! |
44 Construction |
48 Construction |
45 */ |
49 */ |
47 { |
51 { |
48 setObjectName("/HsUninstallFailedState"); |
52 setObjectName("/HsUninstallFailedState"); |
49 if (this->parent()) { |
53 if (this->parent()) { |
50 setObjectName(this->parent()->objectName() + objectName()); |
54 setObjectName(this->parent()->objectName() + objectName()); |
51 } |
55 } |
52 |
|
53 connect(this, SIGNAL(exited()), SLOT(cleanUp())); |
|
54 } |
56 } |
55 |
57 |
56 |
58 |
57 /*! |
59 /*! |
58 Sets entry event. |
60 Sets entry event. |
59 \param event entry event. |
61 \param event entry event. |
60 */ |
62 */ |
61 void HsUninstallFailedState::onEntry(QEvent *event) |
63 void HsUninstallFailedState::onEntry(QEvent *event) |
62 { |
64 { |
63 |
|
64 |
|
65 QState::onEntry(event); |
65 QState::onEntry(event); |
66 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
66 HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event); |
67 QVariantMap data = menuEvent->data(); |
67 QVariantMap data = menuEvent->data(); |
68 int error = data.value(Hs::uninstallError).toInt(); |
68 int error = data.value(Hs::uninstallError).toInt(); |
|
69 QScopedPointer<HbMessageBox> dialog; |
69 if (error == installerBusyError) { |
70 if (error == installerBusyError) { |
70 // Installer is in use |
71 // Installer is in use |
71 mBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); |
72 dialog.reset(new HbMessageBox(HbMessageBox::MessageTypeInformation)); |
72 mBox->setText(hbTrId("txt_applib_info_installer_is_currently_busy")); |
73 dialog->setText(hbTrId("txt_applib_info_installer_is_currently_busy")); |
73 } else { |
74 } else { |
74 // other errors |
75 // other errors |
75 mBox = new HbMessageBox(HbMessageBox::MessageTypeWarning); |
76 dialog.reset(new HbMessageBox(HbMessageBox::MessageTypeWarning)); |
76 mBox->setText(hbTrId("txt_applib_info_uninstallation_failed")); |
77 dialog->setText(hbTrId("txt_applib_info_uninstallation_failed")); |
77 } |
78 } |
78 |
79 |
79 mBox->setAttribute(Qt::WA_DeleteOnClose); |
80 |
80 mBox->setStandardButtons(HbMessageBox::Close); |
81 dialog->setStandardButtons(HbMessageBox::Close); |
81 mBox->open(this, SLOT(stateExited())); |
82 |
|
83 QScopedPointer<HsDialogController> dialogController( |
|
84 new HsDialogController(dialog.take(), |
|
85 HsMenuDialogFactory::acceptActionIndex(), |
|
86 HsMenuDialogFactory::rejectActionIndex())); |
|
87 |
|
88 connect(dialogController.data(), |
|
89 SIGNAL(dialogCompleted()), |
|
90 this, |
|
91 SIGNAL(exit())); |
|
92 |
|
93 // ensure dialog is dismissed on app key pressed |
|
94 connect(this, SIGNAL(exited()), |
|
95 dialogController.data(), |
|
96 SLOT(dismissDialog())); |
|
97 |
|
98 dialogController.take()->openDialog(); |
82 } |
99 } |
83 |
100 |
84 /*! |
|
85 Invoked on exiting state |
|
86 */ |
|
87 void HsUninstallFailedState::onExit(QEvent *event) |
|
88 { |
|
89 QState::onExit(event); |
|
90 } |
|
91 |
101 |
92 /*! |
|
93 State exited. |
|
94 */ |
|
95 void HsUninstallFailedState::stateExited() |
|
96 { |
|
97 mBox = NULL; |
|
98 emit exit(); |
|
99 } |
|
100 |
102 |
101 /*! |
|
102 Slot launched after state has exited and in destructor. |
|
103 \retval void |
|
104 */ |
|
105 void HsUninstallFailedState::cleanUp() |
|
106 { |
|
107 // Close popups if App key was pressed |
|
108 if (mBox) { |
|
109 mBox->close(); |
|
110 mBox = NULL; |
|
111 } |
|
112 } |
|