tstaskmonitor/client/s60/src/tsscreenshotregistry_p.cpp
changeset 96 5d243a69bdda
equal deleted inserted replaced
95:c739008478cc 96:5d243a69bdda
       
     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 "tsscreenshotregistry_p.h"
       
    18 
       
    19 #include <fbs.h>
       
    20 #include <coecntrl.h>
       
    21 #include <QScopedPointer>
       
    22 #include <QApplication>
       
    23 #include <QDesktopWidget>
       
    24 
       
    25 #include "tsscreenshotclient.h"
       
    26 
       
    27 TsScreenshotRegistryPrivate::TsScreenshotRegistryPrivate() : mClient(0)
       
    28 {
       
    29     QT_TRAP_THROWING(mClient = CTsScreenshotClient::NewL());
       
    30 }
       
    31 
       
    32 TsScreenshotRegistryPrivate::~TsScreenshotRegistryPrivate()
       
    33 {
       
    34     delete mClient;
       
    35 }
       
    36 
       
    37 bool TsScreenshotRegistryPrivate::registerScreenshot(const QPixmap &screenshot)
       
    38 {    
       
    39     QScopedPointer<CFbsBitmap> bitmap(screenshot.toSymbianCFbsBitmap());
       
    40     if (bitmap.isNull()) 
       
    41         return false;
       
    42 
       
    43     return KErrNone == mClient->RegisterScreenshot(bitmap.data(), wgId());
       
    44 }
       
    45 
       
    46 bool TsScreenshotRegistryPrivate::unregisterScreenshot()
       
    47 {
       
    48     return KErrNone == mClient->UnregisterScreenshot(wgId());
       
    49 }
       
    50 
       
    51 int TsScreenshotRegistryPrivate::wgId()
       
    52 {
       
    53     return QApplication::desktop()->winId()->ControlEnv()->RootWin().WindowGroupId();
       
    54 }