File indexing completed on 2024-05-12 15:28:00
0001 /*************************************************************************** 0002 File : ImageDock.cpp 0003 Project : LabPlot 0004 Description : widget for image properties 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2019-2020 by Alexander Semke (alexander.semke@web.de) 0007 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 * This program is distributed in the hope that it will be useful, * 0018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0020 * GNU General Public License for more details. * 0021 * * 0022 * You should have received a copy of the GNU General Public License * 0023 * along with this program; if not, write to the Free Software * 0024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0025 * Boston, MA 02110-1301 USA * 0026 * * 0027 ***************************************************************************/ 0028 0029 #include "ImageDock.h" 0030 #include "backend/worksheet/Image.h" 0031 #include "backend/worksheet/Worksheet.h" 0032 #include "kdefrontend/GuiTools.h" 0033 #include "kdefrontend/ThemeHandler.h" 0034 #include "kdefrontend/TemplateHandler.h" 0035 0036 #include <QCompleter> 0037 #include <QDirModel> 0038 #include <QFileDialog> 0039 #include <QImageReader> 0040 #include <QPageSize> 0041 0042 #include <KConfig> 0043 #include <KLocalizedString> 0044 0045 /*! 0046 \class ImageDock 0047 \brief Provides a widget for editing the properties of the worksheets image element. 0048 0049 \ingroup kdefrontend 0050 */ 0051 0052 ImageDock::ImageDock(QWidget* parent) : BaseDock(parent) { 0053 ui.setupUi(this); 0054 m_leName = ui.leName; 0055 m_leComment = ui.leComment; 0056 0057 ui.bOpen->setIcon( QIcon::fromTheme("document-open") ); 0058 ui.leFileName->setCompleter(new QCompleter(new QDirModel, this)); 0059 0060 // ui.cbSize->addItem(i18n("Original")); 0061 // ui.cbSize->addItem(i18n("Custom")); 0062 0063 //Positioning and alignment 0064 ui.cbPositionX->addItem(i18n("Left")); 0065 ui.cbPositionX->addItem(i18n("Center")); 0066 ui.cbPositionX->addItem(i18n("Right")); 0067 ui.cbPositionX->addItem(i18n("Custom")); 0068 0069 ui.cbPositionY->addItem(i18n("Top")); 0070 ui.cbPositionY->addItem(i18n("Center")); 0071 ui.cbPositionY->addItem(i18n("Bottom")); 0072 ui.cbPositionY->addItem(i18n("Custom")); 0073 0074 ui.cbHorizontalAlignment->addItem(i18n("Left")); 0075 ui.cbHorizontalAlignment->addItem(i18n("Center")); 0076 ui.cbHorizontalAlignment->addItem(i18n("Right")); 0077 0078 ui.cbVerticalAlignment->addItem(i18n("Top")); 0079 ui.cbVerticalAlignment->addItem(i18n("Center")); 0080 ui.cbVerticalAlignment->addItem(i18n("Bottom")); 0081 0082 QString suffix; 0083 if (m_units == BaseDock::Units::Metric) 0084 suffix = QLatin1String(" cm"); 0085 else 0086 suffix = QLatin1String(" in"); 0087 0088 ui.sbWidth->setSuffix(suffix); 0089 ui.sbHeight->setSuffix(suffix); 0090 ui.sbPositionX->setSuffix(suffix); 0091 ui.sbPositionY->setSuffix(suffix); 0092 0093 //border 0094 ui.cbBorderStyle->addItem(i18n("No line")); 0095 ui.cbBorderStyle->addItem(i18n("Solid line")); 0096 ui.cbBorderStyle->addItem(i18n("Dash line")); 0097 ui.cbBorderStyle->addItem(i18n("Dot line")); 0098 ui.cbBorderStyle->addItem(i18n("Dash dot line")); 0099 ui.cbBorderStyle->addItem(i18n("Dash dot dot line")); 0100 0101 ImageDock::updateLocale(); 0102 0103 //SLOTs 0104 //General 0105 connect(ui.leName, &QLineEdit::textChanged, this, &ImageDock::nameChanged); 0106 connect(ui.leComment, &QLineEdit::textChanged, this, &ImageDock::commentChanged); 0107 connect(ui.bOpen, &QPushButton::clicked, this, &ImageDock::selectFile); 0108 connect(ui.leFileName, &QLineEdit::returnPressed, this, &ImageDock::fileNameChanged); 0109 connect(ui.leFileName, &QLineEdit::textChanged, this, &ImageDock::fileNameChanged); 0110 connect(ui.sbOpacity, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ImageDock::opacityChanged); 0111 0112 //Size 0113 connect(ui.sbWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ImageDock::widthChanged); 0114 connect(ui.sbHeight, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ImageDock::heightChanged); 0115 connect(ui.chbKeepRatio, &QCheckBox::clicked, this, &ImageDock::keepRatioChanged); 0116 0117 //Position 0118 connect(ui.cbPositionX, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ImageDock::positionXChanged); 0119 connect(ui.cbPositionY, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ImageDock::positionYChanged); 0120 connect(ui.sbPositionX, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ImageDock::customPositionXChanged); 0121 connect(ui.sbPositionY, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ImageDock::customPositionYChanged); 0122 connect(ui.cbHorizontalAlignment, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ImageDock::horizontalAlignmentChanged); 0123 connect(ui.cbVerticalAlignment, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ImageDock::verticalAlignmentChanged); 0124 connect(ui.sbRotation, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ImageDock::rotationChanged); 0125 0126 connect(ui.chbVisible, &QCheckBox::clicked, this, &ImageDock::visibilityChanged); 0127 0128 //Border 0129 connect(ui.cbBorderStyle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ImageDock::borderStyleChanged); 0130 connect(ui.kcbBorderColor, &KColorButton::changed, this, &ImageDock::borderColorChanged); 0131 connect(ui.sbBorderWidth, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &ImageDock::borderWidthChanged); 0132 connect(ui.sbBorderOpacity, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ImageDock::borderOpacityChanged); 0133 } 0134 0135 void ImageDock::setImages(QList<Image*> list) { 0136 Lock lock(m_initializing); 0137 m_imageList = list; 0138 m_image = list.first(); 0139 m_aspect = list.first(); 0140 0141 SET_NUMBER_LOCALE 0142 ui.sbWidth->setLocale(numberLocale); 0143 ui.sbHeight->setLocale(numberLocale); 0144 ui.sbPositionX->setLocale(numberLocale); 0145 ui.sbPositionY->setLocale(numberLocale); 0146 ui.sbBorderWidth->setLocale(numberLocale); 0147 0148 //if there are more then one image in the list, disable the name and comment field in the tab "general" 0149 if (list.size() == 1) { 0150 ui.lName->setEnabled(true); 0151 ui.leName->setEnabled(true); 0152 ui.lComment->setEnabled(true); 0153 ui.leComment->setEnabled(true); 0154 0155 ui.leName->setText(m_image->name()); 0156 ui.leComment->setText(m_image->comment()); 0157 } else { 0158 ui.lName->setEnabled(false); 0159 ui.leName->setEnabled(false); 0160 ui.lComment->setEnabled(false); 0161 ui.leComment->setEnabled(false); 0162 0163 ui.leName->setText(QString()); 0164 ui.leComment->setText(QString()); 0165 } 0166 ui.leName->setStyleSheet(""); 0167 ui.leName->setToolTip(""); 0168 0169 //show the properties of the first image 0170 this->load(); 0171 0172 //init connections 0173 //General 0174 connect(m_image, &Image::fileNameChanged, this, &ImageDock::imageFileNameChanged); 0175 connect(m_image, &Image::opacityChanged, this, &ImageDock::imageOpacityChanged); 0176 connect(m_image, &Image::visibleChanged, this, &ImageDock::imageVisibleChanged); 0177 0178 //Size 0179 connect(m_image, &Image::widthChanged, this, &ImageDock::imageWidthChanged); 0180 connect(m_image, &Image::heightChanged, this, &ImageDock::imageHeightChanged); 0181 connect(m_image, &Image::keepRatioChanged, this, &ImageDock::imageKeepRatioChanged); 0182 0183 //Position 0184 connect(m_image, &Image::positionChanged, this, &ImageDock::imagePositionChanged); 0185 connect(m_image, &Image::horizontalAlignmentChanged, this, &ImageDock::imageHorizontalAlignmentChanged); 0186 connect(m_image, &Image::verticalAlignmentChanged, this, &ImageDock::imageVerticalAlignmentChanged); 0187 connect(m_image, &Image::rotationAngleChanged, this, &ImageDock::imageRotationAngleChanged); 0188 0189 //Border 0190 connect(m_image, &Image::borderPenChanged, this, &ImageDock::imageBorderPenChanged); 0191 connect(m_image, &Image::borderOpacityChanged, this, &ImageDock::imageBorderOpacityChanged); 0192 } 0193 0194 /* 0195 * updates the locale in the widgets. called when the application settins are changed. 0196 */ 0197 void ImageDock::updateLocale() { 0198 SET_NUMBER_LOCALE 0199 ui.sbWidth->setLocale(numberLocale); 0200 ui.sbHeight->setLocale(numberLocale); 0201 ui.sbPositionX->setLocale(numberLocale); 0202 ui.sbPositionY->setLocale(numberLocale); 0203 ui.sbBorderWidth->setLocale(numberLocale); 0204 } 0205 0206 void ImageDock::updateUnits() { 0207 const KConfigGroup group = KSharedConfig::openConfig()->group(QLatin1String("Settings_General")); 0208 BaseDock::Units units = (BaseDock::Units)group.readEntry("Units", static_cast<int>(Units::Metric)); 0209 if (units == m_units) 0210 return; 0211 0212 m_units = units; 0213 Lock lock(m_initializing); 0214 QString suffix; 0215 if (m_units == BaseDock::Units::Metric) { 0216 //convert from imperial to metric 0217 m_worksheetUnit = Worksheet::Unit::Centimeter; 0218 suffix = QLatin1String(" cm"); 0219 ui.sbWidth->setValue(ui.sbWidth->value()*2.54); 0220 ui.sbHeight->setValue(ui.sbHeight->value()*2.54); 0221 ui.sbPositionX->setValue(ui.sbPositionX->value()*2.54); 0222 ui.sbPositionY->setValue(ui.sbPositionY->value()*2.54); 0223 } else { 0224 //convert from metric to imperial 0225 m_worksheetUnit = Worksheet::Unit::Inch; 0226 suffix = QLatin1String(" in"); 0227 ui.sbWidth->setValue(ui.sbWidth->value()/2.54); 0228 ui.sbHeight->setValue(ui.sbHeight->value()/2.54); 0229 ui.sbPositionX->setValue(ui.sbPositionX->value()/2.54); 0230 ui.sbPositionY->setValue(ui.sbPositionY->value()/2.54); 0231 } 0232 0233 ui.sbWidth->setSuffix(suffix); 0234 ui.sbHeight->setSuffix(suffix); 0235 ui.sbPositionX->setSuffix(suffix); 0236 ui.sbPositionY->setSuffix(suffix); 0237 } 0238 0239 //************************************************************* 0240 //******** SLOTs for changes triggered in ImageDock *********** 0241 //************************************************************* 0242 0243 /*! 0244 opens a file dialog and lets the user select the image file. 0245 */ 0246 void ImageDock::selectFile() { 0247 KConfigGroup conf(KSharedConfig::openConfig(), "ImageDock"); 0248 QString dir = conf.readEntry("LastImageDir", ""); 0249 0250 QString formats; 0251 for (const QByteArray& format : QImageReader::supportedImageFormats()) { 0252 QString f = "*." + QString(format.constData()); 0253 if (f == QLatin1String("*.svg")) 0254 continue; 0255 formats.isEmpty() ? formats += f : formats += ' ' + f; 0256 } 0257 0258 QString path = QFileDialog::getOpenFileName(this, i18n("Select the image file"), dir, i18n("Images (%1)", formats)); 0259 if (path.isEmpty()) 0260 return; //cancel was clicked in the file-dialog 0261 0262 int pos = path.lastIndexOf(QLatin1String("/")); 0263 if (pos != -1) { 0264 QString newDir = path.left(pos); 0265 if (newDir != dir) 0266 conf.writeEntry("LastImageDir", newDir); 0267 } 0268 0269 ui.leFileName->setText(path); 0270 } 0271 0272 void ImageDock::fileNameChanged() { 0273 if (m_initializing) 0274 return; 0275 0276 const QString& fileName = ui.leFileName->text(); 0277 bool invalid = (!fileName.isEmpty() && !QFile::exists(fileName)); 0278 GuiTools::highlight(ui.leFileName, invalid); 0279 0280 for (auto* image : m_imageList) 0281 image->setFileName(fileName); 0282 } 0283 0284 void ImageDock::opacityChanged(int value) { 0285 if (m_initializing) 0286 return; 0287 0288 float opacity = (float)value/100; 0289 for (auto* image : m_imageList) 0290 image->setOpacity(opacity); 0291 } 0292 0293 //Size 0294 void ImageDock::sizeChanged(int index) { 0295 Q_UNUSED(index); 0296 } 0297 0298 void ImageDock::widthChanged(double value) { 0299 if (m_initializing) 0300 return; 0301 0302 int width = Worksheet::convertToSceneUnits(value, m_worksheetUnit); 0303 for (auto* image : m_imageList) 0304 image->setWidth(width); 0305 } 0306 0307 void ImageDock::heightChanged(double value) { 0308 if (m_initializing) 0309 return; 0310 0311 int height = Worksheet::convertToSceneUnits(value, m_worksheetUnit); 0312 for (auto* image : m_imageList) 0313 image->setHeight(height); 0314 } 0315 0316 void ImageDock::keepRatioChanged(int state) { 0317 if (m_initializing) 0318 return; 0319 0320 for (auto* image : m_imageList) 0321 image->setKeepRatio(state); 0322 } 0323 0324 //Position 0325 /*! 0326 called when label's current horizontal position relative to its parent (left, center, right, custom ) is changed. 0327 */ 0328 void ImageDock::positionXChanged(int index) { 0329 //Enable/disable the spinbox for the x- oordinates if the "custom position"-item is selected/deselected 0330 if (index == ui.cbPositionX->count()-1 ) 0331 ui.sbPositionX->setEnabled(true); 0332 else 0333 ui.sbPositionX->setEnabled(false); 0334 0335 if (m_initializing) 0336 return; 0337 0338 WorksheetElement::PositionWrapper position = m_image->position(); 0339 position.horizontalPosition = WorksheetElement::HorizontalPosition(index); 0340 for (auto* image : m_imageList) 0341 image->setPosition(position); 0342 } 0343 0344 /*! 0345 called when label's current horizontal position relative to its parent (top, center, bottom, custom ) is changed. 0346 */ 0347 void ImageDock::positionYChanged(int index) { 0348 //Enable/disable the spinbox for the y-coordinates if the "custom position"-item is selected/deselected 0349 if (index == ui.cbPositionY->count()-1 ) 0350 ui.sbPositionY->setEnabled(true); 0351 else 0352 ui.sbPositionY->setEnabled(false); 0353 0354 if (m_initializing) 0355 return; 0356 0357 WorksheetElement::PositionWrapper position = m_image->position(); 0358 position.verticalPosition = WorksheetElement::VerticalPosition(index); 0359 for (auto* image : m_imageList) 0360 image->setPosition(position); 0361 } 0362 0363 void ImageDock::customPositionXChanged(double value) { 0364 if (m_initializing) 0365 return; 0366 0367 WorksheetElement::PositionWrapper position = m_image->position(); 0368 position.point.setX(Worksheet::convertToSceneUnits(value, m_worksheetUnit)); 0369 for (auto* image : m_imageList) 0370 image->setPosition(position); 0371 } 0372 0373 void ImageDock::customPositionYChanged(double value) { 0374 if (m_initializing) 0375 return; 0376 0377 WorksheetElement::PositionWrapper position = m_image->position(); 0378 position.point.setY(Worksheet::convertToSceneUnits(value, m_worksheetUnit)); 0379 for (auto* image : m_imageList) 0380 image->setPosition(position); 0381 } 0382 0383 void ImageDock::horizontalAlignmentChanged(int index) { 0384 if (m_initializing) 0385 return; 0386 0387 for (auto* image : m_imageList) 0388 image->setHorizontalAlignment(WorksheetElement::HorizontalAlignment(index)); 0389 } 0390 0391 void ImageDock::verticalAlignmentChanged(int index) { 0392 if (m_initializing) 0393 return; 0394 0395 for (auto* image : m_imageList) 0396 image->setVerticalAlignment(WorksheetElement::VerticalAlignment(index)); 0397 } 0398 0399 void ImageDock::rotationChanged(int value) { 0400 if (m_initializing) 0401 return; 0402 0403 for (auto* image : m_imageList) 0404 image->setRotationAngle(value); 0405 } 0406 0407 void ImageDock::visibilityChanged(bool state) { 0408 if (m_initializing) 0409 return; 0410 0411 for (auto* image : m_imageList) 0412 image->setVisible(state); 0413 } 0414 0415 //border 0416 void ImageDock::borderStyleChanged(int index) { 0417 if (m_initializing) 0418 return; 0419 0420 auto penStyle = Qt::PenStyle(index); 0421 QPen pen; 0422 for (auto* image : m_imageList) { 0423 pen = image->borderPen(); 0424 pen.setStyle(penStyle); 0425 image->setBorderPen(pen); 0426 } 0427 } 0428 0429 void ImageDock::borderColorChanged(const QColor& color) { 0430 if (m_initializing) 0431 return; 0432 0433 QPen pen; 0434 for (auto* image : m_imageList) { 0435 pen = image->borderPen(); 0436 pen.setColor(color); 0437 image->setBorderPen(pen); 0438 } 0439 0440 m_initializing = true; 0441 GuiTools::updatePenStyles(ui.cbBorderStyle, color); 0442 m_initializing = false; 0443 } 0444 0445 void ImageDock::borderWidthChanged(double value) { 0446 if (m_initializing) 0447 return; 0448 0449 QPen pen; 0450 for (auto* image : m_imageList) { 0451 pen = image->borderPen(); 0452 pen.setWidthF( Worksheet::convertToSceneUnits(value, Worksheet::Unit::Point) ); 0453 image->setBorderPen(pen); 0454 } 0455 } 0456 0457 void ImageDock::borderOpacityChanged(int value) { 0458 if (m_initializing) 0459 return; 0460 0461 qreal opacity = (float)value/100.; 0462 for (auto* image : m_imageList) 0463 image->setBorderOpacity(opacity); 0464 } 0465 0466 //************************************************************* 0467 //********** SLOTs for changes triggered in Image ************* 0468 //************************************************************* 0469 void ImageDock::imageDescriptionChanged(const AbstractAspect* aspect) { 0470 if (m_image != aspect) 0471 return; 0472 0473 m_initializing = true; 0474 if (aspect->name() != ui.leName->text()) 0475 ui.leName->setText(aspect->name()); 0476 else if (aspect->comment() != ui.leComment->text()) 0477 ui.leComment->setText(aspect->comment()); 0478 m_initializing = false; 0479 } 0480 0481 void ImageDock::imageFileNameChanged(const QString& name) { 0482 m_initializing = true; 0483 ui.leFileName->setText(name); 0484 m_initializing = false; 0485 } 0486 0487 void ImageDock::imageOpacityChanged(float opacity) { 0488 m_initializing = true; 0489 ui.sbOpacity->setValue( qRound(opacity*100.0) ); 0490 m_initializing = false; 0491 } 0492 0493 //Size 0494 void ImageDock::imageWidthChanged(int width) { 0495 m_initializing = true; 0496 ui.sbWidth->setValue( Worksheet::convertFromSceneUnits(width, m_worksheetUnit) ); 0497 m_initializing = false; 0498 } 0499 0500 void ImageDock::imageHeightChanged(int height) { 0501 m_initializing = true; 0502 ui.sbHeight->setValue( Worksheet::convertFromSceneUnits(height, m_worksheetUnit) ); 0503 m_initializing = false; 0504 } 0505 0506 0507 void ImageDock::imageKeepRatioChanged(bool keep) { 0508 m_initializing = true; 0509 ui.chbKeepRatio->setChecked(keep); 0510 m_initializing = false; 0511 } 0512 0513 //Position 0514 void ImageDock::imagePositionChanged(const WorksheetElement::PositionWrapper& position) { 0515 m_initializing = true; 0516 ui.sbPositionX->setValue( Worksheet::convertFromSceneUnits(position.point.x(), m_worksheetUnit) ); 0517 ui.sbPositionY->setValue( Worksheet::convertFromSceneUnits(position.point.y(), m_worksheetUnit) ); 0518 ui.cbPositionX->setCurrentIndex( static_cast<int>(position.horizontalPosition) ); 0519 ui.cbPositionY->setCurrentIndex( static_cast<int>(position.verticalPosition) ); 0520 m_initializing = false; 0521 } 0522 0523 void ImageDock::imageHorizontalAlignmentChanged(WorksheetElement::HorizontalAlignment index) { 0524 m_initializing = true; 0525 ui.cbHorizontalAlignment->setCurrentIndex(static_cast<int>(index)); 0526 m_initializing = false; 0527 } 0528 0529 void ImageDock::imageVerticalAlignmentChanged(WorksheetElement::VerticalAlignment index) { 0530 m_initializing = true; 0531 ui.cbVerticalAlignment->setCurrentIndex(static_cast<int>(index)); 0532 m_initializing = false; 0533 } 0534 0535 void ImageDock::imageRotationAngleChanged(qreal angle) { 0536 m_initializing = true; 0537 ui.sbRotation->setValue(angle); 0538 m_initializing = false; 0539 } 0540 0541 void ImageDock::imageVisibleChanged(bool on) { 0542 m_initializing = true; 0543 ui.chbVisible->setChecked(on); 0544 m_initializing = false; 0545 } 0546 0547 //Border 0548 void ImageDock::imageBorderPenChanged(const QPen& pen) { 0549 m_initializing = true; 0550 if (ui.cbBorderStyle->currentIndex() != pen.style()) 0551 ui.cbBorderStyle->setCurrentIndex(pen.style()); 0552 if (ui.kcbBorderColor->color() != pen.color()) 0553 ui.kcbBorderColor->setColor(pen.color()); 0554 if (ui.sbBorderWidth->value() != pen.widthF()) 0555 ui.sbBorderWidth->setValue(Worksheet::convertFromSceneUnits(pen.widthF(), Worksheet::Unit::Point)); 0556 m_initializing = false; 0557 } 0558 0559 void ImageDock::imageBorderOpacityChanged(float value) { 0560 m_initializing = true; 0561 float v = (float)value*100.; 0562 ui.sbBorderOpacity->setValue(v); 0563 m_initializing = false; 0564 } 0565 0566 //************************************************************* 0567 //******************** SETTINGS ******************************* 0568 //************************************************************* 0569 void ImageDock::load() { 0570 if (!m_image) 0571 return; 0572 0573 m_initializing = true; 0574 0575 ui.leFileName->setText(m_image->fileName()); 0576 ui.chbVisible->setChecked(m_image->isVisible()); 0577 0578 //Size 0579 ui.sbWidth->setValue( Worksheet::convertFromSceneUnits(m_image->width(), m_worksheetUnit) ); 0580 ui.sbHeight->setValue( Worksheet::convertFromSceneUnits(m_image->height(), m_worksheetUnit) ); 0581 ui.chbKeepRatio->setChecked(m_image->keepRatio()); 0582 0583 //Position 0584 ui.cbPositionX->setCurrentIndex( (int) m_image->position().horizontalPosition ); 0585 positionXChanged(ui.cbPositionX->currentIndex()); 0586 ui.sbPositionX->setValue( Worksheet::convertFromSceneUnits(m_image->position().point.x(), m_worksheetUnit) ); 0587 ui.cbPositionY->setCurrentIndex( (int) m_image->position().verticalPosition ); 0588 positionYChanged(ui.cbPositionY->currentIndex()); 0589 ui.sbPositionY->setValue( Worksheet::convertFromSceneUnits(m_image->position().point.y(), m_worksheetUnit) ); 0590 0591 ui.cbHorizontalAlignment->setCurrentIndex( (int) m_image->horizontalAlignment() ); 0592 ui.cbVerticalAlignment->setCurrentIndex( (int) m_image->verticalAlignment() ); 0593 ui.sbRotation->setValue( m_image->rotationAngle() ); 0594 0595 //Border 0596 ui.kcbBorderColor->setColor( m_image->borderPen().color() ); 0597 ui.cbBorderStyle->setCurrentIndex( (int) m_image->borderPen().style() ); 0598 ui.sbBorderWidth->setValue( Worksheet::convertFromSceneUnits(m_image->borderPen().widthF(), Worksheet::Unit::Point) ); 0599 ui.sbBorderOpacity->setValue( round(m_image->borderOpacity()*100) ); 0600 GuiTools::updatePenStyles(ui.cbBorderStyle, ui.kcbBorderColor->color()); 0601 0602 m_initializing = false; 0603 }