Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 996b6610 authored by Laurent Montel's avatar Laurent Montel 😁

Avoid to show empty menu

parent cc2861ae
......@@ -436,19 +436,20 @@ void SimpleStringListEditor::slotContextMenu(const QPoint &pos)
{
QList<QListWidgetItem *> lstSelectedItems = d->mListBox->selectedItems();
const bool hasItemsSelected = !lstSelectedItems.isEmpty();
QMenu *menu = new QMenu(this);
QMenu menu(this);
if (d->mAddButton) {
menu->addAction(d->mAddButton->text(), this, &SimpleStringListEditor::slotAdd);
menu.addAction(d->mAddButton->text(), this, &SimpleStringListEditor::slotAdd);
}
if (d->mModifyButton && (lstSelectedItems.count() == 1)) {
menu->addAction(d->mModifyButton->text(), this, &SimpleStringListEditor::slotModify);
menu.addAction(d->mModifyButton->text(), this, &SimpleStringListEditor::slotModify);
}
if (d->mRemoveButton && hasItemsSelected) {
menu->addSeparator();
menu->addAction(d->mRemoveButton->text(), this, &SimpleStringListEditor::slotRemove);
menu.addSeparator();
menu.addAction(d->mRemoveButton->text(), this, &SimpleStringListEditor::slotRemove);
}
if (!menu.isEmpty()) {
menu.exec(d->mListBox->mapToGlobal(pos));
}
menu->exec(d->mListBox->mapToGlobal(pos));
delete menu;
}
QSize SimpleStringListEditor::sizeHint() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment