Skip to content

Commit

Permalink
Fix bug which prevented barlines from being deleted
Browse files Browse the repository at this point in the history
The delete key also now works when the caret is on a barline. Previously the barline needed to also be selected first by clicking on it

#493
  • Loading branch information
cameronwhite committed Nov 14, 2024
1 parent 18ee4b4 commit 33935d8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Thanks to the following contributors who worked on this release:
### Added

### Changed
- The barline under the cursor can now be deleted without requiring it to be selected first

### Fixed
- Fixed AppStream validation issues in `xdg/powertabeditor.metainfo.xml`
- Fixed a bug which could prevent barlines from being deleted

## [2.0.20] - 2024-11-03

Expand Down
7 changes: 4 additions & 3 deletions source/app/powertabeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3874,6 +3874,8 @@ void PowerTabEditor::updateCommands()
ScoreUtils::findByPosition(staff.getDynamics(), position);
const bool positions_selected =
location.hasSelection() && !location.getSelectedPositions().empty();
const bool barlines_selected =
location.hasSelection() && !location.getSelectedBarlines().empty();

myRemoveCurrentSystemCommand->setEnabled(score.getSystems().size() > 1);
myRemoveCurrentStaffCommand->setEnabled(system.getStaves().size() > 1);
Expand All @@ -3883,9 +3885,8 @@ void PowerTabEditor::updateCommands()
Score::MIN_LINE_SPACING);
myRemoveSpaceCommand->setEnabled(!pos && (position == 0 || !barline) &&
!tempoMarker && !altEnding && !dynamic);
myRemoveItemCommand->setEnabled(
pos || positions_selected ||
canDeleteItem(getCaret().getSelectedItem()));
myRemoveItemCommand->setEnabled(pos || positions_selected || barline || barlines_selected ||
canDeleteItem(getCaret().getSelectedItem()));
myRemovePositionCommand->setEnabled(pos || positions_selected);

myChordNameCommand->setChecked(
Expand Down
2 changes: 1 addition & 1 deletion source/score/scorelocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ ScoreLocation::getSelectedBarlines()
// Avoid duplicate logic between const and non-const versions.
std::vector<const Barline *> barlines = ConstScoreLocation::getSelectedBarlines();
std::vector<Barline *> nc_barlines;
for (const Barline *barline : nc_barlines)
for (const Barline *barline : barlines)
nc_barlines.push_back(const_cast<Barline *>(barline));

return nc_barlines;
Expand Down

0 comments on commit 33935d8

Please sign in to comment.