1 /* 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 * 19 */ 20 #ifndef WEBPLUGIN_H 21 #define WEBPLUGIN_H 22 23 #include "qwebkitplatformplugin.h" 24 #include "WebNotificationPresenter.h" 25 26 #include <QDialog> 27 #if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA 28 #include <QVideoWidget> 29 #endif 30 31 class QListWidgetItem; 32 class QListWidget; 33 34 class Popup : public QDialog { 35 Q_OBJECT 36 public: Popup(const QWebSelectData & data)37 Popup(const QWebSelectData& data) : m_data(data) { setModal(true); } 38 39 signals: 40 void itemClicked(int idx); 41 42 protected slots: 43 void onItemSelected(QListWidgetItem* item); 44 45 protected: 46 void populateList(); 47 48 const QWebSelectData& m_data; 49 QListWidget* m_list; 50 }; 51 52 53 class SingleSelectionPopup : public Popup { 54 Q_OBJECT 55 public: 56 SingleSelectionPopup(const QWebSelectData& data); 57 }; 58 59 60 class MultipleSelectionPopup : public Popup { 61 Q_OBJECT 62 public: 63 MultipleSelectionPopup(const QWebSelectData& data); 64 }; 65 66 67 class WebPopup : public QWebSelectMethod { 68 Q_OBJECT 69 public: 70 WebPopup(); 71 ~WebPopup(); 72 73 virtual void show(const QWebSelectData& data); 74 virtual void hide(); 75 76 private slots: 77 void popupClosed(); 78 void itemClicked(int idx); 79 80 private: 81 Popup* m_popup; 82 83 Popup* createPopup(const QWebSelectData& data); 84 Popup* createSingleSelectionPopup(const QWebSelectData& data); 85 Popup* createMultipleSelectionPopup(const QWebSelectData& data); 86 }; 87 88 class TouchModifier : public QWebTouchModifier 89 { 90 Q_OBJECT 91 public: hitTestPaddingForTouch(const PaddingDirection direction)92 unsigned hitTestPaddingForTouch(const PaddingDirection direction) const { 93 // Use 10 as padding in each direction but Up. 94 if (direction == QWebTouchModifier::Up) 95 return 15; 96 return 10; 97 } 98 }; 99 100 #if defined(WTF_USE_QT_MULTIMEDIA) && WTF_USE_QT_MULTIMEDIA 101 class FullScreenVideoWidget : public QVideoWidget { 102 Q_OBJECT 103 public: 104 FullScreenVideoWidget(QMediaPlayer*); ~FullScreenVideoWidget()105 virtual ~FullScreenVideoWidget() {} 106 107 Q_SIGNALS: 108 void fullScreenClosed(); 109 110 protected: 111 bool event(QEvent*); 112 void keyPressEvent(QKeyEvent*); 113 114 private: 115 QMediaPlayer* m_mediaPlayer; // not owned 116 }; 117 118 class FullScreenVideoHandler : public QWebFullScreenVideoHandler { 119 Q_OBJECT 120 public: 121 FullScreenVideoHandler(); 122 virtual ~FullScreenVideoHandler(); 123 bool requiresFullScreenForVideoPlayback() const; 124 125 public Q_SLOTS: 126 void enterFullScreen(QMediaPlayer*); 127 void exitFullScreen(); 128 129 private: 130 FullScreenVideoWidget* m_mediaWidget; // owned 131 }; 132 #endif 133 134 class WebPlugin : public QObject, public QWebKitPlatformPlugin 135 { 136 Q_OBJECT 137 Q_INTERFACES(QWebKitPlatformPlugin) 138 public: 139 virtual bool supportsExtension(Extension extension) const; 140 virtual QObject* createExtension(Extension extension) const; 141 }; 142 143 #endif // WEBPLUGIN_H 144