connected to gui

This commit is contained in:
zanostro 2025-11-12 19:42:59 +01:00
parent 8a6e916876
commit d77a32e6e6
8 changed files with 126 additions and 26 deletions

View file

@ -7,7 +7,6 @@ CMakeCache.txt
CMakeFiles/
CMakeScripts/
cmake_install.cmake
Makefile
*.cmake
!CMakeLists.txt

59
simulator_SIC_XE/Makefile Normal file
View file

@ -0,0 +1,59 @@
# Simple Makefile wrapper to configure, build and run the CMake project.
# Usage:
# make # builds (default)
# make build # configure + build
# make run # build (if needed) and run the executable
# make clean # run CMake clean (or remove build files)
# make distclean # remove build dir and generated targets
CMAKE ?= cmake
BUILD_DIR := build
CMAKE_BUILD_TYPE ?= Release
TARGET := target/bin/simulator_exec
GUI_TARGET := target/bin/simulator_qt
.PHONY: all configure build run clean distclean
all: build
configure:
@echo "Configuring (build dir: $(BUILD_DIR), type: $(CMAKE_BUILD_TYPE))"
$(CMAKE) -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
build: configure
@echo "Building..."
$(CMAKE) --build $(BUILD_DIR) -j$(shell nproc)
run: build
@echo "Running primary target..."
# Prefer GUI if available, otherwise fall back to console executable
@if [ -x "$(GUI_TARGET)" ]; then \
echo "Launching GUI: $(GUI_TARGET)"; \
sh -c 'nohup env QT_QPA_PLATFORM=xcb ./$(GUI_TARGET) >/dev/null 2>&1 & echo $! > "$(BUILD_DIR)/simulator_qt.pid"'; \
elif [ -x "$(TARGET)" ]; then \
@./$(TARGET); \
else \
echo "No runnable target found (tried $(GUI_TARGET) and $(TARGET))."; exit 1; \
fi
.PHONY: run-gui
run-gui: build
@echo "Running GUI target ($(GUI_TARGET))"
@if [ -x "$(GUI_TARGET)" ]; then \
echo "Starting GUI..."; ./$(GUI_TARGET) -platform xcb; \
else \
echo "GUI executable not found: $(GUI_TARGET)"; exit 1; \
fi
.PHONY: build-gui
build-gui: configure
@echo "Building GUI (and core)..."
$(CMAKE) --build $(BUILD_DIR) -j$(shell nproc) --target simulator_qt || true
clean:
@echo "Cleaning build (CMake clean)..."
-$(CMAKE) --build $(BUILD_DIR) --target clean || true
distclean:
@echo "Removing build artifacts and generated files..."
-rm -rf $(BUILD_DIR) CMakeFiles CMakeCache.txt cmake_install.cmake target/bin/*

View file

@ -30,19 +30,20 @@ endif()
set(GUI_SRCS
main.cpp
MainWindow.cpp
mainwindow.cpp
MachineController.cpp
)
set(GUI_HDRS
MainWindow.h
mainwindow.h
MachineController.h
)
add_executable(simulator_qt ${GUI_SRCS} ${GUI_HDRS})
# Use top-level include folder (works when added with add_subdirectory)
target_include_directories(simulator_qt PRIVATE ${CMAKE_SOURCE_DIR}/include)
# Allow the generated UI headers (from AUTOUIC) to be found in the build dir
# and also include the top-level include folder (works when added with add_subdirectory)
target_include_directories(simulator_qt PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include)
# Link to core library target (must be defined by top-level CMake)
target_link_libraries(simulator_qt PRIVATE simulator_lib ${QT_LIB})

View file

@ -1,20 +0,0 @@
#include "MainWindow.h"
#include "MachineController.h"
#include <QLabel>
#include <QVBoxLayout>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QWidget *central = new QWidget(this);
auto *layout = new QVBoxLayout(central);
auto *label = new QLabel("SIC/XE Simulator — GUI stub", central);
label->setAlignment(Qt::AlignCenter);
layout->addWidget(label);
setCentralWidget(central);
m_controller = new MachineController(this);
setWindowTitle("SIC/XE Simulator");
}
MainWindow::~MainWindow() = default;

View file

@ -1,5 +1,5 @@
#include <QApplication>
#include "MainWindow.h"
#include "mainwindow.h"
int main(int argc, char **argv) {
QApplication app(argc, argv);

View file

@ -0,0 +1,14 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}

View file

@ -0,0 +1,22 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View file

@ -0,0 +1,25 @@
<?xml version='1.0'?>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>MainWindow</class>
<widget name="MainWindow" class="QMainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget name="menubar" class="QMenuBar"/>
<widget name="centralwidget" class="QWidget"/>
<widget name="statusbar" class="QStatusBar"/>
</widget>
<pixmapfunction/>
<connections/>
</ui>