UBWebController.h 4.15 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1
/*
Claudio Valerio's avatar
Claudio Valerio committed
2 3
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
Claudio Valerio's avatar
Claudio Valerio committed
4
 * the Free Software Foundation, either version 2 of the License, or
Claudio Valerio's avatar
Claudio Valerio committed
5
 * (at your option) any later version.
Claudio Valerio's avatar
Claudio Valerio committed
6
 *
Claudio Valerio's avatar
Claudio Valerio committed
7 8 9 10 11 12 13
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Claudio Valerio's avatar
Claudio Valerio committed
14 15 16 17 18 19 20 21
 */

#ifndef UBWEBCONTROLLER_H_
#define UBWEBCONTROLLER_H_

#include <QtGui>
#include <QtWebKit>

22
#include "UBOEmbedParser.h"
Claudio Valerio's avatar
Claudio Valerio committed
23 24 25 26 27 28 29 30 31

class WBBrowserWindow;
class UBApplication;
class UBTrapFlashController;
class UBMainWindow;
class UBWebToolsPalette;
class WBWebView;
class UBServerXMLHttpRequest;

32

Claudio Valerio's avatar
Claudio Valerio committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
class UBWebController : public QObject
{
    Q_OBJECT;

    public:
        UBWebController(UBMainWindow* mainWindow);
        virtual ~UBWebController();
        void closing();
        void adaptToolBar();

        QPixmap captureCurrentPage();

        void showTabAtTop(bool attop);

        void loadUrl(const QUrl& url);

        QWebView* createNewTab();

        QUrl currentPageUrl() const;

        enum WebInstance
        {
            WebBrowser = 0, Tutorial, Paraschool, TotalNumberOfWebInstances
        };

        void show(WebInstance type = UBWebController::WebBrowser);

60 61 62 63 64 65
        WBBrowserWindow* GetCurrentWebBrowser() 
        { 
            if( mCurrentWebBrowser != NULL ) return *mCurrentWebBrowser; 
            else return NULL;
        };

Claudio Valerio's avatar
Claudio Valerio committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

    protected:
        void setupPalettes();
        QPixmap getScreenPixmap();

    public slots:

        void screenLayoutChanged();

        void setSourceWidget(QWidget* pWidget);
        void toggleWebToolsPalette(bool checked);
        void captureWindow();
        void customCapture();
        void toogleMirroring(bool checked);

        QWidget* controlView()
        {
            return mBrowserWidget;
        }

        void captureoEmbed();
        void captureEduMedia();

        bool isOEmbedable(const QUrl& pUrl);
90 91 92
        bool hasEmbeddedContent();
        void getEmbeddableContent();

Claudio Valerio's avatar
Claudio Valerio committed
93 94 95 96 97 98 99
        bool isEduMedia(const QUrl& pUrl);

        void copy();
        void paste();
        void cut();

    private:
100 101 102 103 104 105
        void initialiazemOEmbedProviders();
        void tutorialWebInstance();
        void webBrowserInstance();
        void paraschoolWebInstance();
        void lookForEmbedContent(QString* pHtml, QString tag, QString attribute, QList<QUrl>* pList);
        void checkForOEmbed(QString* pHtml);
Claudio Valerio's avatar
Claudio Valerio committed
106

107
        QStackedWidget mStackedWidget[TotalNumberOfWebInstances];
108

Claudio Valerio's avatar
Claudio Valerio committed
109
        UBMainWindow *mMainWindow;
110

Claudio Valerio's avatar
Claudio Valerio committed
111 112
        WBBrowserWindow* mWebBrowserList[TotalNumberOfWebInstances];
        WBBrowserWindow** mCurrentWebBrowser;
113

Claudio Valerio's avatar
Claudio Valerio committed
114 115 116 117
        QWidget* mBrowserWidget;
        UBTrapFlashController* mTrapFlashController;
        UBWebToolsPalette** mToolsCurrentPalette;
        UBWebToolsPalette* mToolsPaletteList[TotalNumberOfWebInstances];
118 119
// 		UBKeyboardPalette** mKeyboardCurrentPalette;
// 		UBKeyboardPalette* mKeyboardPaletteList[TotalNumberOfWebInstances];
120

Claudio Valerio's avatar
Claudio Valerio committed
121 122
        bool mToolsPalettePositionned;
        bool mToolsPalettePositionnedList[TotalNumberOfWebInstances];
123

Claudio Valerio's avatar
Claudio Valerio committed
124
        bool mDownloadViewIsVisible;
125

Claudio Valerio's avatar
Claudio Valerio committed
126
        QStringList mOEmbedProviders;
127

128
        UBOEmbedParser mOEmbedParser;
Claudio Valerio's avatar
Claudio Valerio committed
129 130 131 132 133 134


    private slots:

        void activePageChanged();
        void trapFlash();
135

Claudio Valerio's avatar
Claudio Valerio committed
136 137
        void toggleWebTrap(bool checked);

138
        void onOEmbedParsed(QVector<sOEmbedContent> contents);
139
//		void showKeyboard(bool checked);
140

Claudio Valerio's avatar
Claudio Valerio committed
141 142 143 144 145 146 147
    signals:
        /**
         * This signal is emitted once the screenshot has been performed. This signal is also emitted when user
         * click on go to uniboard button. In this case pCapturedPixmap is an empty pixmap.
         * @param pCapturedPixmap QPixmap corresponding to the capture.
         */
        void imageCaptured(const QPixmap& pCapturedPixmap, bool pageMode, const QUrl& source);
148

Claudio Valerio's avatar
Claudio Valerio committed
149 150 151 152 153
        void activeWebPageChanged(WBWebView* pWebView);

};

#endif /* UBWEBCONTROLLER_H_ */