Claudio Valerio 13 years ago
parent 2b8dd1ba4d
commit 1ebc821ad1
  1. 162
      src/web/UBWebController.cpp
  2. 2
      src/web/UBWebController.h

@ -55,7 +55,7 @@ UBWebController::UBWebController(UBMainWindow* mainWindow)
, mBrowserWidget(0) , mBrowserWidget(0)
, mTrapFlashController(0) , mTrapFlashController(0)
, mToolsCurrentPalette(0) , mToolsCurrentPalette(0)
, mKeyboardCurrentPalette(0) , mKeyboardCurrentPalette(0)
, mToolsPalettePositionned(false) , mToolsPalettePositionned(false)
, mDownloadViewIsVisible(false) , mDownloadViewIsVisible(false)
@ -70,6 +70,8 @@ UBWebController::UBWebController(UBMainWindow* mainWindow)
mToolsPalettePositionnedList[i] = false; mToolsPalettePositionnedList[i] = false;
} }
initialiazemOEmbedProviders();
} }
@ -78,6 +80,26 @@ UBWebController::~UBWebController()
// NOOP // NOOP
} }
void UBWebController::initialiazemOEmbedProviders()
{
mOEmbedProviders << "5min.com";
mOEmbedProviders << "amazon.com";
mOEmbedProviders << "flickr";
mOEmbedProviders << "video.google.";
mOEmbedProviders << "hulu.com";
mOEmbedProviders << "imdb.com";
mOEmbedProviders << "metacafe.com";
mOEmbedProviders << "qik.com";
mOEmbedProviders << "slideshare";
mOEmbedProviders << "5min.com";
mOEmbedProviders << "twitpic.com";
mOEmbedProviders << "viddler.com";
mOEmbedProviders << "vimeo.com";
mOEmbedProviders << "wikipedia.org";
mOEmbedProviders << "wordpress.com";
mOEmbedProviders << "youtube.com";
}
void UBWebController::webBrowserInstance() void UBWebController::webBrowserInstance()
{ {
QString webHomePage = UBSettings::settings()->webHomePage->get().toString(); QString webHomePage = UBSettings::settings()->webHomePage->get().toString();
@ -91,7 +113,7 @@ void UBWebController::webBrowserInstance()
{ {
mCurrentWebBrowser = &mWebBrowserList[WebBrowser]; mCurrentWebBrowser = &mWebBrowserList[WebBrowser];
mToolsCurrentPalette = &mToolsPaletteList[WebBrowser]; mToolsCurrentPalette = &mToolsPaletteList[WebBrowser];
mKeyboardCurrentPalette = &mKeyboardPaletteList[WebBrowser]; mKeyboardCurrentPalette = &mKeyboardPaletteList[WebBrowser];
mToolsPalettePositionned = mToolsPalettePositionnedList[WebBrowser]; mToolsPalettePositionned = mToolsPalettePositionnedList[WebBrowser];
if (!(*mCurrentWebBrowser)) if (!(*mCurrentWebBrowser))
{ {
@ -102,7 +124,7 @@ void UBWebController::webBrowserInstance()
WBBrowserWindow::downloadManager()->setParent((*mCurrentWebBrowser), Qt::Tool); WBBrowserWindow::downloadManager()->setParent((*mCurrentWebBrowser), Qt::Tool);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->webToolBar, UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->webToolBar,
mMainWindow->actionBoard, 32); mMainWindow->actionBoard, 32);
UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu); UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu);
@ -124,23 +146,23 @@ void UBWebController::webBrowserInstance()
(*mCurrentWebBrowser)->tabWidget()->tabBar()->show(); (*mCurrentWebBrowser)->tabWidget()->tabBar()->show();
(*mCurrentWebBrowser)->tabWidget()->lineEdits()->show(); (*mCurrentWebBrowser)->tabWidget()->lineEdits()->show();
} }
UBApplication::applicationController->setMirrorSourceWidget((*mCurrentWebBrowser)->paintWidget()); UBApplication::applicationController->setMirrorSourceWidget((*mCurrentWebBrowser)->paintWidget());
mStackedWidget->setCurrentIndex(WebBrowser); mStackedWidget->setCurrentIndex(WebBrowser);
mMainWindow->switchToWebWidget(); mMainWindow->switchToWebWidget();
setupPalettes(); setupPalettes();
screenLayoutChanged(); screenLayoutChanged();
bool mirroring = UBSettings::settings()->webShowPageImmediatelyOnMirroredScreen->get().toBool(); bool mirroring = UBSettings::settings()->webShowPageImmediatelyOnMirroredScreen->get().toBool();
UBApplication::mainWindow->actionWebShowHideOnDisplay->setChecked(mirroring); UBApplication::mainWindow->actionWebShowHideOnDisplay->setChecked(mirroring);
(*mToolsCurrentPalette)->show(); (*mToolsCurrentPalette)->show();
} }
if (mDownloadViewIsVisible) if (mDownloadViewIsVisible)
WBBrowserWindow::downloadManager()->show(); WBBrowserWindow::downloadManager()->show();
} }
@ -169,7 +191,7 @@ void UBWebController::tutorialWebInstance()
{ {
mCurrentWebBrowser = &mWebBrowserList[Tutorial]; mCurrentWebBrowser = &mWebBrowserList[Tutorial];
mToolsCurrentPalette = &mToolsPaletteList[Tutorial]; mToolsCurrentPalette = &mToolsPaletteList[Tutorial];
mKeyboardCurrentPalette = &mKeyboardPaletteList[Tutorial]; mKeyboardCurrentPalette = &mKeyboardPaletteList[Tutorial];
mToolsPalettePositionned = &mToolsPalettePositionnedList[Tutorial]; mToolsPalettePositionned = &mToolsPalettePositionnedList[Tutorial];
if (!(*mCurrentWebBrowser)) if (!(*mCurrentWebBrowser))
{ {
@ -211,13 +233,13 @@ void UBWebController::paraschoolWebInstance()
QString language = "_" + locale.name().left(2); QString language = "_" + locale.name().left(2);
QString editorPath = "/etc/SankoreEditor/editor" + language + "/index.html"; QString editorPath = "/etc/SankoreEditor/editor" + language + "/index.html";
QString editorHtmlIndexFile; QString editorHtmlIndexFile;
#if defined(Q_WS_MAC) #if defined(Q_WS_MAC)
editorHtmlIndexFile = QApplication::applicationDirPath() + "/../Resources" + editorPath; editorHtmlIndexFile = QApplication::applicationDirPath() + "/../Resources" + editorPath;
#elif defined(Q_WS_WIN) #elif defined(Q_WS_WIN)
editorHtmlIndexFile = QApplication::applicationDirPath() + editorPath; editorHtmlIndexFile = QApplication::applicationDirPath() + editorPath;
#else #else
editorHtmlIndexFile = QApplication::applicationDirPath() + editorPath; editorHtmlIndexFile = QApplication::applicationDirPath() + editorPath;
#endif #endif
QUrl currentUrl = QUrl::fromLocalFile(editorHtmlIndexFile); QUrl currentUrl = QUrl::fromLocalFile(editorHtmlIndexFile);
@ -227,7 +249,7 @@ void UBWebController::paraschoolWebInstance()
else { else {
mCurrentWebBrowser = &mWebBrowserList[Paraschool]; mCurrentWebBrowser = &mWebBrowserList[Paraschool];
mToolsCurrentPalette = &mToolsPaletteList[Paraschool]; mToolsCurrentPalette = &mToolsPaletteList[Paraschool];
mKeyboardCurrentPalette = &mKeyboardPaletteList[Paraschool]; mKeyboardCurrentPalette = &mKeyboardPaletteList[Paraschool];
mToolsPalettePositionned = &mToolsPalettePositionnedList[Paraschool]; mToolsPalettePositionned = &mToolsPalettePositionnedList[Paraschool];
if (!(*mCurrentWebBrowser)){ if (!(*mCurrentWebBrowser)){
(*mCurrentWebBrowser) = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow, true); (*mCurrentWebBrowser) = new WBBrowserWindow(mMainWindow->centralWidget(), mMainWindow, true);
@ -263,17 +285,17 @@ void UBWebController::show(WebInstance type)
{ {
switch(type) switch(type)
{ {
case WebBrowser: case WebBrowser:
webBrowserInstance(); webBrowserInstance();
break; break;
case Tutorial: case Tutorial:
tutorialWebInstance(); tutorialWebInstance();
break; break;
case Paraschool: case Paraschool:
paraschoolWebInstance(); paraschoolWebInstance();
default: default:
qCritical() << __FILE__ << " non supported web instance type " << QString::number(type) ; qCritical() << __FILE__ << " non supported web instance type " << QString::number(type) ;
break; break;
} }
} }
@ -316,10 +338,10 @@ QPixmap UBWebController::captureCurrentPage()
QPixmap pix; QPixmap pix;
if (mCurrentWebBrowser if (mCurrentWebBrowser
&& (*mCurrentWebBrowser) && (*mCurrentWebBrowser)
&& (*mCurrentWebBrowser)->currentTabWebView() && (*mCurrentWebBrowser)->currentTabWebView()
&& (*mCurrentWebBrowser)->currentTabWebView()->page() && (*mCurrentWebBrowser)->currentTabWebView()->page()
&& (*mCurrentWebBrowser)->currentTabWebView()->page()->mainFrame()) && (*mCurrentWebBrowser)->currentTabWebView()->page()->mainFrame())
{ {
QWebFrame* frame = (*mCurrentWebBrowser)->currentTabWebView()->page()->mainFrame(); QWebFrame* frame = (*mCurrentWebBrowser)->currentTabWebView()->page()->mainFrame();
QSize size = frame->contentsSize(); QSize size = frame->contentsSize();
@ -365,49 +387,49 @@ QPixmap UBWebController::captureCurrentPage()
void UBWebController::setupPalettes() void UBWebController::setupPalettes()
{ {
if(!(*mToolsCurrentPalette)) if(!(*mToolsCurrentPalette))
{ {
(*mToolsCurrentPalette) = new UBWebToolsPalette((*mCurrentWebBrowser),false); (*mToolsCurrentPalette) = new UBWebToolsPalette((*mCurrentWebBrowser),false);
(*mKeyboardCurrentPalette) = UBKeyboardPalette::create(*mCurrentWebBrowser); (*mKeyboardCurrentPalette) = UBKeyboardPalette::create(*mCurrentWebBrowser);
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
if (*mKeyboardCurrentPalette) if (*mKeyboardCurrentPalette)
connect(*mKeyboardCurrentPalette, SIGNAL(closed()), *mKeyboardCurrentPalette, SLOT(onDeactivated())); connect(*mKeyboardCurrentPalette, SIGNAL(closed()), *mKeyboardCurrentPalette, SLOT(onDeactivated()));
#endif #endif
connect(mMainWindow->actionWebTrapFlash, SIGNAL(triggered()), this, SLOT(trapFlash())); connect(mMainWindow->actionWebTrapFlash, SIGNAL(triggered()), this, SLOT(trapFlash()));
connect(mMainWindow->actionWebCustomCapture, SIGNAL(triggered()), this, SLOT(customCapture())); connect(mMainWindow->actionWebCustomCapture, SIGNAL(triggered()), this, SLOT(customCapture()));
connect(mMainWindow->actionWebWindowCapture, SIGNAL(triggered()), this, SLOT(captureWindow())); connect(mMainWindow->actionWebWindowCapture, SIGNAL(triggered()), this, SLOT(captureWindow()));
connect(mMainWindow->actionWebOEmbed, SIGNAL(triggered()), this, SLOT(captureoEmbed())); connect(mMainWindow->actionWebOEmbed, SIGNAL(triggered()), this, SLOT(captureoEmbed()));
connect(mMainWindow->actionEduMedia, SIGNAL(triggered()), this, SLOT(captureEduMedia())); connect(mMainWindow->actionEduMedia, SIGNAL(triggered()), this, SLOT(captureEduMedia()));
connect(mMainWindow->actionWebShowHideOnDisplay, SIGNAL(toggled(bool)), this, SLOT(toogleMirroring(bool))); connect(mMainWindow->actionWebShowHideOnDisplay, SIGNAL(toggled(bool)), this, SLOT(toogleMirroring(bool)));
connect(mMainWindow->actionWebTrap, SIGNAL(toggled(bool)), this, SLOT(toggleWebTrap(bool))); connect(mMainWindow->actionWebTrap, SIGNAL(toggled(bool)), this, SLOT(toggleWebTrap(bool)));
connect(mMainWindow->actionVirtualKeyboard, SIGNAL(toggled(bool)), this, SLOT(showKeyboard(bool))); connect(mMainWindow->actionVirtualKeyboard, SIGNAL(toggled(bool)), this, SLOT(showKeyboard(bool)));
(*mToolsCurrentPalette)->hide(); (*mToolsCurrentPalette)->hide();
(*mToolsCurrentPalette)->adjustSizeAndPosition(); (*mToolsCurrentPalette)->adjustSizeAndPosition();
(*mKeyboardCurrentPalette)->adjustSizeAndPosition(); (*mKeyboardCurrentPalette)->adjustSizeAndPosition();
if (controlView()){ if (controlView()){
int left = controlView()->width() - 20 - (*mToolsCurrentPalette)->width(); int left = controlView()->width() - 20 - (*mToolsCurrentPalette)->width();
int top = (controlView()->height() - (*mToolsCurrentPalette)->height()) / 2; int top = (controlView()->height() - (*mToolsCurrentPalette)->height()) / 2;
mToolsPalettePositionnedList[mStackedWidget->currentIndex()] = true; mToolsPalettePositionnedList[mStackedWidget->currentIndex()] = true;
(*mToolsCurrentPalette)->setCustomPosition(true); (*mToolsCurrentPalette)->setCustomPosition(true);
(*mToolsCurrentPalette)->move(left, top); (*mToolsCurrentPalette)->move(left, top);
} }
mMainWindow->actionWebTools->trigger(); mMainWindow->actionWebTools->trigger();
} }
} }
void UBWebController::toggleWebTrap(bool checked) void UBWebController::toggleWebTrap(bool checked)
{ {
if (mCurrentWebBrowser if (mCurrentWebBrowser
&& (*mCurrentWebBrowser) && (*mCurrentWebBrowser)
&& (*mCurrentWebBrowser)->currentTabWebView()) && (*mCurrentWebBrowser)->currentTabWebView())
{ {
(*mCurrentWebBrowser)->currentTabWebView()->setIsTrapping(checked); (*mCurrentWebBrowser)->currentTabWebView()->setIsTrapping(checked);
} }
@ -415,10 +437,10 @@ void UBWebController::toggleWebTrap(bool checked)
void UBWebController::showKeyboard(bool checked) void UBWebController::showKeyboard(bool checked)
{ {
if (mKeyboardCurrentPalette if (mKeyboardCurrentPalette
&& (*mKeyboardCurrentPalette)) && (*mKeyboardCurrentPalette))
{ {
(*mKeyboardCurrentPalette)->setVisible(checked); (*mKeyboardCurrentPalette)->setVisible(checked);
} }
} }
@ -473,16 +495,16 @@ QPixmap UBWebController::getScreenPixmap()
QCoreApplication::flush (); QCoreApplication::flush ();
return QPixmap::grabWindow(desktop->winId(), return QPixmap::grabWindow(desktop->winId(),
primaryScreenRect.x(), primaryScreenRect.y(), primaryScreenRect.x(), primaryScreenRect.y(),
primaryScreenRect.width(), primaryScreenRect.height()); primaryScreenRect.width(), primaryScreenRect.height());
} }
void UBWebController::screenLayoutChanged() void UBWebController::screenLayoutChanged()
{ {
bool hasDisplay = (UBApplication::applicationController && bool hasDisplay = (UBApplication::applicationController &&
UBApplication::applicationController->displayManager() && UBApplication::applicationController->displayManager() &&
UBApplication::applicationController->displayManager()->hasDisplay()); UBApplication::applicationController->displayManager()->hasDisplay());
UBApplication::mainWindow->actionWebShowHideOnDisplay->setVisible(hasDisplay); UBApplication::mainWindow->actionWebShowHideOnDisplay->setVisible(hasDisplay);
} }
@ -516,7 +538,7 @@ void UBWebController::showTabAtTop(bool attop)
void UBWebController::captureoEmbed() void UBWebController::captureoEmbed()
{ {
if ( mCurrentWebBrowser && (*mCurrentWebBrowser) if ( mCurrentWebBrowser && (*mCurrentWebBrowser)
&& (*mCurrentWebBrowser)->currentTabWebView()) && (*mCurrentWebBrowser)->currentTabWebView())
{ {
QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView();
QUrl currentUrl = webView->url(); QUrl currentUrl = webView->url();
@ -538,7 +560,7 @@ void UBWebController::captureoEmbed()
void UBWebController::captureEduMedia() void UBWebController::captureEduMedia()
{ {
if (mCurrentWebBrowser && (*mCurrentWebBrowser) if (mCurrentWebBrowser && (*mCurrentWebBrowser)
&& (*mCurrentWebBrowser)->currentTabWebView()) && (*mCurrentWebBrowser)->currentTabWebView())
{ {
QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView(); QWebView* webView = (*mCurrentWebBrowser)->currentTabWebView();
QUrl currentUrl = webView->url(); QUrl currentUrl = webView->url();

@ -111,7 +111,7 @@ class UBWebController : public QObject
QStringList mOEmbedProviders; QStringList mOEmbedProviders;
UBServerXMLHttpRequest* mGetOEmbedProviderListRequest; void initialiazemOEmbedProviders();
void tutorialWebInstance(); void tutorialWebInstance();
void webBrowserInstance(); void webBrowserInstance();

Loading…
Cancel
Save