27 #include <hbiconitem.h> |
27 #include <hbiconitem.h> |
28 #include <hbmainwindow.h> |
28 #include <hbmainwindow.h> |
29 #include <HbParameterLengthLimiter> |
29 #include <HbParameterLengthLimiter> |
30 |
30 |
31 #include "cpthemepreview.h" |
31 #include "cpthemepreview.h" |
|
32 #include "cpthemeinfo.h" |
32 |
33 |
33 /*! |
34 /*! |
34 \class CpThemePreview |
35 \class CpThemePreview |
35 \brief CpThemePreview shows a preview of a selected theme with a heading displaying the name of the theme as well as |
36 \brief CpThemePreview shows a preview of a selected theme with a heading displaying the name of the theme as well as |
36 a toolbar with Select and Cancel buttons. This view is used for the user to either select the theme and apply |
37 a toolbar with Select and Cancel buttons. This view is used for the user to either select the theme and apply |
50 //Create the layout and add heading and and preview icon to the layout. |
51 //Create the layout and add heading and and preview icon to the layout. |
51 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
52 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical); |
52 |
53 |
53 |
54 |
54 //setup the heading. |
55 //setup the heading. |
55 QString themeHeading = HbParameterLengthLimiter("txt_cp_title_preview_1").arg(mTheme.name); |
56 QString themeHeading = HbParameterLengthLimiter("txt_cp_title_preview_1").arg(mTheme.name()); |
56 HbLabel* label = new HbLabel(themeHeading, this); |
57 HbLabel* label = new HbLabel(themeHeading, this); |
57 |
58 |
58 layout->addItem(label); |
59 layout->addItem(label); |
59 |
60 |
60 layout->setAlignment(layout->itemAt(0), Qt::AlignTop); |
61 layout->setAlignment(layout->itemAt(0), Qt::AlignTop); |
|
62 layout->itemAt(0)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed,QSizePolicy::DefaultType); |
61 |
63 |
62 //Create the toolbar and "Select" and "Cancel" actions. |
64 //Create the toolbar and "Select" and "Cancel" actions. |
63 HbToolBar* mToolBar = new HbToolBar(this); |
65 HbToolBar* mToolBar = new HbToolBar(this); |
64 |
66 |
65 HbAction* selectAction = new HbAction(tr("Select")); |
67 HbAction* selectAction = new HbAction(hbTrId("txt_common_button_select")); |
66 |
68 |
67 //Add Action to the toolbar and show toolbar |
69 //Add Action to the toolbar and show toolbar |
68 mToolBar->addAction( selectAction ); |
70 mToolBar->addAction( selectAction ); |
69 |
71 |
70 HbAction* cancelAction = new HbAction(tr("Cancel")); |
72 HbAction* cancelAction = new HbAction(hbTrId("txt_common_button_cancel")); |
71 mToolBar->addAction( cancelAction ); |
73 mToolBar->addAction( cancelAction ); |
72 |
74 |
73 QObject::connect( selectAction, SIGNAL(triggered()), |
75 QObject::connect( selectAction, SIGNAL(triggered()), |
74 this, SLOT(themeSelected())); |
76 this, SLOT(themeSelected())); |
75 |
77 |
79 QObject::connect( mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
81 QObject::connect( mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
80 this, SLOT(previewOrientationChanged(Qt::Orientation))); |
82 this, SLOT(previewOrientationChanged(Qt::Orientation))); |
81 |
83 |
82 |
84 |
83 if(mainWindow()->orientation() == Qt::Horizontal) { |
85 if(mainWindow()->orientation() == Qt::Horizontal) { |
84 mPreviewIcon = new HbIconItem(mTheme.landscapePreviewIcon, this); |
86 mPreviewIcon = new HbIconItem(mTheme.landscapePreviewIcon(), this); |
85 } |
87 } |
86 else { |
88 else { |
87 mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon, this); |
89 mPreviewIcon = new HbIconItem(mTheme.portraitPreviewIcon(), this); |
88 } |
90 } |
89 layout->addItem(mPreviewIcon); |
91 layout->addItem(mPreviewIcon); |
|
92 layout->itemAt(1)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred,QSizePolicy::DefaultType); |
|
93 |
90 |
94 |
91 setToolBar(mToolBar); |
95 setToolBar(mToolBar); |
92 setLayout(layout); |
96 setLayout(layout); |
93 |
97 |
94 //Setup the Back button action and set softkey. Back button |
98 //Setup the Back button action and set softkey. Back button |
108 } |
112 } |
109 |
113 |
110 /*! |
114 /*! |
111 sets the theme to \a theme. |
115 sets the theme to \a theme. |
112 */ |
116 */ |
113 void CpThemePreview::setThemeInfo(const CpThemeChanger::ThemeInfo& theme) |
117 void CpThemePreview::setThemeInfo(const CpThemeInfo& theme) |
114 { |
118 { |
115 mTheme = theme; |
119 mTheme = theme; |
116 } |
120 } |
117 |
121 |
118 /*! |
122 /*! |
119 returns the themeName. |
123 returns the themeName. |
120 */ |
124 */ |
121 const QString& CpThemePreview::themeName() const |
125 const QString& CpThemePreview::themeName() const |
122 { |
126 { |
123 return mTheme.name; |
127 return mTheme.name(); |
124 } |
128 } |
125 |
129 |
126 /*! |
130 /*! |
127 returns the repersentative themeIcon of the current theme. |
131 returns the repersentative themeIcon of the current theme. |
128 */ |
132 */ |
129 const HbIcon& CpThemePreview::themeIcon() const |
133 const HbIcon& CpThemePreview::themeIcon() const |
130 { |
134 { |
131 return mTheme.icon; |
135 return mTheme.icon(); |
132 } |
136 } |
133 |
137 |
134 /*! |
138 /*! |
135 Slot to handle when the user selects a theme. |
139 Slot to handle when the user selects a theme. |
136 */ |
140 */ |
137 void CpThemePreview::themeSelected() |
141 void CpThemePreview::themeSelected() |
138 { |
142 { |
139 emit applyTheme(mTheme.name); |
143 emit applyTheme(mTheme.name()); |
140 } |
144 } |
141 |
145 |
142 /*! |
146 /*! |
143 * Slot to handle landscape/portrait orientation change to use the |
147 * Slot to handle landscape/portrait orientation change to use the |
144 * right graphics. |
148 * right graphics. |
150 |
154 |
151 if(mPreviewIcon && mPreviewIcon == dynamic_cast<HbIconItem*>(previewLayout->itemAt(1)) ) { |
155 if(mPreviewIcon && mPreviewIcon == dynamic_cast<HbIconItem*>(previewLayout->itemAt(1)) ) { |
152 previewLayout->removeAt(1); |
156 previewLayout->removeAt(1); |
153 |
157 |
154 if(orientation == Qt::Horizontal) { |
158 if(orientation == Qt::Horizontal) { |
155 mPreviewIcon->setIcon(mTheme.landscapePreviewIcon); |
159 mPreviewIcon->setIcon(mTheme.landscapePreviewIcon()); |
156 } |
160 } |
157 else { |
161 else { |
158 mPreviewIcon->setIcon(mTheme.portraitPreviewIcon); |
162 mPreviewIcon->setIcon(mTheme.portraitPreviewIcon()); |
159 } |
163 } |
160 |
164 |
161 previewLayout->addItem(mPreviewIcon); |
165 previewLayout->addItem(mPreviewIcon); |
162 } |
166 } |
163 |
167 |