taskswitcher/testapplications/tssystemapp/lunchwidget.cpp
changeset 117 c63ee96dbe5f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/taskswitcher/testapplications/tssystemapp/lunchwidget.cpp	Thu Sep 16 12:11:40 2010 +0100
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#include "lunchwidget.h"
+#include <hbapplication>
+#include <QStringList>
+#include <HbComboBox>
+#include <HbIcon>
+#include <hbMainWindow>
+#include <hbinstance.h>
+#include "tstasksettings.h"
+#include <EIKENV.H>
+#include <APGWGNAM.H>
+#include <XQConversions>
+
+#define hbApp qobject_cast<HbApplication*>(qApp)
+
+lunchwidget::lunchwidget(QGraphicsItem *parent)
+    : HbWidget(parent)
+{
+    
+    mSystemtLabel = new HbLabel;        
+    //mNameLabel = new HbLabel;
+    
+    mSystemToogleButton = new HbPushButton("Toogle system");
+    //mNameToogleButton = new HbPushButton("Toogle name");
+    
+    
+
+    mGridLayout = new QGraphicsGridLayout();
+    
+    mGridLayout->addItem(mSystemtLabel, 0, 0, 1, 1);
+    mGridLayout->addItem(mSystemToogleButton, 1, 0, 1, 1);
+    //mGridLayout->addItem(mNameLabel, 2, 0, 1, 1);
+    //mGridLayout->addItem(mNameToogleButton, 3, 0, 1, 1);
+    
+    setLayout(mGridLayout);
+    
+    connect( mSystemToogleButton, SIGNAL(released()), this, SLOT(toogleSystem()) );
+    //connect( mNameToogleButton, SIGNAL(released()), this, SLOT(toogleName()) );
+    
+    mSystemtLabel->setPlainText("system");
+    //toogleSystem();
+    //mNameLabel->setPlainText("name1");
+    //toogleName();
+}
+
+lunchwidget::~lunchwidget()
+{
+}
+
+void lunchwidget::toogleSystem() 
+{
+    bool system;
+    if( mSystemtLabel->plainText() == "system" ) {
+        system = false;
+        mSystemtLabel->setPlainText("not system");
+        }
+    else {
+        system = true;
+        mSystemtLabel->setPlainText("system");
+        }
+        
+    TRAPD(err, toogleSystemL(system)); 
+    if (err!=KErrNone) {
+        QString errstr;
+        errstr.setNum(err);
+        mSystemtLabel->setPlainText(errstr);
+        }
+        
+}
+
+void lunchwidget::toogleSystemL(bool system)
+{
+    CEikonEnv * env = CEikonEnv::Static();
+    env->SetSystem(system);
+    /*CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
+    wgName->SetSystem(system);
+    wgName->SetAppUid(TUid::Uid(0xE9340220));
+    wgName->SetWindowGroupName(env->RootWin());
+    CleanupStack::PopAndDestroy(wgName);*/
+}
+
+void lunchwidget::toogleName()
+{
+    QString name;
+    if( mNameLabel->plainText() == "name1" ) {
+        name = "NAME2";
+        mNameLabel->setPlainText("NAME2");
+        }
+    else {
+        name = "name1";
+        mNameLabel->setPlainText("name1");
+        }
+        
+    TRAPD(err, toogleNameL(name)); 
+    if (err!=KErrNone) {
+        QString errstr;
+        errstr.setNum(err);
+        mNameLabel->setPlainText(errstr);
+        }
+}
+
+void lunchwidget::toogleNameL(QString name)
+{
+    CEikonEnv * env = CEikonEnv::Static();
+    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(env->WsSession());
+    HBufC *nameS60 = XQConversions::qStringToS60Desc(name);
+    CleanupStack::PushL(nameS60);
+    wgName->SetCaptionL(*nameS60);
+    CleanupStack::PopAndDestroy(nameS60);
+    env->UpdateTaskNameL();
+    CleanupStack::PopAndDestroy(wgName);
+}
+