13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QGraphicsLinearLayout> |
18 |
19 #include <HbIconItem> |
19 #include <QPainter> |
20 #include "hsdialerwidget.h" |
20 #include <hbframedrawer.h> |
21 #ifdef Q_OS_SYMBIAN |
21 #include <hbframeitem.h> |
|
22 #include <hbtextitem.h> |
|
23 #ifdef Q_OS_SYMBIAN |
|
24 #include <logsdomaincrkeys.h> |
22 #include "qtphonelog.h" |
25 #include "qtphonelog.h" |
23 #include <xqservicerequest.h> |
26 #include <xqservicerequest.h> |
24 #include <xqcallinfo.h> |
27 #include <xqcallinfo.h> |
25 #include <xqpublishandsubscribeutils.h> |
28 #include <xqpublishandsubscribeutils.h> |
26 #include <ctsydomainpskeys.h> |
29 #include <ctsydomainpskeys.h> |
27 #include <logsservices.h> |
30 #include <logsservices.h> |
28 #endif |
31 #endif |
29 |
32 |
|
33 #include "hsdialerwidget.h" |
|
34 |
30 namespace |
35 namespace |
31 { |
36 { |
32 const char KDialerWidgetIcon[] = "qtg_graf_hs_dialer"; |
37 const char KDialerWidgetIcon[] = "qtg_graf_hs_dialer"; |
|
38 const char KMissedCallShortcutBadge[] = ":/icons/resource/qtg_fr_shortcut_badge_bg"; |
33 } |
39 } |
34 |
40 |
35 /*! |
41 /*! |
36 \class HsDialerWidget |
42 \class HsDialerWidget |
37 |
43 |
45 */ |
51 */ |
46 HsDialerWidget::HsDialerWidget(QGraphicsItem *parent, Qt::WindowFlags flags) |
52 HsDialerWidget::HsDialerWidget(QGraphicsItem *parent, Qt::WindowFlags flags) |
47 : HbWidget(parent, flags), |
53 : HbWidget(parent, flags), |
48 mXQCallInfo(0) |
54 mXQCallInfo(0) |
49 { |
55 { |
50 HbIconItem *iconItem = new HbIconItem; |
56 #ifdef Q_OS_SYMBIAN |
51 HbIcon icon(KDialerWidgetIcon); |
57 m_setManager = new XQSettingsManager(this); |
52 iconItem->setIcon(icon); |
58 |
53 |
59 XQSettingsKey settingsKey( XQSettingsKey::TargetCentralRepository, |
54 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout; |
60 KCRUidLogs.iUid, KLogsNewMissedCalls ); |
55 layout->addItem(iconItem); |
61 |
56 setLayout(layout); |
62 bool ok = connect( m_setManager, |
57 |
63 SIGNAL( valueChanged(const XQSettingsKey & ,const QVariant &)), |
58 setPreferredSize(icon.size()); |
64 this, SLOT(updateMissedCallBadge(XQSettingsKey, |
|
65 QVariant))); |
|
66 ASSERT( ok ); |
|
67 ok = false; |
|
68 ok = m_setManager->startMonitoring( settingsKey ); |
|
69 ASSERT(ok); |
|
70 |
|
71 #endif |
|
72 |
|
73 HbFrameDrawer *drawer = new HbFrameDrawer( |
|
74 KDialerWidgetIcon, HbFrameDrawer::OnePiece); |
|
75 m_backgroud = new HbFrameItem(drawer, this); |
|
76 m_backgroud->setZValue(1); |
|
77 |
|
78 drawer = new HbFrameDrawer(KMissedCallShortcutBadge, |
|
79 HbFrameDrawer::ThreePiecesHorizontal ); |
|
80 |
|
81 m_shortcutBadge = new HbFrameItem(drawer, this); |
|
82 m_shortcutBadge->setZValue(2); |
|
83 m_shortcutBadge->setVisible(true); |
|
84 m_missedCalls=2; |
|
85 setItemPositions(); |
59 resize(preferredSize()); |
86 resize(preferredSize()); |
60 } |
87 } |
61 |
88 |
62 /*! |
89 /*! |
63 Destructor. |
90 Destructor. |
64 */ |
91 */ |
65 HsDialerWidget::~HsDialerWidget() |
92 HsDialerWidget::~HsDialerWidget() |
66 { |
93 { |
|
94 } |
|
95 |
|
96 void HsDialerWidget::paint( |
|
97 QPainter *painter, |
|
98 const QStyleOptionGraphicsItem *option, |
|
99 QWidget *widget) |
|
100 { |
|
101 Q_UNUSED(option); |
|
102 Q_UNUSED(widget); |
|
103 painter->setPen(QPen( Qt::transparent ) ); |
|
104 |
|
105 QRectF rect(m_backgroud->boundingRect()); |
|
106 painter->drawRect((int)m_backgroud->pos().x(), |
|
107 (int)m_backgroud->pos().y(), |
|
108 rect.toRect().width(), |
|
109 rect.toRect().height()); |
|
110 |
|
111 if ( m_shortcutBadge->isVisible()) |
|
112 { |
|
113 rect = m_shortcutBadge->boundingRect(); |
|
114 HbTextItem *text = new HbTextItem( m_shortcutBadge->graphicsItem()); |
|
115 |
|
116 QFont badgefont = font(); |
|
117 #ifdef Q_OS_SYMBIAN |
|
118 badgefont.setPointSize( 4 ); |
|
119 #else |
|
120 badgefont.setPointSize( 8 ); |
|
121 #endif |
|
122 text->setFont(badgefont); |
|
123 text->setText(QString::number(m_missedCalls)); |
|
124 text->setZValue(3); |
|
125 text->setTextColor(Qt::white); |
|
126 // text->font().setPointSizeF(2); |
|
127 |
|
128 text->setX( ( rect.toRect().width() / 2 ) - 2); |
|
129 text->setY( ( rect.toRect().height() / 5 ) - 1); |
|
130 |
|
131 painter->drawRect( (int)m_shortcutBadge->pos().x(), |
|
132 (int)m_shortcutBadge->pos().y(), |
|
133 rect.toRect().width(), |
|
134 rect.toRect().height() ); |
|
135 } |
67 } |
136 } |
68 |
137 |
69 /*! |
138 /*! |
70 \fn void HsDialerWidget::startDialer() |
139 \fn void HsDialerWidget::startDialer() |
71 |
140 |
135 void HsDialerWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) |
220 void HsDialerWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) |
136 { |
221 { |
137 Q_UNUSED(event); |
222 Q_UNUSED(event); |
138 startDialer(); |
223 startDialer(); |
139 } |
224 } |
|
225 |
|
226 void HsDialerWidget::setItemPositions() |
|
227 { |
|
228 HbIcon icon(KDialerWidgetIcon); |
|
229 setPreferredWidth( icon.width()); |
|
230 int badgeSize = 20; |
|
231 if ( m_shortcutBadge->isVisible()){ |
|
232 m_backgroud->setGeometry(QRectF(QPointF(0,badgeSize / 2 ), |
|
233 QSizeF(icon.width(),icon.height()))); |
|
234 m_shortcutBadge->setGeometry(QRectF( |
|
235 QPointF(m_backgroud->boundingRect().width() - (badgeSize / 2),0 ), |
|
236 QSizeF(badgeSize, badgeSize))); |
|
237 setPreferredHeight(icon.height()+(badgeSize / 2)); |
|
238 } else { |
|
239 m_backgroud->setGeometry(QRectF(QPointF(0,0), |
|
240 QSizeF(icon.width(),icon.height()))); |
|
241 setPreferredHeight(icon.height()); |
|
242 } |
|
243 } |