usbuis/usbindicatorplugin/src/usbindicatorplugin.cpp
changeset 38 218231f2b3b3
child 56 f45583a69686
equal deleted inserted replaced
35:9d8b04ca6939 38:218231f2b3b3
       
     1 /*
       
     2 * Copyright (c) 2010 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 "usbindicatorplugin.h"
       
    18 #include <QString>
       
    19 #include <QLocale>
       
    20 #include <QApplication>
       
    21 #include "usbindicator.h"
       
    22 #include "usbaddressedindicator.h"
       
    23 
       
    24 Q_EXPORT_PLUGIN(UsbIndicatorPlugin)
       
    25 
       
    26 /*!
       
    27    UsbIndicatorPlugin::UsbIndicatorPlugin
       
    28 */
       
    29 UsbIndicatorPlugin::UsbIndicatorPlugin() : mError(0), mTranslatorLoaded(0)
       
    30 {
       
    31 }
       
    32 
       
    33 /*!
       
    34    UsbIndicatorPlugin::~UsbIndicatorPlugin
       
    35 */
       
    36 UsbIndicatorPlugin::~UsbIndicatorPlugin()
       
    37 {
       
    38     if (mTranslatorLoaded) {
       
    39         QApplication::removeTranslator(&mTranslator); 
       
    40     }
       
    41 }
       
    42 
       
    43 /*!
       
    44    UsbIndicatorPlugin::indicatorTypes
       
    45    Return notification types this plugin implements
       
    46 */
       
    47 QStringList UsbIndicatorPlugin::indicatorTypes() const
       
    48 {
       
    49     QStringList types; 
       
    50     types << ConnectedIndicator;
       
    51     types << AddressedIndicator;
       
    52     return types;
       
    53 }
       
    54 
       
    55 
       
    56 
       
    57 /*!
       
    58    UsbIndicatorPlugin::createIndicator
       
    59    Creates and returns the HbIndicatorInterface
       
    60 */
       
    61 HbIndicatorInterface* UsbIndicatorPlugin::createIndicator(const QString &indicatorType)
       
    62 {  
       
    63     if (!mTranslatorLoaded) {
       
    64         // add translator for application library
       
    65         QString locale = QLocale::system().name();
       
    66         QString filename = QString("usbindimenu_") + locale;             
       
    67         bool success = mTranslator.load(filename, QString("z:/resource/qt/translations"));
       
    68         QApplication::installTranslator(&mTranslator);
       
    69         mTranslatorLoaded = true;    
       
    70     }
       
    71         
       
    72     HbIndicatorInterface *indicator = NULL;    
       
    73     if (indicatorType == ConnectedIndicator) {
       
    74         indicator  = new USBIndicator(indicatorType);
       
    75     }
       
    76     else if (indicatorType == AddressedIndicator) {
       
    77         indicator = new UsbAddressedIndicator(indicatorType); 
       
    78     }
       
    79     return indicator;
       
    80 }
       
    81 
       
    82