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:
parent
5af0ae25e6
commit
ee35aa49a2
|
@ -67,8 +67,8 @@ void ARCodeWidget::CreateWidgets()
|
|||
|
||||
m_code_list->setEnabled(!m_game_id.empty());
|
||||
m_code_add->setEnabled(!m_game_id.empty());
|
||||
m_code_edit->setEnabled(!m_game_id.empty());
|
||||
m_code_remove->setEnabled(!m_game_id.empty());
|
||||
m_code_edit->setEnabled(false);
|
||||
m_code_remove->setEnabled(false);
|
||||
|
||||
m_code_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
|
@ -179,14 +179,18 @@ void ARCodeWidget::OnListReordered()
|
|||
|
||||
void ARCodeWidget::OnSelectionChanged()
|
||||
{
|
||||
auto items = m_code_list->selectedItems();
|
||||
const QList<QListWidgetItem*> items = m_code_list->selectedItems();
|
||||
const bool empty = items.empty();
|
||||
|
||||
if (items.empty())
|
||||
m_code_edit->setDisabled(empty);
|
||||
m_code_remove->setDisabled(empty);
|
||||
|
||||
if (empty)
|
||||
return;
|
||||
|
||||
const auto* selected = items[0];
|
||||
const QListWidgetItem* const selected = items[0];
|
||||
|
||||
bool user_defined = m_ar_codes[m_code_list->row(selected)].user_defined;
|
||||
const bool user_defined = m_ar_codes[m_code_list->row(selected)].user_defined;
|
||||
|
||||
m_code_remove->setEnabled(user_defined);
|
||||
m_code_edit->setText(user_defined ? tr("&Edit Code...") : tr("Clone and &Edit Code..."));
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue