BranchWatchDialog: Fix Misc. Errata
Window icon was missing from QDialog lacking a parent. Giving the QDialog a parent revealed I had failed to make it properly non-modal, necessitating further changes. Settings save less often, now only upon destruction. Construction of BranchWatchDialog is now deferred.
This commit is contained in:
parent
8f6fd912f7
commit
0645b4d579
|
@ -504,15 +504,9 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
|
||||||
restoreGeometry(settings.value(QStringLiteral("branchwatchdialog/geometry")).toByteArray());
|
restoreGeometry(settings.value(QStringLiteral("branchwatchdialog/geometry")).toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchWatchDialog::done(int r)
|
BranchWatchDialog::~BranchWatchDialog()
|
||||||
{
|
{
|
||||||
if (m_timer->isActive())
|
SaveSettings();
|
||||||
m_timer->stop();
|
|
||||||
auto& settings = Settings::GetQSettings();
|
|
||||||
settings.setValue(QStringLiteral("branchwatchdialog/geometry"), saveGeometry());
|
|
||||||
settings.setValue(QStringLiteral("branchwatchdialog/tableheader/state"),
|
|
||||||
m_table_view->horizontalHeader()->saveState());
|
|
||||||
QDialog::done(r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr int BRANCH_WATCH_TOOL_TIMER_DELAY_MS = 100;
|
static constexpr int BRANCH_WATCH_TOOL_TIMER_DELAY_MS = 100;
|
||||||
|
@ -523,18 +517,18 @@ static bool TimerCondition(const Core::BranchWatch& branch_watch, Core::State st
|
||||||
return branch_watch.GetRecordingActive() && state > Core::State::Paused;
|
return branch_watch.GetRecordingActive() && state > Core::State::Paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BranchWatchDialog::exec()
|
void BranchWatchDialog::hideEvent(QHideEvent* event)
|
||||||
{
|
{
|
||||||
if (TimerCondition(m_branch_watch, Core::GetState()))
|
if (m_timer->isActive())
|
||||||
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
|
m_timer->stop();
|
||||||
return QDialog::exec();
|
QDialog::hideEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchWatchDialog::open()
|
void BranchWatchDialog::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
if (TimerCondition(m_branch_watch, Core::GetState()))
|
if (TimerCondition(m_branch_watch, Core::GetState()))
|
||||||
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
|
m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS);
|
||||||
QDialog::open();
|
QDialog::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchWatchDialog::OnStartPause(bool checked)
|
void BranchWatchDialog::OnStartPause(bool checked)
|
||||||
|
@ -927,6 +921,14 @@ void BranchWatchDialog::OnTableCopyAddress(QModelIndexList index_list)
|
||||||
QApplication::clipboard()->setText(text);
|
QApplication::clipboard()->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BranchWatchDialog::SaveSettings()
|
||||||
|
{
|
||||||
|
auto& settings = Settings::GetQSettings();
|
||||||
|
settings.setValue(QStringLiteral("branchwatchdialog/geometry"), saveGeometry());
|
||||||
|
settings.setValue(QStringLiteral("branchwatchdialog/tableheader/state"),
|
||||||
|
m_table_view->horizontalHeader()->saveState());
|
||||||
|
}
|
||||||
|
|
||||||
void BranchWatchDialog::Update()
|
void BranchWatchDialog::Update()
|
||||||
{
|
{
|
||||||
if (m_branch_watch.GetRecordingPhase() == Core::BranchWatch::Phase::Blacklist)
|
if (m_branch_watch.GetRecordingPhase() == Core::BranchWatch::Phase::Blacklist)
|
||||||
|
|
|
@ -49,9 +49,11 @@ class BranchWatchDialog : public QDialog
|
||||||
public:
|
public:
|
||||||
explicit BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
|
explicit BranchWatchDialog(Core::System& system, Core::BranchWatch& branch_watch,
|
||||||
CodeWidget* code_widget, QWidget* parent = nullptr);
|
CodeWidget* code_widget, QWidget* parent = nullptr);
|
||||||
void done(int r) override;
|
~BranchWatchDialog() override;
|
||||||
int exec() override;
|
|
||||||
void open() override;
|
protected:
|
||||||
|
void hideEvent(QHideEvent* event) override;
|
||||||
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnStartPause(bool checked);
|
void OnStartPause(bool checked);
|
||||||
|
@ -82,6 +84,8 @@ private:
|
||||||
void OnTableSetNOP(QModelIndexList index_list);
|
void OnTableSetNOP(QModelIndexList index_list);
|
||||||
void OnTableCopyAddress(QModelIndexList index_list);
|
void OnTableCopyAddress(QModelIndexList index_list);
|
||||||
|
|
||||||
|
void SaveSettings();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
|
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
|
||||||
void Update();
|
void Update();
|
||||||
|
|
|
@ -36,10 +36,7 @@ static const QString BOX_SPLITTER_STYLESHEET = QStringLiteral(
|
||||||
"QSplitter::handle { border-top: 1px dashed black; width: 1px; margin-left: 10px; "
|
"QSplitter::handle { border-top: 1px dashed black; width: 1px; margin-left: 10px; "
|
||||||
"margin-right: 10px; }");
|
"margin-right: 10px; }");
|
||||||
|
|
||||||
CodeWidget::CodeWidget(QWidget* parent)
|
CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent), m_system(Core::System::GetInstance())
|
||||||
: QDockWidget(parent), m_system(Core::System::GetInstance()),
|
|
||||||
m_branch_watch_dialog(
|
|
||||||
new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(), this))
|
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Code"));
|
setWindowTitle(tr("Code"));
|
||||||
setObjectName(QStringLiteral("code"));
|
setObjectName(QStringLiteral("code"));
|
||||||
|
@ -215,7 +212,12 @@ void CodeWidget::ConnectWidgets()
|
||||||
|
|
||||||
void CodeWidget::OnBranchWatchDialog()
|
void CodeWidget::OnBranchWatchDialog()
|
||||||
{
|
{
|
||||||
m_branch_watch_dialog->open();
|
if (m_branch_watch_dialog == nullptr)
|
||||||
|
{
|
||||||
|
m_branch_watch_dialog =
|
||||||
|
new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(), this, this);
|
||||||
|
}
|
||||||
|
m_branch_watch_dialog->show();
|
||||||
m_branch_watch_dialog->raise();
|
m_branch_watch_dialog->raise();
|
||||||
m_branch_watch_dialog->activateWindow();
|
m_branch_watch_dialog->activateWindow();
|
||||||
}
|
}
|
||||||
|
@ -397,7 +399,8 @@ void CodeWidget::UpdateSymbols()
|
||||||
|
|
||||||
// TODO: There seems to be a lack of a ubiquitous signal for when symbols change.
|
// TODO: There seems to be a lack of a ubiquitous signal for when symbols change.
|
||||||
// This is the best location to catch the signals from MenuBar and CodeViewWidget.
|
// This is the best location to catch the signals from MenuBar and CodeViewWidget.
|
||||||
m_branch_watch_dialog->UpdateSymbols();
|
if (m_branch_watch_dialog != nullptr)
|
||||||
|
m_branch_watch_dialog->UpdateSymbols();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
|
void CodeWidget::UpdateFunctionCalls(const Common::Symbol* symbol)
|
||||||
|
@ -470,7 +473,8 @@ void CodeWidget::Step()
|
||||||
// Will get a UpdateDisasmDialog(), don't update the GUI here.
|
// Will get a UpdateDisasmDialog(), don't update the GUI here.
|
||||||
|
|
||||||
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
|
// TODO: Step doesn't cause EmulationStateChanged to be emitted, so it has to call this manually.
|
||||||
m_branch_watch_dialog->Update();
|
if (m_branch_watch_dialog != nullptr)
|
||||||
|
m_branch_watch_dialog->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeWidget::StepOver()
|
void CodeWidget::StepOver()
|
||||||
|
|
|
@ -72,7 +72,7 @@ private:
|
||||||
|
|
||||||
Core::System& m_system;
|
Core::System& m_system;
|
||||||
|
|
||||||
BranchWatchDialog* m_branch_watch_dialog;
|
BranchWatchDialog* m_branch_watch_dialog = nullptr;
|
||||||
QLineEdit* m_search_address;
|
QLineEdit* m_search_address;
|
||||||
QPushButton* m_branch_watch;
|
QPushButton* m_branch_watch;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue