Skip to content

Commit

Permalink
kernel explorer: Make it single-instance tool
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Jan 8, 2021
1 parent 36159c2 commit 92040bc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
17 changes: 13 additions & 4 deletions rpcs3/rpcs3qt/kernel_explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QHeaderView>
#include <QTreeWidget>
#include <QTreeWidgetItem>

#include "Emu/IdManager.h"
Expand Down Expand Up @@ -152,13 +153,16 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent)
{
setWindowTitle(tr("Kernel Explorer"));
setObjectName("kernel_explorer");
setAttribute(Qt::WA_DeleteOnClose);
setMinimumSize(QSize(700, 450));

QVBoxLayout* vbox_panel = new QVBoxLayout();
QHBoxLayout* hbox_buttons = new QHBoxLayout();
QPushButton* button_refresh = new QPushButton(tr("Refresh"), this);
//QPushButton* button_log = new QPushButton(tr("Log"), this); // TODO

hbox_buttons->addWidget(button_refresh);
//hbox_buttons->addSpacing(4);
//hbox_buttons->addWidget(button_log);
hbox_buttons->addStretch();

m_tree = new QTreeWidget(this);
Expand All @@ -167,11 +171,10 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent)
m_tree->header()->close();

// Merge and display everything
vbox_panel->addSpacing(10);
vbox_panel->addSpacing(8);
vbox_panel->addLayout(hbox_buttons);
vbox_panel->addSpacing(10);
vbox_panel->addSpacing(8);
vbox_panel->addWidget(m_tree);
vbox_panel->addSpacing(10);
setLayout(vbox_panel);

// Events
Expand All @@ -180,6 +183,12 @@ kernel_explorer::kernel_explorer(QWidget* parent) : QDialog(parent)
Update();
}

void kernel_explorer::closeEvent(QCloseEvent *event)
{
QDialog::closeEvent(event);
Q_EMIT FrameClosed();
}

void kernel_explorer::Update()
{
const auto dct = g_fxo->get<lv2_memory_container>();
Expand Down
9 changes: 7 additions & 2 deletions rpcs3/rpcs3qt/kernel_explorer.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include <QDialog>
#include <QTreeWidget>

#include "util/types.hpp"
class QTreeWidget;

class kernel_explorer : public QDialog
{
Expand All @@ -30,6 +30,11 @@ class kernel_explorer : public QDialog
private:
QTreeWidget* m_tree;

private Q_SLOTS:
void closeEvent(QCloseEvent* event) override;

Q_SIGNALS:
void FrameClosed();

public Q_SLOTS:
void Update();
};
18 changes: 11 additions & 7 deletions rpcs3/rpcs3qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,6 @@ void main_window::EnableMenus(bool enabled)
ui->sysSendExitAct->setEnabled(enabled);

// Tools
ui->toolskernel_explorerAct->setEnabled(enabled);
ui->toolsmemory_viewerAct->setEnabled(enabled);
ui->toolsRsxDebuggerAct->setEnabled(enabled);
ui->toolsStringSearchAct->setEnabled(enabled);
Expand Down Expand Up @@ -1757,12 +1756,6 @@ void main_window::CreateConnects()
cgdw->show();
});

connect(ui->toolskernel_explorerAct, &QAction::triggered, [this]
{
kernel_explorer* kernelExplorer = new kernel_explorer(this);
kernelExplorer->show();
});

connect(ui->toolsmemory_viewerAct, &QAction::triggered, [this]
{
memory_viewer_panel* mvp = new memory_viewer_panel(this);
Expand Down Expand Up @@ -1795,6 +1788,11 @@ void main_window::CreateConnects()
m_gui_settings->SetValue(gui::mw_logger, checked);
});

connect(ui->showKernelExplorerAct, &QAction::triggered, [this](bool checked)
{
checked ? (m_kernel_explorer->Update(), m_kernel_explorer->show()) : m_kernel_explorer->hide();
});

connect(ui->showGameListAct, &QAction::triggered, [this](bool checked)
{
checked ? m_game_list_frame->show() : m_game_list_frame->hide();
Expand Down Expand Up @@ -1971,6 +1969,7 @@ void main_window::CreateDockWindows()
m_debugger_frame->setObjectName("debugger");
m_log_frame = new log_frame(m_gui_settings, m_mw);
m_log_frame->setObjectName("logger");
m_kernel_explorer = new kernel_explorer(m_mw);

m_mw->addDockWidget(Qt::LeftDockWidgetArea, m_game_list_frame);
m_mw->addDockWidget(Qt::LeftDockWidgetArea, m_log_frame);
Expand All @@ -1988,6 +1987,11 @@ void main_window::CreateDockWindows()
}
});

connect(m_kernel_explorer, &kernel_explorer::FrameClosed, [this]()
{
ui->showKernelExplorerAct->setChecked(false);
});

connect(m_debugger_frame, &debugger_frame::DebugFrameClosed, [this]()
{
if (ui->showDebuggerAct->isChecked())
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/rpcs3qt/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class game_list_frame;
class gui_settings;
class emu_settings;
class persistent_settings;
class kernel_explorer;

struct gui_game_info;

Expand Down Expand Up @@ -164,6 +165,7 @@ private Q_SLOTS:
log_frame* m_log_frame = nullptr;
debugger_frame* m_debugger_frame = nullptr;
game_list_frame* m_game_list_frame = nullptr;
kernel_explorer* m_kernel_explorer;
std::shared_ptr<gui_settings> m_gui_settings;
std::shared_ptr<emu_settings> m_emu_settings;
std::shared_ptr<persistent_settings> m_persistent_settings;
Expand Down
18 changes: 9 additions & 9 deletions rpcs3/rpcs3qt/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
<string>Utilities</string>
</property>
<addaction name="toolsCgDisasmAct"/>
<addaction name="toolskernel_explorerAct"/>
<addaction name="toolsmemory_viewerAct"/>
<addaction name="toolsRsxDebuggerAct"/>
<addaction name="toolsStringSearchAct"/>
Expand Down Expand Up @@ -297,6 +296,7 @@
</widget>
<addaction name="showDebuggerAct"/>
<addaction name="showLogAct"/>
<addaction name="showKernelExplorerAct"/>
<addaction name="separator"/>
<addaction name="showTitleBarsAct"/>
<addaction name="showToolBarAct"/>
Expand Down Expand Up @@ -588,14 +588,6 @@
<string>Cg Disasm</string>
</property>
</action>
<action name="toolskernel_explorerAct">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Kernel Explorer</string>
</property>
</action>
<action name="toolsmemory_viewerAct">
<property name="enabled">
<bool>false</bool>
Expand Down Expand Up @@ -641,6 +633,14 @@
<string>Show Log/TTY</string>
</property>
</action>
<action name="showKernelExplorerAct">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Show Kernel Explorer</string>
</property>
</action>
<action name="aboutAct">
<property name="text">
<string>About RPCS3</string>
Expand Down

0 comments on commit 92040bc

Please sign in to comment.