System dependant rubberband created

preferencesAboutTextFull
Ivan Ilin 12 years ago
parent 0bfa298344
commit 26ae8fb2d6
  1. 22
      src/board/UBBoardView.cpp
  2. 3
      src/board/UBBoardView.h
  3. 5
      src/gui/UBRubberBand.cpp
  4. 1
      src/gui/UBRubberBand.h

@ -117,6 +117,7 @@ UBBoardView::init ()
mUsingTabletEraser = false;
mIsCreatingTextZone = false;
mRubberBand = 0;
mUBRubberBand = 0;
mVirtualKeyboardActive = false;
@ -414,10 +415,19 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
}
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()));
if (!movingItem) {
// Rubberband selection implementation
if (!mUBRubberBand) {
mUBRubberBand = new UBRubberBand(QRubberBand::Rectangle, this);
}
mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mUBRubberBand->show();
}
if (!movingItem
|| movingItem->isSelected()
|| movingItem->type() == UBGraphicsDelegateFrame::Type
@ -443,6 +453,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); // удалить
}
event->accept();
}
else if (currentTool == UBStylusTool::Text)
@ -470,7 +481,6 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
if (!mRubberBand)
mRubberBand = new UBRubberBand (QRubberBand::Rectangle, this);
mRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mRubberBand->show ();
mIsCreatingTextZone = true;
@ -533,6 +543,10 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
return;
}
if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->setGeometry(QRect(mMouseDownPos, event->pos()).normalized());
}
if (movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed))
{
QPointF scenePos = mapToScene(event->pos());
@ -598,6 +612,10 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
suspendedMousePressEvent = NULL;
}
if (mUBRubberBand && mUBRubberBand->isVisible()) {
mUBRubberBand->hide();
}
QGraphicsView::mouseReleaseEvent (event);
}
else if (currentTool == UBStylusTool::Text)

@ -24,6 +24,7 @@ class UBBoardController;
class UBAppleWidget;
class UBGraphicsScene;
class UBGraphicsWidgetItem;
class UBRubberBand;
class UBBoardView : public QGraphicsView
{
@ -123,6 +124,8 @@ class UBBoardView : public QGraphicsView
QGraphicsItem *movingItem;
QMouseEvent *suspendedMousePressEvent;
UBRubberBand *mUBRubberBand;
private slots:
void settingChanged(QVariant newValue);

@ -16,6 +16,8 @@
#include "UBRubberBand.h"
#include <QtGui>
#include <QtGui/QPlastiqueStyle>
#include <QStyleFactory>
#ifdef Q_WS_MAC
#include <QtGui/QMacStyle>
@ -32,10 +34,13 @@ UBRubberBand::UBRubberBand(Shape s, QWidget * p)
customStyle = new QWindowsXPStyle();
#elif defined(Q_WS_MAC)
customStyle = new QMacStyle();
#elif defined(Q_WS_X11)
customStyle = QStyleFactory::create("oxygen");
#endif
if (customStyle)
QRubberBand::setStyle(customStyle);
}
UBRubberBand::~UBRubberBand()

@ -25,6 +25,7 @@ class UBRubberBand : public QRubberBand
public:
UBRubberBand(Shape s, QWidget * p = 0);
virtual ~UBRubberBand();
private:
QStyle* customStyle;
};

Loading…
Cancel
Save