|
1 #include "ToolBar.h" |
|
2 #include "ScreenSize.h" |
|
3 #include <qinputdialog.h> |
|
4 #include <qplaintextedit.h> |
|
5 #include <qdir.h> //Checl lateer |
|
6 #include <qmessagebox.h> |
|
7 #include <qdebug.h> |
|
8 #include <qtooltip.h> |
|
9 //#include <apacmdln.h> |
|
10 //#include <apgcli.h> |
|
11 |
|
12 |
|
13 //MACRO |
|
14 #define KNullUid TUid::Null() |
|
15 |
|
16 //Forward declaration |
|
17 class ScreenSize; |
|
18 |
|
19 ToolBar::ToolBar() |
|
20 { |
|
21 |
|
22 } |
|
23 ToolBar::~ToolBar() |
|
24 { |
|
25 |
|
26 } |
|
27 void ToolBar::GetToolBar(QMainWindow *Mainwindow,QStringList aListOfActions) |
|
28 { |
|
29 //iMainWindow = new QMainWindow; |
|
30 iMainWindow = Mainwindow; |
|
31 |
|
32 QHBoxLayout* layout = new QHBoxLayout; |
|
33 QToolBar* tool = new QToolBar(Mainwindow); |
|
34 QToolButton* button1 = new QToolButton(Mainwindow); |
|
35 QToolButton* button2 = new QToolButton(Mainwindow); |
|
36 QToolButton* button3 = new QToolButton(Mainwindow); |
|
37 QToolButton* button4 = new QToolButton(Mainwindow); |
|
38 |
|
39 tool->setGeometry(0,ScreenSize::GetScreenRect().height() - (ToolbarIconHeight + KWidgetGapFactor),(ScreenSize::GetScreenRect().width()-(KWidgetGapFactor)),ToolbarIconHeight); |
|
40 |
|
41 //ToDo :- Ankit to check on button resizing |
|
42 const int IconWidth = ScreenSize::GetScreenRect().width()/7; |
|
43 button1->setGeometry(0,ScreenSize::GetScreenRect().height() - (ToolbarIconHeight + KWidgetGapFactor),IconWidth,ToolbarIconHeight); |
|
44 |
|
45 button1->setFixedWidth(IconWidth); |
|
46 button2->setFixedWidth(IconWidth); |
|
47 button3->setFixedWidth(IconWidth); |
|
48 button4->setFixedWidth(IconWidth); |
|
49 |
|
50 |
|
51 QIcon icon1("E:/Images/SMF/home.svg"); |
|
52 QIcon icon2("E:/Images/SMF/all_friends.svg"); //next.PNG |
|
53 QIcon icon3("E:/Images/SMF/mail-message-new.svg"); |
|
54 QIcon icon4("E:/Images/SMF/Phone.svg"); |
|
55 QIcon icon5("E:/Images/SMF/system-log-out.svg"); |
|
56 |
|
57 button1->setIcon(icon1); |
|
58 button2->setIcon(icon3); |
|
59 button3->setIcon(icon4); |
|
60 button4->setIcon(icon5); |
|
61 |
|
62 button1->setToolTip("Home"); |
|
63 |
|
64 menu = new QMenu(Mainwindow); |
|
65 icon2.actualSize(QSize(IconWidth-10,ToolbarIconHeight)); |
|
66 //menu->setFixedWidth(IconWidth+10); |
|
67 menu->setIcon(icon2); |
|
68 |
|
69 QMenu *addServ = new QMenu(Mainwindow); |
|
70 addServ->setTitle(aListOfActions.at(0)); |
|
71 |
|
72 //For Facebook and Flickr SP |
|
73 QAction *addServ_Facebk = new QAction("FaceBook",Mainwindow); |
|
74 QAction *addServ_Flickr = new QAction("Flickr",Mainwindow); |
|
75 |
|
76 |
|
77 addServ->addAction(addServ_Facebk); |
|
78 addServ->addAction(addServ_Flickr); |
|
79 |
|
80 // } |
|
81 //Create Actions |
|
82 //newAction1 = new QAction(aListOfActions.at(1),Mainwindow); |
|
83 //newAction2 = new QAction(aListOfActions.at(2),Mainwindow); |
|
84 |
|
85 //need to be modified |
|
86 //menu->addAction(newAction1); |
|
87 //menu->addAction(newAction2); |
|
88 |
|
89 //to add services to the menu button |
|
90 menu->addMenu(addServ); |
|
91 |
|
92 //TODO: button to be disabled |
|
93 //button2->setEnabled(false); |
|
94 //button3->setEnabled(false); |
|
95 |
|
96 tool->addWidget(button1); |
|
97 tool->addAction(menu->menuAction()); |
|
98 tool->addWidget(button2); |
|
99 tool->addWidget(button3); |
|
100 tool->addWidget(button4); |
|
101 |
|
102 layout->addWidget(tool); |
|
103 |
|
104 //connect actions |
|
105 connect(button1,SIGNAL(clicked()),this,SLOT(homeView())); |
|
106 connect(button2,SIGNAL(clicked()),this,SLOT(msg())); |
|
107 connect(button3,SIGNAL(clicked()),this,SLOT(call())); |
|
108 connect(button4,SIGNAL(clicked()),this,SLOT(exitApp())); |
|
109 //connect(newAction1,SIGNAL(triggered()),this,SLOT(post())); |
|
110 //connect(newAction2,SIGNAL(triggered()),this,SLOT(reply())); |
|
111 |
|
112 //connect for authentication |
|
113 connect(addServ_Facebk,SIGNAL(triggered()),this,SLOT(authApp_Fb())); |
|
114 connect(addServ_Flickr,SIGNAL(triggered()),this,SLOT(authApp_Flkr())); |
|
115 |
|
116 } |
|
117 |
|
118 //changing to home view |
|
119 void ToolBar::homeView() |
|
120 { |
|
121 //debug |
|
122 qDebug()<<"Inside View_Change()"; |
|
123 } |
|
124 |
|
125 |
|
126 |
|
127 //slot for post comment |
|
128 /*void ToolBar::post() |
|
129 { |
|
130 //debug purpose |
|
131 qDebug()<<"Inside My Post"; |
|
132 bool ok; |
|
133 QInputDialog inptDialg; |
|
134 inptDialg.setStyleSheet("background: black;");//rgb(255,255,255);"); |
|
135 QString text = inptDialg.getText(iMainWindow, tr("QInputDialog::getText()"),tr("Post"), |
|
136 QLineEdit::Normal,QString::null, &ok,Qt::Window); |
|
137 |
|
138 |
|
139 if ( ok && !text.isEmpty() ) { |
|
140 // user entered something and pressed OK |
|
141 } else { |
|
142 // user entered nothing or pressed Cancel |
|
143 } |
|
144 |
|
145 |
|
146 }*/ |
|
147 |
|
148 //slot for reply comment |
|
149 /*void ToolBar::reply() |
|
150 { |
|
151 //debug purpose |
|
152 qDebug()<<"Inside Reply"; |
|
153 |
|
154 bool ok; |
|
155 QString text = QInputDialog::getText(iMainWindow, tr("QInputDialog::getText()"),tr("Reply To Post"), |
|
156 QLineEdit::Normal,QString::null, &ok,Qt::Window); |
|
157 |
|
158 |
|
159 if ( ok && !text.isEmpty() ) { |
|
160 // user entered something and pressed OK |
|
161 } else { |
|
162 // user entered nothing or pressed Cancel |
|
163 } |
|
164 |
|
165 |
|
166 }*/ |
|
167 //calling |
|
168 //calling |
|
169 void ToolBar::call() |
|
170 { |
|
171 QMessageBox msgbox; |
|
172 QString msg ("Calling not configured!"); |
|
173 msgbox.setText(msg); |
|
174 msgbox.exec(); |
|
175 } |
|
176 |
|
177 |
|
178 |
|
179 //msging |
|
180 void ToolBar::msg() |
|
181 { |
|
182 QMessageBox msgbox; |
|
183 QString msg ("Messaging not configured!"); |
|
184 msgbox.setText(msg); |
|
185 msgbox.exec(); |
|
186 } |
|
187 //exiting application |
|
188 void ToolBar::exitApp() |
|
189 { |
|
190 //qDebug()<<"Inside Exit_App()"; |
|
191 QApplication::exit(); |
|
192 } |
|
193 |
|
194 |
|
195 //Auth_App for FaceBook |
|
196 void ToolBar::authApp_Fb() |
|
197 { |
|
198 //debug |
|
199 qDebug()<<"Inside Auth app of faceBook"; |
|
200 launchFB(); |
|
201 } |
|
202 |
|
203 //Auth App for Flickr |
|
204 void ToolBar::authApp_Flkr() |
|
205 { |
|
206 //debug |
|
207 qDebug()<<"Inside Auth App of Flickr"; |
|
208 launchFlickr(); |
|
209 } |
|
210 |
|
211 |
|
212 //Facebook AuthApp Launch |
|
213 void ToolBar::launchFB() |
|
214 { |
|
215 qDebug()<<"Inside Launch FB AuthApp"; |
|
216 QMessageBox msgbox; |
|
217 QString msg ("Please Login Using Facebook Auth App!"); |
|
218 msgbox.setText(msg); |
|
219 msgbox.exec(); |
|
220 /*TInt result; |
|
221 _LIT(KExecutableName,"release\\winscw\\udeb\\AuthApp.exe"); |
|
222 |
|
223 //we can ignore using UID |
|
224 //const TProcessId FBUid(KFBUid3); |
|
225 RProcess fbProc; |
|
226 result = fbProc.Create(KExecutableName,KNullDesC); |
|
227 if(result != KErrNone) |
|
228 { |
|
229 qDebug()<<"FB Can't be opened"; |
|
230 return; |
|
231 } |
|
232 qDebug()<<"FB AuthApp Launched"; |
|
233 fbProc.Resume(); |
|
234 fbProc.Close();*/ |
|
235 return; |
|
236 |
|
237 } |
|
238 |
|
239 void ToolBar::launchFlickr() |
|
240 { |
|
241 qDebug()<<"Inside Launch FB AuthApp"; |
|
242 QMessageBox msgbox; |
|
243 QString msg ("Please Login Using Flickr Auth App!"); |
|
244 msgbox.setText(msg); |
|
245 msgbox.exec(); |
|
246 /*TInt result; |
|
247 _LIT(KExecutableName,"release\\winscw\\udeb\\Flickr.exe"); |
|
248 |
|
249 //we can ignore using UID |
|
250 //const TProcessId FBUid(KFBUid3); |
|
251 RProcess flickrProc; |
|
252 result = flickrProc.Create(KExecutableName,KNullDesC); |
|
253 if(result != KErrNone) |
|
254 { |
|
255 qDebug()<<"Flickr Can't be opened"; |
|
256 return; |
|
257 } |
|
258 qDebug()<<"Flickr AuthApp Launched"; |
|
259 flickrProc.Resume(); |
|
260 flickrProc.Close();*/ |
|
261 return; |
|
262 } |