|
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 MTP info link. This class is used to provide a link |
|
15 * to educate the user about MTP after a successful manual refresh. |
|
16 * Basically this class inherits from HbLabel and catches mouse events, |
|
17 * when clicked it opens a url already specified in settings. |
|
18 * |
|
19 */ |
|
20 |
|
21 //Qt |
|
22 #include <QUrl> |
|
23 #include <QDesktopServices> |
|
24 #include <QGraphicsSceneMouseEvent> |
|
25 |
|
26 //Orbit |
|
27 #include <hbparameterlengthlimiter.h> |
|
28 |
|
29 //Local |
|
30 #include "mpsettingsmanager.h" |
|
31 #include "mpmtpinfolink.h" |
|
32 #include "mptrace.h" |
|
33 |
|
34 /*! |
|
35 \class MpMtpInfoLink |
|
36 \brief MpMtpInfoLink provides a label that can handle mouse events. |
|
37 |
|
38 When label is clicked it opens a URL containing MTP information. |
|
39 */ |
|
40 |
|
41 /*! |
|
42 Constructs MpMtpInfoLink. |
|
43 */ |
|
44 MpMtpInfoLink::MpMtpInfoLink() |
|
45 { |
|
46 TX_ENTRY |
|
47 setTextWrapping( Hb::TextWrapAnywhere ); |
|
48 setMtpInfoText(); |
|
49 TX_EXIT |
|
50 } |
|
51 |
|
52 /*! |
|
53 Destructs the MpMtpInfoLink. |
|
54 */ |
|
55 MpMtpInfoLink::~MpMtpInfoLink() |
|
56 { |
|
57 TX_LOG |
|
58 } |
|
59 |
|
60 /*! |
|
61 Catches mouse press events. |
|
62 */ |
|
63 void MpMtpInfoLink::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
|
64 { |
|
65 Q_UNUSED( event ); |
|
66 } |
|
67 |
|
68 /*! |
|
69 Catches mouse release event. |
|
70 */ |
|
71 void MpMtpInfoLink::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) |
|
72 { |
|
73 TX_ENTRY |
|
74 QRectF itemRect = boundingRect(); |
|
75 QPointF releasePoint = event->lastPos(); |
|
76 if ( itemRect.contains( releasePoint ) ) { |
|
77 QUrl url( MpSettingsManager::instance()->mtpInfoUrl() ); |
|
78 QDesktopServices::openUrl( url ); |
|
79 } |
|
80 TX_EXIT |
|
81 } |
|
82 |
|
83 /*! |
|
84 \internal |
|
85 Set text to be shown in html format |
|
86 */ |
|
87 void MpMtpInfoLink::setMtpInfoText() |
|
88 { |
|
89 TX_ENTRY |
|
90 QString url = MpSettingsManager::instance()->mtpInfoUrl(); |
|
91 QString text = HbParameterLengthLimiter( "txt_mus_info_please_note_that_using_media_transfer" ).arg( url ); |
|
92 QString htmlLink = "<a href=\"" + url + "\">" + url + "</a>" ; |
|
93 text.replace( url, htmlLink ); |
|
94 text = "<p>" + text + "</p>" ; |
|
95 setHtml( text ); |
|
96 TX_EXIT |
|
97 } |
|
98 |