Commit 26ae8fb2 authored by Ivan Ilin's avatar Ivan Ilin

System dependant rubberband created

parent 0bfa2983
...@@ -117,6 +117,7 @@ UBBoardView::init () ...@@ -117,6 +117,7 @@ UBBoardView::init ()
mUsingTabletEraser = false; mUsingTabletEraser = false;
mIsCreatingTextZone = false; mIsCreatingTextZone = false;
mRubberBand = 0; mRubberBand = 0;
mUBRubberBand = 0;
mVirtualKeyboardActive = false; mVirtualKeyboardActive = false;
...@@ -414,10 +415,19 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -414,10 +415,19 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
} }
else if (currentTool == UBStylusTool::Selector) else if (currentTool == UBStylusTool::Selector)
{ {
QSet<QGraphicsItem*> existingTools = scene()->tools(); // QSet<QGraphicsItem*> existingTools = scene()->tools(); why do we need to get tools here?
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint()));
if (!movingItem) {
// Rubberband selection implementation
if (!mUBRubberBand) {
mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this);
}
mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mUBRubberBand->show();
}
if (!movingItem if (!movingItem
|| movingItem->isSelected() || movingItem->isSelected()
|| movingItem->type() == UBGraphicsDelegateFrame::Type || movingItem->type() == UBGraphicsDelegateFrame::Type
...@@ -443,6 +453,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -443,6 +453,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); // удалить suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); // удалить
} }
event->accept(); event->accept();
} }
else if (currentTool == UBStylusTool::Text) else if (currentTool == UBStylusTool::Text)
...@@ -470,7 +481,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -470,7 +481,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
if (!mRubberBand) if (!mRubberBand)
mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this); mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this);
mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mRubberBand->show (); mRubberBand->show ();
mIsCreatingTextZone = true; mIsCreatingTextZone = true;
...@@ -533,6 +543,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event) ...@@ -533,6 +543,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
return; return;
} }
if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->setGeometry(QRect(mMouseDownPos, event->pos()).normalized());
}
if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed)) if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed))
{ {
QPointF scenePos = mapToScene(event->pos()); QPointF scenePos = mapToScene(event->pos());
...@@ -598,6 +612,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event) ...@@ -598,6 +612,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
suspendedMousePressEvent = NULL; suspendedMousePressEvent = NULL;
} }
if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->hide();
}
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
} }
else if (currentTool == UBStylusTool::Text) else if (currentTool == UBStylusTool::Text)
......
...@@ -24,6 +24,7 @@ class UBBoardController; ...@@ -24,6 +24,7 @@ class UBBoardController;
class UBAppleWidget; class UBAppleWidget;
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
class UBRubberBand;
class UBBoardView : public QGraphicsView class UBBoardView : public QGraphicsView
{ {
...@@ -123,6 +124,8 @@ class UBBoardView : public QGraphicsView ...@@ -123,6 +124,8 @@ class UBBoardView : public QGraphicsView
QGraphicsItem *movingItem; QGraphicsItem *movingItem;
QMouseEvent *suspendedMousePressEvent; QMouseEvent *suspendedMousePressEvent;
UBRubberBand *mUBRubberBand;
private slots: private slots:
void settingChanged(QVariant newValue); void settingChanged(QVariant newValue);
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include "UBRubberBand.h" #include "UBRubberBand.h"
#include <QtGui> #include <QtGui>
#include <QtGui/QPlastiqueStyle>
#include <QStyleFactory>
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
#include <QtGui/QMacStyle> #include <QtGui/QMacStyle>
...@@ -32,10 +34,13 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p) ...@@ -32,10 +34,13 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
customStyle = new QWindowsXPStyle(); customStyle = new QWindowsXPStyle();
#elif defined(Q_WS_MAC) #elif defined(Q_WS_MAC)
customStyle = new QMacStyle(); customStyle = new QMacStyle();
#elif defined(Q_WS_X11)
customStyle = QStyleFactory::create("oxygen");
#endif #endif
if (customStyle) if (customStyle)
QRubberBand::setStyle(customStyle); QRubberBand::setStyle(customStyle);
} }
UBRubberBand::~UBRubberBand() UBRubberBand::~UBRubberBand()
......
...@@ -25,6 +25,7 @@ class UBRubberBand : public QRubberBand ...@@ -25,6 +25,7 @@ class UBRubberBand : public QRubberBand
public: public:
UBRubberBand(Shape s, QWidget * p = 0); UBRubberBand(Shape s, QWidget * p = 0);
virtual ~UBRubberBand(); virtual ~UBRubberBand();
private: private:
QStyle* customStyle; QStyle* customStyle;
}; };
......
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