diff --git a/src/edittab.cpp b/src/edittab.cpp index b433cb4e4..34b4e2648 100644 --- a/src/edittab.cpp +++ b/src/edittab.cpp @@ -20,6 +20,7 @@ #include "processorhandler.h" #include "ripessettings.h" #include "symbolnavigator.h" +#include "wasmSupport.h" namespace Ripes { @@ -87,6 +88,8 @@ EditTab::EditTab(QToolBar *toolbar, QWidget *parent) &EditTab::sourceTypeChanged); connect(m_ui->setCInput, &QRadioButton::toggled, m_buildAction, &QAction::setEnabled); + // C compiler is not yet supported on WASM. + disableIfWasm(m_ui->setCInput); // Ensure that changes to the current compiler path will disable C input, if // the compiler is invalid diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 879a54de3..95120eacb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -15,6 +15,7 @@ #include "syscall/syscallviewer.h" #include "syscall/systemio.h" #include "version/version.h" +#include "wasmSupport.h" #include "fancytabbar/fancytabbar.h" @@ -204,7 +205,6 @@ void MainWindow::setupMenus() { connect(loadAction, &QAction::triggered, this, [=] { this->loadFileTriggered(); }); m_ui->menuFile->addAction(loadAction); - m_ui->menuFile->addSeparator(); auto *examplesMenu = m_ui->menuFile->addMenu("Load Example..."); @@ -231,7 +231,6 @@ void MainWindow::setupMenus() { &EditTab::editorStateChanged, saveAction, [saveAsAction](bool enabled) { saveAsAction->setEnabled(enabled); }); m_ui->menuFile->addAction(saveAsAction); - m_ui->menuFile->addSeparator(); const QIcon exitIcon = QIcon(":/icons/cancel.svg"); @@ -246,6 +245,9 @@ void MainWindow::setupMenus() { m_ui->menuView->addAction( static_cast(m_tabWidgets.at(ProcessorTabID).tab) ->m_displayValuesAction); + + // File I/O is not yet supported on WASM due to sandboxing. + disableIfWasm(QList{loadAction, saveAction, saveAsAction, exitAction}); } MainWindow::~MainWindow() { delete m_ui; } @@ -360,8 +362,8 @@ void MainWindow::loadFileTriggered() { } void MainWindow::wiki() { - QDesktopServices::openUrl( - QUrl(QString("https://github.com/mortbopet/Ripes/blob/master/docs/README.md"))); + QDesktopServices::openUrl(QUrl(QString( + "https://github.com/mortbopet/Ripes/blob/master/docs/README.md"))); } void MainWindow::version() { diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index e34faf1ff..441e2978b 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -21,6 +21,7 @@ #include "utilities/hexspinbox.h" #include "utilities/scrolleventfilter.h" +#include "wasmSupport.h" namespace Ripes { @@ -148,7 +149,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) // Create settings pages addPage("Environment", createEnvironmentPage()); addPage("Simulator", createSimulatorPage()); - addPage("Compiler", createCompilerPage()); + auto *compilerPage = createCompilerPage(); + addPage("Compiler", compilerPage); + // No C compiler support (yet) for wasm. + disableIfWasm(compilerPage); addPage("Editor", createEditorPage()); m_ui->settingsList->setCurrentRow( diff --git a/src/wasmSupport.h b/src/wasmSupport.h new file mode 100644 index 000000000..2643f060b --- /dev/null +++ b/src/wasmSupport.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +namespace Ripes { + +// Disable a widget if we are running in a wasm environment. +template +inline void disableIfWasm(T *widget) { +#ifdef __EMSCRIPTEN__ + widget->setEnabled(false); +#endif +} + +// Disables a list of widgets if we are running in a wasm environment. +template +inline void disableIfWasm(TList widgets) { + for (auto *widget : widgets) + disableIfWasm(widget); +} + +} // namespace Ripes \ No newline at end of file