Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow deletion of empty menu sections #5

Merged
merged 2 commits into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/gmenu2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,15 @@ void GMenu2X::renameSection() {
}

void GMenu2X::deleteSection() {
MessageBox mb(this, tr["All links in this section will be removed."] + "\n" + tr["Are you sure?"]);
// only allow deleting of empty section to reduce accidental deletions
if ( menu->sectionLinks()->size() > 0) {
MessageBox mb(this, tr["Error: cannot delete menu section with links in it."]);
mb.setButton(CONFIRM, tr["OK"]);
mb.exec();
return;
}

MessageBox mb(this, tr["Really delete this menu section?"] + "\n" + tr[menu->selSection()]);
mb.setButton(CONFIRM, tr["Yes"]);
mb.setButton(CANCEL, tr["No"]);
if (mb.exec() == CONFIRM) {
Expand Down