Skip to content

Commit

Permalink
Minor fixes for JS global variable viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
thor2016 committed Jan 17, 2024
1 parent dc2d3c2 commit 1dde9e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/drivers/Qt/QtScriptManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ void QScriptDialog_t::closeWindow(void)
deleteLater();
}
//----------------------------------------------------
void QScriptDialog_t::loadPropertyTree(QJSValue& object, QTreeWidgetItem* parentItem)
void QScriptDialog_t::loadPropertyTree(QJSValue& object, JsPropertyItem* parentItem)
{
QJSValueIterator it(object);

Expand All @@ -755,7 +755,7 @@ void QScriptDialog_t::loadPropertyTree(QJSValue& object, QTreeWidgetItem* parent

if (!isPrototype)
{
QTreeWidgetItem* item = new QTreeWidgetItem();
JsPropertyItem* item = new JsPropertyItem();
QString value;
const char *type = "unknown";

Expand Down Expand Up @@ -833,6 +833,7 @@ void QScriptDialog_t::loadPropertyTree(QJSValue& object, QTreeWidgetItem* parent
item->setText(0, it.name());
item->setText(1, type);
item->setText(2, value);
item->jsValue = child;

if (parentItem == nullptr)
{
Expand Down Expand Up @@ -1055,6 +1056,7 @@ void QScriptDialog_t::startScript(void)

QJSValue globals = scriptInstance->getEngine()->globalObject();

propTree->clear();
loadPropertyTree(globals);

FCEU_WRAPPER_UNLOCK();
Expand Down
18 changes: 17 additions & 1 deletion src/drivers/Qt/QtScriptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@ public slots:
void frameFinishedUpdate();
};

class JsPropertyItem : public QTreeWidgetItem
{
public:
JsPropertyItem()
: QTreeWidgetItem()
{
}

virtual ~JsPropertyItem() override
{
}

QJSValue jsValue;
QMap<QString, JsPropertyItem*> childMap;
};

class QScriptDialog_t : public QDialog
{
Q_OBJECT
Expand All @@ -153,7 +169,7 @@ class QScriptDialog_t : public QDialog
protected:
void closeEvent(QCloseEvent *bar);
void openJSKillMessageBox(void);
void loadPropertyTree(QJSValue& val, QTreeWidgetItem* parentItem = nullptr);
void loadPropertyTree(QJSValue& val, JsPropertyItem* parentItem = nullptr);

QTimer *periodicTimer;
QLineEdit *scriptPath;
Expand Down

0 comments on commit 1dde9e7

Please sign in to comment.