|
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: Music Player audio effect view. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <hbslider.h> |
|
20 #include <hbstackedlayout.h> |
|
21 #include <hbdataformmodel.h> |
|
22 |
|
23 // User includes |
|
24 #include "mpsettingsaudioeffectswidget.h" |
|
25 #include "mpmpxasframeworkwrapper.h" |
|
26 #include "mptrace.h" |
|
27 |
|
28 |
|
29 |
|
30 /*! |
|
31 \class MpSettingsAudioEffectsWidget |
|
32 \brief This class to set up UI widgets for audio effect settings view. |
|
33 |
|
34 Audio Effects widgets allow user to configure settings for Dolby, |
|
35 Balance and Loudness. |
|
36 |
|
37 */ |
|
38 |
|
39 |
|
40 /*! |
|
41 Constructs a new MpSettingsAudioEffectsWidget with \a parent. |
|
42 */ |
|
43 MpSettingsAudioEffectsWidget::MpSettingsAudioEffectsWidget( QGraphicsItem *parent ) |
|
44 : HbWidget( parent ), |
|
45 mFrameworkWrapper( 0 ) |
|
46 { |
|
47 TX_LOG |
|
48 } |
|
49 |
|
50 /*! |
|
51 Destructs the widget. |
|
52 */ |
|
53 MpSettingsAudioEffectsWidget::~MpSettingsAudioEffectsWidget() |
|
54 { |
|
55 delete mFrameworkWrapper; |
|
56 delete mModel; |
|
57 TX_LOG |
|
58 } |
|
59 |
|
60 /*! |
|
61 Initialize the widget. |
|
62 */ |
|
63 void MpSettingsAudioEffectsWidget::initialize() |
|
64 { |
|
65 TX_ENTRY |
|
66 |
|
67 mFrameworkWrapper = new MpMpxAsFrameworkWrapper(); |
|
68 |
|
69 //create data form |
|
70 HbDataForm *dataForm = new HbDataForm(); |
|
71 |
|
72 //create a model class |
|
73 mModel = new HbDataFormModel(); |
|
74 HbDataFormModelItem * slider; |
|
75 HbDataFormModelItem *loudnessItem; |
|
76 slider = mModel->appendDataFormItem( HbDataFormModelItem::SliderItem, hbTrId( "txt_mus_setlabel_balance" ), mModel->invisibleRootItem() ); |
|
77 loudnessItem = mModel->appendDataFormItem( HbDataFormModelItem::ToggleValueItem, hbTrId( "txt_mus_setlabel_loudness" ), mModel->invisibleRootItem() ); |
|
78 slider->setContentWidgetData( QString( "minimum" ),-100 ); |
|
79 slider->setContentWidgetData( QString( "maximum" ),100 ); |
|
80 slider->setContentWidgetData( QString( "majorTickInterval" ),100 ); |
|
81 slider->setContentWidgetData( QString( "minorTickInterval" ),25 ); |
|
82 slider->setContentWidgetData( QString( "singleStep" ),25 ); |
|
83 slider->setContentWidgetData( QString( "toolTipVisible" ), false ); |
|
84 slider->setContentWidgetData( QString( "tickPosition" ), Hb::SliderTicksRight ); |
|
85 slider->setContentWidgetData( QString( "sliderPosition" ),mFrameworkWrapper->balance() ); |
|
86 if ( mFrameworkWrapper->loudness() == true ) { |
|
87 loudnessItem->setContentWidgetData( QString( "text" ), hbTrId( "txt_mus_setlabel_loudness_val_on" ) ); |
|
88 loudnessItem->setContentWidgetData( QString( "additionalText" ), hbTrId( "txt_mus_setlabel_loudness_val_off" ) ); |
|
89 } |
|
90 else { |
|
91 loudnessItem->setContentWidgetData( QString( "text" ), hbTrId( "txt_mus_setlabel_loudness_val_off" ) ); |
|
92 loudnessItem->setContentWidgetData( QString( "additionalText" ), hbTrId( "txt_mus_setlabel_loudness_val_on" ) ); |
|
93 } |
|
94 |
|
95 dataForm->setModel( mModel ); |
|
96 dataForm->setParentItem( this ); |
|
97 HbStackedLayout *mylayout; |
|
98 mylayout = new HbStackedLayout( this ); |
|
99 mylayout->setContentsMargins( 0.0, 0.0, 0.0, 0.0 ); |
|
100 mylayout->setMinimumSize( 0.0, 0.0 ); |
|
101 mylayout->addItem( dataForm ); |
|
102 setLayout( mylayout ); |
|
103 dataForm->addConnection( slider, SIGNAL( valueChanged( int ) ), |
|
104 mFrameworkWrapper, SLOT( setBalance( int ) ) ); |
|
105 connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( filterSignals( QModelIndex, QModelIndex ) ) ); |
|
106 |
|
107 TX_EXIT |
|
108 } |
|
109 |
|
110 void MpSettingsAudioEffectsWidget::filterSignals( QModelIndex startIn, QModelIndex endIn ) |
|
111 { |
|
112 Q_UNUSED( endIn ); |
|
113 HbDataFormModelItem *itm = mModel->itemFromIndex( startIn ); |
|
114 if ( itm->type() == HbDataFormModelItem::ToggleValueItem ) { |
|
115 if( itm->data( HbDataFormModelItem::LabelRole ).toString() == hbTrId( "txt_mus_setlabel_loudness" ) ) { |
|
116 if( itm->contentWidgetData( QString( "text" ) ).toString() == hbTrId( "txt_mus_setlabel_loudness_val_on" ) ) { |
|
117 mFrameworkWrapper->setLoudness( true ); |
|
118 } |
|
119 else if( itm->contentWidgetData( QString( "text" ) ).toString() == hbTrId( "txt_mus_setlabel_loudness_val_off" ) ) { |
|
120 mFrameworkWrapper->setLoudness( false ); |
|
121 } |
|
122 else { |
|
123 TX_LOG_ARGS( "Error: should never get here." ); |
|
124 } |
|
125 } |
|
126 } |
|
127 } |
|
128 |
|
129 |