Make path brushes optional

It auto fills now which is ugly.
This commit is contained in:
ArsenArsen 2017-06-28 19:01:52 +02:00
parent ef20967289
commit d10de26dec
4 changed files with 154 additions and 69 deletions

View File

@ -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<QColor>());
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) {

View File

@ -1,5 +1,7 @@
#include "pathitem.hpp"
#include <settings.hpp>
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);

View File

@ -3,6 +3,7 @@
#include <QCheckBox>
#include <QColorDialog>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QInputDialog>
#include <QSlider>
@ -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();
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>262</height>
<width>416</width>
<height>367</height>
</rect>
</property>
<property name="focusPolicy">
@ -16,38 +16,21 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Pen settings</string>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QPushButton" name="penColor">
<property name="text">
<string>Choose pen color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="1" column="0">
<widget class="QSlider" name="widthSlider">
<property name="maximum">
<number>2500</number>
@ -57,28 +40,129 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<widget class="QPushButton" name="brushColor">
<property name="text">
<string>Choose brush color</string>
</property>
</widget>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="widthSpinner"/>
</item>
<item row="7" column="0" colspan="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Brush settings</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="2" column="0">
<widget class="QCheckBox" name="cosmetic">
<property name="text">
<string>Cosmetic</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="penColor">
<property name="text">
<string>Choose pen color</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Brush settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="brushColor">
<property name="text">
<string>Choose brush color</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="brushStyle">
<item>
<property name="text">
<string>No Brush</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 1</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 2</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 3</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 4</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 5</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 6</string>
</property>
</item>
<item>
<property name="text">
<string>Dense 7</string>
</property>
</item>
<item>
<property name="text">
<string>Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical</string>
</property>
</item>
<item>
<property name="text">
<string>Cross pattern</string>
</property>
</item>
<item>
<property name="text">
<string>Backwards diagonal</string>
</property>
</item>
<item>
<property name="text">
<string>Forwards diagonal</string>
</property>
</item>
<item>
<property name="text">
<string>Diagonal cross</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="pathItemHasBrush">
<property name="text">
<string>Path item has brush</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
@ -88,16 +172,6 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Pen settings</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="widthSpinner"/>
</item>
</layout>
</widget>
<resources/>