Merge branch 'develop' of github.com:Sankore/Sankore-3.1 into develop

preferencesAboutTextFull
Aleksei Kanash 12 years ago
commit 573d6c4d68
  1. 19
      src/desktop/UBDesktopAnnotationController.cpp
  2. 1
      src/desktop/UBDesktopAnnotationController.h
  3. 91
      src/document/UBDocumentController.cpp

@ -102,9 +102,15 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
} }
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard())); 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(customCapture()));
connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(onToolClicked()));
connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture())); 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(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(maximized()), this, SLOT(onDesktopPaletteMaximized()));
connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize()));
@ -382,6 +388,7 @@ void UBDesktopAnnotationController::hideWindow()
void UBDesktopAnnotationController::goToUniboard() void UBDesktopAnnotationController::goToUniboard()
{ {
onToolClicked();
hideWindow(); hideWindow();
UBPlatformUtils::setDesktopMode(false); UBPlatformUtils::setDesktopMode(false);
@ -397,6 +404,7 @@ void UBDesktopAnnotationController::goToUniboard()
void UBDesktopAnnotationController::customCapture() void UBDesktopAnnotationController::customCapture()
{ {
onToolClicked();
mIsFullyTransparent = true; mIsFullyTransparent = true;
updateBackground(); updateBackground();
@ -424,6 +432,7 @@ void UBDesktopAnnotationController::customCapture()
void UBDesktopAnnotationController::windowCapture() void UBDesktopAnnotationController::windowCapture()
{ {
onToolClicked();
mIsFullyTransparent = true; mIsFullyTransparent = true;
updateBackground(); updateBackground();
@ -453,6 +462,7 @@ void UBDesktopAnnotationController::windowCapture()
void UBDesktopAnnotationController::screenCapture() void UBDesktopAnnotationController::screenCapture()
{ {
onToolClicked();
mIsFullyTransparent = true; mIsFullyTransparent = true;
updateBackground(); updateBackground();
@ -539,7 +549,6 @@ void UBDesktopAnnotationController::penActionPressed()
*/ */
void UBDesktopAnnotationController::penActionReleased() void UBDesktopAnnotationController::penActionReleased()
{ {
qDebug() << "penActionReleased()";
mHoldTimerPen.stop(); mHoldTimerPen.stop();
if(mPendingPenButtonPressed) if(mPendingPenButtonPressed)
{ {
@ -594,7 +603,6 @@ void UBDesktopAnnotationController::eraserActionPressed()
*/ */
void UBDesktopAnnotationController::eraserActionReleased() void UBDesktopAnnotationController::eraserActionReleased()
{ {
qDebug() << "eraserActionReleased()";
mHoldTimerEraser.stop(); mHoldTimerEraser.stop();
if(mPendingEraserButtonPressed) if(mPendingEraserButtonPressed)
{ {
@ -651,7 +659,6 @@ void UBDesktopAnnotationController::markerActionPressed()
*/ */
void UBDesktopAnnotationController::markerActionReleased() void UBDesktopAnnotationController::markerActionReleased()
{ {
qDebug() << "markerActionReleased()";
mHoldTimerMarker.stop(); mHoldTimerMarker.stop();
if(mPendingMarkerButtonPressed) if(mPendingMarkerButtonPressed)
{ {
@ -930,3 +937,9 @@ void UBDesktopAnnotationController::refreshMask()
updateMask(true); updateMask(true);
} }
} }
void UBDesktopAnnotationController::onToolClicked(){
mDesktopEraserPalette->hide();
mDesktopMarkerPalette->hide();
mDesktopPenPalette->hide();
}

@ -111,6 +111,7 @@ class UBDesktopAnnotationController : public QObject
void onDesktopPaletteMinimize(); void onDesktopPaletteMinimize();
void onTransparentWidgetResized(); void onTransparentWidgetResized();
void refreshMask(); void refreshMask();
void onToolClicked();
private: private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName); void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);

@ -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(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); int index = proxyTi->parent()->indexOfChild(proxyTi);
index --; index --;
@ -560,7 +563,7 @@ void UBDocumentController::deleteSelectedItem()
{ {
if (proxyTi->proxy() == mBoardController->selectedDocument()) if (proxyTi->proxy() == mBoardController->selectedDocument())
{ {
selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy()); selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy(), true);
} }
else else
proxyTi->parent()->child(index)->setSelected(true); proxyTi->parent()->child(index)->setSelected(true);
@ -569,7 +572,7 @@ void UBDocumentController::deleteSelectedItem()
{ {
if (proxyTi->proxy() == mBoardController->selectedDocument()) if (proxyTi->proxy() == mBoardController->selectedDocument())
{ {
selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy()); selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy(), true);
} }
else else
proxyTi->parent()->child(1)->setSelected(true); proxyTi->parent()->child(1)->setSelected(true);
@ -578,30 +581,36 @@ void UBDocumentController::deleteSelectedItem()
{ {
if (proxyTi->proxy() == mBoardController->selectedDocument()) if (proxyTi->proxy() == mBoardController->selectedDocument())
{ {
bool documentFound = false;
for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++) for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++)
{ {
QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i); QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item); UBDocumentGroupTreeItem* groupItem = dynamic_cast<UBDocumentGroupTreeItem*>(item);
if (groupItem != selectedDocumentGroupTreeItem() && groupItem->childCount() > 0) if (!groupItem->isTrashFolder())
{ {
selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy()); for(int j=0; j<groupItem->childCount(); j++)
break; {
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 else
proxyTi->parent()->setSelected(true); 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(); QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString();
proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName); proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName);
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy()); UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy());
@ -610,6 +619,14 @@ void UBDocumentController::deleteSelectedItem()
mTrashTi->addChild(proxyTi); mTrashTi->addChild(proxyTi);
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); 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) 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<UBDocumentGroupTreeItem*>(item);
if (groupItem != groupTi && groupItem->childCount() > 0)
{
selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy());
break;
}
}
}
QList<UBDocumentProxyTreeItem*> toBeDeleted; QList<UBDocumentProxyTreeItem*> toBeDeleted;
for (int i = 0; i < groupTi->childCount(); i++) 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<UBDocumentGroupTreeItem*>(item);
if (!groupItem->isTrashFolder() && groupItem != groupTi)
{
for(int j=0; j<groupItem->childCount(); 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(); reloadThumbnails();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();

Loading…
Cancel
Save