19
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cpkeyscreenview.h"
|
|
19 |
#include "cpkeyscreenmodel.h"
|
|
20 |
#include "cpkeyscreenconstants.h"
|
|
21 |
#include <hbdataform.h>
|
|
22 |
#include <QStringList>
|
|
23 |
#include <QDebug>
|
|
24 |
#include <QtCore/qobject.h>
|
|
25 |
#include <hbdataformmodel.h>
|
|
26 |
#include <cpsettingformitemdata.h>
|
|
27 |
#include <hbmessagebox.h>
|
21
|
28 |
#include <hbslider.h>
|
19
|
29 |
|
|
30 |
|
|
31 |
CpKeyScreenView::CpKeyScreenView(QGraphicsItem *parent) :
|
|
32 |
CpBaseSettingView(0,parent),
|
21
|
33 |
mScreenComboButton(0),
|
19
|
34 |
mRotateCheckbox(0),
|
|
35 |
mBrightSliderItem(0),
|
|
36 |
mCallibItem(0),
|
|
37 |
mModel(0)
|
21
|
38 |
{
|
19
|
39 |
HbDataForm *form = qobject_cast<HbDataForm*> ( widget() );
|
|
40 |
if (form) {
|
21
|
41 |
// Valid range is:
|
|
42 |
// 15 secs, 30 secs, 45 secs, 1 min, 2 mins
|
|
43 |
mScreenLockValues.insert(KCpKeyscreenLock15s,hbTrId("txt_cp_setlabel_keys_screen_val_15_seconds"));
|
|
44 |
mScreenLockValues.insert(KCpKeyscreenLock30s,hbTrId("txt_cp_setlabel_keys_screen_val_30_seconds"));
|
|
45 |
mScreenLockValues.insert(KCpKeyscreenLock45s,hbTrId("txt_cp_setlabel_keys_screen_val_45_seconds"));
|
|
46 |
mScreenLockValues.insert(KCpKeyscreenLock60s,hbTrId("txt_cp_setlabel_keys_screen_val_1_minute"));
|
|
47 |
mScreenLockValues.insert(KCpKeyscreenLock120s,hbTrId("txt_cp_setlabel_keys_screen_val_2_minutes"));
|
|
48 |
|
19
|
49 |
form->setHeading(hbTrId("txt_cp_subhead_keys_screen"));
|
|
50 |
mModel = new CpKeyScreenModel();
|
|
51 |
HbDataFormModel *model = new HbDataFormModel;
|
|
52 |
|
|
53 |
if ( mModel->isKeyguardSupported() ) {
|
|
54 |
makeScreenItem(*model);
|
|
55 |
}
|
|
56 |
|
|
57 |
if ( mModel->isRotateSupported() ) {
|
|
58 |
makeRotateItem(*model);
|
|
59 |
}
|
|
60 |
|
|
61 |
makeBrightnessItem(*model);
|
|
62 |
|
22
|
63 |
/* if ( mModel->isCallibrationSupported() ) {
|
19
|
64 |
makeCallibrationItem(*model);
|
22
|
65 |
}*/
|
19
|
66 |
|
|
67 |
form->setModel(model);
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
void CpKeyScreenView::makeScreenItem(HbDataFormModel& model)
|
|
72 |
{
|
21
|
73 |
mScreenComboButton = new CpSettingFormItemData(HbDataFormModelItem::ComboBoxItem,
|
|
74 |
hbTrId("txt_cp_setlabel_keys_screen_locked_after"));
|
|
75 |
|
|
76 |
qobject_cast<HbDataForm*> ( widget() )->addConnection(
|
|
77 |
mScreenComboButton,SIGNAL(currentIndexChanged(QString)),
|
|
78 |
this,SLOT(screenValueChanged(QString)));
|
|
79 |
|
|
80 |
model.appendDataFormItem(mScreenComboButton, model.invisibleRootItem());
|
19
|
81 |
|
|
82 |
int period = mModel->keyguard();
|
21
|
83 |
|
|
84 |
int selectedIndex(-1);
|
|
85 |
|
|
86 |
QMap<int,QString>::iterator it = mScreenLockValues.find(period);
|
|
87 |
if (it == mScreenLockValues.end()) {
|
|
88 |
mModel->setKeyguard(KCpKeyscreenLockDefault30s); // Set keyguard and backlight period to default
|
|
89 |
selectedIndex = 1;
|
19
|
90 |
}
|
21
|
91 |
else {
|
|
92 |
for (it = mScreenLockValues.begin();it != mScreenLockValues.end();++it) {
|
|
93 |
selectedIndex++;
|
|
94 |
if (it.key() == period) {
|
|
95 |
break;
|
|
96 |
}
|
|
97 |
}
|
19
|
98 |
}
|
21
|
99 |
|
|
100 |
QStringList items = mScreenLockValues.values();
|
|
101 |
mScreenComboButton->setContentWidgetData( QString("items"), items );
|
|
102 |
mScreenComboButton->setContentWidgetData( QString("currentIndex"), selectedIndex);
|
40
|
103 |
mScreenComboButton->setContentWidgetData("objectName", "screenComboButton");
|
19
|
104 |
}
|
|
105 |
|
|
106 |
void CpKeyScreenView::makeRotateItem(HbDataFormModel& model)
|
|
107 |
{
|
|
108 |
mRotateCheckbox = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, QString());
|
|
109 |
qobject_cast<HbDataForm*> ( widget() )->addConnection(mRotateCheckbox,SIGNAL(stateChanged(int)),this,SLOT(rotateValueChanged(int)));
|
|
110 |
model.appendDataFormItem(mRotateCheckbox, model.invisibleRootItem());
|
|
111 |
|
|
112 |
mRotateCheckbox->setContentWidgetData( QString("text"), QVariant(hbTrId("txt_cp_list_autorotate_display")) );
|
|
113 |
mRotateCheckbox->setData(HbDataFormModelItem::DescriptionRole, QString( hbTrId("txt_cp_info_rotate_the_display_content_automatical") ));
|
|
114 |
Qt::CheckState state;
|
|
115 |
if ( mModel->rotate() ){
|
|
116 |
state = Qt::Checked;
|
|
117 |
} else {
|
|
118 |
state = Qt::Unchecked;
|
|
119 |
}
|
|
120 |
mRotateCheckbox->setContentWidgetData( QString("checkState"), state );
|
40
|
121 |
mRotateCheckbox->setContentWidgetData("objectName", "rotateCheckbox");
|
19
|
122 |
}
|
|
123 |
|
|
124 |
void CpKeyScreenView::makeBrightnessItem(HbDataFormModel& model)
|
|
125 |
{
|
|
126 |
mBrightSliderItem = new CpSettingFormItemData(HbDataFormModelItem::SliderItem, hbTrId("txt_cp_setlabel_brightness"));
|
|
127 |
qobject_cast<HbDataForm*> ( widget() )->addConnection(mBrightSliderItem,SIGNAL(valueChanged(int)),this,SLOT(brightValueChanged(int)));
|
|
128 |
model.appendDataFormItem(mBrightSliderItem, model.invisibleRootItem());
|
|
129 |
|
21
|
130 |
QList<QVariant> sliderElements;
|
|
131 |
sliderElements << QVariant(HbSlider::IncreaseElement) << QVariant(HbSlider::TrackElement)
|
|
132 |
<< QVariant(HbSlider::DecreaseElement);
|
|
133 |
mBrightSliderItem->setContentWidgetData("sliderElements",sliderElements);
|
19
|
134 |
mBrightSliderItem->setContentWidgetData( QString("value"), mModel->brightness() );
|
|
135 |
mBrightSliderItem->setContentWidgetData( QString("minimum"), 1 );
|
|
136 |
mBrightSliderItem->setContentWidgetData( QString("maximum"), 5 );
|
21
|
137 |
QMap< QString, QVariant > iconElements;
|
|
138 |
iconElements.insert(QString("IncreaseElement") , QVariant(":/icon/hb_vol_slider_increment.svg"));
|
|
139 |
iconElements.insert(QString("DecreaseElement"), QVariant(":/icon/hb_vol_slider_decrement.svg") );
|
|
140 |
mBrightSliderItem->setContentWidgetData( QString( "elementIcons" ), iconElements );
|
40
|
141 |
mRotateCheckbox->setContentWidgetData("objectName", "brightSliderItem");
|
19
|
142 |
}
|
|
143 |
|
|
144 |
void CpKeyScreenView::makeCallibrationItem(HbDataFormModel& model)
|
|
145 |
{
|
|
146 |
mCallibItem = new CpSettingFormItemData(HbDataFormModelItem::ToggleValueItem,
|
|
147 |
QString());
|
|
148 |
qobject_cast<HbDataForm*> ( widget() )->addConnection(mCallibItem,SIGNAL(pressed()),this,SLOT(launchCallib()));
|
|
149 |
model.appendDataFormItem(mCallibItem, model.invisibleRootItem());
|
|
150 |
mCallibItem->setContentWidgetData( QString("text"), hbTrId("txt_cp_button_touch_screen_calibration"));
|
|
151 |
}
|
|
152 |
|
|
153 |
CpKeyScreenView::~CpKeyScreenView()
|
|
154 |
{
|
|
155 |
delete mModel;
|
|
156 |
mModel = 0;
|
|
157 |
}
|
|
158 |
|
21
|
159 |
void CpKeyScreenView::screenValueChanged(const QString &value)
|
|
160 |
{
|
|
161 |
for (QMap<int,QString>::iterator it = mScreenLockValues.begin();
|
|
162 |
it != mScreenLockValues.end();++it) {
|
|
163 |
if (it.value() == value) {
|
|
164 |
mModel->setKeyguard(it.key());
|
|
165 |
break;
|
|
166 |
}
|
19
|
167 |
}
|
|
168 |
}
|
|
169 |
|
|
170 |
void CpKeyScreenView::rotateValueChanged(int value)
|
|
171 |
{
|
|
172 |
mModel->setRotate( value );
|
|
173 |
}
|
|
174 |
|
|
175 |
void CpKeyScreenView::brightValueChanged(int value)
|
|
176 |
{
|
|
177 |
mModel->setBrightness(value);
|
|
178 |
}
|
|
179 |
|
|
180 |
void CpKeyScreenView::launchCallib()
|
|
181 |
{
|
|
182 |
}
|
|
183 |
|
|
184 |
|