62
|
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: Screensaver label.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "snsrlabel.h"
|
|
19 |
|
|
20 |
#include <hbevent.h>
|
|
21 |
#include <hbcolorscheme.h>
|
|
22 |
|
86
|
23 |
const QString snsrForegroundColorRole("qtc_screensaver");
|
62
|
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)
|
|
36 |
: HbLabel(parent)
|
|
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)
|
|
47 |
: HbLabel(displayText, parent)
|
|
48 |
{
|
|
49 |
setThemedTextColor();
|
|
50 |
}
|
|
51 |
|
|
52 |
/*!
|
|
53 |
Destructs the class.
|
|
54 |
*/
|
|
55 |
SnsrLabel::~SnsrLabel()
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
/*!
|
|
60 |
\reimp
|
|
61 |
*/
|
|
62 |
void SnsrLabel::changeEvent(QEvent * event)
|
|
63 |
{
|
|
64 |
if (event->type() == HbEvent::ThemeChanged) {
|
|
65 |
setThemedTextColor();
|
|
66 |
}
|
|
67 |
return HbLabel::changeEvent(event);
|
|
68 |
}
|
|
69 |
|
|
70 |
/*!
|
|
71 |
Sets the label's color to follow the theme.
|
|
72 |
*/
|
|
73 |
void SnsrLabel::setThemedTextColor()
|
|
74 |
{
|
|
75 |
QColor textColor(HbColorScheme::color(snsrForegroundColorRole));
|
|
76 |
if (textColor.isValid()) {
|
|
77 |
setTextColor(textColor);
|
|
78 |
} else {
|
|
79 |
// fallback mechanism when color definition is missing in default theme
|
|
80 |
setTextColor(Qt::white);
|
|
81 |
}
|
|
82 |
}
|