X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpenwidget.cpp;h=4bd966af36e2af3cf3ac4e1f8c1d7a893f768f33;hb=60565e2216e2d6d8d3634d0614823a117770e47f;hp=50d90c6d52484ffecc7f7b532bce0834dfb69246;hpb=4708212b56a0c5645226e728f9a26ee1fd2d027d;p=architektonas diff --git a/src/penwidget.cpp b/src/penwidget.cpp index 50d90c6..4bd966a 100644 --- a/src/penwidget.cpp +++ b/src/penwidget.cpp @@ -10,11 +10,15 @@ // --- ---------- ----------------------------------------------------------- // JLH 05/07/2017 Created this file // +//maybe add a button to have it stamp attributes on all objects clicked on? [added Global::penStamp to facilitate this.] +//need to add to drawingview the ability to use attributes on new objects [DONE] +//need to override the selection so you can see the attributes effects immediately when they are changed instead of having to deselect them to see + #include "penwidget.h" -PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0) +PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0), programChange(false) { width = new QLineEdit("1.0"); red = new QLineEdit("00"); @@ -25,6 +29,14 @@ PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0) QLabel * l1 = new QLabel(tr("Width:")); QLabel * l2 = new QLabel(tr("RGB:")); QLabel * l3 = new QLabel(tr("Style:")); + QToolButton * qtb = new QToolButton(this); + + QAction * action = new QAction(QIcon(":/res/pen-stamp.png"), tr(""), this); + action->setToolTip(tr("Stamp Selected")); + action->setStatusTip(tr("Stamp selected objects with pen attributes.")); + action->setShortcut(QKeySequence(tr("p,p"))); +// action->setCheckable(checkable); + qtb->setDefaultAction(action); style->insertItem(1, tr("Solid")); style->insertItem(2, tr("Dash")); @@ -59,6 +71,7 @@ PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0) hbox1->addWidget(blue, 0, Qt::AlignLeft); hbox1->addWidget(l3, 0, Qt::AlignLeft); hbox1->addWidget(style, 0, Qt::AlignLeft); + hbox1->addWidget(qtb, 0, Qt::AlignLeft); hbox1->addStretch(1); setLayout(hbox1); @@ -68,6 +81,7 @@ PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0) connect(green, SIGNAL(textEdited(QString)), this, SLOT(HandleGreenSelected(QString))); connect(blue, SIGNAL(textEdited(QString)), this, SLOT(HandleBlueSelected(QString))); connect(style, SIGNAL(currentIndexChanged(int)), this, SLOT(HandleStyleSelected(int))); + connect(qtb, SIGNAL(triggered(QAction *)), this, SLOT(HandleStamp(QAction *))); } @@ -82,15 +96,21 @@ void PenWidget::SetFields(Object * obj) if (obj == NULL) return; - int r = (obj->color >> 16) & 0xFF; - int g = (obj->color >> 8) & 0xFF; - int b = (obj->color >> 0) & 0xFF; + // We don't handle groups properly--yet--so punt: + if (obj->type == OTContainer) + return; + + r = (obj->color >> 16) & 0xFF; + g = (obj->color >> 8) & 0xFF; + b = (obj->color >> 0) & 0xFF; width->setText(QString("%1").arg(obj->thickness)); red->setText(QString("%1").arg(r, 2, 16, QChar('0'))); green->setText(QString("%1").arg(g, 2, 16, QChar('0'))); blue->setText(QString("%1").arg(b, 2, 16, QChar('0'))); // Styles are 1-indexed while the combobox is 0-indexed + programChange = true; style->setCurrentIndex(obj->style - 1); + programChange = false; } @@ -103,15 +123,21 @@ void PenWidget::HandleWidthSelected(QString text) if (!ok) return; - emit WidthSelected(value); + Global::penWidth = value; + emit WidthSelected(Global::penWidth); } void PenWidget::HandleStyleSelected(int selected) { + // Change was programmatic, don't do anything + if (programChange) + return; + // Styles are 1-based, but the combobox is 0-based, so we compensate for // that here - emit StyleSelected(selected + 1); + Global::penStyle = selected + 1; + emit StyleSelected(Global::penStyle); } @@ -125,7 +151,8 @@ void PenWidget::HandleRedSelected(QString text) return; r = value; - emit ColorSelected((r << 16) | (g << 8) | b); + Global::penColor = (r << 16) | (g << 8) | b; + emit ColorSelected(Global::penColor); } @@ -139,7 +166,8 @@ void PenWidget::HandleGreenSelected(QString text) return; g = value; - emit ColorSelected((r << 16) | (g << 8) | b); + Global::penColor = (r << 16) | (g << 8) | b; + emit ColorSelected(Global::penColor); } @@ -153,6 +181,13 @@ void PenWidget::HandleBlueSelected(QString text) return; b = value; - emit ColorSelected((r << 16) | (g << 8) | b); + Global::penColor = (r << 16) | (g << 8) | b; + emit ColorSelected(Global::penColor); +} + + +void PenWidget::HandleStamp(QAction * /* action */) +{ + emit StampSelected(); }