15af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke/* 25af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 35af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * 45af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * This library is free software; you can redistribute it and/or 55af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * modify it under the terms of the GNU Library General Public 65af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * License as published by the Free Software Foundation; either 75af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * version 2 of the License, or (at your option) any later version. 85af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * 95af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * This library is distributed in the hope that it will be useful, 105af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * but WITHOUT ANY WARRANTY; without even the implied warranty of 115af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 125af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * Library General Public License for more details. 135af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * 145af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * You should have received a copy of the GNU Library General Public License 155af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * along with this library; see the file COPYING.LIB. If not, write to 165af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 175af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * Boston, MA 02110-1301, USA. 185af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke * 195af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke */ 205af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include "WebPlugin.h" 215af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 2265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include <QEvent> 235af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QHBoxLayout> 2465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#include <QKeyEvent> 255af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QListWidget> 265af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QListWidgetItem> 275af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QPainter> 285af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QtPlugin> 295af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QPushButton> 305af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QStyledItemDelegate> 315af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke#include <QVBoxLayout> 325af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 335af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkestatic const int gMaemoListItemSize = 70; 345af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkestatic const int gMaemoListPadding = 38; 355af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkestatic const int gMaemoMaxVisibleItems = 5; 365af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 375af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkevoid Popup::populateList() 385af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 395af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QListWidgetItem* listItem; 405af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke for (int i = 0; i < m_data.itemCount(); ++i) { 415af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (m_data.itemType(i) == QWebSelectData::Option) { 425af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke listItem = new QListWidgetItem(m_data.itemText(i)); 435af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_list->addItem(listItem); 445af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke listItem->setSelected(m_data.itemIsSelected(i)); 455af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke } else if (m_data.itemType(i) == QWebSelectData::Group) { 465af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke listItem = new QListWidgetItem(m_data.itemText(i)); 475af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_list->addItem(listItem); 485af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke listItem->setSelected(false); 495af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke listItem->setFlags(Qt::NoItemFlags); 505af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke } 515af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke } 525af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemSelected(QListWidgetItem*))); 535af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 545af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 555af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkevoid Popup::onItemSelected(QListWidgetItem* item) 565af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 575af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (item->flags() != Qt::NoItemFlags) 585af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke emit itemClicked(m_list->row(item)); 595af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 605af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 615af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkeWebPopup::WebPopup() 625af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke : m_popup(0) 635af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 645af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 655af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 665af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkeWebPopup::~WebPopup() 675af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 685af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (m_popup) 695af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_popup->deleteLater(); 705af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 715af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 725af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkePopup* WebPopup::createSingleSelectionPopup(const QWebSelectData& data) 735af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 745af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke return new SingleSelectionPopup(data); 755af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 765af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 775af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkePopup* WebPopup::createMultipleSelectionPopup(const QWebSelectData& data) 785af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 795af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke return new MultipleSelectionPopup(data); 805af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 815af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 825af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkePopup* WebPopup::createPopup(const QWebSelectData& data) 835af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 845af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke Popup* result = data.multiple() ? createMultipleSelectionPopup(data) : createSingleSelectionPopup(data); 855af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke connect(result, SIGNAL(finished(int)), this, SLOT(popupClosed())); 865af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke connect(result, SIGNAL(itemClicked(int)), this, SLOT(itemClicked(int))); 875af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke return result; 885af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 895af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 905af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkevoid WebPopup::show(const QWebSelectData& data) 915af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 925af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (m_popup) 935af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke return; 945af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 955af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_popup = createPopup(data); 965af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_popup->show(); 975af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 985af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 995af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkevoid WebPopup::hide() 1005af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 1015af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (!m_popup) 1025af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke return; 1035af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1045af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_popup->accept(); 1055af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 1065af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1075af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkevoid WebPopup::popupClosed() 1085af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 1095af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (!m_popup) 1105af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke return; 1115af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1125af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_popup->deleteLater(); 1135af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_popup = 0; 1145af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke emit didHide(); 1155af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 1165af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1175af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkevoid WebPopup::itemClicked(int idx) 1185af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 1195af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke emit selectItem(idx, true, false); 1205af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 1215af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1225af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkeSingleSelectionPopup::SingleSelectionPopup(const QWebSelectData& data) 1235af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke : Popup(data) 1245af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 1255af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke const char* title = "select"; 1265af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (qstrcmp(title, "weba_ti_texlist_single")) 1275af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke setWindowTitle(QString::fromUtf8(title)); 1285af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke else 1295af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke setWindowTitle("Select item"); 1305af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1315af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QHBoxLayout* hLayout = new QHBoxLayout(this); 1325af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->setContentsMargins(0, 0, 0, 0); 1335af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1345af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_list = new QListWidget(this); 1355af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke populateList(); 1365af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1375af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addSpacing(gMaemoListPadding); 1385af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addWidget(m_list); 1395af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addSpacing(gMaemoListPadding); 1405af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1415af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(accept())); 1425af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1435af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke const int visibleItemCount = (m_list->count() > gMaemoMaxVisibleItems) ? gMaemoMaxVisibleItems : m_list->count(); 1445af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke resize(size().width(), visibleItemCount * gMaemoListItemSize); 1455af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 1465af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1475af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1485af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkeclass MultipleItemListDelegate : public QStyledItemDelegate { 1495af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkepublic: 1505af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke MultipleItemListDelegate(QObject* parent = 0) 1515af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke : QStyledItemDelegate(parent) 1525af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke { 1535af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke tickMark = QIcon::fromTheme("widgets_tickmark_list").pixmap(48, 48); 1545af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke } 1555af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1565af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const 1575af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke { 1585af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QStyledItemDelegate::paint(painter, option, index); 1595af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1605af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (option.state & QStyle::State_Selected) 1615af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke painter->drawPixmap(option.rect.width() - tickMark.rect().width(), option.rect.y() + (option.rect.height() / 2 - tickMark.rect().height() / 2), tickMark); 1625af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke } 1635af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1645af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkeprivate: 1655af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QPixmap tickMark; 1665af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke}; 1675af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1685af96e2c7b73ebc627c6894727826a7576d31758Leon ClarkeMultipleSelectionPopup::MultipleSelectionPopup(const QWebSelectData& data) 1695af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke : Popup(data) 1705af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 1715af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke const char* title = "select"; 1725af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (qstrcmp(title, "weba_ti_textlist_multi")) 1735af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke setWindowTitle(QString::fromUtf8(title)); 1745af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke else 1755af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke setWindowTitle("Select items"); 1765af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1775af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QHBoxLayout* hLayout = new QHBoxLayout(this); 1785af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->setContentsMargins(0, 0, 0, 0); 1795af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1805af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_list = new QListWidget(this); 1815af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_list->setSelectionMode(QAbstractItemView::MultiSelection); 1825af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke populateList(); 1835af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1845af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke MultipleItemListDelegate* delegate = new MultipleItemListDelegate(this); 1855af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke m_list->setItemDelegate(delegate); 1865af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1875af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addSpacing(gMaemoListPadding); 1885af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addWidget(m_list); 1895af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1905af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QVBoxLayout* vLayout = new QVBoxLayout(); 1915af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1925af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke const int visibleItemCount = (m_list->count() > gMaemoMaxVisibleItems) ? gMaemoMaxVisibleItems : m_list->count(); 1935af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke vLayout->addSpacing((visibleItemCount - 1) * gMaemoListItemSize); 1945af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 1955af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke QPushButton* done = new QPushButton(this); 1965af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke title = "done"; 1975af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke if (qstrcmp(title, "wdgt_bd_done")) 1985af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke done->setText(QString::fromUtf8(title)); 1995af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke else 2005af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke done->setText("Done"); 2015af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 2025af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke done->setMinimumWidth(178); 2035af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke vLayout->addWidget(done); 2045af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 2055af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addSpacing(8); 2065af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addLayout(vLayout); 2075af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke hLayout->addSpacing(18); 2085af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 2095af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke connect(done, SIGNAL(clicked()), this, SLOT(accept())); 2105af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke resize(size().width(), visibleItemCount * gMaemoListItemSize); 2115af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 2125af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 2132daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA 21465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben MurdochFullScreenVideoWidget::FullScreenVideoWidget(QMediaPlayer* player) 21565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch : QVideoWidget() 21665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch , m_mediaPlayer(player) 21765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 21865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch Q_ASSERT(m_mediaPlayer); 21965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 22065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch setFullScreen(true); 22165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaPlayer->setVideoOutput(this); 22265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 22365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 22465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochbool FullScreenVideoWidget::event(QEvent* ev) 22565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 22665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch if (ev->type() == QEvent::MouseButtonDblClick) { 22765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch emit fullScreenClosed(); 22865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch ev->accept(); 22965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return true; 23065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch } 23165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return QWidget::event(ev); 23265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 23365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 23465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochvoid FullScreenVideoWidget::keyPressEvent(QKeyEvent* ev) 23565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 23665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch if (ev->key() == Qt::Key_Space) { 23765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch if (m_mediaPlayer->state() == QMediaPlayer::PlayingState) 23865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaPlayer->pause(); 23965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch else 24065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaPlayer->play(); 24165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch ev->accept(); 24265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return; 24365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch } 24465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 24565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 24665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben MurdochFullScreenVideoHandler::FullScreenVideoHandler() 24765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch : m_mediaWidget(0) 24865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 24965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 25065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 25165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben MurdochFullScreenVideoHandler::~FullScreenVideoHandler() 25265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 25365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch delete m_mediaWidget; 25465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 25565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 25665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochbool FullScreenVideoHandler::requiresFullScreenForVideoPlayback() const 25765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 25865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return true; 25965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 26065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 26165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochvoid FullScreenVideoHandler::enterFullScreen(QMediaPlayer* player) 26265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 26365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch Q_ASSERT(player); 26465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 26565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaWidget = new FullScreenVideoWidget(player); 26665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch connect(m_mediaWidget, SIGNAL(fullScreenClosed()), this, SIGNAL(fullScreenClosed())); 26765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaWidget->showFullScreen(); 26865f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 26965f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 27065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochvoid FullScreenVideoHandler::exitFullScreen() 27165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch{ 27265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaWidget->hide(); 27365f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch delete m_mediaWidget; 27465f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch m_mediaWidget = 0; 27565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch} 27665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#endif 27765f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch 2785af96e2c7b73ebc627c6894727826a7576d31758Leon Clarkebool WebPlugin::supportsExtension(Extension extension) const 2795af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke{ 280bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen switch (extension) { 281bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen case MultipleSelections: 282545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch return true; 283545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch#if ENABLE_NOTIFICATIONS 284bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen case Notifications: 285545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch return true; 286bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#endif 28728040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu case TouchInteraction: 28828040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu return true; 2892daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA 29065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch case FullScreenVideoPlayer: 29165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return true; 29265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#endif 293bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen default: 294545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch return false; 295bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen } 296bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen} 297bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen 298bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian MonsenQObject* WebPlugin::createExtension(Extension extension) const 299bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen{ 300bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen switch (extension) { 301bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen case MultipleSelections: 302bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen return new WebPopup(); 303bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#if ENABLE_NOTIFICATIONS 304bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen case Notifications: 305bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen return new WebNotificationPresenter(); 306545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch#endif 30728040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu case TouchInteraction: 30828040489d744e0c5d475a88663056c9040ed5320Teng-Hui Zhu return new TouchModifier(); 3092daae5fd11344eaa88a0d92b0f6d65f8d2255c00Ben Murdoch#if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA 31065f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch case FullScreenVideoPlayer: 31165f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch return new FullScreenVideoHandler(); 31265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch#endif 313bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen default: 314bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen return 0; 315bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen } 3165af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke} 3175af96e2c7b73ebc627c6894727826a7576d31758Leon Clarke 31806ea8e899e48f1f2f396b70e63fae369f2f23232Kristian MonsenQ_EXPORT_PLUGIN2(platformplugin, WebPlugin) 319