1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbInput module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #include <QGraphicsLinearLayout> |
|
27 #if QT_VERSION >= 0x040600 |
|
28 #include <QGraphicsDropShadowEffect> |
|
29 #endif |
|
30 |
|
31 #include <hbinputvkbwidget.h> |
|
32 #include <hbaction.h> |
|
33 #include "hbinputtouchkeypadbutton.h" |
|
34 #include "hbinputcustombuttonlist.h" |
|
35 #include "hbdialog_p.h" |
|
36 |
|
37 /// @cond |
|
38 |
|
39 |
|
40 class HbInputCustomButtonListPrivate : public HbDialogPrivate |
|
41 { |
|
42 public: |
|
43 HbInputCustomButtonListPrivate(HbInputVkbWidget* owner) : mOwner(owner) {}; |
|
44 ~HbInputCustomButtonListPrivate() {}; |
|
45 public: |
|
46 HbInputVkbWidget* mOwner; |
|
47 QList<HbTouchKeypadButton*> mButtonList; |
|
48 }; |
|
49 |
|
50 |
|
51 |
|
52 /// @endcond |
|
53 |
|
54 /*! |
|
55 \deprecated HbInputCustomButtonList::HbInputCustomButtonList(QList<HbAction*>&, HbInputVkbWidget*, QGraphicsWidget*) |
|
56 is deprecated. HbInputCustomButtonList will be removed. |
|
57 */ |
|
58 HbInputCustomButtonList::HbInputCustomButtonList(QList<HbAction*>& actionList, HbInputVkbWidget* owner, |
|
59 QGraphicsWidget* parent) |
|
60 : HbDialog(*new HbInputCustomButtonListPrivate(owner), parent) |
|
61 { |
|
62 Q_D(HbInputCustomButtonList); |
|
63 |
|
64 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
|
65 |
|
66 QGraphicsLinearLayout *linearLayout = new QGraphicsLinearLayout(Qt::Horizontal); |
|
67 |
|
68 QGraphicsWidget* contextWidget = new QGraphicsWidget; |
|
69 linearLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0); |
|
70 linearLayout->setSpacing(0.0); |
|
71 contextWidget->setLayout(linearLayout); |
|
72 |
|
73 #if QT_VERSION >= 0x040600 |
|
74 // Make sure the custom button list never steals focus. |
|
75 setFlag(QGraphicsItem::ItemIsPanel, true); |
|
76 setActive(false); |
|
77 |
|
78 // enable drop shadow for the preview pane |
|
79 // Effect deletion is crashing -> Effect temporarily removed |
|
80 // QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect; |
|
81 // effect->setBlurRadius(8); |
|
82 // setGraphicsEffect(effect); |
|
83 #endif |
|
84 |
|
85 setContentWidget(contextWidget); |
|
86 |
|
87 // set default values for popup |
|
88 setTimeout(HbDialog::NoTimeout); |
|
89 layout()->setContentsMargins(0.0, 0.0, 0.0, 0.0); |
|
90 setBackgroundFaded(false); |
|
91 setDismissPolicy(TapAnywhere); |
|
92 setModal(false); |
|
93 |
|
94 updateActions(actionList); |
|
95 } |
|
96 |
|
97 /*! |
|
98 \deprecated HbInputCustomButtonList::~HbInputCustomButtonList() |
|
99 is deprecated. HbInputCustomButtonList will be removed. |
|
100 */ |
|
101 HbInputCustomButtonList::~HbInputCustomButtonList() |
|
102 { |
|
103 } |
|
104 |
|
105 |
|
106 /*! |
|
107 \deprecated HbInputCustomButtonList::updateActions(QList<HbAction*>&) |
|
108 is deprecated. HbInputCustomButtonList will be removed. |
|
109 */ |
|
110 void HbInputCustomButtonList::updateActions(QList<HbAction*>& newActions) |
|
111 { |
|
112 Q_D(HbInputCustomButtonList); |
|
113 |
|
114 QGraphicsLinearLayout* layout = static_cast<QGraphicsLinearLayout*>(contentWidget()->layout()); |
|
115 int j = 0; |
|
116 |
|
117 // create new buttons |
|
118 for(int i=0; i<newActions.count(); i++) |
|
119 { |
|
120 HbTouchKeypadButton* button = 0; |
|
121 |
|
122 if (newActions.at(i)->isVisible()) { |
|
123 if (j < d->mButtonList.count()){ |
|
124 // update old button |
|
125 button = d->mButtonList.at(j); |
|
126 button->disconnect(SIGNAL(clicked())); |
|
127 button->setText(newActions.at(i)->text()); |
|
128 button->setIcon(newActions.at(i)->icon()); |
|
129 } else { |
|
130 // create new button |
|
131 if (!newActions.at(i)->icon().isNull()) { |
|
132 button = new HbTouchKeypadButton(d->mOwner, newActions.at(i)->icon(), newActions.at(i)->text(), this); |
|
133 } else { |
|
134 button = new HbTouchKeypadButton(d->mOwner, newActions.at(i)->text(), this); |
|
135 } |
|
136 d->mButtonList.append(button); |
|
137 layout->addItem(button); |
|
138 } |
|
139 |
|
140 button->setButtonType(HbTouchKeypadButton::HbTouchButtonNormal); |
|
141 button->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
142 if (newActions.at(i)->text().isEmpty()) { |
|
143 button->setObjectName( "Custom button list button " + QString::number(i)); |
|
144 } else { |
|
145 button->setObjectName( "Custom button list " + newActions.at(i)->text()); |
|
146 } |
|
147 button->setToolTip(newActions.at(i)->toolTip()); |
|
148 button->setEnabled(newActions.at(i)->isEnabled()); |
|
149 |
|
150 // make click connection |
|
151 connect(button, SIGNAL(clicked()), newActions.at(i), SLOT(trigger())); |
|
152 ++j; |
|
153 } |
|
154 } |
|
155 |
|
156 // remove extra buttons from layout |
|
157 while(j < d->mButtonList.count()) { |
|
158 HbTouchKeypadButton* button = d->mButtonList.at(j); |
|
159 d->mButtonList.removeAt(j); |
|
160 layout->removeItem(button); |
|
161 button->disconnect(SIGNAL(clicked())); |
|
162 delete button; |
|
163 } |
|
164 } |
|
165 |
|
166 /*! |
|
167 \deprecated HbInputCustomButtonList::count() |
|
168 is deprecated. HbInputCustomButtonList will be removed. |
|
169 */ |
|
170 int HbInputCustomButtonList::count() |
|
171 { |
|
172 Q_D(HbInputCustomButtonList); |
|
173 return d->mButtonList.count(); |
|
174 } |
|
175 |
|
176 /*! |
|
177 \deprecated HbInputCustomButtonList::orientation() |
|
178 is deprecated. HbInputCustomButtonList will be removed. |
|
179 */ |
|
180 Qt::Orientation HbInputCustomButtonList::orientation() |
|
181 { |
|
182 return static_cast<QGraphicsLinearLayout*>(contentWidget()->layout())->orientation(); |
|
183 } |
|
184 |
|
185 /*! |
|
186 \deprecated HbInputCustomButtonList::setOrientation(Qt::Orientation) |
|
187 is deprecated. HbInputCustomButtonList will be removed. |
|
188 */ |
|
189 void HbInputCustomButtonList::setOrientation(Qt::Orientation orientation) |
|
190 { |
|
191 static_cast<QGraphicsLinearLayout*>(contentWidget()->layout())->setOrientation(orientation); |
|
192 updatePrimitives(); |
|
193 } |
|
194 |
|
195 /*! |
|
196 \deprecated HbInputCustomButtonList::setGeometry(const QRectF&) |
|
197 is deprecated. HbInputCustomButtonList will be removed. |
|
198 |
|
199 \reimp |
|
200 */ |
|
201 void HbInputCustomButtonList::setGeometry(const QRectF & rect) |
|
202 { |
|
203 // Override HbDialog setGeometry, which would center the widget. |
|
204 QGraphicsWidget::setGeometry(rect); |
|
205 } |
|
206 |
|
207 // End of file |
|