comment out bunch of qt things

This commit is contained in:
SimoZ64
2025-04-16 15:20:12 +02:00
parent a27ccf87d8
commit 0cb479dda8
13 changed files with 125 additions and 226 deletions

View File

@@ -1,24 +1,17 @@
#pragma once #pragma once
#include <JSONUtils.hpp> #include <JSONUtils.hpp>
#include <QCheckBox>
#include <QSlider>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
class AudioSettings final : public QWidget { class AudioSettings final {
std::unique_ptr<QCheckBox> lockChannels = std::make_unique<QCheckBox>(); //std::unique_ptr<QCheckBox> lockChannels = std::make_unique<QCheckBox>();
std::unique_ptr<QLabel> labelLock = std::make_unique<QLabel>("Lock channels:"); //std::unique_ptr<QLabel> labelLock = std::make_unique<QLabel>("Lock channels:");
std::unique_ptr<QLabel> labelL = std::make_unique<QLabel>("Volume L"); //std::unique_ptr<QLabel> labelL = std::make_unique<QLabel>("Volume L");
std::unique_ptr<QLabel> labelR = std::make_unique<QLabel>("Volume R"); //std::unique_ptr<QLabel> labelR = std::make_unique<QLabel>("Volume R");
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>(); //std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
std::unique_ptr<QHBoxLayout> volLayout = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> volLayout = std::make_unique<QHBoxLayout>();
Q_OBJECT //Q_OBJECT
public: public:
std::unique_ptr<QSlider> volumeL = std::make_unique<QSlider>(Qt::Horizontal), //std::unique_ptr<QSlider> volumeL = std::make_unique<QSlider>(Qt::Horizontal),
volumeR = std::make_unique<QSlider>(Qt::Horizontal); // volumeR = std::make_unique<QSlider>(Qt::Horizontal);
explicit AudioSettings(nlohmann::json &); explicit AudioSettings(nlohmann::json &);
nlohmann::json &settings; nlohmann::json &settings;
Q_SIGNALS:
void modified();
}; };

View File

@@ -121,8 +121,7 @@ add_executable(kaizen
InputSettings.hpp InputSettings.hpp
InputSettings.cpp InputSettings.cpp
Debugger.hpp Debugger.hpp
Debugger.cpp Debugger.cpp)
CodeModel.hpp)
target_link_libraries(kaizen PUBLIC SDL3::SDL3 SDL3::SDL3-static cflags::cflags discord-rpc fmt mio nlohmann_json parallel-rdp capstone backend) target_link_libraries(kaizen PUBLIC SDL3::SDL3 SDL3::SDL3-static cflags::cflags discord-rpc fmt mio nlohmann_json parallel-rdp capstone backend)
target_compile_definitions(kaizen PUBLIC SDL_MAIN_HANDLED) target_compile_definitions(kaizen PUBLIC SDL_MAIN_HANDLED)

View File

@@ -1,18 +1,12 @@
#pragma once #pragma once
#include <JSONUtils.hpp> #include <JSONUtils.hpp>
#include <QComboBox>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
class CPUSettings final : public QWidget { class CPUSettings final {
std::unique_ptr<QComboBox> cpuTypes = std::make_unique<QComboBox>(); //std::unique_ptr<QComboBox> cpuTypes = std::make_unique<QComboBox>();
std::unique_ptr<QLabel> label = std::make_unique<QLabel>("CPU type:"); //std::unique_ptr<QLabel> label = std::make_unique<QLabel>("CPU type:");
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>(); //std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
Q_OBJECT //Q_OBJECT
public: public:
explicit CPUSettings(nlohmann::json &); explicit CPUSettings(nlohmann::json &);
nlohmann::json &settings; nlohmann::json &settings;
Q_SIGNALS:
void modified();
}; };

View File

@@ -1,12 +0,0 @@
#pragma once
#include <QAbstractTableModel>
class CodeModel final : public QAbstractTableModel {
Q_OBJECT
public:
~CodeModel() override = default;
explicit CodeModel(QObject *parent = nullptr) {}
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override { return 1; }
[[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override { return 2; }
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override { return {}; }
};

View File

@@ -1,19 +1,6 @@
#pragma once #pragma once
#include <QDockWidget>
#include <QWidget>
#include <QTreeView>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <CodeModel.hpp>
class Debugger final : public QWidget { class Debugger final {
std::unique_ptr<QDockWidget> disassembly = std::make_unique<QDockWidget>(),
cpuState = std::make_unique<QDockWidget>();
std::unique_ptr<QTreeView> codeView = std::make_unique<QTreeView>(disassembly.get()),
registers = std::make_unique<QTreeView>(cpuState.get());
std::unique_ptr<QHBoxLayout> horLayout = std::make_unique<QHBoxLayout>();
std::unique_ptr<QVBoxLayout> verLayout = std::make_unique<QVBoxLayout>();
std::unique_ptr<CodeModel> codeModel = std::make_unique<CodeModel>();
public: public:
Debugger(); Debugger();

View File

@@ -1,12 +1,14 @@
#include <Core.hpp> #include <Core.hpp>
#include <EmuThread.hpp> #include <EmuThread.hpp>
EmuThread::EmuThread(const std::shared_ptr<n64::Core> &core, QLabel &fps, RenderWidget &renderWidget, EmuThread::EmuThread(const std::shared_ptr<n64::Core> &core, std::string &fps, RenderWidget &renderWidget,
SettingsWindow &settings) noexcept : SettingsWindow &settings) noexcept :
renderWidget(renderWidget), core(core), settings(settings), fps(fps) {} renderWidget(renderWidget), core(core), settings(settings), fps(fps) {}
void EmuThread::run() noexcept { void EmuThread::start() noexcept {
core->parallel.Init(renderWidget.qtVkInstanceFactory, renderWidget.wsiPlatform, renderWidget.windowInfo, thread = std::thread([this]() {
isRunning = true;
core->parallel.Init(renderWidget.imGuiVkInstanceFactory, renderWidget.wsiPlatform, renderWidget.windowInfo,
core->cpu->GetMem().GetRDRAMPtr()); core->cpu->GetMem().GetRDRAMPtr());
auto lastSample = std::chrono::high_resolution_clock::now(); auto lastSample = std::chrono::high_resolution_clock::now();
@@ -14,9 +16,9 @@ void EmuThread::run() noexcept {
auto sampledFps = 0; auto sampledFps = 0;
static bool oneSecondPassed = false; static bool oneSecondPassed = false;
fps.setText(fmt::format("{:.2f} FPS", 1000.0 / avgFps).c_str()); fps = fmt::format("{:.2f} FPS", 1000.0 / avgFps);
while (!isInterruptionRequested()) { while (!interruptionRequested) {
const auto startFrameTime = std::chrono::high_resolution_clock::now(); const auto startFrameTime = std::chrono::high_resolution_clock::now();
if (!core->pause) { if (!core->pause) {
core->Run(settings.getVolumeL(), settings.getVolumeR()); core->Run(settings.getVolumeL(), settings.getVolumeR());
@@ -42,12 +44,13 @@ void EmuThread::run() noexcept {
lastSample = endFrameTime; lastSample = endFrameTime;
avgFps /= sampledFps; avgFps /= sampledFps;
sampledFps = 0; sampledFps = 0;
fps.setText(fmt::format("{:.2f} FPS", 1000.0 / avgFps).c_str()); fps = fmt::format("{:.2f} FPS", 1000.0 / avgFps);
} }
} }
SetRender(false); SetRender(false);
Stop(); Stop();
isRunning = false;
});
} }
void EmuThread::TogglePause() const noexcept { void EmuThread::TogglePause() const noexcept {

View File

@@ -12,14 +12,18 @@ class EmuThread final {
RenderWidget &renderWidget; RenderWidget &renderWidget;
public: public:
explicit EmuThread(const std::shared_ptr<n64::Core> &, RenderWidget &, SettingsWindow &) noexcept; explicit EmuThread(const std::shared_ptr<n64::Core> &, std::string &, RenderWidget &, SettingsWindow &) noexcept;
void run() noexcept; void start() noexcept;
void TogglePause() const noexcept; void TogglePause() const noexcept;
void SetRender(bool v) const noexcept; void SetRender(bool v) const noexcept;
void Reset() const noexcept; void Reset() const noexcept;
void Stop() const noexcept; void Stop() const noexcept;
void requestInterruption() { interruptionRequested = true; }
bool interruptionRequested = false, isRunning = false;
std::shared_ptr<n64::Core> core; std::shared_ptr<n64::Core> core;
SettingsWindow &settings; SettingsWindow &settings;
std::string fps;
std::thread thread;
}; };

View File

@@ -1,14 +1,8 @@
#pragma once #pragma once
#include <JSONUtils.hpp> #include <JSONUtils.hpp>
#include <QLabel> #include <unordered_map>
#include <QPushButton>
#include <QWidget>
#include <QKeyEvent>
#include <QVBoxLayout>
#include <QComboBox>
#include <QTimer>
class InputSettings final : public QWidget { class InputSettings final {
bool grabbing = false; bool grabbing = false;
int whichGrabbing = -1; int whichGrabbing = -1;
@@ -17,29 +11,26 @@ class InputSettings final : public QWidget {
std::unordered_map<u32, std::string> gamepadIndexes{}; std::unordered_map<u32, std::string> gamepadIndexes{};
std::unique_ptr<QHBoxLayout> AB = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> AB = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> ZStart = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> ZStart = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> LR = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> LR = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> DupDdown = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> DupDdown = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> DleftDright = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> DleftDright = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> CupCdown = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> CupCdown = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> CleftCright = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> CleftCright = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> AupAdown = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> AupAdown = std::make_unique<QHBoxLayout>();
std::unique_ptr<QHBoxLayout> AleftAright = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> AleftAright = std::make_unique<QHBoxLayout>();
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>(); //std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
std::array<std::unique_ptr<QPushButton>, 18> kbButtons; //std::array<std::unique_ptr<QPushButton>, 18> kbButtons;
std::array<std::unique_ptr<QLabel>, 18> buttonLabels; //std::array<std::unique_ptr<QLabel>, 18> buttonLabels;
std::unique_ptr<QHBoxLayout> deviceComboBoxLayout = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> deviceComboBoxLayout = std::make_unique<QHBoxLayout>();
QTimer refresh, pollGamepad; //QTimer refresh, pollGamepad;
std::unique_ptr<QLabel> devicesLabel = std::make_unique<QLabel>("Device:"); //std::unique_ptr<QLabel> devicesLabel = std::make_unique<QLabel>("Device:");
std::unique_ptr<QComboBox> devices = std::make_unique<QComboBox>(); //std::unique_ptr<QComboBox> devices = std::make_unique<QComboBox>();
Q_OBJECT //Q_OBJECT
public: public:
bool selectedDeviceIsNotKeyboard = false; bool selectedDeviceIsNotKeyboard = false;
explicit InputSettings(nlohmann::json &); explicit InputSettings(nlohmann::json &);
nlohmann::json &settings; nlohmann::json &settings;
void keyPressEvent(QKeyEvent *) override; //std::array<Qt::Key, 18> GetMappedKeys() const;
std::array<Qt::Key, 18> GetMappedKeys() const;
Q_SIGNALS:
void modified();
}; };

View File

@@ -1,9 +1,5 @@
#include <Core.hpp> #include <Core.hpp>
#include <KaizenQt.hpp> #include <KaizenQt.hpp>
#include <QApplication>
#include <QDropEvent>
#include <QMessageBox>
#include <QMimeData>
namespace fs = std::filesystem; namespace fs = std::filesystem;
@@ -44,17 +40,6 @@ void KaizenQt::ConnectMainWindowSignalsToSlots() noexcept {
connect(mainWindow.get(), &MainWindow::Pause, emuThread.get(), &EmuThread::TogglePause); connect(mainWindow.get(), &MainWindow::Pause, emuThread.get(), &EmuThread::TogglePause);
} }
void KaizenQt::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
}
}
void KaizenQt::dropEvent(QDropEvent *event) {
const auto path = event->mimeData()->urls()[0].toLocalFile();
LoadROM(path);
}
void KaizenQt::LoadROM(const QString &path) const noexcept { void KaizenQt::LoadROM(const QString &path) const noexcept {
mainWindow->actionPause->setEnabled(true); mainWindow->actionPause->setEnabled(true);
mainWindow->actionReset->setEnabled(true); mainWindow->actionReset->setEnabled(true);
@@ -69,8 +54,7 @@ void KaizenQt::LoadROM(const QString &path) const noexcept {
void KaizenQt::Quit() const noexcept { void KaizenQt::Quit() const noexcept {
if (emuThread) { if (emuThread) {
emuThread->requestInterruption(); emuThread->requestInterruption();
while (emuThread->isRunning()) while (emuThread->isRunning) {}
;
} }
QApplication::quit(); QApplication::quit();
} }

View File

@@ -4,23 +4,7 @@
#include <MainWindow.hpp> #include <MainWindow.hpp>
#include <SettingsWindow.hpp> #include <SettingsWindow.hpp>
#include <log.hpp> #include <log.hpp>
#include <memory>
enum class CompositorCategory { Windows, MacOS, XCB, Wayland };
static CompositorCategory GetOSCompositorCategory() {
const QString platform_name = QGuiApplication::platformName();
if (platform_name == QStringLiteral("windows"))
return CompositorCategory::Windows;
if (platform_name == QStringLiteral("xcb"))
return CompositorCategory::XCB;
if (platform_name == QStringLiteral("wayland") || platform_name == QStringLiteral("wayland-egl"))
return CompositorCategory::Wayland;
if (platform_name == QStringLiteral("cocoa") || platform_name == QStringLiteral("ios"))
return CompositorCategory::MacOS;
Util::error("Unknown Qt platform!");
return CompositorCategory::Windows;
}
class KaizenQt { class KaizenQt {
public: public:

View File

@@ -1,41 +1,29 @@
#pragma once #pragma once
#include <QApplication>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QKeyEvent>
#include <QMessageBox>
#include <QSlider>
#include <QMenu>
#include <QMenuBar>
#include <QStatusBar>
#include <RenderWidget.hpp> #include <RenderWidget.hpp>
#include <Debugger.hpp> #include <Debugger.hpp>
class MainWindow final : public QMainWindow { class MainWindow final {
Q_OBJECT
public: public:
explicit MainWindow(const std::shared_ptr<n64::Core> &) noexcept; explicit MainWindow(const std::shared_ptr<n64::Core> &) noexcept;
std::unique_ptr<QAction> actionOpenDebuggerWindow{}; //std::unique_ptr<QAction> actionOpenDebuggerWindow{};
std::unique_ptr<QAction> actionAbout{}; //std::unique_ptr<QAction> actionAbout{};
std::unique_ptr<QAction> actionOpen{}; //std::unique_ptr<QAction> actionOpen{};
std::unique_ptr<QAction> actionExit{}; //std::unique_ptr<QAction> actionExit{};
std::unique_ptr<QAction> actionPause{}; //std::unique_ptr<QAction> actionPause{};
std::unique_ptr<QAction> actionReset{}; //std::unique_ptr<QAction> actionReset{};
std::unique_ptr<QAction> actionStop{}; //std::unique_ptr<QAction> actionStop{};
std::unique_ptr<QAction> actionSettings{}; //std::unique_ptr<QAction> actionSettings{};
std::unique_ptr<QWidget> centralwidget{}; //std::unique_ptr<QWidget> centralwidget{};
std::unique_ptr<QVBoxLayout> verticalLayout{}; //std::unique_ptr<QVBoxLayout> verticalLayout{};
std::unique_ptr<RenderWidget> vulkanWidget{}; //std::unique_ptr<RenderWidget> vulkanWidget{};
std::unique_ptr<QMenuBar> menubar{}; //std::unique_ptr<QMenuBar> menubar{};
std::unique_ptr<QMenu> menuFile{}; //std::unique_ptr<QMenu> menuFile{};
std::unique_ptr<QMenu> menuEmulation{}; //std::unique_ptr<QMenu> menuEmulation{};
std::unique_ptr<QMenu> menuTools{}; //std::unique_ptr<QMenu> menuTools{};
std::unique_ptr<QMenu> menuAbout{}; //std::unique_ptr<QMenu> menuAbout{};
std::unique_ptr<QStatusBar> statusbar{}; //std::unique_ptr<QStatusBar> statusbar{};
std::unique_ptr<QLabel> fpsCounter{}; //std::unique_ptr<QLabel> fpsCounter{};
private: private:
void Retranslate(); void Retranslate();
@@ -43,10 +31,9 @@ private:
bool textPauseToggle = false; bool textPauseToggle = false;
Q_SIGNALS:
void OpenDebugger(); void OpenDebugger();
void OpenSettings(); void OpenSettings();
void OpenROM(const QString &rom_file); void OpenROM(const std::string &rom_file);
void Exit(); void Exit();
void Reset(); void Reset();
void Stop(); void Stop();

View File

@@ -1,5 +1,4 @@
#pragma once #pragma once
#undef signals
#include <ParallelRDPWrapper.hpp> #include <ParallelRDPWrapper.hpp>
#include <SDL3/SDL.h> #include <SDL3/SDL.h>
#include <SDL3/SDL_vulkan.h> #include <SDL3/SDL_vulkan.h>

View File

@@ -2,43 +2,29 @@
#include <AudioSettings.hpp> #include <AudioSettings.hpp>
#include <CPUSettings.hpp> #include <CPUSettings.hpp>
#include <InputSettings.hpp> #include <InputSettings.hpp>
#include <QFileIconProvider> #include <memory>
#include <QPushButton>
#include <QTabWidget>
#include <QWidget>
#include <QButtonGroup>
#include <QFileDialog>
#include <QGroupBox>
#include <QVBoxLayout>
class SettingsWindow final : public QWidget { class SettingsWindow final {
std::unique_ptr<QPushButton> cancel = std::make_unique<QPushButton>("Cancel"); //std::unique_ptr<QPushButton> cancel = std::make_unique<QPushButton>("Cancel");
std::unique_ptr<QPushButton> apply = std::make_unique<QPushButton>("Apply"); //std::unique_ptr<QPushButton> apply = std::make_unique<QPushButton>("Apply");
std::unique_ptr<QFileIconProvider> iconProv = std::make_unique<QFileIconProvider>(); //std::unique_ptr<QFileIconProvider> iconProv = std::make_unique<QFileIconProvider>();
std::unique_ptr<QPushButton> folderBtn = std::make_unique<QPushButton>(iconProv->icon(QFileIconProvider::Folder), ""); //std::unique_ptr<QPushButton> folderBtn = std::make_unique<QPushButton>(iconProv->icon(QFileIconProvider::Folder), "");
std::unique_ptr<QLabel> folderLabelPrefix = std::make_unique<QLabel>("Save files' path: "); //std::unique_ptr<QLabel> folderLabelPrefix = std::make_unique<QLabel>("Save files' path: ");
std::unique_ptr<QLabel> folderLabel; //std::unique_ptr<QLabel> folderLabel;
std::unique_ptr<QHBoxLayout> generalLayout = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> generalLayout = std::make_unique<QHBoxLayout>();
std::unique_ptr<QVBoxLayout> generalLayoutV = std::make_unique<QVBoxLayout>(); //std::unique_ptr<QVBoxLayout> generalLayoutV = std::make_unique<QVBoxLayout>();
std::unique_ptr<QTabWidget> tabs = std::make_unique<QTabWidget>(); //std::unique_ptr<QTabWidget> tabs = std::make_unique<QTabWidget>();
std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>(); //std::unique_ptr<QVBoxLayout> mainLayout = std::make_unique<QVBoxLayout>();
std::unique_ptr<QHBoxLayout> buttonsLayout = std::make_unique<QHBoxLayout>(); //std::unique_ptr<QHBoxLayout> buttonsLayout = std::make_unique<QHBoxLayout>();
Q_OBJECT
public: public:
SettingsWindow(); SettingsWindow();
void hideEvent(QHideEvent *event) override { emit gotClosed(); }
void showEvent(QShowEvent *event) override { emit gotOpened(); }
[[nodiscard]] float getVolumeL() const { return static_cast<float>(audioSettings->volumeL->value()) / 100.f; } [[nodiscard]] float getVolumeL() const { return static_cast<float>(audioSettings->volumeL->value()) / 100.f; }
[[nodiscard]] float getVolumeR() const { return static_cast<float>(audioSettings->volumeR->value()) / 100.f; } [[nodiscard]] float getVolumeR() const { return static_cast<float>(audioSettings->volumeR->value()) / 100.f; }
std::array<Qt::Key, 18> keyMap{}; //std::array<ImGui::Key, 18> keyMap{};
nlohmann::json settings; nlohmann::json settings;
std::unique_ptr<CPUSettings> cpuSettings{}; std::unique_ptr<CPUSettings> cpuSettings{};
std::unique_ptr<AudioSettings> audioSettings{}; std::unique_ptr<AudioSettings> audioSettings{};
std::unique_ptr<InputSettings> inputSettings{}; std::unique_ptr<InputSettings> inputSettings{};
std::unique_ptr<QWidget> generalSettings{}; //std::unique_ptr<QWidget> generalSettings{};
Q_SIGNALS:
void gotOpened();
void gotClosed();
void regrabKeyboard();
}; };