LineStyle toolBar

lineStyle
thomas_lucky13 2 years ago
parent e6d6d29566
commit 9194120bc8
  1. 50
      resources/forms/mainWindow.ui
  2. 25
      src/board/UBBoardController.cpp
  3. 3
      src/board/UBBoardController.h
  4. 5
      src/board/UBDrawingController.cpp
  5. 1
      src/board/UBDrawingController.h
  6. 10
      src/core/UB.h
  7. 35
      src/core/UBSettings.cpp
  8. 6
      src/core/UBSettings.h
  9. 2
      src/domain/UBGraphicsScene.cpp

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1342</width>
<height>223</height>
<height>268</height>
</rect>
</property>
<property name="windowTitle">
@ -1702,6 +1702,54 @@
<string>Draw intermediate grid lines</string>
</property>
</action>
<action name="actionLineSolid">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/toolbar/smallEraser.png</normaloff>:/images/toolbar/smallEraser.png</iconset>
</property>
<property name="text">
<string>Line Style</string>
</property>
<property name="toolTip">
<string>Solid Style</string>
</property>
</action>
<action name="actionLineDashed">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/toolbar/mediumEraser.png</normaloff>:/images/toolbar/mediumEraser.png</iconset>
</property>
<property name="text">
<string>Line Style</string>
</property>
<property name="toolTip">
<string>Dashed Style</string>
</property>
</action>
<action name="actionLineDotted">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../OpenBoard.qrc">
<normaloff>:/images/toolbar/largeEraser.png</normaloff>:/images/toolbar/largeEraser.png</iconset>
</property>
<property name="text">
<string>Line Style</string>
</property>
<property name="toolTip">
<string>Dotted Style</string>
</property>
</action>
</widget>
<resources>
<include location="../OpenBoard.qrc"/>

@ -376,6 +376,27 @@ void UBBoardController::setupToolbar()
mMainWindow->boardToolBar->insertSeparator(mMainWindow->actionBackgrounds);
mPropertyPaletteWidgets.insert(eraserWidth, newPropertyPaletteWidget);
//-----------------------------------------------------------//
// Setup line style choice widget
QList<QAction *> lineStyleActions;
lineStyleActions.append(mMainWindow->actionLineSolid);
lineStyleActions.append(mMainWindow->actionLineDashed);
lineStyleActions.append(mMainWindow->actionLineDotted);
UBToolbarButtonGroup *lineStyleChoice =
new UBToolbarButtonGroup(mMainWindow->boardToolBar, lineStyleActions);
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), lineStyleChoice, SLOT(displayText(QVariant)));
connect(lineStyleChoice, SIGNAL(activated(int)),
UBDrawingController::drawingController(), SLOT(setLineStyleIndex(int)));
lineStyleChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
newPropertyPaletteWidget = mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, lineStyleChoice);
lineStyleChoice->setCurrentIndex(settings->lineStyleIndex());
lineStyleActions.at(settings->lineStyleIndex())->setChecked(true);
mPropertyPaletteWidgets.insert(lineStyle, newPropertyPaletteWidget);
//-----------------------------------------------------------//
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBackgrounds);
@ -2209,23 +2230,27 @@ void UBBoardController::stylusToolChanged(int tool)
mPropertyPaletteWidgets[color]->setVisible(true);
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Eraser)
{
mPropertyPaletteWidgets[color]->setVisible(false);
mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(true);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
} else
if (eTool == UBStylusTool::Line)
{
mPropertyPaletteWidgets[color]->setVisible(true);
mPropertyPaletteWidgets[lineWidth]->setVisible(true);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(true);
} else
{
mPropertyPaletteWidgets[color]->setVisible(false);
mPropertyPaletteWidgets[lineWidth]->setVisible(false);
mPropertyPaletteWidgets[eraserWidth]->setVisible(false);
mPropertyPaletteWidgets[lineStyle]->setVisible(false);
}

@ -326,7 +326,8 @@ class UBBoardController : public UBDocumentContainer
{
color,
lineWidth,
eraserWidth
eraserWidth,
lineStyle
};
QMap<PropertyPalette, QAction*> mPropertyPaletteWidgets;

@ -279,6 +279,11 @@ void UBDrawingController::setEraserWidthIndex(int index)
UBSettings::settings()->setEraserWidthIndex(index);
}
void UBDrawingController::setLineStyleIndex(int index)
{
UBSettings::settings()->setLineStyleIndex(index);
}
void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{
if (onDarkBackground)

@ -80,6 +80,7 @@ class UBDrawingController : public QObject
void setLineWidthIndex(int index);
void setColorIndex(int index);
void setEraserWidthIndex(int index);
void setLineStyleIndex(int index);
signals:
void stylusToolChanged(int tool, int previousTool = -1);

@ -84,6 +84,16 @@ struct UBWidth
};
};
struct UBLineStyle
{
enum Enum
{
Solid = 0,
Dashed = 1,
Dotted = 2
};
};
struct UBZoom
{
enum Enum

@ -785,6 +785,41 @@ qreal UBSettings::currentEraserWidth()
return width;
}
//----------------------------------------//
// line
int UBSettings::lineStyleIndex()
{
return value("Board/LineStyleIndex", 0).toInt();
}
void UBSettings::setLineStyleIndex(int index)
{
setValue("Board/LineStyleIndex", index);
}
Qt::PenStyle UBSettings::currentLineStyle()
{
Qt::PenStyle style = Qt::SolidLine;
switch (lineStyleIndex())
{
case UBLineStyle::Solid:
style = Qt::SolidLine;
break;
case UBLineStyle::Dotted:
style = Qt::DotLine;
break;
case UBLineStyle::Dashed:
style = Qt::DashLine;
break;
default:
Q_ASSERT(false);
style = Qt::SolidLine;
break;
}
return style;
}
bool UBSettings::isDarkBackground()
{
return value("Board/DarkBackground", 0).toBool();

@ -85,6 +85,10 @@ class UBSettings : public QObject
qreal eraserStrongWidth();
qreal currentEraserWidth();
// Line related
int lineStyleIndex();
Qt::PenStyle currentLineStyle();
// Background related
bool isDarkBackground();
UBPageBackground pageBackground();
@ -443,6 +447,8 @@ class UBSettings : public QObject
void setEraserMediumWidth(qreal width);
void setEraserStrongWidth(qreal width);
void setLineStyleIndex(int index);
void setStylusPaletteVisible(bool visible);
void setPenPressureSensitive(bool sensitive);

@ -1362,7 +1362,7 @@ void UBGraphicsScene::initLineItem(UBGraphicsLineItem* lineItem)
lineItem->setColorOnLightBackground(colorOnLightBG);
lineItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
//lineItem->setStyle(UBSettings::settings()->currentLineStyle());
lineItem->setStyle(UBSettings::settings()->currentLineStyle());
QPen linePen = lineItem->pen();
linePen.setWidth(lineItem->originalWidth());

Loading…
Cancel
Save