workaround to adress badly attached thumbnail views (no more time to investigate on it...) + prevent overwriting scenes

preferencesAboutTextFull
Clément Fauconnier 7 years ago
parent 68521209c3
commit 0fd15f62a4
  1. 14
      src/board/UBBoardController.cpp
  2. 2
      src/document/UBDocumentContainer.cpp
  3. 1
      src/document/UBDocumentContainer.h
  4. 17
      src/gui/UBBoardThumbnailsView.cpp
  5. 1
      src/gui/UBBoardThumbnailsView.h

@ -1536,11 +1536,11 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
ClearUndoStack(); ClearUndoStack();
persistCurrentScene(); //previous scene
mActiveScene = targetScene; mActiveScene = targetScene;
mActiveSceneIndex = index; mActiveSceneIndex = index;
persistCurrentScene();
setDocument(pDocumentProxy, forceReload); setDocument(pDocumentProxy, forceReload);
updateSystemScaleFactor(); updateSystemScaleFactor();
@ -1556,6 +1556,8 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
adjustDisplayViews(); adjustDisplayViews();
persistCurrentScene(); //new scene
UBSettings::settings()->setDarkBackground(mActiveScene->isDarkBackground()); UBSettings::settings()->setDarkBackground(mActiveScene->isDarkBackground());
UBSettings::settings()->setPageBackground(mActiveScene->pageBackground()); UBSettings::settings()->setPageBackground(mActiveScene->pageBackground());
@ -1567,10 +1569,18 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
updateBackgroundActionsState(mActiveScene->isDarkBackground(), mActiveScene->pageBackground()); updateBackgroundActionsState(mActiveScene->isDarkBackground(), mActiveScene->pageBackground());
if(documentChange) if(documentChange)
{
UBGraphicsTextItem::lastUsedTextColor = QColor(); UBGraphicsTextItem::lastUsedTextColor = QColor();
emit initThumbnailRequired(this);
}
if (sceneChange) if (sceneChange)
{
emit activeSceneChanged(); emit activeSceneChanged();
//should not be necessary, but if not called, sometimes, some views are not "connected" the first time the document is loaded
//this is a workaround to adress unexpectedly badly attached thumbnail views (no more time to investigate on it...)
emit reloadThumbnailRequired(this, mActiveSceneIndex);
}
} }

@ -92,7 +92,7 @@ void UBDocumentContainer::deletePages(QList<int>& pageIndexes)
offset++; offset++;
} }
emit documentThumbnailsUpdated(this);
} }
void UBDocumentContainer::addPage(int index) void UBDocumentContainer::addPage(int index)

@ -80,6 +80,7 @@ class UBDocumentContainer : public QObject
void addThumbnailRequired(UBDocumentContainer* source, int index); void addThumbnailRequired(UBDocumentContainer* source, int index);
void removeThumbnailRequired(int index); void removeThumbnailRequired(int index);
void moveThumbnailRequired(int from, int to); void moveThumbnailRequired(int from, int to);
void reloadThumbnailRequired(UBDocumentContainer* source, int index);
void documentThumbnailsUpdated(UBDocumentContainer* source); void documentThumbnailsUpdated(UBDocumentContainer* source);
}; };

@ -78,6 +78,7 @@ UBBoardThumbnailsView::UBBoardThumbnailsView(QWidget *parent, const char *name)
connect(UBApplication::boardController, SIGNAL(addThumbnailRequired(UBDocumentContainer*, int)), this, SLOT(addThumbnail(UBDocumentContainer*, int)), Qt::UniqueConnection); connect(UBApplication::boardController, SIGNAL(addThumbnailRequired(UBDocumentContainer*, int)), this, SLOT(addThumbnail(UBDocumentContainer*, int)), Qt::UniqueConnection);
connect(UBApplication::boardController, SIGNAL(moveThumbnailRequired(int, int)), this, SLOT(moveThumbnail(int, int)), Qt::UniqueConnection); connect(UBApplication::boardController, SIGNAL(moveThumbnailRequired(int, int)), this, SLOT(moveThumbnail(int, int)), Qt::UniqueConnection);
connect(this, SIGNAL(moveThumbnailRequired(int, int)), this, SLOT(moveThumbnail(int, int)), Qt::UniqueConnection); connect(this, SIGNAL(moveThumbnailRequired(int, int)), this, SLOT(moveThumbnail(int, int)), Qt::UniqueConnection);
connect(UBApplication::boardController, SIGNAL(reloadThumbnailRequired(UBDocumentContainer*, int)), this, SLOT(reloadThumbnail(UBDocumentContainer*, int)), Qt::UniqueConnection);
connect(UBApplication::boardController, SIGNAL(removeThumbnailRequired(int)), this, SLOT(removeThumbnail(int)), Qt::UniqueConnection); connect(UBApplication::boardController, SIGNAL(removeThumbnailRequired(int)), this, SLOT(removeThumbnail(int)), Qt::UniqueConnection);
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressTimeout()), Qt::UniqueConnection); connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressTimeout()), Qt::UniqueConnection);
@ -94,6 +95,13 @@ void UBBoardThumbnailsView::moveThumbnail(int from, int to)
updateThumbnailsPos(); updateThumbnailsPos();
} }
void UBBoardThumbnailsView::reloadThumbnail(UBDocumentContainer* source, int index)
{
removeThumbnail(index);
addThumbnail(source, index);
}
void UBBoardThumbnailsView::removeThumbnail(int i) void UBBoardThumbnailsView::removeThumbnail(int i)
{ {
UBDraggableThumbnailView* item = mThumbnails.at(i); UBDraggableThumbnailView* item = mThumbnails.at(i);
@ -127,7 +135,12 @@ void UBBoardThumbnailsView::addThumbnail(UBDocumentContainer* source, int i)
void UBBoardThumbnailsView::clearThumbnails() void UBBoardThumbnailsView::clearThumbnails()
{ {
qDeleteAll(mThumbnails); for(int i = 0; i < mThumbnails.size(); i++)
{
scene()->removeItem(mThumbnails.at(i)->pageNumber());
scene()->removeItem(mThumbnails.at(i));
mThumbnails.at(i)->deleteLater();
}
mThumbnails.clear(); mThumbnails.clear();
} }
@ -211,7 +224,7 @@ void UBBoardThumbnailsView::mousePressAndHoldEvent(QPoint pos)
drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2)); drag->setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2));
drag->exec(); drag->exec();
} }
} }
void UBBoardThumbnailsView::mouseReleaseEvent(QMouseEvent *event) void UBBoardThumbnailsView::mouseReleaseEvent(QMouseEvent *event)

@ -50,6 +50,7 @@ public slots:
void clearThumbnails(); void clearThumbnails();
void initThumbnails(UBDocumentContainer* source); void initThumbnails(UBDocumentContainer* source);
void addThumbnail(UBDocumentContainer* source, int i); void addThumbnail(UBDocumentContainer* source, int i);
void reloadThumbnail(UBDocumentContainer* source, int i);
void moveThumbnail(int from, int to); void moveThumbnail(int from, int to);
void removeThumbnail(int i); void removeThumbnail(int i);

Loading…
Cancel
Save