|
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 "cpdisplayview.h" |
|
19 #include "cpdisplaymodel.h" |
|
20 #include <hbdataform.h> |
|
21 #include <qstringlist> |
|
22 #include <QDebug> |
|
23 #include <hbdataformmodel.h> |
|
24 #include <cpsettingformitemdata.h> |
|
25 #include <hbmessagebox.h> |
|
26 |
|
27 |
|
28 CpDisplayView::CpDisplayView(QGraphicsItem *parent) : |
|
29 CpBaseSettingView(0,parent), |
|
30 mScreenRadioButton(0), |
|
31 mDisplayRadioButton(0), |
|
32 mBrightSliderItem(0), |
|
33 mModel(0) |
|
34 { |
|
35 HbDataForm *form = settingForm(); |
|
36 if (form) { |
|
37 form->setHeading(tr("Display")); |
|
38 mModel = new CpDisplayModel(); |
|
39 HbDataFormModel *model = new HbDataFormModel; |
|
40 |
|
41 bool screen = false; |
|
42 bool backlight = false; |
|
43 bool brightness = false; |
|
44 if ( mModel->isKeyguardSupported() ) { |
|
45 makeScreenItem(model); |
|
46 screen = true; |
|
47 } |
|
48 |
|
49 if ( mModel->isBacklightSupported() ) { |
|
50 makeBacklightItem(model); |
|
51 backlight = true; |
|
52 } |
|
53 |
|
54 if ( mModel->isBrightnessSupported() ) { |
|
55 makeBrightnessItem(model); |
|
56 brightness = true; |
|
57 } |
|
58 |
|
59 if ( screen || backlight || brightness ){ |
|
60 mIsHidden = false; |
|
61 } else { |
|
62 mIsHidden = true; |
|
63 } |
|
64 |
|
65 settingForm()->setModel(model); |
|
66 } |
|
67 } |
|
68 |
|
69 bool CpDisplayView::isHidden() |
|
70 { |
|
71 return mIsHidden; |
|
72 } |
|
73 |
|
74 void CpDisplayView::makeScreenItem(HbDataFormModel* model) |
|
75 { |
|
76 mScreenRadioButton = new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, |
|
77 QString("Keys & screen locked after")); |
|
78 settingForm()->addConnection(mScreenRadioButton,SIGNAL(itemSelected(int)),this,SLOT(ScreenValueChanged(int))); |
|
79 model->appendDataFormItem(mScreenRadioButton, model->invisibleRootItem()); |
|
80 |
|
81 QStringList sList; |
|
82 sList<< "0 seconds"<< "5 seconds"<< "10 seconds"<< "15 seconds"<< "20 seconds"<< "25 seconds"; |
|
83 mScreenRadioButton->setContentWidgetData( QString("items"), sList ); |
|
84 mScreenRadioButton->setContentWidgetData( QString("selected"), mModel->keyguard() ); |
|
85 } |
|
86 |
|
87 void CpDisplayView::makeBacklightItem(HbDataFormModel* model) |
|
88 { |
|
89 mDisplayRadioButton = new CpSettingFormItemData(HbDataFormModelItem::RadioButtonListItem, |
|
90 QString("Display dimmed after")); |
|
91 settingForm()->addConnection(mDisplayRadioButton,SIGNAL(itemSelected(int)),this,SLOT(DisplayValueChanged(int))); |
|
92 model->appendDataFormItem(mDisplayRadioButton, model->invisibleRootItem()); |
|
93 |
|
94 QStringList sList; |
|
95 sList<< "0 seconds"<< "5 seconds"<< "10 seconds"<< "15 seconds"<< "20 seconds"<< "25 seconds"; |
|
96 mDisplayRadioButton->setContentWidgetData( QString("items"), sList ); |
|
97 mDisplayRadioButton->setContentWidgetData( QString("selected"), mModel->backlight() ); |
|
98 } |
|
99 |
|
100 void CpDisplayView::makeBrightnessItem(HbDataFormModel* model) |
|
101 { |
|
102 mBrightSliderItem = new CpSettingFormItemData(HbDataFormModelItem::SliderItem, |
|
103 QString("Brightness")); |
|
104 settingForm()->addConnection(mBrightSliderItem,SIGNAL(valueChanged(int)),this,SLOT(BrightValueChanged(int))); |
|
105 model->appendDataFormItem(mBrightSliderItem, model->invisibleRootItem()); |
|
106 |
|
107 mBrightSliderItem->setContentWidgetData( QString("value"), mModel->brightness() ); |
|
108 mBrightSliderItem->setContentWidgetData( QString("minimum"), 0 ); |
|
109 mBrightSliderItem->setContentWidgetData( QString("maximum"), 100 ); |
|
110 } |
|
111 |
|
112 CpDisplayView::~CpDisplayView() |
|
113 { |
|
114 delete mModel; |
|
115 mModel = 0; |
|
116 } |
|
117 |
|
118 void CpDisplayView::ScreenValueChanged(int value) |
|
119 { |
|
120 mModel->setKeyguard(value); |
|
121 } |
|
122 |
|
123 void CpDisplayView::DisplayValueChanged(int value) |
|
124 { |
|
125 mModel->setBacklight(value); |
|
126 } |
|
127 |
|
128 void CpDisplayView::BrightValueChanged(int value) |
|
129 { |
|
130 mModel->setBrightness(value); |
|
131 } |
|
132 |
|
133 |