Ticket #9301: mythbrowser.patch
| File mythbrowser.patch, 6.0 KB (added by , 16 years ago) |
|---|
-
mythplugins/mythbrowser/mythbrowser/bookmarkmanager.cpp
19 19 #include "bookmarkeditor.h" 20 20 #include "browserdbutil.h" 21 21 #include "mythbrowser.h" 22 #include "mythflashplayer.h" 22 23 23 24 // --------------------------------------------------- 24 25 … … 381 382 { 382 383 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 383 384 384 MythBrowser *mythbrowser = new MythBrowser(mainStack, urls, zoom.toFloat()); 385 MythScreenType *mythbrowser; 386 if (urls[0].startsWith("mythflash://")) 387 mythbrowser = new MythFlashPlayer(mainStack, urls); 388 else 389 mythbrowser = new MythBrowser(mainStack, urls, zoom.toFloat()); 385 390 386 391 if (mythbrowser->Create()) 387 392 { -
mythplugins/mythbrowser/mythbrowser/mythflashplayer.h
1 #ifndef MYTHFLASHPLAYER_H 2 #define MYTHFLASHPLAYER_H 3 4 #include <mythscreentype.h> 5 6 class MythUIWebBrowser; 7 8 class MythFlashPlayer : public MythScreenType 9 { 10 Q_OBJECT 11 12 public: 13 MythFlashPlayer(MythScreenStack *parent, QStringList &urlList); 14 ~MythFlashPlayer(); 15 16 bool Create(void); 17 bool keyPressEvent(QKeyEvent *); 18 19 private: 20 QVariant evaluateJavaScript(const QString&); 21 MythUIWebBrowser* m_browser; 22 QString m_url; 23 }; 24 25 #endif -
mythplugins/mythbrowser/mythbrowser/mythbrowser.pro
16 16 INSTALLS += installimages 17 17 18 18 # Input 19 HEADERS += mythbrowser.h webpage.h19 HEADERS += mythbrowser.h mythflashplayer.h webpage.h 20 20 HEADERS += bookmarkmanager.h bookmarkeditor.h browserdbutil.h 21 SOURCES += main.cpp mythbrowser.cpp webpage.cpp21 SOURCES += main.cpp mythbrowser.cpp mythflashplayer.cpp webpage.cpp 22 22 SOURCES += bookmarkmanager.cpp bookmarkeditor.cpp browserdbutil.cpp 23 23 24 24 include ( ../../libs-targetfix.pro ) -
mythplugins/mythbrowser/mythbrowser/main.cpp
15 15 #include "bookmarkmanager.h" 16 16 #include "browserdbutil.h" 17 17 #include "mythbrowser.h" 18 #include "mythflashplayer.h" 18 19 19 20 using namespace std; 20 21 … … 30 31 float zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.4").toFloat(); 31 32 32 33 MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); 34 MythScreenType *mythbrowser; 35 if (urls[0].startsWith("mythflash://")) 36 mythbrowser = new MythFlashPlayer(mainStack, urls); 37 else 38 mythbrowser = new MythBrowser(mainStack, urls, zoom); 33 39 34 MythBrowser *mythbrowser = new MythBrowser(mainStack, urls, zoom);35 36 40 if (mythbrowser->Create()) 37 41 mainStack->AddScreen(mythbrowser); 38 42 else -
mythplugins/mythbrowser/mythbrowser/mythflashplayer.cpp
1 #include <stdlib.h> 2 #include <iostream> 3 4 // qt 5 #include <QApplication> 6 #include <QEvent> 7 8 // myth 9 #include <mythverbose.h> 10 #include <mythcontext.h> 11 #include <libmythui/mythmainwindow.h> 12 #include <mythuiwebbrowser.h> 13 14 // mythbrowser 15 #include "webpage.h" 16 #include "mythflashplayer.h" 17 18 using namespace std; 19 20 MythFlashPlayer::MythFlashPlayer(MythScreenStack *parent, 21 QStringList &urlList) 22 : MythScreenType (parent, "mythflashplayer"), 23 m_browser(NULL), m_url(urlList[0]) 24 { 25 qApp->setOverrideCursor(QCursor(Qt::BlankCursor)); 26 } 27 28 29 MythFlashPlayer::~MythFlashPlayer() 30 { 31 qApp->restoreOverrideCursor(); 32 33 if (m_browser) 34 { 35 m_browser->disconnect(); 36 DeleteChild(m_browser); 37 m_browser = NULL; 38 } 39 } 40 41 bool MythFlashPlayer::Create(void) 42 { 43 m_browser = new MythUIWebBrowser(this, "mythflashplayer"); 44 m_browser->SetArea(GetMythMainWindow()->GetUIScreenRect()); 45 m_browser->Init(); 46 m_browser->SetActive(true); 47 m_browser->Show(); 48 49 BuildFocusList(); 50 51 SetFocusWidget(m_browser); 52 53 m_url.replace("mythflash://", "http://"); 54 VERBOSE(VB_GENERAL, QString("Opening %1").arg(m_url)); 55 m_browser->LoadPage(QUrl::fromEncoded(m_url.toLocal8Bit())); 56 57 return true; 58 } 59 60 QVariant MythFlashPlayer::evaluateJavaScript(const QString& source) 61 { 62 return m_browser->evaluateJavaScript(source); 63 } 64 65 bool MythFlashPlayer::keyPressEvent(QKeyEvent *event) 66 { 67 QStringList actions; 68 bool handled = GetMythMainWindow()->TranslateKeyPress("TV Playback", event, actions); 69 70 for (int i = 0; i < actions.size() && !handled; i++) 71 { 72 QString action = actions[i]; 73 handled = true; 74 75 if (action == "PAUSE") 76 evaluateJavaScript("play();"); 77 else if (action == "SEEKFFWD") 78 evaluateJavaScript("seek(10);"); 79 else if (action == "SEEKRWND") 80 evaluateJavaScript("seek(-10);"); 81 else if (action == "CHANNELUP") 82 evaluateJavaScript("seek(60);"); 83 else if (action == "CHANNELDOWN") 84 evaluateJavaScript("seek(-60);"); 85 else 86 handled = false; 87 88 if (handled) 89 return true; 90 } 91 92 handled = m_browser->keyPressEvent(event); 93 94 if (!handled && MythScreenType::keyPressEvent(event)) 95 handled = true; 96 97 return handled; 98 }
