From d10de26decf8a05608035cce526b8dc2b6712465 Mon Sep 17 00:00:00 2001 From: ArsenArsen Date: Wed, 28 Jun 2017 19:01:52 +0200 Subject: [PATCH] Make path brushes optional It auto fills now which is ugly. --- cropeditor/cropscene.cpp | 2 + cropeditor/drawing/pathitem.cpp | 5 +- cropeditor/settings/brushpenselection.cpp | 6 + cropeditor/settings/brushpenselection.ui | 210 +++++++++++++++------- 4 files changed, 154 insertions(+), 69 deletions(-) diff --git a/cropeditor/cropscene.cpp b/cropeditor/cropscene.cpp index d3dd7cf..bd75274 100644 --- a/cropeditor/cropscene.cpp +++ b/cropeditor/cropscene.cpp @@ -27,6 +27,7 @@ CropScene::CropScene(QObject *parent, QPixmap *pixmap) pen().setCosmetic(settings::settings().value("penCosmetic", pen().isCosmetic()).toBool()); pen().setWidthF(settings::settings().value("penWidth", pen().widthF()).toFloat()); brush().setColor(settings::settings().value("brushColor", brush().color()).value()); + brush().setStyle((Qt::BrushStyle)settings::settings().value("brushStyle", (int)Qt::SolidPattern).toInt()); addDrawingAction(menu, "Dot", [] { return new DotItem; }); addDrawingAction(menu, "Path", [] { return new PathItem; }); @@ -145,6 +146,7 @@ void CropScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { QPen pen(Qt::NoBrush, 1); pen.setColor(Qt::cyan); rect->setPen(pen); + rect->setZValue(-0.1); addItem(rect); } else { if (prevButtons == Qt::NoButton) { diff --git a/cropeditor/drawing/pathitem.cpp b/cropeditor/drawing/pathitem.cpp index ac08510..9bc15b7 100644 --- a/cropeditor/drawing/pathitem.cpp +++ b/cropeditor/drawing/pathitem.cpp @@ -1,5 +1,7 @@ #include "pathitem.hpp" +#include + PathItem::PathItem() { } @@ -10,7 +12,8 @@ PathItem::~PathItem() { void PathItem::mouseDragEvent(QGraphicsSceneMouseEvent *e, CropScene *scene) { if (path == nullptr) { path = new QPainterPath(e->scenePos()); - pathItem = scene->addPath(*path, scene->pen(), scene->brush()); + pathItem = scene->addPath(*path, scene->pen(), + settings::settings().value("brushPath", false).toBool() ? scene->brush() : QBrush()); } else { path->quadTo(path->currentPosition(), e->scenePos()); pathItem->setPath(*path); diff --git a/cropeditor/settings/brushpenselection.cpp b/cropeditor/settings/brushpenselection.cpp index c2053cf..a25856b 100644 --- a/cropeditor/settings/brushpenselection.cpp +++ b/cropeditor/settings/brushpenselection.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -14,6 +15,8 @@ BrushPenSelection::BrushPenSelection(CropScene *scene) : QDialog(), ui(new Ui::B ui->cosmetic->setChecked(scene->pen().isCosmetic()); ui->widthSlider->setValue(scene->pen().width()); ui->widthSpinner->setValue(scene->pen().widthF()); + ui->brushStyle->setCurrentIndex(settings::settings().value("brushStyle", 1).toInt()); + ui->pathItemHasBrush->setChecked(settings::settings().value("brushPath", false).toBool()); this->setFocus(); pen = scene->pen().color(); brush = scene->brush().color(); @@ -37,10 +40,13 @@ void BrushPenSelection::on_buttonBox_accepted() { scene->pen().setCosmetic(ui->cosmetic->isChecked()); scene->pen().setWidthF(ui->widthSpinner->value()); scene->brush().setColor(brush); + scene->brush().setStyle((Qt::BrushStyle)ui->brushStyle->currentIndex()); 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()); + settings::settings().setValue("brushStyle", (int)scene->brush().style()); + settings::settings().setValue("brushPath", ui->pathItemHasBrush->isChecked()); close(); } diff --git a/cropeditor/settings/brushpenselection.ui b/cropeditor/settings/brushpenselection.ui index 5c73226..a6f8934 100644 --- a/cropeditor/settings/brushpenselection.ui +++ b/cropeditor/settings/brushpenselection.ui @@ -6,8 +6,8 @@ 0 0 - 400 - 262 + 416 + 367 @@ -16,69 +16,153 @@ Dialog - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 5 - 5 - - - - - - - - Width + + + + + Pen settings + + + + + Width + + + + + + + 2500 + + + Qt::Horizontal + + + + + + + + + + Cosmetic + + + + + + + Choose pen color + + + + - - - - Choose pen color - - - - - - - 2500 - - - Qt::Horizontal - - - - - - - Choose brush color - - - - - - + + + Brush settings + + + + + Choose brush color + + + + + + + + No Brush + + + + + Solid + + + + + Dense 1 + + + + + Dense 2 + + + + + Dense 3 + + + + + Dense 4 + + + + + Dense 5 + + + + + Dense 6 + + + + + Dense 7 + + + + + Horizontal + + + + + Vertical + + + + + Cross pattern + + + + + Backwards diagonal + + + + + Forwards diagonal + + + + + Diagonal cross + + + + + + + + Path item has brush + + + + - - - - Cosmetic - - - - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -88,16 +172,6 @@ - - - - Pen settings - - - - - -