ARWidget: Disable Edit and Remove buttons when no code is selected

Also some minor refactoring of nearby/related code:
* Make non-obvious variable types explicit instead of auto.
* Throw some consts around.
* Use setDisabled(empty) instead of setEnabled(!empty).
This commit is contained in:
Dentomologist
2024-08-25 15:33:41 -07:00
parent 5af0ae25e6
commit ee35aa49a2
2 changed files with 15 additions and 12 deletions

View File

@ -166,17 +166,16 @@ void GeckoCodeWidget::ConnectWidgets()
void GeckoCodeWidget::OnSelectionChanged()
{
auto items = m_code_list->selectedItems();
const QList<QListWidgetItem*> items = m_code_list->selectedItems();
const bool empty = items.empty();
m_edit_code->setEnabled(!empty);
m_remove_code->setEnabled(!empty);
m_edit_code->setDisabled(empty);
m_remove_code->setDisabled(empty);
if (items.empty())
if (empty)
return;
auto selected = items[0];
const QListWidgetItem* const selected = items[0];
const int index = selected->data(Qt::UserRole).toInt();