Commit f9e12cc3 authored by Aleksei Kanash's avatar Aleksei Kanash

UBToolWidget is QWidget again. He not depends on scene.

Still have some mesh with undo stack and with widget content.
parent ccabe5ad
...@@ -1782,6 +1782,13 @@ qreal UBBoardController::currentZoom() ...@@ -1782,6 +1782,13 @@ qreal UBBoardController::currentZoom()
return 1.0; return 1.0;
} }
void UBBoardController::removeTool(UBToolWidget* toolWidget)
{
toolWidget->hide();
delete toolWidget;
}
void UBBoardController::hide() void UBBoardController::hide()
{ {
UBApplication::mainWindow->actionLibrary->setChecked(false); UBApplication::mainWindow->actionLibrary->setChecked(false);
...@@ -2309,30 +2316,29 @@ void UBBoardController::togglePodcast(bool checked) ...@@ -2309,30 +2316,29 @@ void UBBoardController::togglePodcast(bool checked)
void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget) void UBBoardController::moveGraphicsWidgetToControlView(UBGraphicsWidgetItem* graphicsWidget)
{ {
graphicsWidget->remove();
mActiveScene->setURStackEnable(false); mActiveScene->setURStackEnable(false);
graphicsWidget->remove(false);
UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget)); UBGraphicsItem *toolW3C = duplicateItem(dynamic_cast<UBItem *>(graphicsWidget));
UBGraphicsWidgetItem *copyedGraphicsWidget = NULL; UBGraphicsWidgetItem *copyedGraphicsWidget = NULL;
if (UBGraphicsWidgetItem::Type == toolW3C->type()) if (UBGraphicsWidgetItem::Type == toolW3C->type())
copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C); copyedGraphicsWidget = static_cast<UBGraphicsWidgetItem *>(toolW3C);
UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget); UBToolWidget *toolWidget = new UBToolWidget(copyedGraphicsWidget, mControlView);
mActiveScene->addItem(toolWidget);
qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
toolWidget->setScale(ssf);
toolWidget->setPos(graphicsWidget->scenePos());
mActiveScene->setURStackEnable(true); mActiveScene->setURStackEnable(true);
QPoint controlViewPos = mControlView->mapFromScene(graphicsWidget->sceneBoundingRect().center());
toolWidget->centerOn(mControlView->mapTo(mControlContainer, controlViewPos));
toolWidget->show();
} }
void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget) void UBBoardController::moveToolWidgetToScene(UBToolWidget* toolWidget)
{ {
UBGraphicsWidgetItem *graphicsWidgetItem = addW3cWidget(toolWidget->graphicsWidgetItem()->widgetUrl(), QPointF(0, 0)); UBGraphicsWidgetItem *graphicsWidgetItem = addW3cWidget(toolWidget->toolWidget()->widgetUrl(), QPointF(0, 0));
graphicsWidgetItem->setPos(toolWidget->pos()); graphicsWidgetItem->setPos(toolWidget->pos());
toolWidget->remove(); toolWidget->hide();
delete toolWidget;
graphicsWidgetItem->setSelected(true); graphicsWidgetItem->setSelected(true);
} }
......
...@@ -200,6 +200,7 @@ class UBBoardController : public UBDocumentContainer ...@@ -200,6 +200,7 @@ class UBBoardController : public UBDocumentContainer
void hideMessage(); void hideMessage();
void setDisabled(bool disable); void setDisabled(bool disable);
void setColorIndex(int pColorIndex); void setColorIndex(int pColorIndex);
void removeTool(UBToolWidget* toolWidget);
void hide(); void hide();
void show(); void show();
void setWidePageSize(bool checked); void setWidePageSize(bool checked);
......
...@@ -553,8 +553,8 @@ Here we determines cases when items should to get mouse press event at pressing ...@@ -553,8 +553,8 @@ Here we determines cases when items should to get mouse press event at pressing
return false; return false;
break; break;
case UBToolWidget::Type: //case UBToolWidget::Type:
return true; // return true;
case QGraphicsWebView::Type: case QGraphicsWebView::Type:
return true; return true;
...@@ -1123,7 +1123,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) ...@@ -1123,7 +1123,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
DelegateButton::Type != movingItem->type() && DelegateButton::Type != movingItem->type() &&
QGraphicsSvgItem::Type != movingItem->type() && QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type() && // UBToolWidget::Type != movingItem->type() &&
UBGraphicsCache::Type != movingItem->type() && UBGraphicsCache::Type != movingItem->type() &&
QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools. QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools.
!(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())) !(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()))
......
This diff is collapsed.
...@@ -17,60 +17,51 @@ ...@@ -17,60 +17,51 @@
#define UBTOOLWIDGET_H_ #define UBTOOLWIDGET_H_
#include <QtGui> #include <QtGui>
#include <QtWebKit>
#include "core/UB.h"
class UBGraphicsScene;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
class QWidget;
class UBGraphicsScene;
class QWebView;
class UBToolWidget : public QGraphicsWidget class UBToolWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT;
public: public:
UBToolWidget(const QUrl& pUrl, QGraphicsItem *pParent = 0); UBToolWidget(const QUrl& pUrl, QWidget* pParent = 0);
UBToolWidget(UBGraphicsWidgetItem* pGraphicsWidgetItem, QGraphicsItem *pParent = 0); UBToolWidget(UBGraphicsWidgetItem* pWidget, QWidget* pParent = 0);
virtual ~UBToolWidget(); virtual ~UBToolWidget();
UBGraphicsWidgetItem* graphicsWidgetItem() const; void centerOn(const QPoint& pos);
QPointF naturalCenter() const;
void centerOn(const QPointF& pos);
void remove();
virtual UBGraphicsScene* scene(); QPoint naturalCenter() const;
virtual QPointF pos() const;
virtual void setPos(const QPointF &point);
virtual void setPos(qreal x, qreal y);
virtual int type() const;
enum UBGraphicsWidgetItem *toolWidget() const;
{
Type = UBGraphicsItemType::ToolWidgetItemType
};
protected: protected:
void initialize(); void initialize();
virtual void paintEvent(QPaintEvent *event);
virtual bool event(QEvent *event); virtual void mousePressEvent(QMouseEvent *event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual bool eventFilter(QObject *obj, QEvent *event);
private slots: private slots:
void javaScriptWindowObjectCleared(); void javaScriptWindowObjectCleared();
protected: protected:
bool mShouldMoveWidget; QWebView *mWebView;
int mContentMargin; UBGraphicsWidgetItem *mToolWidget;
int mFrameWidth;
QGraphicsWebView *mGraphicsWebView;
UBGraphicsWidgetItem *mGraphicsWidgetItem;
QPointF mMousePressPos;
static QPixmap *sClosePixmap; static QPixmap *sClosePixmap;
static QPixmap *sUnpinPixmap; static QPixmap *sUnpinPixmap;
QPoint mMousePressPos;
bool mShouldMoveWidget;
int mContentMargin;
int mFrameWidth;
}; };
#endif /* UBTOOLWIDGET_H_ */ #endif /* UBTOOLWIDGET_H_ */
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