From 23531e8488ec3278ea14df3d73fe913349920a63 Mon Sep 17 00:00:00 2001 From: shibakaneki Date: Tue, 21 Aug 2012 13:29:03 +0200 Subject: [PATCH] Fixed issue 962 --- src/board/UBBoardController.cpp | 5 +- src/board/UBBoardPaletteManager.cpp | 11 +- src/core/UBDocumentManager.cpp | 8 +- src/document/UBDocumentContainer.cpp | 7 + src/document/UBDocumentContainer.h | 1 + src/document/UBDocumentController.cpp | 6 +- src/gui/UBDocumentNavigator.cpp | 1 + src/gui/gui.pri | 234 ++++++++++++-------------- 8 files changed, 133 insertions(+), 140 deletions(-) diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 9ccd5bba..d5a383df 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -453,7 +453,7 @@ void UBBoardController::addScene() persistCurrentScene(); UBDocumentContainer::addPage(mActiveSceneIndex + 1); - + selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); setActiveDocumentScene(mActiveSceneIndex + 1); @@ -2282,10 +2282,9 @@ void UBBoardController::addItem() void UBBoardController::importPage() { int pageCount = selectedDocument()->pageCount(); - if (UBApplication::documentController->addFileToDocument(selectedDocument())) { - setActiveDocumentScene(pageCount); + setActiveDocumentScene(selectedDocument(), pageCount, true); } } diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index f6501393..b281a541 100644 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -347,14 +347,15 @@ void UBBoardPaletteManager::pagePaletteButtonReleased() { if( mPageButtonPressedTime.msecsTo(QTime::currentTime()) > 900) { - // The palette is reinstanciate because the duplication depends on the current scene + // The palette is reinstanciated because the duplication depends on the current scene delete(mPagePalette); mPagePalette = 0; QListpageActions; pageActions << UBApplication::mainWindow->actionNewPage; UBBoardController* boardController = UBApplication::boardController; - if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex()))) + if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex()))){ pageActions << UBApplication::mainWindow->actionDuplicatePage; + } pageActions << UBApplication::mainWindow->actionImportPage; mPagePalette = new UBActionPalette(pageActions, Qt::Horizontal , mContainer); @@ -362,8 +363,12 @@ void UBBoardPaletteManager::pagePaletteButtonReleased() mPagePalette->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); mPagePalette->groupActions(); mPagePalette->setClosable(true); - mPagePalette->adjustSizeAndPosition(); + // As we recreate the pagePalette every time, we must reconnect the slots + connect(UBApplication::mainWindow->actionNewPage, SIGNAL(triggered()), mPagePalette, SLOT(close())); + connect(UBApplication::mainWindow->actionDuplicatePage, SIGNAL(triggered()), mPagePalette, SLOT(close())); + connect(UBApplication::mainWindow->actionImportPage, SIGNAL(triggered()), mPagePalette, SLOT(close())); + connect(mPagePalette, SIGNAL(closed()), this, SLOT(pagePaletteClosed())); togglePagePalette(true); } diff --git a/src/core/UBDocumentManager.cpp b/src/core/UBDocumentManager.cpp index 9db3dbe0..b5a34af5 100644 --- a/src/core/UBDocumentManager.cpp +++ b/src/core/UBDocumentManager.cpp @@ -33,6 +33,8 @@ #include "domain/UBGraphicsPixmapItem.h" #include "document/UBDocumentProxy.h" +#include "document/UBDocumentController.h" +#include "board/UBBoardController.h" #include "UBApplication.h" #include "UBSettings.h" @@ -233,7 +235,10 @@ int UBDocumentManager::addFilesToDocument(UBDocumentProxy* document, QStringList int pageIndex = document->pageCount(); UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); importAdaptor->placeImportedItemToScene(scene, page); - UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); + UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); + + // TODO: Add an empty pixmap for the thumbnail here + UBApplication::boardController->addEmptyThumbPage(); } UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document); @@ -297,7 +302,6 @@ QList UBDocumentManager::supportedExportAdaptors() return mExportAdaptors; } - void UBDocumentManager::emitDocumentUpdated(UBDocumentProxy* pDocument) { emit documentUpdated(pDocument); diff --git a/src/document/UBDocumentContainer.cpp b/src/document/UBDocumentContainer.cpp index 4f08cd46..ce8549a7 100644 --- a/src/document/UBDocumentContainer.cpp +++ b/src/document/UBDocumentContainer.cpp @@ -114,6 +114,7 @@ void UBDocumentContainer::reloadThumbnails() if (mCurrentDocument) { UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs); + qDebug() << "Reloading Thumbnails. new mDocumentThumbs size: " << mDocumentThumbs.size(); emit documentThumbnailsUpdated(this); } } @@ -131,3 +132,9 @@ int UBDocumentContainer::sceneIndexFromPage(int page) return page; return page-1; } + +void UBDocumentContainer::addEmptyThumbPage() +{ + const QPixmap* pThumb = new QPixmap(); + mDocumentThumbs.append(pThumb); +} diff --git a/src/document/UBDocumentContainer.h b/src/document/UBDocumentContainer.h index 6e969b83..b1c2aba1 100644 --- a/src/document/UBDocumentContainer.h +++ b/src/document/UBDocumentContainer.h @@ -41,6 +41,7 @@ class UBDocumentContainer : public QObject void deletePages(QList& pageIndexes); void addPage(int index); void updatePage(int index); + void addEmptyThumbPage(); private: void deleteThumbPage(int index); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index 3ed2ed2d..dbe0707b 100755 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -992,8 +992,7 @@ void UBDocumentController::addFileToDocument() bool UBDocumentController::addFileToDocument(UBDocumentProxy* document) { QString defaultPath = UBSettings::settings()->lastImportFilePath->get().toString(); - QString filePath = QFileDialog::getOpenFileName(mParentWidget, tr("Open Supported File") - , defaultPath, UBDocumentManager::documentManager()->importFileFilter()); + QString filePath = QFileDialog::getOpenFileName(mParentWidget, tr("Open Supported File"), defaultPath, UBDocumentManager::documentManager()->importFileFilter()); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::processEvents(); @@ -1005,7 +1004,8 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document) if (filePath.length() > 0) { - QApplication::processEvents(); + QApplication::processEvents(); // NOTE: We performed this just a few lines before. Is it really necessary to do it again here?? + QFile selectedFile(filePath); showMessage(tr("Importing file %1...").arg(fileInfo.baseName()), true); diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index d2e81572..bac3ea61 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -84,6 +84,7 @@ void UBDocumentNavigator::generateThumbnails(UBDocumentContainer* source) for(int i = 0; i < source->selectedDocument()->pageCount(); i++) { + qDebug() << "source->selectedDocument()->pageCount: " << source->selectedDocument()->pageCount() << ", source->pageCount: " << source->pageCount() << ", source->pageAt(" << i << ")"; const QPixmap* pix = source->pageAt(i); UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(*pix, source->selectedDocument(), i); int pageIndex = UBDocumentContainer::pageFromSceneIndex(i); diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 61583d04..aa952a76 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -1,135 +1,111 @@ - -HEADERS += src/gui/UBThumbnailView.h \ - src/gui/UBFloatingPalette.h \ - src/gui/UBToolbarButtonGroup.h \ - src/gui/UBStylusPalette.h \ - src/gui/UBIconButton.h \ - src/gui/UBThumbnailWidget.h \ - src/gui/UBCircleFrame.h \ - src/gui/UBColorPicker.h \ - src/gui/UBWidgetMirror.h \ - src/gui/UBScreenMirror.h \ - src/gui/UBResources.h \ - src/gui/UBMessageWindow.h \ - src/gui/UBDocumentThumbnailWidget.h \ - src/gui/UBDocumentTreeWidget.h \ - src/gui/UBMousePressFilter.h \ - src/gui/UBBlackoutWidget.h \ - src/gui/UBMainWindow.h \ - src/gui/UBToolWidget.h \ - src/gui/UBSpinningWheel.h \ - src/gui/UBZoomPalette.h \ - src/gui/UBRubberBand.h \ - src/gui/UBDocumentToolsPalette.h \ - src/gui/UBWebToolsPalette.h \ - src/gui/UBVideoPlayer.h \ - src/gui/UBActionPalette.h \ - src/gui/UBFavoriteToolPalette.h \ - src/gui/UBKeyboardPalette.h \ - src/gui/UBNavigatorPalette.h \ - src/gui/UBDocumentNavigator.h \ - src/gui/UBDockPalette.h \ - src/gui/UBPropertyPalette.h \ - src/gui/UBLibNavigatorWidget.h \ - src/gui/UBLibItemProperties.h \ - src/gui/UBLibActionBar.h \ - src/gui/UBLibraryWidget.h \ - src/gui/UBLibPathViewer.h \ - src/gui/UBUpdateDlg.h \ - src/gui/UBDockPaletteWidget.h \ - src/gui/UBLeftPalette.h \ - src/gui/UBRightPalette.h \ - src/gui/UBPageNavigationWidget.h \ - src/gui/UBLibWidget.h \ - src/gui/UBMagnifer.h \ - src/gui/UBCachePropertiesWidget.h \ - src/gui/UBLibWebView.h \ - src/gui/UBDownloadWidget.h \ - src/gui/UBDockDownloadWidget.h \ - src/gui/UBFeaturesWidget.h \ - src/gui/UBFeaturesActionBar.h \ +HEADERS += src/gui/UBThumbnailView.h \ + src/gui/UBFloatingPalette.h \ + src/gui/UBToolbarButtonGroup.h \ + src/gui/UBStylusPalette.h \ + src/gui/UBIconButton.h \ + src/gui/UBThumbnailWidget.h \ + src/gui/UBCircleFrame.h \ + src/gui/UBColorPicker.h \ + src/gui/UBWidgetMirror.h \ + src/gui/UBScreenMirror.h \ + src/gui/UBResources.h \ + src/gui/UBMessageWindow.h \ + src/gui/UBDocumentThumbnailWidget.h \ + src/gui/UBDocumentTreeWidget.h \ + src/gui/UBMousePressFilter.h \ + src/gui/UBBlackoutWidget.h \ + src/gui/UBMainWindow.h \ + src/gui/UBToolWidget.h \ + src/gui/UBSpinningWheel.h \ + src/gui/UBZoomPalette.h \ + src/gui/UBRubberBand.h \ + src/gui/UBDocumentToolsPalette.h \ + src/gui/UBWebToolsPalette.h \ + src/gui/UBVideoPlayer.h \ + src/gui/UBActionPalette.h \ + src/gui/UBFavoriteToolPalette.h \ + src/gui/UBKeyboardPalette.h \ + src/gui/UBNavigatorPalette.h \ + src/gui/UBDocumentNavigator.h \ + src/gui/UBDockPalette.h \ + src/gui/UBPropertyPalette.h \ + src/gui/UBLibNavigatorWidget.h \ + src/gui/UBLibItemProperties.h \ + src/gui/UBLibActionBar.h \ + src/gui/UBLibraryWidget.h \ + src/gui/UBLibPathViewer.h \ + src/gui/UBUpdateDlg.h \ + src/gui/UBDockPaletteWidget.h \ + src/gui/UBLeftPalette.h \ + src/gui/UBRightPalette.h \ + src/gui/UBPageNavigationWidget.h \ + src/gui/UBLibWidget.h \ + src/gui/UBMagnifer.h \ + src/gui/UBCachePropertiesWidget.h \ + src/gui/UBLibWebView.h \ + src/gui/UBDownloadWidget.h \ + src/gui/UBDockDownloadWidget.h \ + src/gui/UBFeaturesWidget.h \ + src/gui/UBFeaturesActionBar.h \ src/gui/UBDockTeacherGuideWidget.h \ src/gui/UBTeacherGuideWidget.h \ src/gui/UBTeacherGuideWidgetsTools.h \ - src/gui/UBMessagesDialog.h - -SOURCES += src/gui/UBThumbnailView.cpp \ - src/gui/UBFloatingPalette.cpp \ - src/gui/UBToolbarButtonGroup.cpp \ - src/gui/UBStylusPalette.cpp \ - src/gui/UBIconButton.cpp \ - src/gui/UBThumbnailWidget.cpp \ - src/gui/UBCircleFrame.cpp \ - src/gui/UBColorPicker.cpp \ - src/gui/UBWidgetMirror.cpp \ - src/gui/UBScreenMirror.cpp \ - src/gui/UBResources.cpp \ - src/gui/UBMessageWindow.cpp \ - src/gui/UBDocumentThumbnailWidget.cpp \ - src/gui/UBDocumentTreeWidget.cpp \ - src/gui/UBMousePressFilter.cpp \ - src/gui/UBBlackoutWidget.cpp \ - src/gui/UBMainWindow.cpp \ - src/gui/UBToolWidget.cpp \ - src/gui/UBSpinningWheel.cpp \ - src/gui/UBZoomPalette.cpp \ - src/gui/UBRubberBand.cpp \ - src/gui/UBDocumentToolsPalette.cpp \ - src/gui/UBWebToolsPalette.cpp \ - src/gui/UBVideoPlayer.cpp \ - src/gui/UBActionPalette.cpp \ - src/gui/UBFavoriteToolPalette.cpp \ - src/gui/UBKeyboardPalette.cpp \ - src/gui/UBNavigatorPalette.cpp \ - src/gui/UBDocumentNavigator.cpp \ - src/gui/UBDockPalette.cpp \ - src/gui/UBPropertyPalette.cpp \ - src/gui/UBLibNavigatorWidget.cpp \ - src/gui/UBLibItemProperties.cpp \ - src/gui/UBLibActionBar.cpp \ - src/gui/UBLibraryWidget.cpp \ - src/gui/UBLibPathViewer.cpp \ - src/gui/UBUpdateDlg.cpp \ - src/gui/UBDockPaletteWidget.cpp \ - src/gui/UBLeftPalette.cpp \ - src/gui/UBRightPalette.cpp \ - src/gui/UBPageNavigationWidget.cpp \ - src/gui/UBLibWidget.cpp \ - src/gui/UBMagnifer.cpp \ - src/gui/UBCachePropertiesWidget.cpp \ - src/gui/UBLibWebView.cpp \ - src/gui/UBDownloadWidget.cpp \ - src/gui/UBDockDownloadWidget.cpp \ - src/gui/UBFeaturesWidget.cpp \ - src/gui/UBFeaturesActionBar.cpp \ + src/gui/UBMessagesDialog.h +SOURCES += src/gui/UBThumbnailView.cpp \ + src/gui/UBFloatingPalette.cpp \ + src/gui/UBToolbarButtonGroup.cpp \ + src/gui/UBStylusPalette.cpp \ + src/gui/UBIconButton.cpp \ + src/gui/UBThumbnailWidget.cpp \ + src/gui/UBCircleFrame.cpp \ + src/gui/UBColorPicker.cpp \ + src/gui/UBWidgetMirror.cpp \ + src/gui/UBScreenMirror.cpp \ + src/gui/UBResources.cpp \ + src/gui/UBMessageWindow.cpp \ + src/gui/UBDocumentThumbnailWidget.cpp \ + src/gui/UBDocumentTreeWidget.cpp \ + src/gui/UBMousePressFilter.cpp \ + src/gui/UBBlackoutWidget.cpp \ + src/gui/UBMainWindow.cpp \ + src/gui/UBToolWidget.cpp \ + src/gui/UBSpinningWheel.cpp \ + src/gui/UBZoomPalette.cpp \ + src/gui/UBRubberBand.cpp \ + src/gui/UBDocumentToolsPalette.cpp \ + src/gui/UBWebToolsPalette.cpp \ + src/gui/UBVideoPlayer.cpp \ + src/gui/UBActionPalette.cpp \ + src/gui/UBFavoriteToolPalette.cpp \ + src/gui/UBKeyboardPalette.cpp \ + src/gui/UBNavigatorPalette.cpp \ + src/gui/UBDocumentNavigator.cpp \ + src/gui/UBDockPalette.cpp \ + src/gui/UBPropertyPalette.cpp \ + src/gui/UBLibNavigatorWidget.cpp \ + src/gui/UBLibItemProperties.cpp \ + src/gui/UBLibActionBar.cpp \ + src/gui/UBLibraryWidget.cpp \ + src/gui/UBLibPathViewer.cpp \ + src/gui/UBUpdateDlg.cpp \ + src/gui/UBDockPaletteWidget.cpp \ + src/gui/UBLeftPalette.cpp \ + src/gui/UBRightPalette.cpp \ + src/gui/UBPageNavigationWidget.cpp \ + src/gui/UBLibWidget.cpp \ + src/gui/UBMagnifer.cpp \ + src/gui/UBCachePropertiesWidget.cpp \ + src/gui/UBLibWebView.cpp \ + src/gui/UBDownloadWidget.cpp \ + src/gui/UBDockDownloadWidget.cpp \ + src/gui/UBFeaturesWidget.cpp \ + src/gui/UBFeaturesActionBar.cpp \ src/gui/UBDockTeacherGuideWidget.cpp \ src/gui/UBTeacherGuideWidget.cpp \ src/gui/UBTeacherGuideWidgetsTools.cpp \ - src/gui/UBMessagesDialog.cpp - -win32 { - - SOURCES += src/gui/UBKeyboardPalette_win.cpp - -} - - -macx { - - SOURCES += src/gui/UBKeyboardPalette_mac.cpp -} - - -linux-g++ { - - SOURCES += src/gui/UBKeyboardPalette_linux.cpp -} - -linux-g++-32 { - - SOURCES += src/gui/UBKeyboardPalette_linux.cpp -} -linux-g++-64 { - - SOURCES += src/gui/UBKeyboardPalette_linux.cpp -} + src/gui/UBMessagesDialog.cpp +win32:SOURCES += src/gui/UBKeyboardPalette_win.cpp +macx:SOURCES += src/gui/UBKeyboardPalette_mac.cpp +linux-g++:SOURCES += src/gui/UBKeyboardPalette_linux.cpp +linux-g++-32:SOURCES += src/gui/UBKeyboardPalette_linux.cpp +linux-g++-64:SOURCES += src/gui/UBKeyboardPalette_linux.cpp