WatchWidget: Add new/delete/clear toolbar items
This commit is contained in:
parent
9d94a31eae
commit
07f68560e6
|
@ -5,6 +5,7 @@
|
|||
#include "DolphinQt/Debugger/WatchWidget.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QTableWidget>
|
||||
#include <QToolBar>
|
||||
|
@ -85,9 +86,15 @@ void WatchWidget::CreateWidgets()
|
|||
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
m_new = m_toolbar->addAction(tr("New"), this, &WatchWidget::OnNewWatch);
|
||||
m_delete = m_toolbar->addAction(tr("Delete"), this, &WatchWidget::OnDelete);
|
||||
m_clear = m_toolbar->addAction(tr("Clear"), this, &WatchWidget::OnClear);
|
||||
m_load = m_toolbar->addAction(tr("Load"), this, &WatchWidget::OnLoad);
|
||||
m_save = m_toolbar->addAction(tr("Save"), this, &WatchWidget::OnSave);
|
||||
|
||||
m_new->setEnabled(false);
|
||||
m_delete->setEnabled(false);
|
||||
m_clear->setEnabled(false);
|
||||
m_load->setEnabled(false);
|
||||
m_save->setEnabled(false);
|
||||
|
||||
|
@ -111,6 +118,10 @@ void WatchWidget::ConnectWidgets()
|
|||
|
||||
void WatchWidget::UpdateIcons()
|
||||
{
|
||||
// TODO: Create a "debugger_add_watch" icon
|
||||
m_new->setIcon(Resources::GetScaledThemeIcon("debugger_add_breakpoint"));
|
||||
m_delete->setIcon(Resources::GetScaledThemeIcon("debugger_delete"));
|
||||
m_clear->setIcon(Resources::GetScaledThemeIcon("debugger_clear"));
|
||||
m_load->setIcon(Resources::GetScaledThemeIcon("debugger_load"));
|
||||
m_save->setIcon(Resources::GetScaledThemeIcon("debugger_save"));
|
||||
}
|
||||
|
@ -120,8 +131,12 @@ void WatchWidget::UpdateButtonsEnabled()
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
m_load->setEnabled(Core::IsRunning());
|
||||
m_save->setEnabled(Core::IsRunning());
|
||||
const bool is_enabled = Core::IsRunning();
|
||||
m_new->setEnabled(is_enabled);
|
||||
m_delete->setEnabled(is_enabled);
|
||||
m_clear->setEnabled(is_enabled);
|
||||
m_load->setEnabled(is_enabled);
|
||||
m_save->setEnabled(is_enabled);
|
||||
}
|
||||
|
||||
void WatchWidget::Update()
|
||||
|
@ -216,6 +231,40 @@ void WatchWidget::showEvent(QShowEvent* event)
|
|||
Update();
|
||||
}
|
||||
|
||||
void WatchWidget::OnDelete()
|
||||
{
|
||||
if (m_table->selectedItems().empty())
|
||||
return;
|
||||
|
||||
auto row_variant = m_table->selectedItems()[0]->data(Qt::UserRole);
|
||||
if (row_variant.isNull())
|
||||
return;
|
||||
|
||||
DeleteWatch(row_variant.toInt());
|
||||
}
|
||||
|
||||
void WatchWidget::OnClear()
|
||||
{
|
||||
PowerPC::debug_interface.ClearWatches();
|
||||
Update();
|
||||
}
|
||||
|
||||
void WatchWidget::OnNewWatch()
|
||||
{
|
||||
QString text = QInputDialog::getText(this, tr("Input"), tr("Enter address to watch:"));
|
||||
bool good;
|
||||
uint address = text.toUInt(&good, 16);
|
||||
|
||||
if (!good)
|
||||
{
|
||||
ModalMessageBox::warning(this, tr("Error"), tr("Invalid watch address: %1").arg(text));
|
||||
return;
|
||||
}
|
||||
|
||||
const QString name = QStringLiteral("mem_%1").arg(address, 8, 16, QLatin1Char('0'));
|
||||
AddWatch(name, address);
|
||||
}
|
||||
|
||||
void WatchWidget::OnLoad()
|
||||
{
|
||||
IniFile ini;
|
||||
|
|
|
@ -34,6 +34,10 @@ private:
|
|||
void CreateWidgets();
|
||||
void ConnectWidgets();
|
||||
|
||||
void OnDelete();
|
||||
void OnClear();
|
||||
void OnNewWatch();
|
||||
|
||||
void OnLoad();
|
||||
void OnSave();
|
||||
|
||||
|
@ -47,6 +51,9 @@ private:
|
|||
|
||||
void UpdateIcons();
|
||||
|
||||
QAction* m_new;
|
||||
QAction* m_delete;
|
||||
QAction* m_clear;
|
||||
QAction* m_load;
|
||||
QAction* m_save;
|
||||
QToolBar* m_toolbar;
|
||||
|
|
Loading…
Reference in New Issue