UBBoardPaletteManager.h 5.2 KB
Newer Older
Claudio Valerio's avatar
Claudio Valerio committed
1
/*
Claudio Valerio's avatar
Claudio Valerio committed
2 3 4 5
 * 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
 * the Free Software Foundation, either version 3 of the License, or
 * (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 22
 */

#ifndef UBBOARDPALETTEMANAGER_H_
#define UBBOARDPALETTEMANAGER_H_

#include <QtGui>
#include <QtWebKit>

#include "web/UBRoutedMouseEventWebView.h"
23 24
#include "gui/UBLeftPalette.h"
#include "gui/UBRightPalette.h"
25 26 27
#include "gui/UBPageNavigationWidget.h"
#include "gui/UBLibWidget.h"
#include "gui/UBCachePropertiesWidget.h"
28
#include "gui/UBDockDownloadWidget.h"
29 30 31
#include "core/UBApplicationController.h"


Claudio Valerio's avatar
Claudio Valerio committed
32 33 34 35 36 37 38 39 40 41
class UBStylusPalette;
class UBClockPalette;
class UBPageNumberPalette;
class UBZoomPalette;
class UBActionPalette;
class UBBoardController;
class UBFloatingPalette;
class UBServerXMLHttpRequest;
class UBKeyboardPalette;
class UBMainWindow;
42
class UBApplicationController;
Claudio Valerio's avatar
Claudio Valerio committed
43 44 45

class UBBoardPaletteManager : public QObject
{
Anatoly Mihalchenko's avatar
Anatoly Mihalchenko committed
46
    Q_OBJECT
Claudio Valerio's avatar
Claudio Valerio committed
47 48 49 50 51 52

    public:
        UBBoardPaletteManager(QWidget* container, UBBoardController* controller);
        virtual ~UBBoardPaletteManager();

        void setupLayout();
53
        UBLeftPalette* leftPalette(){return mLeftPalette;}
54
        UBRightPalette* rightPalette(){return mRightPalette;}
55
        void showVirtualKeyboard(bool show = true);
56
        void initPalettesPosAtStartup();
57
        void connectToDocumentController();
shibakaneki's avatar
shibakaneki committed
58
        void refreshPalettes();
Claudio Valerio's avatar
Claudio Valerio committed
59

Anatoly Mihalchenko's avatar
Anatoly Mihalchenko committed
60
        UBKeyboardPalette *mKeyboardPalette;
61

62 63
        void processPalettersWidget(UBDockPalette *paletter, eUBDockPaletteWidgetMode mode);
        void changeMode(eUBDockPaletteWidgetMode newMode, bool isInit = false);
64 65
        void startDownloads();
        void stopDownloads();
66

67 68
    signals:
        void connectToDocController();
69
        void signal_changeMode(eUBDockPaletteWidgetMode newMode);
70

Claudio Valerio's avatar
Claudio Valerio committed
71 72 73 74 75 76 77
    public slots:

        void activeSceneChanged();
        void containerResized();
        void addItem(const QUrl& pUrl);
        void addItem(const QPixmap& pPixmap, const QPointF& p = QPointF(0.0, 0.0), qreal scale = 1.0, const QUrl& sourceUrl = QUrl());

78 79
        void slot_changeMainMode(UBApplicationController::MainMode);
        void slot_changeDesktopMode(bool);
80

Claudio Valerio's avatar
Claudio Valerio committed
81 82 83 84 85
    private:

        void setupPalettes();
        void connectPalettes();
        void positionFreeDisplayPalette();
86
        void setupDockPaletteWidgets();
Claudio Valerio's avatar
Claudio Valerio committed
87 88 89 90 91 92 93

        QWidget* mContainer;
        UBBoardController *mBoardControler;

        UBStylusPalette *mStylusPalette;

        UBZoomPalette *mZoomPalette;
94

95
        /** The left dock palette */
96
        UBLeftPalette* mLeftPalette;
97
        /** The right dock palette */
98
        UBRightPalette* mRightPalette;
Claudio Valerio's avatar
Claudio Valerio committed
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

        UBActionPalette *mBackgroundsPalette;
        UBActionPalette *mToolsPalette;
        UBActionPalette* mAddItemPalette;
        UBActionPalette* mErasePalette;
        UBActionPalette* mPagePalette;

        QUrl mItemUrl;
        QPixmap mPixmap;
        QPointF mPos;
        qreal mScaleFactor;

        QTime mPageButtonPressedTime;
        bool mPendingPageButtonPressed;

        QTime mZoomButtonPressedTime;
        bool mPendingZoomButtonPressed;

        QTime mPanButtonPressedTime;
        bool mPendingPanButtonPressed;

        QTime mEraseButtonPressedTime;
        bool mPendingEraseButtonPressed;

123 124 125 126 127 128
        /** The page navigator widget */
        UBPageNavigationWidget* mpPageNavigWidget;
        /** The library widget */
        UBLibWidget* mpLibWidget;
        /** The cache properties widget */
        UBCachePropertiesWidget* mpCachePropWidget;
Claudio Valerio's avatar
Claudio Valerio committed
129

130 131
        /** The download widget */
        UBDockDownloadWidget* mpDownloadWidget;
shibakaneki's avatar
shibakaneki committed
132 133 134 135
        // HACK: here we duplicate the lib widget for the desktop mode
        //       we MUST refactor the architecture in order to use only one
        //       lib widget!
        UBLibWidget* mpDesktopLibWidget;
136

137 138
        bool mDownloadInProgress;

Claudio Valerio's avatar
Claudio Valerio committed
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    private slots:

        void changeBackground();

        void toggleBackgroundPalette(bool checked);
        void backgroundPaletteClosed();

        void toggleStylusPalette(bool checked);
        void tooglePodcastPalette(bool checked);

        void erasePaletteButtonPressed();
        void erasePaletteButtonReleased();

        void toggleErasePalette(bool ckecked);
        void erasePaletteClosed();

        void togglePagePalette(bool ckecked);
        void pagePaletteClosed();

158
        void pagePaletteButtonPressed();
Claudio Valerio's avatar
Claudio Valerio committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
        void pagePaletteButtonReleased();

        void addItemToCurrentPage();
        void addItemToNewPage();
        void addItemToLibrary();

        void purchaseLinkActivated(const QString&);

        void linkClicked(const QUrl& url);

        void zoomButtonPressed();
        void zoomButtonReleased();
        void panButtonPressed();
        void panButtonReleased();

        void changeStylusPaletteOrientation(QVariant var);
};

#endif /* UBBOARDPALETTEMANAGER_H_ */