62
|
1 |
/*
|
97
|
2 |
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
|
62
|
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: Screensaver label.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "snsrlabel.h"
|
97
|
19 |
#include "snsrcolors.h"
|
62
|
20 |
|
|
21 |
#include <hbevent.h>
|
|
22 |
#include <hbcolorscheme.h>
|
|
23 |
|
|
24 |
|
|
25 |
/*!
|
|
26 |
\class SnsrLabel
|
|
27 |
\ingroup group_snsrutils
|
|
28 |
\brief Screensaver label.
|
|
29 |
*/
|
|
30 |
|
|
31 |
/*!
|
|
32 |
Constructs a new SnsrLabel.
|
|
33 |
\param parent Graphics parent item.
|
|
34 |
*/
|
|
35 |
SnsrLabel::SnsrLabel(QGraphicsItem *parent)
|
97
|
36 |
: HbLabel(parent), mTextColorType(ThemedColorForActiveMode)
|
62
|
37 |
{
|
|
38 |
setThemedTextColor();
|
|
39 |
}
|
|
40 |
|
|
41 |
/*!
|
|
42 |
Constructs a new SnsrLabel.
|
|
43 |
\param displayText Text the label should display.
|
|
44 |
\param parent Graphics parent item.
|
|
45 |
*/
|
|
46 |
SnsrLabel::SnsrLabel(const QString &displayText, QGraphicsItem *parent)
|
97
|
47 |
: HbLabel(displayText, parent),
|
|
48 |
mTextColorType(ThemedColorForActiveMode)
|
62
|
49 |
{
|
|
50 |
setThemedTextColor();
|
|
51 |
}
|
|
52 |
|
|
53 |
/*!
|
|
54 |
Destructs the class.
|
|
55 |
*/
|
|
56 |
SnsrLabel::~SnsrLabel()
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
/*!
|
97
|
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 |
/*!
|
62
|
76 |
\reimp
|
|
77 |
*/
|
|
78 |
void SnsrLabel::changeEvent(QEvent * event)
|
|
79 |
{
|
97
|
80 |
if (event->type() == HbEvent::ThemeChanged &&
|
|
81 |
mTextColorType == ThemedColorForActiveMode) {
|
62
|
82 |
setThemedTextColor();
|
|
83 |
}
|
|
84 |
return HbLabel::changeEvent(event);
|
|
85 |
}
|
|
86 |
|
|
87 |
/*!
|
|
88 |
Sets the label's color to follow the theme.
|
|
89 |
*/
|
|
90 |
void SnsrLabel::setThemedTextColor()
|
|
91 |
{
|
97
|
92 |
QColor textColor(HbColorScheme::color(SnsrColors::WidgetColorRole.latin1()));
|
62
|
93 |
if (textColor.isValid()) {
|
|
94 |
setTextColor(textColor);
|
|
95 |
} else {
|
|
96 |
// fallback mechanism when color definition is missing in default theme
|
|
97 |
setTextColor(Qt::white);
|
|
98 |
}
|
|
99 |
}
|