app/src/mpmtpinfolink.cpp
changeset 41 ea59c434026a
child 43 0f32e550d9d8
child 48 af3740e3753f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/mpmtpinfolink.cpp	Wed Jun 23 18:10:13 2010 +0300
@@ -0,0 +1,98 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Music Player MTP info link. This class is used to provide a link
+*              to educate the user about MTP after a successful manual refresh.
+*              Basically this class inherits from HbLabel and catches mouse events,
+*              when clicked it opens a url already specified in settings.
+*
+*/
+
+//Qt
+#include <QUrl>
+#include <QDesktopServices>
+#include <QGraphicsSceneMouseEvent>
+
+//Orbit
+#include <hbparameterlengthlimiter.h>
+
+//Local
+#include "mpsettingsmanager.h"
+#include "mpmtpinfolink.h"
+#include "mptrace.h"
+
+/*!
+    \class MpMtpInfoLink
+    \brief MpMtpInfoLink provides a label that can handle mouse events.
+
+    When label is clicked it opens a URL containing MTP information.
+*/
+
+/*!
+ Constructs MpMtpInfoLink.
+ */
+MpMtpInfoLink::MpMtpInfoLink()
+{
+    TX_ENTRY
+    setTextWrapping( Hb::TextWrapAnywhere );
+    setMtpInfoText();
+    TX_EXIT
+}
+
+/*!
+ Destructs the MpMtpInfoLink.
+ */
+MpMtpInfoLink::~MpMtpInfoLink()
+{
+    TX_LOG
+}
+
+/*!
+ Catches mouse press events.
+ */
+void MpMtpInfoLink::mousePressEvent( QGraphicsSceneMouseEvent *event )
+{
+    Q_UNUSED( event );
+}
+
+/*!
+ Catches mouse release event.
+ */
+void MpMtpInfoLink::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
+{
+    TX_ENTRY
+    QRectF itemRect = boundingRect();
+    QPointF releasePoint = event->lastPos();
+    if ( itemRect.contains( releasePoint ) ) {
+        QUrl url( MpSettingsManager::instance()->mtpInfoUrl() );
+        QDesktopServices::openUrl( url );
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+ Set text to be shown in html format
+ */
+void MpMtpInfoLink::setMtpInfoText()
+{
+    TX_ENTRY
+    QString url = MpSettingsManager::instance()->mtpInfoUrl();
+    QString text = HbParameterLengthLimiter( "txt_mus_info_please_note_that_using_media_transfer" ).arg( url );
+    QString htmlLink = "<a href=\"" + url + "\">" + url + "</a>" ;
+    text.replace( url, htmlLink );
+    text = "<p>" + text + "</p>" ;
+    setHtml( text );
+    TX_EXIT
+}
+