125 mContextMenu = new HbMenu(); |
125 mContextMenu = new HbMenu(); |
126 } else { |
126 } else { |
127 mContextMenu->clearActions(); |
127 mContextMenu->clearActions(); |
128 } |
128 } |
129 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
129 FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName ); |
|
130 FmDriverInfo::DriveType driveType = driverInfo.driveType(); |
130 FmDriverInfo::DriveState state = driverInfo.driveState(); |
131 FmDriverInfo::DriveState state = driverInfo.driveState(); |
131 if( !( state & FmDriverInfo::EDriveNotPresent ) ) { |
132 if( !( state & FmDriverInfo::EDriveNotPresent ) ) { |
132 if( state & FmDriverInfo::EDriveAvailable ) { |
133 if( state & FmDriverInfo::EDriveAvailable ) { |
133 HbAction *viewAction = new HbAction(); |
134 HbAction *viewAction = new HbAction(); |
134 viewAction->setObjectName( "viewAction" ); |
135 viewAction->setObjectName( "viewAction" ); |
135 viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) ); |
136 viewAction->setText( hbTrId( "txt_fmgr_menu_view_details_memory" ) ); |
136 mContextMenu->addAction( viewAction ); |
137 mContextMenu->addAction( viewAction ); |
137 |
|
138 //state = 0x210; |
|
139 |
|
140 connect( viewAction, SIGNAL( triggered() ), |
138 connect( viewAction, SIGNAL( triggered() ), |
141 this, SLOT( on_viewAction_triggered() ), Qt::QueuedConnection ); |
139 this, SLOT( on_viewAction_triggered() ), Qt::QueuedConnection ); |
142 } |
140 |
143 |
141 if( driveType == FmDriverInfo::EDriveTypeMemoryCard || driveType == FmDriverInfo::EDriveTypeUsbMemory ) { |
144 if( ( state & FmDriverInfo::EDriveAvailable ) && ( state & FmDriverInfo::EDriveRemovable ) && !( state & FmDriverInfo::EDriveMassStorage ) ){ |
142 // MMC or Usb memory |
145 // MMC or Usb memory |
143 |
146 if ( driverInfo.volumeName().length() ){ |
144 // Name/Rename action |
147 HbAction *renameAction = new HbAction(); |
145 if ( driverInfo.volumeName().length() ){ |
148 renameAction->setObjectName( "renameAction" ); |
146 HbAction *renameAction = new HbAction(); |
149 renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) ); |
147 renameAction->setObjectName( "renameAction" ); |
150 mContextMenu->addAction( renameAction ); |
148 renameAction->setText( hbTrId( "txt_fmgr_menu_rename" ) ); |
151 |
149 mContextMenu->addAction( renameAction ); |
152 connect( renameAction, SIGNAL( triggered() ), |
150 |
153 this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection ); |
151 connect( renameAction, SIGNAL( triggered() ), |
|
152 this, SLOT( on_renameAction_triggered() ), Qt::QueuedConnection ); |
|
153 } else { |
|
154 HbAction *nameAction = new HbAction(); |
|
155 nameAction->setObjectName( "nameAction" ); |
|
156 nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) ); |
|
157 mContextMenu->addAction( nameAction ); |
|
158 |
|
159 connect( nameAction, SIGNAL( triggered() ), |
|
160 this, SLOT( on_nameAction_triggered() ), Qt::QueuedConnection ); |
|
161 } |
|
162 |
|
163 // Set/Change/Remove password action |
|
164 if( driveType == FmDriverInfo::EDriveTypeMemoryCard ) { // MMC |
|
165 if( state & FmDriverInfo::EDrivePasswordProtected ){ |
|
166 HbAction *changePwdAction = new HbAction(); |
|
167 changePwdAction->setObjectName( "changePwdAction" ); |
|
168 changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) ); |
|
169 mContextMenu->addAction( changePwdAction ); |
|
170 |
|
171 HbAction *removePwdAction = new HbAction(); |
|
172 removePwdAction->setObjectName( "removePwdAction" ); |
|
173 removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) ); |
|
174 mContextMenu->addAction( removePwdAction ); |
|
175 |
|
176 connect( changePwdAction, SIGNAL( triggered() ), |
|
177 this, SLOT( on_changePwdAction_triggered() ), Qt::QueuedConnection ); |
|
178 connect( removePwdAction, SIGNAL( triggered() ), |
|
179 this, SLOT( on_removePwdAction_triggered() ), Qt::QueuedConnection ); |
|
180 } |
|
181 else{ |
|
182 HbAction *setPwdAction = new HbAction(); |
|
183 setPwdAction->setObjectName( "setPwdAction" ); |
|
184 setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) ); |
|
185 mContextMenu->addAction( setPwdAction ); |
|
186 |
|
187 connect( setPwdAction, SIGNAL( triggered() ), |
|
188 this, SLOT( on_setPwdAction_triggered() ), Qt::QueuedConnection ); |
|
189 } |
|
190 } |
|
191 |
|
192 // Eject action |
|
193 if( state & FmDriverInfo::EDriveEjectable ){ |
|
194 HbAction *ejectAction = new HbAction(); |
|
195 ejectAction->setObjectName( "ejectAction" ); |
|
196 ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) ); |
|
197 mContextMenu->addAction( ejectAction ); |
|
198 |
|
199 connect( ejectAction, SIGNAL( triggered() ), |
|
200 this, SLOT( on_ejectAction_triggered() ), Qt::QueuedConnection ); |
|
201 } |
154 } |
202 } |
155 else{ |
203 } |
156 HbAction *nameAction = new HbAction(); |
|
157 nameAction->setObjectName( "nameAction" ); |
|
158 nameAction->setText( hbTrId( "txt_fmgr_menu_name" ) ); |
|
159 mContextMenu->addAction( nameAction ); |
|
160 |
|
161 connect( nameAction, SIGNAL( triggered() ), |
|
162 this, SLOT( on_nameAction_triggered() ), Qt::QueuedConnection ); |
|
163 } |
|
164 if( !( state & FmDriverInfo::EDriveUsbMemory ) ) { // MMC |
|
165 if( state & FmDriverInfo::EDrivePasswordProtected ){ |
|
166 HbAction *changePwdAction = new HbAction(); |
|
167 changePwdAction->setObjectName( "changePwdAction" ); |
|
168 changePwdAction->setText( hbTrId( "txt_fmgr_menu_change_password" ) ); |
|
169 mContextMenu->addAction( changePwdAction ); |
|
170 |
204 |
171 HbAction *removePwdAction = new HbAction(); |
205 // Format action |
172 removePwdAction->setObjectName( "removePwdAction" ); |
206 if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted ) |
173 removePwdAction->setText( hbTrId( "txt_fmgr_menu_remove_password" ) ); |
|
174 mContextMenu->addAction( removePwdAction ); |
|
175 |
|
176 connect( changePwdAction, SIGNAL( triggered() ), |
|
177 this, SLOT( on_changePwdAction_triggered() ), Qt::QueuedConnection ); |
|
178 connect( removePwdAction, SIGNAL( triggered() ), |
|
179 this, SLOT( on_removePwdAction_triggered() ), Qt::QueuedConnection ); |
|
180 } |
|
181 else{ |
|
182 HbAction *setPwdAction = new HbAction(); |
|
183 setPwdAction->setObjectName( "setPwdAction" ); |
|
184 setPwdAction->setText( hbTrId( "txt_fmgr_menu_set_password" ) ); |
|
185 mContextMenu->addAction( setPwdAction ); |
|
186 |
|
187 connect( setPwdAction, SIGNAL( triggered() ), |
|
188 this, SLOT( on_setPwdAction_triggered() ), Qt::QueuedConnection ); |
|
189 } |
|
190 } |
|
191 } |
|
192 |
|
193 if( state & FmDriverInfo::EDriveEjectable ){ |
|
194 HbAction *ejectAction = new HbAction(); |
|
195 ejectAction->setObjectName( "ejectAction" ); |
|
196 ejectAction->setText( hbTrId( "txt_fmgr_menu_eject" ) ); |
|
197 mContextMenu->addAction( ejectAction ); |
|
198 |
|
199 connect( ejectAction, SIGNAL( triggered() ), |
|
200 this, SLOT( on_ejectAction_triggered() ), Qt::QueuedConnection ); |
|
201 } |
|
202 |
|
203 #ifndef _DEBUG_ENABLE_FORMATMENU_ |
|
204 if ( ( state & FmDriverInfo::EDriveRemovable ) || ( state & FmDriverInfo::EDriveCorrupted ) |
|
205 || ( state & FmDriverInfo::EDriveLocked ) ){ |
207 || ( state & FmDriverInfo::EDriveLocked ) ){ |
206 #endif |
|
207 HbAction *formatAction = new HbAction(); |
208 HbAction *formatAction = new HbAction(); |
208 formatAction->setObjectName( "formatAction" ); |
209 formatAction->setObjectName( "formatAction" ); |
209 formatAction->setText( hbTrId( "txt_fmgr_menu_format" ) ); |
210 formatAction->setText( hbTrId( "txt_fmgr_menu_format" ) ); |
210 mContextMenu->addAction( formatAction ); |
211 mContextMenu->addAction( formatAction ); |
211 |
212 |
212 connect( formatAction, SIGNAL( triggered() ), |
213 connect( formatAction, SIGNAL( triggered() ), |
213 this, SLOT( on_formatAction_triggered() ), Qt::QueuedConnection ); |
214 this, SLOT( on_formatAction_triggered() ), Qt::QueuedConnection ); |
214 #ifndef _DEBUG_ENABLE_FORMATMENU_ |
215 } |
215 } |
216 } |
216 #endif |
217 |
217 |
218 // Unlock action |
218 if( state & FmDriverInfo::EDriveLocked ){ |
219 // put ouside of !EDriveNotPresent judgement so that |
219 HbAction *unLockedAction = new HbAction(); |
220 // user could unlock drive if connected to PC with mass storage mode |
220 unLockedAction->setObjectName( "unLockedAction" ); |
221 if( state & FmDriverInfo::EDriveLocked ){ |
221 unLockedAction->setText( hbTrId( "Unlock" ) ); |
222 HbAction *unLockedAction = new HbAction(); |
222 mContextMenu->addAction( unLockedAction ); |
223 unLockedAction->setObjectName( "unLockedAction" ); |
223 |
224 unLockedAction->setText( hbTrId( "Unlock" ) ); |
224 connect( unLockedAction, SIGNAL( triggered() ), |
225 mContextMenu->addAction( unLockedAction ); |
225 this, SLOT( on_unLockedAction_triggered() ), Qt::QueuedConnection ); |
226 |
226 } |
227 connect( unLockedAction, SIGNAL( triggered() ), |
227 } |
228 this, SLOT( on_unLockedAction_triggered() ), Qt::QueuedConnection ); |
|
229 } |
|
230 |
|
231 // Pop up menu or open drive |
228 if( mContextMenu->actions().count() > 0 ) { |
232 if( mContextMenu->actions().count() > 0 ) { |
229 mContextMenu->setPreferredPos( coords ); |
233 mContextMenu->setPreferredPos( coords ); |
230 mContextMenu->open(); |
234 mContextMenu->open(); |
231 } else { |
235 } else { |
232 emit activated( diskName ); |
236 emit activated( diskName ); |