preferencesAboutTextFull
parent
9fcd791c39
commit
bff3e8343d
File diff suppressed because it is too large
Load Diff
@ -1,285 +1,289 @@ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#ifndef UBBOARDCONTROLLER_H_ |
||||
#define UBBOARDCONTROLLER_H_ |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include <QObject> |
||||
|
||||
class UBMainWindow; |
||||
class UBApplication; |
||||
class UBBoardView; |
||||
|
||||
class UBDocumentController; |
||||
class UBMessageWindow; |
||||
class UBGraphicsScene; |
||||
class UBDocumentProxy; |
||||
class UBBlackoutWidget; |
||||
class UBToolWidget; |
||||
class UBVersion; |
||||
class UBSoftwareUpdate; |
||||
class UBSoftwareUpdateDialog; |
||||
class UBGraphicsVideoItem; |
||||
class UBGraphicsAudioItem; |
||||
class UBGraphicsWidgetItem; |
||||
class UBBoardPaletteManager; |
||||
|
||||
|
||||
class UBBoardController : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
UBBoardController(UBMainWindow *mainWindow); |
||||
virtual ~UBBoardController(); |
||||
|
||||
void init(); |
||||
void setupLayout(); |
||||
UBDocumentProxy* activeDocument() const; |
||||
UBGraphicsScene* activeScene() const; |
||||
int activeSceneIndex() const; |
||||
QSize displayViewport(); |
||||
QSize controlViewport(); |
||||
QRectF controlGeometry(); |
||||
void closing(); |
||||
|
||||
UBDocumentProxy* activeDocument() |
||||
{ |
||||
return mActiveDocument; |
||||
} |
||||
|
||||
QWidget* controlContainer() |
||||
{ |
||||
return mControlContainer; |
||||
} |
||||
|
||||
UBBoardView* controlView() |
||||
{ |
||||
return mControlView; |
||||
} |
||||
|
||||
UBBoardView* displayView() |
||||
{ |
||||
return mDisplayView; |
||||
} |
||||
|
||||
UBGraphicsScene* activeScene() |
||||
{ |
||||
return mActiveScene; |
||||
} |
||||
|
||||
void setPenColorOnDarkBackground(const QColor& pColor) |
||||
{ |
||||
if (mPenColorOnDarkBackground == pColor) |
||||
return; |
||||
|
||||
mPenColorOnDarkBackground = pColor; |
||||
emit penColorChanged(); |
||||
} |
||||
|
||||
void setPenColorOnLightBackground(const QColor& pColor) |
||||
{ |
||||
if (mPenColorOnLightBackground == pColor) |
||||
return; |
||||
|
||||
mPenColorOnLightBackground = pColor; |
||||
emit penColorChanged(); |
||||
} |
||||
|
||||
void setMarkerColorOnDarkBackground(const QColor& pColor) |
||||
{ |
||||
mMarkerColorOnDarkBackground = pColor; |
||||
} |
||||
|
||||
void setMarkerColorOnLightBackground(const QColor& pColor) |
||||
{ |
||||
mMarkerColorOnLightBackground = pColor; |
||||
} |
||||
|
||||
QColor penColorOnDarkBackground() |
||||
{ |
||||
return mPenColorOnDarkBackground; |
||||
} |
||||
|
||||
QColor penColorOnLightBackground() |
||||
{ |
||||
return mPenColorOnLightBackground; |
||||
} |
||||
|
||||
QColor markerColorOnDarkBackground() |
||||
{ |
||||
return mMarkerColorOnDarkBackground; |
||||
} |
||||
|
||||
QColor markerColorOnLightBackground() |
||||
{ |
||||
return mMarkerColorOnLightBackground; |
||||
} |
||||
|
||||
qreal systemScaleFactor() |
||||
{ |
||||
return mSystemScaleFactor; |
||||
} |
||||
qreal currentZoom(); |
||||
void persistCurrentScene(); |
||||
void showNewVersionAvailable(bool automatic, const UBVersion &installedVersion, const UBSoftwareUpdate &softwareUpdate); |
||||
void setBoxing(QRect displayRect); |
||||
void setToolbarTexts(); |
||||
static QUrl expandWidgetToTempDir(const QByteArray& pZipedData, const QString& pExtension = QString("wgt")); |
||||
// static QRect freeRectInGlobalPos() const {return ;}
|
||||
void setPageSize(QSize newSize); |
||||
UBBoardPaletteManager *paletteManager() |
||||
{ |
||||
return mPaletteManager; |
||||
} |
||||
|
||||
void notifyCache(bool visible); |
||||
void notifyPageChanged(); |
||||
void displayMetaData(QMap<QString, QString> metadatas); |
||||
|
||||
void ClearUndoStack(); |
||||
|
||||
|
||||
public slots: |
||||
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0); |
||||
void showDocumentsDialog(); |
||||
void showKeyboard(bool show); |
||||
void togglePodcast(bool checked); |
||||
void blackout(); |
||||
void addScene(); |
||||
void addScene(UBDocumentProxy* proxy, int sceneIndex, bool replaceActiveIfEmpty = false); |
||||
void addScene(UBGraphicsScene* scene, bool replaceActiveIfEmpty = false); |
||||
void duplicateScene(); |
||||
void importPage(); |
||||
void clearScene(); |
||||
void clearSceneItems(); |
||||
void clearSceneAnnotation(); |
||||
void zoomIn(QPointF scenePoint = QPointF(0,0)); |
||||
void zoomOut(QPointF scenePoint = QPointF(0,0)); |
||||
void zoomRestore(); |
||||
void centerRestore(); |
||||
void centerOn(QPointF scenePoint = QPointF(0,0)); |
||||
void zoom(const qreal ratio, QPointF scenePoint); |
||||
void handScroll(qreal dx, qreal dy); |
||||
void previousScene(); |
||||
void nextScene(); |
||||
void firstScene(); |
||||
void lastScene(); |
||||
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false); |
||||
void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false); |
||||
void changeBackground(bool isDark, bool isCrossed); |
||||
void setToolCursor(int tool); |
||||
void showMessage(const QString& message, bool showSpinningWheel); |
||||
void hideMessage(); |
||||
void setDisabled(bool disable); |
||||
void setColorIndex(int pColorIndex); |
||||
UBToolWidget* addTool(const QUrl& toolUrl, QPointF scenePos); |
||||
UBToolWidget* addTool(const QUrl& toolUrl); |
||||
void removeTool(UBToolWidget* toolWidget); |
||||
void hide(); |
||||
void show(); |
||||
void setWidePageSize(bool checked); |
||||
void setRegularPageSize(bool checked); |
||||
void stylusToolChanged(int tool); |
||||
void grabScene(const QRectF& pSceneRect); |
||||
void controlViewHidden(); |
||||
void controlViewShown(); |
||||
UBGraphicsVideoItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos); |
||||
UBGraphicsAudioItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos); |
||||
UBGraphicsWidgetItem *addW3cWidget(const QUrl& pUrl, const QPointF& pos); |
||||
|
||||
void cut(); |
||||
void copy(); |
||||
void paste(); |
||||
void processMimeData(const QMimeData* pMimeData, const QPointF& pPos); |
||||
void moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicWidget); |
||||
void moveToolWidgetToScene(UBToolWidget* toolWidget); |
||||
void addItem(); |
||||
|
||||
signals: |
||||
void activeSceneWillBePersisted(); |
||||
void activeSceneWillChange(); |
||||
void activeSceneChanged(); |
||||
void activeDocumentChanged(); |
||||
void zoomChanged(qreal pZoomFactor); |
||||
void systemScaleFactorChanged(qreal pSystemScaleFactor); |
||||
void penColorChanged(); |
||||
void controlViewportChanged(); |
||||
void backgroundChanged(); |
||||
void cacheEnabled(); |
||||
void cacheDisabled(); |
||||
void pageChanged(); |
||||
void setDocOnPageNavigator(UBDocumentProxy* doc); |
||||
void documentReorganized(int index); |
||||
void displayMetadata(QMap<QString, QString> metadata); |
||||
|
||||
protected: |
||||
void setupViews(); |
||||
void setupToolbar(); |
||||
void connectToolbar(); |
||||
void initToolbarTexts(); |
||||
void updateActionStates(); |
||||
void updateSystemScaleFactor(); |
||||
QString truncate(QString text, int maxWidth); |
||||
|
||||
protected slots: |
||||
void selectionChanged(); |
||||
void undoRedoStateChange(bool canUndo); |
||||
void documentSceneChanged(UBDocumentProxy* proxy, int pIndex); |
||||
|
||||
private: |
||||
void updatePageSizeState(); |
||||
void saveViewState(); |
||||
void adjustDisplayViews(); |
||||
|
||||
UBMainWindow *mMainWindow; |
||||
UBDocumentProxy* mActiveDocument; |
||||
UBGraphicsScene* mActiveScene; |
||||
int mActiveSceneIndex; |
||||
UBBoardPaletteManager *mPaletteManager; |
||||
UBSoftwareUpdateDialog *mSoftwareUpdateDialog; |
||||
UBMessageWindow *mMessageWindow; |
||||
UBBoardView *mControlView; |
||||
UBBoardView *mDisplayView; |
||||
QWidget *mControlContainer; |
||||
QHBoxLayout *mControlLayout; |
||||
qreal mZoomFactor; |
||||
bool mIsClosing; |
||||
QColor mPenColorOnDarkBackground; |
||||
QColor mPenColorOnLightBackground; |
||||
QColor mMarkerColorOnDarkBackground; |
||||
QColor mMarkerColorOnLightBackground; |
||||
QList<UBToolWidget*> mTools; |
||||
qreal mSystemScaleFactor; |
||||
bool mCleanupDone; |
||||
QMap<QAction*, QPair<QString, QString> > mActionTexts; |
||||
|
||||
private slots: |
||||
void stylusToolDoubleClicked(int tool); |
||||
void boardViewResized(QResizeEvent* event); |
||||
void documentWillBeDeleted(UBDocumentProxy* pProxy); |
||||
void updateBackgroundActionsState(bool isDark, bool isCrossed); |
||||
void updateBackgroundState(); |
||||
void colorPaletteChanged(); |
||||
void libraryDialogClosed(int ret); |
||||
void lastWindowClosed(); |
||||
void onDownloadModalFinished(); |
||||
|
||||
}; |
||||
|
||||
|
||||
#endif /* UBBOARDCONTROLLER_H_ */ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#ifndef UBBOARDCONTROLLER_H_ |
||||
#define UBBOARDCONTROLLER_H_ |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include <QObject> |
||||
|
||||
class UBMainWindow; |
||||
class UBApplication; |
||||
class UBBoardView; |
||||
|
||||
class UBDocumentController; |
||||
class UBMessageWindow; |
||||
class UBGraphicsScene; |
||||
class UBDocumentProxy; |
||||
class UBBlackoutWidget; |
||||
class UBToolWidget; |
||||
class UBVersion; |
||||
class UBSoftwareUpdate; |
||||
class UBSoftwareUpdateDialog; |
||||
class UBGraphicsVideoItem; |
||||
class UBGraphicsAudioItem; |
||||
class UBGraphicsWidgetItem; |
||||
class UBBoardPaletteManager; |
||||
|
||||
|
||||
class UBBoardController : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
UBBoardController(UBMainWindow *mainWindow); |
||||
virtual ~UBBoardController(); |
||||
|
||||
void init(); |
||||
void setupLayout(); |
||||
UBDocumentProxy* activeDocument() const; |
||||
UBGraphicsScene* activeScene() const; |
||||
int activeSceneIndex() const; |
||||
QSize displayViewport(); |
||||
QSize controlViewport(); |
||||
QRectF controlGeometry(); |
||||
void closing(); |
||||
|
||||
UBDocumentProxy* activeDocument() |
||||
{ |
||||
return mActiveDocument; |
||||
} |
||||
|
||||
QWidget* controlContainer() |
||||
{ |
||||
return mControlContainer; |
||||
} |
||||
|
||||
UBBoardView* controlView() |
||||
{ |
||||
return mControlView; |
||||
} |
||||
|
||||
UBBoardView* displayView() |
||||
{ |
||||
return mDisplayView; |
||||
} |
||||
|
||||
UBGraphicsScene* activeScene() |
||||
{ |
||||
return mActiveScene; |
||||
} |
||||
|
||||
void setPenColorOnDarkBackground(const QColor& pColor) |
||||
{ |
||||
if (mPenColorOnDarkBackground == pColor) |
||||
return; |
||||
|
||||
mPenColorOnDarkBackground = pColor; |
||||
emit penColorChanged(); |
||||
} |
||||
|
||||
void setPenColorOnLightBackground(const QColor& pColor) |
||||
{ |
||||
if (mPenColorOnLightBackground == pColor) |
||||
return; |
||||
|
||||
mPenColorOnLightBackground = pColor; |
||||
emit penColorChanged(); |
||||
} |
||||
|
||||
void setMarkerColorOnDarkBackground(const QColor& pColor) |
||||
{ |
||||
mMarkerColorOnDarkBackground = pColor; |
||||
} |
||||
|
||||
void setMarkerColorOnLightBackground(const QColor& pColor) |
||||
{ |
||||
mMarkerColorOnLightBackground = pColor; |
||||
} |
||||
|
||||
QColor penColorOnDarkBackground() |
||||
{ |
||||
return mPenColorOnDarkBackground; |
||||
} |
||||
|
||||
QColor penColorOnLightBackground() |
||||
{ |
||||
return mPenColorOnLightBackground; |
||||
} |
||||
|
||||
QColor markerColorOnDarkBackground() |
||||
{ |
||||
return mMarkerColorOnDarkBackground; |
||||
} |
||||
|
||||
QColor markerColorOnLightBackground() |
||||
{ |
||||
return mMarkerColorOnLightBackground; |
||||
} |
||||
|
||||
qreal systemScaleFactor() |
||||
{ |
||||
return mSystemScaleFactor; |
||||
} |
||||
qreal currentZoom(); |
||||
void persistCurrentScene(); |
||||
void showNewVersionAvailable(bool automatic, const UBVersion &installedVersion, const UBSoftwareUpdate &softwareUpdate); |
||||
void setBoxing(QRect displayRect); |
||||
void setToolbarTexts(); |
||||
static QUrl expandWidgetToTempDir(const QByteArray& pZipedData, const QString& pExtension = QString("wgt")); |
||||
// static QRect freeRectInGlobalPos() const {return ;}
|
||||
void setPageSize(QSize newSize); |
||||
UBBoardPaletteManager *paletteManager() |
||||
{ |
||||
return mPaletteManager; |
||||
} |
||||
|
||||
void notifyCache(bool visible); |
||||
void notifyPageChanged(); |
||||
void displayMetaData(QMap<QString, QString> metadatas); |
||||
|
||||
void ClearUndoStack(); |
||||
|
||||
public slots: |
||||
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0); |
||||
void showDocumentsDialog(); |
||||
void showKeyboard(bool show); |
||||
void togglePodcast(bool checked); |
||||
void blackout(); |
||||
void addScene(); |
||||
void addScene(UBDocumentProxy* proxy, int sceneIndex, bool replaceActiveIfEmpty = false); |
||||
void addScene(UBGraphicsScene* scene, bool replaceActiveIfEmpty = false); |
||||
void duplicateScene(); |
||||
void importPage(); |
||||
void clearScene(); |
||||
void clearSceneItems(); |
||||
void clearSceneAnnotation(); |
||||
void zoomIn(QPointF scenePoint = QPointF(0,0)); |
||||
void zoomOut(QPointF scenePoint = QPointF(0,0)); |
||||
void zoomRestore(); |
||||
void centerRestore(); |
||||
void centerOn(QPointF scenePoint = QPointF(0,0)); |
||||
void zoom(const qreal ratio, QPointF scenePoint); |
||||
void handScroll(qreal dx, qreal dy); |
||||
void previousScene(); |
||||
void nextScene(); |
||||
void firstScene(); |
||||
void lastScene(); |
||||
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false); |
||||
void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false); |
||||
void changeBackground(bool isDark, bool isCrossed); |
||||
void setToolCursor(int tool); |
||||
void showMessage(const QString& message, bool showSpinningWheel); |
||||
void hideMessage(); |
||||
void setDisabled(bool disable); |
||||
void setColorIndex(int pColorIndex); |
||||
UBToolWidget* addTool(const QUrl& toolUrl, QPointF scenePos); |
||||
UBToolWidget* addTool(const QUrl& toolUrl); |
||||
void removeTool(UBToolWidget* toolWidget); |
||||
void hide(); |
||||
void show(); |
||||
void setWidePageSize(bool checked); |
||||
void setRegularPageSize(bool checked); |
||||
void stylusToolChanged(int tool); |
||||
void grabScene(const QRectF& pSceneRect); |
||||
void controlViewHidden(); |
||||
void controlViewShown(); |
||||
UBGraphicsVideoItem* addVideo(const QUrl& pUrl, bool startPlay, const QPointF& pos); |
||||
UBGraphicsAudioItem* addAudio(const QUrl& pUrl, bool startPlay, const QPointF& pos); |
||||
UBGraphicsWidgetItem *addW3cWidget(const QUrl& pUrl, const QPointF& pos); |
||||
|
||||
void cut(); |
||||
void copy(); |
||||
void paste(); |
||||
void processMimeData(const QMimeData* pMimeData, const QPointF& pPos); |
||||
void moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicWidget); |
||||
void moveToolWidgetToScene(UBToolWidget* toolWidget); |
||||
void addItem(); |
||||
|
||||
void freezeW3CWidgets(bool freeze); |
||||
void freezeW3CWidget(QGraphicsItem* item, bool freeze); |
||||
void startScript(); |
||||
void stopScript(); |
||||
|
||||
signals: |
||||
void activeSceneWillBePersisted(); |
||||
void activeSceneWillChange(); |
||||
void activeSceneChanged(); |
||||
void activeDocumentChanged(); |
||||
void zoomChanged(qreal pZoomFactor); |
||||
void systemScaleFactorChanged(qreal pSystemScaleFactor); |
||||
void penColorChanged(); |
||||
void controlViewportChanged(); |
||||
void backgroundChanged(); |
||||
void cacheEnabled(); |
||||
void cacheDisabled(); |
||||
void pageChanged(); |
||||
void setDocOnPageNavigator(UBDocumentProxy* doc); |
||||
void documentReorganized(int index); |
||||
void displayMetadata(QMap<QString, QString> metadata); |
||||
|
||||
protected: |
||||
void setupViews(); |
||||
void setupToolbar(); |
||||
void connectToolbar(); |
||||
void initToolbarTexts(); |
||||
void updateActionStates(); |
||||
void updateSystemScaleFactor(); |
||||
QString truncate(QString text, int maxWidth); |
||||
|
||||
protected slots: |
||||
void selectionChanged(); |
||||
void undoRedoStateChange(bool canUndo); |
||||
void documentSceneChanged(UBDocumentProxy* proxy, int pIndex); |
||||
|
||||
private: |
||||
void updatePageSizeState(); |
||||
void saveViewState(); |
||||
void adjustDisplayViews(); |
||||
|
||||
UBMainWindow *mMainWindow; |
||||
UBDocumentProxy* mActiveDocument; |
||||
UBGraphicsScene* mActiveScene; |
||||
int mActiveSceneIndex; |
||||
UBBoardPaletteManager *mPaletteManager; |
||||
UBSoftwareUpdateDialog *mSoftwareUpdateDialog; |
||||
UBMessageWindow *mMessageWindow; |
||||
UBBoardView *mControlView; |
||||
UBBoardView *mDisplayView; |
||||
QWidget *mControlContainer; |
||||
QHBoxLayout *mControlLayout; |
||||
qreal mZoomFactor; |
||||
bool mIsClosing; |
||||
QColor mPenColorOnDarkBackground; |
||||
QColor mPenColorOnLightBackground; |
||||
QColor mMarkerColorOnDarkBackground; |
||||
QColor mMarkerColorOnLightBackground; |
||||
QList<UBToolWidget*> mTools; |
||||
qreal mSystemScaleFactor; |
||||
bool mCleanupDone; |
||||
QMap<QAction*, QPair<QString, QString> > mActionTexts; |
||||
|
||||
private slots: |
||||
void stylusToolDoubleClicked(int tool); |
||||
void boardViewResized(QResizeEvent* event); |
||||
void documentWillBeDeleted(UBDocumentProxy* pProxy); |
||||
void updateBackgroundActionsState(bool isDark, bool isCrossed); |
||||
void updateBackgroundState(); |
||||
void colorPaletteChanged(); |
||||
void libraryDialogClosed(int ret); |
||||
void lastWindowClosed(); |
||||
void onDownloadModalFinished(); |
||||
|
||||
}; |
||||
|
||||
|
||||
#endif /* UBBOARDCONTROLLER_H_ */ |
||||
|
@ -1,161 +1,163 @@ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#ifndef UBAPPLICATION_H_ |
||||
#define UBAPPLICATION_H_ |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include "qtsingleapplication.h" |
||||
|
||||
#include "transition/UniboardSankoreTransition.h" |
||||
|
||||
namespace Ui |
||||
{ |
||||
class MainWindow; |
||||
} |
||||
|
||||
|
||||
class UBBoardController; |
||||
class UBWebController; |
||||
class UBControlView; |
||||
class UBPreferencesController; |
||||
class UBResources; |
||||
class UBSettings; |
||||
class UBPersistenceManager; |
||||
class UBApplicationController; |
||||
class UBDocumentController; |
||||
class UBSoftwareUpdateController; |
||||
class UBMainWindow; |
||||
|
||||
class UBApplication : public QtSingleApplication |
||||
{ |
||||
Q_OBJECT; |
||||
|
||||
public: |
||||
|
||||
UBApplication(const QString &id, int &argc, char **argv); |
||||
virtual ~UBApplication(); |
||||
|
||||
int exec(const QString& pFileToImport); |
||||
|
||||
void cleanup(); |
||||
|
||||
static QPointer<QUndoStack> undoStack; |
||||
|
||||
static UBApplicationController *applicationController; |
||||
static UBBoardController* boardController; |
||||
static UBWebController* webController; |
||||
static UBDocumentController* documentController; |
||||
static UBSoftwareUpdateController* softwareUpdateController; |
||||
static UniboardSankoreTransition* mUniboardSankoreTransition; |
||||
|
||||
static UBMainWindow* mainWindow; |
||||
|
||||
static UBApplication* app() |
||||
{ |
||||
return static_cast<UBApplication*>qApp; |
||||
} |
||||
|
||||
static const QString mimeTypeUniboardDocument; |
||||
static const QString mimeTypeUniboardPage; |
||||
static const QString mimeTypeUniboardPageItem; |
||||
static const QString mimeTypeUniboardPageThumbnail; |
||||
|
||||
static void showMessage(const QString& message, bool showSpinningWheel = false); |
||||
static void setDisabled(bool disable); |
||||
|
||||
static QObject* staticMemoryCleaner; |
||||
static QString globalStyleSheet(); |
||||
|
||||
void decorateActionMenu(QAction* action); |
||||
void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1); |
||||
|
||||
int toolBarHeight(); |
||||
bool eventFilter(QObject *obj, QEvent *event); |
||||
|
||||
bool isVerbose() { return mIsVerbose;} |
||||
void setVerbose(bool verbose){mIsVerbose = verbose;} |
||||
static QString urlFromHtml(QString html); |
||||
static bool isFromWeb(QString url); |
||||
|
||||
signals: |
||||
|
||||
public slots: |
||||
|
||||
void showBoard(); |
||||
void showInternet(); |
||||
void showDocument(); |
||||
|
||||
void toolBarPositionChanged(QVariant topOrBottom); |
||||
void toolBarDisplayTextChanged(QVariant display); |
||||
|
||||
void closeEvent(QCloseEvent *event); |
||||
|
||||
/**
|
||||
* Used on Windows platform to open file in running application. On MacOS X opening file is done through the |
||||
* FileOpen event that is handle in eventFilter method. |
||||
*/ |
||||
bool handleOpenMessage(const QString& pMessage); |
||||
|
||||
private slots: |
||||
|
||||
void closing(); |
||||
#ifdef Q_WS_MAC |
||||
void showMinimized(); |
||||
#endif |
||||
void importUniboardFiles(); |
||||
private: |
||||
|
||||
void updateProtoActionsState(); |
||||
QList<QMenu*> mProtoMenus; |
||||
bool mIsVerbose; |
||||
|
||||
protected: |
||||
|
||||
#if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA) |
||||
bool macEventFilter(EventHandlerCallRef caller, EventRef event); |
||||
#endif |
||||
|
||||
UBPreferencesController* mPreferencesController; |
||||
|
||||
}; |
||||
|
||||
|
||||
class UBStyle : public QPlastiqueStyle |
||||
{ |
||||
public: |
||||
|
||||
UBStyle() |
||||
: QPlastiqueStyle() |
||||
{ |
||||
// NOOP
|
||||
} |
||||
|
||||
virtual ~UBStyle() |
||||
{ |
||||
// NOOP
|
||||
} |
||||
|
||||
/*
|
||||
* redefined to be more cocoa like on texts |
||||
*/ |
||||
virtual void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, |
||||
bool enabled, const QString& text, QPalette::ColorRole textRole) const; |
||||
|
||||
|
||||
}; |
||||
|
||||
#endif /* UBAPPLICATION_H_ */ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#ifndef UBAPPLICATION_H_ |
||||
#define UBAPPLICATION_H_ |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include "qtsingleapplication.h" |
||||
|
||||
#include "transition/UniboardSankoreTransition.h" |
||||
|
||||
namespace Ui |
||||
{ |
||||
class MainWindow; |
||||
} |
||||
|
||||
|
||||
class UBBoardController; |
||||
class UBWebController; |
||||
class UBControlView; |
||||
class UBPreferencesController; |
||||
class UBResources; |
||||
class UBSettings; |
||||
class UBPersistenceManager; |
||||
class UBApplicationController; |
||||
class UBDocumentController; |
||||
class UBSoftwareUpdateController; |
||||
class UBMainWindow; |
||||
|
||||
class UBApplication : public QtSingleApplication |
||||
{ |
||||
Q_OBJECT; |
||||
|
||||
public: |
||||
|
||||
UBApplication(const QString &id, int &argc, char **argv); |
||||
virtual ~UBApplication(); |
||||
|
||||
int exec(const QString& pFileToImport); |
||||
|
||||
void cleanup(); |
||||
|
||||
static QPointer<QUndoStack> undoStack; |
||||
|
||||
static UBApplicationController *applicationController; |
||||
static UBBoardController* boardController; |
||||
static UBWebController* webController; |
||||
static UBDocumentController* documentController; |
||||
static UBSoftwareUpdateController* softwareUpdateController; |
||||
static UniboardSankoreTransition* mUniboardSankoreTransition; |
||||
|
||||
static UBMainWindow* mainWindow; |
||||
|
||||
static UBApplication* app() |
||||
{ |
||||
return static_cast<UBApplication*>qApp; |
||||
} |
||||
|
||||
static const QString mimeTypeUniboardDocument; |
||||
static const QString mimeTypeUniboardPage; |
||||
static const QString mimeTypeUniboardPageItem; |
||||
static const QString mimeTypeUniboardPageThumbnail; |
||||
|
||||
static void showMessage(const QString& message, bool showSpinningWheel = false); |
||||
static void setDisabled(bool disable); |
||||
|
||||
static QObject* staticMemoryCleaner; |
||||
static QString globalStyleSheet(); |
||||
|
||||
void decorateActionMenu(QAction* action); |
||||
void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1); |
||||
|
||||
int toolBarHeight(); |
||||
bool eventFilter(QObject *obj, QEvent *event); |
||||
|
||||
bool isVerbose() { return mIsVerbose;} |
||||
void setVerbose(bool verbose){mIsVerbose = verbose;} |
||||
static QString urlFromHtml(QString html); |
||||
static bool isFromWeb(QString url); |
||||
|
||||
signals: |
||||
|
||||
public slots: |
||||
|
||||
void showBoard(); |
||||
void showInternet(); |
||||
void showDocument(); |
||||
void startScript(); |
||||
void stopScript(); |
||||
|
||||
void toolBarPositionChanged(QVariant topOrBottom); |
||||
void toolBarDisplayTextChanged(QVariant display); |
||||
|
||||
void closeEvent(QCloseEvent *event); |
||||
|
||||
/**
|
||||
* Used on Windows platform to open file in running application. On MacOS X opening file is done through the |
||||
* FileOpen event that is handle in eventFilter method. |
||||
*/ |
||||
bool handleOpenMessage(const QString& pMessage); |
||||
|
||||
private slots: |
||||
|
||||
void closing(); |
||||
#ifdef Q_WS_MAC |
||||
void showMinimized(); |
||||
#endif |
||||
void importUniboardFiles(); |
||||
private: |
||||
|
||||
void updateProtoActionsState(); |
||||
QList<QMenu*> mProtoMenus; |
||||
bool mIsVerbose; |
||||
|
||||
protected: |
||||
|
||||
#if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA) |
||||
bool macEventFilter(EventHandlerCallRef caller, EventRef event); |
||||
#endif |
||||
|
||||
UBPreferencesController* mPreferencesController; |
||||
|
||||
}; |
||||
|
||||
|
||||
class UBStyle : public QPlastiqueStyle |
||||
{ |
||||
public: |
||||
|
||||
UBStyle() |
||||
: QPlastiqueStyle() |
||||
{ |
||||
// NOOP
|
||||
} |
||||
|
||||
virtual ~UBStyle() |
||||
{ |
||||
// NOOP
|
||||
} |
||||
|
||||
/*
|
||||
* redefined to be more cocoa like on texts |
||||
*/ |
||||
virtual void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, |
||||
bool enabled, const QString& text, QPalette::ColorRole textRole) const; |
||||
|
||||
|
||||
}; |
||||
|
||||
#endif /* UBAPPLICATION_H_ */ |
||||
|
@ -1,294 +1,294 @@ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
|
||||
#include "UBDocumentManager.h" |
||||
|
||||
#include "frameworks/UBStringUtils.h" |
||||
|
||||
#include "adaptors/UBExportFullPDF.h" |
||||
#include "adaptors/UBExportDocument.h" |
||||
#include "adaptors/UBExportWeb.h" |
||||
#include "adaptors/UBWebPublisher.h" |
||||
#include "adaptors/UBImportDocument.h" |
||||
#include "adaptors/UBImportPDF.h" |
||||
#include "adaptors/UBImportImage.h" |
||||
#include "adaptors/UBImportCFF.h" |
||||
|
||||
#include "domain/UBGraphicsScene.h" |
||||
#include "domain/UBGraphicsSvgItem.h" |
||||
#include "domain/UBGraphicsPixmapItem.h" |
||||
|
||||
#include "document/UBDocumentProxy.h" |
||||
|
||||
#include "UBApplication.h" |
||||
#include "UBSettings.h" |
||||
#include "UBPersistenceManager.h" |
||||
|
||||
#include "../adaptors/UBExportWeb.h" |
||||
|
||||
#include "core/memcheck.h" |
||||
|
||||
UBDocumentManager* UBDocumentManager::sDocumentManager = 0; |
||||
|
||||
UBDocumentManager* UBDocumentManager::documentManager() |
||||
{ |
||||
if (!sDocumentManager) |
||||
{ |
||||
sDocumentManager = new UBDocumentManager(qApp); |
||||
} |
||||
return sDocumentManager; |
||||
} |
||||
|
||||
|
||||
UBDocumentManager::UBDocumentManager(QObject *parent) |
||||
:QObject(parent) |
||||
{ |
||||
// TODO UB 4.7 string used in document persistence (folder names)
|
||||
QString dummyImages = tr("images"); |
||||
QString dummyVideos = tr("videos"); |
||||
QString dummyObjects = tr("objects"); |
||||
QString dummyWidgets = tr("widgets"); |
||||
|
||||
UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this); |
||||
mExportAdaptors.append(exportFullPdf); |
||||
UBExportDocument* exportDocument = new UBExportDocument(this); |
||||
mExportAdaptors.append(exportDocument); |
||||
// UBExportWeb* exportWeb = new UBExportWeb(this);
|
||||
// mExportAdaptors.append(exportWeb);
|
||||
UBWebPublisher* webPublished = new UBWebPublisher(this); |
||||
mExportAdaptors.append(webPublished); |
||||
|
||||
UBImportDocument* documentImport = new UBImportDocument(this); |
||||
mImportAdaptors.append(documentImport); |
||||
UBImportPDF* pdfImport = new UBImportPDF(this); |
||||
mImportAdaptors.append(pdfImport); |
||||
UBImportImage* imageImport = new UBImportImage(this); |
||||
mImportAdaptors.append(imageImport); |
||||
UBImportCFF* cffImport = new UBImportCFF(this); |
||||
mImportAdaptors.append(cffImport); |
||||
} |
||||
|
||||
|
||||
UBDocumentManager::~UBDocumentManager() |
||||
{ |
||||
// NOOP
|
||||
} |
||||
|
||||
|
||||
QStringList UBDocumentManager::importFileExtensions() |
||||
{ |
||||
QStringList result; |
||||
|
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
result << importAdaptor->supportedExtentions(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
QString UBDocumentManager::importFileFilter() |
||||
{ |
||||
QString result; |
||||
|
||||
result += tr("All supported files (*.%1)").arg(importFileExtensions().join(" *.")); |
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
if (importAdaptor->importFileFilter().length() > 0) |
||||
{ |
||||
if (result.length()) |
||||
{ |
||||
result += ";;"; |
||||
} |
||||
result += importAdaptor->importFileFilter(); |
||||
} |
||||
} |
||||
qDebug() << "import file filter" << result; |
||||
return result; |
||||
} |
||||
|
||||
|
||||
UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString& pGroup) |
||||
{ |
||||
QFileInfo fileInfo(pFile); |
||||
|
||||
UBDocumentProxy* document = 0; |
||||
|
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
if (importAdaptor->supportedExtentions().lastIndexOf(fileInfo.suffix().toLower()) != -1) |
||||
{ |
||||
UBApplication::setDisabled(true); |
||||
document = importAdaptor->importFile(pFile, pGroup); |
||||
UBApplication::setDisabled(false); |
||||
} |
||||
} |
||||
|
||||
return document; |
||||
} |
||||
|
||||
|
||||
bool UBDocumentManager::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) |
||||
{ |
||||
QFileInfo fileInfo(pFile); |
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
if (importAdaptor->supportedExtentions().lastIndexOf(fileInfo.suffix().toLower()) != -1) |
||||
{ |
||||
UBApplication::setDisabled(true); |
||||
bool result = importAdaptor->addFileToDocument(pDocument, pFile); |
||||
UBApplication::setDisabled(false); |
||||
return result; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
|
||||
int UBDocumentManager::addImageDirToDocument(const QDir& pDir, UBDocumentProxy* pDocument) |
||||
{ |
||||
QStringList filenames = pDir.entryList(QDir::Files | QDir::NoDotAndDotDot); |
||||
|
||||
filenames = UBStringUtils::sortByLastDigit(filenames); |
||||
|
||||
QStringList fullPathFilenames; |
||||
|
||||
foreach(QString f, filenames) |
||||
{ |
||||
fullPathFilenames << pDir.absolutePath() + "/" + f; |
||||
} |
||||
|
||||
return addImageAsPageToDocument(fullPathFilenames, pDocument); |
||||
|
||||
} |
||||
|
||||
|
||||
UBDocumentProxy* UBDocumentManager::importDir(const QDir& pDir, const QString& pGroup) |
||||
{ |
||||
UBDocumentProxy* doc = UBPersistenceManager::persistenceManager()->createDocument(pGroup, pDir.dirName()); |
||||
|
||||
int result = addImageDirToDocument(pDir, doc); |
||||
|
||||
if (result > 0) |
||||
{ |
||||
doc->setMetaData(UBSettings::documentGroupName, pGroup); |
||||
doc->setMetaData(UBSettings::documentName, pDir.dirName()); |
||||
|
||||
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(doc); |
||||
|
||||
UBApplication::showMessage(tr("File %1 saved").arg(pDir.dirName())); |
||||
|
||||
} |
||||
else |
||||
{ |
||||
UBPersistenceManager::persistenceManager()->deleteDocument(doc); |
||||
} |
||||
|
||||
return doc; |
||||
} |
||||
|
||||
|
||||
QList<UBExportAdaptor*> UBDocumentManager::supportedExportAdaptors() |
||||
{ |
||||
return mExportAdaptors; |
||||
} |
||||
|
||||
int UBDocumentManager::addImageAsPageToDocument(const QStringList& filenames, UBDocumentProxy* pDocument) |
||||
{ |
||||
|
||||
int result = 0; |
||||
|
||||
if (filenames.size() > 0) |
||||
{ |
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
||||
|
||||
QApplication::processEvents(); |
||||
|
||||
int pageIndex = pDocument->pageCount(); |
||||
|
||||
if (pageIndex == 1 && UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocument, 0)->isEmpty()) |
||||
{ |
||||
pageIndex = 0; |
||||
} |
||||
|
||||
int expectedPageCount = filenames.size(); |
||||
|
||||
for(int i = 0; i < filenames.size(); i ++) |
||||
{ |
||||
UBApplication::showMessage(tr("Importing page %1 of %2").arg(i + 1).arg(expectedPageCount)); |
||||
|
||||
UBGraphicsScene* scene = 0; |
||||
|
||||
QString fullPath = filenames.at(i); |
||||
|
||||
QGraphicsItem *gi = 0; |
||||
|
||||
if (pageIndex == 0) |
||||
{ |
||||
scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocument, pageIndex); |
||||
} |
||||
else |
||||
{ |
||||
scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(pDocument, pageIndex); |
||||
} |
||||
|
||||
scene->setBackground(false, false); |
||||
|
||||
if (fullPath.endsWith(".svg") || fullPath.endsWith(".svgz")) |
||||
{ |
||||
gi = scene->addSvg(QUrl::fromLocalFile(fullPath), QPointF(0, 0)); |
||||
} |
||||
else |
||||
{ |
||||
QPixmap pix(fullPath); |
||||
|
||||
if (pix.isNull()) |
||||
{ |
||||
UBApplication::showMessage(tr("Erronous image data, skipping file %1").arg(filenames.at(i))); |
||||
expectedPageCount--; |
||||
continue; |
||||
} |
||||
else |
||||
{ |
||||
gi = scene->addPixmap(pix, QPointF(0, 0)); |
||||
} |
||||
} |
||||
|
||||
if (gi) |
||||
{ |
||||
scene->setAsBackgroundObject(gi, true); |
||||
|
||||
UBPersistenceManager::persistenceManager()->persistDocumentScene(pDocument, scene, pageIndex); |
||||
|
||||
pageIndex++; |
||||
} |
||||
|
||||
} |
||||
|
||||
result = expectedPageCount; |
||||
|
||||
QApplication::restoreOverrideCursor(); |
||||
|
||||
} |
||||
|
||||
return result; |
||||
|
||||
} |
||||
|
||||
void UBDocumentManager::emitDocumentUpdated(UBDocumentProxy* pDocument) |
||||
{ |
||||
emit documentUpdated(pDocument); |
||||
} |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
|
||||
#include "UBDocumentManager.h" |
||||
|
||||
#include "frameworks/UBStringUtils.h" |
||||
|
||||
#include "adaptors/UBExportFullPDF.h" |
||||
#include "adaptors/UBExportDocument.h" |
||||
#include "adaptors/UBExportWeb.h" |
||||
#include "adaptors/UBWebPublisher.h" |
||||
#include "adaptors/UBImportDocument.h" |
||||
#include "adaptors/UBImportPDF.h" |
||||
#include "adaptors/UBImportImage.h" |
||||
#include "adaptors/UBImportCFF.h" |
||||
|
||||
#include "domain/UBGraphicsScene.h" |
||||
#include "domain/UBGraphicsSvgItem.h" |
||||
#include "domain/UBGraphicsPixmapItem.h" |
||||
|
||||
#include "document/UBDocumentProxy.h" |
||||
|
||||
#include "UBApplication.h" |
||||
#include "UBSettings.h" |
||||
#include "UBPersistenceManager.h" |
||||
|
||||
#include "../adaptors/UBExportWeb.h" |
||||
|
||||
#include "core/memcheck.h" |
||||
|
||||
UBDocumentManager* UBDocumentManager::sDocumentManager = 0; |
||||
|
||||
UBDocumentManager* UBDocumentManager::documentManager() |
||||
{ |
||||
if (!sDocumentManager) |
||||
{ |
||||
sDocumentManager = new UBDocumentManager(qApp); |
||||
} |
||||
return sDocumentManager; |
||||
} |
||||
|
||||
|
||||
UBDocumentManager::UBDocumentManager(QObject *parent) |
||||
:QObject(parent) |
||||
{ |
||||
// TODO UB 4.7 string used in document persistence (folder names)
|
||||
QString dummyImages = tr("images"); |
||||
QString dummyVideos = tr("videos"); |
||||
QString dummyObjects = tr("objects"); |
||||
QString dummyWidgets = tr("widgets"); |
||||
|
||||
UBExportFullPDF* exportFullPdf = new UBExportFullPDF(this); |
||||
mExportAdaptors.append(exportFullPdf); |
||||
UBExportDocument* exportDocument = new UBExportDocument(this); |
||||
mExportAdaptors.append(exportDocument); |
||||
// UBExportWeb* exportWeb = new UBExportWeb(this);
|
||||
// mExportAdaptors.append(exportWeb);
|
||||
UBWebPublisher* webPublished = new UBWebPublisher(this); |
||||
mExportAdaptors.append(webPublished); |
||||
|
||||
UBImportDocument* documentImport = new UBImportDocument(this); |
||||
mImportAdaptors.append(documentImport); |
||||
UBImportPDF* pdfImport = new UBImportPDF(this); |
||||
mImportAdaptors.append(pdfImport); |
||||
UBImportImage* imageImport = new UBImportImage(this); |
||||
mImportAdaptors.append(imageImport); |
||||
UBImportCFF* cffImport = new UBImportCFF(this); |
||||
mImportAdaptors.append(cffImport); |
||||
} |
||||
|
||||
|
||||
UBDocumentManager::~UBDocumentManager() |
||||
{ |
||||
// NOOP
|
||||
} |
||||
|
||||
|
||||
QStringList UBDocumentManager::importFileExtensions() |
||||
{ |
||||
QStringList result; |
||||
|
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
result << importAdaptor->supportedExtentions(); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
|
||||
QString UBDocumentManager::importFileFilter() |
||||
{ |
||||
QString result; |
||||
|
||||
result += tr("All supported files (*.%1)").arg(importFileExtensions().join(" *.")); |
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
if (importAdaptor->importFileFilter().length() > 0) |
||||
{ |
||||
if (result.length()) |
||||
{ |
||||
result += ";;"; |
||||
} |
||||
result += importAdaptor->importFileFilter(); |
||||
} |
||||
} |
||||
qDebug() << "import file filter" << result; |
||||
return result; |
||||
} |
||||
|
||||
|
||||
UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString& pGroup) |
||||
{ |
||||
QFileInfo fileInfo(pFile); |
||||
|
||||
UBDocumentProxy* document = 0; |
||||
|
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
if (importAdaptor->supportedExtentions().lastIndexOf(fileInfo.suffix().toLower()) != -1) |
||||
{ |
||||
UBApplication::setDisabled(true); |
||||
document = importAdaptor->importFile(pFile, pGroup); |
||||
UBApplication::setDisabled(false); |
||||
} |
||||
} |
||||
|
||||
return document; |
||||
} |
||||
|
||||
|
||||
bool UBDocumentManager::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) |
||||
{ |
||||
QFileInfo fileInfo(pFile); |
||||
foreach (UBImportAdaptor *importAdaptor, mImportAdaptors) |
||||
{ |
||||
if (importAdaptor->supportedExtentions().lastIndexOf(fileInfo.suffix().toLower()) != -1) |
||||
{ |
||||
UBApplication::setDisabled(true); |
||||
bool result = importAdaptor->addFileToDocument(pDocument, pFile); |
||||
UBApplication::setDisabled(false); |
||||
return result; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
|
||||
int UBDocumentManager::addImageDirToDocument(const QDir& pDir, UBDocumentProxy* pDocument) |
||||
{ |
||||
QStringList filenames = pDir.entryList(QDir::Files | QDir::NoDotAndDotDot); |
||||
|
||||
filenames = UBStringUtils::sortByLastDigit(filenames); |
||||
|
||||
QStringList fullPathFilenames; |
||||
|
||||
foreach(QString f, filenames) |
||||
{ |
||||
fullPathFilenames << pDir.absolutePath() + "/" + f; |
||||
} |
||||
|
||||
return addImageAsPageToDocument(fullPathFilenames, pDocument); |
||||
|
||||
} |
||||
|
||||
|
||||
UBDocumentProxy* UBDocumentManager::importDir(const QDir& pDir, const QString& pGroup) |
||||
{ |
||||
UBDocumentProxy* doc = UBPersistenceManager::persistenceManager()->createDocument(pGroup, pDir.dirName()); |
||||
|
||||
int result = addImageDirToDocument(pDir, doc); |
||||
|
||||
if (result > 0) |
||||
{ |
||||
doc->setMetaData(UBSettings::documentGroupName, pGroup); |
||||
doc->setMetaData(UBSettings::documentName, pDir.dirName()); |
||||
|
||||
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(doc); |
||||
|
||||
UBApplication::showMessage(tr("File %1 saved").arg(pDir.dirName())); |
||||
|
||||
} |
||||
else |
||||
{ |
||||
UBPersistenceManager::persistenceManager()->deleteDocument(doc); |
||||
} |
||||
|
||||
return doc; |
||||
} |
||||
|
||||
|
||||
QList<UBExportAdaptor*> UBDocumentManager::supportedExportAdaptors() |
||||
{ |
||||
return mExportAdaptors; |
||||
} |
||||
|
||||
int UBDocumentManager::addImageAsPageToDocument(const QStringList& filenames, UBDocumentProxy* pDocument) |
||||
{ |
||||
|
||||
int result = 0; |
||||
|
||||
if (filenames.size() > 0) |
||||
{ |
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); |
||||
|
||||
QApplication::processEvents(); |
||||
|
||||
int pageIndex = pDocument->pageCount(); |
||||
|
||||
if (pageIndex == 1 && UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocument, 0)->isEmpty()) |
||||
{ |
||||
pageIndex = 0; |
||||
} |
||||
|
||||
int expectedPageCount = filenames.size(); |
||||
|
||||
for(int i = 0; i < filenames.size(); i ++) |
||||
{ |
||||
UBApplication::showMessage(tr("Importing page %1 of %2").arg(i + 1).arg(expectedPageCount)); |
||||
|
||||
UBGraphicsScene* scene = 0; |
||||
|
||||
QString fullPath = filenames.at(i); |
||||
|
||||
QGraphicsItem *gi = 0; |
||||
|
||||
if (pageIndex == 0) |
||||
{ |
||||
scene = UBPersistenceManager::persistenceManager()->loadDocumentScene(pDocument, pageIndex); |
||||
} |
||||
else |
||||
{ |
||||
scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(pDocument, pageIndex); |
||||
} |
||||
|
||||
scene->setBackground(false, false); |
||||
|
||||
if (fullPath.endsWith(".svg") || fullPath.endsWith(".svgz")) |
||||
{ |
||||
gi = scene->addSvg(QUrl::fromLocalFile(fullPath), QPointF(0, 0)); |
||||
} |
||||
else |
||||
{ |
||||
QPixmap pix(fullPath); |
||||
|
||||
if (pix.isNull()) |
||||
{ |
||||
UBApplication::showMessage(tr("Erronous image data, skipping file %1").arg(filenames.at(i))); |
||||
expectedPageCount--; |
||||
continue; |
||||
} |
||||
else |
||||
{ |
||||
gi = scene->addPixmap(pix, QPointF(0, 0)); |
||||
} |
||||
} |
||||
|
||||
if (gi) |
||||
{ |
||||
scene->setAsBackgroundObject(gi, true); |
||||
|
||||
UBPersistenceManager::persistenceManager()->persistDocumentScene(pDocument, scene, pageIndex); |
||||
|
||||
pageIndex++; |
||||
} |
||||
|
||||
} |
||||
|
||||
result = expectedPageCount; |
||||
|
||||
QApplication::restoreOverrideCursor(); |
||||
|
||||
} |
||||
|
||||
return result; |
||||
|
||||
} |
||||
|
||||
void UBDocumentManager::emitDocumentUpdated(UBDocumentProxy* pDocument) |
||||
{ |
||||
emit documentUpdated(pDocument); |
||||
} |
||||
|
@ -1,110 +1,137 @@ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#include "UBGraphicsItemUndoCommand.h" |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include "UBGraphicsScene.h" |
||||
|
||||
#include "core/memcheck.h" |
||||
|
||||
|
||||
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, |
||||
const QSet<QGraphicsItem*>& pAddedItems) |
||||
: mScene(pScene) |
||||
, mRemovedItems(pRemovedItems - pAddedItems) |
||||
, mAddedItems(pAddedItems - pRemovedItems) |
||||
{ |
||||
mFirstRedo = true; |
||||
} |
||||
|
||||
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, |
||||
QGraphicsItem* pAddedItem) : |
||||
mScene(pScene) |
||||
{ |
||||
|
||||
if (pRemovedItem) |
||||
mRemovedItems.insert(pRemovedItem); |
||||
|
||||
if (pAddedItem) |
||||
mAddedItems.insert(pAddedItem); |
||||
|
||||
mFirstRedo = true; |
||||
|
||||
} |
||||
|
||||
UBGraphicsItemUndoCommand::~UBGraphicsItemUndoCommand() |
||||
{ |
||||
//NOOP
|
||||
} |
||||
|
||||
void UBGraphicsItemUndoCommand::undo() |
||||
{ |
||||
if (!mScene){ |
||||
return; |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itAdded(mAddedItems); |
||||
while (itAdded.hasNext()) |
||||
{ |
||||
QGraphicsItem* item = itAdded.next(); |
||||
item->setSelected(false); |
||||
mScene->removeItem(item); |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); |
||||
while (itRemoved.hasNext()) |
||||
{ |
||||
mScene->addItem(itRemoved.next()); |
||||
} |
||||
|
||||
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
||||
mScene->update(mScene->sceneRect()); |
||||
|
||||
} |
||||
|
||||
void UBGraphicsItemUndoCommand::redo() |
||||
{ |
||||
// the Undo framework calls a redo while appending the undo command.
|
||||
// as we have already plotted the elements, we do not want to do it twice
|
||||
if (!mFirstRedo) |
||||
{ |
||||
if (!mScene){ |
||||
return; |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); |
||||
while (itRemoved.hasNext()) |
||||
{ |
||||
QGraphicsItem* item = itRemoved.next(); |
||||
item->setSelected(false); |
||||
mScene->removeItem(item); |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itAdded(mAddedItems); |
||||
while (itAdded.hasNext()) |
||||
{ |
||||
mScene->addItem(itAdded.next()); |
||||
} |
||||
|
||||
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2) to trigger repaint
|
||||
mScene->update(mScene->sceneRect()); |
||||
} |
||||
else |
||||
{ |
||||
mFirstRedo = false; |
||||
} |
||||
} |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#include "UBGraphicsItemUndoCommand.h" |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include "UBGraphicsScene.h" |
||||
|
||||
#include "core/memcheck.h" |
||||
|
||||
#include "core/UBApplication.h" |
||||
|
||||
#include "board/UBBoardController.h" |
||||
|
||||
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, |
||||
const QSet<QGraphicsItem*>& pAddedItems) |
||||
: mScene(pScene) |
||||
, mRemovedItems(pRemovedItems - pAddedItems) |
||||
, mAddedItems(pAddedItems - pRemovedItems) |
||||
{ |
||||
mFirstRedo = true; |
||||
|
||||
QSetIterator<QGraphicsItem*> itAdded(mAddedItems); |
||||
while (itAdded.hasNext()) |
||||
{ |
||||
UBApplication::boardController->freezeW3CWidget(itAdded.next(), true); |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); |
||||
while (itRemoved.hasNext()) |
||||
{ |
||||
UBApplication::boardController->freezeW3CWidget(itRemoved.next(), false); |
||||
} |
||||
} |
||||
|
||||
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, |
||||
QGraphicsItem* pAddedItem) : |
||||
mScene(pScene) |
||||
{ |
||||
|
||||
if (pRemovedItem) |
||||
{ |
||||
mRemovedItems.insert(pRemovedItem); |
||||
UBApplication::boardController->freezeW3CWidget(pRemovedItem, true); |
||||
} |
||||
|
||||
if (pAddedItem) |
||||
{ |
||||
mAddedItems.insert(pAddedItem); |
||||
UBApplication::boardController->freezeW3CWidget(pAddedItem, false); |
||||
} |
||||
|
||||
mFirstRedo = true; |
||||
|
||||
} |
||||
|
||||
UBGraphicsItemUndoCommand::~UBGraphicsItemUndoCommand() |
||||
{ |
||||
//NOOP
|
||||
} |
||||
|
||||
void UBGraphicsItemUndoCommand::undo() |
||||
{ |
||||
if (!mScene){ |
||||
return; |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itAdded(mAddedItems); |
||||
while (itAdded.hasNext()) |
||||
{ |
||||
QGraphicsItem* item = itAdded.next(); |
||||
item->setSelected(false); |
||||
mScene->removeItem(item); |
||||
UBApplication::boardController->freezeW3CWidget(item, true); |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); |
||||
while (itRemoved.hasNext()) |
||||
{ |
||||
QGraphicsItem* item = itRemoved.next(); |
||||
mScene->addItem(item); |
||||
UBApplication::boardController->freezeW3CWidget(item, false); |
||||
} |
||||
|
||||
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
|
||||
mScene->update(mScene->sceneRect()); |
||||
|
||||
} |
||||
|
||||
void UBGraphicsItemUndoCommand::redo() |
||||
{ |
||||
// the Undo framework calls a redo while appending the undo command.
|
||||
// as we have already plotted the elements, we do not want to do it twice
|
||||
if (!mFirstRedo) |
||||
{ |
||||
if (!mScene){ |
||||
return; |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); |
||||
while (itRemoved.hasNext()) |
||||
{ |
||||
QGraphicsItem* item = itRemoved.next(); |
||||
item->setSelected(false); |
||||
mScene->removeItem(item); |
||||
UBApplication::boardController->freezeW3CWidget(item, true); |
||||
} |
||||
|
||||
QSetIterator<QGraphicsItem*> itAdded(mAddedItems); |
||||
while (itAdded.hasNext()) |
||||
{ |
||||
QGraphicsItem* item = itAdded.next(); |
||||
mScene->addItem(item); |
||||
UBApplication::boardController->freezeW3CWidget(item, false); |
||||
} |
||||
|
||||
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2) to trigger repaint
|
||||
mScene->update(mScene->sceneRect()); |
||||
} |
||||
else |
||||
{ |
||||
mFirstRedo = false; |
||||
} |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,377 +1,382 @@ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#ifndef UBGRAPHICSSCENE_H_ |
||||
#define UBGRAPHICSSCENE_H_ |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include "frameworks/UBCoreGraphicsScene.h" |
||||
|
||||
#include "core/UB.h" |
||||
|
||||
#include "UBItem.h" |
||||
#include "tools/UBGraphicsCurtainItem.h" |
||||
|
||||
|
||||
class UBGraphicsPixmapItem; |
||||
class UBGraphicsProxyWidget; |
||||
class UBGraphicsSvgItem; |
||||
class UBGraphicsPolygonItem; |
||||
class UBGraphicsVideoItem; |
||||
class UBGraphicsAudioItem; |
||||
class UBGraphicsWidgetItem; |
||||
class UBGraphicsW3CWidgetItem; |
||||
class UBGraphicsAppleWidgetItem; |
||||
class UBGraphicsPDFItem; |
||||
class UBGraphicsTextItem; |
||||
class UBGraphicsRuler; |
||||
class UBGraphicsProtractor; |
||||
class UBGraphicsCompass; |
||||
class UBAbstractWidget; |
||||
class UBDocumentProxy; |
||||
class UBGraphicsCurtainItem; |
||||
class UBGraphicsStroke; |
||||
class UBMagnifierParams; |
||||
class UBMagnifier; |
||||
class UBGraphicsCache; |
||||
|
||||
const double PI = 4.0 * atan(1.0); |
||||
|
||||
class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
// tmp stub for divide addings scene objects from undo mechanism implementation
|
||||
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} |
||||
|
||||
UBGraphicsScene(UBDocumentProxy *parent); |
||||
virtual ~UBGraphicsScene(); |
||||
|
||||
virtual UBItem* deepCopy() const; |
||||
|
||||
UBGraphicsScene* sceneDeepCopy() const; |
||||
|
||||
void clearItemsAndAnnotations(); |
||||
void clearItems(); |
||||
void clearAnnotations(); |
||||
|
||||
bool inputDevicePress(const QPointF& scenePos, const qreal& pressure = 1.0); |
||||
bool inputDeviceMove(const QPointF& scenePos, const qreal& pressure = 1.0); |
||||
bool inputDeviceRelease(); |
||||
|
||||
void leaveEvent (QEvent* event); |
||||
|
||||
void addItem(QGraphicsItem* item); |
||||
void removeItem(QGraphicsItem* item); |
||||
|
||||
void addItems(const QSet<QGraphicsItem*>& item); |
||||
void removeItems(const QSet<QGraphicsItem*>& item); |
||||
|
||||
UBGraphicsWidgetItem* addWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsAppleWidgetItem* addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsW3CWidgetItem* addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0),int widgetType = UBGraphicsItemType::W3CWidgetItemType); |
||||
void addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos = QPointF(0, 0)); |
||||
|
||||
UBGraphicsVideoItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsAudioItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)); |
||||
|
||||
UBGraphicsTextItem* addTextWithFont(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0) |
||||
, int pointSize = -1, const QString& fontFamily = "", bool bold = false, bool italic = false); |
||||
UBGraphicsTextItem* addTextHtml(const QString &pString = QString(), const QPointF& pTopLeft = QPointF(0, 0)); |
||||
|
||||
UBGraphicsW3CWidgetItem* addOEmbed(const QUrl& pContentUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
|
||||
QGraphicsItem* setAsBackgroundObject(QGraphicsItem* item, bool pAdaptTransformation = false, bool expand = false); |
||||
|
||||
QGraphicsItem* backgroundObject() const |
||||
{ |
||||
return mBackgroundObject; |
||||
} |
||||
|
||||
bool isBackgroundObject(const QGraphicsItem* item) const |
||||
{ |
||||
return item == mBackgroundObject; |
||||
} |
||||
|
||||
QGraphicsItem* scaleToFitDocumentSize(QGraphicsItem* item, bool center = false, int margin = 0, bool expand = false); |
||||
|
||||
QRectF normalizedSceneRect(qreal ratio = -1.0); |
||||
|
||||
void moveTo(const QPointF& pPoint); |
||||
void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle); |
||||
void eraseLineTo(const QPointF& pEndPoint, const qreal& pWidth); |
||||
void drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle); |
||||
|
||||
bool isEmpty() const; |
||||
|
||||
bool isModified() const |
||||
{ |
||||
return mIsModified; |
||||
} |
||||
|
||||
void setModified(bool pModified) |
||||
{ |
||||
mIsModified = pModified; |
||||
} |
||||
|
||||
void setDocument(UBDocumentProxy* pDocument); |
||||
|
||||
UBDocumentProxy* document() const |
||||
{ |
||||
return mDocument; |
||||
} |
||||
|
||||
bool isDarkBackground() const |
||||
{ |
||||
return mDarkBackground; |
||||
} |
||||
|
||||
bool isLightBackground() const |
||||
{ |
||||
return !mDarkBackground; |
||||
} |
||||
|
||||
bool isCrossedBackground() const |
||||
{ |
||||
return mCrossedBackground; |
||||
} |
||||
|
||||
void setDrawingZIndex(qreal pDrawingZIndex) |
||||
{ |
||||
mDrawingZIndex = pDrawingZIndex; |
||||
} |
||||
|
||||
void setObjectZIndex(qreal pObjectZIndex) |
||||
{ |
||||
mObjectZIndex = pObjectZIndex; |
||||
} |
||||
|
||||
bool hasBackground() |
||||
{ |
||||
return (mBackgroundObject != 0); |
||||
} |
||||
|
||||
qreal getNextObjectZIndex(); |
||||
|
||||
void addRuler(QPointF center); |
||||
void addProtractor(QPointF center); |
||||
void addCompass(QPointF center); |
||||
void addTriangle(QPointF center); |
||||
void addMagnifier(UBMagnifierParams params); |
||||
|
||||
void addMask(const QPointF ¢er = QPointF()); |
||||
void addCache(); |
||||
|
||||
class SceneViewState |
||||
{ |
||||
public: |
||||
SceneViewState() |
||||
{ |
||||
zoomFactor = 1; |
||||
horizontalPosition = 0; |
||||
verticalPostition = 0; |
||||
} |
||||
|
||||
SceneViewState(qreal pZoomFactor, int pHorizontalPosition, int pVerticalPostition) |
||||
{ |
||||
zoomFactor = pZoomFactor; |
||||
horizontalPosition = pHorizontalPosition; |
||||
verticalPostition = pVerticalPostition; |
||||
} |
||||
|
||||
qreal zoomFactor; |
||||
int horizontalPosition; |
||||
int verticalPostition; |
||||
}; |
||||
|
||||
SceneViewState viewState() const |
||||
{ |
||||
return mViewState; |
||||
} |
||||
|
||||
void setViewState(const SceneViewState& pViewState) |
||||
{ |
||||
mViewState = pViewState; |
||||
} |
||||
|
||||
virtual void setRenderingQuality(UBItem::RenderingQuality pRenderingQuality); |
||||
|
||||
QList<QUrl> relativeDependencies() const; |
||||
|
||||
QSize nominalSize(); |
||||
|
||||
void setNominalSize(const QSize& pSize); |
||||
|
||||
void setNominalSize(int pWidth, int pHeight); |
||||
|
||||
qreal currentObjectZIndex() |
||||
{ |
||||
return mObjectZIndex; |
||||
} |
||||
|
||||
enum RenderingContext |
||||
{ |
||||
Screen = 0, NonScreen, PdfExport, Podcast |
||||
}; |
||||
|
||||
void setRenderingContext(RenderingContext pRenderingContext) |
||||
{ |
||||
mRenderingContext = pRenderingContext; |
||||
} |
||||
|
||||
RenderingContext renderingContext() const |
||||
{ |
||||
return mRenderingContext; |
||||
} |
||||
|
||||
static qreal backgroundLayerStart; |
||||
static qreal objectLayerStart; |
||||
static qreal drawingLayerStart; |
||||
static qreal toolLayerStart; |
||||
|
||||
static qreal toolOffsetEraser; |
||||
static qreal toolOffsetPointer; |
||||
static qreal toolOffsetRuler; |
||||
static qreal toolOffsetProtractor; |
||||
static qreal toolOffsetCompass; |
||||
static qreal toolOffsetCurtain; |
||||
static qreal toolOffsetTriangle; |
||||
static qreal toolOffsetCache; |
||||
|
||||
QSet<QGraphicsItem*> tools(){ return mTools;} |
||||
|
||||
void registerTool(QGraphicsItem* item) |
||||
{ |
||||
mTools << item; |
||||
} |
||||
|
||||
const QPointF& previousPoint() |
||||
{ |
||||
return mPreviousPoint; |
||||
} |
||||
|
||||
public slots: |
||||
|
||||
void hideEraser(); |
||||
|
||||
void setBackground(bool pIsDark, bool pIsCrossed); |
||||
|
||||
void deselectAllItems(); |
||||
|
||||
UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false); |
||||
|
||||
void textUndoCommandAdded(UBGraphicsTextItem *textItem); |
||||
|
||||
void setToolCursor(int tool); |
||||
|
||||
void selectionChangedProcessing(); |
||||
|
||||
void moveMagnifier(QPoint newPos); |
||||
void closeMagnifier(); |
||||
void zoomInMagnifier(); |
||||
void zoomOutMagnifier(); |
||||
void resizedMagnifier(qreal newPercent); |
||||
|
||||
signals: |
||||
|
||||
void pageSizeChanged(); |
||||
|
||||
protected: |
||||
|
||||
UBGraphicsPolygonItem* lineToPolygonItem(const QLineF& pLine, const qreal& pWidth); |
||||
UBGraphicsPolygonItem* arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth); |
||||
UBGraphicsPolygonItem* polygonToPolygonItem(const QPolygonF pPolygon); |
||||
|
||||
void initPolygonItem(UBGraphicsPolygonItem*); |
||||
|
||||
void drawEraser(const QPointF& pEndPoint, bool isFirstDraw = false); |
||||
void drawPointer(const QPointF& pEndPoint, bool isFirstDraw = false); |
||||
void DisposeMagnifierQWidgets(); |
||||
|
||||
|
||||
virtual void keyReleaseEvent(QKeyEvent * keyEvent); |
||||
|
||||
void recolorAllItems(); |
||||
|
||||
qreal getNextDrawingZIndex(); |
||||
|
||||
virtual void drawItems (QPainter * painter, int numItems, |
||||
QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0); |
||||
|
||||
QGraphicsItem* rootItem(QGraphicsItem* item) const; |
||||
|
||||
private: |
||||
void setDocumentUpdated(); |
||||
|
||||
qreal mDrawingZIndex; |
||||
qreal mObjectZIndex; |
||||
|
||||
QGraphicsEllipseItem* mEraser; |
||||
QGraphicsEllipseItem* mPointer; |
||||
|
||||
QSet<QGraphicsItem*> mAddedItems; |
||||
QSet<QGraphicsItem*> mRemovedItems; |
||||
|
||||
UBDocumentProxy* mDocument; |
||||
|
||||
bool mDarkBackground; |
||||
bool mCrossedBackground; |
||||
|
||||
bool mIsModified; |
||||
|
||||
QGraphicsItem* mBackgroundObject; |
||||
|
||||
QPointF mPreviousPoint; |
||||
qreal mPreviousWidth; |
||||
|
||||
QList<UBGraphicsPolygonItem*> mPreviousPolygonItems; |
||||
|
||||
SceneViewState mViewState; |
||||
|
||||
bool mInputDeviceIsPressed; |
||||
|
||||
QSet<QGraphicsItem*> mTools; |
||||
|
||||
UBGraphicsPolygonItem *mArcPolygonItem; |
||||
|
||||
QSize mNominalSize; |
||||
|
||||
RenderingContext mRenderingContext; |
||||
|
||||
UBGraphicsStroke* mCurrentStroke; |
||||
|
||||
bool mShouldUseOMP; |
||||
|
||||
int mItemCount; |
||||
|
||||
QList<QGraphicsItem*> mFastAccessItems; // a local copy as QGraphicsScene::items() is very slow in Qt 4.6
|
||||
|
||||
//int mMesure1Ms, mMesure2Ms;
|
||||
|
||||
bool mHasCache; |
||||
// tmp stub for divide addings scene objects from undo mechanism implementation
|
||||
bool enableUndoRedoStack; |
||||
|
||||
UBMagnifier *magniferControlViewWidget; |
||||
UBMagnifier *magniferDisplayViewWidget; |
||||
|
||||
|
||||
}; |
||||
|
||||
#endif /* UBGRAPHICSSCENE_H_ */ |
||||
/*
|
||||
* 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. |
||||
* |
||||
* 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/>.
|
||||
*/ |
||||
|
||||
#ifndef UBGRAPHICSSCENE_H_ |
||||
#define UBGRAPHICSSCENE_H_ |
||||
|
||||
#include <QtGui> |
||||
|
||||
#include "frameworks/UBCoreGraphicsScene.h" |
||||
|
||||
#include "core/UB.h" |
||||
|
||||
#include "UBItem.h" |
||||
#include "tools/UBGraphicsCurtainItem.h" |
||||
|
||||
|
||||
class UBGraphicsPixmapItem; |
||||
class UBGraphicsProxyWidget; |
||||
class UBGraphicsSvgItem; |
||||
class UBGraphicsPolygonItem; |
||||
class UBGraphicsVideoItem; |
||||
class UBGraphicsAudioItem; |
||||
class UBGraphicsWidgetItem; |
||||
class UBGraphicsW3CWidgetItem; |
||||
class UBGraphicsAppleWidgetItem; |
||||
class UBGraphicsPDFItem; |
||||
class UBGraphicsTextItem; |
||||
class UBGraphicsRuler; |
||||
class UBGraphicsProtractor; |
||||
class UBGraphicsCompass; |
||||
class UBAbstractWidget; |
||||
class UBDocumentProxy; |
||||
class UBGraphicsCurtainItem; |
||||
class UBGraphicsStroke; |
||||
class UBMagnifierParams; |
||||
class UBMagnifier; |
||||
class UBGraphicsCache; |
||||
|
||||
const double PI = 4.0 * atan(1.0); |
||||
|
||||
class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
// tmp stub for divide addings scene objects from undo mechanism implementation
|
||||
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} |
||||
|
||||
UBGraphicsScene(UBDocumentProxy *parent); |
||||
virtual ~UBGraphicsScene(); |
||||
|
||||
virtual UBItem* deepCopy() const; |
||||
|
||||
UBGraphicsScene* sceneDeepCopy() const; |
||||
|
||||
void clearItemsAndAnnotations(); |
||||
void clearItems(); |
||||
void clearAnnotations(); |
||||
|
||||
bool inputDevicePress(const QPointF& scenePos, const qreal& pressure = 1.0); |
||||
bool inputDeviceMove(const QPointF& scenePos, const qreal& pressure = 1.0); |
||||
bool inputDeviceRelease(); |
||||
|
||||
void leaveEvent (QEvent* event); |
||||
|
||||
void addItem(QGraphicsItem* item); |
||||
void removeItem(QGraphicsItem* item); |
||||
|
||||
void addItems(const QSet<QGraphicsItem*>& item); |
||||
void removeItems(const QSet<QGraphicsItem*>& item); |
||||
|
||||
UBGraphicsWidgetItem* addWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsAppleWidgetItem* addAppleWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsW3CWidgetItem* addW3CWidget(const QUrl& pWidgetUrl, const QPointF& pPos = QPointF(0, 0),int widgetType = UBGraphicsItemType::W3CWidgetItemType); |
||||
void addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, const QPointF& pPos = QPointF(0, 0)); |
||||
|
||||
UBGraphicsVideoItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsAudioItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)); |
||||
|
||||
UBGraphicsTextItem* addTextWithFont(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0) |
||||
, int pointSize = -1, const QString& fontFamily = "", bool bold = false, bool italic = false); |
||||
UBGraphicsTextItem* addTextHtml(const QString &pString = QString(), const QPointF& pTopLeft = QPointF(0, 0)); |
||||
|
||||
UBGraphicsW3CWidgetItem* addOEmbed(const QUrl& pContentUrl, const QPointF& pPos = QPointF(0, 0)); |
||||
|
||||
QGraphicsItem* setAsBackgroundObject(QGraphicsItem* item, bool pAdaptTransformation = false, bool expand = false); |
||||
|
||||
QGraphicsItem* backgroundObject() const |
||||
{ |
||||
return mBackgroundObject; |
||||
} |
||||
|
||||
bool isBackgroundObject(const QGraphicsItem* item) const |
||||
{ |
||||
return item == mBackgroundObject; |
||||
} |
||||
|
||||
QGraphicsItem* scaleToFitDocumentSize(QGraphicsItem* item, bool center = false, int margin = 0, bool expand = false); |
||||
|
||||
QRectF normalizedSceneRect(qreal ratio = -1.0); |
||||
|
||||
void moveTo(const QPointF& pPoint); |
||||
void drawLineTo(const QPointF& pEndPoint, const qreal& pWidth, bool bLineStyle); |
||||
void eraseLineTo(const QPointF& pEndPoint, const qreal& pWidth); |
||||
void drawArcTo(const QPointF& pCenterPoint, qreal pSpanAngle); |
||||
|
||||
bool isEmpty() const; |
||||
|
||||
bool isModified() const |
||||
{ |
||||
return mIsModified; |
||||
} |
||||
|
||||
void setModified(bool pModified) |
||||
{ |
||||
mIsModified = pModified; |
||||
} |
||||
|
||||
void setDocument(UBDocumentProxy* pDocument); |
||||
|
||||
UBDocumentProxy* document() const |
||||
{ |
||||
return mDocument; |
||||
} |
||||
|
||||
bool isDarkBackground() const |
||||
{ |
||||
return mDarkBackground; |
||||
} |
||||
|
||||
bool isLightBackground() const |
||||
{ |
||||
return !mDarkBackground; |
||||
} |
||||
|
||||
bool isCrossedBackground() const |
||||
{ |
||||
return mCrossedBackground; |
||||
} |
||||
|
||||
void setDrawingZIndex(qreal pDrawingZIndex) |
||||
{ |
||||
mDrawingZIndex = pDrawingZIndex; |
||||
} |
||||
|
||||
void setObjectZIndex(qreal pObjectZIndex) |
||||
{ |
||||
mObjectZIndex = pObjectZIndex; |
||||
} |
||||
|
||||
bool hasBackground() |
||||
{ |
||||
return (mBackgroundObject != 0); |
||||
} |
||||
|
||||
qreal getNextObjectZIndex(); |
||||
|
||||
void addRuler(QPointF center); |
||||
void addProtractor(QPointF center); |
||||
void addCompass(QPointF center); |
||||
void addTriangle(QPointF center); |
||||
void addMagnifier(UBMagnifierParams params); |
||||
|
||||
void addMask(const QPointF ¢er = QPointF()); |
||||
void addCache(); |
||||
|
||||
QList<QGraphicsItem*> getFastAccessItems() |
||||
{ |
||||
return mFastAccessItems; |
||||
} |
||||
|
||||
class SceneViewState |
||||
{ |
||||
public: |
||||
SceneViewState() |
||||
{ |
||||
zoomFactor = 1; |
||||
horizontalPosition = 0; |
||||
verticalPostition = 0; |
||||
} |
||||
|
||||
SceneViewState(qreal pZoomFactor, int pHorizontalPosition, int pVerticalPostition) |
||||
{ |
||||
zoomFactor = pZoomFactor; |
||||
horizontalPosition = pHorizontalPosition; |
||||
verticalPostition = pVerticalPostition; |
||||
} |
||||
|
||||
qreal zoomFactor; |
||||
int horizontalPosition; |
||||
int verticalPostition; |
||||
}; |
||||
|
||||
SceneViewState viewState() const |
||||
{ |
||||
return mViewState; |
||||
} |
||||
|
||||
void setViewState(const SceneViewState& pViewState) |
||||
{ |
||||
mViewState = pViewState; |
||||
} |
||||
|
||||
virtual void setRenderingQuality(UBItem::RenderingQuality pRenderingQuality); |
||||
|
||||
QList<QUrl> relativeDependencies() const; |
||||
|
||||
QSize nominalSize(); |
||||
|
||||
void setNominalSize(const QSize& pSize); |
||||
|
||||
void setNominalSize(int pWidth, int pHeight); |
||||
|
||||
qreal currentObjectZIndex() |
||||
{ |
||||
return mObjectZIndex; |
||||
} |
||||
|
||||
enum RenderingContext |
||||
{ |
||||
Screen = 0, NonScreen, PdfExport, Podcast |
||||
}; |
||||
|
||||
void setRenderingContext(RenderingContext pRenderingContext) |
||||
{ |
||||
mRenderingContext = pRenderingContext; |
||||
} |
||||
|
||||
RenderingContext renderingContext() const |
||||
{ |
||||
return mRenderingContext; |
||||
} |
||||
|
||||
static qreal backgroundLayerStart; |
||||
static qreal objectLayerStart; |
||||
static qreal drawingLayerStart; |
||||
static qreal toolLayerStart; |
||||
|
||||
static qreal toolOffsetEraser; |
||||
static qreal toolOffsetPointer; |
||||
static qreal toolOffsetRuler; |
||||
static qreal toolOffsetProtractor; |
||||
static qreal toolOffsetCompass; |
||||
static qreal toolOffsetCurtain; |
||||
static qreal toolOffsetTriangle; |
||||
static qreal toolOffsetCache; |
||||
|
||||
QSet<QGraphicsItem*> tools(){ return mTools;} |
||||
|
||||
void registerTool(QGraphicsItem* item) |
||||
{ |
||||
mTools << item; |
||||
} |
||||
|
||||
const QPointF& previousPoint() |
||||
{ |
||||
return mPreviousPoint; |
||||
} |
||||
|
||||
public slots: |
||||
|
||||
void hideEraser(); |
||||
|
||||
void setBackground(bool pIsDark, bool pIsCrossed); |
||||
|
||||
void deselectAllItems(); |
||||
|
||||
UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false); |
||||
|
||||
void textUndoCommandAdded(UBGraphicsTextItem *textItem); |
||||
|
||||
void setToolCursor(int tool); |
||||
|
||||
void selectionChangedProcessing(); |
||||
|
||||
void moveMagnifier(QPoint newPos); |
||||
void closeMagnifier(); |
||||
void zoomInMagnifier(); |
||||
void zoomOutMagnifier(); |
||||
void resizedMagnifier(qreal newPercent); |
||||
|
||||
signals: |
||||
|
||||
void pageSizeChanged(); |
||||
|
||||
protected: |
||||
|
||||
UBGraphicsPolygonItem* lineToPolygonItem(const QLineF& pLine, const qreal& pWidth); |
||||
UBGraphicsPolygonItem* arcToPolygonItem(const QLineF& pStartRadius, qreal pSpanAngle, qreal pWidth); |
||||
UBGraphicsPolygonItem* polygonToPolygonItem(const QPolygonF pPolygon); |
||||
|
||||
void initPolygonItem(UBGraphicsPolygonItem*); |
||||
|
||||
void drawEraser(const QPointF& pEndPoint, bool isFirstDraw = false); |
||||
void drawPointer(const QPointF& pEndPoint, bool isFirstDraw = false); |
||||
void DisposeMagnifierQWidgets(); |
||||
|
||||
|
||||
virtual void keyReleaseEvent(QKeyEvent * keyEvent); |
||||
|
||||
void recolorAllItems(); |
||||
|
||||
qreal getNextDrawingZIndex(); |
||||
|
||||
virtual void drawItems (QPainter * painter, int numItems, |
||||
QGraphicsItem * items[], const QStyleOptionGraphicsItem options[], QWidget * widget = 0); |
||||
|
||||
QGraphicsItem* rootItem(QGraphicsItem* item) const; |
||||
|
||||
private: |
||||
void setDocumentUpdated(); |
||||
|
||||
qreal mDrawingZIndex; |
||||
qreal mObjectZIndex; |
||||
|
||||
QGraphicsEllipseItem* mEraser; |
||||
QGraphicsEllipseItem* mPointer; |
||||
|
||||
QSet<QGraphicsItem*> mAddedItems; |
||||
QSet<QGraphicsItem*> mRemovedItems; |
||||
|
||||
UBDocumentProxy* mDocument; |
||||
|
||||
bool mDarkBackground; |
||||
bool mCrossedBackground; |
||||
|
||||
bool mIsModified; |
||||
|
||||
QGraphicsItem* mBackgroundObject; |
||||
|
||||
QPointF mPreviousPoint; |
||||
qreal mPreviousWidth; |
||||
|
||||
QList<UBGraphicsPolygonItem*> mPreviousPolygonItems; |
||||
|
||||
SceneViewState mViewState; |
||||
|
||||
bool mInputDeviceIsPressed; |
||||
|
||||
QSet<QGraphicsItem*> mTools; |
||||
|
||||
UBGraphicsPolygonItem *mArcPolygonItem; |
||||
|
||||
QSize mNominalSize; |
||||
|
||||
RenderingContext mRenderingContext; |
||||
|
||||
UBGraphicsStroke* mCurrentStroke; |
||||
|
||||
bool mShouldUseOMP; |
||||
|
||||
int mItemCount; |
||||
|
||||
QList<QGraphicsItem*> mFastAccessItems; // a local copy as QGraphicsScene::items() is very slow in Qt 4.6
|
||||
|
||||
//int mMesure1Ms, mMesure2Ms;
|
||||
|
||||
bool mHasCache; |
||||
// tmp stub for divide addings scene objects from undo mechanism implementation
|
||||
bool enableUndoRedoStack; |
||||
|
||||
UBMagnifier *magniferControlViewWidget; |
||||
UBMagnifier *magniferDisplayViewWidget; |
||||
|
||||
|
||||
}; |
||||
|
||||
#endif /* UBGRAPHICSSCENE_H_ */ |
||||
|
Loading…
Reference in new issue