Commit 3860e97b authored by Clément Fauconnier's avatar Clément Fauconnier

1.4 release without real time previews on left palette

parent dcf03944
QWidget#DockPaletteWidgetBox,
QWidget#documentNavigator,
QWidget#UBBoardThumbnailsView,
QWidget#UBLibPathViewer,
QWidget#UBLibNavigatorWidget,
......
......@@ -85,7 +85,6 @@ void UBThumbnailAdaptor::generateMissingThumbnails(UBDocumentProxy* proxy)
const QPixmap* UBThumbnailAdaptor::get(UBDocumentProxy* proxy, int pageIndex)
{
UBApplication::showMessage(tr("loading thumbnail of page %1").arg(pageIndex + 1));
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
QFile file(fileName);
......
......@@ -1994,6 +1994,7 @@ void UBBoardController::persistCurrentScene(bool isAnAutomaticBackup, bool force
&& (mActiveScene->isModified()))
{
UBPersistenceManager::persistenceManager()->persistDocumentScene(selectedDocument(), mActiveScene, mActiveSceneIndex, isAnAutomaticBackup,forceImmediateSave);
updatePage(mActiveSceneIndex);
}
}
......
......@@ -358,7 +358,6 @@ void UBApplicationController::showBoard()
}
}
UBApplication::showMessage(tr("Board drawing..."));
mMainMode = Board;
adaptToolBar();
......
......@@ -183,7 +183,7 @@ void UBPersistenceManager::onSceneLoaded(QByteArray scene, UBDocumentProxy* prox
qDebug() << "scene loaded " << sceneIndex;
QTime time;
time.start();
mSceneCache.insert(proxy, sceneIndex, loadDocumentScene(proxy, sceneIndex));
mSceneCache.insert(proxy, sceneIndex, loadDocumentScene(proxy, sceneIndex, false));
qDebug() << "millisecond for sceneCache " << time.elapsed();
}
......
......@@ -52,7 +52,7 @@ void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReloa
{
mCurrentDocument = document;
emit initThumbnailsRequired(this);
reloadThumbnails();
emit documentSet(mCurrentDocument);
}
}
......@@ -130,6 +130,7 @@ void UBDocumentContainer::deleteThumbPage(int index)
void UBDocumentContainer::updateThumbPage(int index)
{
mDocumentThumbs[index] = UBThumbnailAdaptor::get(mCurrentDocument, index);
emit documentPageUpdated(index);
}
void UBDocumentContainer::insertThumbPage(int index)
......
......@@ -468,11 +468,11 @@ void UBDocumentController::openSelectedItem()
if (selectedItems.count() > 0)
{
UBThumbnailPixmap* thumb = dynamic_cast<UBThumbnailPixmap*> (selectedItems.last());
UBSceneThumbnailPixmap* thumb = dynamic_cast<UBSceneThumbnailPixmap*> (selectedItems.last());
if (thumb)
{
UBDocumentProxy* proxy = thumb->documentProxy();
UBDocumentProxy* proxy = thumb->proxy();
if (proxy && isOKToOpenDocument(proxy))
{
......@@ -505,10 +505,10 @@ void UBDocumentController::duplicateSelectedItem()
QList<int> selectedSceneIndexes;
foreach (QGraphicsItem *item, selectedItems)
{
UBThumbnailPixmap *thumb = dynamic_cast<UBThumbnailPixmap*>(item);
UBSceneThumbnailPixmap *thumb = dynamic_cast<UBSceneThumbnailPixmap*>(item);
if (thumb)
{
UBDocumentProxy *proxy = thumb->documentProxy();
UBDocumentProxy *proxy = thumb->proxy();
if (proxy)
{
......@@ -1366,7 +1366,7 @@ void UBDocumentController::selectionChanged()
mMainWindow->actionDuplicate->setEnabled(!trashSelected);
else{
for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1){
if(dynamic_cast<UBThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){
if(dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i))->sceneIndex() == 0){
mMainWindow->actionDuplicate->setEnabled(!trashSelected);
firstSceneSelected = true;
}
......@@ -1516,11 +1516,11 @@ void UBDocumentController::addToDocument()
foreach (QGraphicsItem* item, selectedItems)
{
UBThumbnailPixmap* thumb = dynamic_cast<UBThumbnailPixmap*> (item);
UBSceneThumbnailPixmap* thumb = dynamic_cast<UBSceneThumbnailPixmap*> (item);
if (thumb && thumb->documentProxy())
if (thumb && thumb->proxy())
{
QPair<UBDocumentProxy*, int> pageInfo(thumb->documentProxy(), thumb->sceneIndex());
QPair<UBDocumentProxy*, int> pageInfo(thumb->proxy(), thumb->sceneIndex());
pageInfoList << pageInfo;
}
}
......@@ -1809,11 +1809,11 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
foreach (QGraphicsItem* item, itemsToDelete)
{
UBThumbnailPixmap* thumb = dynamic_cast<UBThumbnailPixmap*> (item);
UBSceneThumbnailPixmap* thumb = dynamic_cast<UBSceneThumbnailPixmap*> (item);
if (thumb)
{
proxy = thumb->documentProxy();
proxy = thumb->proxy();
if (proxy)
{
sceneIndexes.append(thumb->sceneIndex());
......@@ -1843,7 +1843,7 @@ int UBDocumentController::getSelectedItemIndex()
if (selectedItems.count() > 0)
{
UBThumbnailPixmap* thumb = dynamic_cast<UBThumbnailPixmap*> (selectedItems.last());
UBSceneThumbnailPixmap* thumb = dynamic_cast<UBSceneThumbnailPixmap*> (selectedItems.last());
return thumb->sceneIndex();
}
else return -1;
......@@ -1872,7 +1872,7 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
for (int i = 0; i < selectedDocument()->pageCount(); i++)
{
const QPixmap* pix = pageAt(i);
QGraphicsPixmapItem *pixmapItem = new UBThumbnailPixmap(*pix, proxy, i); // deleted by the tree widget
QGraphicsPixmapItem *pixmapItem = new UBSceneThumbnailPixmap(*pix, proxy, i); // deleted by the tree widget
if (proxy == mBoardController->selectedDocument() && mBoardController->activeSceneIndex() == i)
{
......@@ -1899,7 +1899,7 @@ void UBDocumentController::refreshDocumentThumbnailsView(UBDocumentContainer*)
if (selection) {
disconnect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
UBThumbnailPixmap *currentScene = dynamic_cast<UBThumbnailPixmap*>(selection);
UBSceneThumbnailPixmap *currentScene = dynamic_cast<UBSceneThumbnailPixmap*>(selection);
if (currentScene)
mDocumentUI->thumbnailWidget->hightlightItem(currentScene->sceneIndex());
connect(mDocumentUI->thumbnailWidget->scene(), SIGNAL(selectionChanged()), this, SLOT(pageSelectionChanged()));
......
This diff is collapsed.
/*
* Copyright (C) 2015-2016 Département de l'Instruction Publique (DIP-SEM)
*
* Copyright (C) 2013 Open Education Foundation
*
* Copyright (C) 2010-2013 Groupement d'Intérêt Public pour
* l'Education Numérique en Afrique (GIP ENA)
*
* This file is part of OpenBoard.
*
* OpenBoard is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License,
* with a specific linking exception for the OpenSSL project's
* "OpenSSL" library (or with modified versions of it that use the
* same license as the "OpenSSL" library).
*
* OpenBoard is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTNAVIGATOR_H
#define UBDOCUMENTNAVIGATOR_H
#include <QResizeEvent>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QMouseEvent>
#include <QThread>
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentContainer.h"
#include "UBThumbnailWidget.h"
#define NO_PAGESELECTED -1
class UBDocumentNavigator : public QGraphicsView
{
Q_OBJECT
public:
UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator");
~UBDocumentNavigator();
void setNbColumns(int nbColumns);
int nbColumns();
void setThumbnailMinWidth(int width);
int thumbnailMinWidth();
public slots:
void onScrollToSelectedPage(int index);// { if (mCrntItem) centerOn(mCrntItem); }
void generateThumbnails(UBDocumentContainer* source);
void updateSpecificThumbnail(int iPage);
void longPressTimeout();
void mousePressAndHoldEvent(QPoint pos);
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void dragEnterEvent(QDragEnterEvent* event);
virtual void dragMoveEvent(QDragMoveEvent* event);
virtual void dropEvent(QDropEvent* event);
signals:
void mousePressAndHoldEventRequired(QPoint pos);
void moveThumbnailRequired(int from, int to);
private:
void refreshScene();
int border();
/** The scene */
QGraphicsScene* mScene;
/** The current selected item */
//UBSceneThumbnailNavigPixmap* mCrntItem;
/** The list of current thumbnails with labels*/
QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The current thumbnails width */
int mThumbnailWidth;
/** The current thumbnails minimum width */
int mThumbnailMinWidth;
/** The selected thumbnail */
UBSceneThumbnailNavigPixmap* mSelectedThumbnail;
UBSceneThumbnailNavigPixmap* mDropSource;
UBSceneThumbnailNavigPixmap* mDropTarget;
QGraphicsRectItem *mDropBar;
int mLongPressInterval;
QTimer mLongPressTimer;
QPoint mLastPressedMousePos;
};
#endif // UBDOCUMENTNAVIGATOR_H
......@@ -75,17 +75,17 @@ void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
QList<QGraphicsItem*> graphicsItems = items(mMousePressPos);
UBThumbnailPixmap* sceneItem = 0;
UBSceneThumbnailPixmap* sceneItem = 0;
while (!graphicsItems.isEmpty() && !sceneItem)
sceneItem = dynamic_cast<UBThumbnailPixmap*>(graphicsItems.takeFirst());
sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(graphicsItems.takeFirst());
if (sceneItem)
{
QDrag *drag = new QDrag(this);
QList<UBMimeDataItem> mimeDataItems;
foreach (QGraphicsItem *item, selectedItems())
mimeDataItems.append(UBMimeDataItem(sceneItem->documentProxy(), mGraphicItems.indexOf(item)));
mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
UBMimeData *mime = new UBMimeData(mimeDataItems);
drag->setMimeData(mime);
......@@ -305,7 +305,7 @@ void UBDocumentThumbnailWidget::hightlightItem(int index)
}
if (0 <= index && index < mGraphicItems.length())
{
UBThumbnailPixmap *thumbnail = dynamic_cast<UBThumbnailPixmap*>(mGraphicItems.at(index));
UBSceneThumbnailPixmap *thumbnail = dynamic_cast<UBSceneThumbnailPixmap*>(mGraphicItems.at(index));
if (thumbnail)
thumbnail->highlight();
}
......
......@@ -88,6 +88,7 @@ void UBMessageWindow::showMessage(const QString& message, bool showSpinningWheel
repaint();
// I mean it, *right now*, also on Mac
qApp->flush();
//qApp->sendPostedEvents();
}
void UBMessageWindow::timerEvent(QTimerEvent *event)
......
......@@ -60,7 +60,7 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name
mLayout = new QVBoxLayout(this);
setLayout(mLayout);
mNavigator = new UBBoardThumbnailsView(this);
mNavigator = new UBDocumentNavigator(this);
mLayout->addWidget(mNavigator, 1);
mHLayout = new QHBoxLayout();
......
......@@ -39,6 +39,7 @@
#include <QString>
#include "UBBoardThumbnailsView.h"
#include "UBDocumentNavigator.h"
#include "UBDockPaletteWidget.h"
#include "document/UBDocumentProxy.h"
......@@ -70,7 +71,7 @@ private:
int border();
/** The thumbnails navigator widget */
UBBoardThumbnailsView* mNavigator;
UBDocumentNavigator* mNavigator;
/** The layout */
QVBoxLayout* mLayout;
QHBoxLayout* mHLayout;
......
......@@ -771,7 +771,117 @@ UBThumbnail::~UBThumbnail()
delete mSelectionItem;
}
void UBWidgetTextThumbnailElement::Place(int row, int col, qreal width, qreal height)
UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex)
: UBSceneThumbnailPixmap(pix, proxy, pSceneIndex)
, bButtonsVisible(false)
, bCanDelete(false)
, bCanMoveUp(false)
, bCanMoveDown(false)
{
if(0 <= UBDocumentContainer::pageFromSceneIndex(pSceneIndex)){
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
}
}
UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap()
{
}
void UBSceneThumbnailNavigPixmap::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
event->accept();
bButtonsVisible = true;
bCanDelete = true;
bCanMoveDown = false;
bCanMoveUp = false;
if(sceneIndex() < proxy()->pageCount() - 1)
bCanMoveDown = true;
if(sceneIndex() > 0)
bCanMoveUp = true;
if(proxy()->pageCount() == 1)
bCanDelete = false;
update();
}
void UBSceneThumbnailNavigPixmap::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
event->accept();
bButtonsVisible = false;
update();
}
void UBSceneThumbnailNavigPixmap::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
UBSceneThumbnailPixmap::paint(painter, option, widget);
if(bButtonsVisible)
{
if(bCanDelete)
painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/close.svg"));
else
painter->drawPixmap(0, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/closeDisabled.svg"));
painter->drawPixmap(BUTTONSIZE + BUTTONSPACING, 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/duplicate.svg"));
if(bCanMoveUp)
painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUp.svg"));
else
painter->drawPixmap(2*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/moveUpDisabled.svg"));
if(bCanMoveDown)
painter->drawPixmap(3*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/menu.svg"));
else
painter->drawPixmap(3*(BUTTONSIZE + BUTTONSPACING), 0, BUTTONSIZE, BUTTONSIZE, QPixmap(":images/menuDisabled.svg"));
}
}
void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QPointF p = event->pos();
// Here we check the position of the click and verify if it has to trig an action or not.
if(bCanDelete && p.x() >= 0 && p.x() <= BUTTONSIZE && p.y() >= 0 && p.y() <= BUTTONSIZE)
deletePage();
if(p.x() >= BUTTONSIZE + BUTTONSPACING && p.x() <= 2*BUTTONSIZE + BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE)
duplicatePage();
if(bCanMoveUp && p.x() >= 2*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 3*BUTTONSIZE + 2*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE)
moveUpPage();
if(bCanMoveDown && p.x() >= 3*(BUTTONSIZE + BUTTONSPACING) && p.x() <= 4*BUTTONSIZE + 3*BUTTONSPACING && p.y() >= 0 && p.y() <= BUTTONSIZE)
moveDownPage();
event->accept();
}
void UBSceneThumbnailNavigPixmap::deletePage()
{
if(UBApplication::mainWindow->yesNoQuestion(QObject::tr("Remove Page"), QObject::tr("Are you sure you want to remove 1 page from the selected document '%0'?").arg(UBApplication::documentController->selectedDocument()->metaData(UBSettings::documentName).toString()))){
UBApplication::boardController->deleteScene(sceneIndex());
}
}
void UBSceneThumbnailNavigPixmap::duplicatePage()
{
UBApplication::boardController->duplicateScene(sceneIndex());
}
void UBSceneThumbnailNavigPixmap::moveUpPage()
{
if (sceneIndex()!=0)
UBApplication::boardController->moveSceneToIndex(sceneIndex(), sceneIndex() - 1);
}
void UBSceneThumbnailNavigPixmap::moveDownPage()
{
if (sceneIndex() < UBApplication::boardController->selectedDocument()->pageCount()-1)
UBApplication::boardController->moveSceneToIndex(sceneIndex(), sceneIndex() + 1);
}
void UBImgTextThumbnailElement::Place(int row, int col, qreal width, qreal height)
{
int labelSpacing = 0;
if(this->caption)
......@@ -802,8 +912,11 @@ void UBWidgetTextThumbnailElement::Place(int row, int col, qreal width, qreal he
pix->setRow(row);
}
QPointF pos(border + (width - w * scaleFactor) / 2 + col * (width + border),
border + row * (height + border + labelSpacing) + (height - h * scaleFactor) / 2);
QPointF pos((width - w * scaleFactor) / 2,
row * (height + labelSpacing) + (height - h * scaleFactor) / 2);
/*QPointF pos(border + (width - w * scaleFactor) / 2 + col * (width + border),
border + row * (height + border + labelSpacing) + (height - h * scaleFactor) / 2);*/
this->thumbnail->setPos(pos);
......@@ -816,7 +929,7 @@ void UBWidgetTextThumbnailElement::Place(int row, int col, qreal width, qreal he
this->caption->setWidth(fm.width(elidedText) + 2 * this->caption->document()->documentMargin());
pos.setY(pos.y() + (height + h * scaleFactor) / 2 + 5); // What is this 5 ??
qreal labelWidth = fm.width(elidedText);
pos.setX(border + (width - labelWidth) / 2 + col * (width + border));
pos.setX((width - labelWidth) / 2 + col * (width + border));
this->caption->setPos(pos);
}
}
......@@ -929,7 +1042,7 @@ void UBDraggableThumbnail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
void UBDraggableThumbnailView::updatePos(qreal width, qreal height)
void UBDraggableThumbnail::updatePos(qreal width, qreal height)
{
QFontMetrics fm(mPageNumber->font());
int labelSpacing = UBSettings::thumbnailSpacing + fm.height();
......@@ -959,6 +1072,37 @@ void UBDraggableThumbnailView::updatePos(qreal width, qreal height)
mPageNumber->setPos(position);
}
void UBDraggableThumbnailPixmap::updatePos(qreal width, qreal height)
{
QFontMetrics fm(mPageNumber->font());
int labelSpacing = UBSettings::thumbnailSpacing + fm.height();
int w = thumbnailPixmap()->boundingRect().width();
int h = thumbnailPixmap()->boundingRect().height();
qreal scaledWidth = width / w;
qreal scaledHeight = height / h;
qreal scaledFactor = qMin(scaledWidth, scaledHeight);
QTransform transform;
transform.scale(scaledFactor, scaledFactor);
// Apply the scaling
thumbnailPixmap()->setTransform(transform);
thumbnailPixmap()->setFlag(QGraphicsItem::ItemIsSelectable, true);
QPointF position((width - w * scaledFactor) / 2,
sceneIndex() * (height + labelSpacing) + (height - h * scaledFactor) / 2);
thumbnailPixmap()->setPos(position);
position.setY(position.y() + (height + h * scaledFactor) / 2);
position.setX(position.x() + (w * scaledFactor - fm.width(mPageNumber->toPlainText())) / 2);
mPageNumber->setPos(position);
}
UBThumbnailUI::UBThumbnailUIIcon* UBThumbnailUI::addIcon(const QString& thumbnailIcon, int pos)
{
QString thumbnailIconPath = ":images/" + thumbnailIcon + ".svg";
......
......@@ -48,6 +48,8 @@
#define STARTDRAGTIME 1000000
#define BUTTONSIZE 48
#define BUTTONSPACING 5
class UBDocumentProxy;
class UBThumbnailTextItem;
......@@ -274,44 +276,9 @@ class UBThumbnailTextItem : public QGraphicsTextItem
bool mIsHighlighted;
};
class UBWidgetTextThumbnailElement
{
protected:
QGraphicsItem* thumbnail;
UBThumbnailTextItem* caption;
int border;
public:
UBWidgetTextThumbnailElement(QGraphicsProxyWidget* proxyWidget, UBThumbnailTextItem* text)
: thumbnail(proxyWidget)
, caption(text)
, border(0)
{
}
QGraphicsItem* getThumbnail() const { return this->thumbnail; }
void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; }
UBThumbnailTextItem* getCaption() const { return this->caption; }
void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; }
void Place(int row, int col, qreal width, qreal height);
int getBorder() const { return this->border; }
void setBorder(int newBorder) { this->border = newBorder; }
};
class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail
{
public:
UBThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex)
: QGraphicsPixmapItem(pix)
, mDocumentProxy(proxy)
, mSceneIndex(pSceneIndex)
{
}
UBThumbnailPixmap(const QPixmap& pix)
: QGraphicsPixmapItem(pix)
{
......@@ -320,6 +287,11 @@ class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
virtual ~UBThumbnailPixmap()
{
// NOOP
}
virtual QPainterPath shape () const
{
QPainterPath path;
......@@ -327,6 +299,7 @@ class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail
return path;
}
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QStyleOptionGraphicsItem styleOption = UBThumbnail::muteStyleOption(option);
......@@ -338,26 +311,94 @@ class UBThumbnailPixmap : public QGraphicsPixmapItem, public UBThumbnail
UBThumbnail::itemChange(this, change, value);
return QGraphicsPixmapItem::itemChange(change, value);
}
};
void highlight()
class UBSceneThumbnailPixmap : public UBThumbnailPixmap
{
public:
UBSceneThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex)
: UBThumbnailPixmap(pix)
, mProxy(proxy)
, mSceneIndex(pSceneIndex)
{
// NOOP
}
virtual ~UBSceneThumbnailPixmap()
{
// NOOP
}
UBDocumentProxy* documentProxy()
UBDocumentProxy* proxy()
{
return mDocumentProxy;
return mProxy;
}
int sceneIndex()
{
return mSceneIndex;
}
protected:
UBDocumentProxy* mDocumentProxy;
void highlight()
{
//NOOP
}
private:
UBDocumentProxy* mProxy;
int mSceneIndex;
};
class UBSceneThumbnailNavigPixmap : public UBSceneThumbnailPixmap
{
public:
UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex);
~UBSceneThumbnailNavigPixmap();
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
void deletePage();
void duplicatePage();
void moveUpPage();
void moveDownPage();
bool bButtonsVisible;
bool bCanDelete;
bool bCanMoveUp;
bool bCanMoveDown;
};
class UBImgTextThumbnailElement
{
private:
UBSceneThumbnailNavigPixmap* thumbnail;
UBThumbnailTextItem* caption;
int border;
public:
UBImgTextThumbnailElement(UBSceneThumbnailNavigPixmap* thumb, UBThumbnailTextItem* text): border(0)
{
this->thumbnail = thumb;
this->caption = text;
}
UBSceneThumbnailNavigPixmap* getThumbnail() const { return this->thumbnail; }
void setThumbnail(UBSceneThumbnailNavigPixmap* newGItem) { this->thumbnail = newGItem; }
UBThumbnailTextItem* getCaption() const { return this->caption; }
void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; }
void Place(int row, int col, qreal width, qreal height);
int getBorder() const { return this->border; }
void setBorder(int newBorder) { this->border = newBorder; }
};
class UBThumbnailProxyWidget : public QGraphicsProxyWidget
{
public:
......@@ -393,11 +434,17 @@ class UBDraggableThumbnail : public UBThumbnailProxyWidget
public:
UBDraggableThumbnail(UBDocumentProxy* documentProxy, int index)
: UBThumbnailProxyWidget(documentProxy, index)
, mPageNumber(new UBThumbnailTextItem(index))
, mEditable(false)
{
}
~UBDraggableThumbnail()
{
delete mPageNumber; // not a child of "this" QObject so it has to be deleted manually
}
bool editable()
{
return mEditable;
......@@ -433,6 +480,23 @@ class UBDraggableThumbnail : public UBThumbnailProxyWidget
mEditable = editable;
}
UBThumbnailTextItem* pageNumber()
{
return mPageNumber;
}
void setPageNumber(int i)
{
mPageNumber->setPlainText(tr("Page %0").arg(i+1));
if (UBApplication::boardController->activeSceneIndex() == i)
mPageNumber->setHtml("<span style=\";font-weight:bold;color: red\">" + tr("Page %0").arg(i+1) + "</span>");
else
mPageNumber->setHtml("<span style=\";color: #000000\">" + tr("Page %0").arg(i+1) + "</span>");
}
virtual void updatePos(qreal w, qreal h);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
......@@ -440,6 +504,7 @@ class UBDraggableThumbnail : public UBThumbnailProxyWidget
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
UBThumbnailTextItem* mPageNumber;
private:
void deletePage();
void duplicatePage();
......@@ -451,9 +516,30 @@ class UBDraggableThumbnail : public UBThumbnailProxyWidget
class UBDraggableThumbnailPixmap : public UBDraggableThumbnail
{
Q_OBJECT
public:
UBDraggableThumbnailPixmap(const QPixmap& pix, UBDocumentProxy* proxy, int pSceneIndex);
~UBDraggableThumbnailPixmap();
UBDraggableThumbnailPixmap(UBThumbnailPixmap* thumbnailPixmap, UBDocumentProxy* documentProxy, int index)
: UBDraggableThumbnail(documentProxy, index)
, mThumbnailPixmap(thumbnailPixmap)
{
setFlag(QGraphicsItem::ItemIsSelectable, true);
setAcceptDrops(true);
}
~UBDraggableThumbnailPixmap()
{
}
UBThumbnailPixmap* thumbnailPixmap()
{
return mThumbnailPixmap;
}
void updatePos(qreal w, qreal h);
private:
UBThumbnailPixmap* mThumbnailPixmap;
};
class UBDraggableThumbnailView : public UBDraggableThumbnail
......@@ -463,7 +549,6 @@ class UBDraggableThumbnailView : public UBDraggableThumbnail
UBDraggableThumbnailView(UBThumbnailView* thumbnailView, UBDocumentProxy* documentProxy, int index)
: UBDraggableThumbnail(documentProxy, index)
, mThumbnailView(thumbnailView)
, mPageNumber(new UBThumbnailTextItem(index))
{
setFlag(QGraphicsItem::ItemIsSelectable, true);
setWidget(mThumbnailView);
......@@ -475,8 +560,6 @@ class UBDraggableThumbnailView : public UBDraggableThumbnail
delete mPageNumber; // not a child of "this" QObject so it has to be deleted manually
}
void updatePos(qreal w, qreal h);
UBThumbnailView* thumbnailView()
{
return mThumbnailView;
......@@ -498,8 +581,7 @@ class UBDraggableThumbnailView : public UBDraggableThumbnail
}
private:
UBThumbnailView* mThumbnailView;
UBThumbnailTextItem* mPageNumber;
UBThumbnailView* mThumbnailView;
};
namespace UBThumbnailUI
......
......@@ -41,7 +41,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBOpenSankoreImporterWidget.h \
src/gui/UBStartupHintsPalette.h \
src/gui/UBBackgroundPalette.h \
src/gui/UBBoardThumbnailsView.h
src/gui/UBBoardThumbnailsView.h \
src/gui/UBDocumentNavigator.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
src/gui/UBToolbarButtonGroup.cpp \
......@@ -85,7 +86,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBOpenSankoreImporterWidget.cpp \
src/gui/UBStartupHintsPalette.cpp \
src/gui/UBBackgroundPalette.cpp \
src/gui/UBBoardThumbnailsView.cpp
src/gui/UBBoardThumbnailsView.cpp \
src/gui/UBDocumentNavigator.cpp
win32:SOURCES += src/gui/UBKeyboardPalette_win.cpp
macx:OBJECTIVE_SOURCES += src/gui/UBKeyboardPalette_mac.mm
linux-g++:SOURCES += src/gui/UBKeyboardPalette_linux.cpp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment