Anatoly Mihalchenko 13 years ago
parent 9fcd791c39
commit bff3e8343d
  1. 50
      src/board/UBBoardController.cpp
  2. 6
      src/board/UBBoardController.h
  3. 15
      src/core/UBApplication.cpp
  4. 2
      src/core/UBApplication.h
  5. 31
      src/domain/UBGraphicsItemUndoCommand.cpp
  6. 2
      src/domain/UBGraphicsScene.cpp
  7. 5
      src/domain/UBGraphicsScene.h

@ -351,15 +351,27 @@ void UBBoardController::connectToolbar()
connect(mMainWindow->actionEraseItems, SIGNAL(triggered()), this, SLOT(clearSceneItems())); connect(mMainWindow->actionEraseItems, SIGNAL(triggered()), this, SLOT(clearSceneItems()));
connect(mMainWindow->actionEraseAnnotations, SIGNAL(triggered()), this, SLOT(clearSceneAnnotation())); connect(mMainWindow->actionEraseAnnotations, SIGNAL(triggered()), this, SLOT(clearSceneAnnotation()));
//connect(mMainWindow->actionUndo, SIGNAL(triggered()), this, SLOT(stopScript()));
connect(mMainWindow->actionUndo, SIGNAL(triggered()), UBApplication::undoStack, SLOT(undo())); connect(mMainWindow->actionUndo, SIGNAL(triggered()), UBApplication::undoStack, SLOT(undo()));
connect(mMainWindow->actionRedo, SIGNAL(triggered()), UBApplication::undoStack, SLOT(redo())); connect(mMainWindow->actionRedo, SIGNAL(triggered()), UBApplication::undoStack, SLOT(redo()));
connect(mMainWindow->actionRedo, SIGNAL(triggered()), this, SLOT(startScript()));
connect(mMainWindow->actionBack, SIGNAL( triggered()), this, SLOT(previousScene())); connect(mMainWindow->actionBack, SIGNAL( triggered()), this, SLOT(previousScene()));
connect(mMainWindow->actionForward, SIGNAL(triggered()), this, SLOT(nextScene())); connect(mMainWindow->actionForward, SIGNAL(triggered()), this, SLOT(nextScene()));
connect(mMainWindow->actionSleep, SIGNAL(triggered()), this, SLOT(stopScript()));
connect(mMainWindow->actionSleep, SIGNAL(triggered()), this, SLOT(blackout())); connect(mMainWindow->actionSleep, SIGNAL(triggered()), this, SLOT(blackout()));
connect(mMainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool))); connect(mMainWindow->actionVirtualKeyboard, SIGNAL(triggered(bool)), this, SLOT(showKeyboard(bool)));
connect(mMainWindow->actionImportPage, SIGNAL(triggered()), this, SLOT(importPage())); connect(mMainWindow->actionImportPage, SIGNAL(triggered()), this, SLOT(importPage()));
} }
void UBBoardController::startScript()
{
freezeW3CWidgets(false);
}
void UBBoardController::stopScript()
{
freezeW3CWidgets(true);
}
void UBBoardController::initToolbarTexts() void UBBoardController::initToolbarTexts()
{ {
@ -515,6 +527,7 @@ void UBBoardController::clearScene()
{ {
if (mActiveScene) if (mActiveScene)
{ {
freezeW3CWidgets(true);
mActiveScene->clearItemsAndAnnotations(); mActiveScene->clearItemsAndAnnotations();
updateActionStates(); updateActionStates();
} }
@ -525,6 +538,7 @@ void UBBoardController::clearSceneItems()
{ {
if (mActiveScene) if (mActiveScene)
{ {
freezeW3CWidgets(true);
mActiveScene->clearItems(); mActiveScene->clearItems();
updateActionStates(); updateActionStates();
} }
@ -1134,6 +1148,8 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
if (targetScene) if (targetScene)
{ {
freezeW3CWidgets(true);
if(sceneChange) if(sceneChange)
emit activeSceneWillChange(); emit activeSceneWillChange();
@ -1155,6 +1171,8 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
UBSettings::settings()->setDarkBackground(mActiveScene->isDarkBackground()); UBSettings::settings()->setDarkBackground(mActiveScene->isDarkBackground());
UBSettings::settings()->setCrossedBackground(mActiveScene->isCrossedBackground()); UBSettings::settings()->setCrossedBackground(mActiveScene->isCrossedBackground());
freezeW3CWidgets(false);
} }
selectionChanged(); selectionChanged();
@ -1793,7 +1811,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
newUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(mActiveDocument, pUrl.toLocalFile(), uuid)); newUrl = QUrl::fromLocalFile(UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(mActiveDocument, pUrl.toLocalFile(), uuid));
w3cWidgetItem = mActiveScene->addW3CWidget(newUrl, pos); w3cWidgetItem = mActiveScene->addW3CWidget(pUrl, pos);
if (w3cWidgetItem) { if (w3cWidgetItem) {
w3cWidgetItem->setUuid(uuid); w3cWidgetItem->setUuid(uuid);
@ -2093,7 +2111,7 @@ void UBBoardController::addItem()
QString filename = QFileDialog::getOpenFileName(mControlContainer, tr("Add Item"), QString filename = QFileDialog::getOpenFileName(mControlContainer, tr("Add Item"),
defaultPath, defaultPath,
tr("All Supported (%1)").arg(extensions)); tr("All Supported (%1)").arg(extensions), NULL, QFileDialog::DontUseNativeDialog);
if (filename.length() > 0) if (filename.length() > 0)
{ {
@ -2127,3 +2145,31 @@ void UBBoardController::displayMetaData(QMap<QString, QString> metadatas)
{ {
emit displayMetadata(metadatas); emit displayMetadata(metadatas);
} }
void UBBoardController::freezeW3CWidgets(bool freeze)
{
if (mActiveSceneIndex >= 0)
{
QList<QGraphicsItem *> list = UBApplication::boardController->activeScene()->getFastAccessItems();
foreach(QGraphicsItem *item, list)
{
freezeW3CWidget(item, freeze);
}
}
}
void UBBoardController::freezeW3CWidget(QGraphicsItem *item, bool freeze)
{
if(item->type() == UBGraphicsW3CWidgetItem::Type)
{
QString scriptString;
if (freeze)
scriptString = "setfreezed(true);";
else
scriptString = "setfreezed(false);";
UBGraphicsW3CWidgetItem* item_casted = dynamic_cast<UBGraphicsW3CWidgetItem*>(item);
if (0 == item_casted)
return;
item_casted->widgetWebView()->page()->mainFrame()->evaluateJavaScript(scriptString);
}
}

@ -153,7 +153,6 @@ class UBBoardController : public QObject
void ClearUndoStack(); void ClearUndoStack();
public slots: public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
void showDocumentsDialog(); void showDocumentsDialog();
@ -210,6 +209,11 @@ class UBBoardController : public QObject
void moveToolWidgetToScene(UBToolWidget* toolWidget); void moveToolWidgetToScene(UBToolWidget* toolWidget);
void addItem(); void addItem();
void freezeW3CWidgets(bool freeze);
void freezeW3CWidget(QGraphicsItem* item, bool freeze);
void startScript();
void stopScript();
signals: signals:
void activeSceneWillBePersisted(); void activeSceneWillBePersisted();
void activeSceneWillChange(); void activeSceneWillChange();

@ -237,8 +237,11 @@ int UBApplication::exec(const QString& pFileToImport)
mainWindow->actionCut->setShortcuts(QKeySequence::Cut); mainWindow->actionCut->setShortcuts(QKeySequence::Cut);
connect(mainWindow->actionBoard, SIGNAL(triggered()), this, SLOT(showBoard())); connect(mainWindow->actionBoard, SIGNAL(triggered()), this, SLOT(showBoard()));
connect(mainWindow->actionBoard, SIGNAL(triggered()), this, SLOT(startScript()));
connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(showInternet())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(showInternet()));
connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(stopScript()));
connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(showDocument())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(showDocument()));
connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(stopScript()));
connect(mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(closing())); connect(mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(closing()));
connect(mainWindow, SIGNAL(closeEvent_Signal(QCloseEvent*)), this, SLOT(closeEvent(QCloseEvent*))); connect(mainWindow, SIGNAL(closeEvent_Signal(QCloseEvent*)), this, SLOT(closeEvent(QCloseEvent*)));
@ -262,6 +265,7 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), applicationController, SLOT(showDesktop(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), applicationController, SLOT(showDesktop(bool)));
connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), this, SLOT(stopScript()));
#ifndef Q_WS_MAC #ifndef Q_WS_MAC
connect(mainWindow->actionHideApplication, SIGNAL(triggered()), mainWindow, SLOT(showMinimized())); connect(mainWindow->actionHideApplication, SIGNAL(triggered()), mainWindow, SLOT(showMinimized()));
#else #else
@ -274,6 +278,7 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show()));
connect(mainWindow->actionTutorial, SIGNAL(triggered()), applicationController, SLOT(showTutorial())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), applicationController, SLOT(showTutorial()));
connect(mainWindow->actionTutorial, SIGNAL(triggered()), this, SLOT(stopScript()));
connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor())); connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor()));
connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest()));
@ -353,6 +358,16 @@ void UBApplication::showMinimized()
#endif #endif
void UBApplication::startScript()
{
this->boardController->freezeW3CWidgets(false);
}
void UBApplication::stopScript()
{
this->boardController->freezeW3CWidgets(true);
}
void UBApplication::showBoard() void UBApplication::showBoard()
{ {
applicationController->showBoard(); applicationController->showBoard();

@ -98,6 +98,8 @@ class UBApplication : public QtSingleApplication
void showBoard(); void showBoard();
void showInternet(); void showInternet();
void showDocument(); void showDocument();
void startScript();
void stopScript();
void toolBarPositionChanged(QVariant topOrBottom); void toolBarPositionChanged(QVariant topOrBottom);
void toolBarDisplayTextChanged(QVariant display); void toolBarDisplayTextChanged(QVariant display);

@ -21,6 +21,9 @@
#include "core/memcheck.h" #include "core/memcheck.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems,
const QSet<QGraphicsItem*>& pAddedItems) const QSet<QGraphicsItem*>& pAddedItems)
@ -29,6 +32,18 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, co
, mAddedItems(pAddedItems - pRemovedItems) , mAddedItems(pAddedItems - pRemovedItems)
{ {
mFirstRedo = true; 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, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem,
@ -37,10 +52,16 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QG
{ {
if (pRemovedItem) if (pRemovedItem)
{
mRemovedItems.insert(pRemovedItem); mRemovedItems.insert(pRemovedItem);
UBApplication::boardController->freezeW3CWidget(pRemovedItem, true);
}
if (pAddedItem) if (pAddedItem)
{
mAddedItems.insert(pAddedItem); mAddedItems.insert(pAddedItem);
UBApplication::boardController->freezeW3CWidget(pAddedItem, false);
}
mFirstRedo = true; mFirstRedo = true;
@ -63,12 +84,15 @@ void UBGraphicsItemUndoCommand::undo()
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
item->setSelected(false); item->setSelected(false);
mScene->removeItem(item); mScene->removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true);
} }
QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems); QSetIterator<QGraphicsItem*> itRemoved(mRemovedItems);
while (itRemoved.hasNext()) while (itRemoved.hasNext())
{ {
mScene->addItem(itRemoved.next()); 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 // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
@ -92,12 +116,15 @@ void UBGraphicsItemUndoCommand::redo()
QGraphicsItem* item = itRemoved.next(); QGraphicsItem* item = itRemoved.next();
item->setSelected(false); item->setSelected(false);
mScene->removeItem(item); mScene->removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true);
} }
QSetIterator<QGraphicsItem*> itAdded(mAddedItems); QSetIterator<QGraphicsItem*> itAdded(mAddedItems);
while (itAdded.hasNext()) while (itAdded.hasNext())
{ {
mScene->addItem(itAdded.next()); 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 // force refresh, QT is a bit lazy and take a lot of time (nb item ^2) to trigger repaint

@ -141,8 +141,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
} }
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
} }
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()

@ -178,6 +178,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void addMask(const QPointF &center = QPointF()); void addMask(const QPointF &center = QPointF());
void addCache(); void addCache();
QList<QGraphicsItem*> getFastAccessItems()
{
return mFastAccessItems;
}
class SceneViewState class SceneViewState
{ {
public: public:

Loading…
Cancel
Save