diff --git a/resources/forms/mainWindow.ui b/resources/forms/mainWindow.ui
index fe527d3a..2b3d32ed 100644
--- a/resources/forms/mainWindow.ui
+++ b/resources/forms/mainWindow.ui
@@ -1769,6 +1769,54 @@
Ctrl+J
+
+
+ true
+
+
+
+ :/images/toolbar/solidLine.svg:/images/toolbar/solidLine.svg
+
+
+ Vector Style
+
+
+ To Style
+
+
+
+
+ true
+
+
+ true
+
+
+
+ :/images/toolbar/dashedLine.svg:/images/toolbar/dashedLine.svg
+
+
+ Vector Style
+
+
+ From Style
+
+
+
+
+ true
+
+
+
+ :/images/toolbar/dottedLine.svg:/images/toolbar/dottedLine.svg
+
+
+ Vector Style
+
+
+ FromTo Style
+
+
diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp
index 6f840c9a..0b0b7b0d 100644
--- a/src/adaptors/UBSvgSubsetAdaptor.cpp
+++ b/src/adaptors/UBSvgSubsetAdaptor.cpp
@@ -1794,18 +1794,17 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::vectorItemToSvgVector(UBGraphicsVect
mXmlWriter.writeAttribute("stroke-opacity", QString::number(alpha, 'f', 2));
mXmlWriter.writeAttribute("stroke-linecap", "round");
- /* VectorStyle
- switch (vectorItem->style())
+ switch (vectorItem->getStyle())
{
- case Qt::PenStyle::DotLine:
- mXmlWriter.writeAttribute("line-style", "2");
+ case UBVectorStyle::From:
+ mXmlWriter.writeAttribute("vector-style", "1");
break;
- case Qt::PenStyle::DashLine:
- mXmlWriter.writeAttribute("line-style", "1");
+ case UBVectorStyle::FromTo:
+ mXmlWriter.writeAttribute("vector-style", "2");
break;
default:
- mXmlWriter.writeAttribute("line-style", "0");
- }*/
+ mXmlWriter.writeAttribute("vector-style", "0");
+ }
if (!groupHoldsInfo)
{
@@ -2329,17 +2328,17 @@ UBGraphicsVectorItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::vectorItemFromVecto
}
vectorItem->setColor(penColor);
- /* VectorStyle
+
if (style == 2)
{
- vectorItem->setStyle(Qt::PenStyle::DotLine);
+ vectorItem->setStyle(UBVectorStyle::FromTo);
} else if (style == 1)
{
- lineItem->setStyle(Qt::PenStyle::DashLine);
+ vectorItem->setStyle(UBVectorStyle::From);
} else
{
- lineItem->setStyle(Qt::PenStyle::SolidLine);
- }*/
+ vectorItem->setStyle(UBVectorStyle::To);
+ }
QStringRef ubFillOnDarkBackground = mXmlReader.attributes().value(mNamespaceUri, "fill-on-dark-background");
diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp
index 139dde62..4a6812d1 100644
--- a/src/board/UBBoardController.cpp
+++ b/src/board/UBBoardController.cpp
@@ -399,6 +399,28 @@ void UBBoardController::setupToolbar()
//-----------------------------------------------------------//
+ // Setup vector style choice widget
+ QList vectorStyleActions;
+ vectorStyleActions.append(mMainWindow->actionVectorTo);
+ vectorStyleActions.append(mMainWindow->actionVectorFrom);
+ vectorStyleActions.append(mMainWindow->actionVectorFromTo);
+
+ UBToolbarButtonGroup *vectorStyleChoice =
+ new UBToolbarButtonGroup(mMainWindow->boardToolBar, vectorStyleActions);
+
+ connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), vectorStyleChoice, SLOT(displayText(QVariant)));
+
+ connect(vectorStyleChoice, SIGNAL(activated(int)),
+ UBDrawingController::drawingController(), SLOT(setVectorStyleIndex(int)));
+
+ vectorStyleChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
+ newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, vectorStyleChoice);
+ vectorStyleChoice->setCurrentIndex(settings->vectorStyleIndex());
+ vectorStyleActions.at(settings->vectorStyleIndex())->setChecked(true);
+ mPropertyPaletteWidgets.insert(vectorStyle, newPropertyPaletteWidget);
+
+ //-----------------------------------------------------------//
+
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBackgrounds);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard, 40);
UBApplication::app()->decorateActionMenu(mMainWindow->actionMenu);
@@ -2233,6 +2255,7 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
+ mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Eraser)
{
@@ -2240,6 +2263,7 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(true);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
+ mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Line)
{
@@ -2247,6 +2271,7 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(true);
+ mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Vector)
{
@@ -2254,12 +2279,14 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
+ mPropertyPaletteWidgets[vectorStyle]->setVisible(true);
} else
{
mPropertyPaletteWidgets[color]->setVisible(false);
mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
+ mPropertyPaletteWidgets[vectorStyle]->setVisible(false);
}
diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h
index f582d3a2..61761ded 100644
--- a/src/board/UBBoardController.h
+++ b/src/board/UBBoardController.h
@@ -327,7 +327,8 @@ class UBBoardController : public UBDocumentContainer
color,
lineWidth,
eraserWidth,
- lineStyle
+ lineStyle,
+ vectorStyle
};
QMap mPropertyPaletteWidgets;
diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp
index d75e2895..1cb32745 100644
--- a/src/board/UBDrawingController.cpp
+++ b/src/board/UBDrawingController.cpp
@@ -289,6 +289,11 @@ void UBDrawingController::setLineStyleIndex(int index)
UBSettings::settings()->setLineStyleIndex(index);
}
+void UBDrawingController::setVectorStyleIndex(int index)
+{
+ UBSettings::settings()->setVectorStyleIndex(index);
+}
+
void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{
if (onDarkBackground)
diff --git a/src/board/UBDrawingController.h b/src/board/UBDrawingController.h
index 1cdff717..d6b79b55 100644
--- a/src/board/UBDrawingController.h
+++ b/src/board/UBDrawingController.h
@@ -82,6 +82,7 @@ class UBDrawingController : public QObject
void setColorIndex(int index);
void setEraserWidthIndex(int index);
void setLineStyleIndex(int index);
+ void setVectorStyleIndex(int index);
signals:
void stylusToolChanged(int tool, int previousTool = -1);
diff --git a/src/core/UB.h b/src/core/UB.h
index cd568c35..9ad4923d 100644
--- a/src/core/UB.h
+++ b/src/core/UB.h
@@ -95,6 +95,16 @@ struct UBLineStyle
};
};
+struct UBVectorStyle
+{
+ enum Enum
+ {
+ To = 0,
+ From = 1,
+ FromTo = 2
+ };
+};
+
struct UBZoom
{
enum Enum
diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp
index 09135e60..6456a118 100644
--- a/src/core/UBSettings.cpp
+++ b/src/core/UBSettings.cpp
@@ -820,6 +820,36 @@ Qt::PenStyle UBSettings::currentLineStyle()
return style;
}
+int UBSettings::vectorStyleIndex()
+{
+ return value("Board/VectorStyleIndex", 0).toInt();
+}
+
+void UBSettings::setVectorStyleIndex(int index)
+{
+ setValue("Board/VectorStyleIndex", index);
+}
+UBVectorStyle::Enum UBSettings::currentVectorStyle()
+{
+ switch (vectorStyleIndex())
+ {
+ case UBVectorStyle::To:
+ return UBVectorStyle::To;
+ break;
+ case UBVectorStyle::From:
+ return UBVectorStyle::From;
+ break;
+ case UBVectorStyle::FromTo:
+ return UBVectorStyle::FromTo;
+ break;
+ default:
+ Q_ASSERT(false);
+ return UBVectorStyle::To;
+ break;
+ }
+ return UBVectorStyle::To;
+}
+
bool UBSettings::isDarkBackground()
{
return value("Board/DarkBackground", 0).toBool();
diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h
index 77cefead..ad423541 100644
--- a/src/core/UBSettings.h
+++ b/src/core/UBSettings.h
@@ -89,6 +89,10 @@ class UBSettings : public QObject
int lineStyleIndex();
Qt::PenStyle currentLineStyle();
+ // Line related
+ int vectorStyleIndex();
+ UBVectorStyle::Enum currentVectorStyle();
+
// Background related
bool isDarkBackground();
UBPageBackground pageBackground();
@@ -448,6 +452,7 @@ class UBSettings : public QObject
void setEraserStrongWidth(qreal width);
void setLineStyleIndex(int index);
+ void setVectorStyleIndex(int index);
void setStylusPaletteVisible(bool visible);
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
index 38741d6f..f6d6c5df 100644
--- a/src/domain/UBGraphicsScene.cpp
+++ b/src/domain/UBGraphicsScene.cpp
@@ -1439,6 +1439,7 @@ void UBGraphicsScene::initVectorItem(UBGraphicsVectorItem* vectorItem)
}
vectorItem->setColorOnDarkBackground(colorOnDarkBG);
vectorItem->setColorOnLightBackground(colorOnLightBG);
+ vectorItem->setStyle(UBSettings::settings()->currentVectorStyle());
vectorItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
}
diff --git a/src/domain/UBGraphicsVectorItem.cpp b/src/domain/UBGraphicsVectorItem.cpp
index 22d5a5bb..7f4b1419 100644
--- a/src/domain/UBGraphicsVectorItem.cpp
+++ b/src/domain/UBGraphicsVectorItem.cpp
@@ -63,13 +63,32 @@ void UBGraphicsVectorItem::initialize()
void UBGraphicsVectorItem::setSublines()
{
- QLineF thisLine = QLineF(this->line().p2().x(), this->line().p2().y(),this->line().p2().x()+this->line().length()/10, this->line().p2().y());
- thisLine.setAngle(this->line().angle() - 135);
- sublines.push_back(new QGraphicsLineItem(thisLine));
+ for(int i = 0; i < sublines.length(); ++i)
+ {
+ delete sublines[i];
+ }
+ if ((style == UBVectorStyle::To) || (style == UBVectorStyle::FromTo))
+ {
+ QLineF thisLine = QLineF(this->line().p2().x(), this->line().p2().y(),this->line().p2().x()+this->line().length()/10, this->line().p2().y());
+ thisLine.setAngle(this->line().angle() - 135);
+ sublines.push_back(new QGraphicsLineItem(thisLine));
+
+ thisLine = QLineF(this->line().p2().x(), this->line().p2().y(),this->line().p2().x()+this->line().length()/10, this->line().p2().y());
+ thisLine.setAngle(this->line().angle() + 135);
+ sublines.push_back(new QGraphicsLineItem(thisLine));
+ }
+
+ if ((style == UBVectorStyle::From) || (style == UBVectorStyle::FromTo))
+ {
+ QLineF thisLine = QLineF(this->line().p1().x(), this->line().p1().y(),this->line().p1().x()+this->line().length()/10, this->line().p1().y());
+ thisLine.setAngle(this->line().angle() - 45);
+ sublines.push_back(new QGraphicsLineItem(thisLine));
+
+ thisLine = QLineF(this->line().p1().x(), this->line().p1().y(),this->line().p1().x()+this->line().length()/10, this->line().p1().y());
+ thisLine.setAngle(this->line().angle() + 45);
+ sublines.push_back(new QGraphicsLineItem(thisLine));
+ }
- thisLine = QLineF(this->line().p2().x(), this->line().p2().y(),this->line().p2().x()+this->line().length()/10, this->line().p2().y());
- thisLine.setAngle(this->line().angle() + 135);
- sublines.push_back(new QGraphicsLineItem(thisLine));
}
void UBGraphicsVectorItem::setUuid(const QUuid &pUuid)
@@ -88,7 +107,6 @@ UBGraphicsVectorItem::~UBGraphicsVectorItem()
void UBGraphicsVectorItem::setColor(const QColor& pColor)
{
QPen pen = QPen(pColor);
- pen.setStyle(style());
pen.setCapStyle(Qt::PenCapStyle::RoundCap);
pen.setWidth(mOriginalWidth);
QGraphicsLineItem::setPen(pen);
@@ -103,20 +121,12 @@ QColor UBGraphicsVectorItem::color() const
return QGraphicsLineItem::pen().color();
}
-void UBGraphicsVectorItem::setStyle(const Qt::PenStyle& style)
+void UBGraphicsVectorItem::setStyle(const UBVectorStyle::Enum& _style)
{
- QPen pen = QPen(color());
- pen.setStyle(style);
- pen.setCapStyle(Qt::PenCapStyle::RoundCap);
- pen.setWidth(mOriginalWidth);
- QGraphicsLineItem::setPen(pen);
+ style = _style;
+ setSublines();
for (int i = 0; i < sublines.size(); ++i)
- sublines[i]->setPen(pen);
-}
-
-Qt::PenStyle UBGraphicsVectorItem::style() const
-{
- return QGraphicsLineItem::pen().style();
+ sublines[i]->setPen(this->pen());
}
QList UBGraphicsVectorItem::linePoints()
diff --git a/src/domain/UBGraphicsVectorItem.h b/src/domain/UBGraphicsVectorItem.h
index 7227065b..96734521 100644
--- a/src/domain/UBGraphicsVectorItem.h
+++ b/src/domain/UBGraphicsVectorItem.h
@@ -27,10 +27,13 @@ public:
void setUuid(const QUuid &pUuid);
void setColor(const QColor& color);
- void setStyle(const Qt::PenStyle& style);
+ void setStyle(const UBVectorStyle::Enum& _style);
+ UBVectorStyle::Enum getStyle()
+ {
+ return style;
+ }
QColor color() const;
- Qt::PenStyle style() const;
virtual UBGraphicsScene* scene();
@@ -102,6 +105,7 @@ public:
QColor mColorOnDarkBackground;
QColor mColorOnLightBackground;
QList sublines;
+ UBVectorStyle::Enum style;
};
#endif // UBGRAPHICSVECTORITEM_H