diff --git a/ChangeLog b/ChangeLog index b0828fd692..2f9ad822ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,7 @@ Unreleased Version 2.2.0-pre * Fix: Make reloading the last brush preset slot-specific, since it's nonsense to clobber your current slot with the last preset you set in another one. * Feature: Allow increasing and decreasing key frame exposure. Thanks Tabuley for suggesting. * Fix: Properly update the view when the canvas size changes, rather than leaving stale areas outside of the canvas. + * Feature: Add shortcuts to swap the contents of brush slots to allow for a kind of toggling behavior using a single shortcut. Thanks xxxx for suggesting. 2023-07-31 Version 2.2.0-beta.6 * Fix: Don't forget account password when entering a wrong session password. diff --git a/src/desktop/mainwindow.cpp b/src/desktop/mainwindow.cpp index 128f5e5016..6d1b14ee37 100644 --- a/src/desktop/mainwindow.cpp +++ b/src/desktop/mainwindow.cpp @@ -3773,6 +3773,18 @@ void MainWindow::setupActions() CustomShortcutModel::registerCustomizableAction(q->objectName(), q->text(), q->shortcut()); m_brushSlots->addAction(q); addAction(q); + // Swapping with the eraser slot doesn't make sense. + if(i != 5) { + QAction *s = new QAction{tr("Swap With Brush Slot #%1").arg(i +1 ), this}; + s->setAutoRepeat(false); + s->setObjectName(QStringLiteral("swapslot%1").arg(i)); + CustomShortcutModel::registerCustomizableAction( + s->objectName(), s->text(), QKeySequence()); + addAction(s); + connect(s, &QAction::triggered, this, [this, i] { + m_dockToolSettings->brushSettings()->swapWithSlot(i); + }); + } } connect(m_brushSlots, &QActionGroup::triggered, this, [this](QAction *a) { m_dockToolSettings->setToolSlot(a->property("toolslotidx").toInt()); diff --git a/src/desktop/toolwidgets/brushsettings.cpp b/src/desktop/toolwidgets/brushsettings.cpp index f3d8c83616..aa42d1d18c 100644 --- a/src/desktop/toolwidgets/brushsettings.cpp +++ b/src/desktop/toolwidgets/brushsettings.cpp @@ -418,6 +418,17 @@ void BrushSettings::selectEraserSlot(bool eraser) } } +void BrushSettings::swapWithSlot(int i) +{ + Q_ASSERT(i >= 0); + Q_ASSERT(i < ERASER_SLOT); + if(i != d->current && !isCurrentEraserSlot()) { + std::swap(d->brushSlots[d->current], d->brushSlots[i]); + std::swap(d->lastPresets[d->current], d->lastPresets[i]); + updateUi(); + } +} + void BrushSettings::setGlobalSmoothing(int smoothing) { QSignalBlocker blocker{d->ui.smoothingBox}; diff --git a/src/desktop/toolwidgets/brushsettings.h b/src/desktop/toolwidgets/brushsettings.h index ca5dd7f2eb..7b96ec2785 100644 --- a/src/desktop/toolwidgets/brushsettings.h +++ b/src/desktop/toolwidgets/brushsettings.h @@ -59,6 +59,7 @@ class BrushSettings final : public ToolSettings { public slots: void selectBrushSlot(int i); void selectEraserSlot(bool eraser); + void swapWithSlot(int i); void setGlobalSmoothing(int smoothing); void toggleEraserMode() override; void toggleRecolorMode() override;