UBApplicationController.h 4.97 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1
/*
Craig Watson's avatar
Craig Watson committed
2 3
 * Copyright (C) 2015-2016 Département de l'Instruction Publique (DIP-SEM)
 *
Claudio Valerio's avatar
Claudio Valerio committed
4
 * Copyright (C) 2013 Open Education Foundation
Claudio Valerio's avatar
Claudio Valerio committed
5
 *
Claudio Valerio's avatar
Claudio Valerio committed
6 7
 * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour
 * l'Education Numérique en Afrique (GIP ENA)
8
 *
Claudio Valerio's avatar
Claudio Valerio committed
9 10 11
 * This file is part of OpenBoard.
 *
 * OpenBoard is free software: you can redistribute it and/or modify
Claudio Valerio's avatar
Claudio Valerio committed
12 13
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License,
14 15 16 17
 * with a specific linking exception for the OpenSSL project's
 * "OpenSSL" library (or with modified versions of it that use the
 * same license as the "OpenSSL" library).
 *
Claudio Valerio's avatar
Claudio Valerio committed
18
 * OpenBoard is distributed in the hope that it will be useful,
Claudio Valerio's avatar
Claudio Valerio committed
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Claudio Valerio's avatar
Claudio Valerio committed
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Claudio Valerio's avatar
Claudio Valerio committed
21
 * GNU General Public License for more details.
Claudio Valerio's avatar
Claudio Valerio committed
22
 *
Claudio Valerio's avatar
Claudio Valerio committed
23
 * You should have received a copy of the GNU General Public License
Claudio Valerio's avatar
Claudio Valerio committed
24
 * along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
Claudio Valerio's avatar
Claudio Valerio committed
25
 */
Claudio Valerio's avatar
Claudio Valerio committed
26

27

Claudio Valerio's avatar
Claudio Valerio committed
28

Claudio Valerio's avatar
Claudio Valerio committed
29

Claudio Valerio's avatar
Claudio Valerio committed
30 31 32
#ifndef UBAPPLICATIONCONTROLLER_H_
#define UBAPPLICATIONCONTROLLER_H_

33
#include <QtWidgets>
Claudio Valerio's avatar
Claudio Valerio committed
34

agriche's avatar
agriche committed
35 36 37 38 39 40 41 42 43 44

#include <QtNetwork>
#include <QNetworkAccessManager>


#include <QtNetwork/QHttpPart>
#include <QScriptValue>
#include <QScriptEngine>


Claudio Valerio's avatar
Claudio Valerio committed
45 46 47 48 49 50 51 52 53 54 55
class UBBoardView;
class UBDocumentProxy;
class UBGraphicsScene;
class UBDesktopAnnotationController;
class UBScreenMirror;
class UBMainWindow;
class UBDisplayManager;
class UBVersion;
class UBSoftwareUpdate;
class QNetworkAccessManager;
class QNetworkReply;
Anatoly Mihalchenko's avatar
Anatoly Mihalchenko committed
56
class UBRightPalette;
57
class UBOpenSankoreImporter;
58

Claudio Valerio's avatar
Claudio Valerio committed
59 60
class UBApplicationController : public QObject
{
61
    Q_OBJECT
Claudio Valerio's avatar
Claudio Valerio committed
62 63 64

    public:

Anatoly Mihalchenko's avatar
Anatoly Mihalchenko committed
65
        UBApplicationController(UBBoardView *pControlView, UBBoardView *pDisplayView, UBMainWindow *pMainWindow, QObject* parent, UBRightPalette* rightPalette);
Claudio Valerio's avatar
Claudio Valerio committed
66 67 68 69 70 71 72 73 74 75 76
        virtual ~UBApplicationController();

        int initialHScroll() { return mInitialHScroll; }
        int initialVScroll() { return mInitialVScroll; }

        void adaptToolBar();
        void adjustDisplayView();
        void adjustPreviousViews(int pActiveSceneIndex, UBDocumentProxy *pActiveDocument);

        void blackout();

shibakaneki's avatar
shibakaneki committed
77
        void initScreenLayout(bool useMultiscreen);
Claudio Valerio's avatar
Claudio Valerio committed
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108

        void closing();

        void setMirrorSourceWidget(QWidget*);

        void mirroringEnabled(bool);

        void initViewState(int horizontalPosition, int verticalPosition);

        void showBoard();

        void showInternet();

        void showDocument();

        void showMessage(const QString& message, bool showSpinningWheel);

        void importFile(const QString& pFilePath);

        UBDisplayManager* displayManager()
        {
            return mDisplayManager;
        }

        UBDesktopAnnotationController* uninotesController()
        {
            return mUninoteController;
        }

        enum MainMode
        {
109
            Board = 0, Internet, Document, WebDocument
Claudio Valerio's avatar
Claudio Valerio committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
        };

        MainMode displayMode()
        {
            return mMainMode;
        }

        bool isCheckingForSoftwareUpdate() const;

        bool isShowingDesktop()
        {
            return mIsShowingDesktop;
        }

        QStringList widgetInlineJavaScripts();

    signals:
        void mainModeChanged(UBApplicationController::MainMode pMode);
        void desktopMode(bool displayed);

    public slots:

        /**
         * Add the pPixmap to the current scene and reactivate the board.
         * This Slot is connected with uninotes to manage the transition between board and uninotes.
         */
        void addCapturedPixmap(const QPixmap &pPixmap, bool pageMode, const QUrl& sourceUrl = QUrl());

        void addCapturedEmbedCode(const QString& embedCode);

        void screenLayoutChanged();

        // defaulting to false to match QAction triggered(bool checked = false)
        void showDesktop(bool dontSwitchFrontProcess = false);

        void hideDesktop();

        void useMultiScreen(bool use);

        void actionCut();
        void actionCopy();
        void actionPaste();

        void checkUpdateRequest();
Claudio Valerio's avatar
Claudio Valerio committed
154
        void checkAtLaunch();
155 156

    private slots:
157 158
        void updateRequestFinished(QNetworkReply * reply);

Claudio Valerio's avatar
Claudio Valerio committed
159 160 161 162 163 164 165

    protected:

        UBDesktopAnnotationController *mUninoteController;

        UBMainWindow *mMainWindow;

166 167
        UBOpenSankoreImporter *mOpenSankoreImporter;

Claudio Valerio's avatar
Claudio Valerio committed
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
        UBBoardView *mControlView;
        UBBoardView *mDisplayView;
        QList<UBBoardView*> mPreviousViews;

        UBGraphicsScene *mBlackScene;

        UBScreenMirror* mMirror;

        int mInitialHScroll, mInitialVScroll;

    private:

        MainMode mMainMode;

        UBDisplayManager *mDisplayManager;

        bool mAutomaticCheckForUpdates;
        bool mCheckingForUpdates;

        void setCheckingForUpdates(bool value);

        bool mIsShowingDesktop;

        bool isNoUpdateDisplayed;
192 193
        void checkUpdate(const QUrl &url = QUrl());
        QNetworkAccessManager * mNetworkAccessManager;
194 195

        void downloadJsonFinished(QString updateString);
Claudio Valerio's avatar
Claudio Valerio committed
196 197 198
};

#endif /* UBAPPLICATIONCONTROLLER_H_ */