diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 16b1cf69..258c1ff8 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -102,9 +102,15 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) } connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); + connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(onToolClicked())); connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture())); + connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(onToolClicked())); connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture())); + connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(onToolClicked())); connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture())); + connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(onToolClicked())); + connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered()), this, SLOT(onToolClicked())); + connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered()), this, SLOT(onToolClicked())); connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize())); @@ -382,6 +388,7 @@ void UBDesktopAnnotationController::hideWindow() void UBDesktopAnnotationController::goToUniboard() { + onToolClicked(); hideWindow(); UBPlatformUtils::setDesktopMode(false); @@ -397,6 +404,7 @@ void UBDesktopAnnotationController::goToUniboard() void UBDesktopAnnotationController::customCapture() { + onToolClicked(); mIsFullyTransparent = true; updateBackground(); @@ -424,6 +432,7 @@ void UBDesktopAnnotationController::customCapture() void UBDesktopAnnotationController::windowCapture() { + onToolClicked(); mIsFullyTransparent = true; updateBackground(); @@ -453,6 +462,7 @@ void UBDesktopAnnotationController::windowCapture() void UBDesktopAnnotationController::screenCapture() { + onToolClicked(); mIsFullyTransparent = true; updateBackground(); @@ -539,7 +549,6 @@ void UBDesktopAnnotationController::penActionPressed() */ void UBDesktopAnnotationController::penActionReleased() { - qDebug() << "penActionReleased()"; mHoldTimerPen.stop(); if(mPendingPenButtonPressed) { @@ -594,7 +603,6 @@ void UBDesktopAnnotationController::eraserActionPressed() */ void UBDesktopAnnotationController::eraserActionReleased() { - qDebug() << "eraserActionReleased()"; mHoldTimerEraser.stop(); if(mPendingEraserButtonPressed) { @@ -651,7 +659,6 @@ void UBDesktopAnnotationController::markerActionPressed() */ void UBDesktopAnnotationController::markerActionReleased() { - qDebug() << "markerActionReleased()"; mHoldTimerMarker.stop(); if(mPendingMarkerButtonPressed) { @@ -930,3 +937,9 @@ void UBDesktopAnnotationController::refreshMask() updateMask(true); } } + +void UBDesktopAnnotationController::onToolClicked(){ + mDesktopEraserPalette->hide(); + mDesktopMarkerPalette->hide(); + mDesktopPenPalette->hide(); +} diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h index 207db94b..c98b2466 100644 --- a/src/desktop/UBDesktopAnnotationController.h +++ b/src/desktop/UBDesktopAnnotationController.h @@ -111,6 +111,7 @@ class UBDesktopAnnotationController : public QObject void onDesktopPaletteMinimize(); void onTransparentWidgetResized(); void refreshMask(); + void onToolClicked(); private: void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName); diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp index dbe0707b..4be9ee0f 100755 --- a/src/document/UBDocumentController.cpp +++ b/src/document/UBDocumentController.cpp @@ -551,8 +551,11 @@ void UBDocumentController::deleteSelectedItem() { if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString()))) { - if (proxyTi->parent() == mTrashTi) + if (proxyTi->parent() != mTrashTi) { + // We have to move document into Trash + // Select another document for processing + // This is for Board, where this document can be selected int index = proxyTi->parent()->indexOfChild(proxyTi); index --; @@ -560,7 +563,7 @@ void UBDocumentController::deleteSelectedItem() { if (proxyTi->proxy() == mBoardController->selectedDocument()) { - selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy()); + selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy(), true); } else proxyTi->parent()->child(index)->setSelected(true); @@ -569,7 +572,7 @@ void UBDocumentController::deleteSelectedItem() { if (proxyTi->proxy() == mBoardController->selectedDocument()) { - selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy()); + selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy(), true); } else proxyTi->parent()->child(1)->setSelected(true); @@ -578,30 +581,36 @@ void UBDocumentController::deleteSelectedItem() { if (proxyTi->proxy() == mBoardController->selectedDocument()) { + bool documentFound = false; for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) { QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); UBDocumentGroupTreeItem* groupItem = dynamic_cast(item); - if (groupItem != selectedDocumentGroupTreeItem() && groupItem->childCount() > 0) + if (!groupItem->isTrashFolder()) { - selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy()); - break; + for(int j=0; jchildCount(); j++) + { + if (((UBDocumentProxyTreeItem*)groupItem->child(j))->proxy() != mBoardController->selectedDocument()) + { + selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy(), true); + documentFound = true; + break; + } + } } + if (documentFound) + break; + } + if (!documentFound) + { + UBDocumentProxy *document = UBPersistenceManager::persistenceManager()->createDocument(groupTi->groupName()); + selectDocument(document, true); } } else proxyTi->parent()->setSelected(true); } - proxyTi->parent()->removeChild(proxyTi); - - UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy()); - - reloadThumbnails(); - } - else - { - // Move document to trash QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString(); proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName); UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy()); @@ -610,6 +619,14 @@ void UBDocumentController::deleteSelectedItem() mTrashTi->addChild(proxyTi); proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); } + else + { + // We have to physical delete document + // No action with selection required - document from Trash cant be selected in Board + + proxyTi->parent()->removeChild(proxyTi); + UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy()); + } } } else if (groupTi) @@ -661,20 +678,6 @@ void UBDocumentController::deleteSelectedItem() } } - if (changeCurrentDocument) - { - for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) - { - QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); - UBDocumentGroupTreeItem* groupItem = dynamic_cast(item); - if (groupItem != groupTi && groupItem->childCount() > 0) - { - selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy()); - break; - } - } - } - QList toBeDeleted; for (int i = 0; i < groupTi->childCount(); i++) @@ -712,6 +715,36 @@ void UBDocumentController::deleteSelectedItem() } } + if (changeCurrentDocument) + { + bool documentFound = false; + for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) + { + QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); + UBDocumentGroupTreeItem* groupItem = dynamic_cast(item); + if (!groupItem->isTrashFolder() && groupItem != groupTi) + { + for(int j=0; jchildCount(); j++) + { + if (((UBDocumentProxyTreeItem*)groupItem->child(j))->proxy() != mBoardController->selectedDocument()) + { + selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy(), true); + documentFound = true; + break; + } + } + } + if (documentFound) + break; + } + if (!documentFound) + { + UBDocumentProxy *document = UBPersistenceManager::persistenceManager()->createDocument( UBSettings::defaultDocumentGroupName ); + selectDocument(document, true); + } + } + + reloadThumbnails(); QApplication::restoreOverrideCursor();