screensaver/snsrutils/src/snsrlabel.cpp
changeset 97 66b5fe3c07fd
parent 86 e4f038c420f7
equal deleted inserted replaced
95:32e56106abf2 97:66b5fe3c07fd
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 * Description:  Screensaver label.
    14 * Description:  Screensaver label.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "snsrlabel.h"
    18 #include "snsrlabel.h"
       
    19 #include "snsrcolors.h"
    19 
    20 
    20 #include <hbevent.h>
    21 #include <hbevent.h>
    21 #include <hbcolorscheme.h>
    22 #include <hbcolorscheme.h>
    22 
    23 
    23 const QString snsrForegroundColorRole("qtc_screensaver");
       
    24 
    24 
    25 /*!
    25 /*!
    26     \class SnsrLabel
    26     \class SnsrLabel
    27     \ingroup group_snsrutils
    27     \ingroup group_snsrutils
    28     \brief Screensaver label.
    28     \brief Screensaver label.
    31 /*!
    31 /*!
    32     Constructs a new SnsrLabel.
    32     Constructs a new SnsrLabel.
    33     \param parent Graphics parent item.
    33     \param parent Graphics parent item.
    34  */
    34  */
    35 SnsrLabel::SnsrLabel(QGraphicsItem *parent)
    35 SnsrLabel::SnsrLabel(QGraphicsItem *parent)
    36     : HbLabel(parent)
    36     : HbLabel(parent), mTextColorType(ThemedColorForActiveMode)
    37 {
    37 {
    38     setThemedTextColor();
    38     setThemedTextColor();
    39 }
    39 }
    40 
    40 
    41 /*!
    41 /*!
    42     Constructs a new SnsrLabel.
    42     Constructs a new SnsrLabel.
    43     \param displayText Text the label should display.
    43     \param displayText Text the label should display.
    44     \param parent Graphics parent item.
    44     \param parent Graphics parent item.
    45  */
    45  */
    46 SnsrLabel::SnsrLabel(const QString &displayText, QGraphicsItem *parent)
    46 SnsrLabel::SnsrLabel(const QString &displayText, QGraphicsItem *parent)
    47     : HbLabel(displayText, parent)
    47     : HbLabel(displayText, parent), 
       
    48       mTextColorType(ThemedColorForActiveMode)
    48 {
    49 {
    49     setThemedTextColor();
    50     setThemedTextColor();
    50 }
    51 }
    51 
    52 
    52 /*!
    53 /*!
    55 SnsrLabel::~SnsrLabel()
    56 SnsrLabel::~SnsrLabel()
    56 {
    57 {
    57 }
    58 }
    58 
    59 
    59 /*!
    60 /*!
       
    61     Set the coloring scheme to be used: fixed color for power save mode (white) or 
       
    62     themed color for active mode.
       
    63  */
       
    64 void SnsrLabel::setTextColorType(const TextColorType &colorType)
       
    65 {
       
    66     mTextColorType = colorType;
       
    67     if (mTextColorType==FixedColorForPowerSaveMode) {
       
    68         setTextColor(SnsrColors::PowerSaveModeWidgetColor);
       
    69     }
       
    70     else {
       
    71         setThemedTextColor();
       
    72     }   
       
    73 }
       
    74 
       
    75 /*!
    60     \reimp
    76     \reimp
    61  */
    77  */
    62 void SnsrLabel::changeEvent(QEvent * event)
    78 void SnsrLabel::changeEvent(QEvent * event)
    63 {
    79 {
    64     if (event->type() == HbEvent::ThemeChanged) {
    80     if (event->type() == HbEvent::ThemeChanged &&
       
    81         mTextColorType == ThemedColorForActiveMode) {
    65         setThemedTextColor();
    82         setThemedTextColor();
    66     }
    83     }
    67     return HbLabel::changeEvent(event);
    84     return HbLabel::changeEvent(event);
    68 }
    85 }
    69 
    86 
    70 /*!
    87 /*!
    71     Sets the label's color to follow the theme.
    88     Sets the label's color to follow the theme.
    72  */
    89  */
    73 void SnsrLabel::setThemedTextColor()
    90 void SnsrLabel::setThemedTextColor()
    74 {
    91 {
    75     QColor textColor(HbColorScheme::color(snsrForegroundColorRole));
    92     QColor textColor(HbColorScheme::color(SnsrColors::WidgetColorRole.latin1()));
    76     if (textColor.isValid()) {
    93     if (textColor.isValid()) {
    77         setTextColor(textColor);
    94         setTextColor(textColor);
    78     } else {
    95     } else {
    79         // fallback mechanism when color definition is missing in default theme
    96         // fallback mechanism when color definition is missing in default theme
    80         setTextColor(Qt::white);
    97         setTextColor(Qt::white);