|
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 "nmuiengineheaders.h" |
|
19 |
|
20 static HbIcon *icons[NmIcons::NmLastItem]; |
|
21 |
|
22 /*! |
|
23 \struct IconRes |
|
24 \brief Icon resource structure |
|
25 */ |
|
26 struct IconRes { |
|
27 NmIcons::Icon id; |
|
28 QString resName; |
|
29 }; |
|
30 |
|
31 /*! |
|
32 Icon array |
|
33 */ |
|
34 static IconRes icon_res[] = { |
|
35 {NmIcons::NmIconDefaultMailbox, "qtg_large_email"}, |
|
36 {NmIcons::NmIconPlusSign, "qtg_small_expand"}, |
|
37 {NmIcons::NmIconMinusSign, "qtg_small_collapse"}, |
|
38 {NmIcons::NmIconAttachment, "qtg_small_attachment"}, |
|
39 {NmIcons::NmIconPriorityHigh, "qtg_small_priority_high"}, |
|
40 {NmIcons::NmIconPriorityLow, "qtg_small_priority_low"}, |
|
41 {NmIcons::NmIconAttach, "qtg_mono_attach"}, |
|
42 {NmIcons::NmIconSend, "qtg_mono_send"}, |
|
43 {NmIcons::NmIconContacts, "qtg_mono_contacts"}, |
|
44 {NmIcons::NmIconNewEmail, "qtg_mono_create_email"}, |
|
45 {NmIcons::NmIconDelete, "qtg_mono_delete"}, |
|
46 {NmIcons::NmIconForward, "qtg_mono_forward"}, |
|
47 {NmIcons::NmIconReply, "qtg_mono_reply"}, |
|
48 {NmIcons::NmIconReplyAll, "qtg_mono_reply_all"}, |
|
49 {NmIcons::NmIconSynching, "qtg_small_attachment"}, |
|
50 {NmIcons::NmIconOnline, "qtg_small_priority_low"}, |
|
51 {NmIcons::NmIconDisconnected, "qtg_small_priority_high"}, |
|
52 {NmIcons::NmIconOffline, "qtg_small_fail"}, |
|
53 {NmIcons::NmLastItem, ""} // Last item definion. |
|
54 }; |
|
55 |
|
56 /*! |
|
57 \class NmIcons |
|
58 \brief handles icons loading and destruction |
|
59 */ |
|
60 |
|
61 |
|
62 /*! |
|
63 Get icon function. Use this function with enumeration value to get |
|
64 corresponding icon. Icon is created if it does not exist previously. |
|
65 */ |
|
66 HbIcon &NmIcons::getIcon(NmIcons::Icon icon) |
|
67 { |
|
68 if (!icons[icon]) { |
|
69 for (int i(0); icon_res[i].id != NmIcons::NmLastItem; i++) { |
|
70 if (icon_res[i].id == icon) { |
|
71 // Branding icon check here. If branded icon is not found |
|
72 // default icon is to be loaded. |
|
73 icons[icon] = new HbIcon(icon_res[i].resName); |
|
74 break; |
|
75 } |
|
76 } |
|
77 } |
|
78 if (!icons[icon]) { |
|
79 NMLOG(QString("nmailuiengine: Cannot open icon file: ###").arg(__FILE__)); |
|
80 } |
|
81 return *icons[icon]; |
|
82 } |
|
83 |
|
84 /*! |
|
85 Icon array reset functionality. Called when application exists. |
|
86 */ |
|
87 void NmIcons::freeIcons() |
|
88 { |
|
89 NMLOG("nmailuiengine: Enter freeIcons"); |
|
90 for (int i(0); icon_res[i].id != NmIcons::NmLastItem; i++) { |
|
91 if (icons[i]) { |
|
92 delete icons[i]; |
|
93 icons[i] = NULL; |
|
94 } |
|
95 } |
|
96 } |
|
97 |