[Qt] Add text editor

This commit is contained in:
wheremyfoodat 2023-12-16 15:51:45 +02:00
parent eb23d7eab3
commit c57f2db6c0
8 changed files with 72 additions and 6 deletions

View file

@ -36,7 +36,9 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
connect(configureAction, &QAction::triggered, this, [this]() { configWindow->show(); });
auto dumpRomFSAction = toolsMenu->addAction(tr("Dump RomFS"));
auto luaEditorAction = toolsMenu->addAction(tr("Open Lua Editor"));
connect(dumpRomFSAction, &QAction::triggered, this, &MainWindow::dumpRomFS);
connect(luaEditorAction, &QAction::triggered, this, &MainWindow::openLuaEditor);
auto aboutAction = aboutMenu->addAction(tr("About Panda3DS"));
connect(aboutAction, &QAction::triggered, this, &MainWindow::showAboutMenu);
@ -44,6 +46,7 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
// Set up misc objects
aboutWindow = new AboutWindow(nullptr);
configWindow = new ConfigWindow(this);
luaEditor = new TextEditorWindow(this, "script.lua", "");
emu = new Emulator();
emu->setOutputSize(screen.surfaceWidth, screen.surfaceHeight);
@ -133,6 +136,7 @@ MainWindow::~MainWindow() {
delete menuBar;
delete aboutWindow;
delete configWindow;
delete luaEditor;
}
// Send a message to the emulator thread. Lock the mutex and just push back to the vector.
@ -181,6 +185,8 @@ void MainWindow::showAboutMenu() {
about.exec();
}
void MainWindow::openLuaEditor() { luaEditor->show(); }
void MainWindow::dispatchMessage(const EmulatorMessage& message) {
switch (message.type) {
case MessageType::LoadROM:

View file

@ -0,0 +1,20 @@
#include "panda_qt/text_editor.hpp"
#include <QVBoxLayout>
using namespace Zep;
TextEditorWindow::TextEditorWindow(QWidget* parent, const std::string& filename, const std::string& initialText)
: QDialog(parent), zepWidget(this, qApp->applicationDirPath().toStdString(), fontSize) {
resize(600, 600);
// Register our extensions
ZepRegressExCommand::Register(zepWidget.GetEditor());
ZepReplExCommand::Register(zepWidget.GetEditor(), &replProvider);
zepWidget.GetEditor().SetGlobalMode(Zep::ZepMode_Standard::StaticName());
zepWidget.GetEditor().InitWithText(filename, initialText);
QVBoxLayout* mainLayout = new QVBoxLayout();
setLayout(mainLayout);
mainLayout->addWidget(&zepWidget);
}

2
src/panda_qt/zep.cpp Normal file
View file

@ -0,0 +1,2 @@
#define ZEP_SINGLE_HEADER_BUILD
#include "zep.h"