controlpanelplugins/aboutplugin/src/cpaboutthirdpartyview.cpp
changeset 36 2fee987ebaff
equal deleted inserted replaced
33:0cfa53de576f 36:2fee987ebaff
       
     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 #include "cpaboutthirdpartyview.h"
       
    18 #include "cpaboututils.h"
       
    19 #include <HbScrollArea>
       
    20 #include <HbGroupBox>
       
    21 #include <QGraphicsLinearLayout>
       
    22 #include <QDesktopServices>
       
    23 #include <QUrl>
       
    24 /*!
       
    25   \class CpAboutThirdPartyView
       
    26 */
       
    27 
       
    28 /*!
       
    29     Constructor
       
    30 */
       
    31 CpAboutThirdPartyView::CpAboutThirdPartyView(QGraphicsItem *parent) 
       
    32 : HbView(parent)    
       
    33 {      
       
    34     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    35     layout->setContentsMargins(0, 0, 0, 0);
       
    36     
       
    37     //view titile  
       
    38     HbGroupBox *label = new HbGroupBox();
       
    39     label->setHeading(hbTrId("txt_cp_subhead_3rd_party_notices"));
       
    40     layout->addItem(label);
       
    41     //the first text edit contains the icon.
       
    42     HbTextEdit *firstEdit = new HbTextEdit();//CpAboutUtils::createTextEdit();
       
    43     QImage image("c:\\data\\qgn_graf_mup2_visualizer_image.svg"); 
       
    44     QTextCursor cursor(firstEdit->textCursor());
       
    45     cursor.insertImage(image);    
       
    46     QString str = CpAboutUtils::contentString("txt_cp_3rd_party_notices_",1 );
       
    47     str.insert(0, doubleHtmlLineBreak);    
       
    48     cursor.insertHtml(str);
       
    49     firstEdit->setTextCursor(cursor);
       
    50     layout->addItem(firstEdit);    
       
    51     //2-14 logic string's text edit.     
       
    52     for (int i = 2; i<=14; i++ ) {
       
    53         QString content(CpAboutUtils::findAndReplaceWithLink(\
       
    54                 CpAboutUtils::contentString("txt_cp_3rd_party_notices_", i)));        
       
    55         HbTextEdit *edit = CpAboutUtils::createTextEdit();        
       
    56         edit->setHtml(content);        
       
    57         connect(edit, SIGNAL(anchorTapped(QString)), this, SLOT(handleLinkClicked(QString)));
       
    58         layout->addItem(edit);
       
    59     }
       
    60      
       
    61     HbScrollArea* scrollArea = new HbScrollArea();    
       
    62     QGraphicsWidget* contentWidget = new QGraphicsWidget();    
       
    63     contentWidget->setLayout(layout);   
       
    64     scrollArea->setContentWidget(contentWidget);    
       
    65     scrollArea->setScrollDirections(Qt::Vertical);
       
    66     setWidget(scrollArea);
       
    67 }
       
    68 
       
    69 /*!
       
    70     Destructor
       
    71 */
       
    72 CpAboutThirdPartyView::~CpAboutThirdPartyView()
       
    73 {
       
    74 }
       
    75 
       
    76 /*!
       
    77     Responds to link clicked signal.   
       
    78 */
       
    79 void CpAboutThirdPartyView::handleLinkClicked(const QString &anchor)
       
    80 {    
       
    81     if (!anchor.isEmpty() && 
       
    82             !QDesktopServices::openUrl(QUrl(anchor))) {
       
    83         return;
       
    84     }
       
    85 }
       
    86