diff --git a/src/backend/worksheet/TextLabel.h b/src/backend/worksheet/TextLabel.h --- a/src/backend/worksheet/TextLabel.h +++ b/src/backend/worksheet/TextLabel.h @@ -37,6 +37,7 @@ #include #include #include +#include class TextLabelPrivate; @@ -52,19 +53,53 @@ enum HorizontalAlignment {hAlignLeft, hAlignCenter, hAlignRight}; enum VerticalAlignment {vAlignTop, vAlignCenter, vAlignBottom}; - struct TextWrapper { - TextWrapper() : teXUsed(false) {} - TextWrapper(const QString& t, bool b) : text(t), teXUsed(b) {} - TextWrapper(const QString& t) : text(t), teXUsed(false) {} - QString text; - bool teXUsed; - }; + + enum LabelShape { + Rect=0, + Ellipse, + RoundSideRect, + RoundCornerRect, + InwardsRoundCornerRect, + DentedBorderRect, + Cuboid, + UpPointingRectangle, + DownPointingRectangle, + LeftPointingRectangle, + RightPointingRectangle + + }; + + Qt::BrushStyle patternStyle; + Qt::PenStyle borderstyle; + + void chooseLabelsShape(const int); + TextLabel::LabelShape getLabelShape(); + int getLabelShapeint(); + int getLabelBorder(); + TextLabelPrivate * qp; + QColor backColor; + QColor borderColor; + void chooseLabelBackColor(const QColor); + void chooseLabelBorder(const int); + void chooseLabelBorderColor(const QColor); + void choosePatternStyle(const int); + int getPatternStyle(); + + struct TextWrapper { + TextWrapper() : teXUsed(false) {} + TextWrapper(const QString& t, bool b) : text(t), teXUsed(b) {} + TextWrapper(const QString& t) : text(t), teXUsed(false) {} + + QString text; + bool teXUsed; + }; struct PositionWrapper { QPointF point; HorizontalPosition horizontalPosition; VerticalPosition verticalPosition; + }; explicit TextLabel(const QString& name, Type type = General); @@ -92,6 +127,8 @@ BASIC_D_ACCESSOR_DECL(VerticalAlignment, verticalAlignment, VerticalAlignment); BASIC_D_ACCESSOR_DECL(qreal, rotationAngle, RotationAngle); + BASIC_D_ACCESSOR_DECL(LabelShape, labelShape, LabelShape); + void setVisible(bool on) override; bool isVisible() const override; void setPrinting(bool) override; @@ -118,6 +155,10 @@ Type m_type; QAction* visibilityAction; + + int m_labelshape; + int m_patternStyle; + signals: friend class TextLabelSetTextCmd; friend class TextLabelSetTeXFontCmd; diff --git a/src/backend/worksheet/TextLabel.cpp b/src/backend/worksheet/TextLabel.cpp --- a/src/backend/worksheet/TextLabel.cpp +++ b/src/backend/worksheet/TextLabel.cpp @@ -77,6 +77,13 @@ void TextLabel::init() { Q_D(TextLabel); + + m_labelshape = 0; + backColor = Qt::transparent; + borderstyle = Qt::SolidLine; + patternStyle = Qt::SolidPattern; + m_patternStyle = 1; + KConfig config; KConfigGroup group; if (m_type == AxisTitle) @@ -502,20 +509,188 @@ /*! recalculates the outer bounds and the shape of the label. */ -void TextLabelPrivate::recalcShapeAndBoundingRect() { - prepareGeometryChange(); - - QMatrix matrix; - matrix.rotate(-rotationAngle); - transformedBoundingRectangle = matrix.mapRect(boundingRectangle); - - labelShape = QPainterPath(); - labelShape.addRect(boundingRectangle); - labelShape = matrix.map(labelShape); - - emit(q->changed()); +void TextLabelPrivate::recalcShapeAndBoundingRect(const TextLabel::LabelShape lbShape) { + prepareGeometryChange(); + + QMatrix matrix; + matrix.rotate(-rotationAngle); + transformedBoundingRectangle = matrix.mapRect(boundingRectangle); + + labelShape = QPainterPath(); + + + if(lbShape == TextLabel::LabelShape::Rect) + labelShape.addRect(boundingRectangle); + + else if(lbShape == TextLabel::LabelShape::Ellipse) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.addEllipse(xs-0.1*w, ys-0.1*h, 1.2*w, 1.2*h); + } + else if(lbShape == TextLabel::LabelShape::RoundSideRect) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs, ys); + labelShape.lineTo(xs+w, ys); + labelShape.quadTo(xs+w+h/2, ys+h/2, xs+w, ys+h); + labelShape.lineTo(xs, ys+h); + labelShape.quadTo(xs-h/2, ys+h/2, xs, ys); + } + else if(lbShape == TextLabel::LabelShape::RoundCornerRect) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs+h*0.2, ys); + labelShape.lineTo(xs+w-h*0.2, ys); + labelShape.quadTo(xs+w, ys, xs+w, ys+h*0.2); + labelShape.lineTo(xs+w, ys+h-0.2*h); + labelShape.quadTo(xs+w, ys+h, xs+w-0.2*h, ys+h); + labelShape.lineTo(xs+0.2*h, ys+h); + labelShape.quadTo(xs, ys+h, xs, ys+h-0.2*h); + labelShape.lineTo(xs, ys+0.2*h); + labelShape.quadTo(xs, ys, xs+0.2*h, ys); + + } + else if (lbShape == TextLabel::LabelShape::InwardsRoundCornerRect) + { + + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs, ys-0.3*h); + labelShape.lineTo(xs+w, ys-0.3*h); + labelShape.quadTo(xs+w, ys, xs+w+0.3*h, ys); + labelShape.lineTo(xs+w+0.3*h, ys+h); + labelShape.quadTo(xs+w, ys+h, xs+w, ys+h+0.3*h); + labelShape.lineTo(xs, ys+h+0.3*h); + labelShape.quadTo(xs, ys+h, xs-0.3*h, ys+h); + labelShape.lineTo(xs-0.3*h, ys); + labelShape.quadTo(xs, ys, xs, ys-0.3*h); + } + else if (lbShape == TextLabel::LabelShape::DentedBorderRect) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs-0.2*h, ys-0.2*h); + labelShape.quadTo(xs+w/2, ys, xs+w+0.2*h, ys-0.2*h); + labelShape.quadTo(xs+w, ys+h/2, xs+w+0.2*h, ys+h+0.2*h); + labelShape.quadTo(xs+w/2, ys+h, xs-0.2*h, ys+h+0.2*h); + labelShape.quadTo(xs, ys+h/2, xs-0.2*h, ys-0.2*h); + } + else if (lbShape == TextLabel::LabelShape::Cuboid) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs, ys); + labelShape.lineTo(xs+w, ys); + labelShape.lineTo(xs+w, ys+h); + labelShape.lineTo(xs, ys+h); + labelShape.lineTo(xs, ys); + labelShape.lineTo(xs+0.3*h, ys-0.2*h); + labelShape.lineTo(xs+w+0.3*h, ys-0.2*h); + labelShape.lineTo(xs+w, ys); + labelShape.moveTo(xs+w, ys+h); + labelShape.lineTo(xs+w+0.3*h, ys+h-0.2*h); + labelShape.lineTo(xs+w+0.3*h, ys-0.2*h); + } + else if(lbShape == TextLabel::LabelShape::UpPointingRectangle) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs+h*0.2, ys); + labelShape.lineTo(xs+w/2-0.2*h, ys); + labelShape.lineTo(xs+w/2, ys-0.2*h); + labelShape.lineTo(xs+w/2+0.2*h, ys); + labelShape.lineTo(xs+w-h*0.2, ys); + labelShape.quadTo(xs+w, ys, xs+w, ys+h*0.2); + labelShape.lineTo(xs+w, ys+h-0.2*h); + labelShape.quadTo(xs+w, ys+h, xs+w-0.2*h, ys+h); + labelShape.lineTo(xs+0.2*h, ys+h); + labelShape.quadTo(xs, ys+h, xs, ys+h-0.2*h); + labelShape.lineTo(xs, ys+0.2*h); + labelShape.quadTo(xs, ys, xs+0.2*h, ys); + } + else if(lbShape == TextLabel::LabelShape::DownPointingRectangle) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs+h*0.2, ys); + labelShape.lineTo(xs+w-h*0.2, ys); + labelShape.quadTo(xs+w, ys, xs+w, ys+h*0.2); + labelShape.lineTo(xs+w, ys+h-0.2*h); + labelShape.quadTo(xs+w, ys+h, xs+w-0.2*h, ys+h); + labelShape.lineTo(xs+w/2+0.2*h, ys+h); + labelShape.lineTo(xs+w/2, ys+h+0.2*h); + labelShape.lineTo(xs+w/2-0.2*h, ys+h); + labelShape.lineTo(xs+0.2*h, ys+h); + labelShape.quadTo(xs, ys+h, xs, ys+h-0.2*h); + labelShape.lineTo(xs, ys+0.2*h); + labelShape.quadTo(xs, ys, xs+0.2*h, ys); + } + else if(lbShape == TextLabel::LabelShape::LeftPointingRectangle) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs+h*0.2, ys); + labelShape.lineTo(xs+w-h*0.2, ys); + labelShape.quadTo(xs+w, ys, xs+w, ys+h*0.2); + labelShape.lineTo(xs+w, ys+h-0.2*h); + labelShape.quadTo(xs+w, ys+h, xs+w-0.2*h, ys+h); + labelShape.lineTo(xs+0.2*h, ys+h); + labelShape.quadTo(xs, ys+h, xs, ys+h-0.2*h); + labelShape.lineTo(xs, ys+h/2+0.2*h); + labelShape.lineTo(xs-0.2*h, ys+h/2); + labelShape.lineTo(xs, ys+h/2-0.2*h); + labelShape.lineTo(xs, ys+0.2*h); + labelShape.quadTo(xs, ys, xs+0.2*h, ys); + } + + else if(lbShape == TextLabel::LabelShape::RightPointingRectangle) + { + double xs = boundingRectangle.x(); + double ys = boundingRectangle.y(); + double w = boundingRectangle.width(); + double h = boundingRectangle.height(); + labelShape.moveTo(xs+h*0.2, ys); + labelShape.lineTo(xs+w-h*0.2, ys); + labelShape.quadTo(xs+w, ys, xs+w, ys+h*0.2); + labelShape.lineTo(xs+w, ys+h/2-0.2*h); + labelShape.lineTo(xs+w+0.2*h, ys+h/2); + labelShape.lineTo(xs+w, ys+h/2+0.2*h); + labelShape.lineTo(xs+w, ys+h-0.2*h); + labelShape.quadTo(xs+w, ys+h, xs+w-0.2*h, ys+h); + labelShape.lineTo(xs+0.2*h, ys+h); + labelShape.quadTo(xs, ys+h, xs, ys+h-0.2*h); + labelShape.lineTo(xs, ys+0.2*h); + labelShape.quadTo(xs, ys, xs+0.2*h, ys); + } + + + labelShape = matrix.map(labelShape); + + emit(q->changed()); } + void TextLabelPrivate::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option) Q_UNUSED(widget) @@ -541,13 +716,34 @@ painter->restore(); if (m_hovered && !isSelected() && !m_printing){ - painter->setPen(QPen(QApplication::palette().color(QPalette::Shadow), 2, Qt::SolidLine)); - painter->drawPath(labelShape); + painter->setBrush(QBrush(q->backColor, q->patternStyle)); + painter->setPen(QPen(q->borderColor, 2, q->borderstyle)); + painter->drawPath(labelShape); + painter->save(); + painter->setBrush(QBrush(Qt::NoBrush)); + painter->setPen(QPen(Qt::black, 2, Qt::SolidLine)); + painter->rotate(-rotationAngle); + painter->scale(scaleFactor, scaleFactor); + float w = staticText.size().width(); + float h = staticText.size().height(); + painter->drawStaticText(QPoint(-w/2,-h/2), staticText); + painter->restore(); + } if (isSelected() && !m_printing){ - painter->setPen(QPen(QApplication::palette().color(QPalette::Highlight), 2, Qt::SolidLine)); + painter->setBrush(QBrush(q->backColor, q->patternStyle)); + painter->setPen(QPen(q->borderColor, 2, q->borderstyle)); painter->drawPath(labelShape); + painter->save(); + painter->setBrush(QBrush(Qt::NoBrush)); + painter->setPen(QPen(Qt::black, 2, Qt::SolidLine)); + painter->rotate(-rotationAngle); + painter->scale(scaleFactor, scaleFactor); + float w = staticText.size().width(); + float h = staticText.size().height(); + painter->drawStaticText(QPoint(-w/2,-h/2), staticText); + painter->restore(); } } @@ -688,6 +884,11 @@ writer->writeAttribute( "teXFontColor_b", QString::number(d->teXFontColor.blue()) ); writer->writeEndElement(); + + writer->writeStartElement("shape"); + writer->writeAttribute("ShapeType", QString::number(d->labelsShape)); + writer->writeEndElement(); + if (d->textWrapper.teXUsed) { writer->writeStartElement("teXImage"); QByteArray ba; @@ -764,7 +965,8 @@ if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("'verticalAlignment'")); else - d->verticalAlignment = (TextLabel::VerticalAlignment)str.toInt(); + d->verticalAlignment = (TextLabel::VerticalAlignment)str.toInt(); + str = attribs.value("rotationAngle").toString(); if(str.isEmpty()) @@ -812,7 +1014,19 @@ QString content = reader->text().toString().trimmed(); QByteArray ba = QByteArray::fromBase64(content.toAscii()); teXImageFound = d->teXImage.loadFromData(ba); - } else { // unknown element + } + + else if(!preview && reader->name() == "shape") + { + attribs = reader->attributes(); + str = attribs.value("ShapeType").toString(); + if(str.isEmpty()) + reader->raiseWarning(attributeWarning.arg("'ShapeType'")); + else + d->labelsShape =(TextLabel::LabelShape)str.toInt(); + } + + else { // unknown element reader->raiseWarning(i18n("unknown element '%1'", reader->name().toString())); if (!reader->skipToEndElement()) return false; } @@ -870,3 +1084,76 @@ //TODO // group.writeEntry("TeXFontColor", (QColor) this->teXFontColor()); } + +void TextLabel::chooseLabelsShape(const int shape) +{ + m_labelshape = shape; + d_ptr->labelsShape = (TextLabel::LabelShape)shape; + d_ptr->recalcShapeAndBoundingRect(static_cast(shape)); +} + +int TextLabel::getLabelShapeint() +{ + return m_labelshape; +} + +void TextLabel::chooseLabelBackColor(const QColor color) +{ + backColor = color; + d_ptr->recalcShapeAndBoundingRect(static_cast(m_labelshape)); +} + +void TextLabel::chooseLabelBorder(const int border) +{ + borderstyle = static_cast (border); + d_ptr->recalcShapeAndBoundingRect(static_cast(m_labelshape)); +} + +int TextLabel::getLabelBorder() +{ + return static_cast (borderstyle); +} + +void TextLabel::chooseLabelBorderColor(const QColor color) +{ + borderColor = color; + d_ptr->recalcShapeAndBoundingRect(static_cast(m_labelshape)); +} + +void TextLabel::choosePatternStyle(const int style) +{ + m_patternStyle = style; + switch(style) + { + case 0: + patternStyle = Qt::NoBrush; + break; + case 1: + patternStyle = Qt::SolidPattern; + break; + case 2: + patternStyle = Qt::Dense1Pattern; + break; + case 3: + patternStyle = Qt::HorPattern; + break; + case 4: + patternStyle = Qt::VerPattern; + break; + + case 5: + patternStyle = Qt::CrossPattern; + break; + default: + qDebug()<<"Bad index at patternStyle\n"; + break; + + } + d_ptr->recalcShapeAndBoundingRect(static_cast(m_labelshape)); +} + +int TextLabel::getPatternStyle() +{ + return m_patternStyle; +} + diff --git a/src/backend/worksheet/TextLabelPrivate.h b/src/backend/worksheet/TextLabelPrivate.h --- a/src/backend/worksheet/TextLabelPrivate.h +++ b/src/backend/worksheet/TextLabelPrivate.h @@ -56,11 +56,12 @@ TextLabel::HorizontalAlignment horizontalAlignment; TextLabel::VerticalAlignment verticalAlignment; + TextLabel::LabelShape labelsShape; QString name() const; void retransform(); bool swapVisible(bool on); - virtual void recalcShapeAndBoundingRect(); + virtual void recalcShapeAndBoundingRect(const TextLabel::LabelShape=TextLabel::LabelShape::Rect); void updatePosition(); QPointF positionFromItemPosition(const QPointF&); void updateText(); diff --git a/src/kdefrontend/dockwidgets/AxisDock.h b/src/kdefrontend/dockwidgets/AxisDock.h --- a/src/kdefrontend/dockwidgets/AxisDock.h +++ b/src/kdefrontend/dockwidgets/AxisDock.h @@ -55,6 +55,7 @@ Axis* m_axis; AspectTreeModel* m_aspectTreeModel; LabelWidget* labelWidget; + TreeViewComboBox* cbMajorTicksColumn; TreeViewComboBox* cbMinorTicksColumn; bool m_dataChanged; diff --git a/src/kdefrontend/dockwidgets/AxisDock.cpp b/src/kdefrontend/dockwidgets/AxisDock.cpp --- a/src/kdefrontend/dockwidgets/AxisDock.cpp +++ b/src/kdefrontend/dockwidgets/AxisDock.cpp @@ -36,6 +36,7 @@ #include "kdefrontend/TemplateHandler.h" #include "kdefrontend/widgets/LabelWidget.h" + #include #include #include @@ -50,7 +51,7 @@ */ AxisDock::AxisDock(QWidget* parent):QWidget(parent), m_axis(0), m_aspectTreeModel(0), m_dataChanged(0), m_initializing(false) { - ui.setupUi(this); + ui.setupUi(this); //"Title"-tab QHBoxLayout* hboxLayout = new QHBoxLayout(ui.tabTitle); diff --git a/src/kdefrontend/ui/dockwidgets/axisdock.ui b/src/kdefrontend/ui/dockwidgets/axisdock.ui --- a/src/kdefrontend/ui/dockwidgets/axisdock.ui +++ b/src/kdefrontend/ui/dockwidgets/axisdock.ui @@ -29,7 +29,7 @@ - 0 + 1 @@ -1011,7 +1011,7 @@ - + diff --git a/src/kdefrontend/ui/dockwidgets/cartesianplotdock.ui b/src/kdefrontend/ui/dockwidgets/cartesianplotdock.ui --- a/src/kdefrontend/ui/dockwidgets/cartesianplotdock.ui +++ b/src/kdefrontend/ui/dockwidgets/cartesianplotdock.ui @@ -17,7 +17,7 @@ - 0 + 3 @@ -1181,11 +1181,6 @@ QPushButton
kcolorbutton.h
- - QLineEdit - QLineEdit -
klineedit.h
-
diff --git a/src/kdefrontend/ui/labelwidget.ui b/src/kdefrontend/ui/labelwidget.ui --- a/src/kdefrontend/ui/labelwidget.ui +++ b/src/kdefrontend/ui/labelwidget.ui @@ -225,13 +225,6 @@ QFrame::Raised - - - - Main Font - - - @@ -242,13 +235,6 @@ - - - - Foreground color - - - @@ -256,17 +242,36 @@ - - + + + + Horizontal position relative to label's parent + - visible + x - - + + + + + 0 + 0 + + + + + 20 + 20 + + + + + + - Font + Main Font @@ -292,13 +297,27 @@ - - + + + + Type + + + + + + + + + + + + - Horizontal position relative to label's parent + Distance to the axis tick labels - x + Offset Y @@ -318,18 +337,41 @@ - - + + + + + + + Hor. align. + + + + + + + + 0 + 0 + + + + Horizontal position relative to label's parent + + + + + - Qt::Horizontal + Qt::Vertical QSizePolicy::Fixed - 13 - 23 + 58 + 20 @@ -341,27 +383,30 @@ - - - - - 0 - 0 - + + + + Qt::Horizontal - - Horizontal position relative to label's parent + + QSizePolicy::Fixed - + + + 13 + 23 + + + - - + + - Hor. align. + Foreground color - + Qt::Vertical @@ -374,59 +419,65 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed + + + + Border Style - - - 58 - 20 - + + + + + + Label Shape - + - - + + + + + - Vert. align. + Background Color - - - - Distance to the axis tick labels + + + + + + + + - Offset Y + Border Color - - + + - Rotation + Vert. align. - - - - - 0 - 0 - + + + + Font + + + + - Horizontal position relative to label's parent + Distance to the axis tick labels - cm + pt -99.989999999999995 @@ -436,12 +487,8 @@ - - - - Background color - - + + @@ -459,54 +506,52 @@ - - - - - - - - - - - 0 - 0 - + + + + Background color - - - 20 - 20 - + + + + + + ° + + + 360 + + + 5 - - + + + + + + + Rotation + + + + + - + 0 0 - - - 20 - 20 - - - - - - - Distance to the axis tick labels + Horizontal position relative to label's parent - pt + cm -99.989999999999995 @@ -516,8 +561,15 @@ - - + + + + visible + + + + + Distance to the axis tick labels @@ -532,25 +584,54 @@ - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 58 + 20 + + + + + + - - - - ° + + + + + 0 + 0 + - - 360 + + + 20 + 20 + - - 5 + + + + + + Background Pattern + + +
@@ -558,16 +639,16 @@
- KTextEdit - QTextEdit -
ktextedit.h
-
- KColorButton QPushButton
kcolorbutton.h
+ KTextEdit + QTextEdit +
ktextedit.h
+
+ KFontRequester QWidget
kfontrequester.h
diff --git a/src/kdefrontend/widgets/LabelWidget.h b/src/kdefrontend/widgets/LabelWidget.h --- a/src/kdefrontend/widgets/LabelWidget.h +++ b/src/kdefrontend/widgets/LabelWidget.h @@ -61,6 +61,7 @@ void setFixedLabelMode(const bool); private: + int m_saveShape; Ui::LabelWidget ui; TextLabel* m_label; QList m_labelsList; @@ -99,6 +100,14 @@ void dateTimeMenu(); void insertDateTime(QAction*); + void LabelShapeIndexChanged(int); + void LabelShapePreview(int); + bool eventFilter(QObject *obj, QEvent *event); + void LabelBackColorChanged(); + void LabelBorderChanged(int); + void LabelBorderColorChanged(); + void LabelPatternChanged(int); + void positionXChanged(int); void positionYChanged(int); void customPositionXChanged(double); diff --git a/src/kdefrontend/widgets/LabelWidget.cpp b/src/kdefrontend/widgets/LabelWidget.cpp --- a/src/kdefrontend/widgets/LabelWidget.cpp +++ b/src/kdefrontend/widgets/LabelWidget.cpp @@ -35,6 +35,11 @@ #include #include + +#include +#include +#include + #include #include #include @@ -70,6 +75,10 @@ ui.lText->setMinimumWidth(ui.lGeometry->width()); this->layout()->addWidget(splitter); + + + ui.cbLabelsShape->installEventFilter(this); + m_dateTimeMenu->setSeparatorsCollapsible(false); //we don't want the first separator to be removed ui.kcbFontColor->setColor(Qt::black); // default color @@ -104,6 +113,38 @@ ui.cbVerticalAlignment->addItem(i18n("center")); ui.cbVerticalAlignment->addItem(i18n("bottom")); + + ui.cbLabelsShape->addItem( i18n("Rectangle")); + ui.cbLabelsShape->addItem( i18n("Ellipse")); + ui.cbLabelsShape->addItem( i18n("Round sided rectangle")); + ui.cbLabelsShape->addItem( i18n("Round corner rectangle")); + ui.cbLabelsShape->addItem( i18n("Inwards round corner rectangle")); + ui.cbLabelsShape->addItem( i18n("Dented border rectangle")); + ui.cbLabelsShape->addItem( i18n("Cuboid")); + ui.cbLabelsShape->addItem( i18n("Up Pointing rectangle")); + ui.cbLabelsShape->addItem( i18n("Down Pointing rectangle")); + ui.cbLabelsShape->addItem( i18n("Left Pointing rectangle")); + ui.cbLabelsShape->addItem( i18n("Right Pointing rectangle")); + + ui.cbBorderStyle->addItem(i18n("no line")); + ui.cbBorderStyle->addItem(i18n("solid line")); + ui.cbBorderStyle->addItem(i18n("dash line")); + ui.cbBorderStyle->addItem(i18n("dot line")); + ui.cbBorderStyle->addItem(i18n("dash dot line")); + ui.cbBorderStyle->addItem(i18n("dash dot dot line")); + + ui.cbBackPattern->addItem(i18n("no pattern")); + ui.cbBackPattern->addItem(i18n("solid pattern")); + ui.cbBackPattern->addItem(i18n("dense pattern")); + ui.cbBackPattern->addItem(i18n("Horizontal pattern")); + ui.cbBackPattern->addItem(i18n("Vertical pattern")); + ui.cbBackPattern->addItem(i18n("Cross pattern")); + + + + + + //check whether the used latex compiler is available. //Following logic is implemented (s.a. LabelWidget::teXUsedChanged()): //1. in case latex was used to generate the text label in the stored project @@ -155,6 +196,15 @@ connect( ui.chbVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) ); + + connect(ui.cbLabelsShape, SIGNAL(currentIndexChanged(int)), this, SLOT( LabelShapeIndexChanged(int)) ); + connect(ui.cbLabelsShape, SIGNAL(highlighted(int)), this, SLOT(LabelShapePreview(int))); + connect(ui.bBackColor, SIGNAL(clicked(bool)), this, SLOT(LabelBackColorChanged())); + connect(ui.cbBorderStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(LabelBorderChanged(int))); + connect(ui.bBorderColor, SIGNAL(clicked(bool)), this, SLOT(LabelBorderColorChanged())); + connect(ui.cbBackPattern, SIGNAL(currentIndexChanged(int)), this, SLOT(LabelPatternChanged(int))); + + //TODO: https://bugreports.qt.io/browse/QTBUG-25420 ui.tbFontUnderline->hide(); ui.tbFontStrikeOut->hide(); @@ -776,6 +826,11 @@ ui.cbVerticalAlignment->setCurrentIndex( (int) m_label->verticalAlignment() ); ui.sbRotation->setValue( m_label->rotationAngle() ); + + ui.cbLabelsShape->setCurrentIndex(m_label->getLabelShapeint()); + ui.cbBorderStyle->setCurrentIndex(m_label->getLabelBorder()); + ui.cbBackPattern->setCurrentIndex(m_label->getPatternStyle()); + m_initializing = false; } @@ -805,6 +860,9 @@ ui.cbVerticalAlignment->setCurrentIndex( group.readEntry("VerticalAlignment", (int) m_label->verticalAlignment()) ); ui.sbRotation->setValue( group.readEntry("Rotation", m_label->rotationAngle()) ); + + ui.cbLabelsShape->setCurrentIndex(group.readEntry("ShapeType").toInt()); + m_initializing = false; } @@ -828,4 +886,88 @@ group.writeEntry("HorizontalAlignment", ui.cbHorizontalAlignment->currentIndex()); group.writeEntry("VerticalAlignment", ui.cbVerticalAlignment->currentIndex()); group.writeEntry("Rotation", ui.sbRotation->value()); + + group.writeEntry("ShapeType", ui.cbLabelsShape->currentIndex()); +} + + +void LabelWidget::LabelShapeIndexChanged(int NewShape) +{ + if (m_initializing) + return; + + for (auto* label : m_labelsList) + label->chooseLabelsShape(NewShape); + m_saveShape = ui.cbLabelsShape->currentIndex(); + + +} + +void LabelWidget::LabelShapePreview(int tempShape) +{ + if (m_initializing) + return; + + for (auto* label : m_labelsList) + label->chooseLabelsShape(tempShape); + +} + +bool LabelWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == (QObject*)ui.cbLabelsShape) + { + if (event->type() == QEvent::FocusOut) + { + for (auto* label : m_labelsList) + label->chooseLabelsShape(m_saveShape); + return true; + } + else + return false; + } + return false; +} + +void LabelWidget::LabelBackColorChanged() +{ + QColor backcolor = QColorDialog::getColor(Qt::transparent, this); + if (backcolor.isValid()) + { + QPalette p = palette(); + p.setColor(QPalette::Button, (const QColor)backcolor); + ui.bBackColor->setPalette(p); + for (auto* label : m_labelsList) + label->chooseLabelBackColor(backcolor); + + } + else return; + +} + +void LabelWidget::LabelBorderChanged(int border) +{ + for (auto* label : m_labelsList) + label->chooseLabelBorder(border); +} +void LabelWidget::LabelBorderColorChanged() +{ + QColor backcolor = QColorDialog::getColor(Qt::black, this); + if (backcolor.isValid()) + { + QPalette p = palette(); + p.setColor(QPalette::Button, (const QColor)backcolor); + ui.bBackColor->setPalette(p); + for (auto* label : m_labelsList) + label->chooseLabelBorderColor(backcolor); + + } + else return; + +} + +void LabelWidget::LabelPatternChanged(int pattern) +{ + for (auto* label : m_labelsList) + label->choosePatternStyle(pattern); }