2017-04-29 23:00:32 +02:00
|
|
|
#include "brushpenselection.hpp"
|
|
|
|
#include "ui_brushpenselection.h"
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QColorDialog>
|
2017-06-28 19:01:52 +02:00
|
|
|
#include <QComboBox>
|
2017-04-29 23:00:32 +02:00
|
|
|
#include <QDoubleSpinBox>
|
2017-06-28 20:46:15 +02:00
|
|
|
#include <QGraphicsBlurEffect>
|
2017-04-29 23:00:32 +02:00
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QSlider>
|
2017-08-05 21:20:24 +02:00
|
|
|
#include <QTimer>
|
2017-04-29 23:00:32 +02:00
|
|
|
#include <cropeditor/cropview.hpp>
|
2017-05-02 15:47:08 +02:00
|
|
|
#include <settings.hpp>
|
2017-04-29 23:00:32 +02:00
|
|
|
|
2017-05-09 17:26:00 +02:00
|
|
|
BrushPenSelection::BrushPenSelection(CropScene *scene) : QDialog(), ui(new Ui::BrushPenSelection) {
|
|
|
|
ui->setupUi(this);
|
2017-06-28 20:46:15 +02:00
|
|
|
|
|
|
|
ui->animated->setChecked(settings::settings().value("blur/animatedHint", false).toBool());
|
|
|
|
ui->performance->setChecked(settings::settings().value("blur/performanceHint", true).toBool());
|
|
|
|
ui->quality->setChecked(settings::settings().value("blur/qualityHint", false).toBool());
|
|
|
|
ui->radSlider->setValue(settings::settings().value("blur/radius", 5.).toDouble() * 100);
|
|
|
|
ui->radSpinner->setValue(settings::settings().value("blur/radius", 5.).toDouble());
|
|
|
|
|
2017-08-05 21:20:24 +02:00
|
|
|
ui->gridBox->setChecked(scene->grid());
|
|
|
|
|
2017-05-09 17:26:00 +02:00
|
|
|
ui->cosmetic->setChecked(scene->pen().isCosmetic());
|
|
|
|
ui->widthSlider->setValue(scene->pen().width());
|
|
|
|
ui->widthSpinner->setValue(scene->pen().widthF());
|
2017-06-28 19:01:52 +02:00
|
|
|
ui->brushStyle->setCurrentIndex(settings::settings().value("brushStyle", 1).toInt());
|
|
|
|
ui->pathItemHasBrush->setChecked(settings::settings().value("brushPath", false).toBool());
|
2017-06-28 22:26:18 +02:00
|
|
|
|
2017-06-29 16:28:26 +02:00
|
|
|
ui->arroww->setValue(settings::settings().value("arrow/width", 20).toDouble());
|
|
|
|
ui->arrowh->setValue(settings::settings().value("arrow/height", 10).toDouble());
|
|
|
|
|
2017-05-11 14:49:00 +02:00
|
|
|
this->setFocus();
|
2017-05-09 17:26:00 +02:00
|
|
|
pen = scene->pen().color();
|
2017-06-28 22:26:18 +02:00
|
|
|
ui->penAlphaSlider->setValue(pen.alpha());
|
|
|
|
ui->penAlphaSpin->setValue(pen.alpha());
|
2017-05-09 17:26:00 +02:00
|
|
|
brush = scene->brush().color();
|
2017-06-28 22:26:18 +02:00
|
|
|
ui->alphaSlider->setValue(brush.alpha());
|
|
|
|
ui->alphaSpin->setValue(brush.alpha());
|
2017-08-05 21:20:24 +02:00
|
|
|
highlight = scene->highlight();
|
2017-06-29 13:55:22 +02:00
|
|
|
|
2017-07-29 17:22:17 +02:00
|
|
|
setWindowTitle(tr("Crop editor settings"));
|
2017-05-09 17:26:00 +02:00
|
|
|
this->scene = scene;
|
2017-04-29 23:00:32 +02:00
|
|
|
}
|
|
|
|
|
2017-05-09 17:26:00 +02:00
|
|
|
BrushPenSelection::~BrushPenSelection() {
|
|
|
|
delete ui;
|
|
|
|
}
|
2017-04-29 23:00:32 +02:00
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void BrushPenSelection::on_penColor_clicked(bool) {
|
2017-07-29 17:22:17 +02:00
|
|
|
pen = QColorDialog::getColor(pen, this, tr("Pen Color"));
|
2017-06-28 22:26:18 +02:00
|
|
|
pen.setAlpha(ui->penAlphaSpin->value());
|
2017-04-29 23:00:32 +02:00
|
|
|
}
|
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void BrushPenSelection::on_brushColor_clicked(bool) {
|
2017-07-29 17:22:17 +02:00
|
|
|
brush = QColorDialog::getColor(brush, this, tr("Brush Color"));
|
2017-06-28 22:26:18 +02:00
|
|
|
brush.setAlpha(ui->alphaSpin->value());
|
2017-04-29 23:00:32 +02:00
|
|
|
}
|
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void BrushPenSelection::on_buttonBox_accepted() {
|
2017-05-09 17:26:00 +02:00
|
|
|
scene->pen().setColor(pen);
|
|
|
|
scene->pen().setCosmetic(ui->cosmetic->isChecked());
|
|
|
|
scene->pen().setWidthF(ui->widthSpinner->value());
|
|
|
|
scene->brush().setColor(brush);
|
2017-08-05 21:20:24 +02:00
|
|
|
scene->setHighlight(highlight);
|
|
|
|
scene->setGrid(ui->gridBox->isChecked());
|
2017-06-28 19:01:52 +02:00
|
|
|
scene->brush().setStyle((Qt::BrushStyle)ui->brushStyle->currentIndex());
|
2017-06-28 20:46:15 +02:00
|
|
|
|
2017-05-09 17:26:00 +02:00
|
|
|
settings::settings().setValue("penColor", scene->pen().color());
|
|
|
|
settings::settings().setValue("penCosmetic", scene->pen().isCosmetic());
|
|
|
|
settings::settings().setValue("penWidth", scene->pen().widthF());
|
|
|
|
settings::settings().setValue("brushColor", scene->brush().color());
|
2017-08-05 21:20:24 +02:00
|
|
|
settings::settings().setValue("highlightColor", scene->highlight());
|
|
|
|
settings::settings().setValue("gridEnabled", scene->grid());
|
2017-06-28 19:01:52 +02:00
|
|
|
settings::settings().setValue("brushStyle", (int)scene->brush().style());
|
|
|
|
settings::settings().setValue("brushPath", ui->pathItemHasBrush->isChecked());
|
2017-06-28 20:46:15 +02:00
|
|
|
settings::settings().setValue("blur/radius", ui->radSpinner->value());
|
|
|
|
settings::settings().setValue("blur/animatedHint", ui->animated->isChecked());
|
|
|
|
settings::settings().setValue("blur/qualityHint", ui->quality->isChecked());
|
|
|
|
settings::settings().setValue("blur/performanceHint", ui->performance->isChecked());
|
2017-06-29 16:28:26 +02:00
|
|
|
settings::settings().setValue("arrow/width", ui->arroww->value());
|
|
|
|
settings::settings().setValue("arrow/height", ui->arrowh->value());
|
2017-05-09 17:26:00 +02:00
|
|
|
close();
|
2017-04-29 23:00:32 +02:00
|
|
|
}
|
|
|
|
|
2017-05-09 17:26:00 +02:00
|
|
|
void BrushPenSelection::on_buttonBox_rejected() {
|
|
|
|
close();
|
|
|
|
}
|
2017-04-29 23:00:32 +02:00
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void BrushPenSelection::on_widthSlider_sliderMoved(int position) {
|
2017-05-09 17:26:00 +02:00
|
|
|
ui->widthSpinner->setValue(position / 100.);
|
2017-04-29 23:00:32 +02:00
|
|
|
}
|
|
|
|
|
2017-05-06 13:21:12 +02:00
|
|
|
void BrushPenSelection::on_widthSpinner_valueChanged(double arg) {
|
2017-05-09 17:26:00 +02:00
|
|
|
ui->widthSlider->setValue(arg * 100);
|
2017-04-29 23:00:32 +02:00
|
|
|
}
|
2017-06-28 20:46:15 +02:00
|
|
|
|
|
|
|
void BrushPenSelection::on_radSpinner_valueChanged(double arg1) {
|
|
|
|
ui->radSlider->setValue(arg1 * 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrushPenSelection::on_radSlider_sliderMoved(int position) {
|
|
|
|
ui->radSpinner->setValue(position / 100.);
|
|
|
|
}
|
2017-06-28 22:26:18 +02:00
|
|
|
|
|
|
|
void BrushPenSelection::on_alphaSpin_valueChanged(int arg1) {
|
|
|
|
brush.setAlpha(arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrushPenSelection::on_penAlphaSpin_valueChanged(int arg1) {
|
|
|
|
pen.setAlpha(arg1);
|
|
|
|
}
|
2017-08-05 21:20:24 +02:00
|
|
|
|
|
|
|
void BrushPenSelection::on_highlightColor_clicked() {
|
|
|
|
highlight = QColorDialog::getColor(highlight, this, tr("Highlight color"));
|
|
|
|
}
|