Changeset 56929 in webkit
- Timestamp:
- Apr 1, 2010 12:36:06 PM (14 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/ChangeLog
r56851 r56929 1 2010-04-01 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 Add Single and Multiple Selection Popup for Maemo 5. 6 7 [Qt] Maemo5 theme - popup dialogs 8 https://bugs.webkit.org/show_bug.cgi?id=36789 9 10 * WebCoreSupport/QtMaemoWebPopup.cpp: 11 (WebCore::Maemo5Popup::populateList): 12 (WebCore::Maemo5Popup::onItemSelected): 13 (WebCore::QtMaemoWebPopup::createSingleSelectionPopup): 14 (WebCore::QtMaemoWebPopup::createMultipleSelectionPopup): 15 (WebCore::Maemo5SingleSelectionPopup::Maemo5SingleSelectionPopup): 16 (WebCore::MultipleItemListDelegate::MultipleItemListDelegate): 17 (WebCore::MultipleItemListDelegate::paint): 18 (WebCore::Maemo5MultipleSelectionPopup::Maemo5MultipleSelectionPopup): 19 * WebCoreSupport/QtMaemoWebPopup.h: 20 1 21 2010-03-31 Marcus Bulach <bulach@chromium.org> 2 22 -
trunk/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.cpp
r56784 r56929 21 21 #include "QtMaemoWebPopup.h" 22 22 23 #include <QHBoxLayout> 24 #include <QListWidget> 25 #include <QListWidgetItem> 26 #include <QPainter> 27 #include <QPushButton> 28 #include <QStyledItemDelegate> 29 #include <QVBoxLayout> 30 31 #include <libintl.h> 32 33 23 34 namespace WebCore { 35 36 static const int gMaemoListItemSize = 70; 37 static const int gMaemoListPadding = 38; 38 static const int gMaemoMaxVisibleItems = 5; 39 40 void Maemo5Popup::populateList() 41 { 42 QListWidgetItem* listItem; 43 for (int i = 0; i < m_data.itemCount(); ++i) { 44 if (m_data.itemType(i) == QtAbstractWebPopup::Option) { 45 listItem = new QListWidgetItem(m_data.itemText(i)); 46 m_list->addItem(listItem); 47 listItem->setSelected(m_data.itemIsSelected(i)); 48 } else if (m_data.itemType(i) == QtAbstractWebPopup::Group) { 49 listItem = new QListWidgetItem(m_data.itemText(i)); 50 m_list->addItem(listItem); 51 listItem->setSelected(false); 52 listItem->setFlags(Qt::NoItemFlags); 53 } 54 } 55 connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemSelected(QListWidgetItem*))); 56 } 57 58 void Maemo5Popup::onItemSelected(QListWidgetItem* item) 59 { 60 if (item->flags() != Qt::NoItemFlags) 61 emit itemClicked(m_list->row(item)); 62 } 24 63 25 64 QtMaemoWebPopup::QtMaemoWebPopup() … … 37 76 Maemo5Popup* QtMaemoWebPopup::createSingleSelectionPopup() 38 77 { 78 return new Maemo5SingleSelectionPopup(*this); 39 79 } 40 80 41 81 Maemo5Popup* QtMaemoWebPopup::createMultipleSelectionPopup() 42 82 { 83 return new Maemo5MultipleSelectionPopup(*this); 43 84 } 44 85 … … 51 92 } 52 93 53 54 94 void QtMaemoWebPopup::show() 55 95 { … … 84 124 } 85 125 86 } 126 Maemo5SingleSelectionPopup::Maemo5SingleSelectionPopup(QtAbstractWebPopup& data) 127 : Maemo5Popup(data) 128 { 129 // we try to get the standard list title the web browser is using 130 const char* title = ::dgettext("osso-browser-ui", "weba_ti_texlist_single"); 131 if (qstrcmp(title, "weba_ti_texlist_single")) 132 setWindowTitle(QString::fromUtf8(title)); 133 else 134 setWindowTitle("Select item"); 135 136 QHBoxLayout* hLayout = new QHBoxLayout(this); 137 hLayout->setContentsMargins(0, 0, 0, 0); 138 139 m_list = new QListWidget(this); 140 populateList(); 141 142 hLayout->addSpacing(gMaemoListPadding); 143 hLayout->addWidget(m_list); 144 hLayout->addSpacing(gMaemoListPadding); 145 146 connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(accept())); 147 148 const int visibleItemCount = (m_list->count() > gMaemoMaxVisibleItems) ? gMaemoMaxVisibleItems : m_list->count(); 149 resize(size().width(), visibleItemCount * gMaemoListItemSize); 150 } 151 152 153 class MultipleItemListDelegate : public QStyledItemDelegate { 154 public: 155 MultipleItemListDelegate(QObject* parent = 0) 156 : QStyledItemDelegate(parent) 157 { 158 tickMark = QIcon::fromTheme("widgets_tickmark_list").pixmap(48, 48); 159 } 160 161 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const 162 { 163 QStyledItemDelegate::paint(painter, option, index); 164 165 if (option.state & QStyle::State_Selected) 166 painter->drawPixmap(option.rect.width() - tickMark.rect().width(), option.rect.y() + (option.rect.height() / 2 - tickMark.rect().height() / 2), tickMark); 167 } 168 169 private: 170 QPixmap tickMark; 171 }; 172 173 Maemo5MultipleSelectionPopup::Maemo5MultipleSelectionPopup(QtAbstractWebPopup& data) 174 : Maemo5Popup(data) 175 { 176 // we try to get the standard list title the web browser is using 177 const char* title = ::dgettext("osso-browser-ui", "weba_ti_textlist_multi"); 178 if (qstrcmp(title, "weba_ti_textlist_multi")) 179 setWindowTitle(QString::fromUtf8(title)); 180 else 181 setWindowTitle("Select items"); 182 183 QHBoxLayout* hLayout = new QHBoxLayout(this); 184 hLayout->setContentsMargins(0, 0, 0, 0); 185 186 m_list = new QListWidget(this); 187 m_list->setSelectionMode(QAbstractItemView::MultiSelection); 188 populateList(); 189 190 MultipleItemListDelegate* delegate = new MultipleItemListDelegate(this); 191 m_list->setItemDelegate(delegate); 192 193 hLayout->addSpacing(gMaemoListPadding); 194 hLayout->addWidget(m_list); 195 196 QVBoxLayout* vLayout = new QVBoxLayout(); 197 198 const int visibleItemCount = (m_list->count() > gMaemoMaxVisibleItems) ? gMaemoMaxVisibleItems : m_list->count(); 199 vLayout->addSpacing((visibleItemCount - 1) * gMaemoListItemSize); 200 201 // we try to get the standard Done button title 202 QPushButton* done = new QPushButton(this); 203 title = ::dgettext("hildon-libs", "wdgt_bd_done"); 204 if (qstrcmp(title, "wdgt_bd_done")) 205 done->setText(QString::fromUtf8(title)); 206 else 207 done->setText("Done"); 208 209 done->setMinimumWidth(178); 210 vLayout->addWidget(done); 211 212 hLayout->addSpacing(8); 213 hLayout->addLayout(vLayout); 214 hLayout->addSpacing(18); 215 216 connect(done, SIGNAL(clicked()), this, SLOT(accept())); 217 resize(size().width(), visibleItemCount * gMaemoListItemSize); 218 } 219 220 } -
trunk/WebKit/qt/WebCoreSupport/QtMaemoWebPopup.h
r56784 r56929 25 25 #include <QDialog> 26 26 27 class QListWidgetItem; 28 class QListWidget; 29 30 27 31 namespace WebCore { 28 32 … … 35 39 void itemClicked(int idx); 36 40 41 protected slots: 42 void onItemSelected(QListWidgetItem* item); 43 37 44 protected: 45 void populateList(); 46 38 47 QtAbstractWebPopup& m_data; 48 QListWidget* m_list; 39 49 }; 50 40 51 41 52 class QtMaemoWebPopup : public QObject, public QtAbstractWebPopup { … … 60 71 }; 61 72 73 74 class Maemo5SingleSelectionPopup : public Maemo5Popup { 75 Q_OBJECT 76 public: 77 Maemo5SingleSelectionPopup(QtAbstractWebPopup& data); 78 }; 79 80 81 class Maemo5MultipleSelectionPopup : public Maemo5Popup { 82 Q_OBJECT 83 public: 84 Maemo5MultipleSelectionPopup(QtAbstractWebPopup& data); 85 }; 86 62 87 } 63 88
Note: See TracChangeset
for help on using the changeset viewer.