47 #include "mpcollectionlistcontainer.h" |
45 #include "mpcollectionlistcontainer.h" |
48 #include "mpcollectionpopuphandler.h" |
46 #include "mpcollectionpopuphandler.h" |
49 |
47 |
50 |
48 |
51 const char*MUSIC_COLLECTION_DOCML = ":/docml/musiccollection.docml"; |
49 const char*MUSIC_COLLECTION_DOCML = ":/docml/musiccollection.docml"; |
52 const char*EFFECT_SELECT = ":/effects/select.fxml"; |
50 |
53 const char*EFFECT_SELECT_END = ":/effects/select_end.fxml"; |
51 const char*CONTAINER_EFFECT_GROUP = "mpcontainer"; |
|
52 |
|
53 const char*SHOW_EFFECT = "show"; |
|
54 const char*HIDE_EFFECT = "hide"; |
|
55 const char*SHOW_BACK_EFFECT = "show_back"; |
|
56 const char*HIDE_BACK_EFFECT = "hide_back"; |
|
57 |
|
58 const char*SHOW_EFFECT_RESOURCE_NAME = "view_show_normal"; |
|
59 const char*HIDE_EFFECT_RESOURCE_NAME = "view_hide_normal"; |
|
60 const char*SHOW_BACK_EFFECT_RESOURCE_NAME = "view_show_back"; |
|
61 const char*HIDE_BACK_EFFECT_RESOURCE_NAME = "view_hide_back"; |
|
62 |
|
63 const char*EFFECT_TARGET_SNAPSHOT = "snapshot"; |
|
64 const char*EFFECT_TARGET_CONTAINER = "container"; |
54 |
65 |
55 const int KMainToolBarAll = 0; |
66 const int KMainToolBarAll = 0; |
56 const int KMainToolBarArtists = 1; |
67 const int KMainToolBarArtists = 1; |
57 const int KMainToolBarAlbums = 2; |
68 const int KMainToolBarAlbums = 2; |
58 const int KMainToolBarPlaylists = 3; |
69 const int KMainToolBarPlaylists = 3; |
131 |
140 |
132 delete mCollectionContainer; |
141 delete mCollectionContainer; |
133 delete mContainerFactory; |
142 delete mContainerFactory; |
134 delete mCollectionDataModel; |
143 delete mCollectionDataModel; |
135 delete mDocumentLoader; |
144 delete mDocumentLoader; |
136 delete mMpTranslator; |
|
137 delete mCommonTranslator; |
|
138 TX_EXIT |
145 TX_EXIT |
139 } |
146 } |
140 |
147 |
141 /*! |
148 /*! |
142 Initializes the collection view. Allocates all resources needed by the view. |
149 Initializes the collection view. Allocates all resources needed by the view. |
143 */ |
150 */ |
144 void MpCollectionView::initializeView() |
151 void MpCollectionView::initializeView() |
145 { |
152 { |
146 TX_ENTRY |
153 TX_ENTRY |
147 |
|
148 //Load musicplayer and common translators |
|
149 QString lang = QLocale::system().name(); |
|
150 QString path = QString( "z:/resource/qt/translations/" ); |
|
151 bool translatorLoaded = false; |
|
152 |
|
153 mMpTranslator = new QTranslator( this ); |
|
154 translatorLoaded = mMpTranslator->load( path + "musicplayer_" + lang ); |
|
155 TX_LOG_ARGS( "Loading translator ok=" << translatorLoaded ); |
|
156 if ( translatorLoaded ) { |
|
157 qApp->installTranslator( mMpTranslator ); |
|
158 } |
|
159 |
|
160 mCommonTranslator = new QTranslator( this ); |
|
161 translatorLoaded = mCommonTranslator->load( path + "common_" + lang ); |
|
162 TX_LOG_ARGS( "Loading common translator ok=" << translatorLoaded ); |
|
163 if ( translatorLoaded ) { |
|
164 qApp->installTranslator( mCommonTranslator ); |
|
165 } |
|
166 |
154 |
167 mWindow = mainWindow(); |
155 mWindow = mainWindow(); |
168 |
156 |
169 // Create softkey actions |
157 // Create softkey actions |
170 mSoftKeyQuit = new HbAction( Hb::QuitNaviAction, this ); |
158 mSoftKeyQuit = new HbAction( Hb::QuitNaviAction, this ); |
217 widget = mDocumentLoader->findWidget( QString( "mainContainer" ) ); |
205 widget = mDocumentLoader->findWidget( QString( "mainContainer" ) ); |
218 mMainContainer = qobject_cast<HbWidget*>( widget ); |
206 mMainContainer = qobject_cast<HbWidget*>( widget ); |
219 |
207 |
220 setWidget( mMainContainer ); |
208 setWidget( mMainContainer ); |
221 |
209 |
222 HbEffect::add( QString( "container" ), |
210 HbEffect::add( |
223 QString( ":/effects/slide_out_to_left.fxml" ), |
211 QStringList() << CONTAINER_EFFECT_GROUP << CONTAINER_EFFECT_GROUP << CONTAINER_EFFECT_GROUP << CONTAINER_EFFECT_GROUP, |
224 QString( "slide_out_to_left" ) ); |
212 QStringList() << SHOW_EFFECT_RESOURCE_NAME << HIDE_EFFECT_RESOURCE_NAME << SHOW_BACK_EFFECT_RESOURCE_NAME << HIDE_BACK_EFFECT_RESOURCE_NAME, |
225 |
213 QStringList() << SHOW_EFFECT << HIDE_EFFECT << SHOW_BACK_EFFECT << HIDE_BACK_EFFECT); |
226 HbEffect::add( QString( "container" ), |
214 |
227 QString( ":/effects/slide_out_to_right.fxml" ), |
215 |
228 QString( "slide_out_to_right" ) ); |
|
229 |
|
230 HbEffect::add( QString( "container" ), |
|
231 QString( ":/effects/slide_out_to_top.fxml" ), |
|
232 QString( "slide_out_to_top" ) ); |
|
233 |
|
234 HbEffect::add( QString( "container" ), |
|
235 QString( ":/effects/slide_in_to_right_and_fade_in.fxml" ), |
|
236 QString( "slide_in_to_right_and_fade_in" ) ); |
|
237 |
|
238 HbEffect::add( QString( "container" ), |
|
239 QString( ":/effects/slide_in_to_left_and_fade_in.fxml" ), |
|
240 QString( "slide_in_to_left_and_fade_in" ) ); |
|
241 |
|
242 HbEffect::add( QString( "container" ), |
|
243 QString( ":/effects/slide_in_to_top_and_fade_in.fxml" ), |
|
244 QString( "slide_in_to_top_and_fade_in" ) ); |
|
245 } |
216 } |
246 else { |
217 else { |
247 TX_LOG_ARGS( "Error: invalid xml file." ); |
218 TX_LOG_ARGS( "Error: invalid xml file." ); |
248 Q_ASSERT_X( ok, "MpCollectionView::initializeView", "invalid xml file" ); |
219 Q_ASSERT_X( ok, "MpCollectionView::initializeView", "invalid xml file" ); |
249 } |
220 } |
995 else { |
957 else { |
996 menuAction->setDisabled( true ); |
958 menuAction->setDisabled( true ); |
997 } |
959 } |
998 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); |
960 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); |
999 if ( !mUsbBlocked ) { |
961 if ( !mUsbBlocked ) { |
1000 connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) ); |
962 connect( menuAction, SIGNAL( triggered() ), mMpEngine, SLOT( refreshLibrary() ) ); |
1001 } |
963 } |
1002 else { |
964 else { |
1003 menuAction->setDisabled( true ); |
965 menuAction->setDisabled( true ); |
1004 } |
966 } |
1005 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) ); |
967 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) ); |
1006 break; |
968 break; |
1007 case ECollectionContextArtists: |
969 case ECollectionContextArtists: |
1008 case ECollectionContextAlbums: |
970 case ECollectionContextAlbums: |
1009 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); |
971 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); |
1010 if ( !mUsbBlocked ) { |
972 if ( !mUsbBlocked ) { |
1011 connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) ); |
973 connect( menuAction, SIGNAL( triggered() ), mMpEngine, SLOT( refreshLibrary() ) ); |
1012 } |
974 } |
1013 else { |
975 else { |
1014 menuAction->setDisabled( true ); |
976 menuAction->setDisabled( true ); |
1015 } |
977 } |
1016 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) ); |
978 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) ); |
1219 } |
1181 } |
1220 mSnapshot->capture( mWindow, mMainContainer ); |
1182 mSnapshot->capture( mWindow, mMainContainer ); |
1221 mWindow->scene()->addItem( mSnapshot ); |
1183 mWindow->scene()->addItem( mSnapshot ); |
1222 |
1184 |
1223 |
1185 |
1224 if ( ( contextFrom == ECollectionContextAlbums && contextTo == ECollectionContextAlbumsTBone ) || |
1186 if( ( contextFrom == ECollectionContextAlbumsTBone && contextTo == ECollectionContextAlbums ) || |
1225 ( contextFrom == ECollectionContextArtists && contextTo == ECollectionContextArtistAlbums ) || |
|
1226 ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtistAlbumsTBone ) || |
|
1227 ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtistAllSongs ) || |
|
1228 ( contextFrom == ECollectionContextPlaylists && contextTo == ECollectionContextPlaylistSongs ) ) { |
|
1229 HbEffect::start( mSnapshot, |
|
1230 QString( "container" ), |
|
1231 QString( "slide_out_to_left" ), |
|
1232 this, |
|
1233 "containerTransitionComplete", |
|
1234 QString( "snapshot_effect") ); |
|
1235 |
|
1236 HbEffect::start( mMainContainer, |
|
1237 QString( "container" ), |
|
1238 QString( "slide_in_to_left_and_fade_in" ), |
|
1239 this, |
|
1240 "containerTransitionComplete", |
|
1241 QString( "mainContainer_effect") ); |
|
1242 } |
|
1243 else if( ( contextFrom == ECollectionContextAlbumsTBone && contextTo == ECollectionContextAlbums ) || |
|
1244 ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtists ) || |
1187 ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtists ) || |
1245 ( contextFrom == ECollectionContextArtistAlbumsTBone && contextTo == ECollectionContextArtistAlbums ) || |
1188 ( contextFrom == ECollectionContextArtistAlbumsTBone && contextTo == ECollectionContextArtistAlbums ) || |
|
1189 ( contextFrom == ECollectionContextArtistAlbumsTBone && contextTo == ECollectionContextArtists ) || |
1246 ( contextFrom == ECollectionContextArtistAllSongs && contextTo == ECollectionContextArtistAlbums ) || |
1190 ( contextFrom == ECollectionContextArtistAllSongs && contextTo == ECollectionContextArtistAlbums ) || |
1247 ( contextFrom == ECollectionContextPlaylistSongs && contextTo == ECollectionContextPlaylists ) ) { |
1191 ( contextFrom == ECollectionContextPlaylistSongs && contextTo == ECollectionContextPlaylists ) ) { |
1248 HbEffect::start( mSnapshot, |
1192 HbEffect::start( mSnapshot, |
1249 QString( "container" ), |
1193 QString( CONTAINER_EFFECT_GROUP ), |
1250 QString( "slide_out_to_right" ), |
1194 QString( HIDE_BACK_EFFECT ), |
1251 this, |
1195 this, |
1252 "containerTransitionComplete", |
1196 "containerTransitionComplete", |
1253 QString( "snapshot_effect") ); |
1197 QString( EFFECT_TARGET_SNAPSHOT) ); |
1254 |
1198 |
1255 HbEffect::start( mMainContainer, |
1199 HbEffect::start( mMainContainer, |
1256 QString( "container" ), |
1200 QString( CONTAINER_EFFECT_GROUP ), |
1257 QString( "slide_in_to_right_and_fade_in" ), |
1201 QString( SHOW_BACK_EFFECT ), |
1258 this, |
1202 this, |
1259 "containerTransitionComplete", |
1203 "containerTransitionComplete", |
1260 QString( "mainContainer_effect") ); |
1204 QString( EFFECT_TARGET_CONTAINER) ); |
1261 } |
1205 } |
1262 else { |
1206 else { |
1263 HbEffect::start( mSnapshot, |
1207 HbEffect::start( mSnapshot, |
1264 QString( "container" ), |
1208 QString( CONTAINER_EFFECT_GROUP ), |
1265 QString( "slide_out_to_top" ), |
1209 QString( HIDE_EFFECT ), |
1266 this, |
1210 this, |
1267 "containerTransitionComplete", |
1211 "containerTransitionComplete", |
1268 QString( "snapshot_effect") ); |
1212 QString( EFFECT_TARGET_SNAPSHOT) ); |
1269 |
1213 |
1270 HbEffect::start( mMainContainer, |
1214 HbEffect::start( mMainContainer, |
1271 QString( "container" ), |
1215 QString( CONTAINER_EFFECT_GROUP ), |
1272 QString( "slide_in_to_top_and_fade_in" ), |
1216 QString( SHOW_EFFECT ), |
1273 this, |
1217 this, |
1274 "containerTransitionComplete", |
1218 "containerTransitionComplete", |
1275 QString( "mainContainer_effect") ); |
1219 QString( EFFECT_TARGET_CONTAINER ) ); |
1276 } |
1220 } |
1277 } |
1221 } |
1278 |
1222 |
1279 /*! |
1223 /*! |
1280 \internal |
1224 \internal |
1281 Closes any active dialog or menu. |
1225 Closes any active dialog or menu. |
1282 */ |
1226 */ |
1283 void MpCollectionView::cancelOngoingOperation() |
1227 void MpCollectionView::closeActiveDialog( bool onlyContextMenu ) |
1284 { |
1228 { |
1285 if ( mActivated ) { |
1229 mMpPopupHandler->cancelOngoingPopup( onlyContextMenu ); |
1286 mMpPopupHandler->cancelOngoingPopup(); |
1230 menu()->close(); |
1287 menu()->close(); |
1231 } |
1288 } |
1232 |
1289 } |
|
1290 |
|