diff --git a/ChangeLog b/ChangeLog index 257f442a80..b5dfc63810 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ Unreleased Version 2.2.0-pre * Feature: Capture volume rocker on Android and bind it to undo and redo by default. Thanks to cl for suggesting. * Feature: Add compatibility for Drawpile 2.1's broken indirect mode. * Fix: Make the receive delay not delay your own undos. + * Feature: Add a setting for the background color behind the canvas. Thanks to Nightshade for suggesting. 2023-08-26 Version 2.2.0-beta.7 * Fix: Make classic brushes not go brighter when smudging into transparency. Thanks to cada for reporting. diff --git a/src/desktop/dialogs/settingsdialog/userinterface.cpp b/src/desktop/dialogs/settingsdialog/userinterface.cpp index 1797a2ed3a..4b67dd3b32 100644 --- a/src/desktop/dialogs/settingsdialog/userinterface.cpp +++ b/src/desktop/dialogs/settingsdialog/userinterface.cpp @@ -1,10 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "desktop/dialogs/settingsdialog/userinterface.h" +#include "desktop/dialogs/colordialog.h" #include "desktop/settings.h" #include "desktop/utils/sanerformlayout.h" #include "desktop/utils/widgetutils.h" #include "desktop/widgets/kis_slider_spin_box.h" +#include #include #include #include @@ -130,6 +132,21 @@ void UserInterface::initKineticScrolling( void UserInterface::initMiscellaneous( desktop::settings::Settings &settings, utils::SanerFormLayout *form) { + using color_widgets::ColorPreview; + ColorPreview *colorPreview = new ColorPreview; + colorPreview->setDisplayMode(ColorPreview::DisplayMode::NoAlpha); + colorPreview->setToolTip(tr("Background color behind the canvas")); + colorPreview->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + colorPreview->setCursor(Qt::PointingHandCursor); + form->addRow(tr("Color behind canvas:"), colorPreview); + settings.bindCanvasViewBackgroundColor(this, [colorPreview](const QColor &color) { + colorPreview->setColor(color); + }); + + connect( + colorPreview, &ColorPreview::clicked, this, + [this, &settings] { pickCanvasBackgroundColor(settings); }); + QCheckBox *scrollBars = new QCheckBox(tr("Show scroll bars on canvas")); settings.bindCanvasScrollBars(scrollBars); form->addRow(tr("Miscellaneous:"), scrollBars); @@ -139,5 +156,17 @@ void UserInterface::initMiscellaneous( form->addRow(nullptr, confirmDelete); } +void UserInterface::pickCanvasBackgroundColor(desktop::settings::Settings &settings) +{ + using color_widgets::ColorDialog; + ColorDialog dlg; + dlg.setColor(settings.canvasViewBackgroundColor()); + dlg.setAlphaEnabled(false); + dialogs::applyColorDialogSettings(&dlg); + if(dlg.exec() == QDialog::Accepted) { + settings.setCanvasViewBackgroundColor(dlg.color()); + } +} + } } diff --git a/src/desktop/dialogs/settingsdialog/userinterface.h b/src/desktop/dialogs/settingsdialog/userinterface.h index 4ba105243c..5a746a4eb5 100644 --- a/src/desktop/dialogs/settingsdialog/userinterface.h +++ b/src/desktop/dialogs/settingsdialog/userinterface.h @@ -30,6 +30,7 @@ class UserInterface final : public QWidget { desktop::settings::Settings &settings, utils::SanerFormLayout *form); void initMiscellaneous( desktop::settings::Settings &settings, utils::SanerFormLayout *form); + void pickCanvasBackgroundColor(desktop::settings::Settings &settings); }; } diff --git a/src/desktop/scene/canvasview.cpp b/src/desktop/scene/canvasview.cpp index c6ef29370f..d6af02ac47 100644 --- a/src/desktop/scene/canvasview.cpp +++ b/src/desktop/scene/canvasview.cpp @@ -79,7 +79,12 @@ CanvasView::CanvasView(QWidget *parent) setAcceptDrops(true); setFrameShape(QFrame::NoFrame); - setBackgroundBrush(QColor(100, 100, 100)); + auto &settings = dpApp().settings(); + settings.bindCanvasViewBackgroundColor(this, [this](QColor color) { + color.setAlpha(255); + setBackgroundBrush(color); + invalidateScene(QRectF{}, QGraphicsScene::BackgroundLayer); + }); m_notificationBar = new NotificationBar(this); connect( @@ -107,8 +112,6 @@ CanvasView::CanvasView(QWidget *parent) m_dotcursor = QCursor(dot, 0, 0); } - auto &settings = dpApp().settings(); - settings.bindTabletEvents(this, &widgets::CanvasView::setTabletEnabled); settings.bindOneFingerDraw(this, &widgets::CanvasView::setTouchDraw); settings.bindOneFingerScroll(this, &widgets::CanvasView::setTouchScroll); diff --git a/src/desktop/settings_table.h b/src/desktop/settings_table.h index 6084f18ca6..c23568b1c6 100644 --- a/src/desktop/settings_table.h +++ b/src/desktop/settings_table.h @@ -34,6 +34,7 @@ SETTING(brushCursor , BrushCursor , "settings/brushcursor" , widgets::CanvasView::BrushCursor::TriangleRight) SETTING(brushOutlineWidth , BrushOutlineWidth , "settings/brushoutlinewidth" , 1.0) +SETTING(canvasViewBackgroundColor , CanvasViewBackgroundColor , "settings/canvasviewbackgroundcolor" , QColor(100, 100, 100)) SETTING(canvasScrollBars , CanvasScrollBars , "settings/canvasscrollbars" , true) SETTING(canvasShortcuts , CanvasShortcuts , "settings/canvasshortcuts2" , QVariantMap()) #ifdef Q_OS_ANDROID