screensaver/snsrutils/src/snsrlabel.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 02 Sep 2010 20:17:27 +0300
changeset 85 35368b604b28
parent 61 2b1b11a301d2
child 86 e4f038c420f7
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* 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:  Screensaver label.
*
*/

#include "snsrlabel.h"

#include <hbevent.h>
#include <hbcolorscheme.h>

const QString snsrForegroundColorRole("snsrforeground");

/*!
    \class SnsrLabel
    \ingroup group_snsrutils
    \brief Screensaver label.
 */

/*!
    Constructs a new SnsrLabel.
    \param parent Graphics parent item.
 */
SnsrLabel::SnsrLabel(QGraphicsItem *parent)
    : HbLabel(parent)
{
    setThemedTextColor();
}

/*!
    Constructs a new SnsrLabel.
    \param displayText Text the label should display.
    \param parent Graphics parent item.
 */
SnsrLabel::SnsrLabel(const QString &displayText, QGraphicsItem *parent)
    : HbLabel(displayText, parent)
{
    setThemedTextColor();
}

/*!
    Destructs the class.
 */
SnsrLabel::~SnsrLabel()
{
}

/*!
    \reimp
 */
void SnsrLabel::changeEvent(QEvent * event)
{
    if (event->type() == HbEvent::ThemeChanged) {
        setThemedTextColor();
    }
    return HbLabel::changeEvent(event);
}

/*!
    Sets the label's color to follow the theme.
 */
void SnsrLabel::setThemedTextColor()
{
    QColor textColor(HbColorScheme::color(snsrForegroundColorRole));
    if (textColor.isValid()) {
        setTextColor(textColor);
    } else {
        // fallback mechanism when color definition is missing in default theme
        setTextColor(Qt::white);
    }
}