stylus tool bar

vector_item
thomas_lucky13 2 years ago
parent e7907cd38f
commit 411f85ca81
  1. 21
      resources/forms/mainWindow.ui
  2. 3
      src/api/UBWidgetUniboardAPI.cpp
  3. 2
      src/board/UBBoardController.cpp
  4. 5
      src/board/UBBoardView.cpp
  5. 22
      src/board/UBDrawingController.cpp
  6. 1
      src/board/UBDrawingController.h
  7. 1
      src/core/UB.h
  8. 6
      src/domain/UBGraphicsScene.cpp
  9. 1
      src/gui/UBStylusPalette.cpp
  10. 1
      src/gui/UBToolbarButtonGroup.cpp

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1342</width> <width>1342</width>
<height>223</height> <height>268</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -1702,6 +1702,25 @@
<string>Draw intermediate grid lines</string> <string>Draw intermediate grid lines</string>
</property> </property>
</action> </action>
<action name="actionVector">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/stylusPalette/line.png</normaloff>
<normalon>:/images/stylusPalette/lineOn.png</normalon>:/images/stylusPalette/line.png</iconset>
</property>
<property name="text">
<string>Vector</string>
</property>
<property name="toolTip">
<string>Draw Vectors</string>
</property>
<property name="shortcut">
<string>Ctrl+J</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../OpenBoard.qrc"/> <include location="../OpenBoard.qrc"/>

@ -144,6 +144,9 @@ void UBWidgetUniboardAPI::setTool(const QString& toolString)
else if (lower == "line") else if (lower == "line")
{ {
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Line);
} else if (lower == "vector")
{
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Vector);
} }
} }

@ -1981,6 +1981,7 @@ void UBBoardController::setColorIndex(int pColorIndex)
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker && if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line && UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Line &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Vector &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Text && UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Text &&
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Selector) UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Selector)
{ {
@ -1989,6 +1990,7 @@ void UBBoardController::setColorIndex(int pColorIndex)
if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen || if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line ||
UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Vector ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Text || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Text ||
UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector) UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Selector)
{ {

@ -367,7 +367,7 @@ void UBBoardView::tabletEvent (QTabletEvent * event)
QPointF scenePos = viewportTransform ().inverted ().map (tabletPos); QPointF scenePos = viewportTransform ().inverted ().map (tabletPos);
qreal pressure = 1.0; qreal pressure = 1.0;
if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line) && mPenPressureSensitive) || if (((currentTool == UBStylusTool::Pen || currentTool == UBStylusTool::Line || currentTool == UBStylusTool::Vector) && mPenPressureSensitive) ||
(currentTool == UBStylusTool::Marker && mMarkerPressureSensitive)) (currentTool == UBStylusTool::Marker && mMarkerPressureSensitive))
pressure = event->pressure (); pressure = event->pressure ();
else{ else{
@ -1821,6 +1821,9 @@ void UBBoardView::setToolCursor (int tool)
case UBStylusTool::Line: case UBStylusTool::Line:
controlViewport->setCursor (UBResources::resources ()->penCursor); controlViewport->setCursor (UBResources::resources ()->penCursor);
break; break;
case UBStylusTool::Vector:
controlViewport->setCursor (UBResources::resources ()->penCursor);
break;
case UBStylusTool::Text: case UBStylusTool::Text:
controlViewport->setCursor (UBResources::resources ()->textCursor); controlViewport->setCursor (UBResources::resources ()->textCursor);
break; break;

@ -75,6 +75,7 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool))); connect(UBApplication::mainWindow->actionZoomOut, SIGNAL(triggered(bool)), this, SLOT(zoomOutToolSelected(bool)));
connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered(bool)), this, SLOT(pointerToolSelected(bool))); connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered(bool)), this, SLOT(pointerToolSelected(bool)));
connect(UBApplication::mainWindow->actionLine, SIGNAL(triggered(bool)), this, SLOT(lineToolSelected(bool))); connect(UBApplication::mainWindow->actionLine, SIGNAL(triggered(bool)), this, SLOT(lineToolSelected(bool)));
connect(UBApplication::mainWindow->actionVector, SIGNAL(triggered(bool)), this, SLOT(vectorToolSelected(bool)));
connect(UBApplication::mainWindow->actionText, SIGNAL(triggered(bool)), this, SLOT(textToolSelected(bool))); connect(UBApplication::mainWindow->actionText, SIGNAL(triggered(bool)), this, SLOT(textToolSelected(bool)));
connect(UBApplication::mainWindow->actionCapture, SIGNAL(triggered(bool)), this, SLOT(captureToolSelected(bool))); connect(UBApplication::mainWindow->actionCapture, SIGNAL(triggered(bool)), this, SLOT(captureToolSelected(bool)));
} }
@ -104,12 +105,12 @@ void UBDrawingController::setStylusTool(int tool)
{ {
UBApplication::boardController->activeScene()->deselectAllItems(); UBApplication::boardController->activeScene()->deselectAllItems();
if (mStylusTool == UBStylusTool::Pen || mStylusTool == UBStylusTool::Marker if (mStylusTool == UBStylusTool::Pen || mStylusTool == UBStylusTool::Marker
|| mStylusTool == UBStylusTool::Line) || mStylusTool == UBStylusTool::Line || mStylusTool == UBStylusTool::Vector)
{ {
mLatestDrawingTool = mStylusTool; mLatestDrawingTool = mStylusTool;
} }
if (tool == UBStylusTool::Pen || tool == UBStylusTool::Line) if (tool == UBStylusTool::Pen || tool == UBStylusTool::Line || tool == UBStylusTool::Vector)
{ {
emit lineWidthIndexChanged(UBSettings::settings()->penWidthIndex()); emit lineWidthIndexChanged(UBSettings::settings()->penWidthIndex());
emit colorIndexChanged(UBSettings::settings()->penColorIndex()); emit colorIndexChanged(UBSettings::settings()->penColorIndex());
@ -144,6 +145,8 @@ void UBDrawingController::setStylusTool(int tool)
UBApplication::mainWindow->actionPointer->setChecked(true); UBApplication::mainWindow->actionPointer->setChecked(true);
else if (mStylusTool == UBStylusTool::Line) else if (mStylusTool == UBStylusTool::Line)
UBApplication::mainWindow->actionLine->setChecked(true); UBApplication::mainWindow->actionLine->setChecked(true);
else if (mStylusTool == UBStylusTool::Vector)
UBApplication::mainWindow->actionVector->setChecked(true);
else if (mStylusTool == UBStylusTool::Text) else if (mStylusTool == UBStylusTool::Text)
UBApplication::mainWindow->actionText->setChecked(true); UBApplication::mainWindow->actionText->setChecked(true);
else if (mStylusTool == UBStylusTool::Capture) else if (mStylusTool == UBStylusTool::Capture)
@ -160,13 +163,14 @@ bool UBDrawingController::isDrawingTool()
{ {
return (stylusTool() == UBStylusTool::Pen) return (stylusTool() == UBStylusTool::Pen)
|| (stylusTool() == UBStylusTool::Marker) || (stylusTool() == UBStylusTool::Marker)
|| (stylusTool() == UBStylusTool::Vector)
|| (stylusTool() == UBStylusTool::Line); || (stylusTool() == UBStylusTool::Line);
} }
int UBDrawingController::currentToolWidthIndex() int UBDrawingController::currentToolWidthIndex()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector)
return UBSettings::settings()->penWidthIndex(); return UBSettings::settings()->penWidthIndex();
else if (stylusTool() == UBStylusTool::Marker) else if (stylusTool() == UBStylusTool::Marker)
return UBSettings::settings()->markerWidthIndex(); return UBSettings::settings()->markerWidthIndex();
@ -177,7 +181,7 @@ int UBDrawingController::currentToolWidthIndex()
qreal UBDrawingController::currentToolWidth() qreal UBDrawingController::currentToolWidth()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector)
return UBSettings::settings()->currentPenWidth(); return UBSettings::settings()->currentPenWidth();
else if (stylusTool() == UBStylusTool::Marker) else if (stylusTool() == UBStylusTool::Marker)
return UBSettings::settings()->currentMarkerWidth(); return UBSettings::settings()->currentMarkerWidth();
@ -198,6 +202,7 @@ void UBDrawingController::setLineWidthIndex(int index)
UBSettings::settings()->setPenWidthIndex(index); UBSettings::settings()->setPenWidthIndex(index);
if(stylusTool() != UBStylusTool::Line if(stylusTool() != UBStylusTool::Line
&& stylusTool() != UBStylusTool::Vector
&& stylusTool() != UBStylusTool::Selector) && stylusTool() != UBStylusTool::Selector)
{ {
setStylusTool(UBStylusTool::Pen); setStylusTool(UBStylusTool::Pen);
@ -210,7 +215,7 @@ void UBDrawingController::setLineWidthIndex(int index)
int UBDrawingController::currentToolColorIndex() int UBDrawingController::currentToolColorIndex()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector)
{ {
return UBSettings::settings()->penColorIndex(); return UBSettings::settings()->penColorIndex();
} }
@ -233,7 +238,7 @@ QColor UBDrawingController::currentToolColor()
QColor UBDrawingController::toolColor(bool onDarkBackground) QColor UBDrawingController::toolColor(bool onDarkBackground)
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line || stylusTool() == UBStylusTool::Vector)
{ {
return UBSettings::settings()->penColor(onDarkBackground); return UBSettings::settings()->penColor(onDarkBackground);
} }
@ -390,6 +395,11 @@ void UBDrawingController::lineToolSelected(bool checked)
setStylusTool(UBStylusTool::Line); setStylusTool(UBStylusTool::Line);
} }
void UBDrawingController::vectorToolSelected(bool checked)
{
if (checked)
setStylusTool(UBStylusTool::Vector);
}
void UBDrawingController::textToolSelected(bool checked) void UBDrawingController::textToolSelected(bool checked)
{ {

@ -107,6 +107,7 @@ class UBDrawingController : public QObject
void zoomOutToolSelected(bool checked); void zoomOutToolSelected(bool checked);
void pointerToolSelected(bool checked); void pointerToolSelected(bool checked);
void lineToolSelected(bool checked); void lineToolSelected(bool checked);
void vectorToolSelected(bool checked);
void textToolSelected(bool checked); void textToolSelected(bool checked);
void captureToolSelected(bool checked); void captureToolSelected(bool checked);
}; };

@ -71,6 +71,7 @@ struct UBStylusTool
ZoomOut, ZoomOut,
Pointer, Pointer,
Line, Line,
Vector,
Text, Text,
Capture Capture
}; };

@ -539,7 +539,7 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
width /= UBApplication::boardController->systemScaleFactor(); width /= UBApplication::boardController->systemScaleFactor();
width /= UBApplication::boardController->currentZoom(); width /= UBApplication::boardController->currentZoom();
if (currentTool == UBStylusTool::Line || dc->mActiveRuler) if (currentTool == UBStylusTool::Line || dc->mActiveRuler || currentTool == UBStylusTool::Vector)
{ {
if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker) if (UBDrawingController::drawingController()->stylusTool() != UBStylusTool::Marker)
if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){ if(NULL != mpLastPolygon && NULL != mCurrentStroke && mAddedItems.size() > 0){
@ -580,7 +580,9 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
else if (currentTool == UBStylusTool::Line) { else if (currentTool == UBStylusTool::Line) {
drawLineTo(position, width, true); drawLineTo(position, width, true);
} }
else if (currentTool == UBStylusTool::Vector) {
drawLineTo(position, width, true);
}
else { else {
bool interpolate = false; bool interpolate = false;

@ -61,6 +61,7 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
actions << UBApplication::mainWindow->actionPointer; actions << UBApplication::mainWindow->actionPointer;
actions << UBApplication::mainWindow->actionLine; actions << UBApplication::mainWindow->actionLine;
actions << UBApplication::mainWindow->actionVector;
actions << UBApplication::mainWindow->actionText; actions << UBApplication::mainWindow->actionText;
actions << UBApplication::mainWindow->actionCapture; actions << UBApplication::mainWindow->actionCapture;

@ -210,6 +210,7 @@ void UBToolbarButtonGroup::colorPaletteChanged()
QList<QColor> colors; QList<QColor> colors;
if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen if (UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Pen
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Vector
|| UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line) || UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line)
{ {
colors = UBSettings::settings()->penColors(isDarkBackground); colors = UBSettings::settings()->penColors(isDarkBackground);

Loading…
Cancel
Save