3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/10/2010 Created this file. :-)
17 #include "layerdialog.h"
20 #include "layerlist.h"
22 LayerDialog::LayerDialog(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
23 QDialog(parent, flags), layer(NULL), layerList(NULL), layerName(""), editLayer(false)
28 LayerDialog::~LayerDialog()
32 void LayerDialog::setLayer(Layer * l)
35 layerName = layer->getName();
36 ui.leName->setText(layerName);
37 ui.wPen->setPen(layer->getPen(), false, false, tr("Default Pen"));
39 if (layer->getName() == "0")
40 ui.leName->setEnabled(false);
43 void LayerDialog::setLayerList(LayerList * ll)
48 void LayerDialog::setEditLayer(bool el)
53 void LayerDialog::updateLayer()
55 layer->setName(ui.leName->text());
56 layer->setPen(ui.wPen->getPen());
58 //OK, the problem is the color widget is misreporting the color that's been set.
59 Color c = ui.wPen->getPen().getColor();
60 printf("LayerDialog::updateLayer() -> selected pen is %u, %u, %u\n", c.red(), c.green(), c.blue());
61 std::cout << ui.wPen->getPen();
62 Pen p = layer->getPen();
64 printf("LayerDialog::updateLayer() -> selected pen is %u, %u, %u\n", c.red(), c.green(), c.blue());
65 std::cout << ui.wPen->getPen();
69 void LayerDialog::validate()
71 if (layerList && (!editLayer || layerName != ui.leName->text()))
73 Layer * l = layerList->find(ui.leName->text().toLatin1());
77 QMessageBox::information(parentWidget(), QMessageBox::tr("Layer Properties"),
78 QMessageBox::tr("Layer with a name \"%1\" already exists. Please specify "
79 "a different name.").arg(ui.leName->text()), QMessageBox::Ok);
80 ui.leName->setFocus();
81 ui.leName->selectAll();