|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Delete command handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxcommandhandlersave.h" |
|
22 |
|
23 #include <AknUtils.h> |
|
24 #include <AknCommonDialogsDynMem.h> |
|
25 #include <CAknCommonDialogsBase.h> |
|
26 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
27 #include <bautils.h> |
|
28 #include <data_caging_path_literals.hrh> |
|
29 #include <glxcommandhandlers.hrh> |
|
30 #include <glxuiutility.h> |
|
31 #include <glxuistd.h> |
|
32 #include <glxuiutilities.rsg> |
|
33 #include <mglxmedialist.h> |
|
34 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
35 #include <glxscreenfurniture.h> |
|
36 #include <mpxcollectionpath.h> |
|
37 #include <StringLoader.h> |
|
38 #include <f32file.h> |
|
39 #include <glxappui.h> |
|
40 #include <aknViewAppUi.h> |
|
41 #include <glxicons.mbg> |
|
42 #include <glxtracer.h> |
|
43 #include <glxtextentrypopup.h> |
|
44 #include <DocumentHandler.h> |
|
45 #include <apmstd.h> |
|
46 #include <glximageviewermanager.h> |
|
47 #include "glxcommandfactory.h" |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Two-phased constructor. |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CGlxCommandHandlerSave* CGlxCommandHandlerSave::NewL( |
|
57 MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) |
|
58 { |
|
59 TRACER("CGlxCommandHandlerSave::NewL"); |
|
60 CGlxCommandHandlerSave* self = new (ELeave) CGlxCommandHandlerSave(aMediaListProvider, aHasToolbarItem); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop( self ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // C++ default constructor can NOT contain any code, that |
|
69 // might leave. |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CGlxCommandHandlerSave::CGlxCommandHandlerSave(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) |
|
73 : CGlxMpxCommandCommandHandler( aMediaListProvider, aHasToolbarItem ) |
|
74 { |
|
75 // Don't do anything. |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // Symbian 2nd phase constructor can leave. |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CGlxCommandHandlerSave::ConstructL() |
|
83 { |
|
84 TRACER("CGlxCommandHandlerSave::ConstructL"); |
|
85 iUiUtility = CGlxUiUtility::UtilityL(); |
|
86 iImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
|
87 // Load resource file |
|
88 TParse parse; |
|
89 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
90 TFileName resourceFile; |
|
91 resourceFile.Append(parse.FullName()); |
|
92 CGlxResourceUtilities::GetResourceFilenameL(resourceFile); |
|
93 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile); |
|
94 |
|
95 // Add supported command |
|
96 TCommandInfo saveInfo( EGlxCmdSave ); |
|
97 // Filter out static items |
|
98 saveInfo.iMinSelectionLength = 1; |
|
99 AddCommandL(saveInfo); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Destructor |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C CGlxCommandHandlerSave::~CGlxCommandHandlerSave() |
|
107 { |
|
108 TRACER("CGlxCommandHandlerSave::~CGlxCommandHandlerSave"); |
|
109 if (iResourceOffset) |
|
110 { |
|
111 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
112 } |
|
113 if(iUiUtility) |
|
114 { |
|
115 iUiUtility->Close(); |
|
116 } |
|
117 if ( NULL != iImageViewerInstance) |
|
118 { |
|
119 iImageViewerInstance->DeleteInstance(); |
|
120 } |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // Create an add to container command |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 CMPXCommand* CGlxCommandHandlerSave::CreateCommandL(TInt /*aCommandId*/, |
|
128 MGlxMediaList& /*aMediaList*/, TBool& /*aConsume*/) const |
|
129 { |
|
130 TRACER("CGlxCommandHandlerSave::CreateCommandL"); |
|
131 CMPXCommand* command = NULL; |
|
132 TDataType nullType; |
|
133 CDocumentHandler* handler = CDocumentHandler::NewLC( NULL ); |
|
134 HBufC* imagePath = iImageViewerInstance->ImageUri(); |
|
135 TInt err = handler->CopyL( *imagePath, *imagePath, nullType, NULL ); |
|
136 CleanupStack::PopAndDestroy(handler); |
|
137 return command; |
|
138 } |
|
139 // --------------------------------------------------------------------------- |
|
140 // DynInitMenuPaneL |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CGlxCommandHandlerSave::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* aMenuPane) |
|
144 { |
|
145 TRACER("CGlxCommandHandlerSave::DynInitMenuPaneL"); |
|
146 if ( aMenuPane ) |
|
147 { |
|
148 TInt pos; |
|
149 if ( aMenuPane->MenuItemExists(EGlxCmdSave, pos) ) |
|
150 { |
|
151 if(!iImageViewerInstance->IsPrivate()) |
|
152 { |
|
153 aMenuPane->DeleteMenuItem(EGlxCmdSave); |
|
154 } |
|
155 } |
|
156 } |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 // DoActivateL |
|
161 // ---------------------------------------------------------------------------- |
|
162 void CGlxCommandHandlerSave::DoActivateL(TInt /*aViewId*/) |
|
163 { |
|
164 |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------- |
|
168 // OfferKeyEventL |
|
169 // ---------------------------------------------------------------------------- |
|
170 TKeyResponse CGlxCommandHandlerSave::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
171 TEventCode aType) |
|
172 { |
|
173 TKeyResponse response = EKeyWasNotConsumed; |
|
174 // Is the key event from the Cancel (Backspace) key |
|
175 if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey) |
|
176 { |
|
177 // try to execute the delete command |
|
178 if(ExecuteL( EGlxCmdSave )) |
|
179 { |
|
180 response = EKeyWasConsumed; |
|
181 } |
|
182 } |
|
183 return response; |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------------------------------- |
|
187 // PopulateToolbar |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 void CGlxCommandHandlerSave::PopulateToolbarL() |
|
191 { |
|
192 TRACER( "CGlxCommandHandlerRename::PopulateToolbar" ); |
|
193 |
|
194 iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdSave, CAknButton::EPositionLeft ); |
|
195 } |
|
196 |
|
197 |