Branch Watch Tool: Refresh Context Menus OnEmulationStateChanged
This commit is contained in:
parent
ada646a795
commit
97e2a43eac
|
@ -458,8 +458,12 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
|
||||||
m_mnu_table_context_origin->addActions(
|
m_mnu_table_context_origin->addActions(
|
||||||
{delete_action, m_act_insert_nop, m_act_copy_address, m_mnu_set_breakpoint->menuAction()});
|
{delete_action, m_act_insert_nop, m_act_copy_address, m_mnu_set_breakpoint->menuAction()});
|
||||||
|
|
||||||
m_mnu_table_context_destin_or_symbol = new QMenu(this);
|
m_mnu_table_context_destin = new QMenu(this);
|
||||||
m_mnu_table_context_destin_or_symbol->addActions(
|
m_mnu_table_context_destin->addActions(
|
||||||
|
{delete_action, m_act_insert_blr, m_act_copy_address, m_mnu_set_breakpoint->menuAction()});
|
||||||
|
|
||||||
|
m_mnu_table_context_symbol = new QMenu(this);
|
||||||
|
m_mnu_table_context_symbol->addActions(
|
||||||
{delete_action, m_act_insert_blr, m_act_copy_address, m_mnu_set_breakpoint->menuAction()});
|
{delete_action, m_act_insert_blr, m_act_copy_address, m_mnu_set_breakpoint->menuAction()});
|
||||||
|
|
||||||
m_mnu_table_context_other = new QMenu(this);
|
m_mnu_table_context_other = new QMenu(this);
|
||||||
|
@ -707,8 +711,10 @@ void BranchWatchDialog::OnTimeout() const
|
||||||
|
|
||||||
void BranchWatchDialog::OnEmulationStateChanged(Core::State new_state) const
|
void BranchWatchDialog::OnEmulationStateChanged(Core::State new_state) const
|
||||||
{
|
{
|
||||||
m_btn_was_overwritten->setEnabled(new_state != Core::State::Uninitialized);
|
const bool core_initialized = new_state != Core::State::Uninitialized;
|
||||||
m_btn_not_overwritten->setEnabled(new_state != Core::State::Uninitialized);
|
RefreshVisibleContextMenuActions(core_initialized);
|
||||||
|
m_btn_was_overwritten->setEnabled(core_initialized);
|
||||||
|
m_btn_not_overwritten->setEnabled(core_initialized);
|
||||||
if (TimerCondition(m_branch_watch, new_state))
|
if (TimerCondition(m_branch_watch, new_state))
|
||||||
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
|
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
|
||||||
else if (m_timer->isActive())
|
else if (m_timer->isActive())
|
||||||
|
@ -1192,25 +1198,44 @@ QMenu* BranchWatchDialog::GetTableContextMenu(const QModelIndex& index) const
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case Column::Instruction:
|
case Column::Instruction:
|
||||||
return GetTableContextMenu_Instruction(core_initialized);
|
RefreshContextMenuActions_Instruction(core_initialized);
|
||||||
|
return m_mnu_table_context_instruction;
|
||||||
case Column::Condition:
|
case Column::Condition:
|
||||||
return GetTableContextMenu_Condition(core_initialized);
|
RefreshContextMenuActions_Condition(core_initialized);
|
||||||
|
return m_mnu_table_context_condition;
|
||||||
case Column::Origin:
|
case Column::Origin:
|
||||||
return GetTableContextMenu_Origin(core_initialized);
|
RefreshContextMenuActions_Origin(core_initialized);
|
||||||
|
return m_mnu_table_context_origin;
|
||||||
case Column::Destination:
|
case Column::Destination:
|
||||||
return GetTableContextMenu_Destin(core_initialized);
|
RefreshContextMenuActions_Destin(core_initialized);
|
||||||
|
return m_mnu_table_context_destin;
|
||||||
case Column::RecentHits:
|
case Column::RecentHits:
|
||||||
case Column::TotalHits:
|
case Column::TotalHits:
|
||||||
return m_mnu_table_context_other;
|
return m_mnu_table_context_other;
|
||||||
case Column::OriginSymbol:
|
case Column::OriginSymbol:
|
||||||
case Column::DestinSymbol:
|
case Column::DestinSymbol:
|
||||||
return GetTableContextMenu_Symbol(core_initialized);
|
RefreshContextMenuActions_Symbol(core_initialized);
|
||||||
|
return m_mnu_table_context_symbol;
|
||||||
}
|
}
|
||||||
static_assert(Column::NumberOfColumns == 8);
|
static_assert(Column::NumberOfColumns == 8);
|
||||||
Common::Unreachable();
|
Common::Unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* BranchWatchDialog::GetTableContextMenu_Instruction(bool core_initialized) const
|
void BranchWatchDialog::RefreshVisibleContextMenuActions(bool core_initialized) const
|
||||||
|
{
|
||||||
|
if (m_mnu_table_context_instruction->isVisible())
|
||||||
|
RefreshContextMenuActions_Instruction(core_initialized);
|
||||||
|
else if (m_mnu_table_context_condition->isVisible())
|
||||||
|
RefreshContextMenuActions_Condition(core_initialized);
|
||||||
|
else if (m_mnu_table_context_origin->isVisible())
|
||||||
|
RefreshContextMenuActions_Origin(core_initialized);
|
||||||
|
else if (m_mnu_table_context_destin->isVisible())
|
||||||
|
RefreshContextMenuActions_Destin(core_initialized);
|
||||||
|
else if (m_mnu_table_context_symbol->isVisible())
|
||||||
|
RefreshContextMenuActions_Symbol(core_initialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BranchWatchDialog::RefreshContextMenuActions_Instruction(bool core_initialized) const
|
||||||
{
|
{
|
||||||
const bool all_branches_conditional = // Taking advantage of short-circuit evaluation here.
|
const bool all_branches_conditional = // Taking advantage of short-circuit evaluation here.
|
||||||
core_initialized && std::ranges::all_of(m_index_list_temp, [this](const QModelIndex& index) {
|
core_initialized && std::ranges::all_of(m_index_list_temp, [this](const QModelIndex& index) {
|
||||||
|
@ -1219,10 +1244,9 @@ QMenu* BranchWatchDialog::GetTableContextMenu_Instruction(bool core_initialized)
|
||||||
});
|
});
|
||||||
m_act_invert_condition->setEnabled(all_branches_conditional);
|
m_act_invert_condition->setEnabled(all_branches_conditional);
|
||||||
m_act_invert_decrement_check->setEnabled(all_branches_conditional);
|
m_act_invert_decrement_check->setEnabled(all_branches_conditional);
|
||||||
return m_mnu_table_context_instruction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* BranchWatchDialog::GetTableContextMenu_Condition(bool core_initialized) const
|
void BranchWatchDialog::RefreshContextMenuActions_Condition(bool core_initialized) const
|
||||||
{
|
{
|
||||||
const bool all_branches_conditional = // Taking advantage of short-circuit evaluation here.
|
const bool all_branches_conditional = // Taking advantage of short-circuit evaluation here.
|
||||||
core_initialized && std::ranges::all_of(m_index_list_temp, [this](const QModelIndex& index) {
|
core_initialized && std::ranges::all_of(m_index_list_temp, [this](const QModelIndex& index) {
|
||||||
|
@ -1230,19 +1254,17 @@ QMenu* BranchWatchDialog::GetTableContextMenu_Condition(bool core_initialized) c
|
||||||
m_table_proxy->GetBranchWatchSelection(index).collection_ptr->first.original_inst);
|
m_table_proxy->GetBranchWatchSelection(index).collection_ptr->first.original_inst);
|
||||||
});
|
});
|
||||||
m_act_make_unconditional->setEnabled(all_branches_conditional);
|
m_act_make_unconditional->setEnabled(all_branches_conditional);
|
||||||
return m_mnu_table_context_condition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* BranchWatchDialog::GetTableContextMenu_Origin(bool core_initialized) const
|
void BranchWatchDialog::RefreshContextMenuActions_Origin(bool core_initialized) const
|
||||||
{
|
{
|
||||||
SetBreakpointMenuActionsIcons();
|
SetBreakpointMenuActionsIcons();
|
||||||
m_act_insert_nop->setEnabled(core_initialized);
|
m_act_insert_nop->setEnabled(core_initialized);
|
||||||
m_act_copy_address->setEnabled(true);
|
m_act_copy_address->setEnabled(true);
|
||||||
m_mnu_set_breakpoint->setEnabled(true);
|
m_mnu_set_breakpoint->setEnabled(true);
|
||||||
return m_mnu_table_context_origin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* BranchWatchDialog::GetTableContextMenu_Destin(bool core_initialized) const
|
void BranchWatchDialog::RefreshContextMenuActions_Destin(bool core_initialized) const
|
||||||
{
|
{
|
||||||
SetBreakpointMenuActionsIcons();
|
SetBreakpointMenuActionsIcons();
|
||||||
const bool all_branches_save_lr = // Taking advantage of short-circuit evaluation here.
|
const bool all_branches_save_lr = // Taking advantage of short-circuit evaluation here.
|
||||||
|
@ -1252,10 +1274,9 @@ QMenu* BranchWatchDialog::GetTableContextMenu_Destin(bool core_initialized) cons
|
||||||
m_act_insert_blr->setEnabled(all_branches_save_lr);
|
m_act_insert_blr->setEnabled(all_branches_save_lr);
|
||||||
m_act_copy_address->setEnabled(true);
|
m_act_copy_address->setEnabled(true);
|
||||||
m_mnu_set_breakpoint->setEnabled(true);
|
m_mnu_set_breakpoint->setEnabled(true);
|
||||||
return m_mnu_table_context_destin_or_symbol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu* BranchWatchDialog::GetTableContextMenu_Symbol(bool core_initialized) const
|
void BranchWatchDialog::RefreshContextMenuActions_Symbol(bool core_initialized) const
|
||||||
{
|
{
|
||||||
SetBreakpointMenuActionsIcons();
|
SetBreakpointMenuActionsIcons();
|
||||||
const bool all_symbols_valid =
|
const bool all_symbols_valid =
|
||||||
|
@ -1265,5 +1286,4 @@ QMenu* BranchWatchDialog::GetTableContextMenu_Symbol(bool core_initialized) cons
|
||||||
m_act_insert_blr->setEnabled(core_initialized && all_symbols_valid);
|
m_act_insert_blr->setEnabled(core_initialized && all_symbols_valid);
|
||||||
m_act_copy_address->setEnabled(all_symbols_valid);
|
m_act_copy_address->setEnabled(all_symbols_valid);
|
||||||
m_mnu_set_breakpoint->setEnabled(all_symbols_valid);
|
m_mnu_set_breakpoint->setEnabled(all_symbols_valid);
|
||||||
return m_mnu_table_context_destin_or_symbol;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,11 +124,12 @@ private:
|
||||||
|
|
||||||
void SetBreakpointMenuActionsIcons() const;
|
void SetBreakpointMenuActionsIcons() const;
|
||||||
QMenu* GetTableContextMenu(const QModelIndex& index) const;
|
QMenu* GetTableContextMenu(const QModelIndex& index) const;
|
||||||
QMenu* GetTableContextMenu_Instruction(bool core_initialized) const;
|
void RefreshVisibleContextMenuActions(bool core_initialized) const;
|
||||||
QMenu* GetTableContextMenu_Condition(bool core_initialized) const;
|
void RefreshContextMenuActions_Instruction(bool core_initialized) const;
|
||||||
QMenu* GetTableContextMenu_Origin(bool core_initialized) const;
|
void RefreshContextMenuActions_Condition(bool core_initialized) const;
|
||||||
QMenu* GetTableContextMenu_Destin(bool core_initialized) const;
|
void RefreshContextMenuActions_Origin(bool core_initialized) const;
|
||||||
QMenu* GetTableContextMenu_Symbol(bool core_initialized) const;
|
void RefreshContextMenuActions_Destin(bool core_initialized) const;
|
||||||
|
void RefreshContextMenuActions_Symbol(bool core_initialized) const;
|
||||||
|
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
Core::BranchWatch& m_branch_watch;
|
Core::BranchWatch& m_branch_watch;
|
||||||
|
@ -148,7 +149,7 @@ private:
|
||||||
QAction* m_act_log_on_hit;
|
QAction* m_act_log_on_hit;
|
||||||
QAction* m_act_both_on_hit;
|
QAction* m_act_both_on_hit;
|
||||||
QMenu *m_mnu_table_context_instruction, *m_mnu_table_context_condition,
|
QMenu *m_mnu_table_context_instruction, *m_mnu_table_context_condition,
|
||||||
*m_mnu_table_context_origin, *m_mnu_table_context_destin_or_symbol,
|
*m_mnu_table_context_origin, *m_mnu_table_context_destin, *m_mnu_table_context_symbol,
|
||||||
*m_mnu_table_context_other;
|
*m_mnu_table_context_other;
|
||||||
QMenu* m_mnu_column_visibility;
|
QMenu* m_mnu_column_visibility;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue