|
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 <QString> |
|
19 #include <QGraphicsPixmapItem> |
|
20 #include <QGraphicsLinearLayout> |
|
21 |
|
22 #include <hbaction> |
|
23 #include <hbtoolbar> |
|
24 #include <hbicon.h> |
|
25 #include <hbaction.h> |
|
26 #include <hblabel.h> |
|
27 #include <hbiconitem.h> |
|
28 |
|
29 #include "cpthemepreview.h" |
|
30 |
|
31 /*! |
|
32 \class CpThemePreview |
|
33 \brief CpThemePreview shows a preview of a selected theme with a heading displaying the name of the theme as well as |
|
34 a toolbar with Select and Cancel buttons. This view is used for the user to either select the theme and apply |
|
35 the theme change or press Cancel and go back to theme list view. |
|
36 */ |
|
37 |
|
38 /*! |
|
39 constructor. |
|
40 */ |
|
41 CpThemePreview::CpThemePreview(const CpThemeChanger::ThemeInfo& theme, QGraphicsItem *parent) : |
|
42 HbView(parent), |
|
43 mTheme(theme), |
|
44 mSoftKeyBackAction(0) |
|
45 { |
|
46 |
|
47 //Create the layout and add heading and and preview icon to the layout. |
|
48 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
49 |
|
50 |
|
51 //setup the heading. |
|
52 //TODO: translation of string hbTrId("txt_cp_title_preview_1") |
|
53 |
|
54 QString themeHeading = tr("Preview: ") + mTheme.name; |
|
55 HbLabel* label = new HbLabel(themeHeading, this); |
|
56 label->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
57 |
|
58 layout->addItem(label); |
|
59 |
|
60 //Create the toolbar and "Select" and "Cancel" actions. |
|
61 HbToolBar* mToolBar = new HbToolBar(this); |
|
62 |
|
63 HbAction* selectAction = new HbAction(tr("Select")); |
|
64 |
|
65 //Add Action to the toolbar and show toolbar |
|
66 mToolBar->addAction( selectAction ); |
|
67 |
|
68 HbAction* cancelAction = new HbAction(tr("Cancel")); |
|
69 mToolBar->addAction( cancelAction ); |
|
70 |
|
71 QObject::connect( selectAction, SIGNAL(triggered()), |
|
72 this, SLOT(themeSelected())); |
|
73 |
|
74 QObject::connect( cancelAction, SIGNAL(triggered()), |
|
75 this, SIGNAL(aboutToClose())); |
|
76 |
|
77 //layout->addItem(&HbIconItem(mTheme.icon, this )); |
|
78 HbIconItem* layoutItem = new HbIconItem(mTheme.icon, this); |
|
79 layout->addItem(layoutItem); |
|
80 setToolBar(mToolBar); |
|
81 setLayout(layout); |
|
82 |
|
83 //Setup the Back button action and set softkey. Back button |
|
84 //takes the user to the theme list view. |
|
85 mSoftKeyBackAction = new HbAction(Hb::BackAction, this); |
|
86 QObject::connect(mSoftKeyBackAction, SIGNAL(triggered()), |
|
87 this, SIGNAL(aboutToClose()) ); |
|
88 |
|
89 this->setNavigationAction(mSoftKeyBackAction); |
|
90 } |
|
91 |
|
92 /*! |
|
93 destructor. |
|
94 */ |
|
95 CpThemePreview::~CpThemePreview() |
|
96 { |
|
97 } |
|
98 |
|
99 /*! |
|
100 sets the theme to \a theme. |
|
101 */ |
|
102 void CpThemePreview::setThemeInfo(const CpThemeChanger::ThemeInfo& theme) |
|
103 { |
|
104 mTheme = theme; |
|
105 } |
|
106 |
|
107 /*! |
|
108 returns the themeName. |
|
109 */ |
|
110 const QString& CpThemePreview::themeName() const |
|
111 { |
|
112 return mTheme.name; |
|
113 } |
|
114 |
|
115 /*! |
|
116 returns the repersentative themeIcon of the current theme. |
|
117 */ |
|
118 const HbIcon& CpThemePreview::themeIcon() const |
|
119 { |
|
120 return mTheme.icon; |
|
121 } |
|
122 |
|
123 /*! |
|
124 Slot to handle when the user selects a theme. |
|
125 */ |
|
126 void CpThemePreview::themeSelected() |
|
127 { |
|
128 emit applyTheme(mTheme.name); |
|
129 } |
|
130 |