|
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 "lunchwidget.h" |
|
18 #include <hbapplication> |
|
19 #include <QStringList> |
|
20 #include <HbComboBox> |
|
21 #include <HbIcon> |
|
22 #include <hbMainWindow> |
|
23 #include <hbinstance.h> |
|
24 #include "tstasksettings.h" |
|
25 #include <EIKENV.H> |
|
26 #include <APGWGNAM.H> |
|
27 #include <XQConversions> |
|
28 |
|
29 #define hbApp qobject_cast<HbApplication*>(qApp) |
|
30 |
|
31 lunchwidget::lunchwidget(QGraphicsItem *parent) |
|
32 : HbWidget(parent) |
|
33 { |
|
34 |
|
35 mSystemtLabel = new HbLabel; |
|
36 //mNameLabel = new HbLabel; |
|
37 |
|
38 mSystemToogleButton = new HbPushButton("Toogle system"); |
|
39 //mNameToogleButton = new HbPushButton("Toogle name"); |
|
40 |
|
41 |
|
42 |
|
43 mGridLayout = new QGraphicsGridLayout(); |
|
44 |
|
45 mGridLayout->addItem(mSystemtLabel, 0, 0, 1, 1); |
|
46 mGridLayout->addItem(mSystemToogleButton, 1, 0, 1, 1); |
|
47 //mGridLayout->addItem(mNameLabel, 2, 0, 1, 1); |
|
48 //mGridLayout->addItem(mNameToogleButton, 3, 0, 1, 1); |
|
49 |
|
50 setLayout(mGridLayout); |
|
51 |
|
52 connect( mSystemToogleButton, SIGNAL(released()), this, SLOT(toogleSystem()) ); |
|
53 //connect( mNameToogleButton, SIGNAL(released()), this, SLOT(toogleName()) ); |
|
54 |
|
55 mSystemtLabel->setPlainText("system"); |
|
56 //toogleSystem(); |
|
57 //mNameLabel->setPlainText("name1"); |
|
58 //toogleName(); |
|
59 } |
|
60 |
|
61 lunchwidget::~lunchwidget() |
|
62 { |
|
63 } |
|
64 |
|
65 void lunchwidget::toogleSystem() |
|
66 { |
|
67 bool system; |
|
68 if( mSystemtLabel->plainText() == "system" ) { |
|
69 system = false; |
|
70 mSystemtLabel->setPlainText("not system"); |
|
71 } |
|
72 else { |
|
73 system = true; |
|
74 mSystemtLabel->setPlainText("system"); |
|
75 } |
|
76 |
|
77 TRAPD(err, toogleSystemL(system)); |
|
78 if (err!=KErrNone) { |
|
79 QString errstr; |
|
80 errstr.setNum(err); |
|
81 mSystemtLabel->setPlainText(errstr); |
|
82 } |
|
83 |
|
84 } |
|
85 |
|
86 void lunchwidget::toogleSystemL(bool system) |
|
87 { |
|
88 CEikonEnv * env = CEikonEnv::Static(); |
|
89 env->SetSystem(system); |
|
90 /*CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession()); |
|
91 wgName->SetSystem(system); |
|
92 wgName->SetAppUid(TUid::Uid(0xE9340220)); |
|
93 wgName->SetWindowGroupName(env->RootWin()); |
|
94 CleanupStack::PopAndDestroy(wgName);*/ |
|
95 } |
|
96 |
|
97 void lunchwidget::toogleName() |
|
98 { |
|
99 QString name; |
|
100 if( mNameLabel->plainText() == "name1" ) { |
|
101 name = "NAME2"; |
|
102 mNameLabel->setPlainText("NAME2"); |
|
103 } |
|
104 else { |
|
105 name = "name1"; |
|
106 mNameLabel->setPlainText("name1"); |
|
107 } |
|
108 |
|
109 TRAPD(err, toogleNameL(name)); |
|
110 if (err!=KErrNone) { |
|
111 QString errstr; |
|
112 errstr.setNum(err); |
|
113 mNameLabel->setPlainText(errstr); |
|
114 } |
|
115 } |
|
116 |
|
117 void lunchwidget::toogleNameL(QString name) |
|
118 { |
|
119 CEikonEnv * env = CEikonEnv::Static(); |
|
120 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession()); |
|
121 HBufC *nameS60 = XQConversions::qStringToS60Desc(name); |
|
122 CleanupStack::PushL(nameS60); |
|
123 wgName->SetCaptionL(*nameS60); |
|
124 CleanupStack::PopAndDestroy(nameS60); |
|
125 env->UpdateTaskNameL(); |
|
126 CleanupStack::PopAndDestroy(wgName); |
|
127 } |
|
128 |