1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#include <QPainter>
#include <QColorDialog>
#include "gui/basicchannelsettingswidget.h"
#include "dsp/channelmarker.h"
#include "ui_basicchannelsettingswidget.h"
BasicChannelSettingsWidget::BasicChannelSettingsWidget(ChannelMarker* marker, QWidget* parent) :
QWidget(parent),
ui(new Ui::BasicChannelSettingsWidget),
m_channelMarker(marker)
{
ui->setupUi(this);
ui->title->setText(m_channelMarker->getTitle());
paintColor();
ui->red->setValue(m_channelMarker->getColor().red());
ui->green->setValue(m_channelMarker->getColor().green());
ui->blue->setValue(m_channelMarker->getColor().blue());
}
BasicChannelSettingsWidget::~BasicChannelSettingsWidget()
{
delete ui;
}
void BasicChannelSettingsWidget::on_title_textChanged(const QString& text)
{
m_channelMarker->setTitle(text);
}
void BasicChannelSettingsWidget::on_colorBtn_clicked()
{
QColor c = m_channelMarker->getColor();
c = QColorDialog::getColor(c, this, tr("Select Color for Channel"));
if(c.isValid()) {
m_channelMarker->setColor(c);
paintColor();
ui->red->setValue(m_channelMarker->getColor().red());
ui->green->setValue(m_channelMarker->getColor().green());
ui->blue->setValue(m_channelMarker->getColor().blue());
}
}
void BasicChannelSettingsWidget::paintColor()
{
QColor c(m_channelMarker->getColor());
QPixmap pm(24, 24);
pm.fill(c);
ui->colorBtn->setIcon(pm);
ui->color->setText(tr("#%1%2%3")
.arg(c.red(), 2, 16, QChar('0'))
.arg(c.green(), 2, 16, QChar('0'))
.arg(c.blue(), 2, 16, QChar('0')));
}
void BasicChannelSettingsWidget::on_red_valueChanged(int value)
{
QColor c(m_channelMarker->getColor());
c.setRed(value);
m_channelMarker->setColor(c);
paintColor();
}
void BasicChannelSettingsWidget::on_green_valueChanged(int value)
{
QColor c(m_channelMarker->getColor());
c.setGreen(value);
m_channelMarker->setColor(c);
paintColor();
}
void BasicChannelSettingsWidget::on_blue_valueChanged(int value)
{
QColor c(m_channelMarker->getColor());
c.setBlue(value);
m_channelMarker->setColor(c);
paintColor();
}
|