summaryrefslogtreecommitdiffstats
path: root/deco/config/colorpicker.cc
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2016-03-21 20:35:05 +0100
committerSlávek Banko <[email protected]>2016-03-21 20:35:05 +0100
commit066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce (patch)
tree4cb26eb8ace976f7d0c8607dc2d3de2b5107670c /deco/config/colorpicker.cc
downloadtde-style-baghira-066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce.tar.gz
tde-style-baghira-066aaaeb73a8bb908b1c0d8c45f110b2f799f7ce.zip
Initial import of baghira 0.8
Diffstat (limited to 'deco/config/colorpicker.cc')
-rw-r--r--deco/config/colorpicker.cc124
1 files changed, 124 insertions, 0 deletions
diff --git a/deco/config/colorpicker.cc b/deco/config/colorpicker.cc
new file mode 100644
index 0000000..5e11312
--- /dev/null
+++ b/deco/config/colorpicker.cc
@@ -0,0 +1,124 @@
+#include "colorpicker.h"
+#include <qcolor.h>
+#include <qlayout.h>
+#include <qslider.h>
+#include <qspinbox.h>
+
+ColorPicker::ColorPicker(QWidget* parent, const char* name) : QGroupBox( parent, name){
+// box = new QGroupBox(parent);
+// setFrameShape(QFrame::GroupBoxPanel);
+// setFrameShadow(QFrame::Sunken);
+ setColumnLayout(0, Qt::Vertical );
+ layout()->setSpacing( 6 );
+ layout()->setMargin( 11 );
+
+ QVBoxLayout *vLayout = new QVBoxLayout(layout());
+// gridLayout->setAlignment( Qt::AlignTop );
+
+ QHBoxLayout *redLayout = new QHBoxLayout();
+ redSlider = new QSlider(0, 255, 1, 0, Qt::Horizontal, this, "redSlider");
+ redLayout->addWidget(redSlider);
+
+ redValue = new QSpinBox(0,255,1,this);
+ redValue->setValue(0);
+ redLayout->addWidget(redValue);
+
+ vLayout->addLayout(redLayout);
+
+ QHBoxLayout *greenLayout = new QHBoxLayout();
+ greenSlider = new QSlider(0, 255, 1, 0, Qt::Horizontal, this, "greenSlider");
+ greenLayout->addWidget(greenSlider);
+
+ greenValue = new QSpinBox(0,255,1,this);
+ greenValue->setValue(0);
+ greenLayout->addWidget(greenValue);
+
+ vLayout->addLayout(greenLayout);
+
+ QHBoxLayout *blueLayout = new QHBoxLayout();
+ blueSlider = new QSlider(0, 255, 1, 0, Qt::Horizontal, this, "blueSlider");
+ blueLayout->addWidget(blueSlider);
+
+ blueValue = new QSpinBox(0,255,1,this);
+ blueValue->setValue(0);
+ blueLayout->addWidget(blueValue);
+
+ vLayout->addLayout(blueLayout);
+
+// resize( QSize(350, 100).expandedTo(minimumSizeHint()) );
+
+ //connections
+ connect(redSlider, SIGNAL(valueChanged (int)), this, SLOT(setRed(int)));
+ connect(greenSlider, SIGNAL(valueChanged (int)), this, SLOT(setGreen(int)));
+ connect(blueSlider, SIGNAL(valueChanged (int)), this, SLOT(setBlue(int)));
+ connect(redValue, SIGNAL(valueChanged (int)), this, SLOT(setRed(int)));
+ connect(greenValue, SIGNAL(valueChanged (int)), this, SLOT(setGreen(int)));
+ connect(blueValue, SIGNAL(valueChanged (int)), this, SLOT(setBlue(int)));
+}
+
+ColorPicker::~ColorPicker(){
+}
+
+void ColorPicker::setColor(QColor color){
+ redSlider->blockSignals(true);
+ redSlider->setValue( color.red() );
+ redSlider->blockSignals(false);
+ redValue->blockSignals(true);
+ redValue->setValue(redSlider->value());
+ redValue->blockSignals(false);
+ greenSlider->blockSignals(true);
+ greenSlider->setValue( color.green() );
+ greenSlider->blockSignals(false);
+ greenValue->blockSignals(true);
+ greenValue->setValue(greenSlider->value());
+ greenValue->blockSignals(false);
+ blueSlider->blockSignals(true);
+ blueSlider->setValue( color.blue() );
+ blueSlider->blockSignals(false);
+ blueValue->blockSignals(true);
+ blueValue->setValue(blueSlider->value());
+ blueValue->blockSignals(false);
+ emit colorChanged(color);
+}
+
+void ColorPicker::setRed(int red){
+ redSlider->blockSignals(true);
+ redSlider->setValue( red );
+ redSlider->blockSignals(false);
+ redValue->blockSignals(true);
+ redValue->setValue(red);
+ redValue->blockSignals(false);
+ emit colorChanged(QColor(red, greenSlider->value(), blueSlider->value()));
+}
+
+void ColorPicker::setGreen(int green){
+ greenSlider->blockSignals(true);
+ greenSlider->setValue( green );
+ greenSlider->blockSignals(false);
+ greenValue->blockSignals(true);
+ greenValue->setValue(green);
+ greenValue->blockSignals(false);
+ emit colorChanged(QColor(redSlider->value(), green, blueSlider->value()));
+}
+
+void ColorPicker::setBlue(int blue){
+ blueSlider->blockSignals(true);
+ blueSlider->setValue( blue );
+ blueSlider->blockSignals(false);
+ blueValue->blockSignals(true);
+ blueValue->setValue(blue);
+ blueValue->blockSignals(false);
+ emit colorChanged(QColor(redSlider->value(), greenSlider->value(), blue));
+}
+
+QColor ColorPicker::Color(){
+ return QColor(redSlider->value(), greenSlider->value(), blueSlider->value());
+}
+
+void ColorPicker::reset(){
+ setColor(color_);
+}
+
+void ColorPicker::init(){
+ color_ = Color();
+} \ No newline at end of file