Merge pull request #12797 from mitaclaw/branch-watch-tool-fixes-1

Branch Watch Tool: Fixes
This commit is contained in:
Admiral H. Curtiss 2024-05-31 18:11:36 +02:00 committed by GitHub
commit 072b6cdb1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 13 deletions

View File

@ -57,6 +57,12 @@ public:
: QSortFilterProxyModel(parent), m_branch_watch(branch_watch) : QSortFilterProxyModel(parent), m_branch_watch(branch_watch)
{ {
} }
~BranchWatchProxyModel() override = default;
BranchWatchProxyModel(const BranchWatchProxyModel&) = delete;
BranchWatchProxyModel(BranchWatchProxyModel&&) = delete;
BranchWatchProxyModel& operator=(const BranchWatchProxyModel&) = delete;
BranchWatchProxyModel& operator=(BranchWatchProxyModel&&) = delete;
BranchWatchTableModel* sourceModel() const BranchWatchTableModel* sourceModel() const
{ {
@ -201,7 +207,6 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
{ {
setWindowTitle(tr("Branch Watch Tool")); setWindowTitle(tr("Branch Watch Tool"));
setWindowFlags((windowFlags() | Qt::WindowMinMaxButtonsHint) & ~Qt::WindowContextHelpButtonHint); setWindowFlags((windowFlags() | Qt::WindowMinMaxButtonsHint) & ~Qt::WindowContextHelpButtonHint);
SetQWidgetWindowDecorations(this);
setLayout([this, &ppc_symbol_db]() { setLayout([this, &ppc_symbol_db]() {
auto* main_layout = new QVBoxLayout; auto* main_layout = new QVBoxLayout;
@ -216,6 +221,7 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
m_table_proxy->setSourceModel( m_table_proxy->setSourceModel(
m_table_model = new BranchWatchTableModel(m_system, m_branch_watch, ppc_symbol_db)); m_table_model = new BranchWatchTableModel(m_system, m_branch_watch, ppc_symbol_db));
m_table_proxy->setSortRole(UserRole::SortRole); m_table_proxy->setSortRole(UserRole::SortRole);
m_table_proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
m_table_model->setFont(ui_settings.GetDebugFont()); m_table_model->setFont(ui_settings.GetDebugFont());
connect(&ui_settings, &Settings::DebugFontChanged, m_table_model, connect(&ui_settings, &Settings::DebugFontChanged, m_table_model,
@ -234,6 +240,11 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
table_view->setEditTriggers(QAbstractItemView::NoEditTriggers); table_view->setEditTriggers(QAbstractItemView::NoEditTriggers);
table_view->setCornerButtonEnabled(false); table_view->setCornerButtonEnabled(false);
table_view->verticalHeader()->hide(); table_view->verticalHeader()->hide();
table_view->setColumnWidth(Column::Instruction, 50);
table_view->setColumnWidth(Column::Condition, 50);
table_view->setColumnWidth(Column::OriginSymbol, 250);
table_view->setColumnWidth(Column::DestinSymbol, 250);
// The default column width (100 units) is fine for the rest.
QHeaderView* const horizontal_header = table_view->horizontalHeader(); QHeaderView* const horizontal_header = table_view->horizontalHeader();
horizontal_header->restoreState( // Restore column visibility state. horizontal_header->restoreState( // Restore column visibility state.
@ -495,16 +506,6 @@ BranchWatchDialog::BranchWatchDialog(Core::System& system, Core::BranchWatch& br
return main_layout; return main_layout;
}()); }());
// FIXME: On Linux, Qt6 has recently been resetting column widths to their defaults in many
// unexpected ways. This affects all kinds of QTables in Dolphin's GUI, so to avoid it in
// this QTableView, I have deferred this operation. Any earlier, and this would be undone.
// SetQWidgetWindowDecorations was moved to before these operations for the same reason.
m_table_view->setColumnWidth(Column::Instruction, 50);
m_table_view->setColumnWidth(Column::Condition, 50);
m_table_view->setColumnWidth(Column::OriginSymbol, 250);
m_table_view->setColumnWidth(Column::DestinSymbol, 250);
// The default column width (100 units) is fine for the rest.
const auto& settings = Settings::GetQSettings(); const auto& settings = Settings::GetQSettings();
restoreGeometry(settings.value(QStringLiteral("branchwatchdialog/geometry")).toByteArray()); restoreGeometry(settings.value(QStringLiteral("branchwatchdialog/geometry")).toByteArray());
} }

View File

@ -9,12 +9,11 @@
#include <QDialog> #include <QDialog>
#include <QModelIndexList> #include <QModelIndexList>
#include "Core/Core.h"
namespace Core namespace Core
{ {
class BranchWatch; class BranchWatch;
class CPUThreadGuard; class CPUThreadGuard;
enum class State;
class System; class System;
} // namespace Core } // namespace Core
class PPCSymbolDB; class PPCSymbolDB;
@ -54,6 +53,11 @@ public:
QWidget* parent = nullptr); QWidget* parent = nullptr);
~BranchWatchDialog() override; ~BranchWatchDialog() override;
BranchWatchDialog(const BranchWatchDialog&) = delete;
BranchWatchDialog(BranchWatchDialog&&) = delete;
BranchWatchDialog& operator=(const BranchWatchDialog&) = delete;
BranchWatchDialog& operator=(BranchWatchDialog&&) = delete;
protected: protected:
void hideEvent(QHideEvent* event) override; void hideEvent(QHideEvent* event) override;
void showEvent(QShowEvent* event) override; void showEvent(QShowEvent* event) override;

View File

@ -75,6 +75,13 @@ public:
m_ppc_symbol_db(ppc_symbol_db) m_ppc_symbol_db(ppc_symbol_db)
{ {
} }
~BranchWatchTableModel() override = default;
BranchWatchTableModel(const BranchWatchTableModel&) = delete;
BranchWatchTableModel(BranchWatchTableModel&&) = delete;
BranchWatchTableModel& operator=(const BranchWatchTableModel&) = delete;
BranchWatchTableModel& operator=(BranchWatchTableModel&&) = delete;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override; int role = Qt::DisplayRole) const override;

View File

@ -206,6 +206,7 @@ void CodeWidget::OnBranchWatchDialog()
m_branch_watch_dialog = new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(), m_branch_watch_dialog = new BranchWatchDialog(m_system, m_system.GetPowerPC().GetBranchWatch(),
m_ppc_symbol_db, this, this); m_ppc_symbol_db, this, this);
} }
SetQWidgetWindowDecorations(m_branch_watch_dialog);
m_branch_watch_dialog->show(); 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();