|
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 "cpaboutview.h" |
|
19 #include "cpaboutthirdpartyview.h" |
|
20 #include "cpaboutopensourceview.h" |
|
21 #include "cpaboututils.h" |
|
22 #include <hbgroupbox.h> |
|
23 #include <HbMainWindow> |
|
24 #include <HbInstance> |
|
25 #include <HbAction> |
|
26 #include <HbScrollArea> |
|
27 #include <QGraphicsLinearLayout> |
|
28 #include <HbParameterLengthLimiter> |
|
29 |
|
30 /*! |
|
31 \class CpAboutView |
|
32 */ |
|
33 |
|
34 /*! |
|
35 Constructor |
|
36 */ |
|
37 CpAboutView::CpAboutView(QGraphicsItem *parent) |
|
38 : CpBaseSettingView(0, parent), |
|
39 mThirdPartyView(0), |
|
40 mThirdPartyBackAction(0), |
|
41 mOpenSourceView(0), |
|
42 mOpenSourceBackAction(0) |
|
43 { |
|
44 //application title |
|
45 setTitle(hbTrId("txt_cp_title_control_panel")); |
|
46 //view layout |
|
47 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
48 layout->setContentsMargins(0, 0, 0, 0); |
|
49 //view's title |
|
50 HbGroupBox *label = new HbGroupBox(); |
|
51 label->setHeading(hbTrId("txt_cp_subhead_about")); |
|
52 layout->addItem(label); |
|
53 |
|
54 //phone model |
|
55 QString phoneInfo(HbParameterLengthLimiter("txt_cp_subhead_device_model").arg(\ |
|
56 CpAboutUtils::getPhoneModel())); |
|
57 phoneInfo.append(doubleHtmlLineBreak); |
|
58 //product release |
|
59 phoneInfo.append(hbTrId("txt_cp_subhead_product_release")); |
|
60 phoneInfo.append(htmlLineBreak); |
|
61 phoneInfo.append(HbParameterLengthLimiter("txt_cp_info_product_release").arg(\ |
|
62 CpAboutUtils::getProductRelease())); |
|
63 phoneInfo.append(doubleHtmlLineBreak); |
|
64 //software version |
|
65 phoneInfo.append(hbTrId("txt_cp_subhead_software_version")); |
|
66 phoneInfo.append(htmlLineBreak); |
|
67 phoneInfo.append(HbParameterLengthLimiter("txt_cp_info_software_vesion").arg(\ |
|
68 CpAboutUtils::getSoftwareVersion())); |
|
69 phoneInfo.append(doubleHtmlLineBreak); |
|
70 //produce type |
|
71 phoneInfo.append(hbTrId("txt_cp_subhead_type")); |
|
72 phoneInfo.append(htmlLineBreak); |
|
73 phoneInfo.append(HbParameterLengthLimiter("txt_cp_info_type").arg(\ |
|
74 CpAboutUtils::getPhoneType())); |
|
75 //first text edit for showing phone and release info |
|
76 HbTextEdit *first = CpAboutUtils::createTextEdit(); |
|
77 first->setHtml(CpAboutUtils::preprocessText(phoneInfo)); |
|
78 layout->addItem(first); |
|
79 //second text edit for showing nokia copy right. |
|
80 HbTextEdit *second = CpAboutUtils::createTextEdit(); |
|
81 QString info(hbTrId("txt_cp_info_1")); |
|
82 second->setHtml(CpAboutUtils::preprocessText(info)); |
|
83 layout->addItem(second); |
|
84 //thirdParty content. |
|
85 HbTextEdit *thirdParty = CpAboutUtils::createTextEdit(); |
|
86 thirdParty->setHtml(CpAboutUtils::linkHtmlContent(hbTrId("txt_cp_3rd_party_notices"))); |
|
87 layout->addItem(thirdParty); |
|
88 connect(thirdParty, SIGNAL(anchorTapped(QString)), this, SLOT(openThirdPartyView())); |
|
89 //Open source notices |
|
90 HbTextEdit *openSourceEdit = CpAboutUtils::createTextEdit(); |
|
91 openSourceEdit->setHtml(CpAboutUtils::linkHtmlContent(hbTrId("txt_cp_open_source_software_notices"))); |
|
92 layout->addItem(openSourceEdit); |
|
93 connect(openSourceEdit, SIGNAL(anchorTapped(QString)), this, SLOT(openOpenSourceView())); |
|
94 |
|
95 HbScrollArea* scrollArea = new HbScrollArea(); |
|
96 QGraphicsWidget* widget = new QGraphicsWidget(); |
|
97 widget->setLayout(layout); |
|
98 scrollArea->setContentWidget(widget); |
|
99 scrollArea->setScrollDirections(Qt::Vertical); |
|
100 setWidget(scrollArea); |
|
101 } |
|
102 |
|
103 /*! |
|
104 Destructor |
|
105 */ |
|
106 CpAboutView::~CpAboutView() |
|
107 { |
|
108 // delete mModel; |
|
109 delete mThirdPartyBackAction; |
|
110 delete mOpenSourceBackAction; |
|
111 } |
|
112 |
|
113 /*! |
|
114 Opens the third party view |
|
115 */ |
|
116 void CpAboutView::openThirdPartyView() |
|
117 { |
|
118 HbMainWindow *mainWindow = hbInstance->allMainWindows().first(); |
|
119 mThirdPartyView = new CpAboutThirdPartyView(); |
|
120 mainWindow->addView(mThirdPartyView); |
|
121 |
|
122 mThirdPartyBackAction = new HbAction(Hb::BackNaviAction); |
|
123 mThirdPartyView->setNavigationAction(mThirdPartyBackAction); |
|
124 connect(mThirdPartyBackAction, SIGNAL(triggered()), |
|
125 this, SLOT(handleThirdPartyViewBackAction())); |
|
126 |
|
127 mThirdPartyView->setTitle(hbTrId("txt_cp_title_control_panel")); |
|
128 |
|
129 mainWindow->setCurrentView(mThirdPartyView); |
|
130 } |
|
131 |
|
132 /*! |
|
133 Opens the open source view |
|
134 */ |
|
135 void CpAboutView::openOpenSourceView() |
|
136 { |
|
137 HbMainWindow *mainWindow = hbInstance->allMainWindows().first(); |
|
138 |
|
139 mOpenSourceView = new CpAboutOpenSourceView(); |
|
140 mainWindow->addView(mOpenSourceView); |
|
141 |
|
142 mOpenSourceBackAction = new HbAction(Hb::BackNaviAction); |
|
143 mOpenSourceView->setNavigationAction(mOpenSourceBackAction); |
|
144 connect(mOpenSourceBackAction, SIGNAL(triggered()), |
|
145 this, SLOT(handleOpenSourceViewBackAction())); |
|
146 |
|
147 mOpenSourceView->setTitle(hbTrId("txt_cp_title_control_panel")); |
|
148 |
|
149 mainWindow->setCurrentView(mOpenSourceView); |
|
150 } |
|
151 |
|
152 /*! |
|
153 Handles the back action from Third Party view |
|
154 */ |
|
155 void CpAboutView::handleThirdPartyViewBackAction() |
|
156 { |
|
157 HbMainWindow *mainWindow = hbInstance->allMainWindows().first(); |
|
158 mainWindow->removeView(mThirdPartyView); |
|
159 mThirdPartyView->deleteLater(); |
|
160 } |
|
161 |
|
162 /*! |
|
163 Handles the back action from Open Source view |
|
164 */ |
|
165 void CpAboutView::handleOpenSourceViewBackAction() |
|
166 { |
|
167 HbMainWindow *mainWindow = hbInstance->allMainWindows().first(); |
|
168 mainWindow->removeView(mOpenSourceView); |
|
169 mOpenSourceView->deleteLater(); |
|
170 } |