File indexing completed on 2024-05-12 15:27:58
0001 /*************************************************************************** 0002 File : CustomPointDock.cpp 0003 Project : LabPlot 0004 Description : widget for CustomPoint properties 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2015-2020 Alexander Semke (alexander.semke@web.de) 0007 ***************************************************************************/ 0008 /*************************************************************************** 0009 * * 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the Free Software * 0022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0023 * Boston, MA 02110-1301 USA * 0024 * * 0025 ***************************************************************************/ 0026 0027 #include "CustomPointDock.h" 0028 #include "backend/worksheet/Worksheet.h" 0029 #include "backend/worksheet/plots/cartesian/CustomPoint.h" 0030 0031 #include "kdefrontend/TemplateHandler.h" 0032 #include "kdefrontend/GuiTools.h" 0033 0034 #include <KLocalizedString> 0035 #include <KConfig> 0036 0037 #include <QPainter> 0038 #include <QDir> 0039 0040 CustomPointDock::CustomPointDock(QWidget* parent) : BaseDock(parent) { 0041 ui.setupUi(this); 0042 m_leName = ui.leName; 0043 m_leComment = ui.leComment; 0044 0045 //Validators 0046 ui.lePositionX->setValidator( new QDoubleValidator(ui.lePositionX) ); 0047 ui.lePositionY->setValidator( new QDoubleValidator(ui.lePositionY) ); 0048 0049 //adjust layouts in the tabs 0050 for (int i = 0; i < ui.tabWidget->count(); ++i) { 0051 auto* layout = dynamic_cast<QGridLayout*>(ui.tabWidget->widget(i)->layout()); 0052 if (!layout) 0053 continue; 0054 0055 layout->setContentsMargins(2,2,2,2); 0056 layout->setHorizontalSpacing(2); 0057 layout->setVerticalSpacing(2); 0058 } 0059 0060 CustomPointDock::updateLocale(); 0061 0062 //SLOTS 0063 //General 0064 connect(ui.leName, &QLineEdit::textChanged, this, &CustomPointDock::nameChanged); 0065 connect(ui.leComment, &QLineEdit::textChanged, this, &CustomPointDock::commentChanged); 0066 connect(ui.lePositionX, &QLineEdit::textChanged, this, &CustomPointDock::positionXChanged); 0067 connect(ui.dateTimeEditPositionX, &QDateTimeEdit::dateTimeChanged, this, &CustomPointDock::positionXDateTimeChanged); 0068 connect(ui.lePositionY, &QLineEdit::textChanged, this, &CustomPointDock::positionYChanged); 0069 connect( ui.chkVisible, &QCheckBox::clicked, this, &CustomPointDock::visibilityChanged); 0070 0071 //Symbols 0072 connect( ui.cbSymbolStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CustomPointDock::symbolStyleChanged); 0073 connect( ui.sbSymbolSize, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &CustomPointDock::symbolSizeChanged); 0074 connect( ui.sbSymbolRotation, QOverload<int>::of(&QSpinBox::valueChanged), this, &CustomPointDock::symbolRotationChanged); 0075 connect( ui.sbSymbolOpacity, QOverload<int>::of(&QSpinBox::valueChanged), this, &CustomPointDock::symbolOpacityChanged); 0076 connect( ui.cbSymbolFillingStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CustomPointDock::symbolFillingStyleChanged); 0077 connect( ui.kcbSymbolFillingColor, &KColorButton::changed, this, &CustomPointDock::symbolFillingColorChanged); 0078 connect( ui.cbSymbolBorderStyle, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &CustomPointDock::symbolBorderStyleChanged); 0079 connect( ui.kcbSymbolBorderColor, &KColorButton::changed, this, &CustomPointDock::symbolBorderColorChanged); 0080 connect( ui.sbSymbolBorderWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &CustomPointDock::symbolBorderWidthChanged); 0081 0082 //Template handler 0083 auto* templateHandler = new TemplateHandler(this, TemplateHandler::ClassName::CustomPoint); 0084 ui.verticalLayout->addWidget(templateHandler); 0085 connect(templateHandler, &TemplateHandler::loadConfigRequested, this, &CustomPointDock::loadConfigFromTemplate); 0086 connect(templateHandler, &TemplateHandler::saveConfigRequested, this, &CustomPointDock::saveConfigAsTemplate); 0087 connect(templateHandler, &TemplateHandler::info, this, &CustomPointDock::info); 0088 0089 init(); 0090 } 0091 0092 void CustomPointDock::init() { 0093 m_initializing = true; 0094 GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, Qt::black); 0095 0096 QPainter pa; 0097 int iconSize = 20; 0098 QPixmap pm(iconSize, iconSize); 0099 ui.cbSymbolStyle->setIconSize(QSize(iconSize, iconSize)); 0100 0101 QPen pen(Qt::SolidPattern, 0); 0102 const QColor& color = (palette().color(QPalette::Base).lightness() < 128) ? Qt::white : Qt::black; 0103 pen.setColor(color); 0104 pa.setPen(pen); 0105 0106 QTransform trafo; 0107 trafo.scale(15, 15); 0108 for (int i = 1; i < Symbol::stylesCount(); ++i) { //skip the first style "None" 0109 auto style = (Symbol::Style)i; 0110 pm.fill(Qt::transparent); 0111 pa.begin(&pm); 0112 pa.setPen( pen ); 0113 pa.setRenderHint(QPainter::Antialiasing); 0114 pa.translate(iconSize/2,iconSize/2); 0115 pa.drawPath(trafo.map(Symbol::pathFromStyle(style))); 0116 pa.end(); 0117 ui.cbSymbolStyle->addItem(QIcon(pm), Symbol::nameFromStyle(style), (int)style); 0118 } 0119 GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, Qt::black); 0120 m_initializing = false; 0121 } 0122 0123 void CustomPointDock::setPoints(QList<CustomPoint*> list) { 0124 const Lock lock(m_initializing); 0125 m_pointsList = list; 0126 m_point = list.first(); 0127 m_aspect = list.first(); 0128 Q_ASSERT(m_point); 0129 0130 //if there is more than one point in the list, disable the comment and name widgets in "general" 0131 if (list.size() == 1) { 0132 ui.lName->setEnabled(true); 0133 ui.leName->setEnabled(true); 0134 ui.lComment->setEnabled(true); 0135 ui.leComment->setEnabled(true); 0136 ui.leName->setText(m_point->name()); 0137 ui.leComment->setText(m_point->comment()); 0138 } else { 0139 ui.lName->setEnabled(false); 0140 ui.leName->setEnabled(false); 0141 ui.lComment->setEnabled(false); 0142 ui.leComment->setEnabled(false); 0143 ui.leName->setText(QString()); 0144 ui.leComment->setText(QString()); 0145 } 0146 ui.leName->setStyleSheet(""); 0147 ui.leName->setToolTip(""); 0148 0149 //show the properties of the first custom point 0150 this->load(); 0151 0152 //SIGNALs/SLOTs 0153 // general 0154 connect(m_point, &CustomPoint::aspectDescriptionChanged, this, &CustomPointDock::pointDescriptionChanged); 0155 connect(m_point, &CustomPoint::positionChanged, this, &CustomPointDock::pointPositionChanged); 0156 connect(m_point, &CustomPoint::visibleChanged, this, &CustomPointDock::pointVisibilityChanged); 0157 0158 //symbol 0159 connect(m_point, &CustomPoint::symbolStyleChanged, this, &CustomPointDock::pointSymbolStyleChanged); 0160 connect(m_point, &CustomPoint::symbolSizeChanged, this, &CustomPointDock::pointSymbolSizeChanged); 0161 connect(m_point, &CustomPoint::symbolRotationAngleChanged, this, &CustomPointDock::pointSymbolRotationAngleChanged); 0162 connect(m_point, &CustomPoint::symbolOpacityChanged, this, &CustomPointDock::pointSymbolOpacityChanged); 0163 connect(m_point, &CustomPoint::symbolBrushChanged, this, &CustomPointDock::pointSymbolBrushChanged); 0164 connect(m_point, &CustomPoint::symbolPenChanged, this, &CustomPointDock::pointSymbolPenChanged); 0165 } 0166 0167 /* 0168 * updates the locale in the widgets. called when the application settins are changed. 0169 */ 0170 void CustomPointDock::updateLocale() { 0171 SET_NUMBER_LOCALE 0172 ui.sbSymbolSize->setLocale(numberLocale); 0173 ui.sbSymbolBorderWidth->setLocale(numberLocale); 0174 ui.lePositionX->setLocale(numberLocale); 0175 ui.lePositionY->setLocale(numberLocale); 0176 } 0177 0178 //********************************************************** 0179 //**** SLOTs for changes triggered in CustomPointDock ****** 0180 //********************************************************** 0181 //"General"-tab 0182 void CustomPointDock::positionXChanged() { 0183 if (m_initializing) 0184 return; 0185 0186 bool ok; 0187 SET_NUMBER_LOCALE 0188 double x = numberLocale.toDouble(ui.lePositionX->text(), &ok); 0189 if (ok) { 0190 QPointF pos{m_point->position()}; 0191 pos.setX(x); 0192 for (auto* point : m_pointsList) 0193 point->setPosition(pos); 0194 } 0195 } 0196 0197 void CustomPointDock::positionXDateTimeChanged(const QDateTime& dateTime) { 0198 if (m_initializing) 0199 return; 0200 0201 quint64 x = dateTime.toMSecsSinceEpoch(); 0202 QPointF pos{m_point->position()}; 0203 pos.setX(x); 0204 for (auto* point : m_pointsList) 0205 point->setPosition(pos); 0206 } 0207 0208 void CustomPointDock::positionYChanged() { 0209 if (m_initializing) 0210 return; 0211 0212 bool ok; 0213 SET_NUMBER_LOCALE 0214 double y = numberLocale.toDouble(ui.lePositionY->text(), &ok); 0215 if (ok) { 0216 QPointF pos{m_point->position()}; 0217 pos.setY(y); 0218 for (auto* point : m_pointsList) 0219 point->setPosition(pos); 0220 } 0221 } 0222 0223 void CustomPointDock::visibilityChanged(bool state) { 0224 if (m_initializing) 0225 return; 0226 0227 m_point->beginMacro(i18n("%1 CustomPoints: visibility changed", m_pointsList.count())); 0228 for (auto* point : m_pointsList) 0229 point->setVisible(state); 0230 m_point->endMacro(); 0231 } 0232 0233 void CustomPointDock::symbolStyleChanged(int) { 0234 auto style = static_cast<Symbol::Style>(ui.cbSymbolStyle->itemData(ui.cbSymbolStyle->currentIndex()).toInt()); 0235 //enable/disable the filling options in the GUI depending on the currently selected points. 0236 if (style != Symbol::Style::Line && style != Symbol::Style::Cross) { 0237 ui.cbSymbolFillingStyle->setEnabled(true); 0238 bool noBrush = (Qt::BrushStyle(ui.cbSymbolFillingStyle->currentIndex()) == Qt::NoBrush); 0239 ui.kcbSymbolFillingColor->setEnabled(!noBrush); 0240 } else { 0241 ui.kcbSymbolFillingColor->setEnabled(false); 0242 ui.cbSymbolFillingStyle->setEnabled(false); 0243 } 0244 0245 bool noLine = (Qt::PenStyle(ui.cbSymbolBorderStyle->currentIndex()) == Qt::NoPen); 0246 ui.kcbSymbolBorderColor->setEnabled(!noLine); 0247 ui.sbSymbolBorderWidth->setEnabled(!noLine); 0248 0249 if (m_initializing) 0250 return; 0251 0252 m_point->beginMacro(i18n("%1 CustomPoints: style changed", m_pointsList.count())); 0253 for (auto* point : m_pointsList) 0254 point->setSymbolStyle(style); 0255 m_point->endMacro(); 0256 } 0257 0258 void CustomPointDock::symbolSizeChanged(double value) { 0259 if (m_initializing) 0260 return; 0261 0262 m_point->beginMacro(i18n("%1 CustomPoints: size changed", m_pointsList.count())); 0263 for (auto* point : m_pointsList) 0264 point->setSymbolSize( Worksheet::convertToSceneUnits(value, Worksheet::Unit::Point) ); 0265 m_point->endMacro(); 0266 } 0267 0268 void CustomPointDock::symbolRotationChanged(int value) { 0269 if (m_initializing) 0270 return; 0271 0272 m_point->beginMacro(i18n("%1 CustomPoints: rotation changed", m_pointsList.count())); 0273 for (auto* point : m_pointsList) 0274 point->setSymbolRotationAngle(value); 0275 m_point->endMacro(); 0276 } 0277 0278 void CustomPointDock::symbolOpacityChanged(int value) { 0279 if (m_initializing) 0280 return; 0281 0282 qreal opacity = (double)value/100.; 0283 m_point->beginMacro(i18n("%1 CustomPoints: opacity changed", m_pointsList.count())); 0284 for (auto* point : m_pointsList) 0285 point->setSymbolOpacity(opacity); 0286 m_point->endMacro(); 0287 } 0288 0289 void CustomPointDock::symbolFillingStyleChanged(int index) { 0290 auto brushStyle = Qt::BrushStyle(index); 0291 ui.kcbSymbolFillingColor->setEnabled(!(brushStyle == Qt::NoBrush)); 0292 0293 if (m_initializing) 0294 return; 0295 0296 QBrush brush; 0297 m_point->beginMacro(i18n("%1 CustomPoints: filling style changed", m_pointsList.count())); 0298 for (auto* point : m_pointsList) { 0299 brush = point->symbolBrush(); 0300 brush.setStyle(brushStyle); 0301 point->setSymbolBrush(brush); 0302 } 0303 m_point->endMacro(); 0304 } 0305 0306 void CustomPointDock::symbolFillingColorChanged(const QColor& color) { 0307 if (m_initializing) 0308 return; 0309 0310 QBrush brush; 0311 m_point->beginMacro(i18n("%1 CustomPoints: filling color changed", m_pointsList.count())); 0312 for (auto* point : m_pointsList) { 0313 brush = point->symbolBrush(); 0314 brush.setColor(color); 0315 point->setSymbolBrush(brush); 0316 } 0317 m_point->endMacro(); 0318 0319 m_initializing = true; 0320 GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, color); 0321 m_initializing = false; 0322 } 0323 0324 void CustomPointDock::symbolBorderStyleChanged(int index) { 0325 auto penStyle = Qt::PenStyle(index); 0326 0327 if (penStyle == Qt::NoPen) { 0328 ui.kcbSymbolBorderColor->setEnabled(false); 0329 ui.sbSymbolBorderWidth->setEnabled(false); 0330 } else { 0331 ui.kcbSymbolBorderColor->setEnabled(true); 0332 ui.sbSymbolBorderWidth->setEnabled(true); 0333 } 0334 0335 if (m_initializing) 0336 return; 0337 0338 QPen pen; 0339 m_point->beginMacro(i18n("%1 CustomPoints: border style changed", m_pointsList.count())); 0340 for (auto* point : m_pointsList) { 0341 pen = point->symbolPen(); 0342 pen.setStyle(penStyle); 0343 point->setSymbolPen(pen); 0344 } 0345 m_point->endMacro(); 0346 } 0347 0348 void CustomPointDock::symbolBorderColorChanged(const QColor& color) { 0349 if (m_initializing) 0350 return; 0351 0352 QPen pen; 0353 m_point->beginMacro(i18n("%1 CustomPoints: border color changed", m_pointsList.count())); 0354 for (auto* point : m_pointsList) { 0355 pen = point->symbolPen(); 0356 pen.setColor(color); 0357 point->setSymbolPen(pen); 0358 } 0359 m_point->endMacro(); 0360 0361 m_initializing = true; 0362 GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, color); 0363 m_initializing = false; 0364 } 0365 0366 void CustomPointDock::symbolBorderWidthChanged(double value) { 0367 if (m_initializing) 0368 return; 0369 0370 QPen pen; 0371 m_point->beginMacro(i18n("%1 CustomPoints: border width changed", m_pointsList.count())); 0372 for (auto* point : m_pointsList) { 0373 pen = point->symbolPen(); 0374 pen.setWidthF( Worksheet::convertToSceneUnits(value, Worksheet::Unit::Point) ); 0375 point->setSymbolPen(pen); 0376 } 0377 m_point->endMacro(); 0378 } 0379 0380 //********************************************************* 0381 //**** SLOTs for changes triggered in CustomPoint ********* 0382 //********************************************************* 0383 //"General"-tab 0384 void CustomPointDock::pointDescriptionChanged(const AbstractAspect* aspect) { 0385 if (m_point != aspect) 0386 return; 0387 0388 m_initializing = true; 0389 if (aspect->name() != ui.leName->text()) { 0390 ui.leName->setText(aspect->name()); 0391 } else if (aspect->comment() != ui.leComment->text()) { 0392 ui.leComment->setText(aspect->comment()); 0393 } 0394 m_initializing = false; 0395 } 0396 0397 void CustomPointDock::pointPositionChanged(QPointF position) { 0398 m_initializing = true; 0399 SET_NUMBER_LOCALE 0400 ui.lePositionX->setText(numberLocale.toString(position.x())); 0401 ui.dateTimeEditPositionX->setDateTime(QDateTime::fromMSecsSinceEpoch(position.x())); 0402 ui.lePositionY->setText(numberLocale.toString(position.y())); 0403 m_initializing = false; 0404 } 0405 0406 //"Symbol"-tab 0407 void CustomPointDock::pointSymbolStyleChanged(Symbol::Style style) { 0408 m_initializing = true; 0409 int index = ui.cbSymbolStyle->findData((int)style); 0410 ui.cbSymbolStyle->setCurrentIndex(index); 0411 m_initializing = false; 0412 } 0413 0414 void CustomPointDock::pointSymbolSizeChanged(qreal size) { 0415 m_initializing = true; 0416 ui.sbSymbolSize->setValue( Worksheet::convertFromSceneUnits(size, Worksheet::Unit::Point) ); 0417 m_initializing = false; 0418 } 0419 0420 void CustomPointDock::pointSymbolRotationAngleChanged(qreal angle) { 0421 m_initializing = true; 0422 ui.sbSymbolRotation->setValue(qRound(angle)); 0423 m_initializing = false; 0424 } 0425 0426 void CustomPointDock::pointSymbolOpacityChanged(qreal opacity) { 0427 m_initializing = true; 0428 ui.sbSymbolOpacity->setValue( qRound(opacity*100.0) ); 0429 m_initializing = false; 0430 } 0431 0432 void CustomPointDock::pointSymbolBrushChanged(const QBrush& brush) { 0433 m_initializing = true; 0434 ui.cbSymbolFillingStyle->setCurrentIndex((int) brush.style()); 0435 ui.kcbSymbolFillingColor->setColor(brush.color()); 0436 GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, brush.color()); 0437 m_initializing = false; 0438 } 0439 0440 void CustomPointDock::pointSymbolPenChanged(const QPen& pen) { 0441 m_initializing = true; 0442 ui.cbSymbolBorderStyle->setCurrentIndex( (int) pen.style()); 0443 ui.kcbSymbolBorderColor->setColor( pen.color()); 0444 GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, pen.color()); 0445 ui.sbSymbolBorderWidth->setValue( Worksheet::convertFromSceneUnits(pen.widthF(), Worksheet::Unit::Point)); 0446 m_initializing = false; 0447 } 0448 0449 void CustomPointDock::pointVisibilityChanged(bool on) { 0450 m_initializing = true; 0451 ui.chkVisible->setChecked(on); 0452 m_initializing = false; 0453 } 0454 0455 //********************************************************** 0456 //******************** SETTINGS **************************** 0457 //********************************************************** 0458 void CustomPointDock::load() { 0459 if (!m_point) 0460 return; 0461 0462 SET_NUMBER_LOCALE 0463 CartesianPlot* plot = static_cast<CartesianPlot*>(m_point->parent(AspectType::CartesianPlot)); 0464 if (plot->xRangeFormat() == CartesianPlot::RangeFormat::Numeric) { 0465 ui.lPositionX->show(); 0466 ui.lePositionX->show(); 0467 ui.lPositionXDateTime->hide(); 0468 ui.dateTimeEditPositionX->hide(); 0469 0470 ui.lePositionX->setText(numberLocale.toString(m_point->position().x())); 0471 } else { 0472 ui.lPositionX->hide(); 0473 ui.lePositionX->hide(); 0474 ui.lPositionXDateTime->show(); 0475 ui.dateTimeEditPositionX->show(); 0476 0477 ui.dateTimeEditPositionX->setDisplayFormat(plot->xRangeDateTimeFormat()); 0478 ui.dateTimeEditPositionX->setDateTime(QDateTime::fromMSecsSinceEpoch(m_point->position().x())); 0479 } 0480 0481 ui.lePositionY->setText(numberLocale.toString(m_point->position().y())); 0482 0483 int index = ui.cbSymbolStyle->findData((int)m_point->symbolStyle()); 0484 ui.cbSymbolStyle->setCurrentIndex(index); 0485 ui.sbSymbolSize->setValue( Worksheet::convertFromSceneUnits(m_point->symbolSize(), Worksheet::Unit::Point) ); 0486 ui.sbSymbolRotation->setValue( m_point->symbolRotationAngle() ); 0487 ui.sbSymbolOpacity->setValue( qRound(m_point->symbolOpacity()*100.0) ); 0488 0489 ui.cbSymbolFillingStyle->setCurrentIndex( (int) m_point->symbolBrush().style() ); 0490 ui.kcbSymbolFillingColor->setColor( m_point->symbolBrush().color() ); 0491 0492 ui.cbSymbolBorderStyle->setCurrentIndex( (int) m_point->symbolPen().style() ); 0493 ui.kcbSymbolBorderColor->setColor( m_point->symbolPen().color() ); 0494 ui.sbSymbolBorderWidth->setValue( Worksheet::convertFromSceneUnits(m_point->symbolPen().widthF(), Worksheet::Unit::Point) ); 0495 0496 ui.chkVisible->setChecked( m_point->isVisible() ); 0497 } 0498 0499 void CustomPointDock::loadConfigFromTemplate(KConfig& config) { 0500 //extract the name of the template from the file name 0501 QString name; 0502 int index = config.name().lastIndexOf(QLatin1String("/")); 0503 if (index != -1) 0504 name = config.name().right(config.name().size() - index - 1); 0505 else 0506 name = config.name(); 0507 0508 int size = m_pointsList.size(); 0509 if (size > 1) 0510 m_point->beginMacro(i18n("%1 custom points: template \"%2\" loaded", size, name)); 0511 else 0512 m_point->beginMacro(i18n("%1: template \"%2\" loaded", m_point->name(), name)); 0513 0514 this->loadConfig(config); 0515 0516 m_point->endMacro(); 0517 } 0518 0519 void CustomPointDock::loadConfig(KConfig& config) { 0520 KConfigGroup group = config.group( "CustomPoint" ); 0521 0522 int index = ui.cbSymbolStyle->findData((int)m_point->symbolStyle()); 0523 ui.cbSymbolStyle->setCurrentIndex(group.readEntry("SymbolStyle", index)); 0524 ui.sbSymbolSize->setValue( Worksheet::convertFromSceneUnits(group.readEntry("SymbolSize", m_point->symbolSize()), Worksheet::Unit::Point) ); 0525 ui.sbSymbolRotation->setValue( group.readEntry("SymbolRotation", m_point->symbolRotationAngle()) ); 0526 ui.sbSymbolOpacity->setValue( qRound(group.readEntry("SymbolOpacity", m_point->symbolOpacity())*100.0) ); 0527 ui.cbSymbolFillingStyle->setCurrentIndex( group.readEntry("SymbolFillingStyle", (int) m_point->symbolBrush().style()) ); 0528 ui.kcbSymbolFillingColor->setColor( group.readEntry("SymbolFillingColor", m_point->symbolBrush().color()) ); 0529 ui.cbSymbolBorderStyle->setCurrentIndex( group.readEntry("SymbolBorderStyle", (int) m_point->symbolPen().style()) ); 0530 ui.kcbSymbolBorderColor->setColor( group.readEntry("SymbolBorderColor", m_point->symbolPen().color()) ); 0531 ui.sbSymbolBorderWidth->setValue( Worksheet::convertFromSceneUnits(group.readEntry("SymbolBorderWidth",m_point->symbolPen().widthF()), Worksheet::Unit::Point) ); 0532 0533 m_initializing = true; 0534 GuiTools::updateBrushStyles(ui.cbSymbolFillingStyle, ui.kcbSymbolFillingColor->color()); 0535 GuiTools::updatePenStyles(ui.cbSymbolBorderStyle, ui.kcbSymbolBorderColor->color()); 0536 m_initializing = false; 0537 } 0538 0539 void CustomPointDock::saveConfigAsTemplate(KConfig& config) { 0540 KConfigGroup group = config.group( "CustomPoint" ); 0541 group.writeEntry("SymbolStyle", ui.cbSymbolStyle->itemData(ui.cbSymbolStyle->currentIndex())); 0542 group.writeEntry("SymbolSize", Worksheet::convertToSceneUnits(ui.sbSymbolSize->value(), Worksheet::Unit::Point)); 0543 group.writeEntry("SymbolRotation", ui.sbSymbolRotation->value()); 0544 group.writeEntry("SymbolOpacity", ui.sbSymbolOpacity->value()/100.0); 0545 group.writeEntry("SymbolFillingStyle", ui.cbSymbolFillingStyle->currentIndex()); 0546 group.writeEntry("SymbolFillingColor", ui.kcbSymbolFillingColor->color()); 0547 group.writeEntry("SymbolBorderStyle", ui.cbSymbolBorderStyle->currentIndex()); 0548 group.writeEntry("SymbolBorderColor", ui.kcbSymbolBorderColor->color()); 0549 group.writeEntry("SymbolBorderWidth", Worksheet::convertToSceneUnits(ui.sbSymbolBorderWidth->value(), Worksheet::Unit::Point)); 0550 config.sync(); 0551 }