added zero page logic on document mode

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent fc15dfe45c
commit 24e4a6d710
  1. 18
      src/board/UBBoardPaletteManager.cpp
  2. 3
      src/board/UBBoardPaletteManager.h
  3. 26
      src/document/UBDocumentController.cpp
  4. 50
      src/gui/UBDocumentThumbnailWidget.cpp
  5. 2
      src/gui/UBFeaturesActionBar.cpp
  6. 11
      src/gui/UBThumbnailWidget.cpp

@ -346,6 +346,24 @@ void UBBoardPaletteManager::pagePaletteButtonReleased()
{ {
if( mPageButtonPressedTime.msecsTo(QTime::currentTime()) > 900) if( mPageButtonPressedTime.msecsTo(QTime::currentTime()) > 900)
{ {
// The palette is reinstanciate because the duplication depends on the current scene
delete(mPagePalette);
mPagePalette = 0;
QList<QAction*>pageActions;
pageActions << UBApplication::mainWindow->actionNewPage;
UBBoardController* boardController = UBApplication::boardController;
if(UBApplication::documentController->pageCanBeDuplicated(boardController->pageFromSceneIndex(boardController->activeSceneIndex())))
pageActions << UBApplication::mainWindow->actionDuplicatePage;
pageActions << UBApplication::mainWindow->actionImportPage;
mPagePalette = new UBActionPalette(pageActions, Qt::Horizontal , mContainer);
mPagePalette->setButtonIconSize(QSize(128, 128));
mPagePalette->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
mPagePalette->groupActions();
mPagePalette->setClosable(true);
mPagePalette->adjustSizeAndPosition();
togglePagePalette(true); togglePagePalette(true);
} }
else else

@ -37,7 +37,6 @@ class UBPageNumberPalette;
class UBZoomPalette; class UBZoomPalette;
class UBActionPalette; class UBActionPalette;
class UBBoardController; class UBBoardController;
class UBFloatingPalette;
class UBServerXMLHttpRequest; class UBServerXMLHttpRequest;
class UBKeyboardPalette; class UBKeyboardPalette;
class UBMainWindow; class UBMainWindow;
@ -45,7 +44,7 @@ class UBApplicationController;
class UBDockTeacherGuideWidget; class UBDockTeacherGuideWidget;
// Uncomment this to use old-styles lib paletter // Uncomment this to use old-styles lib paletter
#define USE_WEB_WIDGET // #define USE_WEB_WIDGET
class UBBoardPaletteManager : public QObject class UBBoardPaletteManager : public QObject

@ -1177,7 +1177,27 @@ void UBDocumentController::selectionChanged()
mMainWindow->actionNewDocument->setEnabled((groupSelected || docSelected || pageSelected) && !trashSelected); mMainWindow->actionNewDocument->setEnabled((groupSelected || docSelected || pageSelected) && !trashSelected);
mMainWindow->actionExport->setEnabled((docSelected || pageSelected) && !trashSelected); mMainWindow->actionExport->setEnabled((docSelected || pageSelected) && !trashSelected);
mMainWindow->actionDuplicate->setEnabled((docSelected || pageSelected) && !trashSelected); bool firstSceneSelected = false;
if(docSelected)
mMainWindow->actionDuplicate->setEnabled(!trashSelected);
else if(pageSelected){
QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems();
if(pageCount == 1)
mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBApplication::boardController->pageFromSceneIndex(0)));
else{
for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){
if(dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){
mMainWindow->actionDuplicate->setEnabled(!trashSelected && pageCanBeDuplicated(UBApplication::boardController->pageFromSceneIndex(0)));
firstSceneSelected = true;
}
}
if(!firstSceneSelected)
mMainWindow->actionDuplicate->setEnabled(!trashSelected);
}
}
else
mMainWindow->actionDuplicate->setEnabled(false);
mMainWindow->actionOpen->setEnabled((docSelected || pageSelected) && !trashSelected); mMainWindow->actionOpen->setEnabled((docSelected || pageSelected) && !trashSelected);
mMainWindow->actionRename->setEnabled((groupSelected || docSelected) && !trashSelected && !defaultGroupSelected); mMainWindow->actionRename->setEnabled((groupSelected || docSelected) && !trashSelected && !defaultGroupSelected);
@ -1205,6 +1225,9 @@ void UBDocumentController::selectionChanged()
deleteEnabled = false; deleteEnabled = false;
} }
if(pageSelected && firstSceneSelected)
deleteEnabled = false;
mMainWindow->actionDelete->setEnabled(deleteEnabled); mMainWindow->actionDelete->setEnabled(deleteEnabled);
if (trashSelected) if (trashSelected)
@ -1671,3 +1694,4 @@ bool UBDocumentController::pageCanBeDeleted(int page)
{ {
return page != 0; return page != 0;
} }

@ -19,6 +19,10 @@
#include "core/UBMimeData.h" #include "core/UBMimeData.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "board/UBBoardController.h"
#include "document/UBDocumentController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -51,8 +55,7 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
if (!(event->buttons() & Qt::LeftButton)) if (!(event->buttons() & Qt::LeftButton))
return; return;
if ((event->pos() - mMousePressPos).manhattanLength() if ((event->pos() - mMousePressPos).manhattanLength() < QApplication::startDragDistance())
< QApplication::startDragDistance())
return; return;
QList<QGraphicsItem*> graphicsItems = items(mMousePressPos); QList<QGraphicsItem*> graphicsItems = items(mMousePressPos);
@ -60,24 +63,25 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
UBSceneThumbnailPixmap* sceneItem = 0; UBSceneThumbnailPixmap* sceneItem = 0;
while (!graphicsItems.isEmpty() && !sceneItem) while (!graphicsItems.isEmpty() && !sceneItem)
{
sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(graphicsItems.takeFirst()); sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(graphicsItems.takeFirst());
}
if (sceneItem) if (sceneItem)
{ {
QDrag *drag = new QDrag(this); int pageIndex = UBApplication::boardController->pageFromSceneIndex(sceneItem->sceneIndex());
QList<UBMimeDataItem> mimeDataItems; if(pageIndex != 0){
foreach (QGraphicsItem *item, selectedItems()) QDrag *drag = new QDrag(this);
mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item))); QList<UBMimeDataItem> mimeDataItems;
UBMimeData *mime = new UBMimeData(mimeDataItems); foreach (QGraphicsItem *item, selectedItems())
drag->setMimeData(mime); mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
UBMimeData *mime = new UBMimeData(mimeDataItems);
drag->setMimeData(mime);
drag->setPixmap(sceneItem->pixmap().scaledToWidth(100)); drag->setPixmap(sceneItem->pixmap().scaledToWidth(100));
drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height() / 2));
drag->pixmap().height() / 2));
drag->exec(Qt::MoveAction); drag->exec(Qt::MoveAction);
}
} }
UBThumbnailWidget::mouseMoveEvent(event); UBThumbnailWidget::mouseMoveEvent(event);
@ -104,6 +108,7 @@ void UBDocumentThumbnailWidget::dragLeaveEvent(QDragLeaveEvent *event)
mScrollTimer->stop(); mScrollTimer->stop();
} }
deleteDropCaret(); deleteDropCaret();
UBThumbnailWidget::dragLeaveEvent(event);
} }
void UBDocumentThumbnailWidget::autoScroll() void UBDocumentThumbnailWidget::autoScroll()
@ -145,6 +150,14 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
QGraphicsItem *underlyingItem = itemAt(event->pos()); QGraphicsItem *underlyingItem = itemAt(event->pos());
mClosestDropItem = dynamic_cast<UBSceneThumbnailPixmap*>(underlyingItem); mClosestDropItem = dynamic_cast<UBSceneThumbnailPixmap*>(underlyingItem);
int pageIndex = -1;
if(mClosestDropItem){
pageIndex = UBApplication::boardController->pageFromSceneIndex(mClosestDropItem->sceneIndex());
if(pageIndex == 0){
event->acceptProposedAction();
return;
}
}
if (!mClosestDropItem) if (!mClosestDropItem)
{ {
foreach (UBSceneThumbnailPixmap *item, pixmapItems) foreach (UBSceneThumbnailPixmap *item, pixmapItems)
@ -159,11 +172,12 @@ void UBDocumentThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
{ {
mClosestDropItem = item; mClosestDropItem = item;
minDistance = distance; minDistance = distance;
pageIndex = UBApplication::boardController->pageFromSceneIndex(mClosestDropItem->sceneIndex());
} }
} }
} }
if (mClosestDropItem) if (mClosestDropItem && pageIndex != 0)
{ {
qreal scale = mClosestDropItem->transform().m11(); qreal scale = mClosestDropItem->transform().m11();
@ -206,6 +220,10 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
if (mClosestDropItem) if (mClosestDropItem)
{ {
int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem); int targetIndex = mDropIsRight ? mGraphicItems.indexOf(mClosestDropItem) + 1 : mGraphicItems.indexOf(mClosestDropItem);
if(UBApplication::boardController->pageFromSceneIndex(targetIndex) == 0){
event->ignore();
return;
}
QList<UBMimeDataItem> mimeDataItems; QList<UBMimeDataItem> mimeDataItems;
if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage)) if (event->mimeData()->hasFormat(UBApplication::mimeTypeUniboardPage))
@ -233,7 +251,6 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
actualSourceIndex += sourceIndexOffset; actualSourceIndex += sourceIndexOffset;
event->acceptProposedAction(); event->acceptProposedAction();
if (sourceItem.sceneIndex() < targetIndex) if (sourceItem.sceneIndex() < targetIndex)
{ {
if (actualSourceIndex != actualTargetIndex - 1) if (actualSourceIndex != actualTargetIndex - 1)
@ -248,6 +265,7 @@ void UBDocumentThumbnailWidget::dropEvent(QDropEvent *event)
} }
} }
} }
} }
void UBDocumentThumbnailWidget::deleteDropCaret() void UBDocumentThumbnailWidget::deleteDropCaret()

@ -28,7 +28,6 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
mButtonGroup = new QButtonGroup(this); mButtonGroup = new QButtonGroup(this);
mSearchBar = new QLineEdit(this); mSearchBar = new QLineEdit(this);
mSearchBar->setStyleSheet(QString("background-color:white; border-radius : 10px; padding : 2px;")); mSearchBar->setStyleSheet(QString("background-color:white; border-radius : 10px; padding : 2px;"));
//connect(mSearchBar, SIGNAL(returnPressed()), this, SLOT(onActionSearch()));
mLayout = new QHBoxLayout(); mLayout = new QHBoxLayout();
setLayout(mLayout); setLayout(mLayout);
@ -47,7 +46,6 @@ UBFeaturesActionBar::UBFeaturesActionBar( UBFeaturesController *controller, QWid
// Create the buttons // Create the buttons
mpFavoriteBtn = new UBActionButton(this, mpFavoriteAction); mpFavoriteBtn = new UBActionButton(this, mpFavoriteAction);
mpSocialBtn = new UBActionButton(this, mpSocialAction); mpSocialBtn = new UBActionButton(this, mpSocialAction);
//mpSearchBtn = new UBActionButton(this, mpSearchAction);
mpDeleteBtn = new UBActionButton(this, mpDeleteAction); mpDeleteBtn = new UBActionButton(this, mpDeleteAction);
mpCloseBtn = new UBActionButton(this, mpCloseAction); mpCloseBtn = new UBActionButton(this, mpCloseAction);
mpRemoveFavoriteBtn = new UBActionButton(this, mpRemoveFavorite); mpRemoveFavoriteBtn = new UBActionButton(this, mpRemoveFavorite);

@ -208,9 +208,18 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event)
{ {
mClickTime = QTime::currentTime(); mClickTime = QTime::currentTime();
mMousePressPos = event->pos(); mMousePressPos = event->pos();
UBSceneThumbnailPixmap* sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(itemAt(mMousePressPos));
if(sceneItem){
int pageIndex = UBApplication::boardController->pageFromSceneIndex(sceneItem->sceneIndex());
if(pageIndex == 0){
event->ignore();
return;
}
}
mMousePressScenePos = mapToScene(mMousePressPos); mMousePressScenePos = mapToScene(mMousePressPos);
QGraphicsItem* underlyingItem = itemAt(mMousePressPos); QGraphicsItem* underlyingItem = itemAt(mMousePressPos);
UBThumbnail *previousSelectedThumbnail = mLastSelectedThumbnail; UBThumbnail *previousSelectedThumbnail = mLastSelectedThumbnail;
if (!dynamic_cast<UBThumbnail*>(underlyingItem)) if (!dynamic_cast<UBThumbnail*>(underlyingItem))

Loading…
Cancel
Save