Go to the documentation of this file.00001 #include "curvecolorpick.h"
00002 #include "ui_curvecolorpick.h"
00003 #include <QColorDialog>
00004
00005
00006 CurveColorPick::CurveColorPick(const std::map<QString, QColor> &mapped_colors, QWidget *parent) :
00007 QDialog(parent),
00008 ui(new Ui::CurveColorPick),
00009 _any_modified(false),
00010 _mapped_colors(mapped_colors)
00011 {
00012 ui->setupUi(this);
00013
00014 for(auto it : _mapped_colors)
00015 {
00016 QListWidgetItem* item = new QListWidgetItem( it.first );
00017 item->setForeground( it.second );
00018 ui->listWidget->addItem( item );
00019 }
00020
00021 _color_wheel = new color_widgets::ColorWheel(this);
00022 ui->verticalLayoutRight->insertWidget(0, _color_wheel );
00023 _color_wheel->setMinimumWidth(150);
00024 _color_wheel->setMinimumHeight(150);
00025
00026 _color_preview = new color_widgets::ColorPreview(this);
00027 ui->verticalLayoutRight->insertWidget(1, _color_preview );
00028 _color_preview->setMinimumWidth(150);
00029 _color_preview->setMinimumHeight(100);
00030
00031 connect(_color_wheel, &color_widgets::ColorWheel::colorChanged,
00032 _color_preview, &color_widgets::ColorPreview::setColor );
00033
00034 connect(_color_wheel, &color_widgets::ColorWheel::colorChanged,
00035 this, &CurveColorPick::on_colorChanged );
00036 }
00037
00038 CurveColorPick::~CurveColorPick()
00039 {
00040 delete ui;
00041 }
00042
00043 bool CurveColorPick::anyColorModified() const
00044 {
00045 return _any_modified;
00046 }
00047
00048 void CurveColorPick::on_pushButtonClose_clicked()
00049 {
00050 this->accept();
00051 }
00052
00053 void CurveColorPick::on_pushButtonUndo_clicked()
00054 {
00055 for(int row = 0; row < ui->listWidget->count(); row++)
00056 {
00057 QListWidgetItem *item = ui->listWidget->item(row);
00058 const QString& name = item->text();
00059 const QColor& color = _mapped_colors.find(name)->second;
00060
00061 item->setForeground( color );
00062 emit changeColor( item->text(), color );
00063 }
00064 QListWidgetItem *item = ui->listWidget->currentItem();
00065 QColor current_color = item->foreground().color();
00066 _color_wheel->setColor(current_color);
00067
00068 }
00069
00070 void CurveColorPick::on_listWidget_itemClicked(QListWidgetItem *item)
00071 {
00072 _color_wheel->setColor( item->foreground().color() );
00073 }
00074
00075 void CurveColorPick::on_colorChanged(QColor color)
00076 {
00077 QListWidgetItem *item = ui->listWidget->currentItem();
00078 if( color != item->foreground().color())
00079 {
00080 _any_modified = true;
00081 item->setForeground( color );
00082 emit changeColor( item->text(), color );
00083 }
00084 }
00085