"Fossies" - the Fresh Open Source Software Archive

Member "labplot-2.8.2/src/kdefrontend/dockwidgets/CustomPointDock.cpp" (24 Feb 2021, 21071 Bytes) of package /linux/privat/labplot-2.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "CustomPointDock.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.8.1_vs_2.8.2.

    1 /***************************************************************************
    2     File                 : CustomPointDock.cpp
    3     Project              : LabPlot
    4     Description          : widget for CustomPoint properties
    5     --------------------------------------------------------------------
    6     Copyright            : (C) 2015-2020 Alexander Semke (alexander.semke@web.de)
    7  ***************************************************************************/
    8 /***************************************************************************
    9  *                                                                         *
   10  *  This program is free software; you can redistribute it and/or modify   *
   11  *  it under the terms of the GNU General Public License as published by   *
   12  *  the Free Software Foundation; either version 2 of the License, or      *
   13  *  (at your option) any later version.                                    *
   14  *                                                                         *
   15  *  This program is distributed in the hope that it will be useful,        *
   16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
   17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
   18  *  GNU General Public License for more details.                           *
   19  *                                                                         *
   20  *   You should have received a copy of the GNU General Public License     *
   21  *   along with this program; if not, write to the Free Software           *
   22  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
   23  *   Boston, MA  02110-1301  USA                                           *
   24  *                                                                         *
   25  ***************************************************************************/
   26 
   27 #include "CustomPointDock.h"
   28 #include "backend/worksheet/Worksheet.h"
   29 #include "backend/worksheet/plots/cartesian/CustomPoint.h"
   30 
   31 #include "kdefrontend/TemplateHandler.h"
   32 #include "kdefrontend/GuiTools.h"
   33 
   34 #include <KLocalizedString>
   35 #include <KConfig>
   36 
   37 #include <QPainter>
   38 #include <QDir>
   39 
   40 CustomPointDock::CustomPointDock(QWidget* parent) : BaseDock(parent) {
   41     ui.setupUi(this);
   42     m_leName = ui.leName;
   43     m_leComment = ui.leComment;
   44 
   45     //Validators
   46     ui.lePositionX->setValidator( new QDoubleValidator(ui.lePositionX) );
   47     ui.lePositionY->setValidator( new QDoubleValidator(ui.lePositionY) );
   48 
   49     //adjust layouts in the tabs
   50     for (int i = 0; i < ui.tabWidget->count(); ++i) {
   51         auto* layout = dynamic_cast<QGridLayout*>(ui.tabWidget->widget(i)->layout());
   52         if (!layout)
   53             continue;
   54 
   55         layout->setContentsMargins(2,2,2,2);
   56         layout->setHorizontalSpacing(2);
   57         layout->setVerticalSpacing(2);
   58     }
   59 
   60     CustomPointDock::updateLocale();
   61 
   62     //SLOTS
   63     //General
   64     connect(ui.leName, &QLineEdit::textChanged, this, &CustomPointDock::nameChanged);
   65     connect(ui.leComment, &QLineEdit::textChanged, this, &CustomPointDock::commentChanged);
   66     connect(ui.lePositionX, &QLineEdit::textChanged, this, &CustomPointDock::positionXChanged);
   67     connect(ui.dateTimeEditPositionX, &QDateTimeEdit::dateTimeChanged, this, &CustomPointDock::positionXDateTimeChanged);
   68     connect(ui.lePositionY, &QLineEdit::textChanged, this, &CustomPointDock::positionYChanged);
   69     connect( ui.chkVisible, &QCheckBox::clicked, this, &CustomPointDock::visibilityChanged);
   70 
   71     //Symbols
   72     connect( ui.cbSymbolStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CustomPointDock::symbolStyleChanged);
   73     connect( ui.sbSymbolSize, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &CustomPointDock::symbolSizeChanged);
   74     connect( ui.sbSymbolRotation, QOverload<int>::of(&QSpinBox::valueChanged), this, &CustomPointDock::symbolRotationChanged);
   75     connect( ui.sbSymbolOpacity, QOverload<int>::of(&QSpinBox::valueChanged), this, &CustomPointDock::symbolOpacityChanged);
   76     connect( ui.cbSymbolFillingStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CustomPointDock::symbolFillingStyleChanged);
   77     connect( ui.kcbSymbolFillingColor, &KColorButton::changed, this, &CustomPointDock::symbolFillingColorChanged);
   78     connect( ui.cbSymbolBorderStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CustomPointDock::symbolBorderStyleChanged);
   79     connect( ui.kcbSymbolBorderColor, &KColorButton::changed, this, &CustomPointDock::symbolBorderColorChanged);
   80     connect( ui.sbSymbolBorderWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &CustomPointDock::symbolBorderWidthChanged);
   81 
   82     //Template handler
   83     auto* templateHandler = new TemplateHandler(this, TemplateHandler::ClassName::CustomPoint);
   84     ui.verticalLayout->addWidget(templateHandler);
   85     connect(templateHandler, &TemplateHandler::loadConfigRequested, this, &CustomPointDock::loadConfigFromTemplate);
   86     connect(templateHandler, &TemplateHandler::saveConfigRequested, this, &CustomPointDock::saveConfigAsTemplate);
   87     connect(templateHandler, &TemplateHandler::info, this, &CustomPointDock::info);
   88 
   89     init();
   90 }
   91 
   92 void CustomPointDock::init() {
   93     m_initializing = true;
   94     GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, Qt::black);
   95 
   96     QPainter pa;
   97     int iconSize = 20;
   98     QPixmap pm(iconSize, iconSize);
   99     ui.cbSymbolStyle->setIconSize(QSize(iconSize, iconSize));
  100 
  101     QPen pen(Qt::SolidPattern, 0);
  102     const QColor& color = (palette().color(QPalette::Base).lightness() < 128) ? Qt::white : Qt::black;
  103     pen.setColor(color);
  104     pa.setPen(pen);
  105 
  106     QTransform trafo;
  107     trafo.scale(15, 15);
  108     for (int i = 1; i < Symbol::stylesCount(); ++i) { //skip the first style "None"
  109         auto style = (Symbol::Style)i;
  110         pm.fill(Qt::transparent);
  111         pa.begin(&pm);
  112         pa.setPen( pen );
  113         pa.setRenderHint(QPainter::Antialiasing);
  114         pa.translate(iconSize/2,iconSize/2);
  115         pa.drawPath(trafo.map(Symbol::pathFromStyle(style)));
  116         pa.end();
  117         ui.cbSymbolStyle->addItem(QIcon(pm), Symbol::nameFromStyle(style), (int)style);
  118     }
  119     GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, Qt::black);
  120     m_initializing = false;
  121 }
  122 
  123 void CustomPointDock::setPoints(QList<CustomPoint*> list) {
  124     const Lock lock(m_initializing);
  125     m_pointsList = list;
  126     m_point = list.first();
  127     m_aspect = list.first();
  128     Q_ASSERT(m_point);
  129 
  130     //if there is more than one point in the list, disable the comment and name widgets in "general"
  131     if (list.size() == 1) {
  132         ui.lName->setEnabled(true);
  133         ui.leName->setEnabled(true);
  134         ui.lComment->setEnabled(true);
  135         ui.leComment->setEnabled(true);
  136         ui.leName->setText(m_point->name());
  137         ui.leComment->setText(m_point->comment());
  138     } else {
  139         ui.lName->setEnabled(false);
  140         ui.leName->setEnabled(false);
  141         ui.lComment->setEnabled(false);
  142         ui.leComment->setEnabled(false);
  143         ui.leName->setText(QString());
  144         ui.leComment->setText(QString());
  145     }
  146     ui.leName->setStyleSheet("");
  147     ui.leName->setToolTip("");
  148 
  149     //show the properties of the first custom point
  150     this->load();
  151 
  152     //SIGNALs/SLOTs
  153     // general
  154     connect(m_point, &CustomPoint::aspectDescriptionChanged, this, &CustomPointDock::pointDescriptionChanged);
  155     connect(m_point, &CustomPoint::positionChanged, this, &CustomPointDock::pointPositionChanged);
  156     connect(m_point, &CustomPoint::visibleChanged, this, &CustomPointDock::pointVisibilityChanged);
  157 
  158     //symbol
  159     connect(m_point, &CustomPoint::symbolStyleChanged, this, &CustomPointDock::pointSymbolStyleChanged);
  160     connect(m_point, &CustomPoint::symbolSizeChanged, this, &CustomPointDock::pointSymbolSizeChanged);
  161     connect(m_point, &CustomPoint::symbolRotationAngleChanged, this, &CustomPointDock::pointSymbolRotationAngleChanged);
  162     connect(m_point, &CustomPoint::symbolOpacityChanged, this, &CustomPointDock::pointSymbolOpacityChanged);
  163     connect(m_point, &CustomPoint::symbolBrushChanged, this, &CustomPointDock::pointSymbolBrushChanged);
  164     connect(m_point, &CustomPoint::symbolPenChanged, this, &CustomPointDock::pointSymbolPenChanged);
  165 }
  166 
  167 /*
  168  * updates the locale in the widgets. called when the application settins are changed.
  169  */
  170 void CustomPointDock::updateLocale() {
  171     SET_NUMBER_LOCALE
  172     ui.sbSymbolSize->setLocale(numberLocale);
  173     ui.sbSymbolBorderWidth->setLocale(numberLocale);
  174     ui.lePositionX->setLocale(numberLocale);
  175     ui.lePositionY->setLocale(numberLocale);
  176 }
  177 
  178 //**********************************************************
  179 //**** SLOTs for changes triggered in CustomPointDock ******
  180 //**********************************************************
  181 //"General"-tab
  182 void CustomPointDock::positionXChanged() {
  183     if (m_initializing)
  184         return;
  185 
  186     bool ok;
  187     SET_NUMBER_LOCALE
  188     double x = numberLocale.toDouble(ui.lePositionX->text(), &ok);
  189     if (ok) {
  190         QPointF pos{m_point->position()};
  191         pos.setX(x);
  192         for (auto* point : m_pointsList)
  193             point->setPosition(pos);
  194     }
  195 }
  196 
  197 void CustomPointDock::positionXDateTimeChanged(const QDateTime& dateTime) {
  198     if (m_initializing)
  199         return;
  200 
  201     quint64 x = dateTime.toMSecsSinceEpoch();
  202     QPointF pos{m_point->position()};
  203     pos.setX(x);
  204     for (auto* point : m_pointsList)
  205         point->setPosition(pos);
  206 }
  207 
  208 void CustomPointDock::positionYChanged() {
  209     if (m_initializing)
  210         return;
  211 
  212     bool ok;
  213     SET_NUMBER_LOCALE
  214     double y = numberLocale.toDouble(ui.lePositionY->text(), &ok);
  215     if (ok) {
  216         QPointF pos{m_point->position()};
  217         pos.setY(y);
  218         for (auto* point : m_pointsList)
  219             point->setPosition(pos);
  220     }
  221 }
  222 
  223 void CustomPointDock::visibilityChanged(bool state) {
  224     if (m_initializing)
  225         return;
  226 
  227     m_point->beginMacro(i18n("%1 CustomPoints: visibility changed", m_pointsList.count()));
  228     for (auto* point : m_pointsList)
  229         point->setVisible(state);
  230     m_point->endMacro();
  231 }
  232 
  233 void CustomPointDock::symbolStyleChanged(int) {
  234     auto style = static_cast<Symbol::Style>(ui.cbSymbolStyle->itemData(ui.cbSymbolStyle->currentIndex()).toInt());
  235     //enable/disable the  filling options in the GUI depending on the currently selected points.
  236     if (style != Symbol::Style::Line && style != Symbol::Style::Cross) {
  237         ui.cbSymbolFillingStyle->setEnabled(true);
  238         bool noBrush = (Qt::BrushStyle(ui.cbSymbolFillingStyle->currentIndex()) == Qt::NoBrush);
  239         ui.kcbSymbolFillingColor->setEnabled(!noBrush);
  240     } else {
  241         ui.kcbSymbolFillingColor->setEnabled(false);
  242         ui.cbSymbolFillingStyle->setEnabled(false);
  243     }
  244 
  245     bool noLine = (Qt::PenStyle(ui.cbSymbolBorderStyle->currentIndex()) == Qt::NoPen);
  246     ui.kcbSymbolBorderColor->setEnabled(!noLine);
  247     ui.sbSymbolBorderWidth->setEnabled(!noLine);
  248 
  249     if (m_initializing)
  250         return;
  251 
  252     m_point->beginMacro(i18n("%1 CustomPoints: style changed", m_pointsList.count()));
  253     for (auto* point : m_pointsList)
  254         point->setSymbolStyle(style);
  255     m_point->endMacro();
  256 }
  257 
  258 void CustomPointDock::symbolSizeChanged(double value) {
  259     if (m_initializing)
  260         return;
  261 
  262     m_point->beginMacro(i18n("%1 CustomPoints: size changed", m_pointsList.count()));
  263     for (auto* point : m_pointsList)
  264         point->setSymbolSize( Worksheet::convertToSceneUnits(value, Worksheet::Unit::Point) );
  265     m_point->endMacro();
  266 }
  267 
  268 void CustomPointDock::symbolRotationChanged(int value) {
  269     if (m_initializing)
  270         return;
  271 
  272     m_point->beginMacro(i18n("%1 CustomPoints: rotation changed", m_pointsList.count()));
  273     for (auto* point : m_pointsList)
  274         point->setSymbolRotationAngle(value);
  275     m_point->endMacro();
  276 }
  277 
  278 void CustomPointDock::symbolOpacityChanged(int value) {
  279     if (m_initializing)
  280         return;
  281 
  282     qreal opacity = (double)value/100.;
  283     m_point->beginMacro(i18n("%1 CustomPoints: opacity changed", m_pointsList.count()));
  284     for (auto* point : m_pointsList)
  285         point->setSymbolOpacity(opacity);
  286     m_point->endMacro();
  287 }
  288 
  289 void CustomPointDock::symbolFillingStyleChanged(int index) {
  290     auto brushStyle = Qt::BrushStyle(index);
  291     ui.kcbSymbolFillingColor->setEnabled(!(brushStyle == Qt::NoBrush));
  292 
  293     if (m_initializing)
  294         return;
  295 
  296     QBrush brush;
  297     m_point->beginMacro(i18n("%1 CustomPoints: filling style changed", m_pointsList.count()));
  298     for (auto* point : m_pointsList) {
  299         brush = point->symbolBrush();
  300         brush.setStyle(brushStyle);
  301         point->setSymbolBrush(brush);
  302     }
  303     m_point->endMacro();
  304 }
  305 
  306 void CustomPointDock::symbolFillingColorChanged(const QColor& color) {
  307     if (m_initializing)
  308         return;
  309 
  310     QBrush brush;
  311     m_point->beginMacro(i18n("%1 CustomPoints: filling color changed", m_pointsList.count()));
  312     for (auto* point : m_pointsList) {
  313         brush = point->symbolBrush();
  314         brush.setColor(color);
  315         point->setSymbolBrush(brush);
  316     }
  317     m_point->endMacro();
  318 
  319     m_initializing = true;
  320     GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, color);
  321     m_initializing = false;
  322 }
  323 
  324 void CustomPointDock::symbolBorderStyleChanged(int index) {
  325     auto penStyle = Qt::PenStyle(index);
  326 
  327     if (penStyle == Qt::NoPen) {
  328         ui.kcbSymbolBorderColor->setEnabled(false);
  329         ui.sbSymbolBorderWidth->setEnabled(false);
  330     } else {
  331         ui.kcbSymbolBorderColor->setEnabled(true);
  332         ui.sbSymbolBorderWidth->setEnabled(true);
  333     }
  334 
  335     if (m_initializing)
  336         return;
  337 
  338     QPen pen;
  339     m_point->beginMacro(i18n("%1 CustomPoints: border style changed", m_pointsList.count()));
  340     for (auto* point : m_pointsList) {
  341         pen = point->symbolPen();
  342         pen.setStyle(penStyle);
  343         point->setSymbolPen(pen);
  344     }
  345     m_point->endMacro();
  346 }
  347 
  348 void CustomPointDock::symbolBorderColorChanged(const QColor& color) {
  349     if (m_initializing)
  350         return;
  351 
  352     QPen pen;
  353     m_point->beginMacro(i18n("%1 CustomPoints: border color changed", m_pointsList.count()));
  354     for (auto* point : m_pointsList) {
  355         pen = point->symbolPen();
  356         pen.setColor(color);
  357         point->setSymbolPen(pen);
  358     }
  359     m_point->endMacro();
  360 
  361     m_initializing = true;
  362     GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, color);
  363     m_initializing = false;
  364 }
  365 
  366 void CustomPointDock::symbolBorderWidthChanged(double value) {
  367     if (m_initializing)
  368         return;
  369 
  370     QPen pen;
  371     m_point->beginMacro(i18n("%1 CustomPoints: border width changed", m_pointsList.count()));
  372     for (auto* point : m_pointsList) {
  373         pen = point->symbolPen();
  374         pen.setWidthF( Worksheet::convertToSceneUnits(value, Worksheet::Unit::Point) );
  375         point->setSymbolPen(pen);
  376     }
  377     m_point->endMacro();
  378 }
  379 
  380 //*********************************************************
  381 //**** SLOTs for changes triggered in CustomPoint *********
  382 //*********************************************************
  383 //"General"-tab
  384 void CustomPointDock::pointDescriptionChanged(const AbstractAspect* aspect) {
  385     if (m_point != aspect)
  386         return;
  387 
  388     m_initializing = true;
  389     if (aspect->name() != ui.leName->text()) {
  390         ui.leName->setText(aspect->name());
  391     } else if (aspect->comment() != ui.leComment->text()) {
  392         ui.leComment->setText(aspect->comment());
  393     }
  394     m_initializing = false;
  395 }
  396 
  397 void CustomPointDock::pointPositionChanged(QPointF position) {
  398     m_initializing = true;
  399     SET_NUMBER_LOCALE
  400     ui.lePositionX->setText(numberLocale.toString(position.x()));
  401     ui.dateTimeEditPositionX->setDateTime(QDateTime::fromMSecsSinceEpoch(position.x()));
  402     ui.lePositionY->setText(numberLocale.toString(position.y()));
  403     m_initializing = false;
  404 }
  405 
  406 //"Symbol"-tab
  407 void CustomPointDock::pointSymbolStyleChanged(Symbol::Style style) {
  408     m_initializing = true;
  409     int index = ui.cbSymbolStyle->findData((int)style);
  410     ui.cbSymbolStyle->setCurrentIndex(index);
  411     m_initializing = false;
  412 }
  413 
  414 void CustomPointDock::pointSymbolSizeChanged(qreal size) {
  415     m_initializing = true;
  416     ui.sbSymbolSize->setValue( Worksheet::convertFromSceneUnits(size, Worksheet::Unit::Point) );
  417     m_initializing = false;
  418 }
  419 
  420 void CustomPointDock::pointSymbolRotationAngleChanged(qreal angle) {
  421     m_initializing = true;
  422     ui.sbSymbolRotation->setValue(qRound(angle));
  423     m_initializing = false;
  424 }
  425 
  426 void CustomPointDock::pointSymbolOpacityChanged(qreal opacity) {
  427     m_initializing = true;
  428     ui.sbSymbolOpacity->setValue( qRound(opacity*100.0) );
  429     m_initializing = false;
  430 }
  431 
  432 void CustomPointDock::pointSymbolBrushChanged(const QBrush& brush) {
  433     m_initializing = true;
  434     ui.cbSymbolFillingStyle->setCurrentIndex((int) brush.style());
  435     ui.kcbSymbolFillingColor->setColor(brush.color());
  436     GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, brush.color());
  437     m_initializing = false;
  438 }
  439 
  440 void CustomPointDock::pointSymbolPenChanged(const QPen& pen) {
  441     m_initializing = true;
  442     ui.cbSymbolBorderStyle->setCurrentIndex( (int) pen.style());
  443     ui.kcbSymbolBorderColor->setColor( pen.color());
  444     GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, pen.color());
  445     ui.sbSymbolBorderWidth->setValue( Worksheet::convertFromSceneUnits(pen.widthF(), Worksheet::Unit::Point));
  446     m_initializing = false;
  447 }
  448 
  449 void CustomPointDock::pointVisibilityChanged(bool on) {
  450     m_initializing = true;
  451     ui.chkVisible->setChecked(on);
  452     m_initializing = false;
  453 }
  454 
  455 //**********************************************************
  456 //******************** SETTINGS ****************************
  457 //**********************************************************
  458 void CustomPointDock::load() {
  459     if (!m_point)
  460         return;
  461 
  462     SET_NUMBER_LOCALE
  463     CartesianPlot* plot = static_cast<CartesianPlot*>(m_point->parent(AspectType::CartesianPlot));
  464     if (plot->xRangeFormat() == CartesianPlot::RangeFormat::Numeric) {
  465         ui.lPositionX->show();
  466         ui.lePositionX->show();
  467         ui.lPositionXDateTime->hide();
  468         ui.dateTimeEditPositionX->hide();
  469 
  470         ui.lePositionX->setText(numberLocale.toString(m_point->position().x()));
  471     } else {
  472         ui.lPositionX->hide();
  473         ui.lePositionX->hide();
  474         ui.lPositionXDateTime->show();
  475         ui.dateTimeEditPositionX->show();
  476 
  477         ui.dateTimeEditPositionX->setDisplayFormat(plot->xRangeDateTimeFormat());
  478         ui.dateTimeEditPositionX->setDateTime(QDateTime::fromMSecsSinceEpoch(m_point->position().x()));
  479     }
  480 
  481     ui.lePositionY->setText(numberLocale.toString(m_point->position().y()));
  482 
  483     int index = ui.cbSymbolStyle->findData((int)m_point->symbolStyle());
  484     ui.cbSymbolStyle->setCurrentIndex(index);
  485     ui.sbSymbolSize->setValue( Worksheet::convertFromSceneUnits(m_point->symbolSize(), Worksheet::Unit::Point) );
  486     ui.sbSymbolRotation->setValue( m_point->symbolRotationAngle() );
  487     ui.sbSymbolOpacity->setValue( qRound(m_point->symbolOpacity()*100.0) );
  488 
  489     ui.cbSymbolFillingStyle->setCurrentIndex( (int) m_point->symbolBrush().style() );
  490     ui.kcbSymbolFillingColor->setColor(  m_point->symbolBrush().color() );
  491 
  492     ui.cbSymbolBorderStyle->setCurrentIndex( (int) m_point->symbolPen().style() );
  493     ui.kcbSymbolBorderColor->setColor( m_point->symbolPen().color() );
  494     ui.sbSymbolBorderWidth->setValue( Worksheet::convertFromSceneUnits(m_point->symbolPen().widthF(), Worksheet::Unit::Point) );
  495 
  496     ui.chkVisible->setChecked( m_point->isVisible() );
  497 }
  498 
  499 void CustomPointDock::loadConfigFromTemplate(KConfig& config) {
  500     //extract the name of the template from the file name
  501     QString name;
  502     int index = config.name().lastIndexOf(QLatin1String("/"));
  503     if (index != -1)
  504         name = config.name().right(config.name().size() - index - 1);
  505     else
  506         name = config.name();
  507 
  508     int size = m_pointsList.size();
  509     if (size > 1)
  510         m_point->beginMacro(i18n("%1 custom points: template \"%2\" loaded", size, name));
  511     else
  512         m_point->beginMacro(i18n("%1: template \"%2\" loaded", m_point->name(), name));
  513 
  514     this->loadConfig(config);
  515 
  516     m_point->endMacro();
  517 }
  518 
  519 void CustomPointDock::loadConfig(KConfig& config) {
  520     KConfigGroup group = config.group( "CustomPoint" );
  521 
  522     int index = ui.cbSymbolStyle->findData((int)m_point->symbolStyle());
  523     ui.cbSymbolStyle->setCurrentIndex(group.readEntry("SymbolStyle", index));
  524     ui.sbSymbolSize->setValue( Worksheet::convertFromSceneUnits(group.readEntry("SymbolSize", m_point->symbolSize()), Worksheet::Unit::Point) );
  525     ui.sbSymbolRotation->setValue( group.readEntry("SymbolRotation", m_point->symbolRotationAngle()) );
  526     ui.sbSymbolOpacity->setValue( qRound(group.readEntry("SymbolOpacity", m_point->symbolOpacity())*100.0) );
  527     ui.cbSymbolFillingStyle->setCurrentIndex( group.readEntry("SymbolFillingStyle", (int) m_point->symbolBrush().style()) );
  528     ui.kcbSymbolFillingColor->setColor(  group.readEntry("SymbolFillingColor", m_point->symbolBrush().color()) );
  529     ui.cbSymbolBorderStyle->setCurrentIndex( group.readEntry("SymbolBorderStyle", (int) m_point->symbolPen().style()) );
  530     ui.kcbSymbolBorderColor->setColor( group.readEntry("SymbolBorderColor", m_point->symbolPen().color()) );
  531     ui.sbSymbolBorderWidth->setValue( Worksheet::convertFromSceneUnits(group.readEntry("SymbolBorderWidth",m_point->symbolPen().widthF()), Worksheet::Unit::Point) );
  532 
  533     m_initializing = true;
  534     GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, ui.kcbSymbolFillingColor->color());
  535     GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, ui.kcbSymbolBorderColor->color());
  536     m_initializing = false;
  537 }
  538 
  539 void CustomPointDock::saveConfigAsTemplate(KConfig& config) {
  540     KConfigGroup group = config.group( "CustomPoint" );
  541     group.writeEntry("SymbolStyle", ui.cbSymbolStyle->itemData(ui.cbSymbolStyle->currentIndex()));
  542     group.writeEntry("SymbolSize", Worksheet::convertToSceneUnits(ui.sbSymbolSize->value(), Worksheet::Unit::Point));
  543     group.writeEntry("SymbolRotation", ui.sbSymbolRotation->value());
  544     group.writeEntry("SymbolOpacity", ui.sbSymbolOpacity->value()/100.0);
  545     group.writeEntry("SymbolFillingStyle", ui.cbSymbolFillingStyle->currentIndex());
  546     group.writeEntry("SymbolFillingColor", ui.kcbSymbolFillingColor->color());
  547     group.writeEntry("SymbolBorderStyle", ui.cbSymbolBorderStyle->currentIndex());
  548     group.writeEntry("SymbolBorderColor", ui.kcbSymbolBorderColor->color());
  549     group.writeEntry("SymbolBorderWidth", Worksheet::convertToSceneUnits(ui.sbSymbolBorderWidth->value(), Worksheet::Unit::Point));
  550     config.sync();
  551 }