|
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 <hbmenu.h> |
|
19 #include <hbaction.h> |
|
20 #include <hbeffect.h> |
|
21 #include <qcoreapplication> |
|
22 |
|
23 #include "radioviewbase.h" |
|
24 #include "radiomainwindow.h" |
|
25 #include "radiostationmodel.h" |
|
26 #include "radioxmluiloader.h" |
|
27 #include "radiouiengine.h" |
|
28 #include "radiolocalization.h" |
|
29 #include "radiologger.h" |
|
30 |
|
31 /*! |
|
32 * |
|
33 */ |
|
34 RadioViewBase::RadioViewBase( RadioXmlUiLoader* uiLoader, bool transient ) : |
|
35 HbView( 0 ), |
|
36 mMainWindow( 0 ), |
|
37 mModel( 0 ), |
|
38 mUiLoader( uiLoader ), |
|
39 mTransientView( transient ), |
|
40 mUseLoudspeakerAction( 0 ), |
|
41 mSecondarySoftkeyction( 0 ), |
|
42 mOrientation( Qt::Vertical ) |
|
43 { |
|
44 } |
|
45 |
|
46 /*! |
|
47 * |
|
48 */ |
|
49 RadioViewBase::~RadioViewBase() |
|
50 { |
|
51 if ( mUiLoader ) |
|
52 { |
|
53 mUiLoader->reset(); |
|
54 } |
|
55 } |
|
56 |
|
57 /*! |
|
58 * |
|
59 */ |
|
60 void RadioViewBase::init( RadioMainWindow* aMainWindow, RadioStationModel* aModel ) |
|
61 { |
|
62 // Default implementation does nothing |
|
63 Q_UNUSED( aMainWindow ); |
|
64 Q_UNUSED( aModel ); |
|
65 } |
|
66 |
|
67 /*! |
|
68 * |
|
69 */ |
|
70 bool RadioViewBase::isTransient() const |
|
71 { |
|
72 return mTransientView; |
|
73 } |
|
74 |
|
75 /*! |
|
76 * |
|
77 */ |
|
78 void RadioViewBase::initSecondarySoftkey() |
|
79 { |
|
80 // The default back button activates the tuning view |
|
81 mSecondarySoftkeyction = new HbAction( Hb::BackAction, this ); |
|
82 connectAndTest( mSecondarySoftkeyction, SIGNAL(triggered()), |
|
83 mMainWindow, SLOT(activateTuningView()) ); |
|
84 } |
|
85 |
|
86 /*! |
|
87 * |
|
88 */ |
|
89 HbAction* RadioViewBase::secondarySoftkey() const |
|
90 { |
|
91 return mSecondarySoftkeyction; |
|
92 } |
|
93 |
|
94 /*! |
|
95 * |
|
96 */ |
|
97 void RadioViewBase::updateOrientation( Qt::Orientation orientation, bool forceUpdate ) |
|
98 { |
|
99 if ( orientation != mOrientation || forceUpdate ) |
|
100 { |
|
101 mOrientation = orientation; |
|
102 setOrientation(); |
|
103 } |
|
104 } |
|
105 |
|
106 /*! |
|
107 * Protected slot |
|
108 * |
|
109 */ |
|
110 void RadioViewBase::updateAudioRouting( bool loudspeaker ) |
|
111 { |
|
112 if ( mUseLoudspeakerAction ) { |
|
113 mUseLoudspeakerAction->setText( loudspeaker ? TRANSLATE( KMenuUseHeadset ) : TRANSLATE( KMenuUseLoudspeaker ) ); |
|
114 } |
|
115 } |
|
116 |
|
117 /*! |
|
118 * Protected slot |
|
119 * |
|
120 */ |
|
121 void RadioViewBase::activatePreviousView() |
|
122 { |
|
123 mMainWindow->activateTuningView(); |
|
124 } |
|
125 |
|
126 /*! |
|
127 * Protected slot |
|
128 * |
|
129 */ |
|
130 void RadioViewBase::quit() |
|
131 { |
|
132 qApp->quit(); |
|
133 } |
|
134 |
|
135 /*! |
|
136 * |
|
137 */ |
|
138 HbAction* RadioViewBase::addMenuItem( const QString& aTitle, QObject* aRecipient, const char* aSlot ) |
|
139 { |
|
140 HbAction* action = menu()->addAction( aTitle ); |
|
141 connectAndTest( action, SIGNAL(triggered()), aRecipient, aSlot ); |
|
142 return action; |
|
143 } |
|
144 |
|
145 /*! |
|
146 * |
|
147 */ |
|
148 void RadioViewBase::connectCommonMenuItem( int menuItem ) |
|
149 { |
|
150 RadioUiEngine* engine = &mMainWindow->uiEngine(); |
|
151 switch ( menuItem ) |
|
152 { |
|
153 case MenuItem::UseLoudspeaker: |
|
154 mUseLoudspeakerAction = mUiLoader->findObject<HbAction>( DOCML_NAME_LOUDSPEAKERACTION ); |
|
155 if ( mUseLoudspeakerAction ) { |
|
156 connectAndTest( mUseLoudspeakerAction, SIGNAL(triggered()), engine, SLOT(toggleAudioRoute()) ); |
|
157 updateAudioRouting( engine->isUsingLoudspeaker() ); |
|
158 connectAndTest( engine, SIGNAL(audioRouteChanged(bool)), this, SLOT(updateAudioRouting(bool)) ); |
|
159 } |
|
160 break; |
|
161 |
|
162 default: |
|
163 break; |
|
164 } |
|
165 } |
|
166 |
|
167 /*! |
|
168 * |
|
169 */ |
|
170 void RadioViewBase::connectXmlElement( const char* name, const char* signal, QObject* receiver, const char* slot ) |
|
171 { |
|
172 if ( QObject* action = mUiLoader->findObject<QObject>( name ) ) |
|
173 { |
|
174 connectAndTest( action, signal, receiver, slot ); |
|
175 } |
|
176 } |
|
177 |
|
178 /*! |
|
179 * |
|
180 */ |
|
181 void RadioViewBase::connectViewChangeMenuItem( QString name, const char* slot ) |
|
182 { |
|
183 if ( QObject* action = mUiLoader->findObject<QObject>( name ) ) |
|
184 { |
|
185 connectAndTest( action, SIGNAL(triggered()), mMainWindow, slot ); |
|
186 } |
|
187 } |
|
188 |
|
189 /*! |
|
190 * |
|
191 */ |
|
192 void RadioViewBase::setOrientation() |
|
193 { |
|
194 // Default implementation does nothing |
|
195 } |