From 0895f1f0aeddc314b9429246be6ebde14747ee1d Mon Sep 17 00:00:00 2001 From: ArsenArsen Date: Wed, 28 Jun 2017 22:26:18 +0200 Subject: [PATCH] Add Alt+Click to delete an item, add alpha values --- cropeditor/cropscene.cpp | 10 ++ cropeditor/cropscene.hpp | 1 + cropeditor/settings/brushpenselection.cpp | 15 +++ cropeditor/settings/brushpenselection.hpp | 4 +- cropeditor/settings/brushpenselection.ui | 155 +++++++++++++++++++--- 5 files changed, 163 insertions(+), 22 deletions(-) diff --git a/cropeditor/cropscene.cpp b/cropeditor/cropscene.cpp index bd75274..c19eb91 100644 --- a/cropeditor/cropscene.cpp +++ b/cropeditor/cropscene.cpp @@ -191,6 +191,16 @@ void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { prevButtons = Qt::NoButton; } +void CropScene::mousePressEvent(QGraphicsSceneMouseEvent *e) { + if (e->modifiers() & Qt::AltModifier) { + QTransform stupidThing = views()[0]->transform(); + auto item = itemAt(e->screenPos(), stupidThing); + if (item && item != polyItem && item != rect && item->zValue() != -1) { + removeItem(item); + } + } +} + void CropScene::wheelEvent(QGraphicsSceneWheelEvent *event) { int pixCnt = settings::settings().value("magnifierPixelCount", 11).toInt(); if (pixCnt % 2 == 0) pixCnt++; diff --git a/cropeditor/cropscene.hpp b/cropeditor/cropscene.hpp index 4c50eff..9e03d5d 100644 --- a/cropeditor/cropscene.hpp +++ b/cropeditor/cropscene.hpp @@ -41,6 +41,7 @@ signals: protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *e) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *e) override; + void mousePressEvent(QGraphicsSceneMouseEvent *e) override; void wheelEvent(QGraphicsSceneWheelEvent *event) override; // WHEEEEEEL void contextMenuEvent(QGraphicsSceneContextMenuEvent *e) override; diff --git a/cropeditor/settings/brushpenselection.cpp b/cropeditor/settings/brushpenselection.cpp index 10e5fba..c23c912 100644 --- a/cropeditor/settings/brushpenselection.cpp +++ b/cropeditor/settings/brushpenselection.cpp @@ -25,9 +25,14 @@ BrushPenSelection::BrushPenSelection(CropScene *scene) : QDialog(), ui(new Ui::B 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(); + ui->penAlphaSlider->setValue(pen.alpha()); + ui->penAlphaSpin->setValue(pen.alpha()); brush = scene->brush().color(); + ui->alphaSlider->setValue(brush.alpha()); + ui->alphaSpin->setValue(brush.alpha()); this->scene = scene; } @@ -37,10 +42,12 @@ BrushPenSelection::~BrushPenSelection() { void BrushPenSelection::on_penColor_clicked(bool) { pen = QColorDialog::getColor(pen, this, "Pen Color"); + pen.setAlpha(ui->penAlphaSpin->value()); } void BrushPenSelection::on_brushColor_clicked(bool) { brush = QColorDialog::getColor(brush, this, "Brush Color"); + brush.setAlpha(ui->alphaSpin->value()); } void BrushPenSelection::on_buttonBox_accepted() { @@ -82,3 +89,11 @@ void BrushPenSelection::on_radSpinner_valueChanged(double arg1) { void BrushPenSelection::on_radSlider_sliderMoved(int position) { ui->radSpinner->setValue(position / 100.); } + +void BrushPenSelection::on_alphaSpin_valueChanged(int arg1) { + brush.setAlpha(arg1); +} + +void BrushPenSelection::on_penAlphaSpin_valueChanged(int arg1) { + pen.setAlpha(arg1); +} diff --git a/cropeditor/settings/brushpenselection.hpp b/cropeditor/settings/brushpenselection.hpp index aca79ec..3ae277d 100644 --- a/cropeditor/settings/brushpenselection.hpp +++ b/cropeditor/settings/brushpenselection.hpp @@ -15,7 +15,8 @@ public: explicit BrushPenSelection(CropScene *scene); ~BrushPenSelection(); -public slots: +private slots: + void on_alphaSpin_valueChanged(int arg1); void on_radSlider_sliderMoved(int position); void on_radSpinner_valueChanged(double arg1); void on_penColor_clicked(bool); @@ -24,6 +25,7 @@ public slots: void on_buttonBox_rejected(); void on_widthSlider_sliderMoved(int position); void on_widthSpinner_valueChanged(double arg1); + void on_penAlphaSpin_valueChanged(int arg1); private: Ui::BrushPenSelection *ui; diff --git a/cropeditor/settings/brushpenselection.ui b/cropeditor/settings/brushpenselection.ui index b8c0c8f..de5cebc 100644 --- a/cropeditor/settings/brushpenselection.ui +++ b/cropeditor/settings/brushpenselection.ui @@ -7,7 +7,7 @@ 0 0 449 - 367 + 489 @@ -23,13 +23,30 @@ Pen settings - + + + + 2500 + + + Qt::Horizontal + + + + Choose pen color + + + + Cosmetic + + + @@ -37,26 +54,33 @@ - - - - - + + - Cosmetic + Pen alpha - - + + + + + - 2500 + 255 Qt::Horizontal + + + + 255 + + + @@ -66,14 +90,7 @@ Brush settings - - - - Choose brush color - - - - + @@ -152,13 +169,44 @@ - + Path item has brush + + + + 255 + + + + + + + 255 + + + Qt::Horizontal + + + + + + + Choose brush color + + + + + + + Brush alpha + + + @@ -261,5 +309,70 @@ - + + + alphaSlider + sliderMoved(int) + alphaSpin + setValue(int) + + + 91 + 292 + + + 196 + 292 + + + + + alphaSpin + valueChanged(int) + alphaSlider + setValue(int) + + + 196 + 292 + + + 91 + 292 + + + + + penAlphaSpin + valueChanged(int) + penAlphaSlider + setValue(int) + + + 191 + 211 + + + 86 + 211 + + + + + penAlphaSlider + valueChanged(int) + penAlphaSpin + setValue(int) + + + 86 + 211 + + + 191 + 211 + + + +