curvecolorpick.cpp
Go to the documentation of this file.
1 #include "curvecolorpick.h"
2 #include "ui_curvecolorpick.h"
3 #include <QColorDialog>
4 
5 
6 CurveColorPick::CurveColorPick(const std::map<std::string, QColor> &mapped_colors, QWidget *parent) :
7  QDialog(parent),
8  ui(new Ui::CurveColorPick),
9  _any_modified(false),
10  _mapped_colors(mapped_colors)
11 {
12  ui->setupUi(this);
13 
14  for(auto& it : _mapped_colors)
15  {
16  QListWidgetItem* item = new QListWidgetItem( QString::fromStdString( it.first) );
17  item->setForeground( it.second );
18  ui->listWidget->addItem( item );
19  }
20 
22  ui->verticalLayoutRight->insertWidget(0, _color_wheel );
23  _color_wheel->setMinimumWidth(150);
24  _color_wheel->setMinimumHeight(150);
25 
27  ui->verticalLayoutRight->insertWidget(1, _color_preview );
28  _color_preview->setMinimumWidth(150);
29  _color_preview->setMinimumHeight(100);
30 
33 
36 }
37 
39 {
40  delete ui;
41 }
42 
44 {
45  return _any_modified;
46 }
47 
49 {
50  this->accept();
51 }
52 
54 {
55  for(int row = 0; row < ui->listWidget->count(); row++)
56  {
57  QListWidgetItem *item = ui->listWidget->item(row);
58  const std::string name = item->text().toStdString();
59  const QColor& color = _mapped_colors.find(name)->second;
60 
61  item->setForeground( color );
62  emit changeColor( item->text(), color );
63  }
64  QListWidgetItem *item = ui->listWidget->currentItem();
65  QColor current_color = item->foreground().color();
66  _color_wheel->setColor(current_color);
67 
68 }
69 
70 void CurveColorPick::on_listWidget_itemClicked(QListWidgetItem *item)
71 {
72  _color_wheel->setColor( item->foreground().color() );
73 }
74 
76 {
77  QListWidgetItem *item = ui->listWidget->currentItem();
78  if( color != item->foreground().color())
79  {
80  _any_modified = true;
81  item->setForeground( color );
82  emit changeColor( item->text(), color );
83  }
84 }
85 
Display an analog widget that allows the selection of a HSV color.
Definition: color_wheel.hpp:35
bool anyColorModified() const
void changeColor(QString, QColor)
color_widgets::ColorWheel * _color_wheel
void setColor(const QColor &c)
Set current color.
void on_pushButtonUndo_clicked()
color_widgets::ColorPreview * _color_preview
void on_colorChanged(QColor color)
void setColor(QColor c)
Set current color.
char name[1]
void on_pushButtonClose_clicked()
void on_listWidget_itemClicked(QListWidgetItem *item)
CurveColorPick(const std::map< std::string, QColor > &mapped_colors, QWidget *parent=0)
const std::map< std::string, QColor > & _mapped_colors
Ui::CurveColorPick * ui


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17