|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 #include <glxviewids.h> |
|
18 #include <glxmenumanager.h> |
|
19 #include <QDebug> |
|
20 #include <hbaction.h> |
|
21 #include "hbmenu.h" |
|
22 #include <glxcommandhandlers.hrh> |
|
23 #include <QDebug> |
|
24 |
|
25 GlxMenuManager::GlxMenuManager() |
|
26 { |
|
27 } |
|
28 GlxMenuManager::~GlxMenuManager() |
|
29 { |
|
30 } |
|
31 void GlxMenuManager::CreateViewMenu(qint32 viewId,HbMenu* menu,bool empty, int subState) |
|
32 { |
|
33 Q_UNUSED(empty); |
|
34 switch(viewId) |
|
35 { |
|
36 case GLX_GRIDVIEW_ID: { |
|
37 qDebug()<<"GRIDVIEW MENU CREATED"; |
|
38 CreateGridMenu(menu); |
|
39 } |
|
40 break; |
|
41 |
|
42 case GLX_LISTVIEW_ID: { |
|
43 qDebug()<<"LISTVIEW MENU CREATED"; |
|
44 CreateListMenu(menu); |
|
45 } |
|
46 break; |
|
47 case GLX_FULLSCREENVIEW_ID:{ |
|
48 //image viewer state |
|
49 if(2 == subState){ |
|
50 CreateImageViewerMenu(menu); |
|
51 } |
|
52 else{ |
|
53 qDebug()<<"FULLSCREENVIEW MENU CREATED"; |
|
54 CreateFullscreenMenu(menu); |
|
55 } |
|
56 } |
|
57 break; |
|
58 |
|
59 case GLX_DETAILSVIEW_ID: { |
|
60 //will create details specific menu later |
|
61 qDebug()<<"DETAILS VIEW MENU CREATE"; |
|
62 } |
|
63 |
|
64 case GLX_SLIDESHOWVIEW_ID : |
|
65 break; |
|
66 |
|
67 default: |
|
68 break; |
|
69 |
|
70 } |
|
71 } |
|
72 |
|
73 void GlxMenuManager::createMarkingModeMenu(HbMenu* menu) |
|
74 { |
|
75 qDebug()<< "GlxMenuManager::CreateMarkingModeMenu" ; |
|
76 HbAction *action = NULL; |
|
77 |
|
78 action = menu->addAction("Mark All"); |
|
79 action->setData(EGlxCmdMarkAll); |
|
80 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
81 |
|
82 action = menu->addAction("UnMark All"); |
|
83 action->setData(EGlxCmdUnMarkAll); |
|
84 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
85 |
|
86 action = menu->addAction("Help"); |
|
87 action->setData(EGlxCmdUnMarkAll); |
|
88 action->setVisible(FALSE); |
|
89 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
90 menu->setVisible(FALSE); |
|
91 |
|
92 action = menu->addAction("Exit"); |
|
93 action->setData(EGlxCmdUnMarkAll); |
|
94 action->setVisible(FALSE); |
|
95 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
96 menu->setVisible(FALSE); |
|
97 } |
|
98 |
|
99 void GlxMenuManager::CreateGridMenu(HbMenu* menu) |
|
100 { |
|
101 qDebug()<<"GlxMenuManager::CreateGridMenu"; |
|
102 HbAction *action = NULL; |
|
103 action = menu->addAction("Send"); |
|
104 action->setData(EGlxCmdSend); |
|
105 // action->setVisible(EFalse); |
|
106 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
107 |
|
108 /*action = menu->addAction("Upload to web"); |
|
109 action->setData(EGlxCmdUpload); |
|
110 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/ |
|
111 action = menu->addAction("Slide Show"); |
|
112 action->setData(EGlxCmdFirstSlideshow); |
|
113 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
114 action = menu->addAction("Add to album"); |
|
115 action->setData(EGlxCmdAddToAlbum); |
|
116 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
117 /*action = menu->addAction("Sort by"); |
|
118 //action->setData(); |
|
119 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
120 action = menu->addAction("Setting"); |
|
121 //action->setData(); |
|
122 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/ |
|
123 action = menu->addAction("Delete"); |
|
124 action->setData(EGlxCmdDelete); |
|
125 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
126 /*action = menu->addAction("Help"); |
|
127 //action->setData(); |
|
128 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
129 action = menu->addAction("Exit");*/ |
|
130 } |
|
131 |
|
132 void GlxMenuManager::CreateListMenu(HbMenu* menu) |
|
133 { |
|
134 qDebug()<<"GlxMenuManager::CreateListMenu"; |
|
135 /*HbAction *action = menu->addAction("Setting"); |
|
136 //action->setData(); |
|
137 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
138 action = menu->addAction("Help"); |
|
139 //action->setData(); |
|
140 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
141 action = menu->addAction("Exit"); |
|
142 //action->setData(); |
|
143 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/ |
|
144 } |
|
145 |
|
146 void GlxMenuManager::CreateFullscreenMenu(HbMenu* menu) |
|
147 { |
|
148 qDebug()<<"GlxMenuManager::CreateFullscreenMenu"; |
|
149 HbAction *action = NULL; |
|
150 action = menu->addAction("Send"); |
|
151 action->setData(EGlxCmdSend); |
|
152 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
153 action = menu->addAction("Slide Show"); |
|
154 action->setData(EGlxCmdSelectSlideshow); |
|
155 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
156 action = menu->addAction("Add to album"); |
|
157 action->setData(EGlxCmdAddToAlbum); |
|
158 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
159 action = menu->addAction("Rotate"); |
|
160 action->setData(EGlxCmdRotate); |
|
161 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
162 /*action = menu->addAction("Upload to web"); |
|
163 action->setData(EGlxCmdUpload); |
|
164 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
165 action = menu->addAction("Use Image"); |
|
166 //action->setData(); |
|
167 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
168 action = menu->addAction("Print"); |
|
169 //action->setData(); |
|
170 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
171 action = menu->addAction("Edit"); |
|
172 //action->setData(); |
|
173 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
174 action = menu->addAction("Details"); |
|
175 action->setData(EGlxCmdDetailsOption); |
|
176 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
177 action = menu->addAction("Help"); |
|
178 //action->setData(); |
|
179 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
180 action = menu->addAction("Exit"); |
|
181 //action->setData(); |
|
182 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/ |
|
183 } |
|
184 |
|
185 void GlxMenuManager::CreateImageViewerMenu(HbMenu* menu) |
|
186 { |
|
187 } |
|
188 |
|
189 void GlxMenuManager::menuItemSelected() |
|
190 { |
|
191 HbAction *action = qobject_cast<HbAction*>(sender()); |
|
192 |
|
193 qint32 commandId = action->data().toInt(); |
|
194 emit commandTriggered(commandId); |
|
195 } |
|
196 |
|
197 void GlxMenuManager::ShowItemSpecificMenu(qint32 viewId,QPointF pos) |
|
198 { |
|
199 qDebug("GlxMenuManager::showContextMenu " ); |
|
200 HbMenu *mainMenu = new HbMenu(); |
|
201 HbAction *action = NULL; |
|
202 switch ( viewId ) { |
|
203 case GLX_GRIDVIEW_ID : |
|
204 action = mainMenu->addAction("Send"); |
|
205 action->setData(EGlxCmdSend); |
|
206 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
207 |
|
208 action = mainMenu->addAction("Slide Show"); |
|
209 action->setData(EGlxCmdSelectSlideshow); |
|
210 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
211 |
|
212 action = mainMenu->addAction("Add to album"); |
|
213 action->setData(EGlxCmdContextAddToAlbum); |
|
214 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
215 |
|
216 action = mainMenu->addAction("Delete"); |
|
217 action->setData(EGlxCmdContextDelete); |
|
218 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
219 break; |
|
220 |
|
221 case GLX_LISTVIEW_ID : |
|
222 action = mainMenu->addAction("Slide Show"); |
|
223 action->setData(EGlxCmdAlbumSlideShow); |
|
224 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected())); |
|
225 |
|
226 /*action = mainMenu->addAction("Delete"); |
|
227 action->setData(EGlxCmdContextAlbumDelete); |
|
228 connect(action, SIGNAL(triggered()), this, SLOT(menuItemSelected()));*/ |
|
229 break; |
|
230 default: |
|
231 break; |
|
232 } |
|
233 |
|
234 mainMenu->exec(pos); |
|
235 |
|
236 delete mainMenu; |
|
237 |
|
238 } |