diff --git a/plugins/chartshape/ChartConfigWidget.cpp b/plugins/chartshape/ChartConfigWidget.cpp --- a/plugins/chartshape/ChartConfigWidget.cpp +++ b/plugins/chartshape/ChartConfigWidget.cpp @@ -519,8 +519,6 @@ // "Legend" tab connect(d->ui.legendTitle, SIGNAL(textChanged(QString)), this, SIGNAL(legendTitleChanged(QString))); - connect(d->ui.legendShowFrame, SIGNAL(toggled(bool)), - this, SIGNAL(legendShowFrameChanged(bool))); connect(d->ui.legendOrientationIsVertical, SIGNAL(toggled(bool)), this, SLOT(setLegendOrientationIsVertical(bool))); @@ -1260,10 +1258,6 @@ d->ui.legendTitle->setText(d->shape->legend()->title()); d->ui.legendTitle->blockSignals(false); - d->ui.legendTitle->blockSignals(true); - d->ui.legendShowFrame->setChecked(d->shape->legend()->showFrame()); - d->ui.legendTitle->blockSignals(false); - if (d->shape->legend()->expansion() == HighLegendExpansion) { d->ui.legendOrientationIsVertical->setChecked(true); } else { diff --git a/plugins/chartshape/ChartConfigWidget.ui b/plugins/chartshape/ChartConfigWidget.ui --- a/plugins/chartshape/ChartConfigWidget.ui +++ b/plugins/chartshape/ChartConfigWidget.ui @@ -7,8 +7,8 @@ 0 0 - 296 - 483 + 311 + 541 @@ -35,7 +35,7 @@ - 1 + 2 @@ -248,7 +248,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -551,7 +560,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -684,20 +702,13 @@ - - - Show Frame - - - - Orientation - + v @@ -707,7 +718,7 @@ - + Qt::LeftToRight @@ -721,7 +732,14 @@ - + + + + Edit Fonts... + + + + Qt::Vertical @@ -734,13 +752,6 @@ - - - - Edit Fonts... - - - diff --git a/plugins/chartshape/ChartTool.h b/plugins/chartshape/ChartTool.h --- a/plugins/chartshape/ChartTool.h +++ b/plugins/chartshape/ChartTool.h @@ -116,10 +116,6 @@ void setLegendFontSize(int size); void setLegendOrientation(Qt::Orientation); void setLegendAlignment(Qt::Alignment); - void setLegendFixedPosition(Position position); - void setLegendBackgroundColor(const QColor& color); - void setLegendFrameColor(const QColor& color); - void setLegendShowFrame(bool show); // Called upon shape manager's selectionChanged() signal void shapeSelectionChanged(); diff --git a/plugins/chartshape/ChartTool.cpp b/plugins/chartshape/ChartTool.cpp --- a/plugins/chartshape/ChartTool.cpp +++ b/plugins/chartshape/ChartTool.cpp @@ -353,16 +353,6 @@ connect(widget, SIGNAL(legendAlignmentChanged(Qt::Alignment)), this, SLOT(setLegendAlignment(Qt::Alignment))); - connect(widget, SIGNAL(legendFixedPositionChanged(Position)), - this, SLOT(setLegendFixedPosition(Position))); - - connect(widget, SIGNAL(legendBackgroundColorChanged(QColor)) , - this, SLOT(setLegendBackgroundColor(QColor))); - connect(widget, SIGNAL(legendFrameColorChanged(QColor)) , - this, SLOT(setLegendFrameColor(QColor))); - connect(widget, SIGNAL(legendShowFrameChanged(bool)) , - this, SLOT(setLegendShowFrame(bool))); - connect(d->shape, SIGNAL(updateConfigWidget()), widget, SLOT(update())); connect(d->shape->legend(), SIGNAL(updateConfigWidget()), @@ -700,49 +690,6 @@ d->shape->legend()->update(); } -void ChartTool::setLegendFixedPosition(Position position) -{ - Q_ASSERT(d->shape); - Q_ASSERT(d->shape->legend()); - - d->shape->legend()->setLegendPosition(position); - - foreach (QWidget *w, optionWidgets()) { - ((ChartConfigWidget*) w)->updateFixedPosition(position); - } - - d->shape->legend()->update(); -} - -void ChartTool::setLegendBackgroundColor(const QColor& color) -{ - Q_ASSERT(d->shape); - Q_ASSERT(d->shape->legend()); - - d->shape->legend()->setBackgroundColor(color); - d->shape->legend()->update(); -} - -void ChartTool::setLegendFrameColor(const QColor& color) -{ - Q_ASSERT(d->shape); - Q_ASSERT(d->shape->legend()); - - d->shape->legend()->setFrameColor(color); - d->shape->legend()->update(); -} - -void ChartTool::setLegendShowFrame(bool show) -{ - Q_ASSERT(d->shape); - Q_ASSERT(d->shape->legend()); - - LegendCommand *command = new LegendCommand(d->shape->legend()); - command->setLegendShowFrame(show); - canvas()->addCommand(command); -} - - void ChartTool::addAxis(AxisDimension dimension, const QString& title) { Q_ASSERT(d->shape); diff --git a/plugins/chartshape/Legend.h b/plugins/chartshape/Legend.h --- a/plugins/chartshape/Legend.h +++ b/plugins/chartshape/Legend.h @@ -43,11 +43,6 @@ ~Legend(); QString title() const; - bool showFrame() const; - QPen framePen() const; - QColor frameColor() const; - QBrush backgroundBrush() const; - QColor backgroundColor() const; QFont font() const; qreal fontSize() const; QColor fontColor() const; @@ -58,11 +53,6 @@ Position legendPosition() const; void setTitle(const QString &title); - void setShowFrame(bool show); - void setFramePen(const QPen &pen); - void setFrameColor(const QColor &color); - void setBackgroundBrush(const QBrush &brush); - void setBackgroundColor(const QColor &color); void setFont(const QFont &font); void setFontSize(qreal size); void setFontColor(const QColor &color); diff --git a/plugins/chartshape/Legend.cpp b/plugins/chartshape/Legend.cpp --- a/plugins/chartshape/Legend.cpp +++ b/plugins/chartshape/Legend.cpp @@ -70,9 +70,6 @@ // Properties of the Legend QString title; - bool showFrame; - QPen framePen; - QBrush backgroundBrush; LegendExpansion expansion; Position position; QFont font; @@ -95,9 +92,6 @@ Legend::Private::Private() { lineBorder = new KoShapeStroke(0.5, Qt::black); - showFrame = false; - framePen = QPen(); - backgroundBrush = QBrush(); expansion = HighLegendExpansion; alignment = Qt::AlignCenter; pixmapRepaintRequested = true; @@ -123,6 +117,11 @@ d->kdLegend = new KChart::Legend(); d->kdLegend->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); + // we use the shape to display frame and background + KChart::FrameAttributes frameAttr = d->kdLegend->frameAttributes(); + frameAttr.setVisible(false); + d->kdLegend->setFrameAttributes(frameAttr); + setTitleFontSize(10); setTitle(QString()); setFontSize(8); @@ -158,94 +157,6 @@ emit updateConfigWidget(); } -bool Legend::showFrame() const -{ - return d->showFrame; -} - -void Legend::setShowFrame(bool show) -{ - d->showFrame = show; - setStroke(show ? d->lineBorder : 0); - - emit updateConfigWidget(); -} - -QPen Legend::framePen() const -{ - return d->framePen; -} - -void Legend::setFramePen(const QPen &pen) -{ - d->framePen = pen; - - // KChart - KChart::FrameAttributes attributes = d->kdLegend->frameAttributes(); - attributes.setPen(pen); - d->kdLegend->setFrameAttributes(attributes); - - d->pixmapRepaintRequested = true; -} - -QColor Legend::frameColor() const -{ - return d->framePen.color(); -} - -void Legend::setFrameColor(const QColor &color) -{ - d->framePen.setColor(color); - - // KChart - KChart::FrameAttributes attributes = d->kdLegend->frameAttributes(); - attributes.setVisible(true); - QPen pen = attributes.pen(); - pen.setColor(color); - attributes.setPen(pen); - d->kdLegend->setFrameAttributes(attributes); - - d->pixmapRepaintRequested = true; -} - -QBrush Legend::backgroundBrush() const -{ - return d->backgroundBrush; -} - -void Legend::setBackgroundBrush(const QBrush &brush) -{ - d->backgroundBrush = brush; - - // KChart - KChart::BackgroundAttributes attributes = d->kdLegend->backgroundAttributes(); - attributes.setVisible(true); - attributes.setBrush(brush); - d->kdLegend->setBackgroundAttributes(attributes); - - d->pixmapRepaintRequested = true; -} - -QColor Legend::backgroundColor() const -{ - return d->backgroundBrush.color(); -} - -void Legend::setBackgroundColor(const QColor &color) -{ - d->backgroundBrush.setColor(color); - - // KChart - KChart::BackgroundAttributes attributes = d->kdLegend->backgroundAttributes(); - attributes.setVisible(true); - QBrush brush = attributes.brush(); - brush.setColor(color); - attributes.setBrush(brush); - d->kdLegend->setBackgroundAttributes(attributes); - - d->pixmapRepaintRequested = true; -} - QFont Legend::font() const { return d->font; diff --git a/plugins/chartshape/commands/LegendCommand.h b/plugins/chartshape/commands/LegendCommand.h --- a/plugins/chartshape/commands/LegendCommand.h +++ b/plugins/chartshape/commands/LegendCommand.h @@ -74,7 +74,6 @@ void setLegendFixedPosition(Position); void setLegendBackgroundColor(QColor &color); void setLegendFrameColor(QColor &color);*/ - void setLegendShowFrame(bool show); private: Legend *m_legend; @@ -86,8 +85,6 @@ int m_newFontSize; LegendExpansion m_oldExpansion; LegendExpansion m_newExpansion; - bool m_oldShowFrame; - bool m_newShowFrame; ChartShape *m_chart; }; diff --git a/plugins/chartshape/commands/LegendCommand.cpp b/plugins/chartshape/commands/LegendCommand.cpp --- a/plugins/chartshape/commands/LegendCommand.cpp +++ b/plugins/chartshape/commands/LegendCommand.cpp @@ -44,7 +44,6 @@ m_newTitle = legend->title(); m_newFontSize = legend->fontSize(); m_newExpansion = legend->expansion(); - m_newShowFrame = legend->showFrame(); } LegendCommand::~LegendCommand() @@ -58,45 +57,30 @@ m_oldFont = m_legend->font(); m_oldFontSize = m_legend->fontSize(); m_oldExpansion = m_legend->expansion(); - m_oldShowFrame = m_legend->showFrame(); if (m_oldTitle == m_newTitle && m_oldFont == m_newFont && m_oldFontSize == m_newFontSize - && m_oldExpansion == m_newExpansion && m_oldShowFrame == m_newShowFrame) + && m_oldExpansion == m_newExpansion) return; // Actually do the work m_legend->setTitle(m_newTitle); m_legend->setFont(m_newFont); m_legend->setFontSize(m_newFontSize); m_legend->setExpansion(m_newExpansion); - m_legend->setShowFrame(m_newShowFrame); - - // FIXME: temporary hack, this needs proper undo command - QMap map = m_chart->layout()->calculateLayout(m_legend, m_legend->isVisible()); - for (KoShape *s : map.keys()) { - s->setPosition(map[s].topLeft()); - s->setSize(map[s].size()); - } + m_legend->update(); } void LegendCommand::undo() { if (m_oldTitle == m_newTitle && m_oldFont == m_newFont && m_oldFontSize == m_newFontSize - && m_oldExpansion == m_newExpansion && m_oldShowFrame == m_newShowFrame) + && m_oldExpansion == m_newExpansion) return; m_legend->setTitle(m_oldTitle); m_legend->setFont(m_oldFont); m_legend->setFontSize(m_oldFontSize); m_legend->setExpansion(m_oldExpansion); - m_legend->setShowFrame(m_oldShowFrame); - - // FIXME: temporary hack, this needs proper undo command - QMap map = m_chart->layout()->calculateLayout(m_legend, m_legend->isVisible()); - for (KoShape *s : map.keys()) { - s->setPosition(map[s].topLeft()); - s->setSize(map[s].size()); - } + m_legend->update(); } @@ -128,14 +112,3 @@ setText(kundo2_i18n("Set Legend Orientation")); } - -void LegendCommand::setLegendShowFrame(bool show) -{ - m_newShowFrame = show; - - if (show) { - setText(kundo2_i18n("Show Legend Frame")); - } else { - setText(kundo2_i18n("Hide Legend Frame")); - } -}