Skip to content

Commit

Permalink
Layer edition improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
feragon committed Aug 11, 2016
1 parent 1c15b2d commit 6b2f39e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lcUI/dialogs/addlayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
13 changes: 13 additions & 0 deletions lcUI/widgets/colorselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
1 change: 1 addition & 0 deletions lcUI/widgets/colorselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions lcUI/widgets/linewidthselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
1 change: 1 addition & 0 deletions lcUI/widgets/linewidthselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6b2f39e

Please sign in to comment.