X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fpenwidget.cpp;h=65da6bb6034ea689b02778cdcfa5ffd30ef04116;hb=d9f34cb7917e396a1df805687234d5473d82283b;hp=4bd966af36e2af3cf3ac4e1f8c1d7a893f768f33;hpb=bf5a50feb0f84a4627a65c5b82c3ca2d2eefe54b;p=architektonas diff --git a/src/penwidget.cpp b/src/penwidget.cpp index 4bd966a..65da6bb 100644 --- a/src/penwidget.cpp +++ b/src/penwidget.cpp @@ -1,3 +1,4 @@ +// // penwidget.cpp: Pen tweaking widget // // Part of the Architektonas Project @@ -10,33 +11,28 @@ // --- ---------- ----------------------------------------------------------- // 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 - +// Maybe add a "pen" pallete, to hold most frequently used pen colors/styles +// #include "penwidget.h" - -PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0), programChange(false) +PenWidget::PenWidget(void): QWidget(), width(new QLineEdit("1.0")), red(new QLineEdit("00")), green(new QLineEdit("00")), blue(new QLineEdit("00")), style(new QComboBox), r(0), g(0), b(0), programChange(false), stampAction(new QAction(QIcon(":/res/pen-stamp.png"), tr(""), this)), dropperAction(new QAction(QIcon(":/res/pen-dropper.png"), tr(""), this)), tbStamp(new QToolButton(this)), tbDropper(new QToolButton(this)) { - width = new QLineEdit("1.0"); - red = new QLineEdit("00"); - green = new QLineEdit("00"); - blue = new QLineEdit("00"); - style = new QComboBox; - 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); + stampAction->setToolTip(tr("Stamp Selected")); + stampAction->setStatusTip(tr("Stamp selected objects with pen attributes.")); + stampAction->setShortcut(QKeySequence(tr("p,p"))); + stampAction->setCheckable(true); + tbStamp->setDefaultAction(stampAction); + + dropperAction->setToolTip(tr("Color Picker")); + dropperAction->setStatusTip(tr("Get pen attributes from objects.")); + dropperAction->setShortcut(QKeySequence(tr("d,d"))); + dropperAction->setCheckable(true); + tbDropper->setDefaultAction(dropperAction); style->insertItem(1, tr("Solid")); style->insertItem(2, tr("Dash")); @@ -63,15 +59,16 @@ PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0), programChange(false) style->setToolTip(tr("Sets pen style")); QHBoxLayout * hbox1 = new QHBoxLayout; - hbox1->addWidget(l1, 0, Qt::AlignLeft); - hbox1->addWidget(width, 0, Qt::AlignLeft); hbox1->addWidget(l2, 0, Qt::AlignLeft); hbox1->addWidget(red, 0, Qt::AlignLeft); hbox1->addWidget(green, 0, Qt::AlignLeft); hbox1->addWidget(blue, 0, Qt::AlignLeft); + hbox1->addWidget(l1, 0, Qt::AlignLeft); + hbox1->addWidget(width, 0, Qt::AlignLeft); hbox1->addWidget(l3, 0, Qt::AlignLeft); hbox1->addWidget(style, 0, Qt::AlignLeft); - hbox1->addWidget(qtb, 0, Qt::AlignLeft); + hbox1->addWidget(tbStamp, 0, Qt::AlignLeft); + hbox1->addWidget(tbDropper, 0, Qt::AlignLeft); hbox1->addStretch(1); setLayout(hbox1); @@ -81,15 +78,12 @@ PenWidget::PenWidget(void): QWidget(), r(0), g(0), b(0), programChange(false) 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 *))); } - PenWidget::~PenWidget() { } - void PenWidget::SetFields(Object * obj) { // Sanity check @@ -113,7 +107,6 @@ void PenWidget::SetFields(Object * obj) programChange = false; } - void PenWidget::HandleWidthSelected(QString text) { // Parse the text in the control @@ -124,10 +117,8 @@ void PenWidget::HandleWidthSelected(QString text) return; Global::penWidth = value; - emit WidthSelected(Global::penWidth); } - void PenWidget::HandleStyleSelected(int selected) { // Change was programmatic, don't do anything @@ -137,10 +128,8 @@ void PenWidget::HandleStyleSelected(int selected) // Styles are 1-based, but the combobox is 0-based, so we compensate for // that here Global::penStyle = selected + 1; - emit StyleSelected(Global::penStyle); } - void PenWidget::HandleRedSelected(QString text) { // Parse the text in the control @@ -152,10 +141,8 @@ void PenWidget::HandleRedSelected(QString text) r = value; Global::penColor = (r << 16) | (g << 8) | b; - emit ColorSelected(Global::penColor); } - void PenWidget::HandleGreenSelected(QString text) { // Parse the text in the control @@ -167,10 +154,8 @@ void PenWidget::HandleGreenSelected(QString text) g = value; Global::penColor = (r << 16) | (g << 8) | b; - emit ColorSelected(Global::penColor); } - void PenWidget::HandleBlueSelected(QString text) { // Parse the text in the control @@ -182,12 +167,4 @@ void PenWidget::HandleBlueSelected(QString text) b = value; Global::penColor = (r << 16) | (g << 8) | b; - emit ColorSelected(Global::penColor); } - - -void PenWidget::HandleStamp(QAction * /* action */) -{ - emit StampSelected(); -} -