Skip to content

Commit

Permalink
Add shortcuts to swap the contents of brush slots
Browse files Browse the repository at this point in the history
To allow for a sort of toggling behavior using a single shortcut.
  • Loading branch information
askmeaboutlo0m committed Aug 25, 2023
1 parent f7d8826 commit 33e9dbb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions src/desktop/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
11 changes: 11 additions & 0 deletions src/desktop/toolwidgets/brushsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 1 addition & 0 deletions src/desktop/toolwidgets/brushsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 33e9dbb

Please sign in to comment.