Permalink
Browse files

Layer edition improvements

  • Loading branch information...
feragon committed Aug 11, 2016
1 parent 1c15b2d commit 6b2f39e23518cb2ac2f403df0ae6f8ad23182fb0
@@ -26,6 +26,9 @@ AddLayerDialog::AddLayerDialog(lc::Layer_CSPtr oldLayer, lc::Document_SPtr docum
if(oldLayer != nullptr) {
ui->name->setText(oldLayer->name().c_str());
linePatternSelect->setCurrentText(oldLayer->linePattern()->name().c_str());
lineWidthSelect->setWidth(oldLayer->lineWidth().width());
colorSelect->setColor(oldLayer->color());
if(oldLayer->linePattern() != nullptr) {
int linePatternIndex = linePatternSelect->findText(oldLayer->linePattern()->name().c_str());
@@ -70,6 +70,12 @@ void ColorSelect::onActivated(const QString& text) {
}
void ColorSelect::on_customColorChanged(const QColor &color) {
QPixmap pixmap(qIconSize);
auto index = findText(CUSTOM);
pixmap.fill(color);
setItemIcon(index, QIcon(pixmap));
_customColor = color;
}
@@ -82,4 +88,11 @@ void ColorSelect::onLayerChanged(lc::Layer_CSPtr layer) {
pixmap.fill(color);
setItemIcon(index, QIcon(pixmap));
}
}
void ColorSelect::setColor(lc::Color color) {
QColor qColor(color.redI(), color.greenI(), color.blueI(), color.alphaI());
setCurrentText(CUSTOM);
on_customColorChanged(qColor);
}
@@ -19,6 +19,7 @@ class ColorSelect : public QComboBox {
ColorSelect(QWidget* parent = 0, bool showByLayer = false, bool showByBlock = false);
lc::MetaColor_CSPtr metaColor();
lc::Color color();
void setColor(lc::Color color);
public slots:
void onLayerChanged(lc::Layer_CSPtr layer);
@@ -79,4 +79,13 @@ void LineWidthSelect::onLayerChanged(lc::Layer_CSPtr layer) {
setItemIcon(index, QIcon(pixmap));
}
}
void LineWidthSelect::setWidth(double width) {
for(auto v : values) {
if(v.second == width) {
setCurrentText(v.first);
break;
}
}
}
@@ -15,6 +15,7 @@ class LineWidthSelect : public QComboBox {
public:
LineWidthSelect(QWidget* parent = 0, bool showByLayer = false, bool showByBlock = false);
lc::MetaLineWidthByValue_CSPtr lineWidth();
void setWidth(double width);
public slots:
void onLayerChanged(lc::Layer_CSPtr layer);

0 comments on commit 6b2f39e

Please sign in to comment.