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. 34
      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)
{
// 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);
}
else

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

@ -1177,7 +1177,27 @@ void UBDocumentController::selectionChanged()
mMainWindow->actionNewDocument->setEnabled((groupSelected || 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->actionRename->setEnabled((groupSelected || docSelected) && !trashSelected && !defaultGroupSelected);
@ -1205,6 +1225,9 @@ void UBDocumentController::selectionChanged()
deleteEnabled = false;
}
if(pageSelected && firstSceneSelected)
deleteEnabled = false;
mMainWindow->actionDelete->setEnabled(deleteEnabled);
if (trashSelected)
@ -1671,3 +1694,4 @@ bool UBDocumentController::pageCanBeDeleted(int page)
{
return page != 0;
}

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

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

@ -208,9 +208,18 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event)
{
mClickTime = QTime::currentTime();
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);
QGraphicsItem* underlyingItem = itemAt(mMousePressPos);
UBThumbnail *previousSelectedThumbnail = mLastSelectedThumbnail;
if (!dynamic_cast<UBThumbnail*>(underlyingItem))

Loading…
Cancel
Save